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

Self-referential bindings to reduce clutter #6696

Open
Enyium opened this issue Nov 1, 2024 · 0 comments
Open

Self-referential bindings to reduce clutter #6696

Enyium opened this issue Nov 1, 2024 · 0 comments
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) need triaging Issue that the owner of the area still need to triage

Comments

@Enyium
Copy link
Contributor

Enyium commented Nov 1, 2024

Consider this SlintPad demo (see comments):

component Foo {
    VerticalLayout {
        Rectangle {
            height: 20px;
            background: lightskyblue;
        }

        Text {
            text: "This content happens to expand the component beyond the outer minima.";
        }
    }
}

export component Demo {
    VerticalLayout {
        alignment: center;

        //HorizontalLayout {
        //VerticalLayout {
        //Rectangle {
            // Not better than the same in `Foo`.
            /*
            min-width: 200px;
            min-height: 20px;
            */

            // Having to use wrapper elements and these calculations
            // increases your UI code's verbosity and complexity to an
            // undesirable degree.
            /*
            min-width: max(200px, foo.min-width);
            min-height: max(20px, foo.min-height);
            */

            foo := Foo {
                // This rigorously overwrites the inner constraints,
                // leading to the component overdrawing other UI elements.
                /*
                */
                min-width: 200px;
                min-height: 20px;

                // A property that creates a binding loop with itself
                // could implicitly create another outer property of the
                // same name, or compile to unified property evaluation
                // code.
                //min-width: max(200px, self.min-width);

                // There could be a shorthand syntax for this, with its
                // meaning defined by the compiler per property.
                //&min-width: 200px;
            }
        //}
    }
}
@ogoffart ogoffart added a:layouts Related to the layouting and positioning of the elements (mO,bT) need triaging Issue that the owner of the area still need to triage labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:layouts Related to the layouting and positioning of the elements (mO,bT) need triaging Issue that the owner of the area still need to triage
Projects
None yet
Development

No branches or pull requests

2 participants