From d0433d3ee294ba9f4a5ba55bd7ff2ad93690700a Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 15:41:28 +0100 Subject: [PATCH] Handle gestures on the actual vacant title strip after Open --- crates/ui-egui/src/chrome/doc_tabs.rs | 44 ++++++++++++++++++--------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/chrome/doc_tabs.rs b/crates/ui-egui/src/chrome/doc_tabs.rs index 0ecaa38b54..8cf2e4b60d 100644 --- a/crates/ui-egui/src/chrome/doc_tabs.rs +++ b/crates/ui-egui/src/chrome/doc_tabs.rs @@ -212,13 +212,16 @@ fn show_strip_row<'a>( } }; let builder = egui::UiBuilder::new().max_rect(room).layout(layout); - let drawn = ui + let open = ui .scope_builder(builder, |ui| { - Button::command("file.open").variant(craft::theme::Variant::GHOST).icon(IconId::new("plus")).show(ui); + Button::command("file.open").variant(craft::theme::Variant::GHOST).icon(IconId::new("plus")).show(ui).response().rect }) - .response - .rect - .width(); + .inner; + let drawn = open.width(); + if all_show { + let occupied = strip.tab_rects.iter().fold(open, |rect, (_, tab)| rect.union(*tab)); + window_drag_gap(ui, strip.response.response.rect, occupied); + } if (drawn - held).abs() > 0.5 { ui.ctx().data_mut(|d| d.insert_temp(memory, drawn)); ui.ctx().request_repaint(); @@ -228,6 +231,28 @@ fn show_strip_row<'a>( shown.ok_or(row.output) } +/// The strip and Open overlap in layout. Only the unused strip after both moves the window. +fn window_drag_gap(ui: &mut egui::Ui, strip: egui::Rect, occupied: egui::Rect) { + let mut gap = strip.intersect(ui.clip_rect()); + if ui.layout().prefer_right_to_left() { + gap.max.x = gap.right().min(occupied.left()); + } else { + gap.min.x = gap.left().max(occupied.right()); + } + if !gap.is_positive() { + return; + } + let host = WindowHost::of(ui.ctx()); + if matches!(host.frame(), craft::window::policy::Frame::Integrated(_)) { + let handle = ui.interact(gap, ui.scope_id().with("document-strip-window-drag"), egui::Sense::click_and_drag()); + if handle.double_clicked() { + host.act(host.current(), WindowAction::ToggleMaximize); + } else if handle.drag_started_by(egui::PointerButton::Primary) { + host.act(host.current(), WindowAction::StartMove); + } + } +} + fn paint_group_overlays(app: &PdfCraftApp, ui: &egui::Ui, tab_rects: &[(StripTab, egui::Rect)]) -> Vec<(TabGroupId, egui::Rect)> { let mut group_rects: Vec<(TabGroupId, egui::Rect)> = Vec::new(); let mut prev: Option<(egui::Rect, Option)> = None; @@ -287,15 +312,6 @@ fn select_strip_tab(app: &mut PdfCraftApp, tab: StripTab) { } fn handle_strip_output(app: &mut PdfCraftApp, ui: &egui::Ui, place: Place, entries: &[StripEntry], output: TabStripOutput) { - // The document strip owns the space after the last tab, including on Home. - // Forward gestures in that space to the integrated title bar's window. - if place == Place::Main && (output.empty_drag || output.empty_double) { - let host = WindowHost::of(ui.ctx()); - if matches!(host.frame(), craft::window::policy::Frame::Integrated(_)) { - let action = if output.empty_double { WindowAction::ToggleMaximize } else { WindowAction::StartMove }; - host.act(host.current(), action); - } - } for event in output.response.events { match event { CollectionEvent::Selection(SelectionChange::Set(keys)) => {