Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge lightcraft#2913 (egui 0.37) into title-bar-movable; craft-window at craft-libs main a091680

aionggc01d4c707460
diff --cc Cargo.lock
index f3e4b5bf7,4c745676a..20ff672be
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -1095,17 -1091,6 +1091,17 @@@ dependencies =
"serde",
]
+[[package]]
+name = "craft-window"
+version = "0.1.0"
- source = "git+https://github.com/storytold/craft-libs?rev=5bbe9f6254de3bb9f9707ae0740ab0db8170afd5#5bbe9f6254de3bb9f9707ae0740ab0db8170afd5"
++source = "git+https://github.com/storytold/craft-libs?rev=a0916808f7d78bed8c7b90cdf937176015454a7f#a0916808f7d78bed8c7b90cdf937176015454a7f"
+dependencies = [
+ "egui",
+ "objc2 0.6.4",
+ "objc2-app-kit 0.3.2",
+ "wayland-client",
+]
+
[[package]]
name = "crc32fast"
version = "1.5.2"
@@@ -1684,7 -1667,7 +1678,7 @@@ source = "registry+https://github.com/r
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
- "windows-sys 0.52.0",
- "windows-sys 0.61.2",
++ "windows-sys 0.60.2",
]
[[package]]
@@@ -5270,7 -5294,7 +5306,7 @@@ dependencies =
"errno",
"libc",
"linux-raw-sys 0.12.1",
- "windows-sys 0.52.0",
- "windows-sys 0.61.2",
++ "windows-sys 0.60.2",
]
[[package]]
@@@ -5804,7 -5834,7 +5846,7 @@@ dependencies =
"getrandom 0.4.3",
"once_cell",
"rustix 1.1.5",
- "windows-sys 0.52.0",
- "windows-sys 0.61.2",
++ "windows-sys 0.60.2",
]
[[package]]
@@@ -6591,7 -6644,7 +6656,7 @@@ version = "0.1.11
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.52.0",
- "windows-sys 0.61.2",
++ "windows-sys 0.60.2",
]
[[package]]
diff --cc Cargo.toml
index a41d0d9ad,76a6ad78d..f61b3b868
--- a/Cargo.toml
+++ b/Cargo.toml
@@@ -10,9 -10,8 +10,9 @@@ rust-version = "1.95
repository = "https://github.com/storytold/lightcraft"
[workspace.dependencies]
- craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "5c874d51eeb3de70e735c8ce87a59a7dedd47675", features = ["serde"] }
+ craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "25da1314d443171b4adeaad2cd9454b273f35c6f", features = ["serde"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "82a24b006eefa036b43c09a67fb9a3fbd17ffe63" }
- craft-window = { git = "https://github.com/storytold/craft-libs", rev = "5bbe9f6254de3bb9f9707ae0740ab0db8170afd5", features = ["egui"] }
++craft-window = { git = "https://github.com/storytold/craft-libs", rev = "a0916808f7d78bed8c7b90cdf937176015454a7f", features = ["egui"] }
# internal
lightcraft-denoise-core = { path = "crates/denoise-core" }
lightcraft-denoise = { path = "crates/denoise", default-features = false }
diff --cc crates/ui-egui/src/lib.rs
index e7d1af303,1b5fea8f1..a39fdda5c
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@@ -1626,11 -2668,12 +2670,16 @@@ impl LightcraftApp
panels::keyword_list::drag_feedback(self, &ctx);
panels::toast(self, &ctx);
drop_overlay::show(self, &ctx);
+ // AppKit moves the window on a drag anywhere in the title-bar band unless the window isn't
+ // movable: it stops being movable while the pointer is on a bar control or a panel over it
+ #[cfg(target_os = "macos")]
+ craft_window::title_bar::sync_movable(&ctx, &mut self.window_movable);
- self.widgets = widgets::take_registry(&ctx);
+ if notice_blocks {
+ // Keep the real press/release state for the next pass: an ordinary click spans host
+ // frames, and resetting it above must only hide it from this pass's dialogs.
+ panels::notices::restore_prompt_pointer(self, &ctx);
+ }
+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);
self.text_focus = ctx.egui_wants_keyboard_input();
self.end_frame(&ctx, t0);
}
diff --cc crates/ui-egui/src/panels/topbar.rs
index acee425ed,c1c645a1d..2ba807dcc
--- a/crates/ui-egui/src/panels/topbar.rs
+++ b/crates/ui-egui/src/panels/topbar.rs
@@@ -9,13 -9,45 +9,16 @@@ use crate::theme::Tokens
use crate::widgets::{icon_button, register};
/// The bar doubles as the window's title bar: dragging its empty space moves the window and a
-/// double-click zooms or restores it. Registered before the bar's widgets so they win the click.
-fn window_handle(app: &LightcraftApp, ui: &mut egui::Ui, bar: Rect, search_rect: Rect) {
- use crate::titlebar::{Gesture, WindowState, command_for};
+/// double-click acts as the system setting says. Made before the bar's widgets so they win the click.
+fn window_handle(ui: &mut egui::Ui, bar: Rect) {
- register(ui.ctx(), "region:titlebar", bar);
+ register(ui, "region:titlebar", bar);
- let handle = egui::Id::unique("titlebar-handle");
- let resp = ui.interact(bar, handle, Sense::click_and_drag());
+ let resp = craft_window::title_bar::empty_area(ui, bar);
crate::widgets::announce(&resp, crate::i18n::tr("Title bar"));
- // a press that began on a button or the search field is theirs: dragging off it must not move the window
- // (while pressing, egui hovers every widget under the pointer; once the drag starts, only the dragged one)
- let ctx = ui.ctx().clone();
- let memo = egui::Id::unique("titlebar-press-on-widget");
- if resp.is_pointer_button_down_on() && ctx.input(|i| i.pointer.primary_pressed()) {
- let hovered = ctx.interaction_snapshot(|s| s.hovered.clone());
- let on_widget =
- hovered.iter().any(|id| *id != handle && ctx.read_response(*id).is_some_and(|r| r.sense.senses_click() || r.sense.senses_drag()));
- ctx.data_mut(|d| d.insert_temp(memo, on_widget));
- }
- let on_widget = ctx.data(|d| d.get_temp::<bool>(memo)).unwrap_or(false);
- // The search field is drawn after this handle. Its hit-test response may not exist
- // yet when the press is recorded; the press origin still identifies text selection.
- let on_search = ui.input(|i| i.pointer.press_origin().is_some_and(|p| search_rect.contains(p)));
- let gesture = if resp.double_clicked_by(egui::PointerButton::Primary) && !on_search {
- Some(Gesture::DoubleClicked)
- } else if resp.drag_started_by(egui::PointerButton::Primary) && !on_widget && !on_search {
- Some(Gesture::DragStarted)
- } else {
- None
- };
- if let Some(g) = gesture {
- let window = WindowState { maximized: ui.input(|i| i.viewport().maximized).unwrap_or(false), fullscreen: app.window_is_fullscreen };
- if let Some(cmd) = command_for(g, window) {
- ui.ctx().send_viewport_cmd(cmd);
- }
- }
}
+ /// Draw the top bar: the titlebar drag area, the in-window menus when there is no native menu
+ /// bar, sidebar and back/forward buttons, the centred search field, the filter button with its
+ /// active count, and the right-side action icons.
pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
// room for the traffic lights; in full screen they are gone, and the sidebar button sits as far