How can I lock resolution on images?
5 views (last 30 days)
Show older comments
Stelios Fanourakis on 6 Oct 2019
Commented: Walter Roberson on 7 Oct 2019
Let me give an example. I designed a GUI figure using GUIDE putting some elements upon it such as sliders, buttons, etc. This Figure was created in a small screen of 12 and 15" inches accordingly.
The pixel positions of the elements were set by that resolution. When I tried to project the same figure on a desktop screen with 22" or 25" size, I saw the sliders buttons and text frames displaced having their original position on screen that couldn't fit on a bigger screen with different resolution.
Is there a Matlab command to lock the positions of those elements according to their figure position no matter the screen size they are going to be displaced?
Looking forward to your help.
Image Analyst on 6 Oct 2019
Try setting the units property of all the controls to "pixels" if you want them at the same pixel position regardless of how many pixels are on different screens.
Try setting the units property of all the controls to "normalized" if you want them at the same relative position (percentage of way across or down the screen) regardless of how many pixels are on different screens.
On the smaller monitor, open the figure. Execute the command
set( findall(groot, '-property', 'Units'), 'Units', 'normalized')
Save the figure again. It can now be opened on the larger monitor and everything should scale.
Walter Roberson on 6 Oct 2019
There is a tension between elements of a GUI that is difficult to resolve by just resizing.
Graphs can mostly be resized arbitrarily as long as the aspect ratio is preserved. There is a lower limit below which not all of the detail can be discerned, but humans are pretty good at understanding that "space was limited" and mostly be forgiving as long as the general trend is still visible.
Text, however, gets unreadable below a point, and "looks wrong" if it is too large for the situation.
The proportions that are accepted for graphs are not the same proportions that are accepted for text.
Meanwhile, the sizes that are accepted for some of the user interface elements such as scroll bars sit within a narrow physical range, and do not scale well.
The result of all of this is that mostly you have to let the UI elements sit around a certain physical size without scaling, and that you probably want to constrain how large text will get, whereas graphs can scale up.
In particular, you probably want to re-flow text when you change the proportions of the container rather than scale it up proportionally. And if you define the size of a particular section of a ui as being "just large enough to comfortably fit this text" then you end up moving pieces of the interface around as you resize, and you start to have to develop rules such as "This element is variable in size to fit the current font size representation of this string, and this other element should be just to the right of it and the same height". You start to develop a "layout" instead of fixed positions.
Layouts are beyond the scope of GUIDE. App Designer starts to provide some layout tools.
Have the graphs and texts rescaled propotionally based on the rescaling of the main figure they are placed on.
My experience with this topic is that rescaling everything proportionally will look bad.
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!