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

33 次查看(过去 30 天)
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.

采纳的回答

Melissa Williams
Melissa Williams 2019-4-25
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.
  1 个评论
Mary Hearn
Mary Hearn 2020-4-29
Thank you so much for this question and answer. It worked perfectly! I created an auto-reflow 2-panel canvas, and I need the panels to always resize as 50/50. Thank you for this Q&A platform; it is extremely effective and efficient.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by