BsDockManagerLayout.h 3.3 KB

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