BsDockManagerLayout.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  54. * @brief Returns the root entry in the saved dock manager hierarchy.
  55. */
  56. Entry& getRootEntry() { return mRootEntry; }
  57. /**
  58. * @brief Removes widgets that can no longer be found (their names no longer reference a widget),
  59. * and removes containers with no widgets.
  60. */
  61. void pruneInvalidLeaves();
  62. private:
  63. Entry mRootEntry;
  64. /************************************************************************/
  65. /* RTTI */
  66. /************************************************************************/
  67. public:
  68. friend class DockManagerLayoutRTTI;
  69. static RTTITypeBase* getRTTIStatic();
  70. virtual RTTITypeBase* getRTTI() const override;
  71. };
  72. }