diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 5fec53c6b8..8049433060 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -4,7 +4,7 @@ Every asset PdfCraft includes, bundles or uses to build its published material, with its author, source and licence. The policy is in [AGENTS.md](AGENTS.md) §1. The machine-readable list, with the SHA-256 of every asset, is [ATTRIBUTION.toml](ATTRIBUTION.toml). Licence texts are kept beside the assets and summarised in [NOTICE](NOTICE). -## In this repository (137) +## In this repository (140) | Asset | Title | Author | Licence | Source | Used for | |---|---|---|---|---|---| @@ -25,6 +25,8 @@ Every asset PdfCraft includes, bundles or uses to build its published material, | `assets/icons/braces.svg` | Lucide icon "braces" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/braces.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/camera.svg` | Lucide icon "camera" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/camera.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/check-circle-2.svg` | Lucide icon "check-circle-2" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/check-circle-2.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | +| `assets/icons/chevrons-down.svg` | Lucide icon "chevrons-down" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/chevrons-down.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | +| `assets/icons/chevrons-up.svg` | Lucide icon "chevrons-up" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/chevrons-up.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/circle-check.svg` | Lucide icon "circle-check" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/circle-check.svg) | Source of the path data that crates/sign/src/status_layers.rs draws into displayed signature status layers; the UI draws this icon from the built-in catalogue | | `assets/icons/circle-help.svg` | Lucide icon "circle-help" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/circle-help.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/clock-3.svg` | Lucide icon "clock-3" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/clock-3.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | @@ -67,6 +69,7 @@ Every asset PdfCraft includes, bundles or uses to build its published material, | `assets/icons/minimize-2.svg` | Lucide icon "minimize-2" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/minimize-2.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/paperclip.svg` | Lucide icon "paperclip" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/paperclip.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/pen-line.svg` | Lucide icon "pen-line" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/pen-line.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | +| `assets/icons/pin-off.svg` | Lucide icon "pin-off" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/pin-off.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/presentation.svg` | Lucide icon "presentation" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/presentation.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/printer.svg` | Lucide icon "printer" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/printer.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | | `assets/icons/replace.svg` | Lucide icon "replace" | Lucide Contributors (portions Cole Bemis, Feather) | ISC AND MIT | https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/replace.svg) | UI icon, embedded via crates/ui-egui/src/icons.rs | diff --git a/ATTRIBUTION.toml b/ATTRIBUTION.toml index 486d134ae5..9612d0e0c6 100644 --- a/ATTRIBUTION.toml +++ b/ATTRIBUTION.toml @@ -197,6 +197,28 @@ kind = "icon" usage = "UI icon, embedded via crates/ui-egui/src/icons.rs" sha256 = "765ebd1031367e2fd2a940b62f4402fac8976dea0210b0e3b1e59a2c75897928" +[[asset]] +path = "assets/icons/chevrons-down.svg" +title = "Lucide icon \"chevrons-down\"" +author = "Lucide Contributors (portions Cole Bemis, Feather)" +source = "https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/chevrons-down.svg)" +licence = "ISC AND MIT" +licence_file = "assets/icons/LICENSE-lucide.txt" +kind = "icon" +usage = "UI icon, embedded via crates/ui-egui/src/icons.rs" +sha256 = "f6fb7f1c3d539665c0d4c6ea5c13436ef1eb1a0df8e6c9f0de65fb960cc27083" + +[[asset]] +path = "assets/icons/chevrons-up.svg" +title = "Lucide icon \"chevrons-up\"" +author = "Lucide Contributors (portions Cole Bemis, Feather)" +source = "https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/chevrons-up.svg)" +licence = "ISC AND MIT" +licence_file = "assets/icons/LICENSE-lucide.txt" +kind = "icon" +usage = "UI icon, embedded via crates/ui-egui/src/icons.rs" +sha256 = "36890150a699c3c16fbc28fce1ee2582c0b74c7fe3f4ff30c6917960933051af" + [[asset]] path = "assets/icons/circle-check.svg" title = "Lucide icon \"circle-check\"" @@ -659,6 +681,17 @@ kind = "icon" usage = "UI icon, embedded via crates/ui-egui/src/icons.rs" sha256 = "195939cbf88689334dc3a9d64bd0b3f459ce1de7d71e53620f6b0448b958f9c8" +[[asset]] +path = "assets/icons/pin-off.svg" +title = "Lucide icon \"pin-off\"" +author = "Lucide Contributors (portions Cole Bemis, Feather)" +source = "https://github.com/lucide-icons/lucide (npm lucide-static 1.49.0, icons/pin-off.svg)" +licence = "ISC AND MIT" +licence_file = "assets/icons/LICENSE-lucide.txt" +kind = "icon" +usage = "UI icon, embedded via crates/ui-egui/src/icons.rs" +sha256 = "4c9c29a91905ccc7473f7c62061092abab0c89697f9ab7f7041631a53720d67a" + [[asset]] path = "assets/icons/presentation.svg" title = "Lucide icon \"presentation\"" diff --git a/assets/icons/chevrons-down.svg b/assets/icons/chevrons-down.svg new file mode 100644 index 0000000000..bcd2f90911 --- /dev/null +++ b/assets/icons/chevrons-down.svg @@ -0,0 +1,16 @@ + + + + + diff --git a/assets/icons/chevrons-up.svg b/assets/icons/chevrons-up.svg new file mode 100644 index 0000000000..9355beb141 --- /dev/null +++ b/assets/icons/chevrons-up.svg @@ -0,0 +1,16 @@ + + + + + diff --git a/assets/icons/pin-off.svg b/assets/icons/pin-off.svg new file mode 100644 index 0000000000..924c784025 --- /dev/null +++ b/assets/icons/pin-off.svg @@ -0,0 +1,18 @@ + + + + + + + diff --git a/crates/ui-egui/src/canvas/bars.rs b/crates/ui-egui/src/canvas/bars.rs index 0c8c5dd93d..368d10ebc4 100644 --- a/crates/ui-egui/src/canvas/bars.rs +++ b/crates/ui-egui/src/canvas/bars.rs @@ -56,10 +56,10 @@ pub(super) enum Notice { LockSignatures, } -/// One page notice bar with the icon named `icon`. -fn bar(_tone: Tone, icon: &'static str, text: String) -> Bar<'static> { +/// One page notice bar with the icon `icon`. +fn bar(_tone: Tone, icon: IconId, text: String) -> Bar<'static> { // Production paints every notice bar on the soft accent surface, whatever it warns of; the icon says which kind. - Bar::new(Tone::Info, text).layout(NoticeLayout::Bar).icon(NoticeIcon::Custom(IconId::new(icon).into())) + Bar::new(Tone::Info, text).layout(NoticeLayout::Bar).icon(NoticeIcon::Custom(icon.into())) } /// The notices above the pages, one after another: a file changed on disk first, then what a historical @@ -88,7 +88,7 @@ pub(super) fn notices( if view.disk_changed { let out = bar( Tone::Info, - "rotate-cw", + IconId::new("rotate_cw"), tl!("This file changed on disk. Reload shows the new version and drops your unsaved changes; Save replaces it with this version.") .to_string(), ) @@ -114,7 +114,7 @@ pub(super) fn notices( &[("rev", &snap.revision.to_string()), ("from", &snap.from)], ) }; - let out = bar(Tone::Info, "clock", text).action(NoticeAction::new(tl!("Close").to_string())).show(ui); + let out = bar(Tone::Info, IconId::new("clock"), text).action(NoticeAction::new(tl!("Close").to_string())).show(ui); if out.action == Some(0) { return Some(Notice::Close); } @@ -129,7 +129,7 @@ pub(super) fn notices( // A signature just placed with Fill & Sign is a comment others can move (#2149): offer to // lock it into the page now. `lock_offer` is false for a digitally signed document. if lock_offer && !view.lock_offer_dismissed { - let out = bar(Tone::Info, "lock", tl!("Signature added. Others can move it until it's locked.").to_string()) + let out = bar(Tone::Info, IconId::new("lock"), tl!("Signature added. Others can move it until it's locked.").to_string()) .action(NoticeAction::new(tl!("Lock now").to_string()).default_action()) .dismiss() .show(ui); @@ -141,8 +141,9 @@ pub(super) fn notices( } } if let Some((icon, tone, template, arg)) = signed { - let out = - bar(tone, icon, crate::i18n::fmt(tl!(template), &[("by", &arg)])).action(NoticeAction::new(tl!("Signature panel").to_string())).show(ui); + let out = bar(tone, IconId::new(icon), crate::i18n::fmt(tl!(template), &[("by", &arg)])) + .action(NoticeAction::new(tl!("Signature panel").to_string())) + .show(ui); return (out.action == Some(0)).then_some(Notice::Signatures); } if view.notice_dismissed { @@ -167,17 +168,17 @@ pub(super) fn notices( text.push_str(chars.as_str()); text.push('.'); } - Some(("text-cursor-input", Tone::Info, text, true)) + Some((IconId::new("text-cursor-input"), Tone::Info, text, true)) } else if info.xfa == Some(pdfcraft_render::Xfa::Dynamic) { Some(( - "triangle-alert", + IconId::new("triangle-alert"), Tone::Warn, tl!("This is a dynamic XFA form, which PdfCraft can't display yet. What you see is the file's placeholder page.").to_string(), false, )) } else if info.xfa == Some(pdfcraft_render::Xfa::Static) { Some(( - "text-cursor-input", + IconId::new("text-cursor-input"), Tone::Info, tl!("XFA form: its fields and its XFA data are kept in step, so other viewers show what you fill in.").to_string(), true, @@ -185,7 +186,7 @@ pub(super) fn notices( } else if info.fields.iter().any(|f| f.kind != pdfcraft_render::FieldKind::PushButton) { // Push buttons alone (LaTeX `animate` frames, navigation buttons) leave nothing to fill in. Some(( - "text-cursor-input", + IconId::new("text-cursor-input"), Tone::Info, crate::i18n::fmt(tl!("This document contains {n} interactive form fields."), &[("n", &info.fields.len().to_string())]), true, @@ -194,21 +195,26 @@ pub(super) fn notices( None }; let msg = if scripts_off { - Some(("triangle-alert", Tone::Info, crate::js_ui::scripts_off_notice(), true)) + Some((IconId::new("triangle-alert"), Tone::Info, crate::js_ui::scripts_off_notice(), true)) } else if secured { // A secured form still says what it is, and keeps Highlight fields: the security // sentence follows the form's. let security = tl!("This document is secured. Some changes are restricted by its security settings."); Some(match form { Some((icon, tone, text, fields)) => (icon, tone, format!("{text} {security}"), fields), - None => ("lock", Tone::Info, security.to_string(), false), + None => (IconId::new("lock"), Tone::Info, security.to_string(), false), }) } else if form.is_some() { form } else if repaired { - Some(("bandage", Tone::Info, tl!("This file was damaged and has been repaired. Saving keeps the repaired version.").to_string(), false)) + Some(( + IconId::new("bandage"), + Tone::Info, + tl!("This file was damaged and has been repaired. Saving keeps the repaired version.").to_string(), + false, + )) } else if !info.warnings.is_empty() { - Some(("triangle-alert", Tone::Warn, info.warnings[0].clone(), false)) + Some((IconId::new("triangle-alert"), Tone::Warn, info.warnings[0].clone(), false)) } else { None }; @@ -274,7 +280,7 @@ fn cut_pages_bar(view: &mut DocView, ui: &mut egui::Ui) { &[("n", &n.to_string()), ("page", &page)], ) }; - if bar(Tone::Warn, "triangle-alert", text).dismiss().show(ui).dismissed { + if bar(Tone::Warn, IconId::new("triangle-alert"), text).dismiss().show(ui).dismissed { view.cut_notice_dismissed.extend(cut); } } diff --git a/crates/ui-egui/src/canvas/organize.rs b/crates/ui-egui/src/canvas/organize.rs index dc9b028a06..0a44b205ae 100644 --- a/crates/ui-egui/src/canvas/organize.rs +++ b/crates/ui-egui/src/canvas/organize.rs @@ -172,8 +172,8 @@ pub(super) fn organize_grid(view: &mut DocView, doc: &pdfcraft_engine::Document, }) .show(cx.ui, |ui, _| { Text::new(label.clone()).show(ui); - earlier = IconButton::new(IconId::new("chevron-left")).label(tl!("Move earlier")).enabled(editable && first > 0).show(ui).clicked(); - later = IconButton::new(IconId::new("chevron-right")).label(tl!("Move later")).enabled(editable && last + 1 < n).show(ui).clicked(); + earlier = IconButton::new(IconId::new("chevron_left")).label(tl!("Move earlier")).enabled(editable && first > 0).show(ui).clicked(); + later = IconButton::new(IconId::new("chevron_right")).label(tl!("Move later")).enabled(editable && last + 1 < n).show(ui).clicked(); }); if earlier { view.session.pending_edit = Some(Edit::MovePages { pages: targets.clone(), to: first - 1 }); diff --git a/crates/ui-egui/src/commands/catalog.rs b/crates/ui-egui/src/commands/catalog.rs index c5ed634311..fa8aecde64 100644 --- a/crates/ui-egui/src/commands/catalog.rs +++ b/crates/ui-egui/src/commands/catalog.rs @@ -21,11 +21,11 @@ use craft::theme::ModeChoice; const CATALOG_ONLY: &[(&str, &str, &str)] = &[ ("app.theme", "Switch theme", "moon"), ("home.unpin_tool", "Unpin tool", "pin-off"), - ("form.calculation_order.back", "Back to Prepare a form", "chevron-left"), + ("form.calculation_order.back", "Back to Prepare a form", "chevron_left"), // Labels distinct from the Combine grid's Expand and Collapse, which can show beside them. - ("tools.expand", "Expand all tools", "maximize-2"), + ("tools.expand", "Expand all tools", "maximize_2"), ("tools.collapse", "Collapse all tools", "minimize-2"), - ("tools.all", "Back to all tools", "layout-grid"), + ("tools.all", "Back to all tools", "layout_grid"), // The rail's button names the side it moves the rail to. ("view.rail.left", "Dock navigation rail on Left", "panel-left"), ("view.rail.right", "Dock navigation rail on Right", "panel-right"), @@ -33,7 +33,7 @@ const CATALOG_ONLY: &[(&str, &str, &str)] = &[ ("bookmark.paste", "Paste bookmarks", "clipboard-paste"), ("bookmark.expand_all", "Expand all bookmarks", "chevrons-down"), ("bookmark.collapse_all", "Collapse all bookmarks", "chevrons-up"), - ("bookmark.expand_level", "Expand top-level bookmarks", "chevron-down"), + ("bookmark.expand_level", "Expand top-level bookmarks", "chevron_down"), ("layers.reset_visibility", "Reset to Initial Visibility", "layers"), (PANEL, "Side panel", "panel-right"), (DOCUMENT, "Switch to document", "file"), diff --git a/crates/ui-egui/src/dialogs/prompts.rs b/crates/ui-egui/src/dialogs/prompts.rs index 7650a19e5f..4f5534880b 100644 --- a/crates/ui-egui/src/dialogs/prompts.rs +++ b/crates/ui-egui/src/dialogs/prompts.rs @@ -90,7 +90,7 @@ impl PdfCraftApp { }; let mut prompt = StandardPrompt::custom(crate::i18n::fmt(template, &[("who", tl!(pending.origin.noun()))])) .title(title) - .icon(IconId::new("external-link")) + .icon(IconId::new("open")) .button(PromptChoice::Proceed, open) .button(PromptChoice::Cancel, tl!("Cancel")) .default_choice(PromptChoice::Cancel) diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 4519f2eeef..c35acbd4aa 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -28,6 +28,8 @@ const ICONS: &[(&str, &[u8])] = &[ icon!("braces"), icon!("camera"), icon!("check-circle-2"), + icon!("chevrons-down"), + icon!("chevrons-up"), icon!("circle-check"), icon!("circle-help"), icon!("circle-x"), @@ -83,6 +85,7 @@ const ICONS: &[(&str, &[u8])] = &[ icon!("panel-right"), icon!("paperclip"), icon!("pen-line"), + icon!("pin-off"), icon!("presentation"), icon!("printer"), icon!("replace"), @@ -123,6 +126,7 @@ mod tests { use craft::behavior::IconId; use craft::ui::primitives::{has_icon, icon_names}; use pdfcraft_engine::{catalog, commands, links}; + use std::borrow::Cow; /// Every icon string the engine carries: groups, items, commands and links. fn engine_icons() -> Vec<(String, &'static str)> { @@ -144,12 +148,49 @@ mod tests { names } - /// A name neither the catalogue nor the app set has draws nothing, silently. + /// The icon of every command in the app's catalog, which menus and command bars draw beside the command: the + /// engine's commands and the UI's own. + fn command_icons() -> Vec<(String, Cow<'static, str>)> { + let catalog = crate::commands::catalog::catalog(false).expect("the command catalog builds"); + catalog.defs().iter().filter_map(|def| Some((format!("command {}", def.command.id), def.icon.clone()?))).collect() + } + + /// Every `IconId::new("…")` literal in the UI source outside inline test modules, with its file. A name that + /// reaches `IconId::new` in a variable isn't seen. + fn literal_icons() -> Vec<(String, Cow<'static, str>)> { + let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); + let mut stack = vec![root.clone()]; + let mut names = Vec::new(); + while let Some(dir) = stack.pop() { + for entry in std::fs::read_dir(dir).expect("UI source directory") { + let path = entry.expect("UI source entry").path(); + if path.is_dir() { + stack.push(path); + } else if path.extension().is_some_and(|ext| ext == "rs") { + let source = std::fs::read_to_string(&path).expect("UI source file").replace("\r\n", "\n"); + let code = source.split("#[cfg(test)]\nmod ").next().unwrap_or_default(); + let file = path.strip_prefix(&root).unwrap_or(&path).display().to_string(); + for call in code.split("IconId::new(").skip(1) { + if let Some((name, _)) = call.trim_start().strip_prefix('"').and_then(|rest| rest.split_once('"')) { + names.push((file.clone(), Cow::Owned(name.to_owned()))); + } + } + } + } + } + names + } + + /// A name neither the catalogue nor the app set has draws nothing, silently. The catalogue names its icons by + /// meaning (`chevron_down`), not by the file a set draws for them (`chevron-down`). #[test] fn every_icon_the_app_names_resolves() { register(); + let literals = literal_icons(); + assert!(!literals.is_empty(), "the UI source names icons with IconId::new"); + let named = engine_icons().into_iter().map(|(owner, name)| (owner, Cow::Borrowed(name))).chain(command_icons()).chain(literals); let missing: Vec = - engine_icons().into_iter().filter(|(_, name)| !has_icon(&IconId::new(name))).map(|(owner, name)| format!("{owner}: {name}")).collect(); + named.filter(|(_, name)| !has_icon(&IconId::from(name.clone()))).map(|(owner, name)| format!("{owner}: {name}")).collect(); assert!(missing.is_empty(), "icons nobody has: {missing:?}"); assert!(has_icon(&IconId::new(crate::chrome::HOME_ICON)), "the title bar Home icon resolves"); for name in ["circle-check", "circle-x", "triangle-alert"] { diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index 0ff879eaf4..41eb986e1b 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -39,7 +39,7 @@ pub(super) fn edit_panel(app: &mut PdfCraftApp, ui: &mut egui::Ui, g: &'static T let title = if from_all_tools { tl!(g.label) } else { tl!("Edit") }.to_string(); let mut commands = Vec::new(); if from_all_tools { - commands.push(HeaderCommand::new(IconId::new("chevron-left"), "tools.all")); + commands.push(HeaderCommand::new(IconId::new("chevron_left"), "tools.all")); } commands.push(HeaderCommand::new(IconId::new("settings"), "app.preferences")); let shown = Panel::new(title).titled().commands(commands).actions([HeaderAction::Close]).show(ui, |ui, _| { diff --git a/crates/ui-egui/src/panels/fields.rs b/crates/ui-egui/src/panels/fields.rs index 194eaf69a9..d6f2351ac9 100644 --- a/crates/ui-egui/src/panels/fields.rs +++ b/crates/ui-egui/src/panels/fields.rs @@ -97,15 +97,15 @@ fn heading(info: &DocInfo, page: Option) -> String { } /// The icon a field kind shows. -fn kind_icon(kind: &FieldKind) -> &'static str { +fn kind_icon(kind: &FieldKind) -> IconId { match kind { - FieldKind::Text => "text-cursor-input", - FieldKind::CheckBox => "check-circle-2", - FieldKind::Radio => "circle", - FieldKind::PushButton | FieldKind::Unknown => "square", - FieldKind::Combo => "chevron-down", - FieldKind::List => "list", - FieldKind::Signature => "signature", + FieldKind::Text => IconId::new("text-cursor-input"), + FieldKind::CheckBox => IconId::new("check-circle-2"), + FieldKind::Radio => IconId::new("circle"), + FieldKind::PushButton | FieldKind::Unknown => IconId::new("square"), + FieldKind::Combo => IconId::new("chevron_down"), + FieldKind::List => IconId::new("list"), + FieldKind::Signature => IconId::new("signature"), } } @@ -169,7 +169,7 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult { let page = if let FieldRow::Page(p) = &row.key { *p } else { None }; return ListRow::new(heading(info, page)).section_heading(); }; - let mut list_row = ListRow::new(field.name.clone()).icon(IconSpec::svg(IconId::new(kind_icon(&field.kind)))).tooltip(field_tip(field)); + let mut list_row = ListRow::new(field.name.clone()).icon(IconSpec::svg(kind_icon(&field.kind))).tooltip(field_tip(field)); if let Some(value) = &field.value { list_row = list_row.optional(value.clone()); } @@ -177,8 +177,8 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult { // Each arrow names the field it moves. let named = |tip: &str| format!("{}: {}", tl!(tip), field.name); list_row = list_row - .trailing_part(EARLIER, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron-up"))), named("Earlier in tab order")) - .trailing_part(LATER, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron-down"))), named("Later in tab order")); + .trailing_part(EARLIER, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron_up"))), named("Earlier in tab order")) + .trailing_part(LATER, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron_down"))), named("Later in tab order")); } list_row }, diff --git a/crates/ui-egui/src/panels/organize_panel.rs b/crates/ui-egui/src/panels/organize_panel.rs index b3cbbfbb9c..bc4c0693d8 100644 --- a/crates/ui-egui/src/panels/organize_panel.rs +++ b/crates/ui-egui/src/panels/organize_panel.rs @@ -108,13 +108,13 @@ pub(crate) fn panel(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let can_delete = editable && targets.len() < n; Row::new().show(ui, |ui, _| { let buttons = [ - ("rotate-ccw", "Rotate counterclockwise", editable), - ("rotate-cw", "Rotate clockwise", editable), - ("trash-2", "Delete pages (Delete)", can_delete), - ("file-output", "Extract pages to a new document", editable), + (IconId::new("rotate_ccw"), "Rotate counterclockwise", editable), + (IconId::new("rotate_cw"), "Rotate clockwise", editable), + (IconId::new("trash-2"), "Delete pages (Delete)", can_delete), + (IconId::new("file-output"), "Extract pages to a new document", editable), ]; for (at, (icon, label, enabled)) in buttons.into_iter().enumerate() { - if !IconButton::new(IconId::new(icon)).label(tl!(label).to_owned()).enabled(enabled).show(ui).clicked() { + if !IconButton::new(icon).label(tl!(label).to_owned()).enabled(enabled).show(ui).clicked() { continue; } act = Some(match at { diff --git a/crates/ui-egui/src/panels/side_panels.rs b/crates/ui-egui/src/panels/side_panels.rs index c3d93485ec..cac75fe563 100644 --- a/crates/ui-egui/src/panels/side_panels.rs +++ b/crates/ui-egui/src/panels/side_panels.rs @@ -492,10 +492,10 @@ impl DockPanels for Panels<'_> { if self.app.left == LeftPanel::CalculationOrder { crate::calc_order_ui::header(ui); } else if crate::organize_panel::showing(self.app) { - IconButton::command(IconSpec::svg(IconId::new("chevron-left")), CommandRef::new("tools.all")).show(ui); + IconButton::command(IconSpec::svg(IconId::new("chevron_left")), CommandRef::new("tools.all")).show(ui); IconButton::command(IconSpec::svg(IconId::new("close")), CommandRef::new("page.organize")).label(tl!("Close panel")).show(ui); } else if self.app.left == LeftPanel::AllTools { - IconButton::command(IconSpec::svg(IconId::new("maximize-2")), CommandRef::new("tools.expand")).show(ui); + IconButton::command(IconSpec::svg(IconId::new("maximize_2")), CommandRef::new("tools.expand")).show(ui); } } PanelId::Bookmarks => super::bookmarks::header(self.app, ui), diff --git a/crates/ui-egui/src/tools/calc_order_ui.rs b/crates/ui-egui/src/tools/calc_order_ui.rs index 4462d86152..994db6cdb7 100644 --- a/crates/ui-egui/src/tools/calc_order_ui.rs +++ b/crates/ui-egui/src/tools/calc_order_ui.rs @@ -573,10 +573,10 @@ fn order_row<'a>(k: usize, count: usize, f: &CalculatedField, row: &Row, editabl // Each arrow names the field it moves. let named = |tip: &str| format!("{}: {}", tl!(tip), f.name); if k > 0 { - r = r.trailing_part_revealed(UP, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron-up"))), named("Earlier in calculation order")); + r = r.trailing_part_revealed(UP, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron_up"))), named("Earlier in calculation order")); } if k + 1 < count { - r = r.trailing_part_revealed(DOWN, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron-down"))), named("Later in calculation order")); + r = r.trailing_part_revealed(DOWN, TrailingFace::Icon(IconSpec::svg(IconId::new("chevron_down"))), named("Later in calculation order")); } } r @@ -585,7 +585,7 @@ fn order_row<'a>(k: usize, count: usize, f: &CalculatedField, row: &Row, editabl /// The panel's title row: Back to Prepare a form. Returns the command to run when it was pressed. pub(crate) fn header(ui: &mut egui::Ui) -> Option<&'static str> { // A command-bound button fires its command itself; the return also lets the caller run it. - let button = IconButton::command(IconSpec::svg(IconId::new("chevron-left")), BACK).show(ui); + let button = IconButton::command(IconSpec::svg(IconId::new("chevron_left")), BACK).show(ui); button.response().clicked().then_some(BACK) } diff --git a/crates/ui-egui/src/tools/content_ui.rs b/crates/ui-egui/src/tools/content_ui.rs index 03baa95744..31f088d591 100644 --- a/crates/ui-egui/src/tools/content_ui.rs +++ b/crates/ui-egui/src/tools/content_ui.rs @@ -1638,25 +1638,24 @@ pub(crate) fn image_panel(ui: &mut egui::Ui, img: &pdfcraft_engine::AddedImage) let (cx, cy, w, h) = ((r[0] + r[2]) / 2.0, (r[1] + r[3]) / 2.0, r[2] - r[0], r[3] - r[1]); i.rect = [cx - h / 2.0, cy - w / 2.0, cx + h / 2.0, cy + w / 2.0]; }; - let button = - |ui: &mut egui::Ui, icon: &'static str, label: &str| IconButton::new(IconId::new(icon)).label(label.to_string()).show(ui).clicks > 0; - if button(ui, "rotate-ccw", tl!("Rotate counterclockwise")) { + let button = |ui: &mut egui::Ui, icon: IconId, label: &str| IconButton::new(icon).label(label.to_string()).show(ui).clicks > 0; + if button(ui, IconId::new("rotate_ccw"), tl!("Rotate counterclockwise")) { turn(&mut i, 1); out = Some(ImageAction::Update(AddedContent::Image(i.clone()))); } - if button(ui, "rotate-cw", tl!("Rotate clockwise")) { + if button(ui, IconId::new("rotate_cw"), tl!("Rotate clockwise")) { turn(&mut i, 3); out = Some(ImageAction::Update(AddedContent::Image(i.clone()))); } - if button(ui, FLIP_HORIZONTAL_ICON, tl!("Flip horizontal")) { + if button(ui, IconId::new(FLIP_HORIZONTAL_ICON), tl!("Flip horizontal")) { i.flip_h = !i.flip_h; out = Some(ImageAction::Update(AddedContent::Image(i.clone()))); } - if button(ui, FLIP_VERTICAL_ICON, tl!("Flip vertical")) { + if button(ui, IconId::new(FLIP_VERTICAL_ICON), tl!("Flip vertical")) { i.flip_v = !i.flip_v; out = Some(ImageAction::Update(AddedContent::Image(i.clone()))); } - if button(ui, "replace", tl!("Replace image")) { + if button(ui, IconId::new("replace"), tl!("Replace image")) { out = Some(ImageAction::Replace); } }); diff --git a/crates/ui-egui/src/tools/edit_text_ui/image.rs b/crates/ui-egui/src/tools/edit_text_ui/image.rs index e73c9ddae8..8928e6beef 100644 --- a/crates/ui-egui/src/tools/edit_text_ui/image.rs +++ b/crates/ui-egui/src/tools/edit_text_ui/image.rs @@ -745,13 +745,13 @@ pub(crate) fn picture_menu(ui: &mut egui::Ui, session: &mut PageSession, menu: & Ccw, Cw, } - let mut picks = vec![(Pick::Note, "message-square", tl!("Add a sticky note here"))]; + let mut picks = vec![(Pick::Note, IconId::new("note"), tl!("Add a sticky note here"))]; if raster { - picks.push((Pick::Crop, "crop", tl!("Crop"))); + picks.push((Pick::Crop, IconId::new("crop"), tl!("Crop"))); } - picks.push((Pick::Ccw, "rotate-ccw", tl!("Rotate Counterclockwise"))); - picks.push((Pick::Cw, "rotate-cw", tl!("Rotate Clockwise"))); - let icons: Vec> = picks.iter().map(|(_, name, label)| MenuIcon::new(IconId::new(name), *label)).collect(); + picks.push((Pick::Ccw, IconId::new("rotate_ccw"), tl!("Rotate Counterclockwise"))); + picks.push((Pick::Cw, IconId::new("rotate_cw"), tl!("Rotate Clockwise"))); + let icons: Vec> = picks.iter().map(|(_, icon, label)| MenuIcon::new(icon.clone(), *label)).collect(); if let Some(picked) = MenuIconRow::new(tl!("Picture"), &icons).show(ui).picked.and_then(|i| picks.get(i)) { match picked.0 { Pick::Note => action = Some(ImageAction::AddComment(page, hit)), diff --git a/crates/ui-egui/src/tools/fill_sign/scan.rs b/crates/ui-egui/src/tools/fill_sign/scan.rs index 3beb5981b5..82dfee165c 100644 --- a/crates/ui-egui/src/tools/fill_sign/scan.rs +++ b/crates/ui-egui/src/tools/fill_sign/scan.rs @@ -290,10 +290,10 @@ impl ScanTabState { Row::new().show(ui, |ui, _| { choose = clicked(&Button::new(tl!("Choose photo…")).icon(craft::behavior::IconId::new("camera")).show(ui)); if self.scan.is_some() { - if clicked(&IconButton::new(craft::behavior::IconId::new("rotate-ccw")).label(tl!("Rotate counterclockwise")).show(ui)) { + if clicked(&IconButton::new(craft::behavior::IconId::new("rotate_ccw")).label(tl!("Rotate counterclockwise")).show(ui)) { turn = Some(Turn::CounterClockwise); } - if clicked(&IconButton::new(craft::behavior::IconId::new("rotate-cw")).label(tl!("Rotate clockwise")).show(ui)) { + if clicked(&IconButton::new(craft::behavior::IconId::new("rotate_cw")).label(tl!("Rotate clockwise")).show(ui)) { turn = Some(Turn::Clockwise); } } diff --git a/crates/ui-egui/src/workflows/a11y_ui.rs b/crates/ui-egui/src/workflows/a11y_ui.rs index 92205e93fa..9b2965a310 100644 --- a/crates/ui-egui/src/workflows/a11y_ui.rs +++ b/crates/ui-egui/src/workflows/a11y_ui.rs @@ -209,12 +209,12 @@ pub(crate) fn pass(ctx: &egui::Context, app: &mut PdfCraftApp) { } /// The icon and tone of a rule's status. -fn status_icon(s: Status) -> (&'static str, Tone) { +fn status_icon(s: Status) -> (IconId, Tone) { match s { - Status::Passed => ("circle-check", Tone::Good), - Status::Failed => ("circle-x", Tone::Bad), - Status::Manual => ("circle-help", Tone::Warn), - Status::Skipped => ("circle-dashed", Tone::Neutral), + Status::Passed => (IconId::new("circle-check"), Tone::Good), + Status::Failed => (IconId::new("circle-x"), Tone::Bad), + Status::Manual => (IconId::new("circle-help"), Tone::Warn), + Status::Skipped => (IconId::new("ellipse_dashed"), Tone::Neutral), } } @@ -415,7 +415,7 @@ pub(crate) fn panel(ui: &mut Ui, state: &mut A11yState, doc: DocId) -> Option row, LineKind::Rule { rule, status } => { let (icon, tone) = status_icon(*status); - let row = row.icon(IconSpec::svg(IconId::new(icon))).tone(tone); + let row = row.icon(IconSpec::svg(icon)).tone(tone); let row = if *status == Status::Skipped { row.ink(RowInk::Muted) } else { row }; if explained == Some(*rule) { row.below(Text::new(tl!(rule.explanation())).shade(Shade::Muted), |_| {}) } else { row } } @@ -782,8 +782,8 @@ impl StackDialog for AltTextDialog { if let Some(on) = alt.decorative.same() { *decorative = *on; } - let back = IconButton::new(IconSpec::svg(IconId::new("chevron-left"))).label(tl!("Previous figure")).enabled(i > 0).show(ui); - let next = IconButton::new(IconSpec::svg(IconId::new("chevron-right"))).label(tl!("Next figure")).enabled(i + 1 < n).show(ui); + let back = IconButton::new(IconSpec::svg(IconId::new("chevron_left"))).label(tl!("Previous figure")).enabled(i > 0).show(ui); + let next = IconButton::new(IconSpec::svg(IconId::new("chevron_right"))).label(tl!("Next figure")).enabled(i + 1 < n).show(ui); if back.response().clicked() { value.index = i.saturating_sub(1); } diff --git a/crates/ui-egui/src/workflows/combine_grid.rs b/crates/ui-egui/src/workflows/combine_grid.rs index 351fb59a48..5f08ddd4c0 100644 --- a/crates/ui-egui/src/workflows/combine_grid.rs +++ b/crates/ui-egui/src/workflows/combine_grid.rs @@ -286,7 +286,7 @@ pub(crate) fn grid(app: &mut PdfCraftApp, ui: &mut egui::Ui, checks: &[Result false, }; if locked { - entries.push(Entry::new(TileRow::Unlock, tl!("Unlock…")).icon(IconId::new("lock-open"))); + entries.push(Entry::new(TileRow::Unlock, tl!("Unlock…")).icon(IconId::new("lock_open"))); } match Menu::context(tl!("File"), &shown.response.response).pick(ui, &entries).picked { Some(TileRow::Act(act)) => actions.push(act_action(act, key)), diff --git a/crates/ui-egui/src/workflows/combine_ui/table.rs b/crates/ui-egui/src/workflows/combine_ui/table.rs index c1bd899f9d..c55b79961d 100644 --- a/crates/ui-egui/src/workflows/combine_ui/table.rs +++ b/crates/ui-egui/src/workflows/combine_ui/table.rs @@ -289,7 +289,7 @@ pub(super) fn table(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> Option None, }); if let Some(id) = locked { - let entries = [Entry::new(id, tl!("Unlock…")).icon(IconId::new("lock-open"))]; + let entries = [Entry::new(id, tl!("Unlock…")).icon(IconId::new("lock_open"))]; if let Some(id) = Menu::context(tl!("File"), &out.response).pick(ui, &entries).picked { action = Some(RowAction::Unlock(Some(id))); } diff --git a/crates/ui-egui/src/workflows/combine_ui/view.rs b/crates/ui-egui/src/workflows/combine_ui/view.rs index cee8262fbf..e07a435e2b 100644 --- a/crates/ui-egui/src/workflows/combine_ui/view.rs +++ b/crates/ui-egui/src/workflows/combine_ui/view.rs @@ -106,23 +106,23 @@ pub(crate) fn page(app: &mut PdfCraftApp, ui: &mut egui::Ui) { (_, 0) => tl!("Remove").to_string(), (_, k) => crate::i18n::fmt(tl!("Remove {n} files"), &[("n", &k.to_string())]), }; - if IconButton::new(IconId::new("chevron-up")).label(tl!("Move up")).enabled(can_up).show(ui).clicked() { + if IconButton::new(IconId::new("chevron_up")).label(tl!("Move up")).enabled(can_up).show(ui).clicked() { action = Some(RowAction::MoveUp); } - if IconButton::new(IconId::new("chevron-down")).label(tl!("Move down")).enabled(can_down).show(ui).clicked() { + if IconButton::new(IconId::new("chevron_down")).label(tl!("Move down")).enabled(can_down).show(ui).clicked() { action = Some(RowAction::MoveDown); } if IconButton::new(IconId::new("trash-2")).label(remove).enabled(count > 0 || pages_picked > 0).show(ui).clicked() { action = Some(RowAction::Remove); } let locked = app.combine_draft.iter().zip(&selected).any(|(f, s)| *s && f.lock.is_some()); - if Button::new(tl!("Unlock…")).icon(IconId::new("lock-open")).enabled(locked).show(ui).clicked() { + if Button::new(tl!("Unlock…")).icon(IconId::new("lock_open")).enabled(locked).show(ui).clicked() { action = Some(RowAction::Unlock(None)); } - IconButton::command(IconId::new("undo-2"), "edit.undo").enabled(app.combine_can_undo(true)).show(ui); - IconButton::command(IconId::new("redo-2"), "edit.redo").enabled(app.combine_can_undo(false)).show(ui); + IconButton::command(IconId::new("undo"), "edit.undo").enabled(app.combine_can_undo(true)).show(ui); + IconButton::command(IconId::new("redo"), "edit.redo").enabled(app.combine_can_undo(false)).show(ui); let views = [ - Entry::new(CombineView::Grid, tl!("Grid view")).icon(IconId::new("layout-grid")), + Entry::new(CombineView::Grid, tl!("Grid view")).icon(IconId::new("layout_grid")), Entry::new(CombineView::List, tl!("List view")).icon(IconId::new("list")), ]; Segmented::new(tl!("View"), Bind::bound(&mut app.combine_view), &views).show(ui); @@ -132,7 +132,7 @@ pub(crate) fn page(app: &mut PdfCraftApp, ui: &mut egui::Ui) { if grid && n > 0 { // Every file as its pages, or all as cards again. let can_expand = app.combine_draft.iter_mut().any(|f| !app.combine_tab.expanded.contains(&f.id) && expandable(f)); - if IconButton::new(IconId::new("maximize-2")).label(tl!("Expand all")).enabled(can_expand).show(ui).clicked() { + if IconButton::new(IconId::new("maximize_2")).label(tl!("Expand all")).enabled(can_expand).show(ui).clicked() { action = Some(RowAction::ExpandAll(true)); } let can_collapse = !app.combine_tab.expanded.is_empty(); @@ -223,9 +223,9 @@ pub(crate) fn page(app: &mut PdfCraftApp, ui: &mut egui::Ui) { #[cfg(not(target_arch = "wasm32"))] fn add_files(app: &mut PdfCraftApp, ui: &mut egui::Ui) { let entries = [ - Entry::new(AddHow::Files, tl!("Add files…")).icon(IconId::new("file-plus")), + Entry::new(AddHow::Files, tl!("Add files…")).icon(IconId::new("new_file")), Entry::new(AddHow::Folder, tl!("Add folder…")).icon(IconId::new("folder")), - Entry::new(AddHow::Subfolders, tl!("Add folder and subfolders…")).icon(IconId::new("folder-open")), + Entry::new(AddHow::Subfolders, tl!("Add folder and subfolders…")).icon(IconId::new("folder_open")), ]; let out = SplitButton::new(tl!("Add files…"), &entries).arrow_label(tl!("More ways to add files")).icon(IconId::new("plus")).show(ui); if out.response.clicked() { @@ -254,7 +254,7 @@ fn add_open_documents(app: &mut PdfCraftApp, ui: &mut egui::Ui) { // `None` is every open document. let mut entries: Vec>> = vec![Entry::new(None, tl!("All open documents"))]; entries.extend(open.iter().map(|(i, name)| Entry::new(Some(*i), name.clone()))); - let opener = Button::new(tl!("Add open documents")).icon(IconId::new("file-plus")).enabled(!open.is_empty()).show(ui); + let opener = Button::new(tl!("Add open documents")).icon(IconId::new("new_file")).enabled(!open.is_empty()).show(ui); let picked = Menu::new(tl!("Add open documents")).opened_by(&opener, Trigger::Click).pick(ui, &entries).picked; match picked { Some(Some(i)) => app.add_open_documents(&[i]),