|
8 | 8 | use VISU\FlyUI\FUIButtonGroup; |
9 | 9 | use VISU\FlyUI\FUILayoutFlow; |
10 | 10 | use VISU\FlyUI\FUILayoutSizing; |
| 11 | +use VISU\FlyUI\FUILayoutAlignment; |
11 | 12 | use VISU\FlyUI\Theme\FUIButtonStyle; |
12 | 13 | use VISU\FlyUI\Theme\FUIButtonGroupStyle; |
13 | 14 | use VISU\Graphics\Rendering\RenderContext; |
@@ -37,6 +38,7 @@ class FlyUiDemoState { |
37 | 38 | public FUILayoutFlow $stackFlow = FUILayoutFlow::vertical; |
38 | 39 | public FUILayoutSizing $verticalStackSizing = FUILayoutSizing::fill; |
39 | 40 | public FUILayoutSizing $horizontalStackSizing = FUILayoutSizing::fill; |
| 41 | + public FUILayoutAlignment $stackAlignment = FUILayoutAlignment::topLeft; |
40 | 42 | } |
41 | 43 |
|
42 | 44 | $state = new FlyUiDemoState; |
@@ -69,6 +71,7 @@ function UIDemo(string $name, \Closure $func) : void { |
69 | 71 | FlyUI::beginLayout() |
70 | 72 | ->verticalFill() |
71 | 73 | ->flow($state->stackFlow) |
| 74 | + ->align($state->stackAlignment) |
72 | 75 | ->spacing(5); |
73 | 76 |
|
74 | 77 | for ($i = 0; $i < 10; $i++) { |
@@ -134,16 +137,64 @@ function UIDemo(string $name, \Closure $func) : void { |
134 | 137 | } |
135 | 138 | }); |
136 | 139 |
|
137 | | - // FlyUI::buttonGroup(['fill' => 'Fill', 'fit' => 'Fit'], $state->stackSizing->name, function(string $option) use(&$state) { |
138 | | - // var_dump($option); |
139 | | - // if ($option === 'fill') { |
140 | | - // $state->stackSizing = FUILayoutSizing::fill; |
141 | | - // } else { |
142 | | - // $state->stackSizing = FUILayoutSizing::fit; |
143 | | - // } |
144 | | - // }); |
| 140 | + FlyUI::spaceY(10); |
| 141 | + |
| 142 | + // alignment |
| 143 | + FlyUI::beginSection('Stack Alignment'); |
| 144 | + |
| 145 | + // horizontal alignment |
| 146 | + $horizontalAlignment = match($state->stackAlignment) { |
| 147 | + FUILayoutAlignment::topLeft, FUILayoutAlignment::centerLeft, FUILayoutAlignment::bottomLeft => 'left', |
| 148 | + FUILayoutAlignment::topCenter, FUILayoutAlignment::center, FUILayoutAlignment::bottomCenter => 'center', |
| 149 | + FUILayoutAlignment::topRight, FUILayoutAlignment::centerRight, FUILayoutAlignment::bottomRight => 'right', |
| 150 | + }; |
| 151 | + |
| 152 | + FlyUI::buttonGroup('Horizontal', [ |
| 153 | + 'left' => 'Left', |
| 154 | + 'center' => 'Center', |
| 155 | + 'right' => 'Right', |
| 156 | + ], $horizontalAlignment, function(string $option) use(&$state) { |
| 157 | + $state->stackAlignment = match([$state->stackAlignment, $option]) { |
| 158 | + [FUILayoutAlignment::topLeft, 'left'], [FUILayoutAlignment::topCenter, 'left'], [FUILayoutAlignment::topRight, 'left'] => FUILayoutAlignment::topLeft, |
| 159 | + [FUILayoutAlignment::topLeft, 'center'], [FUILayoutAlignment::topCenter, 'center'], [FUILayoutAlignment::topRight, 'center'] => FUILayoutAlignment::topCenter, |
| 160 | + [FUILayoutAlignment::topLeft, 'right'], [FUILayoutAlignment::topCenter, 'right'], [FUILayoutAlignment::topRight, 'right'] => FUILayoutAlignment::topRight, |
| 161 | + [FUILayoutAlignment::centerLeft, 'left'], [FUILayoutAlignment::center, 'left'], [FUILayoutAlignment::centerRight, 'left'] => FUILayoutAlignment::centerLeft, |
| 162 | + [FUILayoutAlignment::centerLeft, 'center'], [FUILayoutAlignment::center, 'center'], [FUILayoutAlignment::centerRight, 'center'] => FUILayoutAlignment::center, |
| 163 | + [FUILayoutAlignment::centerLeft, 'right'], [FUILayoutAlignment::center, 'right'], [FUILayoutAlignment::centerRight, 'right'] => FUILayoutAlignment::centerRight, |
| 164 | + [FUILayoutAlignment::bottomLeft, 'left'], [FUILayoutAlignment::bottomCenter, 'left'], [FUILayoutAlignment::bottomRight, 'left'] => FUILayoutAlignment::bottomLeft, |
| 165 | + [FUILayoutAlignment::bottomLeft, 'center'], [FUILayoutAlignment::bottomCenter, 'center'], [FUILayoutAlignment::bottomRight, 'center'] => FUILayoutAlignment::bottomCenter, |
| 166 | + [FUILayoutAlignment::bottomLeft, 'right'], [FUILayoutAlignment::bottomCenter, 'right'], [FUILayoutAlignment::bottomRight, 'right'] => FUILayoutAlignment::bottomRight, |
| 167 | + }; |
| 168 | + })->setId('h-align-btn-group'); |
| 169 | + |
| 170 | + // vertical alignment |
| 171 | + $verticalAlignment = match($state->stackAlignment) { |
| 172 | + FUILayoutAlignment::topLeft, FUILayoutAlignment::topCenter, FUILayoutAlignment::topRight => 'top', |
| 173 | + FUILayoutAlignment::centerLeft, FUILayoutAlignment::center, FUILayoutAlignment::centerRight => 'center', |
| 174 | + FUILayoutAlignment::bottomLeft, FUILayoutAlignment::bottomCenter, FUILayoutAlignment::bottomRight => 'bottom', |
| 175 | + }; |
| 176 | + |
| 177 | + FlyUI::buttonGroup('Vertical', [ |
| 178 | + 'top' => 'Top', |
| 179 | + 'center' => 'Center', |
| 180 | + 'bottom' => 'Bottom', |
| 181 | + ], $verticalAlignment, function(string $option) use(&$state) { |
| 182 | + $state->stackAlignment = match([$state->stackAlignment, $option]) { |
| 183 | + [FUILayoutAlignment::topLeft, 'top'], [FUILayoutAlignment::centerLeft, 'top'], [FUILayoutAlignment::bottomLeft, 'top'] => FUILayoutAlignment::topLeft, |
| 184 | + [FUILayoutAlignment::topCenter, 'top'], [FUILayoutAlignment::center, 'top'], [FUILayoutAlignment::bottomCenter, 'top'] => FUILayoutAlignment::topCenter, |
| 185 | + [FUILayoutAlignment::topRight, 'top'], [FUILayoutAlignment::centerRight, 'top'], [FUILayoutAlignment::bottomRight, 'top'] => FUILayoutAlignment::topRight, |
| 186 | + [FUILayoutAlignment::topLeft, 'center'], [FUILayoutAlignment::centerLeft, 'center'], [FUILayoutAlignment::bottomLeft, 'center'] => FUILayoutAlignment::centerLeft, |
| 187 | + [FUILayoutAlignment::topCenter, 'center'], [FUILayoutAlignment::center, 'center'], [FUILayoutAlignment::bottomCenter, 'center'] => FUILayoutAlignment::center, |
| 188 | + [FUILayoutAlignment::topRight, 'center'], [FUILayoutAlignment::centerRight, 'center'], [FUILayoutAlignment::bottomRight, 'center'] => FUILayoutAlignment::centerRight, |
| 189 | + [FUILayoutAlignment::topLeft, 'bottom'], [FUILayoutAlignment::centerLeft, 'bottom'], [FUILayoutAlignment::bottomLeft, 'bottom'] => FUILayoutAlignment::bottomLeft, |
| 190 | + [FUILayoutAlignment::topCenter, 'bottom'], [FUILayoutAlignment::center, 'bottom'], [FUILayoutAlignment::bottomCenter, 'bottom'] => FUILayoutAlignment::bottomCenter, |
| 191 | + [FUILayoutAlignment::topRight, 'bottom'], [FUILayoutAlignment::centerRight, 'bottom'], [FUILayoutAlignment::bottomRight, 'bottom'] => FUILayoutAlignment::bottomRight, |
| 192 | + }; |
| 193 | + })->setId('v-align-btn-group'); |
| 194 | + |
| 195 | + FlyUI::end(); // end alignment section |
145 | 196 |
|
146 | | - FlyUI::end(); // end right settings area |
| 197 | + FlyUI::end(); // end right settings area |
147 | 198 |
|
148 | 199 | FlyUI::end(); // end main container |
149 | 200 |
|
|
0 commit comments