guiFrameSetCtrl.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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()),
  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. bool hasLeftRightButtons;
  47. bool hasTopBottomButtons;
  48. GuiFrameSetCtrl* owner;
  49. Frame* parent;
  50. Frame* child1;
  51. Frame* child2;
  52. GuiControl* control;
  53. void resize(const Point2I& newPosition, const Point2I& newExtent);
  54. void sizeInsertButtons(const Point2I& newPosition, const Point2I& newExtent);
  55. Frame* findFrame(const S32 frameID);
  56. Frame* findEmptyFrame();
  57. Frame* twin();
  58. Frame* findHitDivider(const Point2I& position);
  59. Frame* findFrameWithCtrl(GuiControl* ctrl);
  60. Frame* findFrameWithPoint(const Point2I& point);
  61. };
  62. Frame mRootFrame;
  63. Frame* mHitDivider;
  64. Frame* mOldHitDivider;
  65. U8 mDividerThickness;
  66. const S32 minSize = 20;
  67. private:
  68. public:
  69. GuiFrameSetCtrl();
  70. ~GuiFrameSetCtrl();
  71. static void initPersistFields();
  72. bool onAdd();
  73. virtual void parentResized(const Point2I& oldParentExtent, const Point2I& newParentExtent);
  74. void resize(const Point2I& newPosition, const Point2I& newExtent);
  75. void inspectPostApply();
  76. bool onWake();
  77. void onSleep();
  78. void onChildAdded(GuiControl* child);
  79. void onChildRemoved(GuiControl* child);
  80. void childResized(GuiControl* child);
  81. void childMoved(GuiControl* child);
  82. void childrenReordered();
  83. void renderDropOptions(GuiWindowCtrl* window);
  84. void renderDropButton(const GuiFrameSetCtrl::Frame* frame, const RectI& buttonRect, const Point2I& cursorPt, const Point2I& fillPos, const Point2I& fillExt, GuiDirection direction);
  85. void handleDropButtons(GuiWindowCtrl* window);
  86. Point2I splitFrame(S32 frameID, bool isVertical);
  87. void splitFrame(GuiFrameSetCtrl::Frame* frame, GuiDirection direction);
  88. void anchorFrame(GuiFrameSetCtrl::Frame* frame);
  89. void anchorFrame(S32 frameID);
  90. void setFrameSize(S32 frameID, S32 size);
  91. void onRender(Point2I offset, const RectI& updateRect);
  92. void onTouchMove(const GuiEvent& event);
  93. void onTouchDragged(const GuiEvent& event);
  94. void onTouchDown(const GuiEvent& event);
  95. void onTouchUp(const GuiEvent& event);
  96. void getCursor(GuiCursor*& cursor, bool& showCursor, const GuiEvent& lastGuiEvent);
  97. void setDropButtonProfile(GuiControlProfile* prof);
  98. void setControlLeftRightCursor(GuiCursor* cursor);
  99. void setControlUpDownCursor(GuiCursor* cursor);
  100. DECLARE_CONOBJECT(GuiFrameSetCtrl);
  101. };
  102. #endif // _GUIFRAMESETCTRL_H_