Skip to content

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

Compare files: side by side, scrolled and zoomed together (#1927)

regendorf-ux9caddc6e9b82
diff --git a/ATTRIBUTION.toml b/ATTRIBUTION.toml
index 5734c0395..290dea2cc 100644
--- a/ATTRIBUTION.toml
+++ b/ATTRIBUTION.toml
@@ -7,7 +7,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Greek UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "0ef505ad4ae53d404d4474d2881f54bc3692739fe9200692fad2b3ace9036a03"
+sha256 = "a4ab30e3f0e7e65c93dadf7c4dd88b15efbad5ae1f218d77f639cf490c900bdb"
# ATTRIBUTION.toml: one entry per asset (AGENTS.md §1). The source of truth for provenance and licences.
# ATTRIBUTION.md is generated from this file: `cargo xtask assets --write`. Checked by `cargo xtask assets` (part of `xtask ci`).
@@ -30,7 +30,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Simplified Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "73efe98c3a4190715f3f76d714390396887f45d2092926729832b79a194488c0"
+sha256 = "3ed54e2ed759fbcf7fbff39a70820de78a7e79ce0cd8133e0d870ad0f4b62ac3"
[[asset]]
path = "crates/ui-egui/src/i18n/zh-hant.tsv"
@@ -41,7 +41,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Traditional Chinese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "e0959af2ee8e317372d9076e487e41d025015460b99906482efa1a0e528802c3"
+sha256 = "74ce914c682d54480f986a007ae4140ec19bdfa2ac9729418f04a8779a98330b"
[[asset]]
path = "crates/ui-egui/src/i18n/cs.tsv"
@@ -52,7 +52,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Czech UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "0a327af10b0bb916ef1b912e6797214bd0b2c18c1e0ef27d9f7a92a3cbeac5b7"
+sha256 = "06bb8f0ce964ac41355c589ba278c941b281aca249741672d513ca2033bd818d"
[[asset]]
path = "crates/ui-egui/src/i18n/pt-br.tsv"
@@ -63,7 +63,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Brazilian Portuguese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "c2cf9490a9f9c828382e2f24df3eaea511b4dfab6543ca00ac61e0014029f051"
+sha256 = "615c578b6da67dc5c23fe6f290464aabb327da68027bd7ebd4e065a61f047b4b"
[[asset]]
path = "crates/ui-egui/src/i18n/es.tsv"
@@ -74,7 +74,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Spanish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "fccce321ccb64bdfcb75e1d6d09f661fb6a738b30cc0ec1133134ea91959e3ad"
+sha256 = "c7156ba4a06220d697c908e173f6bbd9ef1475069f90dcb8f72bc5a620e51cb3"
[[asset]]
path = "crates/ui-egui/src/i18n/fr.tsv"
@@ -85,7 +85,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "French UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "64722973eaf542884ddd170dd9541649c1b1b365ad8c63d0d2864ffbecd20941"
+sha256 = "8286c0e834e0a87fc1909dba2d974aa8993230e5cdb9ce89abdab3cd1ecf0d22"
[[asset]]
path = "crates/ui-egui/src/i18n/de.tsv"
@@ -96,7 +96,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "German UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "0475c03f0b2190998e247d6996d5473d3fd85ea6c55e582b7159b42096c63f9e"
+sha256 = "8b65824b11221ec61fc42a32093d61f301a57e206f69e166c491f26333cd593f"
[[asset]]
path = "crates/ui-egui/src/i18n/te.tsv"
@@ -107,7 +107,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Telugu UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "6423cc0904fd4e49af25121d9fe4d67d09d684f45acbb8165d4ea7a474a3275c"
+sha256 = "85eb2eb9f43b773fe76747b51d288a590a1d5251b19c189e818c38bc88a5781c"
[[asset]]
path = "crates/ui-egui/src/i18n/it.tsv"
@@ -118,7 +118,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Italian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "588adcef83d5ec8e9a1e1fac093afa6afee30d94ac68e8b428ebd487cdc23c3e"
+sha256 = "32c0f3141dab1aa960690e38a9414b88252a8477e9dd9c19e6b21a7dd099c6b0"
[[asset]]
path = "crates/ui-egui/src/i18n/pl.tsv"
@@ -129,7 +129,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Polish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "9fda2deb8db4e919199ae032b9a9a220f32896462640578cd155074809e71f0d"
+sha256 = "8b47ba586f779b4fd42d483b52a81260e52e10c4135fe541f6a62148f9b64812"
[[asset]]
path = "crates/ui-egui/src/i18n/ru.tsv"
@@ -140,7 +140,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Russian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "b60244d234bcec0602a10a077167861d60c86ab3a364c3dfc4b4e0466dd54872"
+sha256 = "0a9864a30413a28ba90c11eb4b2760686adf0cb7d060365c2936a5e0c1201009"
[[asset]]
path = "crates/ui-egui/src/i18n/hu.tsv"
@@ -151,7 +151,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Hungarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "18416c5dc7b28bfb999e1f8127337d37915c67a91d8b8b3fc52e3286a11205ba"
+sha256 = "09e2c640908567e8a56ec9ac857ad5fb1e09d4c3ad68b1ad873f098a55396bb5"
[[asset]]
path = "crates/ui-egui/src/i18n/bg.tsv"
@@ -162,7 +162,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Bulgarian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "e50991d9d81a9a45e78c719c790029486e4c03045c30b10b4fee349fcc6702d0"
+sha256 = "7d36195963293e514d9a40242a8fd2aaed479fa4642fed13f9648916a5b1fde1"
[[asset]]
path = "crates/ui-egui/src/i18n/kk.tsv"
@@ -173,7 +173,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Kazakh UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "73fb4046cd4fdccd8c1da4abfab90ecd0ca2395fc9a6302dd00dd4f810a14418"
+sha256 = "9c42561f5279e1e5c14b23e35328c69d800750ade22981e9524fc748412328bd"
[[asset]]
path = "crates/ui-egui/src/i18n/ja.tsv"
@@ -184,7 +184,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Japanese UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "e090ca970a518bbf667959181167ff8f8058b78e4239c0c62654c58450738a99"
+sha256 = "64bba70d41277aeba09c1af425347e67586aa52d5d7758148c679af208a6a63b"
[[asset]]
path = "crates/ui-egui/src/i18n/uk.tsv"
@@ -195,7 +195,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Ukrainian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "a5e4cbf2fd2b1f840d31482a090a68fe58dbbd03e2187deecd1398d091c9fb8f"
+sha256 = "f055211d06eee77906ddea5e53c7f29c7b110ee58a031a8359a4ce7485edfe46"
[[asset]]
path = "crates/ui-egui/src/i18n/ar.tsv"
@@ -206,7 +206,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Arabic UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "036dfc2952a758352933ec9ab7f1668a699ed108c8902340566f149df4bc0b79"
+sha256 = "eecf66414e14f29b989e7b6de748810609002dc62b71e7789a2eb2daed5ec845"
[[asset]]
path = "crates/ui-egui/src/i18n/tr.tsv"
@@ -217,7 +217,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Turkish UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "d4ac259fc9dad897c9ca8a55eb830d2027f3387eafd641744dd7b9d43a5d1cb4"
+sha256 = "34ce3af08c6afc0bbc3ec37ec1923aa4f8a51db44b4f08d6b45674e91cd1bed4"
[[asset]]
path = "crates/ui-egui/src/i18n/lt.tsv"
@@ -228,7 +228,7 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Lithuanian UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "b0e3dacf8ce437663e3cb9946ced5b9f3cde6a62a2bf5ff8dd3d45268b264bf5"
+sha256 = "9d76dc284dd281e3d7a2fb7ea7636ae2c3650519713665f02bf96e8c65d86374"
[[asset]]
@@ -3363,4 +3363,4 @@ licence = "MIT OR Apache-2.0"
licence_file = "LICENSE-MIT"
kind = "translation"
usage = "Slovene UI strings, compiled in by crates/ui-egui/src/i18n/mod.rs"
-sha256 = "eb1f9d2990ab5e177be78d5d5e6d4c3cbdb0961c64df04bbd34e5d9ad5b42a3d"
+sha256 = "fb217509688595c77fcf8c5d256adb931a7a21c87c23dcc31bc79ba5710a4ffc"
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index fc4366ff0..f9e9aeca9 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -491,7 +491,9 @@ pub struct DocView {
/// interpret, so a drag would otherwise queue a storm of them (one per frame) while the
/// in-flight ones cannot be cancelled mid-operator. Older tiles and the backdrop stay
/// stretched meanwhile; fresh tiles go out once the pan settles.
- last_scroll: Vec2,
+ pub(crate) last_scroll: Vec2,
+ /// Side-by-side compare: scroll to here this frame, following the other half.
+ pub(crate) sync_scroll: Option<Vec2>,
pan_hold_until: f64,
/// Pages whose raster proved slow (see `SLOW_MILLIS`): only these get the zoom/pan
/// settle holds. Fast pages render straight through, with no added latency.
@@ -679,6 +681,7 @@ impl DocView {
last_scale: 0.0,
sharp_hold_until: 0.0,
last_scroll: Vec2::ZERO,
+ sync_scroll: None,
pan_hold_until: 0.0,
slow_pages: HashSet::new(),
comments: Default::default(),
@@ -2326,6 +2329,9 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
if !std::mem::replace(&mut view.shown, true) {
scroll = scroll.scroll_offset(Vec2::ZERO);
}
+ if let Some(v) = view.sync_scroll.take() {
+ scroll = scroll.scroll_offset(v);
+ }
if let Some((page, fx, fy, rel)) = view.zoom_anchor.take() {
let r = rects[page.min(rects.len() - 1)];
let point = pos2(r.left() + fx * r.width(), r.top() - y_shift + fy * r.height());
diff --git a/crates/ui-egui/src/compare_ui.rs b/crates/ui-egui/src/compare_ui.rs
index e84cc34dc..f9c1cbcee 100644
--- a/crates/ui-egui/src/compare_ui.rs
+++ b/crates/ui-egui/src/compare_ui.rs
@@ -17,6 +17,13 @@ pub struct CompareState {
/// Regions that look different (page, user-space box), page n against page n.
pub visual: Vec<(usize, [f64; 4])>,
pub selected: Option<usize>,
+ /// Side by side: the old file on the left, the new on the right, scrolled and zoomed
+ /// together.
+ pub side_by_side: bool,
+ /// Which half leads the other (the one the pointer was over last): 0 old, 1 new.
+ pub leader: usize,
+ /// Each half's scroll offset last frame, to tell which one moved.
+ pub prev_scroll: [egui::Vec2; 2],
}
/// Visual differences are shaded orange.
@@ -28,6 +35,7 @@ pub enum PanelAction {
Mark,
Report,
Clear,
+ SideBySide(bool),
}
pub fn colour(kind: Kind) -> Color32 {
@@ -99,6 +107,16 @@ pub(crate) fn panel(ui: &mut egui::Ui, t: &Tokens, state: &Option<CompareState>,
ui.label(crate::i18n::fmt(tl!("{n} {kind}"), &[("n", &s.visual.len().to_string()), ("kind", tl!("Visual"))]));
});
ui.add_space(6.0);
+ // Side by side, or the new file alone.
+ ui.horizontal(|ui| {
+ if widgets::pill_button(ui, tl!("Side by side"), s.side_by_side).clicked() {
+ action = Some(PanelAction::SideBySide(true));
+ }
+ if widgets::pill_button(ui, tl!("New file only"), !s.side_by_side).clicked() {
+ action = Some(PanelAction::SideBySide(false));
+ }
+ });
+ ui.add_space(4.0);
ui.horizontal(|ui| {
if ui.button(tl!("Mark as comments")).clicked() {
action = Some(PanelAction::Mark);
@@ -166,8 +184,37 @@ impl PdfCraftApp {
self.views[i].compare_marks.push((*p, r, VISUAL));
}
}
+ // The old file's pages too: what was deleted or replaced, and the visual
+ // differences, so both versions read with their own shading.
+ if let Some(oi) = self.views.iter().position(|v| v.id == old) {
+ let mut marks: Vec<(usize, [f32; 4], Color32)> = result
+ .changes
+ .iter()
+ .filter(|ch| ch.kind != Kind::Inserted)
+ .flat_map(|ch| ch.old.rects.iter().map(move |r| (ch.old.page, r.map(|v| v as f32), colour(ch.kind))))
+ .collect();
+ for (p, r) in &visual {
+ let r = r.map(|v| v as f32);
+ let covered = marks.iter().any(|(mp, m, _)| *mp == *p && m[0] <= r[2] && r[0] <= m[2] && m[1] <= r[3] && r[1] <= m[3]);
+ if !covered {
+ marks.push((*p, r, VISUAL));
+ }
+ }
+ self.views[oi].compare_marks = marks;
+ }
let n = result.changes.len();
- self.compare = Some(crate::compare_ui::CompareState { old, new, result, visual, selected: None });
+ // Side by side when the old version is open in a tab and the window has the room.
+ let side_by_side = self.views.iter().any(|v| v.id == old) && self.ctx.as_ref().is_none_or(|c| c.content_rect().width() >= 1000.0);
+ self.compare = Some(crate::compare_ui::CompareState {
+ old,
+ new,
+ result,
+ visual,
+ selected: None,
+ side_by_side,
+ leader: 1,
+ prev_scroll: [egui::Vec2::ZERO; 2],
+ });
self.right = Some(RightPanel::Compare);
self.notify(if n == 0 {
tl!("The text is the same").to_string()
@@ -190,9 +237,20 @@ impl PdfCraftApp {
let Some(ch) = s.result.changes.get(i) else { return };
let rect = ch.new.rects.first().copied().or(ch.new.near).unwrap_or_default();
let page = ch.new.page;
+ let old_target = (ch.old.page, ch.old.rects.first().copied().or(ch.old.near).unwrap_or_default());
let v = &mut self.views[index];
v.go_to_page(page);
v.flash = Some((page, rect.map(|x| x as f32), 0.0));
+ // The old file's half jumps to its side of the change too.
+ if let Some(oi) = self.views.iter().position(|v| v.id == old) {
+ let v = &mut self.views[oi];
+ v.go_to_page(old_target.0);
+ v.flash = Some((old_target.0, old_target.1.map(|x| x as f32), 0.0));
+ }
+ }
+ PanelAction::SideBySide(on) => {
+ s.side_by_side = on;
+ s.leader = 1;
}
PanelAction::Mark => match self.session.mark_differences(old, new) {
Ok(n) => {
@@ -218,8 +276,88 @@ impl PdfCraftApp {
PanelAction::Clear => {
self.compare = None;
self.views[index].compare_marks.clear();
+ if let Some(oi) = self.views.iter().position(|v| v.id == old) {
+ self.views[oi].compare_marks.clear();
+ }
self.right = None;
}
}
}
}
+
+/// The two halves of a side-by-side comparison, as view indexes (old, new), when the active
+/// document is the new file of a comparison shown side by side and the old file is open too.
+pub(crate) fn side_by_side(app: &PdfCraftApp, index: usize) -> Option<(usize, usize)> {
+ let c = app.compare.as_ref().filter(|c| c.side_by_side)?;
+ let new = app.views.get(index).filter(|v| v.id == c.new)?;
+ let old = app.views.iter().position(|v| v.id == c.old)?;
+ (old != index).then_some((old, app.views.iter().position(|v| v.id == new.id)?))
+}
+
+/// Side by side: the old file on the left, the new on the right, each a page view of its own
+/// with its shading, scrolled and zoomed together. The half the pointer is over leads; the
+/// other follows its zoom, layout and scroll offset.
+pub(crate) fn compare_area(app: &mut PdfCraftApp, old: usize, new: usize, ui: &mut egui::Ui) {
+ let t = Tokens::get(ui.ctx());
+ let rect = ui.available_rect_before_wrap();
+ let gap = 1.0;
+ let half_w = ((rect.width() - gap) / 2.0).max(1.0);
+ let caption_h = 22.0;
+ let left = egui::Rect::from_min_size(rect.min, egui::vec2(half_w, rect.height()));
+ let right = egui::Rect::from_min_size(egui::pos2(rect.min.x + half_w + gap, rect.min.y), egui::vec2(half_w, rect.height()));
+ // Who leads: the half under the pointer (remembered), the new file at first.
+ if let Some(p) = ui.input(|i| i.pointer.hover_pos())
+ && let Some(c) = app.compare.as_mut()
+ {
+ if left.contains(p) {
+ c.leader = 0;
+ } else if right.contains(p) {
+ c.leader = 1;
+ }
+ }
+ let leader = app.compare.as_ref().map_or(1, |c| c.leader);
+ let (lead, follow) = if leader == 0 { (old, new) } else { (new, old) };
+ // The follower takes the leader's zoom and layout before either is drawn.
+ let (zoom, fit, layout, continuous, rotation) = {
+ let v = &app.views[lead];
+ (v.zoom, v.fit, v.layout, v.continuous, v.rotation)
+ };
+ {
+ let v = &mut app.views[follow];
+ if v.zoom != zoom || v.fit != fit || v.layout != layout || v.continuous != continuous || v.rotation != rotation {
+ v.zoom = zoom;
+ v.fit = fit;
+ v.layout = layout;
+ v.continuous = continuous;
+ v.rotation = rotation;
+ }
+ }
+ let names = [old, new].map(|i| app.session.get(app.views[i].id).map(|d| d.name.clone()).unwrap_or_default());
+ ui.painter().vline(rect.min.x + half_w, rect.y_range(), egui::Stroke::new(gap, t.border));
+ for (k, (r, index)) in [(left, old), (right, new)].into_iter().enumerate() {
+ let caption = egui::Rect::from_min_size(r.min, egui::vec2(r.width(), caption_h));
+ ui.painter().rect_filled(caption, 0.0, t.panel);
+ let label = crate::i18n::fmt(if k == 0 { tl!("Old file: {name}") } else { tl!("New file: {name}") }, &[("name", &names[k])]);
+ ui.painter().text(
+ egui::pos2(caption.min.x + 10.0, caption.center().y),
+ egui::Align2::LEFT_CENTER,
+ label,
+ egui::FontId::proportional(12.0),
+ t.text_muted,
+ );
+ let body = egui::Rect::from_min_max(egui::pos2(r.min.x, r.min.y + caption_h), r.max);
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(body).id_salt(("compare-half", k)));
+ child.set_clip_rect(body);
+ crate::canvas::document_area(app, index, &mut child);
+ }
+ // After both drew: the leader's scroll, when it moved, is the follower's next offset.
+ let offsets = [app.views[old].last_scroll, app.views[new].last_scroll];
+ if let Some(c) = app.compare.as_mut() {
+ let lead_k = if leader == 0 { 0 } else { 1 };
+ if (offsets[lead_k] - c.prev_scroll[lead_k]).length() > 0.5 && (offsets[1 - lead_k] - offsets[lead_k]).length() > 0.5 {
+ app.views[follow].sync_scroll = Some(offsets[lead_k]);
+ ui.ctx().request_repaint();
+ }
+ c.prev_scroll = offsets;
+ }
+}
diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs
index fe4c0390d..58fd71a67 100644
--- a/crates/ui-egui/src/docking.rs
+++ b/crates/ui-egui/src/docking.rs
@@ -409,7 +409,10 @@ pub fn show(app: &mut crate::PdfCraftApp, ui: &mut egui::Ui) {
match app.active {
None if app.combine_showing() => crate::combine_ui::page(app, ui),
None => crate::home::show(app, ui),
- Some(index) => crate::canvas::document_area(app, index, ui),
+ Some(index) => match crate::compare_ui::side_by_side(app, index) {
+ Some((old, new)) => crate::compare_ui::compare_area(app, old, new, ui),
+ None => crate::canvas::document_area(app, index, ui),
+ },
}
}
Panel::Tools => crate::panels::left_panel(app, ui),
diff --git a/crates/ui-egui/src/i18n/ar.tsv b/crates/ui-egui/src/i18n/ar.tsv
index c67df5571..093757cdc 100644
--- a/crates/ui-egui/src/i18n/ar.tsv
+++ b/crates/ui-egui/src/i18n/ar.tsv
@@ -2398,3 +2398,7 @@ animation effects Off معطّلة
Mobile الهاتف المحمول
Merge image fragments دمج أجزاء الصور
Optimizing… merging image fragments جارٍ التحسين… دمج أجزاء الصور
+ Side by side جنبًا إلى جنب
+ New file only الملف الجديد فقط
+ Old file: {name} الملف القديم: {name}
+ New file: {name} الملف الجديد: {name}
diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv
index 84f2d6eae..e75a7bc08 100644
--- a/crates/ui-egui/src/i18n/bg.tsv
+++ b/crates/ui-egui/src/i18n/bg.tsv
@@ -2340,3 +2340,7 @@ animation effects Off Изключени
Mobile Мобилни устройства
Merge image fragments Обединяване на фрагменти от изображения
Optimizing… merging image fragments Оптимизиране… обединяване на фрагменти от изображения
+ Side by side Един до друг
+ New file only Само новият файл
+ Old file: {name} Стар файл: {name}
+ New file: {name} Нов файл: {name}
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 3e5e3680c..6037cf281 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -2451,3 +2451,7 @@ animation effects Off Vypnuto
Mobile Mobilní zařízení
Merge image fragments Sloučit fragmenty obrázků
Optimizing… merging image fragments Optimalizace… slučování fragmentů obrázků
+ Side by side Vedle sebe
+ New file only Jen nový soubor
+ Old file: {name} Starý soubor: {name}
+ New file: {name} Nový soubor: {name}
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index d21a24d6b..ee0a5418c 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -2378,3 +2378,7 @@ animation effects Off Aus
Mobile Mobilgerät
Merge image fragments Bildfragmente zusammenführen
Optimizing… merging image fragments Optimieren… Bildfragmente werden zusammengeführt
+ Side by side Nebeneinander
+ New file only Nur neue Datei
+ Old file: {name} Alte Datei: {name}
+ New file: {name} Neue Datei: {name}
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index c9680ed94..679c2e2e9 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -2387,3 +2387,7 @@ animation effects Off Ανενεργά
Mobile Κινητό
Merge image fragments Συγχώνευση τμημάτων εικόνας
Optimizing… merging image fragments Βελτιστοποίηση… συγχώνευση τμημάτων εικόνας
+ Side by side Δίπλα-δίπλα
+ New file only Μόνο το νέο αρχείο
+ Old file: {name} Παλιό αρχείο: {name}
+ New file: {name} Νέο αρχείο: {name}
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 8c63c182a..3ca46ff11 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2507,3 +2507,7 @@ animation effects Off Desactivados
Mobile Móvil
Merge image fragments Combinar fragmentos de imagen
Optimizing… merging image fragments Optimizando… combinando fragmentos de imagen
+ Side by side Lado a lado
+ New file only Solo el archivo nuevo
+ Old file: {name} Archivo antiguo: {name}
+ New file: {name} Archivo nuevo: {name}
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 3d6bcce62..1408fddf8 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -2377,3 +2377,7 @@ animation effects Off Désactivés
Mobile Mobile
Merge image fragments Fusionner les fragments d’image
Optimizing… merging image fragments Optimisation… fusion des fragments d’image
+ Side by side Côte à côte
+ New file only Nouveau fichier seul
+ Old file: {name} Ancien fichier : {name}
+ New file: {name} Nouveau fichier : {name}
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index 1961246f0..0ca2ec150 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -2376,3 +2376,7 @@ animation effects Off Ki
Mobile Mobil
Merge image fragments Képtöredékek egyesítése
Optimizing… merging image fragments Optimalizálás… képtöredékek egyesítése
+ Side by side Egymás mellett
+ New file only Csak az új fájl
+ Old file: {name} Régi fájl: {name}
+ New file: {name} Új fájl: {name}
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index bfed12bf0..d762d9869 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -2386,3 +2386,7 @@ animation effects Off Disattivati
Mobile Cellulare
Merge image fragments Unisci frammenti di immagine
Optimizing… merging image fragments Ottimizzazione… unione dei frammenti di immagine
+ Side by side Affiancati
+ New file only Solo il nuovo file
+ Old file: {name} File vecchio: {name}
+ New file: {name} File nuovo: {name}
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 2ac86df72..4a80d277f 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -2377,3 +2377,7 @@ animation effects Off オフ
Mobile モバイル
Merge image fragments 画像の断片を結合
Optimizing… merging image fragments 最適化中… 画像の断片を結合しています
+ Side by side 並べて表示
+ New file only 新しいファイルのみ
+ Old file: {name} 古いファイル: {name}
+ New file: {name} 新しいファイル: {name}
diff --git a/crates/ui-egui/src/i18n/kk.tsv b/crates/ui-egui/src/i18n/kk.tsv
index 443b756a9..67631f337 100644
--- a/crates/ui-egui/src/i18n/kk.tsv
+++ b/crates/ui-egui/src/i18n/kk.tsv
@@ -2375,3 +2375,7 @@ animation effects Off Өшірулі
Mobile Мобильді құрылғы
Merge image fragments Сурет фрагменттерін біріктіру
Optimizing… merging image fragments Оңтайландыру… сурет фрагменттерін біріктіру
+ Side by side Қатар
+ New file only Тек жаңа файл
+ Old file: {name} Ескі файл: {name}
+ New file: {name} Жаңа файл: {name}
diff --git a/crates/ui-egui/src/i18n/lt.tsv b/crates/ui-egui/src/i18n/lt.tsv
index a658a2c9a..f67f0bd8c 100644
--- a/crates/ui-egui/src/i18n/lt.tsv
+++ b/crates/ui-egui/src/i18n/lt.tsv
@@ -2621,3 +2621,7 @@ key Space Tarpas
Mobile Mobilusis
Merge image fragments Sujungti vaizdo fragmentus
Optimizing… merging image fragments Optimizuojama… jungiami vaizdo fragmentai
+ Side by side Greta
+ New file only Tik naujas failas
+ Old file: {name} Senas failas: {name}
+ New file: {name} Naujas failas: {name}
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 1824e1742..dc2891116 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -2357,3 +2357,7 @@ animation effects Off Wyłączone
Mobile Urządzenie mobilne
Merge image fragments Scal fragmenty obrazów
Optimizing… merging image fragments Optymalizacja… scalanie fragmentów obrazów
+ Side by side Obok siebie
+ New file only Tylko nowy plik
+ Old file: {name} Stary plik: {name}
+ New file: {name} Nowy plik: {name}
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index a6461661c..fe507b6b4 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -2391,3 +2391,7 @@ animation effects Off Desativados
Mobile Celular
Merge image fragments Mesclar fragmentos de imagem
Optimizing… merging image fragments Otimizando… mesclando fragmentos de imagem
+ Side by side Lado a lado
+ New file only Somente o arquivo novo
+ Old file: {name} Arquivo antigo: {name}
+ New file: {name} Arquivo novo: {name}
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 299590f46..d8d23a3ad 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -2290,3 +2290,7 @@ animation effects Off Выкл
Mobile Мобильные устройства
Merge image fragments Объединять фрагменты изображений
Optimizing… merging image fragments Оптимизация… объединение фрагментов изображений
+ Side by side Рядом
+ New file only Только новый файл
+ Old file: {name} Старый файл: {name}
+ New file: {name} Новый файл: {name}
diff --git a/crates/ui-egui/src/i18n/sl.tsv b/crates/ui-egui/src/i18n/sl.tsv
index 742f77046..c0bb30459 100644
--- a/crates/ui-egui/src/i18n/sl.tsv
+++ b/crates/ui-egui/src/i18n/sl.tsv
@@ -2382,3 +2382,7 @@ animation effects Off Izklopljeni
Mobile Mobilna naprava
Merge image fragments Združi delce slik
Optimizing… merging image fragments Optimiziranje… združevanje delcev slik
+ Side by side Drug ob drugem
+ New file only Samo nova datoteka
+ Old file: {name} Stara datoteka: {name}
+ New file: {name} Nova datoteka: {name}
diff --git a/crates/ui-egui/src/i18n/te.tsv b/crates/ui-egui/src/i18n/te.tsv
index 0079cd69a..5bd6fa150 100644
--- a/crates/ui-egui/src/i18n/te.tsv
+++ b/crates/ui-egui/src/i18n/te.tsv
@@ -2290,3 +2290,7 @@ animation effects Off ఆఫ్
Mobile మొబైల్
Merge image fragments చిత్ర శకలాలను విలీనం చేయి
Optimizing… merging image fragments ఆప్టిమైజ్ చేస్తోంది… చిత్ర శకలాలను విలీనం చేస్తోంది
+ Side by side పక్కపక్కన
+ New file only కొత్త ఫైల్ మాత్రమే
+ Old file: {name} పాత ఫైల్: {name}
+ New file: {name} కొత్త ఫైల్: {name}
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index 320db7fb2..b400033d0 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -2373,3 +2373,7 @@ animation effects Off Kapalı
Mobile Mobil
Merge image fragments Görüntü parçalarını birleştir
Optimizing… merging image fragments İyileştiriliyor… görüntü parçaları birleştiriliyor
+ Side by side Yan yana
+ New file only Yalnızca yeni dosya
+ Old file: {name} Eski dosya: {name}
+ New file: {name} Yeni dosya: {name}
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index abb939813..5dbbf01a6 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -2399,3 +2399,7 @@ animation effects Off Вимкнено
Mobile Мобільні пристрої
Merge image fragments Об’єднувати фрагменти зображень
Optimizing… merging image fragments Оптимізація… об’єднання фрагментів зображень
+ Side by side Поруч
+ New file only Лише новий файл
+ Old file: {name} Старий файл: {name}
+ New file: {name} Новий файл: {name}
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index 931a422c3..c24a7fea7 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2341,3 +2341,7 @@ animation effects Off 关
Mobile 移动设备
Merge image fragments 合并图像碎片
Optimizing… merging image fragments 正在优化… 正在合并图像碎片
+ Side by side 并排
+ New file only 仅新文件
+ Old file: {name} 旧文件:{name}
+ New file: {name} 新文件:{name}
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index c6e9f368d..6aa5270ab 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2331,3 +2331,7 @@ animation effects Off 關
Mobile 行動裝置
Merge image fragments 合併影像片段
Optimizing… merging image fragments 正在最佳化… 正在合併影像片段
+ Side by side 並排
+ New file only 僅新檔案
+ Old file: {name} 舊檔案:{name}
+ New file: {name} 新檔案:{name}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 8aacc7eea..1c9487781 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -2978,7 +2978,10 @@ impl eframe::App for PdfCraftApp {
ui,
|ui| {
if let Some(i) = self.active {
- canvas::document_area(self, i, ui);
+ match compare_ui::side_by_side(self, i) {
+ Some((old, new)) => compare_ui::compare_area(self, old, new, ui),
+ None => canvas::document_area(self, i, ui),
+ }
}
},
);
@@ -3015,7 +3018,10 @@ impl eframe::App for PdfCraftApp {
match self.active {
None if self.combine_showing() => combine_ui::page(self, ui),
None => home::show(self, ui),
- Some(index) => canvas::document_area(self, index, ui),
+ Some(index) => match compare_ui::side_by_side(self, index) {
+ Some((old, new)) => compare_ui::compare_area(self, old, new, ui),
+ None => canvas::document_area(self, index, ui),
+ },
}
} else {
docking::show(self, ui);
@@ -3036,17 +3042,22 @@ impl PdfCraftApp {
self.combine_thumbs_frame(ctx);
// Retire hidden documents before admitting the visible document's textures, so the
// three cache limits apply to the application, regardless of how many tabs are open.
+ // Side by side: the comparison's old file renders alongside the active one.
+ let partner = self.active.and_then(|i| compare_ui::side_by_side(self, i)).map(|(old, _)| old);
for (i, view) in self.views.iter_mut().enumerate() {
if Some(i) != self.active
+ && Some(i) != partner
&& let Some(doc) = self.session.get(view.id)
{
view.suspend_rendering(&doc.renderer);
}
}
- if let Some(view) = self.active.and_then(|i| self.views.get_mut(i))
- && let Some(doc) = self.session.get(view.id)
- {
- view.finish_render_frame(ctx, &doc.info, &doc.renderer);
+ for i in self.active.into_iter().chain(partner) {
+ if let Some(view) = self.views.get_mut(i)
+ && let Some(doc) = self.session.get(view.id)
+ {
+ view.finish_render_frame(ctx, &doc.info, &doc.renderer);
+ }
}
}
}
diff --git a/crates/ui-egui/tests/compare.rs b/crates/ui-egui/tests/compare.rs
index 089d3b882..e735668a1 100644
--- a/crates/ui-egui/tests/compare.rs
+++ b/crates/ui-egui/tests/compare.rs
@@ -33,6 +33,24 @@ fn compare_two_versions() {
let id = h.state().active_ids().unwrap().1;
let i = h.state().active_ids().unwrap().0;
assert_eq!(h.state().views[i].compare_marks.len(), 2);
+ // Side by side: the old file's half shades its side of the changes and follows the new
+ // file's zoom; "New file only" ends it.
+ assert!(h.state().compare.as_ref().unwrap().side_by_side, "side by side on a wide window");
+ let old_i = h.state().views.iter().position(|v| v.id == h.state().compare.as_ref().unwrap().old).unwrap();
+ assert_eq!(h.state().views[old_i].compare_marks.len(), 2, "replaced words shaded on the old file too");
+ assert!(h.state().views[old_i].flash.is_some(), "the old half jumped to the change");
+ h.state_mut().views[i].zoom = 1.5;
+ h.state_mut().views[i].fit = pdfcraft_ui_egui::canvas::Fit::None;
+ h.run_steps(3);
+ assert_eq!((h.state().views[old_i].zoom, h.state().views[old_i].fit), (1.5, pdfcraft_ui_egui::canvas::Fit::None), "the old half follows");
+ h.get_by_label("New file only").click();
+ h.run_steps(2);
+ assert!(!h.state().compare.as_ref().unwrap().side_by_side);
+ h.get_by_label("Side by side").click();
+ h.run_steps(2);
+ assert!(h.state().compare.as_ref().unwrap().side_by_side);
+ h.get_by_label("New file only").click();
+ h.run_steps(2);
h.get_by_label("Mark as comments").click();
h.run_steps(3);
assert_eq!(h.state().session.get(id).unwrap().info.annotations.len(), 2);
diff --git a/parity/acrobat-features.toml b/parity/acrobat-features.toml
index 0a3816046..dfcdb9aab 100644
--- a/parity/acrobat-features.toml
+++ b/parity/acrobat-features.toml
@@ -9155,11 +9155,11 @@ title = "Side-by-side compare view with synchronised scrolling"
area = "N"
tier = "P1"
milestone = "M12"
-status = "planned"
-commands = []
+status = "shipped"
+commands = ["doc.compare"]
tools = []
-evidence = []
-notes = ""
+evidence = ["crates/ui-egui/tests/compare.rs::compare_two_versions"]
+notes = "After Compare files the document area splits (when the old version is open in a tab and the window is at least 1000 px wide; the Compare panel's Side by side / New file only toggles it): the old file on the left, the new on the right, each a page view of its own with its shading (deleted and replaced on the old, inserted and replaced on the new, visual differences on both). The half the pointer is over leads: the other takes its zoom, fit, layout, rotation and scroll offset; a change clicked in the panel jumps both halves to their side of it. Clear ends it. Still missing against Acrobat: scrolling by matching content rather than by offset (pages of different sizes drift), and the comparison kept when the old file's tab closes."
[[feature]]
id = "misc.compare-report"