mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-22 18:34:42 +01:00
Keep a cancelled trace sampler press owned through release
This commit is contained in:
1 parent
768edc48fe
commit
42f69621a2
2 files changed
+28
-2
No files matched your search
@@ -466,9 +466,24 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A press arriving with an invalidated sampler is consumed, not given to its restored tool.
|
||||
/// A press arriving with an invalidated sampler and its release belong to that cancelled pick.
|
||||
fn input_after_sampler_refresh(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Response, rect: egui::Rect, cancelled: bool) {
|
||||
if !cancelled || !ui.input(|i| i.pointer.any_pressed()) {
|
||||
let (pressed, released, down, any_pressed) = ui.input(|i| {
|
||||
(i.pointer.primary_pressed(), i.pointer.primary_released(), i.pointer.primary_down(), i.pointer.any_pressed())
|
||||
});
|
||||
let consumed_primary = ui.data_mut(|data| {
|
||||
let id = resp.id.with("image-trace-consumed-primary");
|
||||
// A fresh press replaces any ownership whose release this canvas did not observe.
|
||||
let consumed = if pressed { cancelled } else { data.get_temp::<bool>(id).unwrap_or(false) };
|
||||
if consumed && down {
|
||||
data.insert_temp(id, true);
|
||||
} else {
|
||||
data.remove::<bool>(id);
|
||||
}
|
||||
// egui classifies double/triple clicks on release, independently of the tool's Down.
|
||||
consumed && (pressed || released || down)
|
||||
});
|
||||
if !consumed_primary && (!cancelled || !any_pressed) {
|
||||
canvas_input(app, ui, resp, rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,6 +481,17 @@ fn a_consumed_stale_sampler_press_does_not_complete_a_double_click() {
|
||||
assert_eq!((state.history.undo.len(), state.history.redo.len()), history);
|
||||
assert_eq!(app.session.paint, paint);
|
||||
assert_eq!(app.session.tool_id(), "selection");
|
||||
// The consumed release must not take the next independent ordinary gesture with it.
|
||||
let next = start + 4.0 * step + delay + 1.0;
|
||||
frame_at(&mut app, &ctx, next, vec![Event::PointerMoved(at), press(true)]);
|
||||
frame_at(&mut app, &ctx, next + step, vec![press(false)]);
|
||||
assert!(!ctx.input(|i| i.pointer.button_double_clicked(PointerButton::Primary)));
|
||||
assert_eq!(app.session.active().unwrap().selection.objects, vec![group], "the next ordinary first click selects the group");
|
||||
assert_eq!(app.session.active().unwrap().isolation, None);
|
||||
frame_at(&mut app, &ctx, next + 3.0 * step, vec![press(true)]);
|
||||
frame_at(&mut app, &ctx, next + 4.0 * step, vec![press(false)]);
|
||||
assert!(ctx.input(|i| i.pointer.button_double_clicked(PointerButton::Primary)));
|
||||
assert_eq!(app.session.active().unwrap().isolation, Some(group), "the next ordinary double-click still isolates the group");
|
||||
} else {
|
||||
assert_eq!(app.session.active().unwrap().selection.objects, vec![group], "the ordinary first click really selects the group");
|
||||
frame_at(&mut app, &ctx, start + 3.0 * step, vec![press(true)]);
|
||||
|
||||
Reference in new issue
Block a user