From 89ec8ed9f421fb93fc10dce5de55d11bdb69f30a Mon Sep 17 00:00:00 2001 From: Cristi Radu Date: Thu, 12 Nov 2026 22:13:20 +0200 Subject: [PATCH 1/2] fix(ui): split view's active-pane line is drawn under open menus (#7010) The line had a layer of its own at Order::Foreground. egui draws a layer no area owns after every area of that order, so it crossed open menus and popups. Order::Middle keeps it over the pages and under the menus. --- crates/ui-egui/src/panes.rs | 6 ++++-- crates/ui-egui/tests/it/split_view.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index 9dd906d725..61a722aca4 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -615,10 +615,12 @@ fn pane(app: &mut PdfCraftApp, ui: &mut egui::Ui, rect: Rect, place: Place, fron (Place::Second, None) => {} } app.panes.drawing = Place::Main; - // The active pane is marked along its top edge. + // The active pane is marked along its top edge: over the pages, under the menus (#7010). A + // layer with no area is drawn after every area of its order, so at Foreground it crossed + // open menus and popups. if active { let edge = Rect::from_min_size(rect.min, vec2(rect.width(), 2.0)); - ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, egui::Id::unique(("active-pane", salt)))).rect_filled(edge, 0.0, t.accent); + ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique(("active-pane", salt)))).rect_filled(edge, 0.0, t.accent); } } diff --git a/crates/ui-egui/tests/it/split_view.rs b/crates/ui-egui/tests/it/split_view.rs index 2cbde22eb6..652eeaa253 100644 --- a/crates/ui-egui/tests/it/split_view.rs +++ b/crates/ui-egui/tests/it/split_view.rs @@ -315,3 +315,21 @@ fn closing_the_second_panes_tab_from_its_strip_keeps_the_program_running() { assert!(h.state().panes.split.is_none()); assert_eq!(h.state().views.len(), 1); } + +/// The line marking the active pane sits under the menus (#7010). It was painted on a layer of +/// its own at the menus' order, and egui draws such a layer after every menu and popup of that +/// order, so the line crossed an open menu. +#[test] +fn the_active_panes_line_is_drawn_under_the_menus() { + let mut h = harness(&["right.pdf", "left.pdf"]); + let right = index(&h, "right.pdf"); + h.state_mut().split_tab(right, false); + h.run_steps(4); + let painted = |h: &Harness<'static, PdfCraftApp>, order: egui::Order| { + ["main-pane", "second-pane"] + .iter() + .any(|salt| h.ctx.graphics(|g| g.get(egui::LayerId::new(order, egui::Id::unique(("active-pane", *salt)))).is_some())) + }; + assert!(!painted(&h, egui::Order::Foreground), "the line is not painted at the menus' order"); + assert!(painted(&h, egui::Order::Middle), "the line is painted above the pages, below the menus"); +} From b549727855ef47f18328be9b374c1296372699fe Mon Sep 17 00:00:00 2001 From: Cristi Radu Date: Thu, 12 Nov 2026 22:35:42 +0200 Subject: [PATCH 2/2] fix(ui): paint the active-pane line on the pane's layer, test it under an open menu A layer no area owns is drawn after every area of its order, so at Middle the line would cross the floating bars instead. Painted on the pane's own layer after its pages, it sits over them and under every area. --- crates/ui-egui/src/panes.rs | 8 ++--- crates/ui-egui/tests/it/split_view.rs | 42 ++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index 61a722aca4..6873f1fbac 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -615,12 +615,12 @@ fn pane(app: &mut PdfCraftApp, ui: &mut egui::Ui, rect: Rect, place: Place, fron (Place::Second, None) => {} } app.panes.drawing = Place::Main; - // The active pane is marked along its top edge: over the pages, under the menus (#7010). A - // layer with no area is drawn after every area of its order, so at Foreground it crossed - // open menus and popups. + // The active pane is marked along its top edge, on the pane's own layer after its pages: over + // them, and under every menu, popup and floating bar (#7010). A layer of its own, which no + // area owns, is drawn after every area of its order, so the line crossed open menus. if active { let edge = Rect::from_min_size(rect.min, vec2(rect.width(), 2.0)); - ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique(("active-pane", salt)))).rect_filled(edge, 0.0, t.accent); + child.painter().rect_filled(edge, 0.0, t.accent); } } diff --git a/crates/ui-egui/tests/it/split_view.rs b/crates/ui-egui/tests/it/split_view.rs index 652eeaa253..2e8f22ef7b 100644 --- a/crates/ui-egui/tests/it/split_view.rs +++ b/crates/ui-egui/tests/it/split_view.rs @@ -320,16 +320,42 @@ fn closing_the_second_panes_tab_from_its_strip_keeps_the_program_running() { /// its own at the menus' order, and egui draws such a layer after every menu and popup of that /// order, so the line crossed an open menu. #[test] -fn the_active_panes_line_is_drawn_under_the_menus() { +fn the_active_panes_line_is_drawn_under_an_open_menu() { let mut h = harness(&["right.pdf", "left.pdf"]); + // With the tools pane closed, the main pane starts under the tabs. + h.state_mut().set_option("left", "closed").unwrap(); let right = index(&h, "right.pdf"); h.state_mut().split_tab(right, false); h.run_steps(4); - let painted = |h: &Harness<'static, PdfCraftApp>, order: egui::Order| { - ["main-pane", "second-pane"] - .iter() - .any(|salt| h.ctx.graphics(|g| g.get(egui::LayerId::new(order, egui::Id::unique(("active-pane", *salt)))).is_some())) - }; - assert!(!painted(&h, egui::Order::Foreground), "the line is not painted at the menus' order"); - assert!(painted(&h, egui::Order::Middle), "the line is painted above the pages, below the menus"); + let left = index(&h, "left.pdf"); + let at = h.state().views[left].viewport_rect().center(); + click_at(&mut h, at); + assert_eq!(h.state().active, Some(left), "the main pane is the active one"); + let top = h.state().views[left].viewport_rect(); + // The menu of the main strip's tab drops down across the main pane's top edge. + h.get_by_role_and_label(Role::Tab, "left.pdf").click_secondary(); + h.run_steps(2); + let item = h.get_by_label("Split right").rect(); + fn flat(shape: &egui::Shape, out: &mut Vec) { + match shape { + egui::Shape::Vec(shapes) => shapes.iter().for_each(|s| flat(s, out)), + egui::Shape::Rect(r) => out.push(r.clone()), + _ => {} + } + } + let mut rects = Vec::new(); + for clipped in &h.output().shapes { + flat(&clipped.shape, &mut rects); + } + let line = rects + .iter() + .position(|r| (r.rect.height() - 2.0).abs() < 0.01 && (r.rect.top() - top.top()).abs() < 1.0 && (r.rect.left() - top.left()).abs() < 1.0) + .expect("the active pane's line is painted"); + let line_rect = rects[line].rect; + let menu = rects + .iter() + .rposition(|r| r.fill.a() == 255 && r.rect.contains_rect(item) && r.rect.width() < line_rect.width()) + .expect("the tab's menu is painted"); + assert!(rects[menu].rect.intersects(line_rect), "the menu crosses the line: {:?} {line_rect:?}", rects[menu].rect); + assert!(line < menu, "the line was painted over the open menu"); }