From 10f7206bbe3b8a1115445e39a345708ccde11753 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 00:26:27 -0800 Subject: [PATCH] Attributes: Panel Options sets how many recent URLs the URL menu lists The Attributes panel menu gets Panel Options..., whose dialog sets how many of the recent URLs the URL menu lists, a whole number from 1 to 30 (10 by default). ui.attributesPanelOptions {count} sets it without the dialog; a count out of range is an error and changes nothing. The count is kept with the UI state. The recent URL list now keeps the 30 newest distinct URLs of the session, so a lower count hides older URLs without removing them. --- crates/engine/src/cmd.rs | 3 +- crates/engine/src/cmd/attributes.rs | 7 +- crates/engine/src/cmd/overprint.rs | 2 +- crates/engine/src/lib.rs | 3 +- crates/engine/src/tests/attributes.rs | 17 +++ crates/mcp/src/ui_catalog.rs | 6 + crates/ui-egui/src/dialogs.rs | 2 + .../src/dialogs/attributes_panel_options.rs | 82 ++++++++++++++ crates/ui-egui/src/i18n/bg.tsv | 3 + crates/ui-egui/src/i18n/bs.tsv | 3 + crates/ui-egui/src/i18n/ca.tsv | 3 + crates/ui-egui/src/i18n/cs.tsv | 3 + crates/ui-egui/src/i18n/da.tsv | 3 + crates/ui-egui/src/i18n/de.tsv | 3 + crates/ui-egui/src/i18n/el.tsv | 3 + crates/ui-egui/src/i18n/es.tsv | 3 + crates/ui-egui/src/i18n/fi.tsv | 3 + crates/ui-egui/src/i18n/fr.tsv | 3 + crates/ui-egui/src/i18n/gu.tsv | 3 + crates/ui-egui/src/i18n/hi.tsv | 3 + crates/ui-egui/src/i18n/hu.tsv | 3 + crates/ui-egui/src/i18n/id.tsv | 3 + crates/ui-egui/src/i18n/it.tsv | 3 + crates/ui-egui/src/i18n/ja.tsv | 3 + crates/ui-egui/src/i18n/ka.tsv | 3 + crates/ui-egui/src/i18n/ko.tsv | 3 + crates/ui-egui/src/i18n/nl.tsv | 3 + crates/ui-egui/src/i18n/pl.tsv | 3 + crates/ui-egui/src/i18n/pt-br.tsv | 3 + crates/ui-egui/src/i18n/ru.tsv | 3 + crates/ui-egui/src/i18n/sv.tsv | 3 + crates/ui-egui/src/i18n/tests.rs | 16 +++ crates/ui-egui/src/i18n/tr.tsv | 3 + crates/ui-egui/src/i18n/uk.tsv | 3 + crates/ui-egui/src/i18n/vi.tsv | 3 + crates/ui-egui/src/i18n/zh-hans.tsv | 3 + crates/ui-egui/src/i18n/zh-hant.tsv | 3 + crates/ui-egui/src/menus/run.rs | 1 + crates/ui-egui/src/menus/ui_commands.rs | 6 + crates/ui-egui/src/panels/attributes.rs | 107 +++++++++++++++++- crates/ui-egui/src/state.rs | 4 + docs/mcp.md | 9 ++ docs/target-app-parity.md | 1 + 43 files changed, 339 insertions(+), 11 deletions(-) create mode 100644 crates/ui-egui/src/dialogs/attributes_panel_options.rs diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index e2bc50cdc5..b8ceae3116 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -862,7 +862,8 @@ pub use compoundshape::selected_member_modes; /// Pathfinder Options (`Prefs::pathfinder`). pub use pathops::{PATHFINDER_PRECISION_RANGE, PathfinderOptions}; -/// The Attributes panel's state ([`Session::attributes_info`]). +/// The Attributes panel's state ([`Session::attributes_info`]) and how many recent URLs it keeps. +pub use attributes::RECENT_URLS; pub use overprint::AttributesInfo; /// Object → Flatten Transparency settings (`object.flattenTransparency`). diff --git a/crates/engine/src/cmd/attributes.rs b/crates/engine/src/cmd/attributes.rs index 684d33a53d..b257a978db 100644 --- a/crates/engine/src/cmd/attributes.rs +++ b/crates/engine/src/cmd/attributes.rs @@ -12,8 +12,9 @@ use super::overprint::{AttributesInfo, apply_overprint, edit_counted, overprint_ use super::path::paths_in; use super::{CommandSpec, NodeId, Result, Session, bad, cmd, has_doc, str_param, targets}; -/// How many URLs the Attributes panel's recent list keeps. -const RECENT_URLS: usize = 10; +/// How many URLs the Attributes panel's recent list keeps: the most its Panel Options lets the +/// URL menu list. +pub const RECENT_URLS: usize = 30; pub fn specs() -> Vec { vec![ @@ -22,7 +23,7 @@ pub fn specs() -> Vec { "Attributes", [], None, - "{overprintFill?: bool, overprintStroke?: bool (aimed as object.setOverprint's fill and stroke, item? too), showCenter?: bool (the canvas shows the selected object's centre point), imageMap?: \"none\"|\"rectangle\"|\"polygon\", url?: string (\"\" removes it; SVG, PDF and .ai export link the object), note?: string, ids?|id?, item?: appearance item index|null, target?: \"object\"|\"contents\"} set the Attributes panel's values on ids or the selection, as one undo step; a URL given joins the recent URLs (attributes.info) → {changed: objects}", + "{overprintFill?: bool, overprintStroke?: bool (aimed as object.setOverprint's fill and stroke, item? too), showCenter?: bool (the canvas shows the selected object's centre point), imageMap?: \"none\"|\"rectangle\"|\"polygon\", url?: string (\"\" removes it; SVG, PDF and .ai export link the object), note?: string, ids?|id?, item?: appearance item index|null, target?: \"object\"|\"contents\"} set the Attributes panel's values on ids or the selection, as one undo step; a URL given joins the recent URLs (attributes.info, newest first, at most 30) → {changed: objects}", has_doc, set ), diff --git a/crates/engine/src/cmd/overprint.rs b/crates/engine/src/cmd/overprint.rs index e8957691ec..7435f04a3a 100644 --- a/crates/engine/src/cmd/overprint.rs +++ b/crates/engine/src/cmd/overprint.rs @@ -30,7 +30,7 @@ pub fn specs() -> Vec { "Attributes", [], None, - "{ids?|id?, item?, target?: \"object\"|\"contents\"} → {ids, overprintFill, overprintStroke, showCenter, imageMap: \"none\"|\"rectangle\"|\"polygon\", url, note, fillRule: \"nonZero\"|\"evenOdd\" (of the paths and compound paths in them), reversed (their subpaths run counter-clockwise on screen: Reverse Path Direction On), recentUrls: [newest first]} the Attributes panel's values for `ids` or the selection, overprint aimed as object.setOverprint aims; a value is null where they differ (or nothing has a fill, stroke or path)", + "{ids?|id?, item?, target?: \"object\"|\"contents\"} → {ids, overprintFill, overprintStroke, showCenter, imageMap: \"none\"|\"rectangle\"|\"polygon\", url, note, fillRule: \"nonZero\"|\"evenOdd\" (of the paths and compound paths in them), reversed (their subpaths run counter-clockwise on screen: Reverse Path Direction On), recentUrls: [newest first, at most 30]} the Attributes panel's values for `ids` or the selection, overprint aimed as object.setOverprint aims; a value is null where they differ (or nothing has a fill, stroke or path)", has_doc, |s, p| Ok(attributes(s, p)?.to_json()) ), diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 4f7532108d..eb339b8cda 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -194,7 +194,8 @@ pub struct Session { /// `plugin.install` takes `grant` and `allowHeavy` from any request /// ([`Session::allow_plugin_grants_from_requests`]). plugin_grants_from_requests: bool, - /// URLs recently given in the Attributes panel (`attributes.set {url}`), newest first; not saved. + /// URLs recently given in the Attributes panel (`attributes.set {url}`), newest first, at most + /// [`cmd::RECENT_URLS`]; not saved. pub recent_urls: Vec, /// The saved tracing presets' revision and latest changes ([`Session::trace_presets_revision`]). pub(crate) trace_preset_changes: cmd::TracePresetChanges, diff --git a/crates/engine/src/tests/attributes.rs b/crates/engine/src/tests/attributes.rs index b6d00111e2..35dda8656b 100644 --- a/crates/engine/src/tests/attributes.rs +++ b/crates/engine/src/tests/attributes.rs @@ -90,6 +90,23 @@ fn values_that_differ_read_null_and_recent_urls_keep_the_newest_first() { assert_eq!(info(&mut s, json!({"ids": [p.0, a.0]}))["showCenter"], Value::Null); } +/// The recent URLs keep the 30 newest distinct URLs, the most the panel's URL menu can list, and +/// a URL given again moves to the front without taking a second place. +#[test] +fn recent_urls_keep_the_thirty_newest() { + let mut s = session(); + rect(&mut s, 0.0); + for i in 0..35 { + run(&mut s, "attributes.set", json!({"url": format!("https://example.com/{i}")})); + } + let want: Vec = (5..35).rev().map(|i| format!("https://example.com/{i}")).collect(); + assert_eq!(info(&mut s, json!({}))["recentUrls"], json!(want)); + run(&mut s, "attributes.set", json!({"url": "https://example.com/20"})); + let urls = info(&mut s, json!({}))["recentUrls"].as_array().unwrap().clone(); + assert_eq!((urls.len(), urls[0].as_str(), urls[1].as_str()), (30, Some("https://example.com/20"), Some("https://example.com/34"))); + assert_eq!(urls.iter().filter(|u| *u == "https://example.com/20").count(), 1); +} + /// A five-pointed star drawn as one self-intersecting path (its centre is wound twice). fn star(s: &mut Session) -> NodeId { let (c, r) = (50.0f64, 45.0f64); diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 0e3d6df203..829206e156 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1099,6 +1099,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them)} set the Navigator panel's options, the color its view box is drawn in and solid dashes (kept with the UI state) → {color, solidDashes}; with neither, open its Panel Options (dialog `navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing", ), + ( + "ui.attributesPanelOptions", + "Panel Options…", + "", + "{count?: 1–30 (10 by default)} set how many of the recent URLs (attributes.info › recentUrls, which keeps 30) the Attributes panel's URL menu lists, newest first (kept with the UI state) → {count}; without count, open its Panel Options (dialog `attributesPanelOptions`, field count; OK sets it); an error for a count that is not a whole number from 1 to 30, which changes nothing", + ), ( "ui.layersExpand", "Expand Layers Panel Rows", diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index da1062838f..79cb24cba3 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -15,6 +15,7 @@ pub mod action_select_object; pub mod action_set_options; pub mod action_stop; pub mod artboard_options; +pub mod attributes_panel_options; pub mod blend_options; mod brush_art_options; pub mod brush_delete; @@ -466,6 +467,7 @@ registry! { LayerOptions: [layer_options::KIND] => layer_options::SPEC, LayersPanelOptions: [layers_panel_options::KIND] => layers_panel_options::SPEC, NavigatorPanelOptions: [navigator_panel_options::KIND] => navigator_panel_options::SPEC, + AttributesPanelOptions: [attributes_panel_options::KIND] => attributes_panel_options::SPEC, PathfinderOptions: [pathfinder_options::KIND] => pathfinder_options::SPEC, PixelSnapOptions: [pixel_snap_options::KIND] => pixel_snap_options::SPEC, RearrangeArtboards: [rearrange_artboards::KIND] => rearrange_artboards::SPEC, diff --git a/crates/ui-egui/src/dialogs/attributes_panel_options.rs b/crates/ui-egui/src/dialogs/attributes_panel_options.rs new file mode 100644 index 0000000000..2a5a7356ff --- /dev/null +++ b/crates/ui-egui/src/dialogs/attributes_panel_options.rs @@ -0,0 +1,82 @@ +//! Attributes panel › Panel Options…: how many recent URLs the panel's URL menu lists. +//! +//! Field: `count` (1–30). OK runs `ui.attributesPanelOptions` with it (kept with the UI state). + +use serde_json::{Value, json}; + +use super::DialogSpec; +use super::swatch_options::{grid, label}; +use crate::panels::attributes::DEFAULT_RECENT_URLS; +use crate::state::Dialog; +use crate::{VectorcraftApp, widgets}; + +/// The dialog kind of the Attributes Panel Options. +pub const KIND: &str = "attributesPanelOptions"; + +pub(super) const SPEC: DialogSpec = + DialogSpec { heading: |_| tl!("Attributes Panel Options").into(), body, confirm, min_width: 280.0, ..DialogSpec::FORM }; + +/// `ui.attributesPanelOptions` without options: open the dialog on the panel's options. +pub fn open(app: &mut VectorcraftApp) -> Result { + let count = app.ui.attributes_panel.shown(); + app.ui.dialog = Some(Dialog::new(KIND, json!({ "count": count }))); + Ok(Value::Null) +} + +fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { + grid(ui, |ui| { + label(ui, tl!("Number of Recent URLs:")); + let v = d.f64("count", f64::from(DEFAULT_RECENT_URLS)); + let max = vectorcraft_engine::cmd::RECENT_URLS as f64; + if let Some(v) = widgets::range_field(ui, "attributes-recent-urls", v, 1.0..=max, "", 0, 60.0) { + d.fields.insert("count".into(), json!(v)); + } + ui.end_row(); + }); + false +} + +/// OK: set the count; a count that is refused leaves the dialog open. +fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { + let params = json!({ "count": d.fields.get("count").cloned().unwrap_or(Value::Null) }); + let r = app.run("ui.attributesPanelOptions", params)?; + app.ui.dialog = None; + Ok(r) +} + +#[cfg(test)] +mod tests { + use super::*; + use vectorcraft_engine::Session; + + /// The dialog opens on the panel's count (10 by default), OK sets it, kept with the UI state, + /// and a count out of range is refused, leaving the dialog open and the count as it was. + #[test] + fn panel_options_set_the_recent_url_count() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("ui.attributesPanelOptions", json!({})).unwrap(); + let d = app.ui.dialog.as_ref().unwrap(); + assert_eq!((d.kind.as_str(), d.f64("count", 0.0)), (KIND, 10.0)); + // Drawn headlessly in the shared frame. + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + let mut out = ctx.run_ui(Default::default(), |ui| super::super::show(&mut app, ui.ctx())); + out.textures_delta.clear(); + let set = |app: &mut VectorcraftApp, count: Value| { + app.ui.dialog.as_mut().unwrap().fields.insert("count".into(), count); + super::super::confirm(app) + }; + assert_eq!(set(&mut app, json!(25.0)).unwrap(), json!({"count": 25})); + assert!(app.ui.dialog.is_none()); + assert_eq!(app.ui.attributes_panel.recent_urls, 25); + app.run("ui.attributesPanelOptions", json!({})).unwrap(); + assert_eq!(app.ui.dialog.as_ref().unwrap().f64("count", 0.0), 25.0, "opens on the current count"); + assert!(set(&mut app, json!(31)).is_err()); + assert!(app.ui.dialog.is_some() && app.ui.attributes_panel.recent_urls == 25, "a refused count changes nothing"); + // Cancel closes the dialog without applying what was typed. + app.ui.dialog.as_mut().unwrap().fields.insert("count".into(), json!(3)); + super::super::cancel(&mut app); + assert!(app.ui.dialog.is_none()); + assert_eq!(app.ui.attributes_panel.recent_urls, 25); + } +} diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 71e443a399..a4ab22438b 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2113,6 +2113,9 @@ font-technology Variable Променливи Navigate Навигация Navigator Навигатор Navigator Panel Options Опции за панела „Навигатор“ + Attributes Panel Options Опции за панела „Атрибути“ + Number of Recent URLs: Брой скорошни URL адреси: +@msg `count` must be a whole number from 1 to 30 `count` трябва да е цяло число от 1 до 30 Draw Dashed Lines as Solid Lines Изчертаване на прекъснатите линии като плътни Needs the desktop app Изисква десктоп приложение Neutral Gradients Неутрални градиенти diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 883d6dd387..6fc2c9ebef 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -766,6 +766,9 @@ Magic Wand Čarobni štapić Navigator Navigator Navigator Panel Options Opcije panela navigatora + Attributes Panel Options Opcije panela atributa + Number of Recent URLs: Broj nedavnih URL-ova: +@msg `count` must be a whole number from 1 to 30 `count` mora biti cijeli broj od 1 do 30 Draw Dashed Lines as Solid Lines Crtaj isprekidane linije kao pune Pattern Options Opcije uzorka Properties Svojstva diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index a8a63cbf55..1356db240b 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -2776,6 +2776,9 @@ digits Malayalam Malaiàlam Navigate Navega Navigator Navegador Navigator Panel Options Opcions del panell Navegador + Attributes Panel Options Opcions del panell Atributs + Number of Recent URLs: Nombre d’URL recents: +@msg `count` must be a whole number from 1 to 30 `count` ha de ser un nombre enter d’1 a 30 Draw Dashed Lines as Solid Lines Dibuixa les línies discontínues com a contínues Needs a choice Necessita una tria Needs a key Necessita una clau diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 569b1347ec..fdb2b53988 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -779,6 +779,9 @@ Magic Wand Kouzelná hůlka Navigator Navigátor Navigator Panel Options Možnosti panelu Navigátor + Attributes Panel Options Možnosti panelu Atributy + Number of Recent URLs: Počet nedávných URL: +@msg `count` must be a whole number from 1 to 30 `count` musí být celé číslo od 1 do 30 Draw Dashed Lines as Solid Lines Kreslit čárkované čáry jako plné Pattern Options Možnosti vzorku Properties Vlastnosti diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 4578e4efc1..94eb01b545 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3398,6 +3398,9 @@ liquify-list-end {0}, {1} {0} og {1} Magic Wand Magisk tryllestav Navigator Navigator Navigator Panel Options Indstillinger for navigatorpanelet + Attributes Panel Options Indstillinger for attributpanelet + Number of Recent URLs: Antal seneste URL'er: +@msg `count` must be a whole number from 1 to 30 `count` skal være et heltal fra 1 til 30 Draw Dashed Lines as Solid Lines Tegn stiplede linjer som hele linjer Pattern Options Mønsterindstillinger Properties Egenskaber diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index c943c89dd2..f15f34919b 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2193,6 +2193,9 @@ file-filter Templates Vorlagen Navigate Navigieren Navigator Navigator Navigator Panel Options Optionen für das Navigatorbedienfeld + Attributes Panel Options Optionen für das Attributebedienfeld + Number of Recent URLs: Anzahl zuletzt verwendeter URLs: +@msg `count` must be a whole number from 1 to 30 `count` muss eine ganze Zahl von 1 bis 30 sein Draw Dashed Lines as Solid Lines Gestrichelte Linien als durchgezogene Linien zeichnen Needs the desktop app Erfordert die Desktop-App Neutral Gradients Neutrale Verläufe diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 906640aa0a..0620ebb7e2 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -1888,6 +1888,9 @@ font-technology Variable Μεταβλητές Name: Όνομα: Navigator Πλοήγηση Navigator Panel Options Επιλογές πίνακα πλοήγησης + Attributes Panel Options Επιλογές πίνακα χαρακτηριστικών + Number of Recent URLs: Αριθμός πρόσφατων διευθύνσεων URL: +@msg `count` must be a whole number from 1 to 30 Το `count` πρέπει να είναι ακέραιος από 1 έως 30 Draw Dashed Lines as Solid Lines Σχεδίαση διακεκομμένων γραμμών ως συνεχών New Νέο Scatter: Διασπορά: diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 9239c93a73..9d7023ec9f 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2194,6 +2194,9 @@ font-technology Variable Variables Navigate Navegar Navigator Navegador Navigator Panel Options Opciones del panel Navegador + Attributes Panel Options Opciones del panel Atributos + Number of Recent URLs: Número de URL recientes: +@msg `count` must be a whole number from 1 to 30 `count` debe ser un número entero entre 1 y 30 Draw Dashed Lines as Solid Lines Dibujar líneas discontinuas como continuas Needs the desktop app Requiere la aplicación de escritorio Neutral Gradients Degradados neutros diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 423703e5c1..622dc1e7d6 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -770,6 +770,9 @@ Magic Wand Taikasauva Navigator Navigaattori Navigator Panel Options Navigaattori-paneelin asetukset + Attributes Panel Options Määritteet-paneelin asetukset + Number of Recent URLs: Viimeisimpien URL-osoitteiden määrä: +@msg `count` must be a whole number from 1 to 30 `count` on oltava kokonaisluku 1–30 Draw Dashed Lines as Solid Lines Piirrä katkoviivat yhtenäisinä viivoina Pattern Options Kuvion asetukset Properties Ominaisuudet diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8af602785b..315099dae6 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2184,6 +2184,9 @@ font-technology Variable Variables Navigate Naviguer Navigator Navigation Navigator Panel Options Options du panneau Navigation + Attributes Panel Options Options du panneau Options d’objet + Number of Recent URLs: Nombre d’URL récentes : +@msg `count` must be a whole number from 1 to 30 `count` doit être un nombre entier compris entre 1 et 30 Draw Dashed Lines as Solid Lines Dessiner les pointillés en traits pleins Needs the desktop app Nécessite l’application de bureau Neutral Gradients Dégradés neutres diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 4eed343e3d..65800aaac4 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -2278,6 +2278,9 @@ Navigate નેવિગેટ કરો Navigator નેવિગેટર Navigator Panel Options નેવિગેટર પૅનલ વિકલ્પો + Attributes Panel Options ગુણધર્મો પૅનલ વિકલ્પો + Number of Recent URLs: તાજેતરના URLની સંખ્યા: +@msg `count` must be a whole number from 1 to 30 `count` 1 થી 30 સુધીની પૂર્ણ સંખ્યા હોવી જોઈએ Needs Attention Only માત્ર ધ્યાન માગતા Needs a choice પસંદગી જરૂરી Needs a key કીની જરૂર છે diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index de33cdbd92..1447ae7e01 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -3032,6 +3032,9 @@ antiAlias Sharp शार्प Navigate नेविगेट करें Navigator नेविगेटर Navigator Panel Options नेविगेटर पैनल ऑप्शन्स + Attributes Panel Options एट्रिब्यूट्स पैनल ऑप्शन्स + Number of Recent URLs: हाल के URL की संख्या: +@msg `count` must be a whole number from 1 to 30 `count` 1 से 30 तक पूरी संख्या होना चाहिए Nearly Closed Paths लगभग बंद पाथ Nearly Coincident Anchors लगभग Coincident एंकर Needless Clipping Groups अनावश्यक क्लिपिंग समूह diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index f869e7d07b..886fc759f0 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -2737,6 +2737,9 @@ file-filter Templates Sablonok Navigate Navigálás Navigator Navigátor Navigator Panel Options Navigátor panel beállításai + Attributes Panel Options Attribútumok panel beállításai + Number of Recent URLs: Legutóbbi URL-ek száma: +@msg `count` must be a whole number from 1 to 30 `count`: 1 és 30 közötti egész szám kell Draw Dashed Lines as Solid Lines Szaggatott vonalak rajzolása folytonosként Needs the desktop app Az asztali alkalmazás kell hozzá Negative Negatív diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index c5f865e69b..1d7632f34c 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -724,6 +724,9 @@ Magic Wand Tongkat ajaib Navigator Navigator Navigator Panel Options Opsi panel navigator + Attributes Panel Options Opsi panel atribut + Number of Recent URLs: Jumlah URL terbaru: +@msg `count` must be a whole number from 1 to 30 `count` harus bilangan bulat dari 1 sampai 30 Draw Dashed Lines as Solid Lines Gambar garis putus-putus sebagai garis utuh Pattern Options Opsi pola Properties Properti diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 08cefdbed7..14c4d1c6cf 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2230,6 +2230,9 @@ file-filter Templates Modelli Navigate Naviga Navigator Navigatore Navigator Panel Options Opzioni pannello Navigatore + Attributes Panel Options Opzioni pannello Attributi + Number of Recent URLs: Numero di URL recenti: +@msg `count` must be a whole number from 1 to 30 `count` deve essere un numero intero compreso tra 1 e 30 Draw Dashed Lines as Solid Lines Disegna le linee tratteggiate come linee continue Needs the desktop app Richiede l'app desktop Neutral Gradients Sfumature neutre diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 59c7628f40..3562378244 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -798,6 +798,9 @@ digits Malayalam マラヤーラム数字 Magic Wand 自動選択 Navigator ナビゲーター Navigator Panel Options ナビゲーターパネルオプション + Attributes Panel Options 属性パネルオプション + Number of Recent URLs: 最近使った URL の数: +@msg `count` must be a whole number from 1 to 30 `count` には 1 から 30 までの整数を指定してください Draw Dashed Lines as Solid Lines 破線を実線で表示 Pattern Options パターンオプション Properties プロパティ diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 9393433cdb..57e63f701f 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2773,6 +2773,9 @@ Magic Wand ჯადოსნური ჯოხი Navigator ნავიგატორი Navigator Panel Options ნავიგატორის პანელის პარამეტრები + Attributes Panel Options ატრიბუტების პანელის პარამეტრები + Number of Recent URLs: ბოლოდროინდელი URL-ების რაოდენობა: +@msg `count` must be a whole number from 1 to 30 `count` უნდა იყოს მთელი რიცხვი 1-დან 30-მდე Draw Dashed Lines as Solid Lines ტირეებიანი ხაზების უწყვეტ ხაზებად დახატვა Pattern Options პატერნის პარამეტრები Properties თვისებები diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 49d5e10dc1..a951bca253 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -791,6 +791,9 @@ digits Malayalam 말라얄람어 Magic Wand 마술봉 Navigator 내비게이터 Navigator Panel Options 내비게이터 패널 옵션 + Attributes Panel Options 속성 패널 옵션 + Number of Recent URLs: 최근 URL 수: +@msg `count` must be a whole number from 1 to 30 `count`은(는) 1에서 30 사이의 정수여야 합니다 Draw Dashed Lines as Solid Lines 점선을 실선으로 그리기 Pattern Options 패턴 옵션 Properties 속성 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index f071ebd0e2..2df6b36831 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1292,6 +1292,9 @@ liquify-list-end {0}, {1} {0} en {1} Magic Wand Magische toverstaf Navigator Navigator Navigator Panel Options Opties voor het paneel Navigator + Attributes Panel Options Opties voor het paneel Kenmerken + Number of Recent URLs: Aantal recente URL's: +@msg `count` must be a whole number from 1 to 30 `count` moet een geheel getal van 1 tot 30 zijn Draw Dashed Lines as Solid Lines Streepjeslijnen als doorgetrokken lijnen tekenen Pattern Options Patroonopties Properties Eigenschappen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 2477c73abd..8cdfdb29d1 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -726,6 +726,9 @@ Magic Wand Różdżka Navigator Nawigator Navigator Panel Options Opcje panelu Nawigator + Attributes Panel Options Opcje panelu Atrybuty + Number of Recent URLs: Liczba ostatnich adresów URL: +@msg `count` must be a whole number from 1 to 30 `count` musi być liczbą całkowitą od 1 do 30 Draw Dashed Lines as Solid Lines Rysuj linie przerywane jako ciągłe Pattern Options Opcje wzorka Properties Właściwości diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 333351b9af..fac99b0fc7 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -1829,6 +1829,9 @@ antiAlias Sharp Nítido Navigate Navegar Navigator Navegador Navigator Panel Options Opções do painel Navegador + Attributes Panel Options Opções do painel Atributos + Number of Recent URLs: Número de URLs Recentes: +@msg `count` must be a whole number from 1 to 30 `count` deve ser um número inteiro de 1 a 30 Draw Dashed Lines as Solid Lines Desenhar linhas tracejadas como linhas sólidas Needs the desktop app Requer o aplicativo de desktop Neutral Gradients Gradientes Neutros diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ae33aa0d55..931c8768d2 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2221,6 +2221,9 @@ file-filter Templates Шаблоны Navigate Навигация Navigator Навигатор Navigator Panel Options Параметры панели «Навигатор» + Attributes Panel Options Параметры панели «Атрибуты» + Number of Recent URLs: Число последних URL: +@msg `count` must be a whole number from 1 to 30 `count` должно быть целым числом от 1 до 30 Draw Dashed Lines as Solid Lines Рисовать штриховые линии сплошными Needs the desktop app Требуется настольное приложение Neutral Gradients Нейтральные градиенты diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 1bd4fd0692..debf440d55 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2129,6 +2129,9 @@ font-technology Variable Variabla Navigate Navigera Navigator Navigator Navigator Panel Options Alternativ för panelen Navigator + Attributes Panel Options Alternativ för panelen Attribut + Number of Recent URLs: Antal senaste URL:er: +@msg `count` must be a whole number from 1 to 30 `count` måste vara ett heltal från 1 till 30 Draw Dashed Lines as Solid Lines Rita streckade linjer som heldragna linjer Needs the desktop app Kräver skrivbordsappen Neutral Gradients Neutrala gradienter diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index d21a146585..c54a75c05c 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -434,6 +434,22 @@ fn font_height_reference_labels_are_in_complete_catalogs() { } } +/// The Attributes Panel Options dialog's heading and field, and the error for a count out of range. +#[test] +fn attributes_panel_options_strings_are_in_complete_catalogs() { + for lang in LANGUAGES.iter().filter(|lang| lang.complete_menus) { + for label in ["Attributes Panel Options", "Number of Recent URLs:"] { + assert!(lang.catalog().plain(label).is_some(), "{} is missing {label}", lang.code); + } + } + let range = "`count` must be a whole number from 1 to 30"; + assert!(message_literals().contains(range)); + for code in COMPLETE_MESSAGES { + let lang = Lang::from_code(code).expect("registered"); + assert_ne!(message(lang, range), range, "{code}"); + } +} + /// The Objects on Path Options section's Detach button, its undo step and the message for a /// Detach with no object chosen. #[test] diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index a2a38c679a..7443463ef5 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2009,6 +2009,9 @@ font-technology Variable Değişken Navigate Gezin Navigator Gezgin Navigator Panel Options Gezgin Paneli Seçenekleri + Attributes Panel Options Nitelikler Paneli Seçenekleri + Number of Recent URLs: Son URL Sayısı: +@msg `count` must be a whole number from 1 to 30 `count` 1 ile 30 arasında bir tam sayı olmalıdır Draw Dashed Lines as Solid Lines Kesikli Çizgileri Düz Çizgi Olarak Çiz Needs the desktop app Masaüstü uygulaması gerekiyor Neutral Gradients Nötr Degradeler diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 17c673885d..be86bef9ee 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2224,6 +2224,9 @@ file-filter Templates Шаблони Navigate Навігація Navigator Навігатор Navigator Panel Options Параметри панелі «Навігатор» + Attributes Panel Options Параметри панелі «Атрибути» + Number of Recent URLs: Кількість останніх URL: +@msg `count` must be a whole number from 1 to 30 `count` має бути цілим числом від 1 до 30 Draw Dashed Lines as Solid Lines Малювати штрихові лінії суцільними Needs the desktop app Потрібен настільний додаток Neutral Gradients Нейтральні градієнти diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index da89525314..721f77b009 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -2555,6 +2555,9 @@ digits Hindi Hindi Navigate Dẫn hướng Navigator Bộ dẫn hướng Navigator Panel Options Tùy chọn bảng bộ dẫn hướng + Attributes Panel Options Tùy chọn bảng thuộc tính + Number of Recent URLs: Số URL gần đây: +@msg `count` must be a whole number from 1 to 30 `count` phải là số nguyên từ 1 đến 30 Draw Dashed Lines as Solid Lines Vẽ đường nét đứt thành đường liền Needs the desktop app Cần ứng dụng máy tính để bàn Neutral Gradients Chuyển sắc trung tính diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 5f612cb0d4..98534a2b07 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2096,6 +2096,9 @@ file-filter Templates 模板 Navigate 导航 Navigator 导航器 Navigator Panel Options 导航器面板选项 + Attributes Panel Options 属性面板选项 + Number of Recent URLs: 最近使用的网址数量: +@msg `count` must be a whole number from 1 to 30 `count` 必须是 1 到 30 之间的整数 Draw Dashed Lines as Solid Lines 将虚线绘制为实线 Needs the desktop app 需要桌面应用 Neutral Gradients 中性渐变 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e0b5a13ee2..560de59b0a 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -3352,6 +3352,9 @@ liquify-list-end {0}, {1} {0}和{1} Navigate 導覽 Navigator 導覽器 Navigator Panel Options 導覽器面板選項 + Attributes Panel Options 屬性面板選項 + Number of Recent URLs: 最近使用的網址數量: +@msg `count` must be a whole number from 1 to 30 `count` 必須是 1 到 30 之間的整數 Draw Dashed Lines as Solid Lines 將虛線繪製為實線 Needs the desktop app 需要桌面版應用程式 Neutral Gradients 中性漸層 diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index 495e606d6c..13bec6b050 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -838,6 +838,7 @@ fn run_ui_part8(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option crate::panels::artboards::select_all_command(app), "ui.layersPanelOptions" => crate::dialogs::layers_panel_options::open(app), "ui.navigatorPanelOptions" => crate::panels::navigator::set_options(app, p), + "ui.attributesPanelOptions" => crate::panels::attributes::set_options(app, p), "ui.layersExpand" => crate::panels::layers::expand(app, p), "ui.layersFilter" => crate::panels::layers::set_filter(app, p), "ui.panelView" => crate::panels::set_view(app, p), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index ced961e32c..a8ccf5a908 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1100,6 +1100,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{color?: #rrggbb or a preset name (Light Red, the default, then the layer colors such as \"Light Blue\"), solidDashes?: bool (Draw Dashed Lines as Solid Lines, off by default: the Navigator's thumbnail draws dashed strokes without their dashes; the canvas, printing and exports keep them)} set the Navigator panel's options, the color its view box is drawn in and solid dashes (kept with the UI state) → {color, solidDashes}; with neither, open its Panel Options (dialog `navigatorPanelOptions`, fields color, solidDashes; OK sets them); an error for a value that is not a color or not true or false, which changes nothing", ), + ( + "ui.attributesPanelOptions", + "Panel Options…", + "", + "{count?: 1–30 (10 by default)} set how many of the recent URLs (attributes.info › recentUrls, which keeps 30) the Attributes panel's URL menu lists, newest first (kept with the UI state) → {count}; without count, open its Panel Options (dialog `attributesPanelOptions`, field count; OK sets it); an error for a count that is not a whole number from 1 to 30, which changes nothing", + ), ( "ui.layersExpand", "Expand Layers Panel Rows", diff --git a/crates/ui-egui/src/panels/attributes.rs b/crates/ui-egui/src/panels/attributes.rs index d387735de9..19efb7055a 100644 --- a/crates/ui-egui/src/panels/attributes.rs +++ b/crates/ui-egui/src/panels/attributes.rs @@ -1,13 +1,15 @@ //! Attributes panel: Overprint Fill / Overprint Stroke, Show / Don't Show Center, Reverse Path //! Direction Off / On, the fill rule (non-zero winding or even-odd), Image Map, URL (with the -//! recent URLs and a Browser button) and the note. The menu hides the options and shows the note. +//! recent URLs and a Browser button) and the note. The menu hides the options and shows the note, +//! and its Panel Options… sets how many recent URLs the URL menu lists ([`PanelOptions`]). //! Everything reads `attributes.info` ([`vectorcraft_engine::Session::attributes_info`]) and acts //! through `attributes.set`, `path.reverse` and `path.setFillRule`. use egui::Ui; +use serde::{Deserialize, Deserializer, Serialize}; use serde_json::{Value, json}; use vectorcraft_doc::{ImageMap, NodeId, NodeKind}; -use vectorcraft_engine::cmd::AttributesInfo; +use vectorcraft_engine::cmd::{AttributesInfo, RECENT_URLS}; use vectorcraft_geom::FillRule; use super::{pstate, selection_len, set_pstate}; @@ -20,6 +22,63 @@ const HIDE_OPTIONS: &str = "attr-hide-options"; const HIDE_NOTE: &str = "attr-hide-note"; const LABEL_W: f32 = 70.0; +/// How many recent URLs the URL menu lists by default (VectorCraft's own value). +pub const DEFAULT_RECENT_URLS: u8 = 10; + +/// Attributes panel options (≡ › Panel Options…), kept with the UI state. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(default, rename_all = "camelCase")] +pub struct PanelOptions { + /// How many of the recent URLs the URL menu lists, 1 to [`RECENT_URLS`]. A saved value that is + /// not a whole number in that range reads as [`DEFAULT_RECENT_URLS`]. + #[serde(deserialize_with = "saved_count")] + pub recent_urls: u8, +} + +impl Default for PanelOptions { + fn default() -> Self { + Self { recent_urls: DEFAULT_RECENT_URLS } + } +} + +impl PanelOptions { + /// How many recent URLs the URL menu lists: [`Self::recent_urls`], or the default when it is + /// out of range. + pub fn shown(&self) -> usize { + Some(usize::from(self.recent_urls)).filter(|n| (1..=RECENT_URLS).contains(n)).unwrap_or(usize::from(DEFAULT_RECENT_URLS)) + } +} + +/// A saved count of recent URLs: a whole number from 1 to [`RECENT_URLS`], anything else the default. +fn saved_count<'de, D: Deserializer<'de>>(d: D) -> Result { + let v = Value::deserialize(d)?; + Ok(count(&v).unwrap_or(DEFAULT_RECENT_URLS)) +} + +/// `v` as a count of recent URLs, when it is a whole number from 1 to [`RECENT_URLS`]. +fn count(v: &Value) -> Option { + let n = v.as_f64().filter(|n| n.fract() == 0.0 && (1.0..=RECENT_URLS as f64).contains(n))?; + u8::try_from(n as u64).ok() +} + +/// `ui.attributesPanelOptions {count?}`: without `count`, open Panel Options on the panel's +/// options; otherwise set how many recent URLs the URL menu lists and answer the options. A count +/// that is not a whole number from 1 to 30 is an error, and nothing changes. +pub fn set_options(app: &mut VectorcraftApp, p: &Value) -> Result { + let Some(c) = p.get("count") else { + return crate::dialogs::attributes_panel_options::open(app); + }; + let n = count(c).ok_or("`count` must be a whole number from 1 to 30")?; + app.ui.attributes_panel.recent_urls = n; + Ok(json!({ "count": n })) +} + +/// The recent URLs the URL menu lists, newest first: as many as Panel Options sets. +fn menu_urls(app: &VectorcraftApp) -> &[String] { + let urls = &app.session.recent_urls; + &urls[..urls.len().min(app.ui.attributes_panel.shown())] +} + /// The panel's values and whether the targets hold paths (direction and fill rule apply), /// recomputed only when the document or the selection changes. fn state(app: &VectorcraftApp, ctx: &egui::Context) -> (AttributesInfo, bool) { @@ -133,13 +192,13 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { } } -/// The recent URLs button: a menu of the URLs given lately; picking one sets it. +/// The recent URLs button: a menu of the URLs given lately ([`menu_urls`]); picking one sets it. fn recent_urls(app: &mut VectorcraftApp, ui: &mut Ui) { let resp = widgets::icon_button_enabled(ui, "chevron-down", tl!("Recent URLs"), false, !app.session.recent_urls.is_empty(), 20.0); let mut chosen = None; egui::Popup::menu(&resp).show(|ui| { ui.set_min_width(220.0); - for u in &app.session.recent_urls { + for u in menu_urls(app) { if widgets::menu_item_name(ui, u, true, false) { chosen = Some(u.clone()); } @@ -150,13 +209,16 @@ fn recent_urls(app: &mut VectorcraftApp, ui: &mut Ui) { } } -pub fn menu(_app: &mut VectorcraftApp, ui: &mut Ui) { +pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { for (key, hide, show) in [(HIDE_OPTIONS, tl!("Hide Options"), tl!("Show Options")), (HIDE_NOTE, tl!("Hide Note"), tl!("Show Note"))] { let hidden: bool = pstate(ui.ctx(), key); if menu_item(ui, if hidden { show } else { hide }, true, false) { set_pstate(ui.ctx(), key, !hidden); } } + if menu_item(ui, tl!("Panel Options…"), true, false) { + app.run("ui.attributesPanelOptions", json!({})).ok(); + } } /// `attributes.openUrl {url?}`: open `url`, else the selection's URL, in the web browser. @@ -257,4 +319,39 @@ mod tests { open_url(&mut app, &json!({"url": "https://example.com/b"})).unwrap(); assert_eq!(*opened.borrow(), ["https://example.com/b"]); } + + /// The URL menu lists the newest 10 recent URLs by default, and `ui.attributesPanelOptions` + /// sets how many it lists, from 1 to 30, kept with the UI state. A lower count hides the older + /// URLs without forgetting them, and a count that is not a whole number from 1 to 30 is an + /// error that changes nothing. + #[test] + fn panel_options_set_how_many_recent_urls_the_menu_lists() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + run(&mut app, "file.new", json!({"width": 100, "height": 100})); + run(&mut app, "shape.rectangle", json!({"x": 0, "y": 0, "width": 50, "height": 50})); + for i in 0..32 { + run(&mut app, "attributes.set", json!({"url": format!("https://example.com/{i}")})); + } + assert!(frame(&mut app).iter().any(|t| t == " Panel Options…")); + assert_eq!((menu_urls(&app).len(), menu_urls(&app)[0].as_str()), (10, "https://example.com/31")); + assert_eq!(app.run("ui.attributesPanelOptions", json!({"count": 1})).unwrap(), json!({"count": 1})); + assert_eq!(menu_urls(&app), ["https://example.com/31"]); + app.run("ui.attributesPanelOptions", json!({"count": 30.0})).unwrap(); + assert_eq!((menu_urls(&app).len(), menu_urls(&app)[29].as_str()), (30, "https://example.com/2")); + for bad in [json!(0), json!(31), json!(2.5), json!(-1), json!("5"), Value::Null] { + assert!(app.run("ui.attributesPanelOptions", json!({"count": bad})).is_err(), "{bad}"); + } + assert_eq!(app.ui.attributes_panel.recent_urls, 30, "a refused count changes nothing"); + assert_eq!(app.session.recent_urls.len(), 30); + // Kept with the UI state; UI state saved without it, or with a count out of range, lists 10. + let back: crate::UiState = serde_json::from_value(serde_json::to_value(&app.ui).unwrap()).unwrap(); + assert_eq!(back.attributes_panel.recent_urls, 30); + let old: crate::UiState = serde_json::from_value(json!({})).unwrap(); + assert_eq!(old.attributes_panel, PanelOptions::default()); + for saved in [json!(0), json!(99), json!(1000), json!(4.5), json!("12"), Value::Null] { + let s: crate::UiState = serde_json::from_value(json!({"attributes_panel": {"recentUrls": saved}})).unwrap(); + assert_eq!(s.attributes_panel.shown(), 10, "{saved}"); + } + assert_eq!(PanelOptions { recent_urls: 200 }.shown(), 10); + } } diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index d3698aaeef..6d4c1f6585 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -853,6 +853,9 @@ pub struct UiState { /// Navigator panel › Panel Options… (the view box color, Draw Dashed Lines as Solid Lines). #[serde(default)] pub navigator_panel: crate::panels::navigator::PanelOptions, + /// Attributes panel › Panel Options… (how many recent URLs the URL menu lists). + #[serde(default)] + pub attributes_panel: crate::panels::attributes::PanelOptions, /// The Layers panel's Filter (`ui.layersFilter`). It is not saved and lasts the session, as the /// Search All text does. #[serde(skip)] @@ -1273,6 +1276,7 @@ impl Default for UiState { trace_hold_source: None, layers_panel: Default::default(), navigator_panel: Default::default(), + attributes_panel: Default::default(), layers_filter: Default::default(), swatches_view: Default::default(), graphic_styles_view: Default::default(), diff --git a/docs/mcp.md b/docs/mcp.md index c7aa202d3f..7c80eae06a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5692,9 +5692,18 @@ paths and compound paths, and `path.reverse {reversed?}` makes subpaths run coun (false). When every subpath of a path or compound path turns alike, its strokes' width profiles (left and right swapped) and pen pressure, tilt, bearing and rotation turn with it, so the strokes draw as before. SVG export wraps an object with a URL in ``, and SVG import reads `` links back. +`recentUrls` keeps the 30 newest distinct URLs given in the session, newest first. The panel's URL menu lists the +first 10 of them by default; the panel menu's Panel Options… opens the `attributesPanelOptions` dialog (field `count`), +and `ui.attributesPanelOptions {count}` sets the number without it, a whole number from 1 to 30 → `{count}`. A lower +count hides the older URLs without removing them from `recentUrls`. The count is kept with the UI state; a count out of +range is an error and changes nothing. The help page +[Create image maps for web graphics](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/create-image-maps-for-web-graphics.html) +describes the same 1 to 30 range; the default of 10 is VectorCraft's own value. + ```json {"name":"run_command","arguments":{"command":"attributes.set","params":{"ids":[12],"url":"https://example.com","imageMap":"rectangle"}}} {"name":"run_command","arguments":{"command":"path.setFillRule","params":{"rule":"evenOdd"}}} +{"name":"invoke_menu","arguments":{"command":"ui.attributesPanelOptions","params":{"count":20}}} ``` ## SVG interactivity diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..b3e2de6d72 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1332,6 +1332,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Artboard click-to-fit (#1227):** a plain click fits the topmost editable object or group to a new artboard, including its stroke like Fit to Selected Art, and makes the new artboard active. Art and its selection stay unchanged; creation is one undo step. Handles, modified clicks, drags, Escape and tool changes retain their meaning. Tested inside an artboard and on the pasteboard (`crates/engine/tests/it/artboard_click.rs`); the public [CS6 Printing Guide](https://helpx.adobe.com/content/dam/help/en/indesign/pdf/CS6_PrintGuide.pdf) documents the object-click gesture. This legacy gesture adds evidence without regrading the 2026 canvas controls. - **Rotated views:** with the view rotated, Fit Artboard in Window, Fit All in Window and the status bar's artboard navigator fit the artboard or the art as the view turns it, and a Zoom tool marquee (Animated Zoom or GPU Performance off) zooms to the area dragged across. Ruler guides on no artboard turn with the view. The canvas draws the selection marquee where the tools select, Show Hidden Characters draws the marks of type partly inside the canvas, the Contextual Task Bar stays under the selection, and the Navigator's red box outlines what the window shows. - **Navigator panel options:** the Navigator panel menu's Panel Options… sets the color the view box is drawn in, from a preset list (VectorCraft's own: Light Red, the default, then the layer colors) or a custom color, and Draw Dashed Lines as Solid Lines, off by default, which draws dashed strokes without their dashes in the panel's thumbnail only (`ui.navigatorPanelOptions`; kept with the UI state; behavior reference: [View artwork](https://helpx.adobe.com/illustrator/using/viewing-artwork.html)). +- **Attributes panel options:** the Attributes panel menu's Panel Options… sets how many recent URLs the URL menu lists, a whole number from 1 to 30 (10 by default, VectorCraft's own value); the panel keeps the 30 newest URLs of the session, so a lower count hides older URLs without removing them (`ui.attributesPanelOptions`; kept with the UI state; behavior reference: [Create image maps for web graphics](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/create-image-maps-for-web-graphics.html); test `panel_options_set_how_many_recent_urls_the_menu_lists`). - **Views:** the status bar's artboard navigator (first, previous, next, last; `view.goToArtboard`) goes to an artboard, fits it and synchronizes the Artboard tool selection when that tool is active; ordinary object selection is preserved. Its four buttons are also commands of their own (`view.firstArtboard`, `view.previousArtboard`, `view.nextArtboard`, `view.lastArtboard`), listed in Edit › Keyboard Shortcuts without a default key, so a user can give them keys such as Page Up and Page Down (#5218). Actual Next-button regressions cover keyboard/Properties deletion and Undo in `chrome.rs`. Fit Artboard in Window and Actual Size show the navigator's artboard. The Artboards panel highlights that active artboard: clicking a row makes it active (the Artboard tool's too, while it is chosen) as does clicking an artboard with the Artboard tool, double-clicking its number also fits it in the window and double-clicking its name renames it. Duplicate Artboards, or a row dragged onto New Artboard, copies the artboard with its art (#446). Escape leaves Presentation Mode, `view.screenMode` from it goes back to Normal Screen Mode, and the screen mode isn't saved with the preferences: the app always starts in Normal Screen Mode with its menus and panels (#472). View › Pixel Preview shows the art as the document pixels it rasterizes to, one per point and hard-edged when magnified, turning with a rotated view (it used to draw the smooth vectors, with only the pixel grid over them). In Outline view a template layer keeps drawing in Preview, dimmed, so a picture placed to be traced stays visible under the outlines (#1505, fixes #1486). Outline view draws on a white canvas in every interface brightness and Canvas Color, pasteboard included, with the artboards as their edges and no paper (VectorCraft's own rule), so the black outlines of art on the pasteboard show. In Presentation Mode, → and ← go to the next and the previous artboard, and a click anywhere goes to the next one, as the status bar navigator's Next and Previous do (`view.goToArtboard`): on the last artboard → and a click leave the view as it is, and so does ← on the first. The arrow keys do not move the selection there, and the tool does not receive a click, so a click selects and draws nothing (behavior reference: [View artwork](https://helpx.adobe.com/illustrator/using/viewing-artwork.html)). Full Screen Mode and Presentation Mode put the window full screen, covering the taskbar and the window's frame, and Normal Screen Mode or Full Screen Mode with Menu Bar puts it back (#4365); a window the user made full screen stays so.