From ccb9cf93f5fdfef123fde5c5ea858be6a8fbddbe Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 00:04:51 -0800 Subject: [PATCH] Contextual Task Bar: Bar Actions names without a full-width colon, wider coverage test Bar Actions listed the Smooth tool's Fidelity with its colon in Chinese, where the catalogs write a full-width colon, and with a trailing no-break space in French. bar_action_name now trims the colon in either width, the space before it and a final ellipsis. every_action_the_bar_offers_can_be_turned_off now also covers an Image Trace object's Expand, Dynamic Text on point, area and path type, the Type tool's bar and the chips. With every action and chip off, it checks that the bar still shows its handle and More Options, where Bar Actions turns them on again; docs/mcp.md and the progress-doc line say so. --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/canvas/task_bar.rs | 28 ++++++++----- crates/ui-egui/src/tests/taskbar.rs | 57 +++++++++++++++++++++++---- docs/mcp.md | 6 ++- docs/target-app-parity.md | 2 +- 5 files changed, 74 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 316681b493..1ae7fd0aff 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -74,7 +74,7 @@ pub use selection_marks::SelectionMarks; use task_bar::task_bar; pub(crate) use task_bar::{TASK_BAR_ACTIONS, TASK_BAR_CHIPS, is_task_bar_action, read_hidden_task_bar_actions}; #[cfg(test)] -pub(crate) use task_bar::{chip_paints, images_with_other_art, task_bar_offered}; +pub(crate) use task_bar::{bar_action_name, chip_paints, images_with_other_art, task_bar_offered}; pub(crate) use task_bar::{has_colors, task_bar_rect, task_bar_shows_fonts, task_bar_shows_type}; #[cfg(test)] use tool_overlays::{DIAL_RADIUS, HiddenMarks}; diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index 7ba9ee4e94..c539197aff 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -19,8 +19,9 @@ pub(crate) fn task_bar_shows_fonts(ctx: &egui::Context) -> bool { task_bar_rect(ctx).is_some() && ctx.data(|d| d.get_temp::(task_bar_id().with("fonts")).unwrap_or(false)) } -/// The actions the Contextual Task Bar offered when it was last drawn, before Bar Actions left any -/// out: each one's name and its id in [`TASK_BAR_ACTIONS`] (none: Bar Actions cannot turn it off). +/// The actions and chips the Contextual Task Bar offered when it was last drawn, before Bar Actions +/// left any out: each one's name and its id in [`TASK_BAR_ACTIONS`] or [`TASK_BAR_CHIPS`] (none: +/// Bar Actions cannot turn it off). #[cfg(test)] pub(crate) fn task_bar_offered(ctx: &egui::Context) -> Vec<(String, Option<&'static str>)> { ctx.data(|d| d.get_temp(task_bar_id().with("offered")).unwrap_or_default()) @@ -191,7 +192,8 @@ pub(crate) fn task_bar_shows_type(app: &VectorcraftApp) -> bool { /// Its handle drags it anywhere on the canvas; unpinned it keeps that offset as it follows the /// selection, pinned it stays put ([`crate::state::TaskBarPlace`]). More Options › Bar Actions /// turns each action and chip the bar offers on or off ([`TASK_BAR_ACTIONS`], [`TASK_BAR_CHIPS`]); -/// the bar leaves out the ones that are off, and Reset Bar Actions shows them all again. +/// the bar leaves out the ones that are off, and Reset Bar Actions shows them all again. With every +/// one of them off, the bar still shows its handle and More Options, where they turn back on. pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { let t = Tokens::get(ui.ctx()); let on_artboards = app.session.tool_id() == "artboard"; @@ -364,11 +366,8 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { // the ones that are off there are left out of the bar. let hidden = &app.ui.task_bar_hidden_actions; #[cfg(test)] - ui.ctx().data_mut(|d| { - let ids: Vec<(String, Option<&'static str>)> = - items.iter().map(|(label, _, cmd, params)| (label.to_string(), action_id(cmd, params))).collect(); - d.insert_temp(task_bar_id().with("offered"), ids); - }); + let mut probe: Vec<(String, Option<&'static str>)> = + items.iter().map(|(label, _, cmd, params)| (label.to_string(), action_id(cmd, params))).collect(); let mut offered: Vec<(&str, &'static str)> = items.iter().filter_map(|(label, _, cmd, params)| Some((*label, action_id(cmd, params)?))).collect(); items.retain(|(_, _, cmd, params)| action_id(cmd, params).is_none_or(|a| !hidden.contains(a))); let bounds = xf.rect.shrink(8.0); @@ -392,6 +391,11 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { .filter_map(|(shown, chip)| shown.then_some(chip)) .collect(); offered.extend(chips.iter().map(|c| (c.label(shape.is_some()), c.id(shape.is_some())))); + #[cfg(test)] + { + probe.extend(chips.iter().map(|c| (c.label(shape.is_some()).to_string(), Some(c.id(shape.is_some()))))); + ui.ctx().data_mut(|d| d.insert_temp(task_bar_id().with("offered"), probe)); + } let chips: Vec = chips.into_iter().filter(|c| !hidden.contains(c.id(shape.is_some()))).collect(); let offered: Vec<(&str, &str, bool)> = offered.into_iter().map(|(label, action)| (label, action, !hidden.contains(action))).collect(); let any_hidden = !hidden.is_empty(); @@ -528,7 +532,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { ui.menu_button(format!(" {}", tl!("Bar Actions")), |ui| { ui.set_min_width(170.0); for (label, action, shown) in &offered { - if widgets::menu_item_name(ui, label.trim_end_matches([':', '…']), true, *shown) { + if widgets::menu_item_name(ui, bar_action_name(label), true, *shown) { run = Some(("window.taskBar.actions", json!({ "action": action }))); } } @@ -701,6 +705,12 @@ fn action_id(cmd: &str, params: &serde_json::Value) -> Option<&'static str> { TASK_BAR_ACTIONS.iter().find(|(_, c, t)| *c == cmd && *t == tool).map(|a| a.0) } +/// The name More Options › Bar Actions lists for the bar's item `label`: without a field's colon +/// (a full-width one too), the space some languages put before it, or a final ellipsis. +pub(crate) fn bar_action_name(label: &str) -> &str { + label.trim_end().trim_end_matches([':', ':', '…']).trim_end() +} + /// Reads the Contextual Task Bar's actions and chips that are off, as kept in the preferences. Ids /// the bar does not have are dropped, and a value that is not a list of strings reads as none off, /// so the bar shows every action. diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index 9b5ab37031..89ab5d324b 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -1803,10 +1803,11 @@ fn an_action_turned_off_is_not_listed_in_more_options() { assert!(on_bar.iter().chain(&menu).any(|t| t == "Duplicate"), "Duplicate is still offered: {on_bar:?} {menu:?}"); } -/// Every action the bar offers, for every kind of selection and tool, has an id in Bar Actions, -/// and with all of them turned off the bar shows none of them. That covers Connect and Join (both -/// `join`), the actions matched by the tool they switch to (`editPath`, `drawPencil`, -/// `smoothToolOptions`), the Smooth tool's Fidelity and the Artboard tool's actions. +/// Every action and chip the bar offers, for every kind of selection and tool, has an id in Bar +/// Actions, and with all of them turned off the bar shows none of them but still shows, with More +/// Options. That covers Connect and Join (both `join`), the actions matched by the tool they switch +/// to (`editPath`, `drawPencil`, `smoothToolOptions`), the Smooth tool's Fidelity, Dynamic Text, +/// an Image Trace object's Expand, the Type tool's Fill and the Artboard tool's actions. #[test] fn every_action_the_bar_offers_can_be_turned_off() { let dir = crate::tests_folder::Folder::new("ui-taskbar-actions"); @@ -1878,7 +1879,16 @@ fn every_action_the_bar_offers_can_be_turned_off() { let t = id(app.run("text.create", json!({"x": 60, "y": 80, "text": "Hello"})).unwrap()); select(app, &[t]); }), - &["createOutlines", "convertToAreaType"], + &["createOutlines", "convertToAreaType", "dynamicText", "fill", "stroke", "lock"], + ), + ( + "the Type tool with type selected", + Box::new(|app| { + let t = id(app.run("text.create", json!({"x": 60, "y": 80, "text": "Hello"})).unwrap()); + select(app, &[t]); + app.run("tool.select", json!({"tool": "type"})).unwrap(); + }), + &["fill"], ), ( "area type", @@ -1888,7 +1898,7 @@ fn every_action_the_bar_offers_can_be_turned_off() { app.run("type.convertToAreaType", json!({})).unwrap(); select(app, &[t]); }), - &["createOutlines", "convertToPointType"], + &["createOutlines", "convertToPointType", "dynamicText"], ), ( "type on a closed path", @@ -1897,7 +1907,15 @@ fn every_action_the_bar_offers_can_be_turned_off() { let t = id(app.run("text.createInPath", json!({"path": circle, "mode": "onPath", "text": "Round", "at": [90, 300]})).unwrap()); select(app, &[t]); }), - &["createOutlines", "typeOnPathOptions", "centerOnTop", "centerOnBottom"], + &["createOutlines", "typeOnPathOptions", "centerOnTop", "centerOnBottom", "dynamicText"], + ), + ( + "an Image Trace object", + Box::new(|app| { + place_image(app, &dir); + app.run("imageTrace.make", json!({"params": {}})).unwrap(); + }), + &["expand", "duplicate"], ), ( "an image", @@ -1967,9 +1985,32 @@ fn every_action_the_bar_offers_can_be_turned_off() { for action in &ids { show_action(&mut app, action, false); } - let (_, texts) = bar_texts(&mut app); + let (ctx, texts) = bar_texts(&mut app); for (label, _) in &offered { assert!(!has(&texts, label), "{case}: {label} is off: {texts:?}"); } + // The bar still shows, with More Options, where Bar Actions turns them back on. + assert!(canvas::task_bar_rect(&ctx).is_some(), "{case}: the bar still shows"); + let names: Vec = buttons(&mut app).1.into_iter().map(|(n, _)| n).collect(); + assert!(names.iter().any(|n| n == "More Options"), "{case}: {names:?}"); + for (label, _) in &offered { + assert!(!names.iter().any(|n| n == label), "{case}: {label} is off: {names:?}"); + } } } + +/// Bar Actions lists a field's name without its colon, as each language writes it, and an item +/// that opens a dialog without its ellipsis. +#[test] +fn bar_actions_list_names_without_a_colon_or_an_ellipsis() { + let lang = |code| crate::i18n::Lang::from_code(code).unwrap(); + for (code, label, name) in + [("en", "Fidelity:", "Fidelity"), ("en", "Tool Options…", "Tool Options"), ("fr", "Fidelity:", "Fidélité"), ("ja", "Fidelity:", "精度")] + .into_iter() + .chain([("zh-hans", "Fidelity:", "精确度"), ("zh-hant", "Fidelity:", "精確度"), ("zh-hans", "Tool Options…", "工具选项")]) + { + let label = crate::i18n::tr(lang(code), label); + assert_eq!(canvas::bar_action_name(label), name, "{code}: {label:?}"); + } + assert_eq!(canvas::bar_action_name("Duplicate"), "Duplicate"); +} diff --git a/docs/mcp.md b/docs/mcp.md index b7cbb49c0f..dd02cbefc1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -8186,8 +8186,10 @@ every group as it is. The groups and their contents are VectorCraft's own. `duplicateArtboards`, `rearrangeArtboards` and `exportArtboards` (the Artboard tool's); the chips are `fill`, `stroke`, `recolor` (Recolor Artwork), `lock` and `shapeProperties` (a basic shape's Shape Properties, in Lock's place). The bar's More Options menu has Bar Actions, which lists the actions and chips the bar offers for the current selection or tool, -each checked while it is on, and runs the command for the one clicked. An action or chip that is off stays out of the -bar and out of More Options wherever the bar would offer it; turning one off changes only the bar. Every action starts +each checked while it is on and named without a final colon or ellipsis, and runs the command for the one clicked. An +action or chip that is off stays out of the bar and out of More Options wherever the bar would offer it; turning one off +changes only the bar. With every action and chip it would offer off, the bar still shows its handle and More Options, +where Bar Actions turns them on again. Every action starts on. The type font controls are not in Bar Actions and stay on the bar. Which actions are off is kept with the preferences and with the workspace; a workspace or preferences saved without them show every action, and an id the bar does not have is dropped when they are read. Another `action`, or none, fails with "`action` must be one of …", and a diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index b1eaefd513..02d20396ea 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1038,7 +1038,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The contextual task bar offers more next steps by selection (): an open path Join and Edit Path (the Direct Selection tool), a closed path Edit Path, a compound path Edit Path and Release Compound Path, a clipping group Edit Clipping Path and Release Clipping Mask instead of Ungroup and Isolate, an image selected with vector art Make Clipping Mask instead of Unite, point or area type Convert To Area Type or Convert To Point Type beside Create Outlines, and type on a path, for which the overview names an item to add an effect and rearrange the text, Type on a Path Options (`type.pathOptions`; its options: ) beside Create Outlines. Evidence: `crates/ui-egui/src/tests/taskbar.rs`. - While a Type tool (Type, Area Type, Type on a Path and their vertical versions) adds or edits type, the contextual task bar shows the font family menu, the font style menu, the Font Size combo and the Fill chip (); the Touch Type tool shows no bar, as the same page describes. Type selected with a selection tool shows the same three font controls beside its Create Outlines, conversion and Type on a Path items (). The controls act as the Character panel's do: on the characters a Type tool selects, else on every selected type object, with the size left blank where the sizes differ. VectorCraft's own rules: a Type tool's bar leaves out the object actions, the Stroke chip, Recolor Artwork and Lock; a Type tool shows no bar before it adds type or with other art selected; type selected with other art shows no font controls; the font controls go on a second row when one row would be wider than the canvas, and narrow to fit a canvas narrower than they are; while a Type tool edits type, the Fill chip shows the edited characters' fill ("?" where it differs). Evidence: `the_type_tools_show_font_and_fill_controls`, `the_type_tools_show_no_bar_without_type`, `selected_type_shows_font_controls_beside_its_actions`, `the_task_bars_font_size_sets_what_the_character_panel_would`, `the_type_tools_fill_chip_activates_the_fill`, `the_type_tools_bar_is_named_and_stays_on_the_canvas`, `selected_types_font_controls_take_a_second_row_on_a_narrow_canvas` and `the_type_tools_fill_chip_shows_the_edited_characters_fill` in `crates/ui-egui/src/tests/taskbar.rs`. - The help page describes the contextual task bar as one horizontal row () and gives no rule for a canvas narrower than that row. VectorCraft's own rule: the bar stays whole on the canvas. When its actions don't fit in one row, they wrap, in order, onto rows under the row with the handle, the chips and More Options; an action wider than any row, or one that would need a row past the canvas's height, is listed in More Options instead; when the chips don't fit beside the handle and More Options, they take rows after the actions; with no row to spare for the font controls, the bar leaves them out; a canvas too small for the handle and More Options shows no bar. Evidence: `a_task_bars_actions_wrap_on_a_narrow_canvas` and `a_task_bar_action_wider_than_the_canvas_goes_in_more_options` in `crates/ui-egui/src/tests/taskbar.rs`. - - The contextual task bar's More Options menu has Bar Actions, which lists the actions and the Fill, Stroke, Recolor Artwork, Lock or Shape Properties chips the bar offers for the current selection or tool, each checked while it is on, and Reset Bar Actions, which turns every one on again (`window.taskBar.actions`, `window.taskBar.resetActions`). An action that is off stays out of the bar and out of More Options wherever the bar would offer it; turning one off changes only the bar. The type font controls are not in Bar Actions. Which actions are off is kept with the preferences and with the workspace. Choosing the bar's actions is VectorCraft's own. Evidence: `an_action_turned_off_leaves_the_bar_and_stays_in_its_menu`, `an_action_turned_off_is_not_listed_in_more_options`, `every_action_the_bar_offers_can_be_turned_off`, `a_chip_turned_off_leaves_the_bar`, `reset_bar_actions_shows_every_action_again`, `bar_actions_are_kept_with_the_preferences` and `more_options_bar_actions_turns_an_action_off_and_on` in `crates/ui-egui/src/tests/taskbar.rs`, and `saved_workspaces_restore_the_task_bar_actions` in `crates/ui-egui/src/workspaces.rs`. + - The contextual task bar's More Options menu has Bar Actions, which lists the actions and the Fill, Stroke, Recolor Artwork, Lock or Shape Properties chips the bar offers for the current selection or tool, each checked while it is on, and Reset Bar Actions, which turns every one on again (`window.taskBar.actions`, `window.taskBar.resetActions`). An action that is off stays out of the bar and out of More Options wherever the bar would offer it; turning one off changes only the bar. With all of them off, the bar still shows its handle and More Options. The type font controls are not in Bar Actions. Which actions are off is kept with the preferences and with the workspace. Choosing the bar's actions is VectorCraft's own. Evidence: `an_action_turned_off_leaves_the_bar_and_stays_in_its_menu`, `an_action_turned_off_is_not_listed_in_more_options`, `every_action_the_bar_offers_can_be_turned_off`, `a_chip_turned_off_leaves_the_bar`, `reset_bar_actions_shows_every_action_again`, `bar_actions_are_kept_with_the_preferences`, `bar_actions_list_names_without_a_colon_or_an_ellipsis` and `more_options_bar_actions_turns_an_action_off_and_on` in `crates/ui-egui/src/tests/taskbar.rs`, and `saved_workspaces_restore_the_task_bar_actions` in `crates/ui-egui/src/workspaces.rs`. - With a live rectangle, rounded rectangle, ellipse or polygon selected with the Selection tool, the contextual task bar shows a Shape Properties button in place of Lock. It opens a popup with the shape's rows from the Transform panel (corner radius, pie angles, or sides, angle, corner and radius), which edit it through `object.setLiveShape`. The overview describes this: when a shape drawn with a shape tool (Rectangle, Star) is selected, the bar offers to change its properties where Lock Object would be ([Contextual Task Bar overview](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/contextual-task-bar-overview.html)). Object › Lock and ⌘2 still lock the shape. Not done: stars, which the app draws as plain paths. Evidence: `a_basic_shape_shows_its_properties_in_place_of_lock`, `the_shape_properties_popup_edits_the_shape` and `other_selections_keep_lock` in `crates/ui-egui/src/tests/taskbar.rs`. - While the Rectangle, Rounded Rectangle, Ellipse, Polygon or Star tool is in use, the contextual task bar offers Edit Path (the Direct Selection tool), the Fill and Stroke chips, and Shape Properties for the shape it draws, as the help page lists for those five tools (). VectorCraft's own rules: the bar shows while one of those tools has one closed path selected whole, as right after it draws one, and not with nothing selected, several objects, a group, an open path, type or picked-out anchors; it shows nothing during the drag that draws the shape; it leaves out the selection tools' Duplicate, Offset Path, Simplify, Recolor Artwork and Lock; the Line Segment tool shows no bar. Not done: Shape Properties for a star, which the app draws as a plain path, and Gen Shape Fill and Generate Vectors, which the app doesn't have. Evidence: `shape_tools_show_edit_path_paint_and_properties_after_drawing`, `shape_tools_have_no_shape_bar_without_a_single_shape` and `shape_tool_bar_retargets_after_another_shape_and_undo` in `crates/ui-egui/src/tests/taskbar.rs`. - While the Smooth tool is in use with a path it can smooth selected (a path with three or more anchors, or two joined by a curve, on its own or inside a selected group), the contextual task bar shows the tool's Fidelity field and Tool Options…, which opens the Smooth tool's options. The overview says the Smooth tool's bar has its tool options (), and the tool's help page names Fidelity as its option (). A value typed or stepped in the field sets the tool's Fidelity through `tool.setOption`, with the same range, unit (screen pixels) and steps as the field in its options. VectorCraft's own rules: with nothing selected, or only straight lines or type selected, the tool shows no bar; the bar leaves out the selection tools' actions, the Fill and Stroke chips, Recolor Artwork and Lock; on a canvas too narrow for the field, More Options lists Fidelity, which opens the tool's options. Evidence: `the_smooth_tool_shows_fidelity_and_tool_options_for_a_path` and `the_smooth_tool_shows_no_bar_without_a_path_to_smooth` in `crates/ui-egui/src/tests/taskbar.rs`.