horizontal-layout.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #if defined(Hiro_HorizontalLayout)
  2. struct HorizontalLayout;
  3. struct HorizontalLayoutCell;
  4. struct mHorizontalLayout;
  5. struct mHorizontalLayoutCell;
  6. using sHorizontalLayout = shared_pointer<mHorizontalLayout>;
  7. using sHorizontalLayoutCell = shared_pointer<mHorizontalLayoutCell>;
  8. struct mHorizontalLayout : mSizable {
  9. using type = mHorizontalLayout;
  10. using mSizable::remove;
  11. auto alignment() const -> maybe<float>;
  12. auto append(sSizable sizable, Size size, float spacing = 5_sy) -> type&;
  13. auto cell(uint position) const -> HorizontalLayoutCell;
  14. auto cell(sSizable sizable) const -> HorizontalLayoutCell;
  15. auto cells() const -> vector<HorizontalLayoutCell>;
  16. auto cellCount() const -> uint;
  17. auto minimumSize() const -> Size override;
  18. auto padding() const -> Geometry;
  19. auto remove(sSizable sizable) -> type&;
  20. auto remove(sHorizontalLayoutCell cell) -> type&;
  21. auto reset() -> type& override;
  22. auto resize() -> type&;
  23. auto setAlignment(maybe<float> alignment) -> type&;
  24. auto setEnabled(bool enabled) -> type& override;
  25. auto setFont(const Font& font) -> type& override;
  26. auto setGeometry(Geometry geometry) -> type& override;
  27. auto setPadding(Geometry padding) -> type&;
  28. auto setParent(mObject* parent = nullptr, int offset = -1) -> type&;
  29. auto setSpacing(float spacing) -> type&;
  30. auto setVisible(bool visible) -> type& override;
  31. auto spacing() const -> float;
  32. auto synchronize() -> type&;
  33. private:
  34. auto destruct() -> void override;
  35. struct State {
  36. maybe<float> alignment;
  37. vector<HorizontalLayoutCell> cells;
  38. Geometry padding;
  39. float spacing = 5_sx;
  40. } state;
  41. };
  42. struct mHorizontalLayoutCell : mObject {
  43. using type = mHorizontalLayoutCell;
  44. auto alignment() const -> maybe<float>;
  45. auto collapsible() const -> bool;
  46. auto setAlignment(maybe<float> alignment) -> type&;
  47. auto setEnabled(bool enabled) -> type& override;
  48. auto setFont(const Font& font) -> type& override;
  49. auto setParent(mObject* parent = nullptr, int offset = -1) -> type& override;
  50. auto setSizable(sSizable sizable) -> type&;
  51. auto setSize(Size size) -> type&;
  52. auto setSpacing(float spacing) -> type&;
  53. auto setVisible(bool visible) -> type& override;
  54. auto sizable() const -> Sizable;
  55. auto size() const -> Size;
  56. auto spacing() const -> float;
  57. auto synchronize() -> type&;
  58. private:
  59. auto destruct() -> void override;
  60. struct State {
  61. maybe<float> alignment;
  62. sSizable sizable;
  63. Size size;
  64. float spacing = 5_sx;
  65. } state;
  66. friend class mHorizontalLayout;
  67. };
  68. #endif