guiFrameSetCtrl.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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),
  35. hasTopBottomButtons(false), spliterRect1(RectI()), spliterRect2(RectI()) { }
  36. virtual ~Frame() { }
  37. void deleteChildren();
  38. bool isVertical;
  39. U32 id;
  40. Point2I extent;
  41. bool isAnchored;
  42. Point2I localPosition;
  43. RectI dividerRect;
  44. RectI spliterRect1;//shown in edit mode
  45. RectI spliterRect2;//shown in edit mode
  46. RectI mLeftButtonRect;
  47. RectI mRightButtonRect;
  48. RectI mTopButtonRect;
  49. RectI mBottomButtonRect;
  50. RectI mCenterButtonRect;
  51. bool hasLeftRightButtons;
  52. bool hasTopBottomButtons;
  53. GuiFrameSetCtrl* owner;
  54. Frame* parent;
  55. Frame* child1;
  56. Frame* child2;
  57. GuiControl* control;
  58. void resize(const Point2I& newPosition, const Point2I& newExtent);
  59. void sizeInsertButtons(const Point2I& newPosition, const Point2I& newExtent);
  60. Frame* findFrame(const S32 frameID);
  61. Frame* findEmptyFrame();
  62. Frame* findEmptyFrameAtLocation(const RectI& location);
  63. Frame* twin();
  64. Frame* findHitDivider(const Point2I& position);
  65. Frame* findFrameWithCtrl(GuiControl* ctrl);
  66. Frame* findFrameWithPoint(const Point2I& point);
  67. void editRender(const Point2I& cursorPt, const F32 fade);
  68. };
  69. Frame mRootFrame;
  70. Frame* mHitDivider;
  71. Frame* mOldHitDivider;
  72. U8 mDividerThickness;
  73. const S32 minSize = 20;
  74. GuiControlProfile* mTabBookProfile;
  75. GuiControlProfile* mTabProfile;
  76. GuiControlProfile* mTabPageProfile;
  77. protected:
  78. void onTamlCustomWrite(TamlCustomNodes& customNodes);
  79. void writeFrameCustomTaml(TamlCustomNode* pParentNode, Frame* frame);
  80. void onTamlCustomRead(const TamlCustomNodes& customNodes);
  81. void loadTamlFrames(const TamlCustomNodes& customNodes);
  82. void loadTamlFrame(const TamlCustomNode& node, Frame* frame);
  83. public:
  84. GuiFrameSetCtrl();
  85. ~GuiFrameSetCtrl();
  86. static void initPersistFields();
  87. bool onAdd();
  88. virtual void parentResized(const Point2I& oldParentExtent, const Point2I& newParentExtent);
  89. void loadFrame(GuiFrameSetCtrl::Frame* frame, const U32 frameID);
  90. void resize(const Point2I& newPosition, const Point2I& newExtent);
  91. void inspectPostApply();
  92. bool onWake();
  93. void onSleep();
  94. void onChildAdded(GuiControl* child);
  95. void assignChildToFrame(GuiControl* child);
  96. void onChildRemoved(GuiControl* child);
  97. void childResized(GuiControl* child);
  98. void childMoved(GuiControl* child);
  99. void childrenReordered();
  100. void renderDropOptions(GuiWindowCtrl* window);
  101. bool hasCenterButton(GuiFrameSetCtrl::Frame* frame);
  102. void renderDropButton(const GuiFrameSetCtrl::Frame* frame, const RectI& buttonRect, const Point2I& cursorPt, const Point2I& fillPos, const Point2I& fillExt, GuiDirection direction);
  103. void handleDropButtons(GuiWindowCtrl* window);
  104. void undockWindowFromBook(GuiWindowCtrl* window, GuiTabBookCtrl* book, GuiTabPageCtrl* page);
  105. void renderChild(GuiControl* ctrl, const Point2I& offset, const RectI& content, const RectI& clipRect);
  106. GuiControl* findHitControl(const Point2I& pt, S32 initialLayer = -1);
  107. Point2I splitFrame(S32 frameID, bool isVertical);
  108. void splitFrame(GuiFrameSetCtrl::Frame* frame, GuiDirection direction);
  109. void anchorFrame(GuiFrameSetCtrl::Frame* frame);
  110. void anchorFrame(S32 frameID);
  111. void setFrameSize(S32 frameID, S32 size);
  112. void onPreRender();
  113. void onRender(Point2I offset, const RectI& updateRect);
  114. void onTouchMove(const GuiEvent& event);
  115. void onTouchDragged(const GuiEvent& event);
  116. void onTouchDown(const GuiEvent& event);
  117. void onTouchUp(const GuiEvent& event);
  118. void getCursor(GuiCursor*& cursor, bool& showCursor, const GuiEvent& lastGuiEvent);
  119. bool onMouseDownEditor(const GuiEvent& event, const Point2I& offset);
  120. bool onMouseUpEditor(const GuiEvent& event, const Point2I& offset);
  121. bool onMouseDraggedEditor(const GuiEvent& event, const Point2I& offset);
  122. void setDropButtonProfile(GuiControlProfile* prof);
  123. void setTabBookProfile(GuiControlProfile* prof);
  124. void setTabProfile(GuiControlProfile* prof);
  125. void setTabPageProfile(GuiControlProfile* prof);
  126. void setControlLeftRightCursor(GuiCursor* cursor);
  127. void setControlUpDownCursor(GuiCursor* cursor);
  128. static bool setBookProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabBookProfile(profile); return true; }
  129. static bool setTabProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabProfile(profile); return true; }
  130. static bool setPageProfileFn(void* obj, const char* data) { GuiControlProfile* profile; Sim::findObject(data, profile); static_cast<GuiFrameSetCtrl*>(obj)->setTabPageProfile(profile); return true; }
  131. void writeFields(Stream& stream, U32 tabStop);
  132. void generateFrameFields(Frame* frame);
  133. void setDataField(const char* tag, const U32 id, const U32 value);
  134. const char* getDataField(const char* tag, const U32 id);
  135. DECLARE_CONOBJECT(GuiFrameSetCtrl);
  136. };
  137. #endif // _GUIFRAMESETCTRL_H_