BsDockManagerLayout.h 3.3 KB

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