-
Notifications
You must be signed in to change notification settings - Fork 633
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
Implement #2655 - Add more easing formulas #3812
Implement #2655 - Add more easing formulas #3812
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your PR.
Documentation would be nice, a paragraph for different easing curves should be added in https://github.com/slint-ui/slint/blob/master/docs/reference/src/language/syntax/animations.md
(idea: It could even have an example that animates something with all easing curves.)
internal/compiler/generator/cpp.rs
Outdated
@@ -2821,6 +2821,12 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String | |||
"slint::cbindgen_private::EasingCurve(slint::cbindgen_private::EasingCurve::Tag::CubicBezier, {}, {}, {}, {})", | |||
a, b, c, d | |||
), | |||
Expression::EasingCurve(EasingCurve::EaseInElastic) => "slint::cbindgen_private::EasingCurve()".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will have to pass something like slint::cbindgen_private::EasingCurve::Tag::EaseInElastic
in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if that looks good now.
Fix PR feedback
I added a list of all the types and a link to easings.net. I don't think these can be described in a paragraph, but let me know if you have another idea. I haven't (yet) put anything dynamic in the help. Is there an example of embedding a slint demo in Markdown I can follow? |
That's fine. The way to do it is just to have it in There are a few errors from CI:
The test you added is failing, I did not investigate why For the MCU cases, we need to import the Float trait as the error message says . slint/internal/core/animations.rs Lines 15 to 16 in 2176523
And the C++ tests are also failling you have to construct the struct with its constructor |
Actually, for C++, the best would be to get a constructor that initialize the tag: Lines 601 to 605 in 2176523
Replace with something like: config.export.body.insert(
"EasingCurve".to_owned(),
" constexpr explicit EasingCurve(EasingCurve::Tag tag = Tag::Linear , float a = 0, float b = 0, float c = 1, float d = 1) : tag(tag), cubic_bezier{{a,b,c,d}} {}".into()
); |
api/cpp/cbindgen.rs
Outdated
constexpr explicit EasingCurve(EasingCurve::Tag tag, float a, float b, float c, float d) : tag(tag), cubic_bezier{{a,b,c,d}} {}".into() | ||
config.export.body.insert( | ||
"EasingCurve".to_owned(), | ||
" constexpr explicit EasingCurve(EasingCurve::Tag tag = Tag::Linear , float a = 0, float b = 0, float c = 1, float d = 1) : tag(tag), cubic_bezier{{a,b,c,d}} {}".into() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" constexpr explicit EasingCurve(EasingCurve::Tag tag = Tag::Linear , float a = 0, float b = 0, float c = 1, float d = 1) : tag(tag), cubic_bezier{{a,b,c,d}} {}".into() | |
" constexpr EasingCurve(EasingCurve::Tag tag = Tag::Linear , float a = 0, float b = 0, float c = 1, float d = 1) : tag(tag), cubic_bezier{{a,b,c,d}} {}".into() |
It shouldn't have been explicit, sorry to have mislead you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries...How can I test this locally? I'm not doing anything with CPP and Slint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can run the driver test like so.
cargo test -p test-driver-cpp
But I'm not sure this test any of the new curves since they are not in the tests but in the gallery.
To build the gallery, you need cmake:
https://github.com/slint-ui/slint/blob/master/docs/building.md#c-api-build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Rectangle { | ||
border-radius: 8px; | ||
background: #F4F4F4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcoded color cause issues in dark mode, so i'll remove it.
WIP: I'm adding an example page to show all the easings visually.
This adds support for all easings from https://easings.net