Skip to content

Conversation

@gustavo-hms
Copy link
Contributor

@gustavo-hms gustavo-hms commented Aug 18, 2025

This PR adds an Easing namespace to Slint. This way, we can name an easing curve outside an expression of type easing. We can, for instance, have a struct with a field of type easing.

Since now we can create structs containing easing curves in Slint code, we need to be able to construct such structs from Rust code. Thus, the EasingCurve enum was made part of the public API.

Closes #3943.
Closes #5734.

The definition of an Easing namespace allows to name an easing curve
outside an expression of type easing like, for instance, a struct field.

Closes slint-ui#3943.
Closes slint-ui#5734.
Now that we can create structs containing easing curves in Slint code,
we need to be able to instantiate such structs from Rust code. Thus, the
EasingCurve enum must be exposed as part of the public API.
@gustavo-hms
Copy link
Contributor Author

gustavo-hms commented Aug 18, 2025

I'm gonna need some help to expose EasingCurve to the bindings. I've seen Python code uses PyO3 and it seems a bit simpler to me. For C++, I've taken a look at cbindgen.rs but it looks a bit cryptic. I didn't take a look at Javascript bindings yet.

Is there any guide I can follow?

@ogoffart
Copy link
Member

Thanks for the PR!

This does two things:

  1. adds a Easing namespace in the Slint language so we can reference easing curve outside of animations by doing Easing.ease-in in slint bindings. This is uncontroversial.
  2. Expose the i_slint_core::animations::EasingCurve enum in the Rust public API. But I think there is some work to get this public. Do we want to expose the enum as is? It certainly nee non_exaustive.

I suggest to split the PR in two so we can merge them separately.
For the Easing namesapce, it should be documented.

@gustavo-hms
Copy link
Contributor Author

I've documented the Easing namespace and reverted back the changes exposing EasingCurve. Tomorrow I will have some time to make a different PR for it and then we can discuss how to do it properly.

Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The code looks good.

One note for the documentation though, there is no other documentation for the Easing namespace now. So the sentence should also define the Easing namespace there saying that all the names are part of the namespace.

@gustavo-hms
Copy link
Contributor Author

Nice! I improved the documentation and added a small snippet showing the definition of an easing curve via the Easing namespace and directly, hoping it would make the difference clear. Not sure if it is necessary though. Feel free to suggest further changes.

@ogoffart ogoffart merged commit e0ae0af into slint-ui:master Aug 21, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Struct field of type easing causes Slint compiler panic struct with a field of type easing is impossible to specify

3 participants