Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

fix(ui): keep document_area under the complexity gate after merging main

FredApps25916985ca58
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 111aecc55..52e05fc35 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -3861,14 +3861,9 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
can_paste_image,
};
let mut page_out = PageOut::default();
- let fade_strength = ui.spacing().scroll.fade.strength;
- if !app.show_page_edge_shadows {
- ui.spacing_mut().scroll.fade.strength = 0.0;
- }
- let out = page_scroll(ui, scroll, egui::Id::unique(("page-view-scope", view.id)), |ui, viewport| {
+ let out = page_scroll(ui, scroll, egui::Id::unique(("page-view-scope", view.id)), app.show_page_edge_shadows, |ui, viewport| {
draw_pages(ui, viewport, view, &env, &mut page_out, &mut app.signature_preview)
});
- ui.spacing_mut().scroll.fade.strength = fade_strength;
let PageOut {
canvas_action,
clicked_link,
diff --git a/crates/ui-egui/src/canvas/area.rs b/crates/ui-egui/src/canvas/area.rs
index 068661ea5..0d934dc8c 100644
--- a/crates/ui-egui/src/canvas/area.rs
+++ b/crates/ui-egui/src/canvas/area.rs
@@ -32,14 +32,22 @@ pub(super) const SUPPRESS_SECS: f64 = 0.25;
/// Short rolling extension while egui still has an unprocessed wheel tail.
pub(super) const SUPPRESS_TAIL_SECS: f64 = 0.05;
-// Keep the viewer's scroll identity tied to the document instead of its parent UI.
+// Keep the viewer's scroll identity tied to the document instead of its parent UI. Without
+// `fades` (Show Page Edge Shadows off) the viewport-edge gradients are off for this area only.
pub(super) fn page_scroll<R>(
ui: &mut egui::Ui,
scroll: egui::ScrollArea,
id: egui::Id,
+ fades: bool,
draw: impl FnOnce(&mut egui::Ui, egui::Rect) -> R,
) -> egui::scroll_area::ScrollAreaOutput<R> {
- ui.scope_builder(egui::UiBuilder::new().scope_id(id), |ui| scroll.show_viewport(ui, draw)).inner
+ let strength = ui.spacing().scroll.fade.strength;
+ if !fades {
+ ui.spacing_mut().scroll.fade.strength = 0.0;
+ }
+ let out = ui.scope_builder(egui::UiBuilder::new().scope_id(id), |ui| scroll.show_viewport(ui, draw)).inner;
+ ui.spacing_mut().scroll.fade.strength = strength;
+ out
}
/// Run a push button's action (the ones that need no JavaScript engine).