フィルターのクリア

How to move panels and uicontrols collectively as a group in a figure?

2 ビュー (過去 30 日間)
Fredrik Gustavsson
Fredrik Gustavsson 2016 年 8 月 12 日
回答済み: Fredrik Gustavsson 2016 年 8 月 12 日
I have a giant GUIDE constructed GUI with many panels and multilevel subpanels and then uicontrols and graphs all over those panels. When I started four years ago, I did the mistake to build the GUI for one screen resolution only. I've tried numerous ways to make the GUI look good in other resolutions by scaling it but there are always some controls that looks ugly or end up in the wrong place.
As a compromise solution, I now plan not to try to scale the GUI but allow it to shrink at higher screen resolutions. I would, however, like the GUI to be centered on the screen and the figure window to be maximized to fill the whole screen. Right now the GUI bounding box is alignes with the lower left corner of the figure window when it is maximised. My question is: how can I move all these GUI components collectively as a group inside the figure? I am looking for something like "select all" and then specify a fixed pixel displacement in x and y. Can it be done?
  2 件のコメント
Adam
Adam 2016 年 8 月 12 日
Do you mean how do you do it in GUIDE or programmatically or as a a user once you have launched the GUI?
Fredrik Gustavsson
Fredrik Gustavsson 2016 年 8 月 12 日
Thanks. It should be done programatically.

サインインしてコメントする。

採用された回答

Fredrik Gustavsson
Fredrik Gustavsson 2016 年 8 月 12 日
By selecting all objects directly descendant from the main figure (with handles hObject) and only shift them, it seems to work as I would like to:
firstLevelHandles=findall(hObject,'parent',hObject);
currentRes=get(0,'monitorposition'); %the current screen resolution
shiftPos=[(currentRes(3:4)-[1366 768])./2 0 0]; %1366x768 is the default resolution
for i=1:length(firstLevelHandles)
basePos=getpixelposition(firstLevelHandles(i),true);
setpixelposition(firstLevelHandles(i),basePos+shiftPos,true);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by