Create GUI figures which scale position and size based on resolution

조회 수: 14 (최근 30일)
Ak K
Ak K 2018년 7월 14일
댓글: OCDER 2018년 7월 20일
Hello, I have a program which first has one GUI which has a button which is pushed to call three other GUIs. I want these four GUIs to have a set layout, in that the initial GUI occupies ~1/4 of the screen on the left side, two GUIs stacked upon each other in the middle of the screen, then the final GUI on the right side. I have changed the positions for each and made it so that this layout is present using my laptop at its native screen resolution. The issue, however, is that I plan to give the program to others, and when I change the screen resolution of my laptop to one with a different aspect ratio of a smaller size, the distance between GUIs and their size remains the same. This pushes the last, right-most GUI partially off the screen. I have set all units, including font units and position units, to 'normalized' for all four GUI windows. Is there something else I have to do to have the window size scale automatically?
Thanks, Ak
  댓글 수: 8
Adam
Adam 2018년 7월 18일
My second monitor is just considered as an extension of the first in terms of size - e.g. screen resolution returns 1920 as my lateral screen size. If I position a figure at 2100 it puts it on the second monitor.
You can use
get( groot, 'MonitorPositions' )
if you want to make full use of the real estate available on a given machine, although this would involve having to do different things depending how many monitors there are. The above command gives me a 2x4 output for my monitors so taking the size of the first dimension of this result will tell you how many monitors there are, though there may be a single call function that also gives you this that I am not aware of.
As an aside, if you want to nosey into what is available (which I always do!)
get( groot )
will give a list of all the values you can query from groot.
Ak K
Ak K 2018년 7월 18일
Currently, I have the positions (for each GUI) set within the GUI Property Inspector based on the (0,0) to (1,1) scale. I understand that if I get the dimensions of the display, I could hypothetically set the position based on that, for example putting one window at 1/3 of the display from the left and 1/3 of the display off the bottom. I do not, however, know how to alter the position of a GUI without doing so within the property inspector.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2018년 7월 18일
Fig1H = figure('Units', 'normalized', 'Position', [0, 0, 0.25, 1], 'Name', 'Figure 1');
Fig2H = figure('Units', 'normalized', 'Position', [0.25, 0.5, 0.5, 0.5], 'Name', 'Figure 2');
Fig3H = figure('Units', 'normalized', 'Position', [0.25, 0, 0.5, 0.5], 'Name', 'Figure 3');
Fig4H = figure('Units', 'normalized', 'Position', [0.75, 0, 0.25, 1], 'Name', 'Figure 4');
This creates two figures with 1/4 of the width and the full height on the left and right, and two figures on top of each other at the center. Does this help already?
  댓글 수: 11
Rik
Rik 2018년 7월 20일
@Jan, not entirely: try it with you taskbar on the side instead of top or bottom. I also have my IM program docked on the other side, so maximizing is the only way to find out how much screen real estate you have to work with. In my case the position is [0.0431 0 0.8243 0.9144] for a maximized window.
OCDER
OCDER 2018년 7월 20일
Matlab 2018a now has the WindowState property of a figure to allow users to maximize a figure according to the OS behavior.
set(FigH(1), 'WindowState', 'maximized')
ScreenPosWithoutTaskbar = get(FigH(1), 'Position');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by