mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-20 19:18:41 +00:00
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.
This commit is contained in:
1 parent
bd0a21c2de
commit
89ec8ed9f4
2 files changed
+22
-2
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
Reference in new issue
Block a user