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.53k stars 600 forks source link

`struct` with a field of type `easing` is impossible to specify #3943

Open spikespaz opened 12 months ago

spikespaz commented 12 months ago

Slint version: 1.3.0 (extension version ??? does every subproject have the same version) Platform: irrelevant (MacOS, Linux, Windows) Language: irrelevant, LSP/preview issue

Creating a struct with a field type of easing is impossible to represent.

struct SomeStyle {
  some-duration: duration,
  some-easing: easing,
}

component SomeWidget {
  in property <SomeStyle> style: {
    some-duration: 100ms,
    some-easing: ease-in-out, // SYNTAX ERROR
  };

  background: #202020;
  width: 20px;
  height: 40px;
  animate height { duration: style.some-duration; easing: style.some-easing; }
}
spikespaz commented 11 months ago

Has it been reproduced?

ogoffart commented 11 months ago

Thanks for reporting a bug.

The problem is that the easing keywords are not part of a namespace or enum so you can't name them outside of an expression that is itself an easing. We should probably add a Easing namespace or something like that.

spikespaz commented 11 months ago

I took a peak but truth be told had a hard time navigating this behemoth of a repo. I'll take another, more focused, look to see if I can contribute.

ogoffart commented 11 months ago

If you want to have a look at implementing that, this should be done in lookup.rs. Right now, the easing curves are in the EasingSpecific, which is only used if the type is an easing curve. But we could add an entry in BuiltinNamespaceLookup to access the.