mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 05:12:55 +00:00
live-preview: Do not stop the first gradient stop from moving
This commit is contained in:
parent
7ae6212b0b
commit
cd48bbd251
1 changed files with 50 additions and 1 deletions
|
|
@ -37,7 +37,7 @@ pub fn move_gradient_stop(
|
|||
new_position: f32,
|
||||
) -> i32 {
|
||||
let mut row_usize = row as usize;
|
||||
if row <= 0 || row_usize >= model.row_count() {
|
||||
if row < 0 || row_usize >= model.row_count() {
|
||||
return row;
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +571,55 @@ mod tests {
|
|||
|
||||
let model = make_model();
|
||||
|
||||
assert_eq!(super::move_gradient_stop(model.clone(), 0, 0.05), 1);
|
||||
let mut it = model.iter();
|
||||
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 0.0,
|
||||
color: slint::Color::from_argb_encoded(0xff040404)
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 0.05,
|
||||
color: slint::Color::from_argb_encoded(0xff030303)
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 0.1445,
|
||||
color: slint::Color::from_argb_encoded(0xff060606),
|
||||
}),
|
||||
);
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 0.5,
|
||||
color: slint::Color::from_argb_encoded(0xff050505)
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 1.0,
|
||||
color: slint::Color::from_argb_encoded(0xff010101)
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
it.next(),
|
||||
Some(ui::GradientStop {
|
||||
position: 1.0,
|
||||
color: slint::Color::from_argb_encoded(0xff020202)
|
||||
})
|
||||
);
|
||||
assert_eq!(it.next(), None);
|
||||
|
||||
let model = make_model();
|
||||
|
||||
assert_eq!(super::move_gradient_stop(model.clone(), 3, 0.0), 2);
|
||||
let mut it = model.iter();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue