Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VisUI Bug] GridGroup inside MultiSplitPane not resizing correctly #218

Open
mbrlabs opened this issue Sep 26, 2016 · 3 comments
Open

[VisUI Bug] GridGroup inside MultiSplitPane not resizing correctly #218

mbrlabs opened this issue Sep 26, 2016 · 3 comments
Labels

Comments

@mbrlabs
Copy link

mbrlabs commented Sep 26, 2016

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

@kotcrab
Copy link
Owner

kotcrab commented Sep 27, 2016

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();

@mbrlabs
Copy link
Author

mbrlabs commented Sep 27, 2016

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

@kotcrab kotcrab added the wontfix label Oct 8, 2016
@kotcrab kotcrab closed this as completed Oct 8, 2016
@metaphore
Copy link
Contributor

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

grid-group-resize-bug.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;
}

@czyzby czyzby reopened this Jan 8, 2023
@czyzby czyzby removed the wontfix label Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants