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