Skip to content

Conversation

@miozune
Copy link
Collaborator

@miozune miozune commented Apr 9, 2025

This is the code I used to test behaviors:

public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) {
    ModularPanel panel = new ModularPanel("test_tile");
    panel.child(new Rectangle().setColor(Color.RED.main).asWidget().alignX(0.5f).alignY(0.4f).size(1));
    Flow row = Flow.row();
    panel.child(row
            .center()
            .coverChildrenHeight()
            .width(150)
            .padding(2)
            // .paddingLeft(20)
            .collapseDisabledChild()
            .mainAxisAlignment(Alignment.MainAxis.SPACE_BETWEEN)
            .childPadding(3)
            .background(GuiTextures.DISPLAY)
            .child(new TestButton(row)
                    .overlay(IKey.str("1")))
            .child(new TestButton(row)
                    .overlay(IKey.str("2"))
                    .marginLeft(7))
            .child(new TestButton(row)
                    .overlay(IKey.str("3")))
            .child(new TestButton(row)
                    .overlay(IKey.str("4"))
                    .marginRight(7))
            .child(new TestButton(row)
                    .overlay(IKey.str("5"))));
    return panel;
}

private static class TestButton extends ButtonWidget<TestButton> {
    private TestButton(IWidget widget) {
        onMousePressed($ -> {
            setEnabled(false);
            if (NetworkUtils.isClient()) {
                WidgetTree.resize(widget);
            }
            return true;
        });
    }
}

@miozune miozune requested a review from brachy84 April 9, 2025 15:38
@brachy84 brachy84 merged commit f42ea21 into master Apr 12, 2025
@brachy84 brachy84 deleted the feature/layout-disabled-children branch April 12, 2025 13:02
brachy84 pushed a commit to brachy84/ModularUI2-GTNH that referenced this pull request May 15, 2025
* Allow collapsing disabled child widgets

* Fix disabled child's margin being considered

* Correct comment and variable name

* Remove seemingly unreachable code

* Fix space size

* Fix division by zero

* Fix padding

* oops

(cherry picked from commit f42ea21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants