Merge branch 'lookfix/shellwf' into area/app-1

This commit is contained in:
Dylan M. Taylor
2026-11-22 05:20:47 -05:00
4 changed files with 77 additions and 24 deletions
+11 -1
View File
@@ -179,7 +179,17 @@ impl PdfCraftApp {
SaveStep::AskChangedOnDisk { key, .. } => {
// The file on disk is another version than the document came from (#2166).
let name = self.session.get(key).map(|d| d.name.clone()).unwrap_or_default();
let prompt = crate::dialogs::host::open(self, StandardPrompt::changed_on_disk(name));
// Production's wording and buttons: Save anyway is an ordinary answer, not a red Replace.
let message = crate::i18n::fmt(
tl!("“{name}” changed on disk after it was opened or last saved. Saving now replaces that newer version with this one."),
&[("name", &name)],
);
let prompt = StandardPrompt::custom(message)
.title(tl!("Save over the changed file?").to_string())
.button(PromptChoice::Proceed, tl!("Save anyway").to_string())
.button(PromptChoice::Alternate, tl!("Save as…").to_string())
.button(PromptChoice::Cancel, tl!("Cancel").to_string());
let prompt = crate::dialogs::host::open(self, prompt);
if let Some(pending) = self.pending_save.as_mut().filter(|p| p.key == key) {
pending.prompt = Some(prompt);
}
@@ -263,6 +263,39 @@ impl PageSource for FilePages {
}
}
/// The pages a file adds as the preview's whole document: it counts and numbers them 1..n as the production
/// preview does ("Page 1 of 3" for a range of three), where `pages` maps each one to its page in the file.
struct RangePages<'a> {
inner: &'a FilePages,
pages: &'a [usize],
}
impl ThumbSource<usize> for RangePages<'_> {
fn revision(&self, page: &usize, request: &ThumbRequest) -> Revision {
match self.pages.get(*page) {
Some(real) => self.inner.revision(real, request),
None => Revision::of(&u8::MAX),
}
}
fn render(&self, page: &usize, request: &ThumbRequest) -> ThumbRender {
match self.pages.get(*page) {
Some(real) => self.inner.render(real, request),
None => ThumbRender::Blank,
}
}
}
impl PageSource for RangePages<'_> {
fn page_count(&self) -> usize {
self.pages.len()
}
fn page_size(&self, page: usize) -> Size {
self.pages.get(page).map_or_else(|| Size::new(612.0, 792.0), |real| self.inner.page_size(*real))
}
}
/// The file a tile's Preview opened, shown large over the window: one of the pages it adds at a time,
/// stepped with the buttons or the keys; Escape or Close closes it. It closes by itself when the file
/// leaves the list, is locked again or has nothing to show.
@@ -302,7 +335,9 @@ pub(crate) fn preview(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
documents: app.combine_tab.open_documents.clone(),
};
let mut at = p.at;
let shown = PagePreview::new(&source, &pages, &mut at, DataColor::new(egui::Color32::WHITE)).show(ui);
let numbered: Vec<usize> = (0..pages.len()).collect();
let ranged = RangePages { inner: &source, pages: &pages };
let shown = PagePreview::new(&ranged, &numbered, &mut at, DataColor::new(egui::Color32::WHITE)).show(ui);
p.at = at;
p.page = pages.get(at).copied();
if shown.closed {
+4 -1
View File
@@ -402,7 +402,10 @@ pub(crate) fn compare_area(app: &mut PdfCraftApp, old: usize, new: usize, ui: &m
if let Some(v) = app.views.get_mut(index) {
std::mem::swap(&mut v.view, state);
}
let output = crate::canvas::document_area_at(app, index, rect, ui);
// Each half's notices lie within its own half: draw in a child ui bounded by the half.
let mut half_ui = ui.new_child(egui::UiBuilder::new().max_rect(rect).id_salt(("compare-half", index)));
half_ui.shrink_clip_rect(rect);
let output = crate::canvas::document_area_at(app, index, rect, &mut half_ui);
if let Some(v) = app.views.get_mut(index) {
std::mem::swap(&mut v.view, state);
}
+26 -21
View File
@@ -9,9 +9,10 @@ use std::sync::{Arc, Mutex, PoisonError, RwLock};
use craft::behavior::{ColumnKey, ColumnWidth, DisplayOrder, ItemSource};
use craft::host::queue::{JobQueue, Priority};
use craft::ui::contract::{Bind, ColumnSpec, Props as _, SelectMode, Show as _, ShowCollection as _, Sizing};
use craft::ui::contract::{Bind, ColumnSpec, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing};
use craft::ui::dialog::{DialogResult, dialog_id};
use craft::ui::display::Text;
use craft::ui::layout_components::Stack;
use craft::ui::list::ListRow;
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind, ParamTab, SharedRows};
use craft::ui::table::Table;
@@ -499,27 +500,31 @@ impl ItemSource<usize> for AuditRows<'_> {}
fn audit_row(rows: Arc<RwLock<Vec<SpaceUse>>>) -> Param {
Param::custom("space-audit", tl!("Space Audit"), move |ui, _fields, _cx| {
let lines = audit_lines(&rows.read().unwrap_or_else(PoisonError::into_inner));
Text::new(tl!("What takes up the space in this file, by kind of content.")).show(ui);
let columns = vec![
ColumnSpec::new(DESCRIPTION, tl!("Description"), ColumnWidth::Content),
ColumnSpec::new(BYTES, tl!("Bytes"), ColumnWidth::Content).numeric(),
ColumnSpec::new(PERCENTAGE, tl!("Percentage"), ColumnWidth::Content).numeric(),
];
Table::<usize>::new(tl!("Space Audit"), columns)
.select(SelectMode::None)
.sizing(Sizing::Content)
.natural_height(true)
.striped(true)
.show_items(ui, &AuditRows(&lines), &mut |at, icx| {
let Some(line) = lines.get(*at) else { return ListRow::new("") };
ListRow::new(line.description.clone())
.cells(icx.cells())
.striped(icx.row.striped)
.cell(BYTES, line.bytes.clone())
.cell(PERCENTAGE, line.percentage.clone())
})
.response
let shown = Stack::new().fill_width().show(ui, |ui, _| {
Text::new(tl!("What takes up the space in this file, by kind of content.")).show(ui);
let columns = vec![
ColumnSpec::new(DESCRIPTION, tl!("Description"), ColumnWidth::Content),
ColumnSpec::new(BYTES, tl!("Bytes"), ColumnWidth::Content).numeric(),
ColumnSpec::new(PERCENTAGE, tl!("Percentage"), ColumnWidth::Content).numeric(),
];
Table::<usize>::new(tl!("Space Audit"), columns)
.select(SelectMode::None)
.sizing(Sizing::Content)
.natural_height(true)
.striped(true)
.show_items(ui, &AuditRows(&lines), &mut |at, icx| {
let Some(line) = lines.get(*at) else { return ListRow::new("") };
ListRow::new(line.description.clone())
.cells(icx.cells())
.striped(icx.row.striped)
.cell(BYTES, line.bytes.clone())
.cell(PERCENTAGE, line.percentage.clone())
})
.response
});
shown.inner.unwrap_or(shown.output)
})
.full_width()
}
/// The Space Audit row, for a dialog that shows the audit among other rows (Properties ▸ Space Audit): reads the app's shared