BsGUIDimensions.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "BsVector2I.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Contains valid size range for a GUI element in a GUI layout.
  8. */
  9. struct BS_EXPORT LayoutSizeRange
  10. {
  11. Vector2I optimal;
  12. Vector2I min;
  13. Vector2I max;
  14. };
  15. /**
  16. * @brief Flags that identify the type of data stored in a GUIDimensions structure.
  17. */
  18. enum GUIDimensionFlags
  19. {
  20. GUIDF_FixedWidth = 0x01,
  21. GUIDF_FixedHeight = 0x02,
  22. GUIDF_OverWidth = 0x04,
  23. GUIDF_OverHeight = 0x08
  24. };
  25. /**
  26. * @brief Options that control how an element is positioned and sized.
  27. */
  28. struct BS_EXPORT GUIDimensions
  29. {
  30. /**
  31. * @brief Creates new default layout options.
  32. */
  33. static GUIDimensions create();
  34. /**
  35. * @brief Creates layout options with user defined options.
  36. */
  37. static GUIDimensions create(const GUIOptions& options);
  38. GUIDimensions();
  39. /**
  40. * @brief Updates layout options from the provided style. If user has not manually
  41. * set a specific layout property, that property will be inherited from style.
  42. */
  43. void updateWithStyle(const GUIElementStyle* style);
  44. /**
  45. * @brief Calculates size range for a GUI element using this layout.
  46. *
  47. * @param optimal Preferred size of the GUI element.
  48. */
  49. LayoutSizeRange calculateSizeRange(const Vector2I& optimal) const;
  50. /**
  51. * @brief Checks do the dimensions override the style height.
  52. */
  53. bool overridenHeight() const { return (flags & GUIDF_OverHeight) != 0; }
  54. /**
  55. * @brief Checks do the dimensions override the style width.
  56. */
  57. bool overridenWidth() const { return (flags & GUIDF_OverWidth) != 0; }
  58. /**
  59. * @brief Checks do the dimensions contain fixed width.
  60. */
  61. bool fixedWidth() const { return (flags & GUIDF_FixedWidth) != 0; }
  62. /**
  63. * @brief Checks do the dimensions contain fixed height.
  64. */
  65. bool fixedHeight() const { return (flags & GUIDF_FixedHeight) != 0; }
  66. INT32 x, y;
  67. UINT32 minWidth, maxWidth, minHeight, maxHeight;
  68. UINT32 flags;
  69. };
  70. }