UIPreferredSize.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <ThirdParty/TurboBadger/tb_widgets.h>
  3. #include <Atomic/Container/RefCounted.h>
  4. namespace tb
  5. {
  6. class PreferredSize;
  7. }
  8. namespace Atomic
  9. {
  10. /// Defines how the size in one axis depend on the other axis when a widgets size is affected by constraints.
  11. enum UI_SIZE_DEP {
  12. /// No dependency (Faster layout).
  13. UI_SIZE_DEP_NONE = tb::SIZE_DEP_NONE,
  14. /// The width is dependant on the height. Additional layout pass may be required.
  15. UI_SIZE_DEP_WIDTH_DEPEND_ON_HEIGHT = tb::SIZE_DEP_WIDTH_DEPEND_ON_HEIGHT,
  16. /// The height is dependant on the width. Additional layout pass may be required.
  17. UI_SIZE_DEP_HEIGHT_DEPEND_ON_WIDTH = tb::SIZE_DEP_HEIGHT_DEPEND_ON_WIDTH,
  18. /// Both width and height are dependant on each other. Additional layout pass may be required.
  19. UI_SIZE_DEP_BOTH = tb::SIZE_DEP_BOTH
  20. };
  21. class UIPreferredSize : public RefCounted
  22. {
  23. friend class UIWidget;
  24. REFCOUNTED(UIPreferredSize)
  25. public:
  26. UIPreferredSize(int w = 0, int h = 0);
  27. virtual ~UIPreferredSize();
  28. int GetMinWidth() const;
  29. int GetMinHeight() const;
  30. int GetMaxWidth() const;
  31. int GetMaxHeight() const;
  32. int GetPrefWidth() const;
  33. int GetPrefHeight() const;
  34. UI_SIZE_DEP GetSizeDep() const;
  35. void SetMinWidth(int w);
  36. void SetMinHeight(int h);
  37. void SetMaxWidth(int w);
  38. void SetMaxHeight(int h);
  39. void SetPrefWidth(int w);
  40. void SetPrefHeight(int h);
  41. void SetSizeDep(UI_SIZE_DEP dep);
  42. private:
  43. /// tb sync
  44. void SetFromTBPreferredSize(const tb::PreferredSize& sz) { preferredSize_ = sz; }
  45. const tb::PreferredSize& GetTBPreferredSize() { return preferredSize_; }
  46. tb::PreferredSize preferredSize_;
  47. };
  48. }