guiRolloutCtrl.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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_ROLLOUTCTRL_H_
  23. #define _GUI_ROLLOUTCTRL_H_
  24. #ifndef _GUICONTROL_H_
  25. #include "gui/guiControl.h"
  26. #endif
  27. #ifndef _GUISTACKCTRL_H_
  28. #include "gui/containers/guiStackCtrl.h"
  29. #endif
  30. #ifndef _H_GUIDEFAULTCONTROLRENDER_
  31. #include "gui/guiDefaultControlRender.h"
  32. #endif
  33. #ifndef _GUITICKCTRL_H_
  34. #include "gui/guiTickCtrl.h"
  35. #endif
  36. class GuiRolloutCtrl : public GuiTickCtrl
  37. {
  38. private:
  39. typedef GuiControl Parent;
  40. public:
  41. // Members
  42. StringTableEntry mCaption;
  43. RectI mHeader;
  44. RectI mExpanded;
  45. RectI mChildRect;
  46. Point2I mMargin;
  47. bool mIsExpanded;
  48. bool mIsAnimating;
  49. bool mCollapsing;
  50. S32 mAnimateDestHeight;
  51. S32 mAnimateStep;
  52. S32 mDefaultHeight;
  53. bool mCanCollapse;
  54. GuiCursor* mDefaultCursor;
  55. GuiCursor* mVertSizingCursor;
  56. // Theme Support
  57. enum
  58. {
  59. CollapsedLeft = 0,
  60. CollapsedCenter,
  61. CollapsedRight,
  62. TopLeftHeader,
  63. TopMidHeader,
  64. TopRightHeader,
  65. MidPageLeft,
  66. MidPageCenter,
  67. MidPageRight,
  68. BottomLeftHeader,
  69. BottomMidHeader,
  70. BottomRightHeader,
  71. NumBitmaps ///< Number of bitmaps in this array
  72. };
  73. bool mHasTexture; ///< Indicates whether we have a texture to render the tabs with
  74. RectI *mBitmapBounds;///< Array of rectangles identifying textures for tab book
  75. // Constructor/Destructor/Conobject Declaration
  76. GuiRolloutCtrl();
  77. ~GuiRolloutCtrl();
  78. DECLARE_CONOBJECT(GuiRolloutCtrl);
  79. // Persistence
  80. static void initPersistFields();
  81. // Control Events
  82. bool onWake();
  83. void addObject(SimObject *obj);
  84. void removeObject(SimObject *obj);
  85. virtual void childResized(GuiControl *child);
  86. // Mouse Events
  87. virtual void onMouseDown( const GuiEvent &event );
  88. virtual void onMouseUp( const GuiEvent &event );
  89. // Sizing Helpers
  90. virtual void calculateHeights();
  91. void resize( const Point2I &newPosition, const Point2I &newExtent );
  92. virtual void sizeToContents();
  93. inline bool isExpanded(){ return mIsExpanded; };
  94. // Sizing Animation Functions
  95. void animateTo( S32 height );
  96. virtual void processTick();
  97. void collapse() { animateTo( mHeader.extent.y ); };
  98. void expand() { animateTo( mExpanded.extent.y ); };
  99. void instantCollapse();
  100. void instantExpand();
  101. // Property - "Collapsed"
  102. static bool setCollapsed(void* obj, const char* data)
  103. {
  104. bool bCollapsed = dAtob( data );
  105. if( bCollapsed )
  106. static_cast<GuiRolloutCtrl*>(obj)->instantCollapse();
  107. else
  108. static_cast<GuiRolloutCtrl*>(obj)->instantExpand();
  109. return false;
  110. };
  111. // Control Rendering
  112. virtual void onRender(Point2I offset, const RectI &updateRect);
  113. bool onAdd();
  114. };
  115. #endif