slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.54k stars 600 forks source link

RFC: Component declaration #1682

Closed ogoffart closed 1 year ago

ogoffart commented 2 years ago

We want to change the component declaration so that

Following the discussion in https://github.com/slint-ui/slint/issues/191#issuecomment-938811947 we came up with

component Foo {
   property <int> yy : 42;
   rect := Rectangle { /* .. */ }
    //...
}

component Bar inherits Window {
   title: "foobar";
    //...
}

struct Stru {
  foo: int, bar: string
}

global Glob {
   property <int> yy: 42;
}

So:

ogoffart commented 2 years ago

Edited the description to keep inheritence

jturcotte commented 2 years ago

About

component Foo {
   property <int> yy : 42;
   rect := Rectangle { /* .. */ }
    //...
}

Is this equivalent to inheriting from some item class with only common properties?

I think you have eliding of trivial rectangles in the compiler, maybe it would be nice to partly document that behavior so that developers are not tempted to use inheritance to prune their item tree.

ogoffart commented 2 years ago

@jturcotte: Yes it is exactly that. And you're right we should document that properly.

tronical commented 1 year ago

I suppose that this can be ... closed? :)