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

Allow accessing parent in exported component #6840

Open
bryce-happel-walton opened this issue Nov 20, 2024 · 0 comments
Open

Allow accessing parent in exported component #6840

bryce-happel-walton opened this issue Nov 20, 2024 · 0 comments
Labels
enhancement New feature or request need triaging Issue that the owner of the area still need to triage

Comments

@bryce-happel-walton
Copy link

bryce-happel-walton commented Nov 20, 2024

Feature Description

Allow to access the parent attribute in components. Alternatively allow properties to have a component type to bind to another component.

component GaugeAttachedSymbol inherits SymbolLight {
    in property <angle> angle: 0deg;
    in property <length> radius-offset: 25px;
    in property <length> radius: max(self.width, self.height) / 2;

    in property <length> center-x: 0px;
    in property <length> center-y: 0px;
    in property <length> center-radius: 1px;

    x: center-x - self.width / 2 + ((center-radius + radius + radius-offset) * cos(angle));
    y: center-y - self.height / 2 - ((center-radius + radius + radius-offset) * sin(angle));
}

I would like to do one of two things with the above code:

component GaugeAttachedSymbol inherits SymbolLight {
    in property <angle> angle: 0deg;
    in property <length> radius-offset: 25px;
    in property <length> radius: max(self.width, self.height) / 2;

    x: parent.x - self.width / 2 + ((parent.width / 2 + radius + radius-offset) * cos(angle));
    y: parent.y - self.height / 2 - ((parent.height / 2 + radius + radius-offset) * sin(angle));
}

OR

component GaugeAttachedSymbol inherits SymbolLight {
    in property <angle> angle: 0deg;
    in property <length> radius-offset: 25px;
    in property <length> radius: max(self.width, self.height) / 2;

    in property <T where T: Position + Size>  center-around;

    x: center-around.x - self.width / 2 + ((center-around.width / 2 + radius + radius-offset) * cos(angle));
    y: center-around.y - self.height / 2 - ((center-around.height / 2 + radius + radius-offset) * sin(angle));
}

I used Rust syntax where there is no Slint equivalent for coherency, actual trait based typing may be asking a bit much.

In theory, the only component without parent should be Window and those that inherit Window. Every other component should default the parent to the main window until they have been built. I understand that inferring the properties of the parent without knowing its type is not possible, but everything has position and size, so those should be accessible at least and everything else can error.

Product Impact

Parent accessibility is fundamental.
Object binding is a must-have.

@bryce-happel-walton bryce-happel-walton added enhancement New feature or request need triaging Issue that the owner of the area still need to triage labels Nov 20, 2024
@bryce-happel-walton bryce-happel-walton changed the title Allow accessing parent in exported compnent Allow accessing parent in exported component Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need triaging Issue that the owner of the area still need to triage
Projects
None yet
Development

No branches or pull requests

1 participant