Listen for when uigridlayout finishes resizing children

3 visualizaciones (últimos 30 días)
Thomas Watson
Thomas Watson el 1 de Mzo. de 2023
Respondida: Amit Dhakite el 12 de Abr. de 2023
Is there a property or event that I can listen to that occurs after a uigridlayout has finished automatic layout/resizing its children?
I'm using a uigridlayout to automatically place 2 uiaxes in a vertical stack (one on top of the other).
I am trying to make the bottom axes's X-position and width dynamically match the InnerPosition of the top axes. This makes the bottom axes perfectly line up vertically with the top axes and ignores the area used by ticks/tick marks. The size and data of the axes can change dynamically, hence needing to adjust the bottom axes position to match the top without user interaction.
The problem is the internal function setPositionForAutoResizableChildren (from a callstack involving LayoutableControl) is setting the OuterPosition of the bottom axes and overriding my manually-set InnerPosition.
The execution essentially boils down to:
  1. My code: Change size of RowHeight for a child element, e.g. grid.RowHeight{1} = '1x'
  2. My code: Set Bottom axes's InnerPosition([1 3]) = Top axes's InnerPosition([1 3]), e.g. [30, 800]
  3. Internal Matlab code: setPositionForAutoResizableChildren(Bottom axes, 'OuterPosition', [1, _, 850, _], ...)
My manual x/width offset in #2 is getting overridden by #3 since the uigridlayout is laying children out after my code runs.
I don't want to rely on a timer with some hardcoded delay to work around this because of how hacky that is.
drawnow after changing the RowHeight and before setting the axes InnerPosition doesn't seem to make the gridlayout finish resizing first.
It would be nice if uigridlayout let you have the best of both worlds - automatic initial layout, and then manual adjustments afterward (within the same callstack, or via listener/callback).
Being able to programmatically toggle a uigridlayout's automatic layout would also be helpful, or at least making it respect its parent container's AutoResizeChildren property, since right now it ignores it.

Respuestas (1)

Amit Dhakite
Amit Dhakite el 12 de Abr. de 2023
Hi Thomas,
As per my understanding, you want an event once ‘uigridlayout’ has finished automatic resizing of containers.
You may use ‘SizeChangedFcn’ callback that resizes UI components. The callback executes whenever the figure window size changes.
For further information, kindly refer to the following link which gives information about how to manage resize behaviour:

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by