MATLAB: In appdesigner, is there any way to control which panels change size under auto-reflow

appdesignerauto reflowMATLABuifigure

Under App Designer, is there any way to select which panel(s) change size under "Auto-Reflow"? In the two-panel template, for example, it seems only the right-hand panel changes size with the UI and that this is not user-selectable.

Best Answer

Hi Kevn,
You're right, this is not curently user configurable in the design environment. If you wanted to "override" the generated code algorithm and change the behavior, you could do something like this:
Add a startup function and change the Figure Size change callback to use your own function
% Code that executes after component creation
function startupFcn(app)
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @myUpdateAppLayout, true);
end
Then add a function and adjust the grid code. In your example to make the left column grow and the right column fixed, you would reverse the line app.GridLayout.ColumnWidth = {'1x', 299}; where 1x is grow and 299 is the fixed width.
function myUpdateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2x1 grid
app.GridLayout.RowHeight = {480, 480};
app.GridLayout.ColumnWidth = {'1x'};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {'1x', 299};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
Keep in mind, this will "disconnect" you somewhat from the design view layout, if you change the height of your app or the width of your two columns, you will want to update the numbers in your function.