mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Fix #3370: each step stops at the bounds, so a step back in the same frame starts from there
Review follow-up (CodeRabbit): step_value clamped once after all of a frame's steps, so at the lower bound a step down then a step up in the same frame left the field at the bound. Each step is now clamped as it is applied. The Stroke panel test steps down and up in one frame at each bound and expects one step above it; it fails without the change.
This commit is contained in:
committed by
bflatastic
parent
28ac044c74
commit
cc499d7e8e
@@ -642,6 +642,11 @@ mod tests {
|
||||
let texts = frame(&mut app, vec![]);
|
||||
assert_eq!(stroke(&app)[which], low, "{shown}: {:?}", stroke(&app));
|
||||
assert!(texts.iter().any(|(t, _)| t == after), "{shown} → {after}: {texts:?}");
|
||||
// At the bound, a step down and a step up in one frame end one step above it.
|
||||
let key = |key| Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE };
|
||||
frame(&mut app, vec![key(egui::Key::ArrowDown), key(egui::Key::ArrowUp)]);
|
||||
let texts = frame(&mut app, vec![]);
|
||||
assert!(texts.iter().any(|(t, _)| t == shown), "{after}, down and up → {shown}: {texts:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +390,8 @@ fn step_value(
|
||||
let mut v = read(buf)?;
|
||||
for (mods, size, n) in steps {
|
||||
v = if mods == egui::Modifiers::SHIFT { v + size * n } else { step_to_multiple(v, size, n) };
|
||||
// Each step stops at the bounds, so a step back in the same frame starts from there.
|
||||
v = within(v, bounds);
|
||||
}
|
||||
// Rounded as fields show it, within the field's bounds.
|
||||
let v = within(round_to(v, STEP_DECIMALS), bounds);
|
||||
|
||||
Reference in New Issue
Block a user