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

Trouble with @children on derived component #5071

Closed
FloVanGH opened this issue Apr 16, 2024 · 0 comments · Fixed by #5072
Closed

Trouble with @children on derived component #5071

FloVanGH opened this issue Apr 16, 2024 · 0 comments · Fixed by #5072
Labels
a:compiler Slint compiler internal (not the codegen, not the parser)

Comments

@FloVanGH
Copy link
Member

I noticed that I have trouble with the padding and constraint of a layout inside of a base component if I use inherits. In the following example the padding of the HorizontalLayout for FinalButton is not respected and for MyButton is respected:

export component ButtonBase {
    in property <brush> background: green;

    Rectangle {
        width: 100%;
        height: 100%;
        background: root.background;
    }

    HorizontalLayout {
        @children
    }
}

export component MyButton inherits ButtonBase {
    horizontal-stretch: 0;
    vertical-stretch: 0;

    layout := HorizontalLayout {
        padding-left: 16px;

        @children

    }
}

export component FinalButton inherits MyButton {
    background: blue;
}

export component MyWindow inherits Window {
    width: 600px;
    height: 400px;

    HorizontalLayout {
        alignment: start;

        button := FinalButton {
            Text {
                text: "Final Button";
            }
        }

        MyButton {
            Text {
                text: "My Button";
            }
        }
    }

    Text {
        text: button.min-width / 1px;
    }
}

As workaround the padding is respected after adding @children to FinalButton:

export component FinalButton inherits MyButton {
    background: blue;
    @children
}
@FloVanGH FloVanGH added the a:compiler Slint compiler internal (not the codegen, not the parser) label Apr 16, 2024
ogoffart added a commit that referenced this issue Apr 16, 2024
ogoffart added a commit that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:compiler Slint compiler internal (not the codegen, not the parser)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant