BsGUIDimensions.h 2.1 KB

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