0

I have created a basic MATLAB UI (without using GUIDE). I basically have a bunch of panels for various things, (sliders, axes, text boxes, etc).

The one thing I would like to do though, it make it so that they scale properly, when I resize the figure. Right now, I painstakingly have to make a re-scale function for every button, panel, sub-panel, etc etc to make it rescale correctly.

Is there an easy way to simply automate the re-scaling here?

Thanks.

Spacey
  • 2,941
  • 10
  • 47
  • 63

2 Answers2

3

Use the GUI Layout Toolbox from the MATLAB File Exchange. I haven't personally used dynamic resizing functionality, but that's one benefit of using this package.

It functions much like using uicontrols, except you can't use the inspect tool on these objects.

EDIT: If you're looking only to do resizing when the figure itself is resized, set the Units property for all your uicontrols to normalized.

Dang Khoa
  • 5,693
  • 8
  • 51
  • 80
  • Hmm, I think I might have to use the inspect tool though. – Spacey Nov 14 '13 at 18:43
  • You can still use `get(h)` to see the properties, though. You just can't do it with the graphical tool. – Dang Khoa Nov 14 '13 at 18:59
  • How do you mean? What I would basically like to do is make my UI normally through coding, but make all the panels etc rescale automatically when I resize a figure... – Spacey Nov 14 '13 at 19:15
  • The inspect tool is only used to mess around with the [handle object properties](http://www.mathworks.com/help/matlab/learn_matlab/understanding-handle-graphics-objects.html#btc_la2-1) when you're setting up your GUI. It's just a graphical interface for the `set` and `get` calls on those handle objects. In the end, you won't need to use `inspect` for anything. The `uiextras` objects you create with the GUI Layout Toolbox will take care of dynamically resizing for you. – Dang Khoa Nov 14 '13 at 19:36
  • Yes, I am looking to everything being re-sized automatically when I myself re-size a figure. I think your edit concerns this, yes? – Spacey Nov 14 '13 at 20:01
2

You could also use the builtin, but undocumented uigridcontainer and uiflowcontainer.

They have the benefit of e.g. allowing to set contraints, such that e.g. your pushbuttons don't get increased in size, when the full figure does. Check the link for some examples: http://undocumentedmatlab.com/blog/matlab-layout-managers-uicontainer-and-relatives/

sebastian
  • 9,526
  • 26
  • 54