mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Fixup tests and and compilation with no_std
The interpolation now rounds the value, so the test needs to be adjusted by one unit
This commit is contained in:
parent
4845241ebf
commit
cb4ef70d33
4 changed files with 27 additions and 4 deletions
|
@ -19,6 +19,7 @@ All notable changes to this project are documented in this file.
|
|||
- Added `Switch` widget.
|
||||
- Added boolean `font-italic` property to `Text` and `TextInput`.
|
||||
- Added `select-all()`, `cut()`, `copy()`, and `paste() to `TextInput`, `LineEdit`, and `TextEdit`.
|
||||
- Added functions on color: `transparentize`, `mix`, `opaque`, `with-alpha`
|
||||
|
||||
### Rust
|
||||
|
||||
|
|
|
@ -69,18 +69,38 @@ colors from the `Colors` namespace.
|
|||
|
||||
All colors and brushes define the following methods:
|
||||
|
||||
- **`brighter(factor: float) -> Brush`**
|
||||
- **`brighter(factor: float) -> brush`**
|
||||
|
||||
Returns a new color derived from this color but has its brightness increased by the specified factor.
|
||||
For example if the factor is 0.5 (or for example 50%) the returned color is 50% brighter. Negative factors
|
||||
decrease the brightness.
|
||||
|
||||
- **`darker(factor: float) -> Brush`**
|
||||
- **`darker(factor: float) -> brush`**
|
||||
|
||||
Returns a new color derived from this color but has its brightness decreased by the specified factor.
|
||||
For example if the factor is .5 (or for example 50%) the returned color is 50% darker. Negative factors
|
||||
increase the brightness.
|
||||
|
||||
- **`mix(other: brush, factor: float) -> brush`**
|
||||
|
||||
Returns a new color that is a mix of this color and `other`, with a proportion
|
||||
factor given by \a factor (which will be clamped to be between `0.0` and `1.0`).
|
||||
|
||||
- **`opaque(factor: float) -> brush`**
|
||||
|
||||
Returns a new color derived from this color with the opacity increased by `factor`,
|
||||
meaning the new opacity will be scaled up by `1.0 + factor`.
|
||||
|
||||
- **`transparentize(factor: float) -> brush`**
|
||||
|
||||
Returns a new color with the opacity decreased by `factor`,
|
||||
meaning the new opacity will be the current one times `factor`.
|
||||
factor is clamped to be between `0.0` and `1.0` before applying it.
|
||||
|
||||
- **`with_alpha(alpha: float) -> brush`**
|
||||
|
||||
Returns a new color with the alpha value set to `alpha` (between 0 and 1)
|
||||
|
||||
### Linear Gradients
|
||||
|
||||
Linear gradients describe smooth, colorful surfaces. They're specified using an angle and a series of
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
use super::*;
|
||||
use crate::{items::PropertyAnimation, lengths::LogicalLength};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::Float;
|
||||
|
||||
enum AnimationState {
|
||||
Delaying,
|
||||
|
|
|
@ -15,7 +15,7 @@ export component TestCase {
|
|||
```rust
|
||||
let instance = TestCase::new().unwrap();
|
||||
instance.set_xx(500);
|
||||
// It's the first time we querty the value: so no animation
|
||||
// It's the first time we query the value: so no animation
|
||||
assert_eq!(instance.get_yy(), 5000);
|
||||
instance.set_xx(1000);
|
||||
// now it is animated
|
||||
|
@ -30,7 +30,7 @@ assert_eq!(instance.get_yy(), 7500 - 2500/2); // even if time has passed, since
|
|||
slint_testing::mock_elapsed_time(500);
|
||||
instance.set_xx(1000);
|
||||
slint_testing::mock_elapsed_time(250);
|
||||
assert_eq!(instance.get_yy(), 9062);
|
||||
assert_eq!(instance.get_yy(), 9063);
|
||||
slint_testing::mock_elapsed_time(250);
|
||||
assert_eq!(instance.get_yy(), 10000);
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue