BsGUIOptions.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Controls GUI element layout options, possibly by overriding
  7. * the default options specified in GUI element style. These options
  8. * control GUI element placement and size in a GUI layout.
  9. */
  10. class BS_EXPORT GUIOption
  11. {
  12. /**
  13. * @brief Type of GUI element options.
  14. */
  15. enum class Type
  16. {
  17. FixedWidth,
  18. FlexibleWidth,
  19. FixedHeight,
  20. FlexibleHeight,
  21. Position
  22. };
  23. public:
  24. GUIOption();
  25. /**
  26. * @brief Constructs a GUI option notifying the GUI layout that this element should be positioned
  27. * at this offset from the parent GUI panel. This option is ignored if element is part of a
  28. * layout since it controls its placement.
  29. */
  30. static GUIOption position(INT32 x, INT32 y);
  31. /**
  32. * @brief Constructs a GUI option notifying the GUI layout that this element has a fixed width.
  33. * This will override the width property set in element style.
  34. */
  35. static GUIOption fixedWidth(UINT32 value);
  36. /**
  37. * @brief Constructs a GUI option notifying the GUI layout that this element has a flexible width with
  38. * optional min/max constraints (value of 0 means no constraint). This will override the width property
  39. * set in element style.
  40. */
  41. static GUIOption flexibleWidth(UINT32 min = 0, UINT32 max = 0);
  42. /**
  43. * @brief Constructs a GUI option notifying the GUI layout that this element has a fixed height.
  44. * This will override the height property set in element style.
  45. */
  46. static GUIOption fixedHeight(UINT32 value);
  47. /**
  48. * @brief Constructs a GUI option notifying the GUI layout that this element has a flexible height with
  49. * optional min/max constraints (value of 0 means no constraint). This will override the height property
  50. * set in element style.
  51. */
  52. static GUIOption flexibleHeight(UINT32 min = 0, UINT32 max = 0);
  53. private:
  54. friend struct GUIDimensions;
  55. UINT32 min, max;
  56. Type type;
  57. };
  58. /**
  59. * @brief Container for a list of options used for controlling GUI element properties.
  60. */
  61. class BS_EXPORT GUIOptions
  62. {
  63. public:
  64. GUIOptions() { }
  65. GUIOptions(const GUIOption& e0)
  66. {
  67. mOptions.push_back(e0);
  68. }
  69. GUIOptions(const GUIOption& e0, const GUIOption& e1)
  70. {
  71. mOptions.push_back(e0);
  72. mOptions.push_back(e1);
  73. }
  74. GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2)
  75. {
  76. mOptions.push_back(e0);
  77. mOptions.push_back(e1);
  78. mOptions.push_back(e2);
  79. }
  80. GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2,
  81. const GUIOption& e3)
  82. {
  83. mOptions.push_back(e0);
  84. mOptions.push_back(e1);
  85. mOptions.push_back(e2);
  86. mOptions.push_back(e3);
  87. }
  88. GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2,
  89. const GUIOption& e3, const GUIOption& e4)
  90. {
  91. mOptions.push_back(e0);
  92. mOptions.push_back(e1);
  93. mOptions.push_back(e2);
  94. mOptions.push_back(e3);
  95. mOptions.push_back(e4);
  96. }
  97. /**
  98. * @brief Adds a new option to the options list.
  99. */
  100. void addOption(const GUIOption& option)
  101. {
  102. mOptions.push_back(option);
  103. }
  104. private:
  105. friend struct GUIDimensions;
  106. Vector<GUIOption> mOptions;
  107. };
  108. }