guiStackCtrl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 _GUISTACKCTRL_H_
  23. #define _GUISTACKCTRL_H_
  24. #ifndef _GUICONTROL_H_
  25. #include "gui/guiControl.h"
  26. #endif
  27. #include "graphics/dgl.h"
  28. #include "console/console.h"
  29. #include "console/consoleTypes.h"
  30. /// A stack of GUI controls.
  31. ///
  32. /// This maintains a horizontal or vertical stack of GUI controls. If one is deleted, or
  33. /// resized, then the stack is resized to fit. The order of the stack is
  34. /// determined by the internal order of the children (ie, order of addition).
  35. ///
  36. ///
  37. /// @todo Make this support horizontal right to left stacks.
  38. class GuiStackControl : public GuiControl
  39. {
  40. protected:
  41. typedef GuiControl Parent;
  42. bool mResizing;
  43. S32 mPadding;
  44. S32 mStackHorizSizing; ///< Set from horizSizingOptions.
  45. S32 mStackVertSizing; ///< Set from vertSizingOptions.
  46. S32 mStackingType;
  47. public:
  48. GuiStackControl();
  49. enum stackingOptions
  50. {
  51. horizStackLeft = 0,///< Stack from left to right when horizontal
  52. horizStackRight, ///< Stack from right to left when horizontal
  53. vertStackTop, ///< Stack from top to bottom when vertical
  54. vertStackBottom, ///< Stack from bottom to top when vertical
  55. stackingTypeVert, ///< Always stack vertically
  56. stackingTypeHoriz, ///< Always stack horizontally
  57. stackingTypeDyn ///< Dynamically switch based on width/height
  58. };
  59. void resize(const Point2I &newPosition, const Point2I &newExtent);
  60. void childResized(GuiControl *child);
  61. /// prevent resizing. useful when adding many items.
  62. void freeze(bool);
  63. bool onWake();
  64. void onSleep();
  65. void updatePanes();
  66. void stackFromLeft();
  67. void stackFromRight();
  68. void stackFromTop();
  69. void stackFromBottom();
  70. S32 getCount() { return size(); }; /// Returns the number of children in the stack
  71. void addObject(SimObject *obj);
  72. void removeObject(SimObject *obj);
  73. bool reOrder(SimObject* obj, SimObject* target = 0);
  74. static void initPersistFields();
  75. DECLARE_CONOBJECT(GuiStackControl);
  76. };
  77. #endif