BsGUISpace.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsGUIElementBase.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief GUI element that may be inserted into layouts in order to make
  8. * a space of a fixed size.
  9. */
  10. class BS_EXPORT GUIFixedSpace : public GUIElementBase
  11. {
  12. public:
  13. GUIFixedSpace(UINT32 size)
  14. :mSize(size)
  15. {
  16. _markAsClean();
  17. }
  18. /**
  19. * @brief Returns the size of the space in pixels.
  20. */
  21. UINT32 getSize() const { return mSize; }
  22. /**
  23. * @brief Changes the size of the space to the specified value, in pixels.
  24. */
  25. void setSize(UINT32 size) { mSize = size; markContentAsDirty(); }
  26. /**
  27. * @copydoc GUIElementBase::_getType
  28. */
  29. Type _getType() const { return GUIElementBase::Type::FixedSpace; }
  30. /**
  31. * @copydoc GUIElementBase::_getOptimalSize
  32. */
  33. virtual Vector2I _getOptimalSize() const { return Vector2I(getSize(), getSize()); }
  34. /**
  35. * @copydoc GUIElementBase::_calculateLayoutSizeRange
  36. */
  37. virtual LayoutSizeRange _calculateLayoutSizeRange() const;
  38. /**
  39. * @copydoc GUIElementBase::_isContentDirty
  40. */
  41. virtual bool _isContentDirty() const { return false; }
  42. /**
  43. * @copydoc GUIElementBase::_isMeshDirty
  44. */
  45. virtual bool _isMeshDirty() const { return false; }
  46. /**
  47. * @copydoc GUIElementBase::_getPadding
  48. */
  49. virtual const RectOffset& _getPadding() const
  50. {
  51. static RectOffset padding;
  52. return padding;
  53. }
  54. protected:
  55. UINT32 mSize;
  56. };
  57. /**
  58. * @brief GUI element that may be inserted into layouts to make a space of
  59. * a flexible size. The space will expand only if there is room and
  60. * other elements are not squished because of it. If multiple flexible
  61. * spaces are in a layout, their sizes will be shared equally.
  62. *
  63. * @note e.g. If you had a horizontal layout with a button, and you wanted to
  64. * align that button to the right of the layout, you would insert a flexible
  65. * space before the button in the layout.
  66. */
  67. class BS_EXPORT GUIFlexibleSpace : public GUIElementBase
  68. {
  69. public:
  70. GUIFlexibleSpace()
  71. {
  72. _markAsClean();
  73. }
  74. /**
  75. * @copydoc GUIElementBase::_getType
  76. */
  77. Type _getType() const { return GUIElementBase::Type::FlexibleSpace; }
  78. /**
  79. * @copydoc GUIElementBase::_getOptimalSize
  80. */
  81. virtual Vector2I _getOptimalSize() const { return Vector2I(0, 0); }
  82. /**
  83. * @copydoc GUIElementBase::_calculateLayoutSizeRange
  84. */
  85. virtual LayoutSizeRange _calculateLayoutSizeRange() const;
  86. /**
  87. * @copydoc GUIElementBase::_isContentDirty
  88. */
  89. virtual bool _isContentDirty() const { return false; }
  90. /**
  91. * @copydoc GUIElementBase::_isMeshDirty
  92. */
  93. virtual bool _isMeshDirty() const { return false; }
  94. /**
  95. * @copydoc GUIElementBase::_getPadding
  96. */
  97. virtual const RectOffset& _getPadding() const
  98. {
  99. static RectOffset padding;
  100. return padding;
  101. }
  102. };
  103. }