table-layout.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #if defined(Hiro_TableLayout)
  2. struct TableLayout;
  3. struct TableLayoutColumn;
  4. struct TableLayoutRow;
  5. struct TableLayoutCell;
  6. struct mTableLayout;
  7. struct mTableLayoutColumn;
  8. struct mTableLayoutRow;
  9. struct mTableLayoutCell;
  10. using sTableLayout = shared_pointer<mTableLayout>;
  11. using sTableLayoutColumn = shared_pointer<mTableLayoutColumn>;
  12. using sTableLayoutRow = shared_pointer<mTableLayoutRow>;
  13. using sTableLayoutCell = shared_pointer<mTableLayoutCell>;
  14. struct mTableLayout : mSizable {
  15. using type = mTableLayout;
  16. using mSizable::remove;
  17. auto alignment() const -> Alignment;
  18. auto append(sSizable sizable, Size size) -> type&;
  19. auto cell(uint position) const -> TableLayoutCell;
  20. auto cell(uint x, uint y) const -> TableLayoutCell;
  21. auto cell(sSizable sizable) const -> TableLayoutCell;
  22. auto cells() const -> vector<TableLayoutCell>;
  23. auto cellCount() const -> uint;
  24. auto column(uint position) const -> TableLayoutColumn;
  25. auto columns() const -> vector<TableLayoutColumn>;
  26. auto columnCount() const -> uint;
  27. auto minimumSize() const -> Size override;
  28. auto padding() const -> Geometry;
  29. auto remove(sSizable sizable) -> type&;
  30. auto remove(sTableLayoutCell cell) -> type&;
  31. auto reset() -> type& override;
  32. auto resize() -> type&;
  33. auto row(uint position) const -> TableLayoutRow;
  34. auto rows() const -> vector<TableLayoutRow>;
  35. auto rowCount() const -> uint;
  36. auto setAlignment(Alignment alignment) -> type&;
  37. auto setEnabled(bool enabled) -> type& override;
  38. auto setFont(const Font& font) -> type& override;
  39. auto setGeometry(Geometry geometry) -> type& override;
  40. auto setPadding(Geometry padding) -> type&;
  41. auto setParent(mObject* parent = nullptr, int offset = -1) -> type& override;
  42. auto setSize(Size size) -> type&;
  43. auto setVisible(bool visible) -> type& override;
  44. auto size() const -> Size;
  45. auto synchronize() -> type&;
  46. private:
  47. auto destruct() -> void override;
  48. struct State {
  49. Alignment alignment;
  50. vector<TableLayoutCell> cells;
  51. vector<TableLayoutColumn> columns;
  52. Geometry padding;
  53. vector<TableLayoutRow> rows;
  54. Size size;
  55. } state;
  56. };
  57. struct mTableLayoutColumn : mObject {
  58. using type = mTableLayoutColumn;
  59. auto alignment() const -> Alignment;
  60. auto setAlignment(Alignment alignment) -> type&;
  61. auto setSpacing(float spacing) -> type&;
  62. auto spacing() const -> float;
  63. auto synchronize() -> type&;
  64. private:
  65. struct State {
  66. Alignment alignment;
  67. float spacing = 5_sx;
  68. } state;
  69. friend class mTableLayout;
  70. };
  71. struct mTableLayoutRow : mObject {
  72. using type = mTableLayoutRow;
  73. auto alignment() const -> Alignment;
  74. auto setAlignment(Alignment alignment) -> type&;
  75. auto setSpacing(float spacing) -> type&;
  76. auto spacing() const -> float;
  77. auto synchronize() -> type&;
  78. private:
  79. struct State {
  80. Alignment alignment;
  81. float spacing = 5_sy;
  82. } state;
  83. friend class mTableLayout;
  84. };
  85. struct mTableLayoutCell : mObject {
  86. using type = mTableLayoutCell;
  87. auto alignment() const -> Alignment;
  88. auto setAlignment(Alignment alignment) -> type&;
  89. auto setEnabled(bool enabled) -> type& override;
  90. auto setFont(const Font& font) -> type& override;
  91. auto setParent(mObject* parent = nullptr, int offset = -1) -> type& override;
  92. auto setSizable(sSizable sizable) -> type&;
  93. auto setSize(Size size) -> type&;
  94. auto setVisible(bool visible) -> type& override;
  95. auto sizable() const -> Sizable;
  96. auto size() const -> Size;
  97. auto synchronize() -> type&;
  98. private:
  99. auto destruct() -> void override;
  100. struct State {
  101. Alignment alignment;
  102. sSizable sizable;
  103. Size size;
  104. } state;
  105. friend class mTableLayout;
  106. };
  107. #endif