Skip to content

WBox with horizontalAlignment set to RIGHT will automatically expand when a widget is added. #174

@xiaocihua

Description

@xiaocihua

Describe the bug
The number of pixels expanded to the right is the same as the horizontal size of the insets.

To Reproduce
Add these code to the subclass of LightweightGuiDescription:

var root = new WBox(Axis.HORIZONTAL);
setRootPanel(root);
root.setSize(200, 240);
root.setInsets(Insets.ROOT_PANEL);
root.setHorizontalAlignment(HorizontalAlignment.RIGHT);
root.add(new WButton());
root.validate(this);
System.out.println(root.getWidth());

If horizontalAlignment is LEFT, the width is 200; If it's RIGHT, the width is 207.

Expected behavior
Fix the width of WBox.

Version of the (please complete the following information):
-LibGui 6.3.0
-Fabric api 0.61.0
-Minecraft 1.19.2

Additional context
This problem can be solved by moving the setSize call after validate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions