Code covered by the BSD License  

Highlights from
GridLayout

4.5

4.5 | 2 ratings Rate this file 19 Downloads (last 30 days) File Size: 12.5 KB File ID: #29472
image thumbnail

GridLayout

by

 

20 Nov 2010 (Updated )

An intuitive and flexible layout manager

| Watch this File

File Information
Description

GridLayout was inspired by the GridBagLayout manager. It is equally flexible but more intuitive for my taste and it also requires less boilerplate code.

Each cell is a uicontainer and can hold only one child. Unlike GridBagLayout, children are added at creation time by passing the cell container handle as their parent. No 'Add' methods are needed, which reduces the amount of code.

Cell sizes can be specified in pixels or as relative values. Merging and removing cells are supported, as well as various alignment options: stretch, center, left, right, top, bottom.

The archive also includes demos illustrating the GridLayout capabilities . Bug reports and suggestion for improvement are very much appreciated. Download, unpack, and enjoy!

Acknowledgements

Grid Bag Layout inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
18 May 2012 Mihail Petrov

Eric, the Layout.Cell property itself is an array of uicontainers. This is one of the the main features of GridLayout. You don't need any additional function.

17 May 2012 Eric Cousineau

To make it easier to wrap child objects, such as nested GridLayout's and plots, I think a function such as GridLayout.WrapCell(Row, Col) would help. It would create a uicontainer() inside the cell, and then return a handle to that container.

28 Mar 2012 Mihail Petrov

Another change was to replace the HMargin and VMargin parameters with LMargin, RMargin, TMargin, and BMargin, that is, left, right, top, and bottom. This is very useful for axes in particular. See demo 7 for an example.

27 Mar 2012 David

Sounds awesome, can't wait to give it a try! Thanks Mihail!

10 Oct 2011 Mihail Petrov

Hi David & Eric,

Give me a few days still and I'll upload the fixed version. I've been really busy these days...

Thanks for your feedback!

08 Oct 2011 David

Pretty cool library, thanks! I'm having problem #2 mentioned above by Eric Cousineau. Really needs to be able to handle multiple children in an axes object to be functional for plotting purposes.

08 Sep 2011 Eric Cousineau

Sure thing! I commented a small portion in the constructor to allow ~ishghandle() objects to contain a GridLayout.
I also updated the UpdateLayout() method to allow for plots.
I have uploaded a diff file: http://pastebin.com/knn05prR

However, I think it would probably be easier if both plots and child GridLayouts were wrapped in uicontainers() - that way they can be contained by a GridLayout. I was thinking that this wrapping could happen at the first call to UpdateLayout().

17 Aug 2011 Mihail Petrov

Eric, thanks for the feedback and rating.

Could you indicate what exactly you changed in the code? In the past months I made several small changes myself and I'd like to merge them with yours before uploading a new version.

15 Aug 2011 Eric Cousineau

Just realized a couple of things:
1) You can nest GridLayout's by disabling the check (ishghandle()) in the constructor and wrap it in a uicontainer.
2) If you add legends for your plot, it will introduce additional children into the cell, causing errors. The best fix for this is to wrap it in a container. This is also another bugfix towards adding plots without the little workaround.

15 Aug 2011 Eric Cousineau

This is an awesome redux of GridBagLayout!

I noticed that there was a bug when resizing plots. Found a bugfix in Jason's layout.GridBagLayout and incorporated it into GridLayout.ResizeCell().

I have uploaded the code to
http://pastebin.com/fqRhFCgC

Thank you again!

Updates
22 Nov 2010

A few bugs were fixed and an additional demo added.

27 Mar 2012

Added support for:

1) axes with legends (as requested)

2) nested layouts (as requested)

3) automatic row/column sizing (experimental)

28 Mar 2012

Forgotten to add ParseArgs and GetArg functions to the release.

Contact us