guiSplitContainer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUI_SPLTCONTAINER_H_
  23. #define _GUI_SPLTCONTAINER_H_
  24. #ifndef _GUICONTROL_H_
  25. #include "gui/core/guiControl.h"
  26. #endif
  27. #ifndef _GUICONTAINER_H_
  28. #include "gui/containers/guiContainer.h"
  29. #endif
  30. #ifndef _GUI_PANEL_H_
  31. #include "gui/containers/guiPanel.h"
  32. #endif
  33. #ifndef _PLATFORMINPUT_H_
  34. #include "platform/platformInput.h"
  35. #endif
  36. /// @addtogroup gui_container_group Containers
  37. ///
  38. /// @ingroup gui_group Gui System
  39. /// @{
  40. class GuiSplitContainer : public GuiContainer
  41. {
  42. typedef GuiContainer Parent;
  43. public:
  44. enum Orientation
  45. {
  46. Vertical = 0,
  47. Horizontal = 1
  48. };
  49. enum FixedPanel
  50. {
  51. None = 0,
  52. FirstPanel = 1,
  53. SecondPanel
  54. };
  55. GuiSplitContainer();
  56. DECLARE_CONOBJECT( GuiSplitContainer );
  57. DECLARE_DESCRIPTION( "A container that splits its area between two child controls.\n"
  58. "The split ratio can be dynamically adjusted with a handle control between the two children.\n"
  59. "Splitting can be either horizontal or vertical." );
  60. // ConsoleObject
  61. static void initPersistFields();
  62. virtual bool onAdd();
  63. // GuiControl
  64. virtual bool onWake();
  65. virtual void parentResized(const RectI &oldParentRect, const RectI &newParentRect);
  66. virtual bool resize( const Point2I &newPosition, const Point2I &newExtent );
  67. virtual void onRender(Point2I offset, const RectI &updateRect);
  68. virtual void onMouseDown(const GuiEvent &event);
  69. virtual void onMouseUp(const GuiEvent &event);
  70. virtual void onMouseDragged(const GuiEvent &event);
  71. virtual bool layoutControls( RectI &clientRect );
  72. virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
  73. virtual inline Point2I getSplitPoint() { return mSplitPoint; };
  74. /// The Splitters entire Client Rectangle, this takes into account padding of this control
  75. virtual inline RectI getSplitRect() { return mSplitRect; };
  76. virtual void solvePanelConstraints(Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, const RectI& clientRect);
  77. virtual Point2I getMinExtent() const;
  78. //Set the positin of the split handler
  79. void setSplitPoint(Point2I splitPoint);
  80. protected:
  81. S32 mFixedPanel;
  82. S32 mFixedPanelSize;
  83. S32 mOrientation;
  84. S32 mSplitterSize;
  85. Point2I mSplitPoint;
  86. RectI mSplitRect;
  87. bool mDragging;
  88. };
  89. typedef GuiSplitContainer::Orientation GuiSplitOrientation;
  90. typedef GuiSplitContainer::FixedPanel GuiSplitFixedPanel;
  91. DefineEnumType( GuiSplitOrientation );
  92. DefineEnumType( GuiSplitFixedPanel );
  93. /// @}
  94. #endif // _GUI_SPLTCONTAINER_H_