BsDockManagerLayout.h 3.2 KB

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