| 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/BsRect2I.h" |
| 7 | #include "Math/BsVector2I.h" |
| 8 | |
| 9 | namespace bs |
| 10 | { |
| 11 | /** @addtogroup GUI-Internal |
| 12 | * @{ |
| 13 | */ |
| 14 | |
| 15 | /** Helper class that performs various operations related to GUILayout and GUI element sizing/placement. */ |
| 16 | class BS_EXPORT GUILayoutUtility |
| 17 | { |
| 18 | public: |
| 19 | /** |
| 20 | * Calculates optimal size of a GUI element. This is the size that allows the GUI element to properly display all of |
| 21 | * its content. |
| 22 | */ |
| 23 | static Vector2I calcOptimalSize(const GUIElementBase* elem); |
| 24 | |
| 25 | /** |
| 26 | * Calculates the size of elements in a layout of the specified size. |
| 27 | * |
| 28 | * @param[in] width Width of the layout. |
| 29 | * @param[in] height Height of the layout. |
| 30 | * @param[in] layout Parent layout of the children to calculate the area for. |
| 31 | * @param[in] updateOptimalSizes Optimization (doesn't change the results). Set to false if |
| 32 | * GUIElementBase::_updateOptimalLayoutSizes was already called and optimal sizes |
| 33 | * are up to date to avoid recalculating them. (Normally that is true if this is |
| 34 | * being called during GUI layout update) |
| 35 | */ |
| 36 | static Vector2I calcActualSize(UINT32 width, UINT32 height, GUILayout* layout, bool updateOptimalSizes = true); |
| 37 | |
| 38 | private: |
| 39 | /** |
| 40 | * Calculates the size of elements in a layout of the specified size. Assumes the layout and all its children |
| 41 | * have updated optimal sizes. |
| 42 | * |
| 43 | * @param[in] width Width of the layout. |
| 44 | * @param[in] height Height of the layout. |
| 45 | * @param[in] layout Parent layout of the children to calculate the area for. |
| 46 | */ |
| 47 | static Vector2I calcActualSizeInternal(UINT32 width, UINT32 height, GUILayout* layout); |
| 48 | }; |
| 49 | |
| 50 | /** @} */ |
| 51 | } |
| 52 | |