MATLAB Answers

GUI Button Groups and Panel Containers Cause Cross Platform Issues?

1 view (last 30 days)
Hendrik Dewald
Hendrik Dewald on 21 Mar 2017
Edited: Afiq Azaibi on 30 Mar 2017
I'm designing multiple GUIs that I would like to be usable on both my Mac (MacBook Pro Retina 15inch early 2013) and on a lab computer running Windows 7. Both have Matlab 2015b. I have reviewed the Matlab documentation titled "Design Cross-Platform UIs in GUIDE", but have still had difficulties.
I made two GUIs first on my Mac, as it's my main work computer. Below are photos of the original designs when viewed on my Mac.
When viewing the GUIs on the Windows computer, I instead saw the following.
Playing around with Non-Resizable vs Proportional made no difference. And as changing all the fonts/fontsizes simultaneously seems to make GUIDE hang indefinitely, I decided to edit the GUI on the Windows computer. I did this because the Windows computer is much faster and so I'd much rather the GUI be optimized to this computer anyways. I was hoping my edits would translate back to my Mac with a slightly too large GUI which I could simply set to Proportional. After all, the major problems simply seemed to be that the text was larger when viewed in Windows.
And so I edited my GUIs through GUIDE on the windows computer, until I had the following (when viewed on the Windows computer):
I was happy with them, but I found the first GUI transformed into a monstrosity when viewed on my Mac:
Fiddling with Non-Resizable vs Proportional yielded no change. It seems that font size alone is not enough. I think perhaps screen resolution and DPI differences could account for the difference in size, but I am utterly baffled as to the tremendous mess that Panel Containers and Button Groups cause. Seeing how the DOFOptions GUI remained legible, I am inclined to believe that somehow the Panels and Groups are treated differently across platforms. Is there some solution to this issue?

Answers (1)

Afiq Azaibi
Afiq Azaibi on 30 Mar 2017
Edited: Afiq Azaibi on 30 Mar 2017
When interchanging the units of graphics objects in MATLAB, the way the figure appears in one environment may be drastically different in another. This can be caused by a difference in monitors and screen resolutions especially if the 'pixel' unit is being used. A best practice is to stay consistent with using the 'normalized' unit for these objects which gets rendered in respect to its parents opposed to the screen. If you have code that looks the way you want but is using a variety of units, try using the following function to find all instances of units to 'normalized' within your figure:
function [] = normalize(obj)
%sets to normal if it can
prop = properties(obj);
if(sum(ismember(prop,'Units')))
obj.Units = 'normalized';
end
%recurses on all the children
if(~isempty(obj.Children))
for i = 1:length(obj.Children)
normalize(obj.Children(i));
end
end
end

Community Treasure Hunt

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

Start Hunting!