Layouts – preview & discussion… anyone? please ;)

Oh hey! I have cell clipping working.

It will be a param setting for the layout… so must be explicitly enabled. But it works really nice. I’ll likely need to change the initial clipping call to setControlClippingLayer… as I believe that’s the one that recursively set child clipping if the control doesn’t override it.

But… anyways… it works!

@rockfire
I had almost no time to play with this today as I have company in from out of town… however, where I had left off was ensuring that relative, absolute and variable resizing all worked together. It took me the better part of an hour to track down that I was not resetting the SizeUnit back to absolute.as I was looping through to setup Cell dimensions. So, after hitting a variable or percentage based cell, everything was going weird. Anyways, long story short… it works really well now!

A layout like this:
[java]
new MigLayout(screen, “[150][30%][][200][]”,"[][][30%][][150][]");
[/java]

Will produce correct resizing results now… seriously thought I was losing my mind as I read over the code. Everything looked right… >.<

Hey @t0neg0d have you examples for all the stuff we can do with the layouts. I need some examples to use it =)

@Snowsun92 said: Hey @t0neg0d have you examples for all the stuff we can do with the layouts. I need some examples to use it =)

So sorry for the delay… I’m semi-buried in company from out of town and haven’t had much time to put into anything development related lately. Once they are on their way, I’ll put together some examples.

1 Like

I’ve just started coming back to working on GUI stuff and have a quick note to anyone using the MigLayout and possibly the other Layouts too:

The constructor for MigLayout is
[java]MigLayout(ElementManager screen, String cols, String rows, String… constraints)[/java]

When you define LayoutHints, you might type something like this:
[java].define(“cell 1 0”, “span 2 1”, “pad 10 10 10 10”)[/java]

  1. The MigLayout constructor wants you to enter information column-row order.
  2. The “cell” attribute of LayoutHint wants numbers in row-column order.
  3. The “span” attribute interprets its values as “span in X direction” and then “span in Y direction,” which is effectively column-row order (x direction goes across columns, y direction goes across rows).

So, you construct a layout using col-row, define element locations using row-col, then define each element’s span using col-row again. I’d recommend that the LayoutHint code swap the “cell” attribute from row-col to col-row to be consistent with the rest. I was getting ArrayOutOfBoundsExceptions and had no idea why! :slight_smile:

I started playing with the Mig layout and found some strange behavior with text boxes and select boxes where the dropdown button or cursor will not match the size the element is at or even the position. Buttons and containers seem to work fine.

code example:

element.getLayouHints().define("cell 1 1", "span 2 1");
parent.addChild(element);
parent.getLayout().layoutChildren();

Am i missing something or is it just that this is a work in progress yet?