guiFrameSetCtrl.h 4.5 KB

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