Merge remote-tracking branch 'origin/main' into fix/ruler-double-click-guide

This commit is contained in:
Taha-Mahmoodi
2026-11-11 13:59:31 +04:30
5 changed files with 34 additions and 4 deletions
+1
View File
@@ -233,6 +233,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) {
for (label, icon, cmd, params) in &items {
let galley = ui.painter().layout_no_wrap(label.to_string(), egui::FontId::proportional(13.0), t.text_strong);
let (r, resp) = ui.allocate_exact_size(vec2(galley.size().x + 38.0, 30.0), Sense::click());
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, *label));
if resp.hovered() {
ui.painter().rect_filled(r, CornerRadius::same(3), t.hover);
}
+14
View File
@@ -9198,6 +9198,20 @@ fn the_task_bar_offers_the_artboard_tools_actions() {
assert_eq!(names(&mut app), ["Resize", "Duplicate", "Export"]);
}
/// Screen readers name the Contextual Task Bar's text buttons by their labels.
#[test]
fn screen_readers_name_the_task_bars_text_buttons() {
use crate::widgets::accessibility_tests::{named, tree};
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
app.session.execute("shape.rectangle", &json!({"x": 180, "y": 130, "width": 40, "height": 40})).unwrap();
app.select_tool("selection");
let tree = tree(|ui| show(&mut app, ui));
for label in ["Edit Path", "Offset Path", "Simplify", "Duplicate"] {
assert_eq!(named(&tree, label).role(), egui::accesskit::Role::Button, "{label}");
}
}
/// A selected group's Contextual Task Bar offers Ungroup and Isolate. While an opacity mask is
/// edited, when Enter Isolation Mode is off, a group in the mask art gets Ungroup without Isolate.
#[test]
+1 -1
View File
@@ -1536,7 +1536,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
crate::scripts_menu::COMMAND,
"Run Script",
"",
"{path: a script's path as script.listInstalled gives it} run a script of the Scripts folder, as its File › Scripts item does (script.run with the file's text, under the file's name), without the warning Other Script… shows; a file that is no longer a .js or .jsx file in the folder or a subfolder at most 4 levels below it, or that is or lies behind a link or is hidden, is not run, and the menu's listing is read again",
"{path: a script's path as script.listInstalled gives it} run a script of the Scripts folder, as its File › Scripts item does (the script is checked again, then script.run runs it by its path, so its #include lines and $.evalFile read beside it), without the warning Other Script… shows; a file that is no longer a .js or .jsx file in the folder or a subfolder at most 4 levels below it, or that is or lies behind a link or is hidden, is not run, and the menu's listing is read again",
),
(
"ui.checkScript",
+4 -3
View File
@@ -242,13 +242,14 @@ pub fn readable(p: &Value) -> bool {
}
/// `ui.runInstalledScript {path}`: run the listed script at `path`. A script that is no longer in
/// the folder is not run, and the folder is read again.
/// the folder is not run, and the folder is read again. The script runs from its file, so its
/// `#include` lines and `$.evalFile` read beside it.
pub fn run(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
let path = p.get("path").and_then(Value::as_str).ok_or("missing `path`")?;
let source = app.session.installed_script(path).map_err(|e| {
app.session.installed_script(path).map_err(|e| {
let ctx = app.ui_ctx.clone();
refresh(app, ctx.as_ref());
e.to_string()
})?;
app.run("script.run", json!({"source": source, "name": vectorcraft_engine::cmd::fileio::file_name(path)}))
app.run("script.run", json!({ "path": path }))
}
+14
View File
@@ -142,6 +142,20 @@ fn a_script_runs_its_own_file_whatever_its_name_ends_with() {
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn a_listed_script_reads_its_included_files_and_runs_files_beside_it() {
let dir = folder("include");
let mut app = app(&dir);
write(&dir, "lib/two.jsxinc", DRAW);
write(&dir, "lib/one.js", "vc.run('shape.rectangle', {x:40,y:0,width:10,height:10});");
let main = write(&dir, "Main.jsx", "#include \"lib/two.jsxinc\"\n$.evalFile('lib/one.js');\n");
read(&app);
menus::run_ui_command(&mut app, scripts_menu::COMMAND, &json!({ "path": main })).unwrap().unwrap();
finish(&mut app);
assert_eq!(objects(&app), 3, "{}", app.ui.status);
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn script_and_folder_names_are_shown_as_they_are_in_every_language() {
let dir = folder("language");