BsGUILayoutUtility.h 2.0 KB

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