From e68aa17f0a838373f40b63a32391fbc4ae798c47 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 22:46:00 -0800 Subject: [PATCH 1/3] App bar: a search field in place of the search icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The magnifier at the right of the app bar becomes a field showing the magnifier, "Search commands" and the Help › Search Commands… shortcut, or no shortcut when it is cleared or too long to fit. A click on it, or Enter or Space with the keyboard focus on it, toggles the command palette as the shortcut does, and the palette's popup holds the text field. While a dialog is open the field and the icon do nothing, as the shortcut does; the icon used to open the palette over a dialog. Screen readers name the field "Search commands" with the shortcut, and its tooltip stays "Search commands and tools". As the bar narrows, the community button goes first, then Explore tutorials, then the field becomes the 28-point icon, then the workspace switcher narrows to 64 points, then the icon goes. Safe Mode's label keeps its room first. The order is the same as before, with the field's collapse to the icon as a new step after Explore tutorials goes. --- crates/ui-egui/src/chrome.rs | 183 +++++++++-- crates/ui-egui/src/chrome/tests.rs | 381 +++++++++++++++++++++++ crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/gu.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/panels/learn/tests.rs | 6 +- docs/development.md | 2 +- docs/mcp.md | 2 +- docs/target-app-parity.md | 3 +- 34 files changed, 574 insertions(+), 31 deletions(-) diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 7e48fc244e..d10d320ad9 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -82,10 +82,8 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { ui.add_space(2.0); // With the macOS menu bar the menus are at the top of the screen instead. let menus_end = if app.services.native_menu.is_some() { ui.cursor().min.x } else { menus::menu_bar(app, ui) }; - // The right-side group fills the space after the menus from the right; when it runs - // short, Discord goes first (it is also under Help), then Explore tutorials (also - // Window › Learn), then the search icon (the palette stays under its shortcut), then - // the workspace switcher narrows. + // The right-side group fills the space after the menus from the right, in the order + // [`fit_right_group`] gives. let full = ui.max_rect(); let right_edge = if captions_right > 0.0 { full.right() - captions_right - 10.0 } else { full.right() }; let right = egui::Rect::from_min_max(egui::pos2(menus_end + 8.0, full.top()), egui::pos2(right_edge, full.bottom())); @@ -97,21 +95,22 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { let text = ui.painter().layout_no_wrap(label.text().to_string(), egui::FontId::proportional(12.0), t.warning); text.size().x + 2.0 * ui.spacing().button_padding.x + 8.0 + ui.spacing().item_spacing.x }); - let room = (right.width() - safe_w).max(0.0); - let switcher = safe.is_none() || room >= 64.0 + 8.0; // Built-in workspace names translate; the user's own stay as typed. let ws_name = if crate::workspaces::is_builtin(&app.ui.workspace) { tl!(&app.ui.workspace).to_string() } else { app.ui.workspace.clone() }; let ws = ui.painter().layout_no_wrap(ws_name, egui::FontId::proportional(12.0), t.text); - let ws_w = (ws.size().x + 36.0).clamp(112.0, 190.0); - let gap = ui.spacing().item_spacing.x; - // The search icon, as in PhotoCraft: shown while a minimal switcher fits beside it. - let icon = 28.0; - let search = switcher && room >= 64.0 + 8.0 + gap + icon; - let ws_w = ws_w.min(room - 8.0 - gap - if search { icon } else { 0.0 }).max(64.0); - // Explore tutorials, beside the search icon, opens the Learn panel. - let learn = search && room >= ws_w + 8.0 + 2.0 * (gap + icon); - let discord = learn && room >= ws_w + 8.0 + 2.0 * (gap + icon) + 10.0 + gap + crate::community::discord_width(ui, false); + let shortcut = menus::shortcut_of("help.commandPalette").map(menus::shown_shortcut); + let field = SearchField::new(ui, &t, shortcut); + let fit = fit_right_group(&RightWidths { + room: (right.width() - safe_w).max(0.0), + safe_mode: safe.is_some(), + switcher: (ws.size().x + 36.0).clamp(112.0, 190.0), + field: field.width, + icon: BAR_ICON, + gap: ui.spacing().item_spacing.x, + discord: crate::community::discord_width(ui, false), + }); + let (switcher, ws_w, learn, discord) = (fit.switcher, fit.switcher_w, fit.learn, fit.discord); let mut rui = ui.new_child(egui::UiBuilder::new().max_rect(right).layout(egui::Layout::right_to_left(egui::Align::Center))); let ui = &mut rui; // Workspace switcher: shows the current workspace, opens Window → Workspace. @@ -131,19 +130,26 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { ui.add_space(8.0); } // Search → command palette (its shortcut opens it too). - if search { - let tip = match menus::shortcut_of("help.commandPalette") { - Some(sc) => format!("{} ({})", tl!("Search commands and tools"), menus::shown_shortcut(sc)), - None => tl!("Search commands and tools").to_string(), - }; - if widgets::icon_button(ui, "search", &tip, app.ui.palette_open, icon).clicked() { - app.ui.palette_open = !app.ui.palette_open; - app.ui.palette_query.clear(); - } + let with_shortcut = |text: &str| match &field.shortcut { + Some(sc) => format!("{text} ({sc})"), + None => text.to_string(), + }; + let tip = with_shortcut(tl!("Search commands and tools")); + let name = with_shortcut(tl!("Search commands")); + let clicked = match fit.search { + Search::Field => field.show(ui, &t, &name, &tip, app.ui.palette_open).clicked(), + Search::Icon => widgets::icon_button(ui, "search", &tip, app.ui.palette_open, BAR_ICON).clicked(), + Search::Hidden => false, + }; + // The field and the icon toggle the palette as its shortcut does, and like the shortcut + // they do nothing while a dialog is open. + if clicked && app.ui.dialog.is_none() { + app.ui.palette_open = !app.ui.palette_open; + app.ui.palette_query.clear(); } if learn { let shown = crate::panels::learn::visible(&app.ui); - if widgets::icon_button(ui, "graduation-cap", tl!("Explore tutorials"), shown, icon).clicked() + if widgets::icon_button(ui, "graduation-cap", tl!("Explore tutorials"), shown, BAR_ICON).clicked() && let Err(e) = app.run("window.learn", json!({})) { app.ui.status = e; @@ -168,6 +174,133 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { } } +/// The side of the app bar's square icon buttons (the search icon, Explore tutorials). +const BAR_ICON: f32 = 28.0; +/// The narrowest the workspace switcher gets. +const MIN_SWITCHER: f32 = 64.0; + +/// How the app bar shows the search that opens the command palette. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Search { + /// A field with the magnifier, "Search commands" and the palette's shortcut. + Field, + /// The magnifier alone. + Icon, + /// Not in the bar; the palette stays under its shortcut and Help › Search Commands…. + Hidden, +} + +/// The widths [`fit_right_group`] fits into `room`, in points. +#[derive(Clone, Copy, Debug)] +struct RightWidths { + /// The room after the menus, less the Safe Mode label's. + room: f32, + safe_mode: bool, + /// The workspace switcher's full width. + switcher: f32, + /// The search field's width. + field: f32, + icon: f32, + gap: f32, + discord: f32, +} + +/// What the right-hand group of the app bar shows. +#[derive(Clone, Copy, Debug, PartialEq)] +struct RightGroup { + switcher: bool, + switcher_w: f32, + search: Search, + learn: bool, + discord: bool, +} + +/// The right-hand group for the room it has. As the room runs short, the community button goes first +/// (it is also under Help), then Explore tutorials (also Window › Learn), then the search field becomes the +/// search icon, then the workspace switcher narrows to [`MIN_SWITCHER`], then the icon goes. In Safe +/// Mode the label's width is taken first, and the switcher (also under Window › Workspace) goes when +/// a minimal one does not fit. +fn fit_right_group(w: &RightWidths) -> RightGroup { + let room = w.room; + let switcher = !w.safe_mode || room >= MIN_SWITCHER + 8.0; + let icon = switcher && room >= MIN_SWITCHER + 8.0 + w.gap + w.icon; + let field = icon && room >= w.switcher + 8.0 + w.gap + w.field; + let search = if field { + Search::Field + } else if icon { + Search::Icon + } else { + Search::Hidden + }; + let search_w = match search { + Search::Field => w.gap + w.field, + Search::Icon => w.gap + w.icon, + Search::Hidden => 0.0, + }; + let switcher_w = w.switcher.min(room - 8.0 - search_w).max(MIN_SWITCHER); + let learn_end = switcher_w + 8.0 + search_w + w.gap + w.icon; + let learn = field && room >= learn_end; + let discord = learn && room >= learn_end + 10.0 + w.gap + w.discord; + RightGroup { switcher, switcher_w, search, learn, discord } +} + +/// The app bar's search field: a button drawn as a field. The command palette's popup holds the +/// only text field. +struct SearchField { + hint: Arc, + /// The palette's shortcut as the menus show it; none when the user cleared it. + shortcut: Option, + key: Option>, + width: f32, +} + +impl SearchField { + /// Space from the field's left edge to the hint text (the magnifier sits in it). + const TEXT_LEFT: f32 = 26.0; + /// The widest the field gets. + const MAX_WIDTH: f32 = 220.0; + + fn new(ui: &Ui, t: &Tokens, shortcut: Option) -> SearchField { + let hint = ui.painter().layout_no_wrap(tl!("Search commands").to_string(), egui::FontId::proportional(12.0), t.text_dim); + let text_w = Self::TEXT_LEFT + hint.size().x + 8.0; + // A shortcut that leaves no room for the hint in the widest field is left to the tooltip. + let key = shortcut + .as_ref() + .map(|s| ui.painter().layout_no_wrap(s.clone(), egui::FontId::proportional(11.0), t.text_dim)) + .filter(|k| text_w + 12.0 + k.size().x <= Self::MAX_WIDTH); + let key_w = key.as_ref().map_or(0.0, |k| 12.0 + k.size().x); + let width = (text_w + key_w + 24.0).clamp(120.0, Self::MAX_WIDTH); + SearchField { hint, shortcut, key, width } + } + + /// Draws the field. A click, or Enter or Space with the keyboard on it, clicks it. Screen + /// readers get a button called `name`, and hovering it shows `tip`. + fn show(self, ui: &mut Ui, t: &Tokens, name: &str, tip: &str, open: bool) -> egui::Response { + let (r, resp) = ui.allocate_exact_size(vec2(self.width, WIDGET_H), Sense::click()); + let fill = if open { + t.tool_active + } else if resp.hovered() { + t.hover + } else { + t.input + }; + let border = if resp.has_focus() { t.accent } else { t.input_border }; + ui.painter().rect(r, CornerRadius::same(4), fill, Stroke::new(1.0, border), egui::StrokeKind::Inside); + icons::paint(ui, "search", egui::Rect::from_center_size(r.left_center() + vec2(14.0, 0.0), vec2(14.0, 14.0)), t.icon); + let mut text_right = r.right() - 8.0; + if let Some(key) = self.key { + let at = egui::pos2(text_right - key.size().x, r.center().y - key.size().y / 2.0); + text_right = at.x - 12.0; + ui.painter().with_clip_rect(r).galley(at, key, t.text_dim); + } + let clip = egui::Rect::from_min_max(r.min, egui::pos2(text_right.max(r.left()), r.bottom())); + let at = egui::pos2(r.left() + Self::TEXT_LEFT, r.center().y - self.hint.size().y / 2.0); + ui.painter().with_clip_rect(clip).galley(at, self.hint, t.text_dim); + resp.widget_info(|| widgets::icon_button_info(ui.is_enabled(), open, name)); + resp.on_hover_text(tip) + } +} + /// Whether the window shows the system's title bar instead of the app drawing its own /// ([`VectorcraftApp::desktop_frame`]): Windows with Preferences › User Interface › System Title /// Bar, and Linux whenever the desktop draws the frame, with or without the preference. The diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index f1c63eafb4..f0ac33613b 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -159,6 +159,387 @@ fn hints_name_keys_as_the_menus_do() { } } +/// The widths of the app bar's right-hand group used by the fitting tests. +fn right_widths(room: f32, safe_mode: bool) -> super::RightWidths { + super::RightWidths { room, safe_mode, switcher: 150.0, field: 170.0, icon: 28.0, gap: 8.0, discord: 80.0 } +} + +/// What the group shows, in words, with the switcher's width as full, narrower or minimal. +fn right_stage(g: &super::RightGroup) -> String { + let switcher = match g.switcher_w { + _ if !g.switcher => "no switcher", + w if w >= 150.0 => "full switcher", + w if w > super::MIN_SWITCHER => "narrower switcher", + _ => "minimal switcher", + }; + format!("discord {}, learn {}, {:?}, {switcher}", g.discord, g.learn, g.search) +} + +/// As the app bar's room runs short, Discord goes first, then Explore tutorials, then the search +/// field becomes the icon, then the workspace switcher narrows to its minimum, then the icon goes. +/// Whatever shows fits in the room, down to the minimal switcher alone. +#[test] +fn the_app_bar_gives_up_its_right_hand_controls_in_order() { + let mut stages: Vec = Vec::new(); + for room in (0..=700).rev().map(|r| r as f32) { + let w = right_widths(room, false); + let g = super::fit_right_group(&w); + let stage = right_stage(&g); + if stages.last() != Some(&stage) { + stages.push(stage); + } + let search = match g.search { + super::Search::Field => w.gap + w.field, + super::Search::Icon => w.gap + w.icon, + super::Search::Hidden => 0.0, + }; + let learn = if g.learn { w.gap + w.icon } else { 0.0 }; + let discord = if g.discord { 10.0 + w.gap + w.discord } else { 0.0 }; + let used = g.switcher_w + 8.0 + search + learn + discord; + assert!(used <= room || g.switcher_w == super::MIN_SWITCHER && g.search == super::Search::Hidden, "{room}: {g:?} needs {used}"); + } + assert_eq!( + stages, + [ + "discord true, learn true, Field, full switcher", + "discord false, learn true, Field, full switcher", + "discord false, learn false, Field, full switcher", + "discord false, learn false, Icon, full switcher", + "discord false, learn false, Icon, narrower switcher", + "discord false, learn false, Icon, minimal switcher", + // Once the icon has gone, the switcher takes the room it leaves. + "discord false, learn false, Hidden, narrower switcher", + "discord false, learn false, Hidden, minimal switcher", + ] + ); + // In Safe Mode the label's width is taken first (not counted in `room`), and the switcher goes + // when a minimal one does not fit. + let safe = |room| right_stage(&super::fit_right_group(&right_widths(room, true))); + assert_eq!(safe(700.0), "discord true, learn true, Field, full switcher"); + assert_eq!(safe(72.0), "discord false, learn false, Hidden, minimal switcher"); + assert_eq!(safe(71.0), "discord false, learn false, Hidden, no switcher"); +} + +/// What screen readers call the app bar's search field, before its shortcut, and how the collapsed +/// icon's name starts. +const SEARCH_NAME: &str = "Search commands"; + +/// A native menu bar that draws nothing. +struct NoMenus; +impl crate::native_menu::Backend for NoMenus { + fn sync(&mut self, _: &crate::native_menu::MenuBar) {} + fn drain(&mut self) -> Vec { + Vec::new() + } +} + +/// The app bar drawn alone, `width` points wide. +struct AppBar { + app: crate::VectorcraftApp, + ctx: egui::Context, + width: f32, + /// Handle the app's keys before the bar and show the command palette after it, as the app's + /// frame does. Off, Tab moves the keyboard focus through the bar's controls, as with a screen + /// reader. + keys: bool, +} + +/// The app bar's search control, as a screen reader and the painter see it. +#[derive(Debug)] +struct SearchSeen { + name: String, + rect: egui::Rect, + texts: Vec, +} + +impl AppBar { + fn new(width: f32) -> AppBar { + crate::i18n::set_current(crate::i18n::Lang::EN); + let ctx = egui::Context::default(); + ctx.enable_accesskit(); + crate::theme::install_fonts(&ctx); + let app = crate::VectorcraftApp::new(Session::new(), Default::default()); + crate::shortcut_editor::sync(&app.ui); + AppBar { app, ctx, width, keys: false } + } + + /// One frame; the accessibility nodes and the texts painted, with where each is. + fn frame(&mut self, events: Vec) -> (Vec, Vec<(String, egui::Rect)>) { + fn walk(s: &egui::Shape, v: &mut Vec<(String, egui::Rect)>) { + match s { + egui::Shape::Text(t) => v.push((t.galley.text().to_string(), egui::Rect::from_min_size(t.pos, t.galley.size()))), + egui::Shape::Vec(s) => s.iter().for_each(|s| walk(s, v)), + _ => {} + } + } + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(self.width, 600.0)); + let (app, keys) = (&mut self.app, self.keys); + let mut out = self.ctx.run_ui(egui::RawInput { events, screen_rect: Some(screen), ..Default::default() }, |ui| { + if keys { + crate::shortcuts::handle(app, ui.ctx()); + } + super::app_bar(app, ui); + if keys { + crate::palette::show(app, ui.ctx()); + } + }); + out.textures_delta.clear(); + let mut texts = vec![]; + out.shapes.iter().for_each(|c| walk(&c.shape, &mut texts)); + (out.platform_output.accesskit_update.map(|u| u.nodes.into_iter().map(|(_, n)| n).collect()).unwrap_or_default(), texts) + } + + /// The search control after two frames, if the bar shows it. + fn search(&mut self) -> Option { + self.frame(vec![]); + let (nodes, texts) = self.frame(vec![]); + let node = nodes.iter().find(|n| n.label().is_some_and(|l| l.starts_with(SEARCH_NAME)))?; + let b = node.bounds()?; + let rect = egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32)); + // Without the icon set loaded, a test frame draws an icon as a warning sign; leave it out. + let mut texts: Vec<(String, egui::Rect)> = + texts.into_iter().filter(|(t, r)| rect.expand(0.5).contains_rect(*r) && !t.starts_with('\u{26a0}')).collect(); + texts.sort_by(|a, b| a.1.left().total_cmp(&b.1.left())); + let texts = texts.into_iter().map(|(t, _)| t).collect(); + Some(SearchSeen { name: node.label().unwrap_or_default().to_string(), rect, texts }) + } + + /// Where the in-window menus end: the right edge of the Help menu's title, if the bar shows it. + fn menus_end(&mut self) -> Option { + self.frame(vec![]); + let nodes = self.frame(vec![]).0; + nodes.iter().filter(|n| n.label() == Some("Help")).filter_map(|n| n.bounds()).map(|b| b.x1 as f32).reduce(f32::max) + } + + fn has(&mut self, name: &str) -> bool { + self.frame(vec![]); + self.frame(vec![]).0.iter().any(|n| n.label() == Some(name)) + } + + fn click(&mut self, at: egui::Pos2) { + let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + self.frame(vec![egui::Event::PointerMoved(at), press(true)]); + self.frame(vec![press(false)]); + } + + /// Whether the widget at `rect` has the keyboard focus. + fn focused_at(&self, rect: egui::Rect) -> bool { + self.ctx.memory(|m| m.focused()).and_then(|id| self.ctx.read_response(id)).is_some_and(|r| r.rect == rect) + } + + /// A press and release of `key`; Space also types a space, as a keyboard does. + fn key(&mut self, key: egui::Key) { + let event = |pressed| egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: Default::default() }; + let mut press = vec![event(true)]; + if key == egui::Key::Space { + press.push(egui::Event::Text(" ".into())); + } + self.frame(press); + self.frame(vec![event(false)]); + } +} + +/// A wide app bar shows a search field with the palette's shortcut in it, and screen readers get a +/// button named [`SEARCH_NAME`] with the shortcut. +#[test] +fn a_wide_app_bar_shows_a_search_field_with_the_palette_shortcut() { + let mut bar = AppBar::new(1400.0); + let shortcut = crate::menus::shown_shortcut("Cmd+Shift+/"); + let seen = bar.search().expect("the search field shows"); + assert_eq!(seen.name, format!("{SEARCH_NAME} ({shortcut})")); + assert!(seen.rect.width() >= 120.0 && seen.rect.width() <= 220.0, "a field, not the 28-point icon: {seen:?}"); + assert_eq!(seen.texts, [SEARCH_NAME.to_string(), shortcut], "{seen:?}"); + assert!(bar.has("Explore tutorials")); +} + +/// The field shows the palette's shortcut as the user set it, and no shortcut once it is cleared. +#[test] +fn the_search_field_follows_the_palettes_shortcut() { + let mut bar = AppBar::new(1400.0); + crate::keymap::set_override(&mut bar.app.ui.shortcut_overrides, "help.commandPalette", "Alt+F9"); + crate::shortcut_editor::sync(&bar.app.ui); + let rebound = crate::menus::shown_shortcut("Alt+F9"); + let seen = bar.search().expect("the search field shows"); + assert_eq!(seen.name, format!("{SEARCH_NAME} ({rebound})")); + assert_eq!(seen.texts, [SEARCH_NAME.to_string(), rebound], "{seen:?}"); + crate::keymap::set_override(&mut bar.app.ui.shortcut_overrides, "help.commandPalette", ""); + crate::shortcut_editor::sync(&bar.app.ui); + let seen = bar.search().expect("the search field shows"); + assert_eq!(seen.name, SEARCH_NAME); + assert_eq!(seen.texts, [SEARCH_NAME], "{seen:?}"); + bar.app.ui.shortcut_overrides.clear(); + crate::shortcut_editor::sync(&bar.app.ui); +} + +/// A shortcut too long to sit beside "Search commands" in the widest field is left to the tooltip +/// and the screen-reader name, and "Search commands" stays readable. +#[test] +fn a_long_shortcut_leaves_the_search_hint_readable() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + let long = format!("Ctrl+Alt+Shift+{}", "PageDown".repeat(4)); + let mut fields = vec![]; + for _ in 0..2 { + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| { + let t = Tokens::get(ui.ctx()); + fields = [Some("Ctrl+Shift+/".to_string()), Some(long.clone()), None] + .into_iter() + .map(|s| { + let f = super::SearchField::new(ui, &t, s); + (f.width, f.hint.size().x, f.key.as_ref().map(|k| k.size().x), f.shortcut.clone()) + }) + .collect(); + }); + out.textures_delta.clear(); + } + let [(short_w, hint, short_key, _), (long_w, _, long_key, long_shortcut), (none_w, _, none_key, _)] = &fields[..] else { + panic!("three fields: {fields:?}"); + }; + let short_key = short_key.expect("a short shortcut is shown"); + assert!(*short_w <= 220.0 && 26.0 + hint + 12.0 + short_key + 8.0 <= *short_w, "the hint and the shortcut fit side by side: {fields:?}"); + assert_eq!((*long_key, long_shortcut.as_deref()), (None, Some(long.as_str())), "a long one is left to the tooltip and the name"); + assert!(*long_w <= 220.0 && 26.0 + hint + 8.0 <= *long_w, "{fields:?}"); + assert!(none_key.is_none() && *none_w >= 120.0, "{fields:?}"); +} + +/// A click on the field, or on the icon it becomes in a narrow bar, opens the command palette with an +/// empty query, and a second click closes it, as the palette's shortcut does. While a dialog is open +/// neither does anything, as the shortcut does. +#[test] +fn a_click_on_the_search_field_opens_the_palette() { + for icon in [false, true] { + let mut bar = AppBar::new(1400.0); + if icon { + let narrow = (300..1400).rev().step_by(10).find(|w| { + bar.width = *w as f32; + bar.search().is_some_and(|s| s.rect.width() == 28.0) + }); + assert!(narrow.is_some(), "a narrow bar shows the icon"); + } + let at = bar.search().expect("the search control shows").rect.center(); + bar.app.ui.palette_query = "old".into(); + bar.click(at); + assert!(bar.app.ui.palette_open, "icon: {icon}"); + assert_eq!(bar.app.ui.palette_query, "", "icon: {icon}"); + bar.app.ui.palette_query = "typed".into(); + bar.click(at); + assert!(!bar.app.ui.palette_open, "a second click closes it (icon: {icon})"); + assert_eq!(bar.app.ui.palette_query, "", "icon: {icon}"); + bar.app.ui.dialog = Some(crate::state::Dialog::new("about", json!({}))); + bar.click(at); + assert!(!bar.app.ui.palette_open, "not over a dialog (icon: {icon})"); + } +} + +/// The keyboard focus reaches the field, Enter or Space opens the palette and does nothing else, and +/// Tab then moves the focus on. This holds with the app's keys handled, the palette drawn after the +/// bar, a document open, and an object selected with the Selection tool, whose Enter otherwise +/// opens Move. In the app, Tab with no field focused shows and hides the panels instead of moving +/// the focus, so the focus reaches the bar the way a screen reader moves it. +#[test] +fn the_keyboard_opens_the_palette_from_the_search_field() { + let cases = + [(egui::Key::Enter, 0), (egui::Key::Space, 0), (egui::Key::Enter, 1), (egui::Key::Space, 1), (egui::Key::Enter, 2), (egui::Key::Space, 2)]; + for (key, setup) in cases { + let document = setup > 0; + let mut bar = AppBar::new(1400.0); + let field = bar.search().expect("the search field shows").rect; + assert!(field.width() >= 120.0, "a field, not the icon: {field:?}"); + let mut reached = false; + for _ in 0..40 { + bar.key(egui::Key::Tab); + if bar.focused_at(field) { + reached = true; + break; + } + } + assert!(reached, "Tab reaches the search field"); + bar.keys = true; + if document { + bar.app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + } + if setup == 2 { + let id = bar.app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 30})).unwrap()["id"].clone(); + bar.app.select_tool("selection"); + bar.app.session.execute("select.set", &json!({"ids": [id]})).unwrap(); + } + // The app's keys leave the focus on the field. + bar.frame(vec![]); + assert!(bar.focused_at(field), "{key:?} (setup {setup})"); + assert!(!bar.app.ui.palette_open); + let status = bar.app.ui.status.clone(); + bar.key(key); + // The key opens the palette and goes no further: it does not pick the first result, type a + // space into the palette's field or open Move. + assert!(bar.app.ui.palette_open, "{key:?} opens the palette (setup {setup})"); + assert!(bar.app.ui.dialog.is_none(), "{key:?} opened no dialog (setup {setup})"); + assert_eq!(bar.app.ui.palette_query, "", "{key:?} (setup {setup})"); + assert!(bar.app.ui.recent_commands.is_empty() && bar.app.ui.status == status, "{key:?} ran nothing (setup {setup})"); + } + // Tab moves the focus off the field with the app's keys handled. + let mut bar = AppBar::new(1400.0); + let field = bar.search().expect("the search field shows").rect; + for _ in 0..40 { + if bar.focused_at(field) { + break; + } + bar.key(egui::Key::Tab); + } + assert!(bar.focused_at(field), "Tab reaches the search field at {field:?}"); + bar.keys = true; + let panels = (bar.app.ui.dock, bar.app.ui.toolbar); + bar.key(egui::Key::Tab); + assert!(!bar.focused_at(field), "Tab leaves the field"); + assert_eq!((bar.app.ui.dock, bar.app.ui.toolbar), panels, "Tab on the field does not hide the panels"); +} + +/// As the window narrows, the search field becomes the icon after Explore tutorials has gone and +/// before the icon goes, never overlapping the menus: with a long workspace name, with the menus in +/// the system's menu bar, and with the window's own caption buttons. +#[test] +fn a_narrowing_app_bar_turns_the_search_field_into_the_icon() { + for case in ["default", "long workspace name", "native menus", "caption buttons"] { + let mut bar = AppBar::new(1400.0); + match case { + "long workspace name" => bar.app.ui.workspace = "A workspace with a very long name indeed".into(), + "native menus" => bar.app.services.native_menu = Some(crate::native_menu::NativeMenu::new(Box::new(NoMenus))), + "caption buttons" => bar.app.custom_titlebar = true, + _ => {} + } + assert_eq!(bar.menus_end().is_some(), case != "native menus", "{case}: the in-window menus show"); + // 0: gone, 1: icon, 2: field. + let mut last = 2; + let mut seen_icon = false; + for width in (300..=1400).rev().step_by(10) { + bar.width = width as f32; + let learn = bar.has("Explore tutorials"); + let search = bar.search(); + let now = match &search { + Some(s) if s.rect.width() >= 120.0 => 2, + Some(s) => { + assert_eq!(s.rect.width(), 28.0, "{case} at {width}"); + assert!(s.texts.is_empty(), "the icon has no text: {case} at {width}"); + 1 + } + None => 0, + }; + assert!(width < 1400 || now == 2, "{case}: a wide bar shows the field"); + assert!(now <= last, "{case} at {width}: the search came back as the bar narrowed"); + assert!(!learn || now == 2, "{case} at {width}: Explore tutorials outlasted the field"); + if let Some(s) = &search { + assert!(s.rect.right() <= width as f32, "{case} at {width}: {s:?}"); + if let Some(menus_end) = bar.menus_end() { + assert!(s.rect.left() >= menus_end, "{case} at {width}: the search overlaps the menus ending at {menus_end}: {s:?}"); + } + } + seen_icon |= now == 1; + last = now; + } + assert!(seen_icon, "{case}: the field becomes the icon before it goes"); + } +} + #[derive(Debug)] struct StatusText { text: String, diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 71e443a399..2ea516f550 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -3182,6 +3182,7 @@ digits Malayalam Малаялам Scripts Скриптове Search Търсене Search All Търсене във всички + Search commands Търсене на команди Search commands and tools Търсене на команди и инструменти Search commands and tools… Търсене на команди и инструменти… Recent Commands Последни команди diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 883d6dd387..620d5edd19 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -1300,6 +1300,7 @@ lighting Light Svjetlo Name* @ 66.67% (RGB/Preview) Naziv* @ 66,67% (RGB/pregled) No Document Nema dokumenta Press Pritisnite + Search commands Pretraži naredbe Search commands and tools Pretraži naredbe i alate Style: Stil: Switch workspace Promijeni radni prostor diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index a8a63cbf55..1a4208cc01 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -4110,6 +4110,7 @@ digits Malayalam Malaiàlam Scrub Numeric Fields by Dragging Canvia els camps numèrics arrossegant Search Cerca Search All Cerca a tot + Search commands Cerca ordres Search commands and tools Cerca ordres i eines Search commands and tools… Cerca ordres i eines… Recent Commands Ordres recents diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 569b1347ec..02f5b97abc 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1324,6 +1324,7 @@ lighting Light Světlo Name* @ 66.67% (RGB/Preview) Název* @ 66,67 % (RGB/náhled) No Document Žádný dokument Press Klávesou + Search commands Hledat příkazy Search commands and tools Hledat příkazy a nástroje Style: Styl: Switch workspace Přepnout pracovní prostor diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 4578e4efc1..9733b65591 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3901,6 +3901,7 @@ lighting Light Lys Name* @ 66.67% (RGB/Preview) Navn* @ 66.67% (RGB/forhåndsvisning) No Document Intet dokument Press Tryk på + Search commands Søg i kommandoer Search commands and tools Søg i kommandoer og værktøjer Style: Typografi: Switch workspace Skift arbejdsområde diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index c943c89dd2..8a262a0d66 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3246,6 +3246,7 @@ digits Malayalam Malayalam Filter Layers Panel Rows Zeilen im Ebenenbedienfeld filtern @msg `Custom` stands for changed settings: save the preset under another name `Custom` steht für geänderte Einstellungen: Speichern Sie die Vorgabe unter einem anderen Namen @msg `{key}` must be an array of these names: {_1} `{key}` muss ein Array mit diesen Namen sein: {_1} + Search commands Befehle suchen Search commands and tools Befehle und Werkzeuge suchen Search commands and tools… Befehle und Werkzeuge suchen… Recent Commands Zuletzt verwendete Befehle diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 906640aa0a..0fc84a4f9a 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3948,6 +3948,7 @@ digits Malayalam Μαλαγιάλαμ Scribble… Μουτζούρωμα… Script / Brush Σενάριο / Πινέλο Search All Αναζήτηση όλων + Search commands Αναζήτηση εντολών Search commands and tools Αναζήτηση εντολών και εργαλείων Search commands and tools… Αναζήτηση εντολών και εργαλείων… Recent Commands Πρόσφατες εντολές diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 9239c93a73..f6c7c0e152 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3284,6 +3284,7 @@ digits Malayalam Malayálam Filter Layers Panel Rows Filtrar filas del panel Capas @msg `Custom` stands for changed settings: save the preset under another name `Custom` representa ajustes modificados: guarda el preajuste con otro nombre @msg `{key}` must be an array of these names: {_1} `{key}` debe ser una lista de estos nombres: {_1} + Search commands Buscar comandos Search commands and tools Buscar comandos y herramientas Search commands and tools… Buscar comandos y herramientas… Recent Commands Comandos recientes diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 423703e5c1..e971f1fe79 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -1302,6 +1302,7 @@ lighting Light Valo Name* @ 66.67% (RGB/Preview) Nimi* @ 66.67% (RGB/esikatselu) No Document Ei asiakirjaa Press Paina + Search commands Hae komentoja Search commands and tools Hae komentoja ja työkaluja Style: Tyyli: Switch workspace Vaihda työtilaa diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 8af602785b..4a89f385bf 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3272,6 +3272,7 @@ digits Malayalam Malayalam Filter Layers Panel Rows Filtrer les lignes du panneau Calques @msg `Custom` stands for changed settings: save the preset under another name `Custom` désigne des réglages modifiés : enregistrez le paramètre prédéfini sous un autre nom @msg `{key}` must be an array of these names: {_1} `{key}` doit être un tableau de noms parmi {_1} + Search commands Chercher des commandes Search commands and tools Chercher commandes et outils Search commands and tools… Chercher commandes et outils… Recent Commands Commandes récentes diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 4eed343e3d..d8caa0e6b1 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3388,6 +3388,7 @@ Search Commands… આદેશો શોધો… Search Fonts Folder ફોન્ટ ફોલ્ડર શોધો Search Preferences પસંદગીઓ શોધો + Search commands આદેશો શોધો Search commands and tools આદેશો અને ટૂલ્સ શોધો Search commands and tools… આદેશો અને ટૂલ્સ શોધો… Recent Commands તાજેતરના આદેશો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index de33cdbd92..164537497d 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4462,6 +4462,7 @@ antiAlias Sharp शार्प Search खोजें Search All सभी खोजें Search artboards खोज आर्टबोर्ड + Search commands आदेश खोजें Search commands and tools खोज आदेश और टूल Search commands and tools… आदेश और टूल खोजें… Recent Commands हाल के आदेश diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index f869e7d07b..9c856323ce 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3904,6 +3904,7 @@ mark-style Japanese Japán Filter Layers Panel Rows Rétegek panel sorainak szűrése @msg `Custom` stands for changed settings: save the preset under another name a `Custom` a módosított beállításokat jelöli: mentsd az előbeállítást más néven @msg `{key}` must be an array of these names: {_1} `{key}`: ezen nevek tömbje kell: {_1} + Search commands Parancsok keresése Search commands and tools Parancsok és eszközök keresése Search commands and tools… Parancsok és eszközök keresése… Recent Commands Legutóbbi parancsok diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index c5f865e69b..0c5b65e7f0 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1227,6 +1227,7 @@ lighting Light Cahaya Name* @ 66.67% (RGB/Preview) Nama* @ 66.67% (RGB/Pratinjau) No Document Tidak ada dokumen Press Tekan + Search commands Cari perintah Search commands and tools Cari perintah dan alat Style: Gaya: Switch workspace Ganti ruang kerja diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 08cefdbed7..c4e2f39dc4 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3327,6 +3327,7 @@ digits Malayalam Malayalam Filter Layers Panel Rows Filtra righe del pannello Livelli @msg `Custom` stands for changed settings: save the preset under another name `Custom` indica impostazioni modificate: salva il preset con un altro nome @msg `{key}` must be an array of these names: {_1} `{key}` deve essere un array di questi nomi: {_1} + Search commands Cerca comandi Search commands and tools Cerca comandi e strumenti Search commands and tools… Cerca comandi e strumenti… Recent Commands Comandi recenti diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 59c7628f40..bd1c00f4ae 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3204,6 +3204,7 @@ mark-style Japanese 日本式 Filter Layers Panel Rows レイヤーパネルの行をフィルター @msg `Custom` stands for changed settings: save the preset under another name `Custom` は変更した設定を表します: プリセットを別の名前で保存してください @msg `{key}` must be an array of these names: {_1} `{key}` には {_1} の中の名前の配列を指定してください + Search commands コマンドを検索 Search commands and tools コマンドとツールを検索 Search commands and tools… コマンドとツールを検索… Recent Commands 最近使ったコマンド diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 9393433cdb..6589d60e98 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3269,6 +3269,7 @@ lighting Light სინათლე Name* @ 66.67% (RGB/Preview) სახელი* @ 66.67% (RGB/წინასწარი ნახვა) No Document დოკუმენტი არ არის Press დააჭირეთ + Search commands ბრძანებების ძიება Search commands and tools ბრძანებებისა და ხელსაწყოების ძიება Style: სტილი: Switch workspace სამუშაო სივრცის გადართვა diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 49d5e10dc1..13860e91b9 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3193,6 +3193,7 @@ mark-style Japanese 일본식 Filter Layers Panel Rows 레이어 패널 행 필터링 @msg `Custom` stands for changed settings: save the preset under another name `Custom`은 변경된 설정을 나타냅니다. 프리셋을 다른 이름으로 저장하세요 @msg `{key}` must be an array of these names: {_1} `{key}`은(는) 다음 이름의 배열이어야 합니다: {_1} + Search commands 명령 검색 Search commands and tools 명령 및 도구 검색 Search commands and tools… 명령 및 도구 검색… Recent Commands 최근 명령 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index f071ebd0e2..9f165efd14 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1795,6 +1795,7 @@ lighting Light Licht Name* @ 66.67% (RGB/Preview) Naam* @ 66.67% (RGB/Voorbeeld) No Document Geen document Press Druk op + Search commands Opdrachten zoeken Search commands and tools Opdrachten en gereedschappen zoeken Style: Stijl: Switch workspace Werkruimte wisselen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 2477c73abd..20e2f86d10 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1254,6 +1254,7 @@ lighting Light Światło Name* @ 66.67% (RGB/Preview) Nazwa* @ 66,67% (RGB/Podgląd) No Document Brak dokumentu Press Naciśnij + Search commands Szukaj poleceń Search commands and tools Szukaj poleceń i narzędzi Style: Styl: Switch workspace Przełącz obszar roboczy diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 333351b9af..0d95825dde 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2742,6 +2742,7 @@ digits Malayalam Malaiala @msg `Custom` stands for changed settings: save the preset under another name `Custom` representa configurações alteradas: salve a predefinição com outro nome @msg `{key}` must be an array of these names: {_1} `{key}` deve ser uma matriz destes nomes: {_1} Search Commands… Pesquisar Comandos… + Search commands Pesquisar comandos Search commands and tools Pesquisar comandos e ferramentas Search commands and tools… Pesquisar comandos e ferramentas… Recent Commands Comandos recentes diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index ae33aa0d55..3dfaa07482 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3316,6 +3316,7 @@ digits Malayalam Малаялам Filter Layers Panel Rows Фильтровать строки панели «Слои» @msg `Custom` stands for changed settings: save the preset under another name `Custom` обозначает изменённые параметры: сохраните набор под другим именем @msg `{key}` must be an array of these names: {_1} `{key}` должно быть массивом из этих имён: {_1} + Search commands Поиск команд Search commands and tools Поиск команд и инструментов Search commands and tools… Поиск команд и инструментов… Recent Commands Недавние команды diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 1bd4fd0692..248adc3ec7 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -3202,6 +3202,7 @@ digits Malayalam Malayalam Scripts Skript Search Sök Search All Sök i alla + Search commands Sök kommandon Search commands and tools Sök kommandon och verktyg Search commands and tools… Sök kommandon och verktyg… Recent Commands Senaste kommandon diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index a2a38c679a..c8ff293ebb 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3074,6 +3074,7 @@ digits Malayalam Malayalam Redefine {name} “{name}” Stilini Yeniden Tanımla @msg `Custom` stands for changed settings: save the preset under another name `Custom` değiştirilmiş ayarları ifade eder: ön ayarı başka bir adla kaydedin @msg `{key}` must be an array of these names: {_1} `{key}` şu adlardan oluşan bir dizi olmalıdır: {_1} + Search commands Komutları arayın Search commands and tools Komutları ve araçları arayın Search commands and tools… Komutları ve araçları arayın… Recent Commands Son komutlar diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 17c673885d..c4e95fd2db 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3319,6 +3319,7 @@ digits Malayalam Малаялам Filter Layers Panel Rows Фільтрувати рядки панелі «Шари» @msg `Custom` stands for changed settings: save the preset under another name `Custom` позначає змінені параметри: збережіть набір під іншим ім’ям @msg `{key}` must be an array of these names: {_1} `{key}` має бути масивом цих назв: {_1} + Search commands Пошук команд Search commands and tools Пошук команд та інструментів Search commands and tools… Пошук команд та інструментів… Recent Commands Нещодавні команди diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index da89525314..6c79308d93 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3661,6 +3661,7 @@ mark-style Japanese Kiểu Nhật Filter Layers Panel Rows Lọc hàng bảng Lớp @msg `Custom` stands for changed settings: save the preset under another name `Custom` biểu thị các cài đặt đã thay đổi: hãy lưu thiết lập sẵn với tên khác @msg `{key}` must be an array of these names: {_1} `{key}` phải là một mảng gồm các tên sau: {_1} + Search commands Tìm kiếm lệnh Search commands and tools Tìm kiếm lệnh và công cụ Search commands and tools… Tìm kiếm lệnh và công cụ… Recent Commands Lệnh gần đây diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 5f612cb0d4..1e318d4001 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -3146,6 +3146,7 @@ digits Malayalam 马拉雅拉姆数字 Locked 已锁定 Hidden 已隐藏 Filter Layers Panel Rows 筛选图层面板行 + Search commands 搜索命令 Search commands and tools 搜索命令和工具 Search commands and tools… 搜索命令和工具… Recent Commands 最近使用的命令 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e0b5a13ee2..e2f1a7950c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4452,6 +4452,7 @@ digits Malayalam 馬來亞拉姆數字 Locked 已鎖定 Hidden 已隱藏 Filter Layers Panel Rows 篩選圖層面板列 + Search commands 搜尋指令 Search commands and tools 搜尋指令與工具 Search commands and tools… 搜尋指令與工具… Recent Commands 最近使用的指令 diff --git a/crates/ui-egui/src/panels/learn/tests.rs b/crates/ui-egui/src/panels/learn/tests.rs index 319ca1decf..21486d4b1a 100644 --- a/crates/ui-egui/src/panels/learn/tests.rs +++ b/crates/ui-egui/src/panels/learn/tests.rs @@ -104,10 +104,10 @@ fn explore_tutorials_on_the_app_bar_shows_and_hides_the_learn_panel() { let ctx = context(); assert!(!shown(&app)); let nodes = frame(&mut app, &ctx, vec![], app_bar); - let search = center_where(&nodes, |label| label.starts_with("Search commands and tools")); + let search = center_where(&nodes, |label| label.starts_with("Search commands")); let learn = center(&nodes, "Explore tutorials"); - let (search, learn) = (search.expect("the search icon shows"), learn.expect("the app bar has Explore tutorials")); - assert!(learn.x < search.x && (learn.y - search.y).abs() < 1.0, "beside the search icon: {learn:?}, {search:?}"); + let (search, learn) = (search.expect("the search field shows"), learn.expect("the app bar has Explore tutorials")); + assert!(learn.x < search.x && (learn.y - search.y).abs() < 1.0, "beside the search field: {learn:?}, {search:?}"); click(&mut app, &ctx, "Explore tutorials", app_bar); assert!(shown(&app), "{}", app.ui.status); click(&mut app, &ctx, "Explore tutorials", app_bar); diff --git a/docs/development.md b/docs/development.md index 64b66678b5..2b1a3d7d87 100644 --- a/docs/development.md +++ b/docs/development.md @@ -111,7 +111,7 @@ When the interface thread stays in one part of a frame for 3 s (VectorCraft's ow ## macOS: the menu bar -On macOS the menus live in the system menu bar, not in the window's app bar (which keeps the brand mark, Home, the search icon and the workspace switcher next to the traffic lights, centred on the bar by `apps/vectorcraft/src/mac_window.rs`). `--in-window-menus` or `VECTORCRAFT_IN_WINDOW_MENUS=1` keeps them in the window, as on Windows, Linux and the web; so does a menu bar AppKit refuses to build (logged). `ui.inspect` says which with `nativeMenuBar`. +On macOS the menus live in the system menu bar, not in the window's app bar (which keeps the brand mark, Home, the search field and the workspace switcher next to the traffic lights, centred on the bar by `apps/vectorcraft/src/mac_window.rs`). `--in-window-menus` or `VECTORCRAFT_IN_WINDOW_MENUS=1` keeps them in the window, as on Windows, Linux and the web; so does a menu bar AppKit refuses to build (logged). `ui.inspect` says which with `nativeMenuBar`. - **One menu model.** `crates/ui-egui/src/native_menu.rs` (platform-free, tested on every platform) builds the menu bar from the in-window menus (`menus::menu_tree`, each item through `menus::entry`, which the in-window menus draw too) and lays it out the Mac way: the VectorCraft menu holds About, Settings ▸ (one item per Preferences page, General… ⌘K), Language ▸, Appearance ▸ (UI brightness), Services, Hide VectorCraft ⌃⌘H (⌘H stays View › Hide Edges), Hide Others ⌥⌘H, Show All and Quit ⌘Q (the app's own `app.quit`, so unsaved documents are asked about); those leave Edit and Help. The in-window bar itself never shows the VectorCraft menu (it starts at File, as in Illustrator, on every platform): Language and Appearance have no in-window menu and are synthesized in `mac_layout`, and Quit is File › Exit in the window, relabelled to Quit in the App menu. Window starts with Minimize ⌃⌘M and Zoom and ends with Bring All to Front, and Help is the system's Help menu (its search field). A system key a command (or a user's shortcut) already has stays the command's, and the log says so. - **The native side** is `apps/vectorcraft/src/mac_menu.rs`: muda (`=0.21.1`, default features off, macOS only, no `unsafe`) builds the `NSMenu`s. Labels, enabled and checked are updated in place when anything they show may have changed (a command ran, the document, its history or selection changed, a click or a key press); a change of structure (a recent file, the language, a shortcut) rebuilds the menus. While an interaction is open (for example a move, scale or shape drag, a dialog's preview or the font menu's preview), the app updates them for the document's changes only when the interaction begins and when it ends. diff --git a/docs/mcp.md b/docs/mcp.md index c7aa202d3f..e2de2d90df 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3212,7 +3212,7 @@ own layout rules. ## Learn panel -Window › Learn and the Explore tutorials button beside the search icon at the right end of the app bar show and hide +Window › Learn and the Explore tutorials button beside the search field at the right end of the app bar show and hide the Learn panel. Its For you tab holds a Get started section with a Quick skill guide card; choosing the card opens the Skills tab. The Skills tab lists VectorCraft's own skills, each with a progress ring and the count of its tutorials finished of all its tutorials. Choosing a skill lists its tutorials, choosing a tutorial shows its numbered steps, and diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..a4585db2f7 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1017,7 +1017,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The Free Transform widget's Constrain works in Free Distort as well as in Free Transform ([the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/free-transform-tool.html)). With Constrain on, or Shift held, a corner dragged in Free Distort moves only along the line through the opposite corner, in the box's own proportions, and the other three corners stay in place; on a turned box the line runs through the box's own corners. The line is VectorCraft's own rule. Cmd/Ctrl+Alt+Shift on a corner still drags in Perspective Distort, where Constrain stays unavailable (tools `xform::free::tests::free_distort_corner_keeps_to_its_diagonal_with_shift_or_constrain`, `shift_pressed_during_a_free_distort_drag_constrains_it`, `a_turned_box_is_constrained_along_its_own_diagonal`, `along_diagonal_of_a_degenerate_box`; engine `xform::free_transform_constrained_distort_keeps_the_corner_on_its_diagonal`; ui-egui `free_transform::tests::the_widget_sets_the_mode_and_a_corner_drag_then_distorts`). - Native macOS menu bar, vector tool cursors, a command palette (Help › Search Commands…), middle-button panning with any tool. Native menus explicitly end tracking on command selection, outside window presses and Escape; menu updates wait until tracking ends, and a dismissing press never starts a canvas gesture (M14.8). - A Recent Commands button beside the Help › Search Commands field lists the last five commands and tools picked from the palette, most recent first, with a command picked again moved to the top. Choosing a row closes the palette and runs it as a pick of the same result does; with no picks yet the list shows a dimmed No recent commands row, and a command that is not available now, such as a filter of a plug-in that is not loaded, is left out until it comes back. The ids are saved with the UI state. While the list is open, Up and Down move through its rows, wrapping at the ends, and Escape closes the list before the palette. This is VectorCraft's own addition and does not raise a score (#6376; `palette` tests `recent_commands_*`, `a_recent_command_runs_what_its_pick_runs`, `the_keys_wrap_within_recent_commands`, `escape_closes_recent_commands_before_the_palette`). - - The Learn panel (Window › Learn, or Explore tutorials beside the search icon on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their progress rings and counts of tutorials finished; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list`, `learn.tab {tab}`, `learn.skill {skill}`, `learn.show {tutorial}` and `learn.back` script it, and the tab buttons, the rows and Back run them ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`). + - The app bar's search control is a field showing a magnifier, "Search commands" and the Help › Search Commands… shortcut. The field shows no shortcut when the shortcut is cleared or too long to fit beside the text; the tooltip and the screen-reader name still give it. A click on the field, or Enter or Space while it has the keyboard focus, toggles the command palette as the shortcut does, and the palette's popup holds the text field. While the field has the focus, the app's own keys stay off, so Enter does not open Move and Tab moves the focus on. While a dialog is open the field and the icon do nothing, as the shortcut does. Screen readers name the field Search commands, with the shortcut. As the bar narrows, the community button goes first, then Explore tutorials, then the field becomes the magnifier icon, then the workspace switcher narrows to 64 points, then the icon goes; Safe Mode's label keeps its room first. This is VectorCraft's own addition and does not raise a score (`chrome::tests`: `the_app_bar_gives_up_its_right_hand_controls_in_order`, `a_wide_app_bar_shows_a_search_field_with_the_palette_shortcut`, `the_search_field_follows_the_palettes_shortcut`, `a_long_shortcut_leaves_the_search_hint_readable`, `a_click_on_the_search_field_opens_the_palette`, `the_keyboard_opens_the_palette_from_the_search_field`, `a_narrowing_app_bar_turns_the_search_field_into_the_icon`). + - The Learn panel (Window › Learn, or Explore tutorials beside the search field on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their progress rings and counts of tutorials finished; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list`, `learn.tab {tab}`, `learn.skill {skill}`, `learn.show {tutorial}` and `learn.back` script it, and the tab buttons, the rows and Back run them ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`). - A tool's name in a Learn tutorial step is a blue link that shows where the tool is without choosing it (`learn.locateTool {tool}`): its toolbar button is marked, a collapsed group's flyout opens with the tool's row marked, a torn-off strip comes to the front, and a tool no shown toolbar holds is marked in the All Tools drawer. The mark, its 3 seconds and the hidden-toolbar cases are VectorCraft's own rules ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`, the `a_learn_link_*` tests in `toolbar::tests`). - Under a tutorial's steps, View more opens the tutorial's own practice sample as a new untitled document, and once the tutorial is finished, Next Up moves to the next tutorial in the same skill, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). The samples are VectorCraft's own drawings. A Finish tutorial button that shows once the sample is open, the untitled copy, Back to skills in place of Next Up after a skill's last tutorial, and Next Up showing the next tutorial without opening its sample are VectorCraft's own rules. `learn.openSample`, `learn.finish`, `learn.next` and `learn.skills` (Back to skills) script them. Not done: the help page's short video. Regression tests: `view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document`, `finishing_a_tutorial_offers_next_up_in_its_skill`, `the_practice_controls_work_from_the_keyboard`, `the_last_tutorial_of_a_skill_offers_back_to_skills`, `learn_finish_and_learn_next_follow_the_practice`, `learn_skills_shows_the_list_of_skills`, `the_practice_commands_reject_a_missing_or_unknown_tutorial`, `every_tutorial_has_its_own_readable_sample` and `the_next_tutorial_is_the_next_one_in_the_same_skill` in `crates/ui-egui/src/panels/learn/tests.rs`. - A Learn tutorial's steps are marked complete as the learner works, and a skill's progress ring fills as its tutorials are finished, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). Each step has a check box that marks it done once the tutorial's sample is open (`learn.markStep`); Finish tutorial marks every step done; a skill's count shows its tutorials finished of all, and a finished tutorial has a check mark in its skill's list. Marking steps by hand, the count, keeping the progress in the preferences (the web build keeps it while the page is open) and Reset progress (`learn.resetProgress`) are VectorCraft's own rules; `learn.list` reports the progress. Regression tests: `a_step_s_check_box_marks_only_that_step`, `a_step_s_check_box_works_from_the_keyboard`, `finishing_tutorials_fills_their_skill_s_ring_and_count`, `a_skill_with_no_tutorials_shows_0_of_0`, `learn_mark_step_checks_its_params`, `reset_progress_clears_only_the_progress`, `the_preferences_keep_the_progress` and `saved_progress_is_read_leniently` in `crates/ui-egui/src/panels/learn/tests.rs`. From f9f9f9132121b14fb407e0f0b4db77ab72152226 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 01:22:24 -0800 Subject: [PATCH 2/3] App bar: the search icon takes the field's name, and both draw disabled under a dialog - Screen readers now call the search icon "Search commands" with the shortcut, as they call the field; its tooltip stays "Search commands and tools". paint_icon_button_named gives an icon button a name apart from its tooltip. - While a dialog is open the field and the icon are drawn disabled and screen readers report them disabled, since a click on them does nothing then. - The titlebar test now checks that the field shows "Search commands" in a wide window, and its comments describe the field. - The fitting code and its tests call the community button's width and flag `community`, and the new struct fields have doc comments. - The new "Search commands" catalog rows move a few rows down, next to "No recent commands" or "Switch workspace", away from the rows other open pull requests change. - The docs line says the app's existing rule for a focused control keeps the app's keys off while the field has the focus, and that the community button and Explore tutorials go at wider bars than they did beside the icon. --- crates/ui-egui/src/chrome.rs | 42 ++++++++++++------ crates/ui-egui/src/chrome/tests.rs | 61 +++++++++++++++++++-------- crates/ui-egui/src/i18n/bg.tsv | 2 +- crates/ui-egui/src/i18n/bs.tsv | 2 +- crates/ui-egui/src/i18n/ca.tsv | 2 +- crates/ui-egui/src/i18n/cs.tsv | 2 +- crates/ui-egui/src/i18n/da.tsv | 2 +- crates/ui-egui/src/i18n/de.tsv | 2 +- crates/ui-egui/src/i18n/el.tsv | 2 +- crates/ui-egui/src/i18n/es.tsv | 2 +- crates/ui-egui/src/i18n/fi.tsv | 2 +- crates/ui-egui/src/i18n/fr.tsv | 2 +- crates/ui-egui/src/i18n/gu.tsv | 2 +- crates/ui-egui/src/i18n/hi.tsv | 2 +- crates/ui-egui/src/i18n/hu.tsv | 2 +- crates/ui-egui/src/i18n/id.tsv | 2 +- crates/ui-egui/src/i18n/it.tsv | 2 +- crates/ui-egui/src/i18n/ja.tsv | 2 +- crates/ui-egui/src/i18n/ka.tsv | 2 +- crates/ui-egui/src/i18n/ko.tsv | 2 +- crates/ui-egui/src/i18n/nl.tsv | 2 +- crates/ui-egui/src/i18n/pl.tsv | 2 +- crates/ui-egui/src/i18n/pt-br.tsv | 2 +- crates/ui-egui/src/i18n/ru.tsv | 2 +- crates/ui-egui/src/i18n/sv.tsv | 2 +- crates/ui-egui/src/i18n/tr.tsv | 2 +- crates/ui-egui/src/i18n/uk.tsv | 2 +- crates/ui-egui/src/i18n/vi.tsv | 2 +- crates/ui-egui/src/i18n/zh-hans.tsv | 2 +- crates/ui-egui/src/i18n/zh-hant.tsv | 2 +- crates/ui-egui/src/titlebar.rs | 8 +++- crates/ui-egui/src/widgets.rs | 4 +- crates/ui-egui/src/widgets/buttons.rs | 10 ++++- docs/target-app-parity.md | 2 +- 34 files changed, 118 insertions(+), 65 deletions(-) diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index d10d320ad9..4cbd0e9e85 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -108,9 +108,9 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { field: field.width, icon: BAR_ICON, gap: ui.spacing().item_spacing.x, - discord: crate::community::discord_width(ui, false), + community: crate::community::discord_width(ui, false), }); - let (switcher, ws_w, learn, discord) = (fit.switcher, fit.switcher_w, fit.learn, fit.discord); + let (switcher, ws_w, learn, discord) = (fit.switcher, fit.switcher_w, fit.learn, fit.community); let mut rui = ui.new_child(egui::UiBuilder::new().max_rect(right).layout(egui::Layout::right_to_left(egui::Align::Center))); let ui = &mut rui; // Workspace switcher: shows the current workspace, opens Window → Workspace. @@ -136,14 +136,21 @@ pub fn app_bar(app: &mut VectorcraftApp, ui: &mut Ui) { }; let tip = with_shortcut(tl!("Search commands and tools")); let name = with_shortcut(tl!("Search commands")); - let clicked = match fit.search { - Search::Field => field.show(ui, &t, &name, &tip, app.ui.palette_open).clicked(), - Search::Icon => widgets::icon_button(ui, "search", &tip, app.ui.palette_open, BAR_ICON).clicked(), - Search::Hidden => false, - }; // The field and the icon toggle the palette as its shortcut does, and like the shortcut - // they do nothing while a dialog is open. - if clicked && app.ui.dialog.is_none() { + // they do nothing while a dialog is open, so they are drawn disabled then. + let enabled = app.ui.dialog.is_none(); + let open = app.ui.palette_open; + let clicked = ui + .add_enabled_ui(enabled, |ui| match fit.search { + Search::Field => field.show(ui, &t, &name, &tip, open).clicked(), + Search::Icon => { + let (_, resp) = ui.allocate_exact_size(vec2(BAR_ICON, BAR_ICON), Sense::click()); + widgets::paint_icon_button_named(ui, resp, "search", &name, &tip, open).clicked() + } + Search::Hidden => false, + }) + .inner; + if clicked && enabled { app.ui.palette_open = !app.ui.palette_open; app.ui.palette_query.clear(); } @@ -195,24 +202,33 @@ enum Search { struct RightWidths { /// The room after the menus, less the Safe Mode label's. room: f32, + /// Whether the bar shows the Safe Mode label. safe_mode: bool, /// The workspace switcher's full width. switcher: f32, /// The search field's width. field: f32, + /// The side of a square icon button. icon: f32, + /// The space between two controls. gap: f32, - discord: f32, + /// The community button's width. + community: f32, } /// What the right-hand group of the app bar shows. #[derive(Clone, Copy, Debug, PartialEq)] struct RightGroup { + /// Whether the workspace switcher shows. switcher: bool, + /// The workspace switcher's width. switcher_w: f32, + /// How the search shows. search: Search, + /// Whether Explore tutorials shows. learn: bool, - discord: bool, + /// Whether the community button shows. + community: bool, } /// The right-hand group for the room it has. As the room runs short, the community button goes first @@ -240,8 +256,8 @@ fn fit_right_group(w: &RightWidths) -> RightGroup { let switcher_w = w.switcher.min(room - 8.0 - search_w).max(MIN_SWITCHER); let learn_end = switcher_w + 8.0 + search_w + w.gap + w.icon; let learn = field && room >= learn_end; - let discord = learn && room >= learn_end + 10.0 + w.gap + w.discord; - RightGroup { switcher, switcher_w, search, learn, discord } + let community = learn && room >= learn_end + 10.0 + w.gap + w.community; + RightGroup { switcher, switcher_w, search, learn, community } } /// The app bar's search field: a button drawn as a field. The command palette's popup holds the diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index f0ac33613b..e19221a91d 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -161,7 +161,7 @@ fn hints_name_keys_as_the_menus_do() { /// The widths of the app bar's right-hand group used by the fitting tests. fn right_widths(room: f32, safe_mode: bool) -> super::RightWidths { - super::RightWidths { room, safe_mode, switcher: 150.0, field: 170.0, icon: 28.0, gap: 8.0, discord: 80.0 } + super::RightWidths { room, safe_mode, switcher: 150.0, field: 170.0, icon: 28.0, gap: 8.0, community: 80.0 } } /// What the group shows, in words, with the switcher's width as full, narrower or minimal. @@ -172,10 +172,10 @@ fn right_stage(g: &super::RightGroup) -> String { w if w > super::MIN_SWITCHER => "narrower switcher", _ => "minimal switcher", }; - format!("discord {}, learn {}, {:?}, {switcher}", g.discord, g.learn, g.search) + format!("community {}, learn {}, {:?}, {switcher}", g.community, g.learn, g.search) } -/// As the app bar's room runs short, Discord goes first, then Explore tutorials, then the search +/// As the app bar's room runs short, the community button goes first, then Explore tutorials, then the search /// field becomes the icon, then the workspace switcher narrows to its minimum, then the icon goes. /// Whatever shows fits in the room, down to the minimal switcher alone. #[test] @@ -194,34 +194,33 @@ fn the_app_bar_gives_up_its_right_hand_controls_in_order() { super::Search::Hidden => 0.0, }; let learn = if g.learn { w.gap + w.icon } else { 0.0 }; - let discord = if g.discord { 10.0 + w.gap + w.discord } else { 0.0 }; - let used = g.switcher_w + 8.0 + search + learn + discord; + let community = if g.community { 10.0 + w.gap + w.community } else { 0.0 }; + let used = g.switcher_w + 8.0 + search + learn + community; assert!(used <= room || g.switcher_w == super::MIN_SWITCHER && g.search == super::Search::Hidden, "{room}: {g:?} needs {used}"); } assert_eq!( stages, [ - "discord true, learn true, Field, full switcher", - "discord false, learn true, Field, full switcher", - "discord false, learn false, Field, full switcher", - "discord false, learn false, Icon, full switcher", - "discord false, learn false, Icon, narrower switcher", - "discord false, learn false, Icon, minimal switcher", + "community true, learn true, Field, full switcher", + "community false, learn true, Field, full switcher", + "community false, learn false, Field, full switcher", + "community false, learn false, Icon, full switcher", + "community false, learn false, Icon, narrower switcher", + "community false, learn false, Icon, minimal switcher", // Once the icon has gone, the switcher takes the room it leaves. - "discord false, learn false, Hidden, narrower switcher", - "discord false, learn false, Hidden, minimal switcher", + "community false, learn false, Hidden, narrower switcher", + "community false, learn false, Hidden, minimal switcher", ] ); // In Safe Mode the label's width is taken first (not counted in `room`), and the switcher goes // when a minimal one does not fit. let safe = |room| right_stage(&super::fit_right_group(&right_widths(room, true))); - assert_eq!(safe(700.0), "discord true, learn true, Field, full switcher"); - assert_eq!(safe(72.0), "discord false, learn false, Hidden, minimal switcher"); - assert_eq!(safe(71.0), "discord false, learn false, Hidden, no switcher"); + assert_eq!(safe(700.0), "community true, learn true, Field, full switcher"); + assert_eq!(safe(72.0), "community false, learn false, Hidden, minimal switcher"); + assert_eq!(safe(71.0), "community false, learn false, Hidden, no switcher"); } -/// What screen readers call the app bar's search field, before its shortcut, and how the collapsed -/// icon's name starts. +/// What screen readers call the app bar's search field, and the icon it becomes, before the shortcut. const SEARCH_NAME: &str = "Search commands"; /// A native menu bar that draws nothing. @@ -432,6 +431,32 @@ fn a_click_on_the_search_field_opens_the_palette() { } } +/// The icon a narrow bar shows has the field's screen-reader name, and while a dialog is open screen +/// readers find the field and the icon disabled. +#[test] +fn the_search_icon_has_the_fields_name_and_both_are_disabled_under_a_dialog() { + let shortcut = crate::menus::shown_shortcut("Cmd+Shift+/"); + for icon in [false, true] { + let mut bar = AppBar::new(1400.0); + if icon { + let narrow = (300..1400).rev().step_by(10).find(|w| { + bar.width = *w as f32; + bar.search().is_some_and(|s| s.rect.width() == 28.0) + }); + assert!(narrow.is_some(), "a narrow bar shows the icon"); + } + let disabled = |bar: &mut AppBar| { + bar.frame(vec![]); + let nodes = bar.frame(vec![]).0; + let node = nodes.iter().find(|n| n.label().is_some_and(|l| l.starts_with(SEARCH_NAME))).expect("the search control shows"); + (node.label().unwrap_or_default().to_string(), node.is_disabled()) + }; + assert_eq!(disabled(&mut bar), (format!("{SEARCH_NAME} ({shortcut})"), false), "icon: {icon}"); + bar.app.ui.dialog = Some(crate::state::Dialog::new("about", json!({}))); + assert_eq!(disabled(&mut bar), (format!("{SEARCH_NAME} ({shortcut})"), true), "icon: {icon}"); + } +} + /// The keyboard focus reaches the field, Enter or Space opens the palette and does nothing else, and /// Tab then moves the focus on. This holds with the app's keys handled, the palette drawn after the /// bar, a document open, and an object selected with the Selection tool, whose Enter otherwise diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 2ea516f550..732b89f37a 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -3182,11 +3182,11 @@ digits Malayalam Малаялам Scripts Скриптове Search Търсене Search All Търсене във всички - Search commands Търсене на команди Search commands and tools Търсене на команди и инструменти Search commands and tools… Търсене на команди и инструменти… Recent Commands Последни команди No recent commands Няма последни команди + Search commands Търсене на команди Search Commands… Търсене на команди… Secondary Вторичен Section Symbol Символ за раздел diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 620d5edd19..e57f7d794d 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -1300,10 +1300,10 @@ lighting Light Svjetlo Name* @ 66.67% (RGB/Preview) Naziv* @ 66,67% (RGB/pregled) No Document Nema dokumenta Press Pritisnite - Search commands Pretraži naredbe Search commands and tools Pretraži naredbe i alate Style: Stil: Switch workspace Promijeni radni prostor + Search commands Pretraži naredbe Show all open documents Prikaži sve otvorene dokumente Use Koristite the object to select | objekat za odabir | diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 1a4208cc01..3644e3f97f 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -4110,11 +4110,11 @@ digits Malayalam Malaiàlam Scrub Numeric Fields by Dragging Canvia els camps numèrics arrossegant Search Cerca Search All Cerca a tot - Search commands Cerca ordres Search commands and tools Cerca ordres i eines Search commands and tools… Cerca ordres i eines… Recent Commands Ordres recents No recent commands No hi ha ordres recents + Search commands Cerca ordres Search Commands… Cerca ordres… Search Fonts Folder Cerca a la carpeta de tipus de lletra Searching… Cercant… diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 02f5b97abc..e18d63dd69 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -1324,10 +1324,10 @@ lighting Light Světlo Name* @ 66.67% (RGB/Preview) Název* @ 66,67 % (RGB/náhled) No Document Žádný dokument Press Klávesou - Search commands Hledat příkazy Search commands and tools Hledat příkazy a nástroje Style: Styl: Switch workspace Přepnout pracovní prostor + Search commands Hledat příkazy Show all open documents Zobrazit všechny otevřené dokumenty Use Příkazem the object to select | na objekt jej vybere | diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 9733b65591..89ae110f26 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -3901,10 +3901,10 @@ lighting Light Lys Name* @ 66.67% (RGB/Preview) Navn* @ 66.67% (RGB/forhåndsvisning) No Document Intet dokument Press Tryk på - Search commands Søg i kommandoer Search commands and tools Søg i kommandoer og værktøjer Style: Typografi: Switch workspace Skift arbejdsområde + Search commands Søg i kommandoer Show all open documents Vis alle åbne dokumenter Use Brug the object to select | på objektet for at markere det | diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 8a262a0d66..e1be23383f 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3246,11 +3246,11 @@ digits Malayalam Malayalam Filter Layers Panel Rows Zeilen im Ebenenbedienfeld filtern @msg `Custom` stands for changed settings: save the preset under another name `Custom` steht für geänderte Einstellungen: Speichern Sie die Vorgabe unter einem anderen Namen @msg `{key}` must be an array of these names: {_1} `{key}` muss ein Array mit diesen Namen sein: {_1} - Search commands Befehle suchen Search commands and tools Befehle und Werkzeuge suchen Search commands and tools… Befehle und Werkzeuge suchen… Recent Commands Zuletzt verwendete Befehle No recent commands Keine zuletzt verwendeten Befehle + Search commands Befehle suchen Search Commands… Befehle suchen… Secondary Sekundär Section Symbol Paragrafenzeichen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 0fc84a4f9a..4aef4b46b9 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3948,11 +3948,11 @@ digits Malayalam Μαλαγιάλαμ Scribble… Μουτζούρωμα… Script / Brush Σενάριο / Πινέλο Search All Αναζήτηση όλων - Search commands Αναζήτηση εντολών Search commands and tools Αναζήτηση εντολών και εργαλείων Search commands and tools… Αναζήτηση εντολών και εργαλείων… Recent Commands Πρόσφατες εντολές No recent commands Δεν υπάρχουν πρόσφατες εντολές + Search commands Αναζήτηση εντολών Search Commands… Αναζήτηση εντολών… Secondary Δευτερεύον Section Symbol Σύμβολο ενότητας diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index f6c7c0e152..d1acec9c47 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3284,11 +3284,11 @@ digits Malayalam Malayálam Filter Layers Panel Rows Filtrar filas del panel Capas @msg `Custom` stands for changed settings: save the preset under another name `Custom` representa ajustes modificados: guarda el preajuste con otro nombre @msg `{key}` must be an array of these names: {_1} `{key}` debe ser una lista de estos nombres: {_1} - Search commands Buscar comandos Search commands and tools Buscar comandos y herramientas Search commands and tools… Buscar comandos y herramientas… Recent Commands Comandos recientes No recent commands No hay comandos recientes + Search commands Buscar comandos Search Commands… Buscar comandos… Secondary Secundario Section Symbol Símbolo de sección diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index e971f1fe79..c4b75dfd05 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -1302,10 +1302,10 @@ lighting Light Valo Name* @ 66.67% (RGB/Preview) Nimi* @ 66.67% (RGB/esikatselu) No Document Ei asiakirjaa Press Paina - Search commands Hae komentoja Search commands and tools Hae komentoja ja työkaluja Style: Tyyli: Switch workspace Vaihda työtilaa + Search commands Hae komentoja Show all open documents Näytä kaikki avoimet asiakirjat Use Käytä the object to select | objektia valitaksesi sen | diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 4a89f385bf..25c41029e6 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3272,11 +3272,11 @@ digits Malayalam Malayalam Filter Layers Panel Rows Filtrer les lignes du panneau Calques @msg `Custom` stands for changed settings: save the preset under another name `Custom` désigne des réglages modifiés : enregistrez le paramètre prédéfini sous un autre nom @msg `{key}` must be an array of these names: {_1} `{key}` doit être un tableau de noms parmi {_1} - Search commands Chercher des commandes Search commands and tools Chercher commandes et outils Search commands and tools… Chercher commandes et outils… Recent Commands Commandes récentes No recent commands Aucune commande récente + Search commands Chercher des commandes Search Commands… Rechercher des commandes… Secondary Secondaire Section Symbol Symbole de section diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index d8caa0e6b1..29b99bcea3 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3388,11 +3388,11 @@ Search Commands… આદેશો શોધો… Search Fonts Folder ફોન્ટ ફોલ્ડર શોધો Search Preferences પસંદગીઓ શોધો - Search commands આદેશો શોધો Search commands and tools આદેશો અને ટૂલ્સ શોધો Search commands and tools… આદેશો અને ટૂલ્સ શોધો… Recent Commands તાજેતરના આદેશો No recent commands કોઈ તાજેતરના આદેશો નથી + Search commands આદેશો શોધો Search images છબીઓ શોધો Searching… શોધી રહ્યા છીએ… Secondary ગૌણ diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 164537497d..1375038394 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4462,11 +4462,11 @@ antiAlias Sharp शार्प Search खोजें Search All सभी खोजें Search artboards खोज आर्टबोर्ड - Search commands आदेश खोजें Search commands and tools खोज आदेश और टूल Search commands and tools… आदेश और टूल खोजें… Recent Commands हाल के आदेश No recent commands कोई हाल का आदेश नहीं + Search commands आदेश खोजें Search Commands… कमांड खोजें… Search Fonts Folder खोज फ़ॉन्ट फ़ोल्डर Search images इमेज खोजना diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 9c856323ce..7995864553 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3904,11 +3904,11 @@ mark-style Japanese Japán Filter Layers Panel Rows Rétegek panel sorainak szűrése @msg `Custom` stands for changed settings: save the preset under another name a `Custom` a módosított beállításokat jelöli: mentsd az előbeállítást más néven @msg `{key}` must be an array of these names: {_1} `{key}`: ezen nevek tömbje kell: {_1} - Search commands Parancsok keresése Search commands and tools Parancsok és eszközök keresése Search commands and tools… Parancsok és eszközök keresése… Recent Commands Legutóbbi parancsok No recent commands Nincsenek legutóbbi parancsok + Search commands Parancsok keresése Search Commands… Parancsok keresése… Search Fonts Folder Keresés betűtípusmappában Searching… Keresés… diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 0c5b65e7f0..4bfe6020f7 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -1227,10 +1227,10 @@ lighting Light Cahaya Name* @ 66.67% (RGB/Preview) Nama* @ 66.67% (RGB/Pratinjau) No Document Tidak ada dokumen Press Tekan - Search commands Cari perintah Search commands and tools Cari perintah dan alat Style: Gaya: Switch workspace Ganti ruang kerja + Search commands Cari perintah Show all open documents Tampilkan semua dokumen terbuka Use Gunakan the object to select | objek untuk memilihnya | diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index c4e2f39dc4..b933002c31 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3327,11 +3327,11 @@ digits Malayalam Malayalam Filter Layers Panel Rows Filtra righe del pannello Livelli @msg `Custom` stands for changed settings: save the preset under another name `Custom` indica impostazioni modificate: salva il preset con un altro nome @msg `{key}` must be an array of these names: {_1} `{key}` deve essere un array di questi nomi: {_1} - Search commands Cerca comandi Search commands and tools Cerca comandi e strumenti Search commands and tools… Cerca comandi e strumenti… Recent Commands Comandi recenti No recent commands Nessun comando recente + Search commands Cerca comandi Search Commands… Cerca comandi… Secondary Secondario Section Symbol Simbolo di sezione diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index bd1c00f4ae..ed710d2fc8 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3204,11 +3204,11 @@ mark-style Japanese 日本式 Filter Layers Panel Rows レイヤーパネルの行をフィルター @msg `Custom` stands for changed settings: save the preset under another name `Custom` は変更した設定を表します: プリセットを別の名前で保存してください @msg `{key}` must be an array of these names: {_1} `{key}` には {_1} の中の名前の配列を指定してください - Search commands コマンドを検索 Search commands and tools コマンドとツールを検索 Search commands and tools… コマンドとツールを検索… Recent Commands 最近使ったコマンド No recent commands 最近使ったコマンドはありません + Search commands コマンドを検索 Secondary セカンダリ Select All Art on Layer レイヤー上のすべてのアートを選択 Select All Assets すべてのアセットを選択 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 6589d60e98..1e7dadf720 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -3269,10 +3269,10 @@ lighting Light სინათლე Name* @ 66.67% (RGB/Preview) სახელი* @ 66.67% (RGB/წინასწარი ნახვა) No Document დოკუმენტი არ არის Press დააჭირეთ - Search commands ბრძანებების ძიება Search commands and tools ბრძანებებისა და ხელსაწყოების ძიება Style: სტილი: Switch workspace სამუშაო სივრცის გადართვა + Search commands ბრძანებების ძიება Show all open documents ყველა ღია დოკუმენტის ჩვენება Use გამოიყენეთ the object to select | ობიექტზე — მოსანიშნად | diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 13860e91b9..38cae50e93 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3193,11 +3193,11 @@ mark-style Japanese 일본식 Filter Layers Panel Rows 레이어 패널 행 필터링 @msg `Custom` stands for changed settings: save the preset under another name `Custom`은 변경된 설정을 나타냅니다. 프리셋을 다른 이름으로 저장하세요 @msg `{key}` must be an array of these names: {_1} `{key}`은(는) 다음 이름의 배열이어야 합니다: {_1} - Search commands 명령 검색 Search commands and tools 명령 및 도구 검색 Search commands and tools… 명령 및 도구 검색… Recent Commands 최근 명령 No recent commands 최근 명령 없음 + Search commands 명령 검색 Secondary 보조 Select All Art on Layer 레이어의 모든 아트웍 선택 Select All Assets 모든 에셋 선택 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 9f165efd14..bef25a7478 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -1795,10 +1795,10 @@ lighting Light Licht Name* @ 66.67% (RGB/Preview) Naam* @ 66.67% (RGB/Voorbeeld) No Document Geen document Press Druk op - Search commands Opdrachten zoeken Search commands and tools Opdrachten en gereedschappen zoeken Style: Stijl: Switch workspace Werkruimte wisselen + Search commands Opdrachten zoeken Show all open documents Alle geopende documenten tonen Use Gebruik the object to select | op het object om te selecteren | diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 20e2f86d10..c29121f73f 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -1254,10 +1254,10 @@ lighting Light Światło Name* @ 66.67% (RGB/Preview) Nazwa* @ 66,67% (RGB/Podgląd) No Document Brak dokumentu Press Naciśnij - Search commands Szukaj poleceń Search commands and tools Szukaj poleceń i narzędzi Style: Styl: Switch workspace Przełącz obszar roboczy + Search commands Szukaj poleceń Show all open documents Pokaż wszystkie otwarte dokumenty Use Użyj the object to select | obiekt, aby go zaznaczyć | diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 0d95825dde..bec56aff21 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2742,11 +2742,11 @@ digits Malayalam Malaiala @msg `Custom` stands for changed settings: save the preset under another name `Custom` representa configurações alteradas: salve a predefinição com outro nome @msg `{key}` must be an array of these names: {_1} `{key}` deve ser uma matriz destes nomes: {_1} Search Commands… Pesquisar Comandos… - Search commands Pesquisar comandos Search commands and tools Pesquisar comandos e ferramentas Search commands and tools… Pesquisar comandos e ferramentas… Recent Commands Comandos recentes No recent commands Nenhum comando recente + Search commands Pesquisar comandos Secondary Secundária Section Symbol Símbolo de Seção Select Selecionar diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 3dfaa07482..2f8eaf86b9 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3316,11 +3316,11 @@ digits Malayalam Малаялам Filter Layers Panel Rows Фильтровать строки панели «Слои» @msg `Custom` stands for changed settings: save the preset under another name `Custom` обозначает изменённые параметры: сохраните набор под другим именем @msg `{key}` must be an array of these names: {_1} `{key}` должно быть массивом из этих имён: {_1} - Search commands Поиск команд Search commands and tools Поиск команд и инструментов Search commands and tools… Поиск команд и инструментов… Recent Commands Недавние команды No recent commands Нет недавних команд + Search commands Поиск команд Search Commands… Поиск команд… Secondary Вторичный Section Symbol Символ параграфа diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 248adc3ec7..f82ed5aef1 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -3202,11 +3202,11 @@ digits Malayalam Malayalam Scripts Skript Search Sök Search All Sök i alla - Search commands Sök kommandon Search commands and tools Sök kommandon och verktyg Search commands and tools… Sök kommandon och verktyg… Recent Commands Senaste kommandon No recent commands Inga senaste kommandon + Search commands Sök kommandon Search Commands… Sök kommandon… Secondary Sekundär Section Symbol Paragraftecken diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index c8ff293ebb..7d24eb2167 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3074,11 +3074,11 @@ digits Malayalam Malayalam Redefine {name} “{name}” Stilini Yeniden Tanımla @msg `Custom` stands for changed settings: save the preset under another name `Custom` değiştirilmiş ayarları ifade eder: ön ayarı başka bir adla kaydedin @msg `{key}` must be an array of these names: {_1} `{key}` şu adlardan oluşan bir dizi olmalıdır: {_1} - Search commands Komutları arayın Search commands and tools Komutları ve araçları arayın Search commands and tools… Komutları ve araçları arayın… Recent Commands Son komutlar No recent commands Son komut yok + Search commands Komutları arayın Search Commands… Arama Komutları… Secondary İkincil Section Symbol Bölüm Sembolü diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index c4e95fd2db..33e2e91479 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3319,11 +3319,11 @@ digits Malayalam Малаялам Filter Layers Panel Rows Фільтрувати рядки панелі «Шари» @msg `Custom` stands for changed settings: save the preset under another name `Custom` позначає змінені параметри: збережіть набір під іншим ім’ям @msg `{key}` must be an array of these names: {_1} `{key}` має бути масивом цих назв: {_1} - Search commands Пошук команд Search commands and tools Пошук команд та інструментів Search commands and tools… Пошук команд та інструментів… Recent Commands Нещодавні команди No recent commands Немає нещодавніх команд + Search commands Пошук команд Search Commands… Пошук команд… Secondary Вторинний Section Symbol Символ параграфа diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 6c79308d93..7e24df798e 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3661,11 +3661,11 @@ mark-style Japanese Kiểu Nhật Filter Layers Panel Rows Lọc hàng bảng Lớp @msg `Custom` stands for changed settings: save the preset under another name `Custom` biểu thị các cài đặt đã thay đổi: hãy lưu thiết lập sẵn với tên khác @msg `{key}` must be an array of these names: {_1} `{key}` phải là một mảng gồm các tên sau: {_1} - Search commands Tìm kiếm lệnh Search commands and tools Tìm kiếm lệnh và công cụ Search commands and tools… Tìm kiếm lệnh và công cụ… Recent Commands Lệnh gần đây No recent commands Không có lệnh gần đây + Search commands Tìm kiếm lệnh Search Commands… Tìm kiếm lệnh… Search Fonts Folder Tìm kiếm thư mục phông chữ Searching… Đang tìm kiếm… diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 1e318d4001..392ac019ba 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -3146,11 +3146,11 @@ digits Malayalam 马拉雅拉姆数字 Locked 已锁定 Hidden 已隐藏 Filter Layers Panel Rows 筛选图层面板行 - Search commands 搜索命令 Search commands and tools 搜索命令和工具 Search commands and tools… 搜索命令和工具… Recent Commands 最近使用的命令 No recent commands 没有最近使用的命令 + Search commands 搜索命令 Search Commands… 搜索命令… Secondary 次要 Section Symbol 章节符号 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e2f1a7950c..d20b65b184 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4452,11 +4452,11 @@ digits Malayalam 馬來亞拉姆數字 Locked 已鎖定 Hidden 已隱藏 Filter Layers Panel Rows 篩選圖層面板列 - Search commands 搜尋指令 Search commands and tools 搜尋指令與工具 Search commands and tools… 搜尋指令與工具… Recent Commands 最近使用的指令 No recent commands 沒有最近使用的指令 + Search commands 搜尋指令 Search Commands… 搜尋指令… Secondary 次要 Section Symbol 章節符號 diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rs index cbbd216e75..8f62cbff12 100644 --- a/crates/ui-egui/src/titlebar.rs +++ b/crates/ui-egui/src/titlebar.rs @@ -322,11 +322,15 @@ mod tests { assert!(!a.shrink(0.5).intersects(b.shrink(0.5)), "{a:?} overlaps {b:?} at {width}"); } } - // Wide windows show the whole group; narrow ones drop Discord, then the search icon. + // Wide windows show the whole group, the search field included; narrow ones drop the + // community button first, and the search field goes before the search icon. let texts: Vec = texts(&out).into_iter().map(|(t, _)| t).collect(); let has = |s: &str| texts.iter().any(|t| t == s); assert_eq!(has("Discord"), width > 1000.0, "{width}: {texts:?}"); - // Search is an icon only (as in PhotoCraft): its label lives in the tooltip. + if width > 1000.0 { + assert!(has("Search commands"), "the search field shows at {width}: {texts:?}"); + } + // The search's tooltip text is not painted in the bar. assert!(!has("Search commands and tools"), "{width}: {texts:?}"); } } diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index d4d677a0a6..444cdda37d 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -30,7 +30,9 @@ pub use buttons::{ SPLIT_ARROW, flat_button, flat_button_fit, icon_button, icon_button_enabled, menu_item, menu_item_name, paint_icon_button, primary_button, primary_button_enabled, secondary_button, split_button, split_button_named, toggle_icon, }; -pub(crate) use buttons::{button_width, flat_button_fit_width, icon_button_info, primary_button_width, secondary_button_width}; +pub(crate) use buttons::{ + button_width, flat_button_fit_width, icon_button_info, paint_icon_button_named, primary_button_width, secondary_button_width, +}; #[cfg(test)] use chips::gradient_chip_colors; pub use chips::{ProxyClicks, chip_button, chip_button_named, fill_stroke_proxy, gradient_chip, paint_chip, proxy_chip, swatch_tile}; diff --git a/crates/ui-egui/src/widgets/buttons.rs b/crates/ui-egui/src/widgets/buttons.rs index a8b8486bfa..19062eaf4c 100644 --- a/crates/ui-egui/src/widgets/buttons.rs +++ b/crates/ui-egui/src/widgets/buttons.rs @@ -8,6 +8,12 @@ pub fn icon_button(ui: &mut Ui, icon: &str, tip: &str, selected: bool, size: f32 /// [`icon_button`] drawn for a response the caller made (its own id or sense). pub fn paint_icon_button(ui: &mut Ui, resp: Response, icon: &str, tip: &str, selected: bool) -> Response { + paint_icon_button_named(ui, resp, icon, tl!(tip), tl!(tip), selected) +} + +/// [`paint_icon_button`] that screen readers call `name` and that shows the tool tip `tip` (none +/// when empty), both as given. +pub(crate) fn paint_icon_button_named(ui: &mut Ui, resp: Response, icon: &str, name: &str, tip: &str, selected: bool) -> Response { let t = Tokens::get(ui.ctx()); let rect = resp.rect; let size = rect.width(); @@ -21,8 +27,8 @@ pub fn paint_icon_button(ui: &mut Ui, resp: Response, icon: &str, tip: &str, sel ui.painter().rect_filled(rect, CornerRadius::same(5), bg); let pad = (size * 0.2).round(); icons::paint(ui, icon, rect.shrink(pad), if selected { t.text_strong } else { t.icon }); - resp.widget_info(|| icon_button_info(ui.is_enabled(), selected, tl!(tip))); - if !tip.is_empty() { resp.on_hover_text(tl!(tip)) } else { resp } + resp.widget_info(|| icon_button_info(ui.is_enabled(), selected, name)); + if !tip.is_empty() { resp.on_hover_text(tip) } else { resp } } /// Small flat text button (Quick Actions style). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index a4585db2f7..ecd556028f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1017,7 +1017,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The Free Transform widget's Constrain works in Free Distort as well as in Free Transform ([the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/free-transform-tool.html)). With Constrain on, or Shift held, a corner dragged in Free Distort moves only along the line through the opposite corner, in the box's own proportions, and the other three corners stay in place; on a turned box the line runs through the box's own corners. The line is VectorCraft's own rule. Cmd/Ctrl+Alt+Shift on a corner still drags in Perspective Distort, where Constrain stays unavailable (tools `xform::free::tests::free_distort_corner_keeps_to_its_diagonal_with_shift_or_constrain`, `shift_pressed_during_a_free_distort_drag_constrains_it`, `a_turned_box_is_constrained_along_its_own_diagonal`, `along_diagonal_of_a_degenerate_box`; engine `xform::free_transform_constrained_distort_keeps_the_corner_on_its_diagonal`; ui-egui `free_transform::tests::the_widget_sets_the_mode_and_a_corner_drag_then_distorts`). - Native macOS menu bar, vector tool cursors, a command palette (Help › Search Commands…), middle-button panning with any tool. Native menus explicitly end tracking on command selection, outside window presses and Escape; menu updates wait until tracking ends, and a dismissing press never starts a canvas gesture (M14.8). - A Recent Commands button beside the Help › Search Commands field lists the last five commands and tools picked from the palette, most recent first, with a command picked again moved to the top. Choosing a row closes the palette and runs it as a pick of the same result does; with no picks yet the list shows a dimmed No recent commands row, and a command that is not available now, such as a filter of a plug-in that is not loaded, is left out until it comes back. The ids are saved with the UI state. While the list is open, Up and Down move through its rows, wrapping at the ends, and Escape closes the list before the palette. This is VectorCraft's own addition and does not raise a score (#6376; `palette` tests `recent_commands_*`, `a_recent_command_runs_what_its_pick_runs`, `the_keys_wrap_within_recent_commands`, `escape_closes_recent_commands_before_the_palette`). - - The app bar's search control is a field showing a magnifier, "Search commands" and the Help › Search Commands… shortcut. The field shows no shortcut when the shortcut is cleared or too long to fit beside the text; the tooltip and the screen-reader name still give it. A click on the field, or Enter or Space while it has the keyboard focus, toggles the command palette as the shortcut does, and the palette's popup holds the text field. While the field has the focus, the app's own keys stay off, so Enter does not open Move and Tab moves the focus on. While a dialog is open the field and the icon do nothing, as the shortcut does. Screen readers name the field Search commands, with the shortcut. As the bar narrows, the community button goes first, then Explore tutorials, then the field becomes the magnifier icon, then the workspace switcher narrows to 64 points, then the icon goes; Safe Mode's label keeps its room first. This is VectorCraft's own addition and does not raise a score (`chrome::tests`: `the_app_bar_gives_up_its_right_hand_controls_in_order`, `a_wide_app_bar_shows_a_search_field_with_the_palette_shortcut`, `the_search_field_follows_the_palettes_shortcut`, `a_long_shortcut_leaves_the_search_hint_readable`, `a_click_on_the_search_field_opens_the_palette`, `the_keyboard_opens_the_palette_from_the_search_field`, `a_narrowing_app_bar_turns_the_search_field_into_the_icon`). + - The app bar's search control is a field showing a magnifier, "Search commands" and the Help › Search Commands… shortcut. The field shows no shortcut when the shortcut is cleared or too long to fit beside the text; the tooltip and the screen-reader name still give it. A click on the field, or Enter or Space while it has the keyboard focus, toggles the command palette as the shortcut does, and the palette's popup holds the text field. While the field has the focus, the app's existing rule for a focused control keeps the app's own keys off, so Enter does not open Move and Tab moves the focus on. While a dialog is open the field and the icon are drawn disabled and do nothing, as the shortcut does. Screen readers name the field and the icon Search commands, with the shortcut. As the bar narrows, the community button goes first, then Explore tutorials, then the field becomes the magnifier icon, then the workspace switcher narrows to 64 points, then the icon goes; Safe Mode's label keeps its room first. The field is wider than the icon, so the community button and Explore tutorials go at wider bars than they did beside the icon. This is VectorCraft's own addition and does not raise a score (`chrome::tests`: `the_app_bar_gives_up_its_right_hand_controls_in_order`, `a_wide_app_bar_shows_a_search_field_with_the_palette_shortcut`, `the_search_field_follows_the_palettes_shortcut`, `a_long_shortcut_leaves_the_search_hint_readable`, `a_click_on_the_search_field_opens_the_palette`, `the_search_icon_has_the_fields_name_and_both_are_disabled_under_a_dialog`, `the_keyboard_opens_the_palette_from_the_search_field`, `a_narrowing_app_bar_turns_the_search_field_into_the_icon`). - The Learn panel (Window › Learn, or Explore tutorials beside the search field on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their progress rings and counts of tutorials finished; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list`, `learn.tab {tab}`, `learn.skill {skill}`, `learn.show {tutorial}` and `learn.back` script it, and the tab buttons, the rows and Back run them ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`). - A tool's name in a Learn tutorial step is a blue link that shows where the tool is without choosing it (`learn.locateTool {tool}`): its toolbar button is marked, a collapsed group's flyout opens with the tool's row marked, a torn-off strip comes to the front, and a tool no shown toolbar holds is marked in the All Tools drawer. The mark, its 3 seconds and the hidden-toolbar cases are VectorCraft's own rules ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`, the `a_learn_link_*` tests in `toolbar::tests`). - Under a tutorial's steps, View more opens the tutorial's own practice sample as a new untitled document, and once the tutorial is finished, Next Up moves to the next tutorial in the same skill, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). The samples are VectorCraft's own drawings. A Finish tutorial button that shows once the sample is open, the untitled copy, Back to skills in place of Next Up after a skill's last tutorial, and Next Up showing the next tutorial without opening its sample are VectorCraft's own rules. `learn.openSample`, `learn.finish`, `learn.next` and `learn.skills` (Back to skills) script them. Not done: the help page's short video. Regression tests: `view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document`, `finishing_a_tutorial_offers_next_up_in_its_skill`, `the_practice_controls_work_from_the_keyboard`, `the_last_tutorial_of_a_skill_offers_back_to_skills`, `learn_finish_and_learn_next_follow_the_practice`, `learn_skills_shows_the_list_of_skills`, `the_practice_commands_reject_a_missing_or_unknown_tutorial`, `every_tutorial_has_its_own_readable_sample` and `the_next_tutorial_is_the_next_one_in_the_same_skill` in `crates/ui-egui/src/panels/learn/tests.rs`. From 9adda33c8c403aa9aaa8bc48ab317eb1071ff843 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 12:42:27 -0800 Subject: [PATCH 3/3] Command palette: the opening-click test clicks the app bar's search field The test looked for the app bar's search icon by its old name. The bar now shows a search field named "Search commands" in its place, so the test finds and clicks the field. --- crates/ui-egui/src/palette.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 544929a0e7..c6e1bf40f1 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -2487,13 +2487,13 @@ mod tests { } } - /// The click on the app bar's search button that opens the palette leaves it open; the next - /// click on the button closes it. + /// The click on the app bar's search field that opens the palette leaves it open; the next + /// click on the field closes it. #[test] fn the_click_that_opens_the_palette_does_not_close_it() { let mut window = Window::new(); let nodes = window.frame(vec![]); - let at = button_at(&nodes, "Search commands, tools, panels and effects"); + let at = button_at(&nodes, "Search commands"); window.click(at); assert!(window.app.ui.palette_open, "the click opens the palette"); window.frame(vec![]);