File Exchange

## GUIresizefcn

version 1.2.0.0 (233 KB) by
Resize function for GUIs.

1 Download

Updated 16 Dec 2014

View License

Makes it possible to specifiy positions of uicontrols and other graphics objects (e.g. axes) with pixels and normalized coordiantes at the same time. This allows e.g. to place a button with constant width and height in the top right corner of a figure and to resize the figure while keeping the button in the corner.

### Cite As

Dr.-Ing. Volker Sellmeier (2021). GUIresizefcn (https://www.mathworks.com/matlabcentral/fileexchange/48748-guiresizefcn), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (6)

Hi Andras, the idea of GUIresizefcn is just to add up both normal and pixel coordinates. So the position of the graphics object is defined by the sum of ud.normal and ud.pixels. The meaning of the structure is:
ud.pixels = [left bottom width height] %position in pixels
ud.normal = [left bottom width height] %position in normalized coordinates

% Axes (between the four buttons)
ud5.pixels = [120 30 -240 -40];
ud5.normal = [0 0 1 1 ];
With this structure the width of the axes goes over the whole width of the figure (ud5.normal(3)=1) minus 240 Pixels (ud5.pixels=-240). The x-Position is at 120 Pixels since ud5.normal(1)=0 and so on.

% Button 2 (top right)
ud2.pixels = [-100 -20 100 20 ];
ud2.normal = [1 1 0 0 ];
This button is located end the very right edge of the figure (ud2.normal(1)=1) minus 100 pixels (ud2.pixels(1)=-100).

I wonder why MathWorks does not implement this by default. In this case the Units-property could be switched to let's say 'normal/pixel' and then the position-property must be a 2x4-matrix with the position in pixels and normal coordinates which are then just summed up every time the figure gets resized.

Andras Saftics

Hi,
Thanks for the code, it seems very helpful. However I don't really understand the meaning of the ud.pixels and ud.normal structurres. What is the definition of dx, dy, dw, dh and fx, fy, fw, fh? In the example, there are negative position and width values, how is it possible?
Thank you!

RG

RG

RG

I recommend to set the units property of the uicontrols and graphic objects equipped with the callback function GUIresizefcn to 'pixels'. Otherwise some incorrect behavior can occur during resizing when using tabs.

##### MATLAB Release Compatibility
Created with R2012a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux

### Community Treasure Hunt

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

Start Hunting!