From 324931ed0464cb55fd65fb86a1fcca7392cdd722 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 14:06:35 -0800 Subject: [PATCH] Graphic Styles: built-in library styles show in the UI language List rows, tooltips and Find in a built-in graphic style library use the translated style name, as brush libraries do. User Defined and loaded libraries keep their style names, and clicks and commands still use the stored name. --- crates/ui-egui/src/panels/graphic_styles.rs | 10 ++++++-- .../src/panels/tests_style_libraries.rs | 23 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/graphic_styles.rs b/crates/ui-egui/src/panels/graphic_styles.rs index 2696c78c08..f033d64825 100644 --- a/crates/ui-egui/src/panels/graphic_styles.rs +++ b/crates/ui-egui/src/panels/graphic_styles.rs @@ -920,10 +920,16 @@ impl LibraryKind for GraphicStyleLibraries { fn path(app: &VectorcraftApp, id: &str) -> Option { app.session.style_libraries.path(id).map(str::to_string) } - fn rows<'a>(lib: &'a Self::Lib, _: &str, query: &str) -> Vec> { - let found = |n: &str| query.is_empty() || n.to_lowercase().contains(query); + /// Find matches a style's name as shown and as stored. + fn rows<'a>(lib: &'a Self::Lib, id: &str, query: &str) -> Vec> { + let found = |n: &str| query.is_empty() || n.to_lowercase().contains(query) || Self::label(id, n).to_lowercase().contains(query); lib.iter().filter(|s| found(&s.style().name)).map(|s| Row { name: &s.style().name, item: Some(s) }).collect() } + /// A built-in library's style in the UI language; a User Defined or loaded library's style as + /// it is named. + fn label<'a>(id: &str, name: &'a str) -> &'a str { + super::label_or_name(name, STYLE_LIBRARIES.iter().any(|b| b.id == id)) + } /// The style on the Graphic Styles panel's preview shape. fn draw(app: &VectorcraftApp, ui: &Ui, r: Rect, s: &LibStyle, selected: bool, hovered: bool) { let paints = Paints { patterns: &s.lib.patterns, brushes: None }; diff --git a/crates/ui-egui/src/panels/tests_style_libraries.rs b/crates/ui-egui/src/panels/tests_style_libraries.rs index fa8c33cccd..fa9046eb74 100644 --- a/crates/ui-egui/src/panels/tests_style_libraries.rs +++ b/crates/ui-egui/src/panels/tests_style_libraries.rs @@ -143,6 +143,29 @@ fn paper_cutouts_opens_from_the_window_menu_and_applies_a_layered_style() { assert_eq!(appearance.effects[0].id, "stylize.dropShadow"); } +/// A built-in library's list rows and Find field use the UI language; a user library's styles keep +/// their names, and clicks still name the stored style. +#[test] +fn built_in_style_names_show_in_the_ui_language() { + let mut app = app(); + let ctx = context(); + app.run("window.graphicStyleLibrary", json!({"library": "paper-cutouts"})).unwrap(); + app.run("ui.libraryPanel", json!({"panel": "library:graphicStyles:paper-cutouts", "view": "largeList"})).unwrap(); + crate::i18n::set_current(crate::i18n::Lang::from_code("fr").unwrap()); + let mut texts = vec![]; + for t in [0.0, 0.25] { + texts = frame(&ctx, vec![], Modifiers::NONE, t, |ui| library_panel::show_window(&mut app, ui.ctx())); + } + let (_, lib) = GraphicStyleLibraries::get(&app, "paper-cutouts").unwrap(); + let found: Vec<&str> = GraphicStyleLibraries::rows(&lib, "paper-cutouts", "corail").iter().map(|r| r.name).collect(); + let user = GraphicStyleLibraries::label("user/Mine", "Coral Layers").to_string(); + crate::i18n::set_current(crate::i18n::Lang::EN); + assert!(texts.iter().any(|t| t == "Couches corail"), "{texts:?}"); + assert!(!texts.iter().any(|t| t == "Coral Layers"), "{texts:?}"); + assert_eq!(found, ["Coral Layers"]); + assert_eq!(user, "Coral Layers"); +} + #[test] fn the_window_menu_and_the_panel_open_every_library() { let mut app = app();