BsDockManager.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. namespace BansheeEditor
  4. {
  5. enum class DockLocation
  6. {
  7. Left, Right, Top, Bottom, Center
  8. };
  9. class DockManager
  10. {
  11. class DockContainer
  12. {
  13. public:
  14. DockContainer();
  15. ~DockContainer();
  16. void setArea(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
  17. void makeLeaf(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
  18. void addLeft(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
  19. void addRight(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
  20. void addTop(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
  21. void addBottom(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
  22. DockContainer* find(EditorWidgetContainer* widgetContainer);
  23. /**
  24. * @brief Searches for a DockContainer at the specified position.
  25. *
  26. * @param pos Position in the same space as DockContainer.
  27. *
  28. * @return null if it fails, else the found DockContainer at position.
  29. */
  30. DockContainer* findAtPos(const CM::Int2& pos);
  31. bool mIsLeaf;
  32. DockContainer* mChildren[2];
  33. EditorWidgetContainer* mWidgets;
  34. CM::INT32 mX, mY;
  35. CM::UINT32 mWidth, mHeight;
  36. float mSplitPosition;
  37. bool mIsHorizontal;
  38. static const CM::UINT32 SliderSize;
  39. private:
  40. void splitContainer(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget, bool horizontal, bool newChildIsFirst);
  41. };
  42. enum class DockLocation
  43. {
  44. Top,
  45. Bottom,
  46. Left,
  47. Right,
  48. None
  49. };
  50. public:
  51. DockManager(BS::GUIWidget* parent, CM::RenderWindow* parentWindow);
  52. ~DockManager();
  53. void render(const CM::Viewport* viewport, CM::RenderQueue& renderQueue);
  54. void insert(EditorWidgetContainer* relativeTo, EditorWidget* widgetToInsert, DockLocation location);
  55. void setArea(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
  56. private:
  57. static const CM::Color TINT_COLOR;
  58. static const CM::Color HIGHLIGHT_COLOR;
  59. BS::GUIWidget* mParent;
  60. CM::RenderWindow* mParentWindow;
  61. DockContainer mRootContainer;
  62. CM::HMesh mDropOverlayMesh;
  63. CM::HMaterial mDropOverlayMat;
  64. DockContainer* mMouseOverContainer;
  65. DockLocation mHighlightedDropLoc;
  66. CM::Vector2* mTopDropPolygon;
  67. CM::Vector2* mBotDropPolygon;
  68. CM::Vector2* mLeftDropPolygon;
  69. CM::Vector2* mRightDropPolygon;
  70. void updateDropOverlay(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
  71. void onGUIMouseEvent(BS::GUIWidget* widget, BS::GUIElement* element, const BS::GUIMouseEvent& event);
  72. bool insidePolygon(CM::Vector2* polyPoints, CM::UINT32 numPoints, CM::Vector2 point) const;
  73. };
  74. }