1313 parentGrid , row );
1414 case ' action'
1515 ui = buildAction(ui , controlSpec , parentGrid , row , [1 2 ]);
16- case ' actionGroup '
17- ui = buildActionGroup (ui , controlSpec , parentGrid , row );
16+ case ' group '
17+ ui = buildGroup (ui , controlSpec , parentGrid , row , debug );
1818 case ' filePanel'
1919 ui = buildFilePanel(ui , controlSpec , parentGrid , row );
2020 case ' resultTable'
2929 ui = buildToolPanelControl(ui , controlSpec , parentGrid , row );
3030 otherwise
3131 error(' labkit:ui:app:UnsupportedControl' , ...
32- ' Unsupported UI 3 .0 control kind "%s ".' , controlSpec .kind);
32+ ' Unsupported UI 4 .0 control kind "%s ".' , controlSpec .kind);
3333 end
3434end
3535
100100 applyTextFit(control );
101101 otherwise
102102 error(' labkit:ui:app:UnsupportedFieldKind' , ...
103- ' Unsupported UI 3 .0 field kind "%s ".' , kind );
103+ ' Unsupported UI 4 .0 field kind "%s ".' , kind );
104104 end
105105 applyCommonValueProps(control , props );
106106 applySliderTicks(control , props );
@@ -173,10 +173,26 @@ function setRangeValue(newValue)
173173 end
174174end
175175
176- function ui = buildActionGroup(ui , groupSpec , parentGrid , row )
176+ function ui = buildGroup(ui , groupSpec , parentGrid , row , debug )
177+ if usesActionLayout(groupSpec )
178+ ui = buildActionLayout(ui , groupSpec , parentGrid , row );
179+ return ;
180+ end
181+ ui = buildFormGroup(ui , groupSpec , parentGrid , row , debug );
182+ end
183+
184+ function tf = usesActionLayout(groupSpec )
185+ layout = lower(char(string(optionValue(groupSpec .props, ' layout' , ' auto' ))));
186+ childKinds = string(cellfun(@(child ) child .kind, groupSpec .children, ...
187+ ' UniformOutput' , false ));
188+ tf = strcmp(layout , ' actions' ) || ...
189+ (strcmp(layout , ' auto' ) && all(childKinds == " action" ));
190+ end
191+
192+ function ui = buildActionLayout(ui , groupSpec , parentGrid , row )
177193 actions = groupSpec .children;
178194 count = max(1 , numel(actions ));
179- maxColumns = actionGroupMaxColumns (groupSpec );
195+ maxColumns = actionLayoutMaxColumns (groupSpec );
180196 columnCount = min(count , maxColumns );
181197 rowCount = max(1 , ceil(count / columnCount ));
182198 grid = uigridlayout(parentGrid , [rowCount columnCount ]);
@@ -187,7 +203,7 @@ function setRangeValue(newValue)
187203 grid.ColumnWidth = repmat({' 1x' }, 1 , columnCount );
188204 grid.Layout.Row = row ;
189205 grid.Layout.Column = [1 2 ];
190- adapter = baseAdapter(groupSpec , ' actionGroup ' );
206+ adapter = baseAdapter(groupSpec , ' group ' );
191207 adapter.grid = grid ;
192208 adapter.actions = struct();
193209 ui .controls.(groupSpec .id) = adapter ;
@@ -204,7 +220,42 @@ function setRangeValue(newValue)
204220 end
205221end
206222
207- function maxColumns = actionGroupMaxColumns(groupSpec )
223+ function ui = buildFormGroup(ui , groupSpec , parentGrid , row , debug )
224+ childCount = max(1 , numel(groupSpec .children));
225+ titleText = char(string(optionValue(groupSpec .props, ' title' , ' ' )));
226+ if strlength(string(titleText )) > 0
227+ host = uipanel(parentGrid , ' Title' , titleText );
228+ else
229+ host = uipanel(parentGrid , ' BorderType' , ' none' );
230+ end
231+ host.Layout.Row = row ;
232+ host.Layout.Column = [1 2 ];
233+
234+ grid = uigridlayout(host , [childCount 2 ]);
235+ grid.RowHeight = groupRowHeights(groupSpec .children);
236+ grid.ColumnWidth = {120 , ' 1x' };
237+ grid.RowSpacing = 6 ;
238+ grid.ColumnSpacing = 8 ;
239+ grid.Padding = [0 0 0 0 ];
240+
241+ adapter = baseAdapter(groupSpec , ' group' );
242+ adapter.panel = host ;
243+ adapter.grid = grid ;
244+ ui .controls.(groupSpec .id) = adapter ;
245+ for iChild = 1 : numel(groupSpec .children)
246+ ui = buildControl(ui , groupSpec.children{iChild }, grid , iChild , debug );
247+ end
248+ end
249+
250+ function rowHeight = groupRowHeights(children )
251+ count = max(1 , numel(children ));
252+ rowHeight = repmat({' fit' }, 1 , count );
253+ for k = 1 : numel(children )
254+ rowHeight{k } = specRowHeight(children{k }, ' fit' );
255+ end
256+ end
257+
258+ function maxColumns = actionLayoutMaxColumns(groupSpec )
208259 maxColumns = 2 ;
209260 labels = actionLabels(groupSpec .children);
210261 if any(strlength(labels ) > 28 )
0 commit comments