Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

merge: preserve drag flyouts and upstream tool memory

Ni-zavfa5aac84c30c
diff --cc crates/ui-egui/src/panels.rs
index f2885658f,10476013e..a025cc496
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@@ -187,10 -174,10 +185,10 @@@ pub fn toolbar(app: &mut PhotocraftApp
let _ = app.run("view.fitOnScreen", json!({}));
}
if resp.double_clicked() && tool == Tool::Zoom {
- app.ui.tool = tool;
+ crate::tool_memory::select(app, tool);
let _ = app.run("view.actualPixels", json!({}));
}
- // Right-click or long-press opens the flyout (Photoshop).
+ // Right-click, long-press, or press-drag away opens the flyout (Photoshop).
let held_for =
resp.is_pointer_button_down_on().then(|| ui.input(|i| i.pointer.press_start_time().map(|t0| i.time - t0))).flatten();
if slot.len() > 1
@@@ -280,14 -265,8 +278,14 @@@
t.text_dim,
);
}
- if ir.clicked() {
+ let drag_release = tool_flyout_release(
+ r,
+ ui.input(|i| i.pointer.hover_pos()),
+ ui.input(|i| i.pointer.primary_released()),
+ ui.data(|d| d.get_temp::<egui::Id>(held_id)) == Some(key),
+ );
+ if ir.clicked() || drag_release {
- app.ui.tool = item;
+ crate::tool_memory::select(app, item);
ui.data_mut(|d| d.remove::<(egui::Id, Rect)>(flyout_id));
}
}