vis-ui icon indicating copy to clipboard operation
vis-ui copied to clipboard

[VisUI Bug] GridGroup inside MultiSplitPane not resizing correctly

Open mbrlabs opened this issue 9 years ago • 3 comments
trafficstars

Hello, i have a rather complex ui setup, that is seperated into 3 parts using the MultiSplitPane. Column 1 & 2 are pretty simple, in the thrind col i have a GridGroup, containing some elements. If i move the second handle between column 2 & 3 the thrind column gets bigger (as expected). But if i try to move it back the content of the thrid column (GridGroup) doesn't get smaller.

Initial state: gridbug0

move handle to left: gridbug1

move handle to the right gridbug2

Source of the example: MyGdxGame.txt

I'm not sure if this is a bug or it's just not supported..or i'm doing something wrong?

Libgdx 1.9.4 VisUI 1.2.3 Linux Mint

mbrlabs avatar Sep 26 '16 20:09 mbrlabs

Ah yes, this a tricky one coming from combination of GridGroup and Tables. So what's going on here: you have structure like this MultiSplitPane -> Table -> Table-> GridGroup. MultiSplitPane is working correctly, and the first table is getting its size set correctly. The actual problem comes from GridGroup embedded in Table with expandX().fillX() (growX() effectively) which causes it to become 'greedy', consuming all available width as it's grows and prevents it from shrinking.

Unfortunately I don't know how to fix it, I tried but I encountered another issue when GridGroup: children won't overflow to next row because Table won't ever allow to set cell size below it's preferred size and since GridGroup relays on having correct width this makes GridGroup think that there is just enough space for single row and won't create new rows.

I can suggest a workaround though, you have to manually set group cells to proper width, like this:

        c2.add(grid).width(new Value() {
            @Override
            public float get (Actor context) {
                return c2.getWidth();
            }
        }).row();
        table3.add(c2).width(new Value() {
            @Override
            public float get (Actor context) {
                return table3.getWidth() - 20; //padding must be manually acknowledged here
            }
        }).pad(10).row();

kotcrab avatar Sep 27 '16 19:09 kotcrab

Tricky indeed ;) Thanks for the explanation, the workaround will do it.

mbrlabs avatar Sep 27 '16 20:09 mbrlabs

I just encountered the same issue. it actually appears to be a bug, if compared to the resizing behavior of other widgets.

https://user-images.githubusercontent.com/6159734/211216959-3a8cc9eb-5d3e-4f1b-825a-4ac61d1dbdfe.mp4

The cause of the problem is GridGroup doesn't provide correct min size layout values and is locked to the preferred size. Thus doesn't resize down at all.

The fix is rather simple, GridGroup should have these methods overriden:

@Override
public float getMinWidth() {
    return 0f;
}

@Override
public float getMinHeight() {
    return 0f;
}

metaphore avatar Jan 08 '23 20:01 metaphore