BsDockManagerLayout.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "BsIReflectable.h"
  6. #include "BsRect2I.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Used for storing a layout of widgets in a dock manager.
  11. *
  12. * @see DockManager
  13. */
  14. class DockManagerLayout : public IReflectable
  15. {
  16. public:
  17. /**
  18. * @brief A single entry in the dock layout which may contain
  19. * references to two other entries (non-leaf) or may contain
  20. * multiple widgets (leaf).
  21. */
  22. struct Entry
  23. {
  24. public:
  25. Entry();
  26. ~Entry();
  27. /**
  28. * @brief Creates a new leaf entry with the specified widgets.
  29. *
  30. * @param parent Parent of this leaf entry. Can be null for root.
  31. * @param childIdx Index of this entry in the parents child list. Can be 0 or 1.
  32. * @param widgetNames A list of all widgets opened in this entry, listed by name.
  33. */
  34. static Entry* createLeaf(Entry* parent, UINT32 childIdx,
  35. const Vector<String>& widgetNames);
  36. /**
  37. * @brief Creates a new container entry with the specified split data.
  38. *
  39. * @param parent Parent of this leaf entry. Can be null for root.
  40. * @param childIdx Index of this entry in the parents child list. Can be 0 or 1.
  41. * @param splitPosition Determines at what position(in percent) should this container be split.
  42. * @param horizontalSplit Whether the split is horizontal (true) or vertical (false).
  43. */
  44. static Entry* createContainer(Entry* parent, UINT32 childIdx, float splitPosition,
  45. bool horizontalSplit);
  46. Vector<String> widgetNames;
  47. bool isLeaf;
  48. float splitPosition;
  49. bool horizontalSplit;
  50. Entry* children[2];
  51. Entry* parent;
  52. };
  53. public:
  54. DockManagerLayout();
  55. ~DockManagerLayout();
  56. /**
  57. * @brief Returns the root entry in the saved dock manager hierarchy.
  58. */
  59. Entry& getRootEntry() { return mRootEntry; }
  60. /**
  61. * @brief Signals whether there is a maximized dock container in the layout.
  62. *
  63. * @param maximized True if maximized.
  64. * @param widgetName Name of the widgets on the maximized container.
  65. */
  66. void setIsMaximized(bool maximized, const Vector<String>& widgetNames);
  67. /**
  68. * @brief Check if the layout has a maximized container.
  69. */
  70. bool isMaximized() const { return mIsMaximized; }
  71. /**
  72. * @brief Returns widget names that are in the maximized container, if there is one.
  73. */
  74. const Vector<String>& getMaximizedWidgetNames() const { return mMaximizedWidgetNames; }
  75. /**
  76. * @brief Removes widgets that can no longer be found (their names no longer reference a widget),
  77. * and removes containers with no widgets.
  78. */
  79. void pruneInvalidLeaves();
  80. /**
  81. * @brief Makes a deep copy of this object.
  82. */
  83. DockManagerLayoutPtr clone();
  84. private:
  85. Entry mRootEntry;
  86. bool mIsMaximized;
  87. Vector<String> mMaximizedWidgetNames;
  88. /************************************************************************/
  89. /* RTTI */
  90. /************************************************************************/
  91. public:
  92. friend class DockManagerLayoutRTTI;
  93. static RTTITypeBase* getRTTIStatic();
  94. virtual RTTITypeBase* getRTTI() const override;
  95. };
  96. }