mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 22:34:09 +00:00
Contextual Task Bar: Bar Actions names drop a colon and an ellipsis in any order
More Options › Bar Actions now leaves out a final colon and a final
ellipsis ("…" or "...") whichever comes last, with or without a space
between them, so "Name...:" and "Name: ..." are listed as "Name".
window.taskBar.actions treats a `visible` of null as omitted again, so
the action toggles, as docs/mcp.md says for every command's params and
as window.control.options does. Its params text and docs/mcp.md entry
now say that null toggles, and a test covers it.
This commit is contained in:
@@ -679,7 +679,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"window.taskBar.actions",
|
||||
"Bar Actions",
|
||||
"",
|
||||
"{action: \"imageTrace\"|\"cropImage\"|\"removeBackground\"|\"removeAnchorPoints\"|\"join\"|\"cutPath\"|\"convertToCorner\"|\"convertToSmooth\"|\"group\"|\"makeClippingMask\"|\"unite\"|\"expand\"|\"editClippingPath\"|\"releaseClippingMask\"|\"ungroup\"|\"isolate\"|\"editPath\"|\"releaseCompoundPath\"|\"createOutlines\"|\"convertToPointType\"|\"convertToAreaType\"|\"typeOnPathOptions\"|\"centerOnTop\"|\"centerOnBottom\"|\"dynamicText\"|\"offsetPath\"|\"simplify\"|\"smooth\"|\"duplicate\"|\"drawPencil\"|\"placeImage\"|\"fidelity\"|\"smoothToolOptions\"|\"resizeArtboard\"|\"duplicateArtboards\"|\"rearrangeArtboards\"|\"exportArtboards\"|\"fill\"|\"stroke\"|\"recolor\"|\"lock\"|\"shapeProperties\", visible?: bool} show (true), hide (false) or toggle (omitted) one of the Contextual Task Bar's actions or chips, as the bar's More Options › Bar Actions does; an action that is off stays out of the bar and out of More Options, and turning one off changes only the bar; `join` is both Connect and Join; every action starts on; kept with the preferences and with the workspace; another action, or a `visible` that is not true or false, is an error and changes nothing; returns {action, visible}",
|
||||
"{action: \"imageTrace\"|\"cropImage\"|\"removeBackground\"|\"removeAnchorPoints\"|\"join\"|\"cutPath\"|\"convertToCorner\"|\"convertToSmooth\"|\"group\"|\"makeClippingMask\"|\"unite\"|\"expand\"|\"editClippingPath\"|\"releaseClippingMask\"|\"ungroup\"|\"isolate\"|\"editPath\"|\"releaseCompoundPath\"|\"createOutlines\"|\"convertToPointType\"|\"convertToAreaType\"|\"typeOnPathOptions\"|\"centerOnTop\"|\"centerOnBottom\"|\"dynamicText\"|\"offsetPath\"|\"simplify\"|\"smooth\"|\"duplicate\"|\"drawPencil\"|\"placeImage\"|\"fidelity\"|\"smoothToolOptions\"|\"resizeArtboard\"|\"duplicateArtboards\"|\"rearrangeArtboards\"|\"exportArtboards\"|\"fill\"|\"stroke\"|\"recolor\"|\"lock\"|\"shapeProperties\", visible?: bool} show (true), hide (false) or toggle (omitted or null) one of the Contextual Task Bar's actions or chips, as the bar's More Options › Bar Actions does; an action that is off stays out of the bar and out of More Options, and turning one off changes only the bar; `join` is both Connect and Join; every action starts on; kept with the preferences and with the workspace; another action, or a `visible` that is not true, false or null, is an error and changes nothing; returns {action, visible}",
|
||||
),
|
||||
(
|
||||
"window.taskBar.resetActions",
|
||||
|
||||
@@ -705,11 +705,17 @@ fn action_id(cmd: &str, params: &serde_json::Value) -> Option<&'static str> {
|
||||
|
||||
/// 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 (`…` or
|
||||
/// `...`).
|
||||
/// `...`), in whichever order they come.
|
||||
pub(crate) fn bar_action_name(label: &str) -> &str {
|
||||
let label = label.trim_end();
|
||||
let label = label.strip_suffix("...").unwrap_or(label);
|
||||
label.trim_end_matches([':', ':', '…']).trim_end()
|
||||
let mut name = label.trim_end();
|
||||
loop {
|
||||
let rest = name.trim_end_matches([':', ':', '…']);
|
||||
let rest = rest.strip_suffix("...").unwrap_or(rest).trim_end();
|
||||
if rest == name {
|
||||
return name;
|
||||
}
|
||||
name = rest;
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads the Contextual Task Bar's actions and chips that are off, as kept in the preferences. Ids
|
||||
|
||||
@@ -640,15 +640,7 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
Ok(Value::Null)
|
||||
}
|
||||
// More Options › Bar Actions: one of the bar's actions or chips on or off.
|
||||
// A `visible` of null is an error, as any other value that is not true or false is; only
|
||||
// an omitted one toggles.
|
||||
"window.taskBar.actions" => match (
|
||||
s("action").filter(|a| crate::canvas::is_task_bar_action(a)),
|
||||
match p.get("visible") {
|
||||
Some(Value::Null) => Err("`visible` must be true or false".to_string()),
|
||||
_ => opt_bool(p, "visible"),
|
||||
},
|
||||
) {
|
||||
"window.taskBar.actions" => match (s("action").filter(|a| crate::canvas::is_task_bar_action(a)), opt_bool(p, "visible")) {
|
||||
(None, _) => {
|
||||
let ids = crate::canvas::TASK_BAR_ACTIONS.iter().map(|a| a.0).chain(crate::canvas::TASK_BAR_CHIPS);
|
||||
Err(format!("`action` must be one of {}", ids.collect::<Vec<_>>().join(", ")))
|
||||
|
||||
@@ -680,7 +680,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"window.taskBar.actions",
|
||||
"Bar Actions",
|
||||
"",
|
||||
"{action: \"imageTrace\"|\"cropImage\"|\"removeBackground\"|\"removeAnchorPoints\"|\"join\"|\"cutPath\"|\"convertToCorner\"|\"convertToSmooth\"|\"group\"|\"makeClippingMask\"|\"unite\"|\"expand\"|\"editClippingPath\"|\"releaseClippingMask\"|\"ungroup\"|\"isolate\"|\"editPath\"|\"releaseCompoundPath\"|\"createOutlines\"|\"convertToPointType\"|\"convertToAreaType\"|\"typeOnPathOptions\"|\"centerOnTop\"|\"centerOnBottom\"|\"dynamicText\"|\"offsetPath\"|\"simplify\"|\"smooth\"|\"duplicate\"|\"drawPencil\"|\"placeImage\"|\"fidelity\"|\"smoothToolOptions\"|\"resizeArtboard\"|\"duplicateArtboards\"|\"rearrangeArtboards\"|\"exportArtboards\"|\"fill\"|\"stroke\"|\"recolor\"|\"lock\"|\"shapeProperties\", visible?: bool} show (true), hide (false) or toggle (omitted) one of the Contextual Task Bar's actions or chips, as the bar's More Options › Bar Actions does; an action that is off stays out of the bar and out of More Options, and turning one off changes only the bar; `join` is both Connect and Join; every action starts on; kept with the preferences and with the workspace; another action, or a `visible` that is not true or false, is an error and changes nothing; returns {action, visible}",
|
||||
"{action: \"imageTrace\"|\"cropImage\"|\"removeBackground\"|\"removeAnchorPoints\"|\"join\"|\"cutPath\"|\"convertToCorner\"|\"convertToSmooth\"|\"group\"|\"makeClippingMask\"|\"unite\"|\"expand\"|\"editClippingPath\"|\"releaseClippingMask\"|\"ungroup\"|\"isolate\"|\"editPath\"|\"releaseCompoundPath\"|\"createOutlines\"|\"convertToPointType\"|\"convertToAreaType\"|\"typeOnPathOptions\"|\"centerOnTop\"|\"centerOnBottom\"|\"dynamicText\"|\"offsetPath\"|\"simplify\"|\"smooth\"|\"duplicate\"|\"drawPencil\"|\"placeImage\"|\"fidelity\"|\"smoothToolOptions\"|\"resizeArtboard\"|\"duplicateArtboards\"|\"rearrangeArtboards\"|\"exportArtboards\"|\"fill\"|\"stroke\"|\"recolor\"|\"lock\"|\"shapeProperties\", visible?: bool} show (true), hide (false) or toggle (omitted or null) one of the Contextual Task Bar's actions or chips, as the bar's More Options › Bar Actions does; an action that is off stays out of the bar and out of More Options, and turning one off changes only the bar; `join` is both Connect and Join; every action starts on; kept with the preferences and with the workspace; another action, or a `visible` that is not true, false or null, is an error and changes nothing; returns {action, visible}",
|
||||
),
|
||||
(
|
||||
"window.taskBar.resetActions",
|
||||
|
||||
@@ -1608,6 +1608,9 @@ fn an_action_turned_off_leaves_the_bar_and_stays_in_its_menu() {
|
||||
assert_eq!(app.run("window.taskBar.actions", json!({"action": "offsetPath"})).unwrap(), json!({"action": "offsetPath", "visible": true}));
|
||||
let (_, texts) = bar(&mut app);
|
||||
assert!(has(&texts, "Offset Path"), "{texts:?}");
|
||||
// A `visible` of null counts as omitted and toggles too.
|
||||
let r = app.run("window.taskBar.actions", json!({"action": "offsetPath", "visible": null})).unwrap();
|
||||
assert_eq!(r, json!({"action": "offsetPath", "visible": false}));
|
||||
}
|
||||
|
||||
/// The Fill, Stroke, Recolor Artwork, Lock and Shape Properties chips each turn off on their own:
|
||||
@@ -1677,13 +1680,7 @@ fn bar_action_ids_are_distinct() {
|
||||
fn bar_actions_refuse_bad_params() {
|
||||
let mut app = app();
|
||||
show_action(&mut app, "group", false);
|
||||
for p in [
|
||||
json!({"action": "teleport"}),
|
||||
json!({}),
|
||||
json!({"action": 3}),
|
||||
json!({"action": "unite", "visible": "yes"}),
|
||||
json!({"action": "unite", "visible": null}),
|
||||
] {
|
||||
for p in [json!({"action": "teleport"}), json!({}), json!({"action": 3}), json!({"action": "unite", "visible": "yes"})] {
|
||||
assert!(app.run("window.taskBar.actions", p.clone()).is_err(), "{p}");
|
||||
}
|
||||
let err = app.run("window.taskBar.actions", json!({"action": "teleport"})).unwrap_err();
|
||||
@@ -2029,4 +2026,16 @@ fn bar_actions_list_names_without_a_colon_or_an_ellipsis() {
|
||||
assert_eq!(canvas::bar_action_name("Duplicate"), "Duplicate");
|
||||
assert_eq!(canvas::bar_action_name("Tool Options..."), "Tool Options");
|
||||
assert_eq!(canvas::bar_action_name("Offset Path."), "Offset Path.");
|
||||
// The colon and the ellipsis go in either order, with or without a space between them.
|
||||
for label in [
|
||||
"Tool Options...:",
|
||||
"Tool Options... :",
|
||||
"Tool Options: ...",
|
||||
"Tool Options …:",
|
||||
"Tool Options… :",
|
||||
"Tool Options…\u{a0}:",
|
||||
"Tool Options...\u{202f}:",
|
||||
] {
|
||||
assert_eq!(canvas::bar_action_name(label), "Tool Options", "{label:?}");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -8192,8 +8192,9 @@ changes only the bar. With every action and chip it would offer off, the bar sti
|
||||
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
|
||||
`visible` that is not true or false fails with "`visible` must be true or false"; either leaves every action as it is.
|
||||
is dropped when they are read. A `visible` of null toggles, as an omitted one does. Another `action`, or none, fails
|
||||
with "`action` must be one of …", and a `visible` that is not true, false or null fails with "`visible` must be true
|
||||
or false"; either leaves every action as it is.
|
||||
`window.taskBar.resetActions {}` (More Options › Reset Bar Actions) turns every action and chip on again and returns
|
||||
the ids it turned on. Choosing the bar's actions is VectorCraft's own.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user