Can movegui in openfig be disabled?

3 visualizzazioni (ultimi 30 giorni)
Johnny B
Johnny B il 23 Apr 2014
Commentato: Johnny B il 24 Apr 2014
I have a dual-monitor setup with my left (primary) monitor rotated into a portrait orientation, so that the monitor width is only 1024 pixels. I'm trying to run a program that loads a GUI figure that is 1300 pixels wide. When I run the program, the figure gets resized to be only 1014 pixels wide. The culprit appears to be a call to movegui(fig(n),'onscreen') in openfig , which gets called to open the .FIG file. I don't want the figure to be resized; in my extended desktop, the figure would be just fine spilling into the other monitor. Plus, the figure's children's units are not normalized, so important controls are being chopped off the right side of the figure.
For now, I've commented-out the call to movegui on line 109 of openfig . I'm always reluctant to modify Mathworks-supplied files, so I was looking for an alternate method of keeping MATLAB from resizing the figure.

Risposte (1)

Walter Roberson
Walter Roberson il 24 Apr 2014
GUIDE is an approximation of a GUI creation tool. Sometimes you need to repair the code it generates, such as by commenting out movegui() in your case.
  1 Commento
Johnny B
Johnny B il 24 Apr 2014
I guess I wasn't clear enough in my description of my problem. GUIDE has nothing to do with it; it's the act of opening the figure that causes the problem. I'm typing this on a computer with a single monitor with a width of 1680 pixels. Here's an example of what MATLAB will do to me:
>> get(0,'screenSize')
ans =
1 1 1680 1050
>> figure
>> plot(randn(100,1))
>> set(gcf,'position',[1 400 1680 420])
>> get(gcf,'position')
ans =
1 400 1680 420
{{{ Here I save the figure using the figure's menu }}}
>> close
{{{ Here I open the figure using the command window menu }}}
>> get(gcf,'position')
ans =
38 400 1664 414
Notice that the figure's width has been reduced to 16 pixels narrower than my screen. When you open a figure in MATLAB, it uses $matlabroot\toolbox\matlab\graphics\openfig.m to do the work. This function in turn calls $matlabroot\toolbox\matlab\uitools\movegui.m, which makes sure the figure it's opening fits on the screen. I suppose that the behavior in this example is reasonable, though I'd prefer that it not make the figure smaller than the actual screen width. The problem really occurs when the primary monitor is narrower than the second monitor. The act of opening the figure causes MATLAB to resize the figure to fit on the primary monitor, even if "extended desktop" would allow it to spill onto the second monitor. I think this is really a bug in movegui ; it should use MonitorPositions instead of ScreenSize to decide whether the figure will fit.

Accedi per commentare.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by