guiFrameSetCtrl.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef _GUIFRAMESETCTRL_H_
  2. #define _GUIFRAMESETCTRL_H_
  3. #ifndef _GUICONTROL_H_
  4. #include "gui/guiControl.h"
  5. #endif
  6. #ifndef _VECTOR2_H_
  7. #include "2d/core/Vector2.h"
  8. #endif
  9. #include "graphics/dgl.h"
  10. #include "console/console.h"
  11. #include "console/consoleTypes.h"
  12. #include "gui/containers/guiWindowCtrl.h"
  13. #include "gui/containers/guiTabBookCtrl.h"
  14. class GuiFrameSetCtrl : public GuiEasingSupport
  15. {
  16. private:
  17. typedef GuiControl Parent;
  18. U32 mNextFrameID;
  19. bool mResizeGuard;
  20. bool mDepressed;
  21. S32 mFrameDragAnchor;
  22. // Sizing Cursors
  23. GuiCursor* mLeftRightCursor;
  24. GuiCursor* mUpDownCursor;
  25. GuiControlProfile* mDropButtonProfile; //Used to render a drop button (the buttons that appear on frames when dragging a window).
  26. public:
  27. class Frame
  28. {
  29. public:
  30. Frame() : Frame(nullptr, nullptr) { }
  31. Frame(GuiFrameSetCtrl* theOwner, Frame* theParent) : owner(theOwner), parent(theParent), child1(nullptr), child2(nullptr),
  32. control(nullptr), isVertical(true), id(1), extent(Point2I(100, 100)), dividerRect(RectI()),
  33. localPosition(Point2I(0, 0)), mLeftButtonRect(RectI()), mRightButtonRect(RectI()), mCenterButtonRect(RectI()),
  34. mTopButtonRect(RectI()), mBottomButtonRect(RectI()), isAnchored(true), hasLeftRightButtons(false), hasTopBottomButtons(false) { }
  35. virtual ~Frame() { }
  36. void deleteChildren();
  37. bool isVertical;
  38. U32 id;
  39. Point2I extent;
  40. Point2I localPosition;
  41. bool isAnchored;
  42. RectI dividerRect;
  43. RectI mLeftButtonRect;
  44. RectI mRightButtonRect;
  45. RectI mTopButtonRect;
  46. RectI mBottomButtonRect;
  47. RectI mCenterButtonRect;
  48. bool hasLeftRightButtons;
  49. bool hasTopBottomButtons;
  50. GuiFrameSetCtrl* owner;
  51. Frame* parent;
  52. Frame* child1;
  53. Frame* child2;
  54. GuiControl* control;
  55. void resize(const Point2I& newPosition, const Point2I& newExtent);
  56. void sizeInsertButtons(const Point2I& newPosition, const Point2I& newExtent);
  57. Frame* findFrame(const S32 frameID);
  58. Frame* findEmptyFrame();
  59. Frame* twin();
  60. Frame* findHitDivider(const Point2I& position);
  61. Frame* findFrameWithCtrl(GuiControl* ctrl);
  62. Frame* findFrameWithPoint(const Point2I& point);
  63. };
  64. Frame mRootFrame;
  65. Frame* mHitDivider;
  66. Frame* mOldHitDivider;
  67. U8 mDividerThickness;
  68. const S32 minSize = 20;
  69. GuiControlProfile* mTabBookProfile;
  70. GuiControlProfile* mTabProfile;
  71. GuiControlProfile* mTabPageProfile;
  72. private:
  73. public:
  74. GuiFrameSetCtrl();
  75. ~GuiFrameSetCtrl();
  76. static void initPersistFields();
  77. bool onAdd();
  78. virtual void parentResized(const Point2I& oldParentExtent, const Point2I& newParentExtent);
  79. void resize(const Point2I& newPosition, const Point2I& newExtent);
  80. void inspectPostApply();
  81. bool onWake();
  82. void onSleep();
  83. void onChildAdded(GuiControl* child);
  84. void onChildRemoved(GuiControl* child);
  85. void childResized(GuiControl* child);
  86. void childMoved(GuiControl* child);
  87. void childrenReordered();
  88. void renderDropOptions(GuiWindowCtrl* window);
  89. bool hasCenterButton(GuiFrameSetCtrl::Frame* frame);
  90. void renderDropButton(const GuiFrameSetCtrl::Frame* frame, const RectI& buttonRect, const Point2I& cursorPt, const Point2I& fillPos, const Point2I& fillExt, GuiDirection direction);
  91. void handleDropButtons(GuiWindowCtrl* window);
  92. void undockWindowFromBook(GuiWindowCtrl* window, GuiTabBookCtrl* book, GuiTabPageCtrl* page);
  93. Point2I splitFrame(S32 frameID, bool isVertical);
  94. void splitFrame(GuiFrameSetCtrl::Frame* frame, GuiDirection direction);
  95. void anchorFrame(GuiFrameSetCtrl::Frame* frame);
  96. void anchorFrame(S32 frameID);
  97. void setFrameSize(S32 frameID, S32 size);
  98. void onPreRender();
  99. void onRender(Point2I offset, const RectI& updateRect);
  100. void onTouchMove(const GuiEvent& event);
  101. void onTouchDragged(const GuiEvent& event);
  102. void onTouchDown(const GuiEvent& event);
  103. void onTouchUp(const GuiEvent& event);
  104. void getCursor(GuiCursor*& cursor, bool& showCursor, const GuiEvent& lastGuiEvent);
  105. void setDropButtonProfile(GuiControlProfile* prof);
  106. void setTabBookProfile(GuiControlProfile* prof);
  107. void setTabProfile(GuiControlProfile* prof);
  108. void setTabPageProfile(GuiControlProfile* prof);
  109. void setControlLeftRightCursor(GuiCursor* cursor);
  110. void setControlUpDownCursor(GuiCursor* cursor);
  111. static bool setBookProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabBookProfile(profile); return true; }
  112. static bool setTabProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabProfile(profile); return true; }
  113. static bool setPageProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabPageProfile(profile); return true; }
  114. DECLARE_CONOBJECT(GuiFrameSetCtrl);
  115. };
  116. #endif // _GUIFRAMESETCTRL_H_