From 73fe594bb36a300b3d487e8d618ce646edfabd0e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 10:42:25 -0800 Subject: [PATCH 1/4] Command Palette: the highlighted result points to where it lives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the palette is open, the highlighted result is marked where it lives, in the same frame the arrow keys or the pointer move the highlight. A result with an item of the in-window menu bar has that menu's title outlined, and a box under it shows the item's whole path (Effect › Stylize › Round Corners…). A panel points at the Window menu. A tool has its slot's button outlined on the toolbar its row names, or its own button on a strip torn off its group. The box beside it, on the canvas side of the toolbar, names the tool, or reads "In the Direct Selection Tool group: press and hold to open it" for a tool hidden in a group; screen readers hear that sentence with the search field's description. The box stays inside the window and off the button and the palette's popup: beside a button, its text wraps to up to three rows to fit before the popup or the window's edge, and where it still would not fit, the footer shows the text and only the outline is drawn. When the popup covers the control, nothing is drawn and the footer names the home. Highlighting a result opens no menu, flyout or All Tools drawer, shows no toolbar and leaves the chosen tool as it is. With the system's menu bar, nothing is drawn over it, and the footer reads "In the menu bar:" and the path. When no control in view shows the home (Presentation Mode, toolbars hidden by Window › Tools or Tab, a button scrolled out of view or under a floating panel or another toolbar), the footer names the home followed by "not shown now". A command with no menu item reads "No menu item" there, with its shortcut. The menu bar, the Tools panel, the toolbars made with New Toolbar and the strips torn off them note where they draw each control only while the palette is open, and only controls wholly in view. The list keeps one pass of each window. The palette uses only the controls noted in the current pass of its own window, and shows no footer line for the home in the pass that opens it, before anything is noted. learn.locateTool's search for a tool's place moves into a function without side effects (locate::find), which the palette calls with the order its rows use. Learn calls it and then shows the toolbar, flyout or drawer as before, and the mark's outline is shared. New strings have rows in every catalog. --- crates/ui-egui/src/custom_toolbars.rs | 1 + crates/ui-egui/src/i18n/bg.tsv | 3 + crates/ui-egui/src/i18n/bs.tsv | 3 + crates/ui-egui/src/i18n/ca.tsv | 3 + crates/ui-egui/src/i18n/cs.tsv | 3 + crates/ui-egui/src/i18n/da.tsv | 3 + crates/ui-egui/src/i18n/de.tsv | 3 + crates/ui-egui/src/i18n/el.tsv | 3 + crates/ui-egui/src/i18n/es.tsv | 3 + crates/ui-egui/src/i18n/fi.tsv | 3 + crates/ui-egui/src/i18n/fr.tsv | 3 + crates/ui-egui/src/i18n/gu.tsv | 3 + crates/ui-egui/src/i18n/hi.tsv | 3 + crates/ui-egui/src/i18n/hu.tsv | 3 + crates/ui-egui/src/i18n/id.tsv | 3 + crates/ui-egui/src/i18n/it.tsv | 3 + crates/ui-egui/src/i18n/ja.tsv | 3 + crates/ui-egui/src/i18n/ka.tsv | 3 + crates/ui-egui/src/i18n/ko.tsv | 3 + crates/ui-egui/src/i18n/nl.tsv | 3 + crates/ui-egui/src/i18n/pl.tsv | 3 + crates/ui-egui/src/i18n/pt-br.tsv | 3 + crates/ui-egui/src/i18n/ru.tsv | 3 + crates/ui-egui/src/i18n/sv.tsv | 3 + crates/ui-egui/src/i18n/tr.tsv | 3 + crates/ui-egui/src/i18n/uk.tsv | 3 + crates/ui-egui/src/i18n/vi.tsv | 3 + crates/ui-egui/src/i18n/zh-hans.tsv | 3 + crates/ui-egui/src/i18n/zh-hant.tsv | 3 + crates/ui-egui/src/menus/bar.rs | 1 + crates/ui-egui/src/palette.rs | 864 +++++++++++++++++++++- crates/ui-egui/src/panels/learn/locate.rs | 92 ++- crates/ui-egui/src/toolbar.rs | 13 +- docs/target-app-parity.md | 1 + 34 files changed, 1023 insertions(+), 33 deletions(-) diff --git a/crates/ui-egui/src/custom_toolbars.rs b/crates/ui-egui/src/custom_toolbars.rs index f8c3033a5e..5ee944afe3 100644 --- a/crates/ui-egui/src/custom_toolbars.rs +++ b/crates/ui-egui/src/custom_toolbars.rs @@ -1121,6 +1121,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { ui.add_space((middle - BUTTON / 2.0 * row.len() as f32 - ui.cursor().min.x).max(0.0)); for &(s, slot) in row { let Some((rect, shown)) = slot_button(ui, &t, &press, slot, &mut actions) else { continue }; + crate::palette::note_spot(ui, rect, || crate::palette::SpotAt::Slot(Some(bar.name.clone()), slot.clone())); if edit_this { buttons.push((s, rect)); } diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 11db47b8da..e2c664ab34 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -3195,6 +3195,9 @@ digits Malayalam Малаялам No menu item Няма елемент в менюто Toolbar Лента с инструменти {toolbar}, in the {tool} group {toolbar}, в групата на {tool} + In the menu bar: {path} В лентата с менюта: {path} + In the {group} group: press and hold to open it В групата {group}: натиснете и задръжте, за да я отворите + {home}, not shown now {home}, не се показва сега @plural {n} result|{n} results {n} резултат|{n} резултата @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} от {n} резултат. Продължете да пишете, за да ги стесните.|{shown} от {n} резултата. Продължете да пишете, за да ги стесните. Recent Commands Последни команди diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 0eb468b3d4..13effad79c 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -4394,6 +4394,9 @@ font-technology Variable Varijabilni No menu item Nema stavke menija Toolbar Traka s alatima {toolbar}, in the {tool} group {toolbar}, u grupi {tool} + In the menu bar: {path} Na traci menija: {path} + In the {group} group: press and hold to open it U grupi {group}: pritisnite i držite da je otvorite + {home}, not shown now {home}, trenutno nije prikazano @plural {n} result|{n} results {n} rezultat|{n} rezultata|{n} rezultata @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} od {n} rezultata. Nastavite kucati da ih suzite.|{shown} od {n} rezultata. Nastavite kucati da ih suzite.|{shown} od {n} rezultata. Nastavite kucati da ih suzite. Recent Commands Nedavne naredbe diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 7abf69a8b5..7f0a3c57aa 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -4124,6 +4124,9 @@ digits Malayalam Malaiàlam No menu item Cap element de menú Toolbar Barra d’eines {toolbar}, in the {tool} group {toolbar}, al grup {tool} + In the menu bar: {path} A la barra de menús: {path} + In the {group} group: press and hold to open it Al grup {group}: manteniu premut per obrir-lo + {home}, not shown now {home}, ara no es mostra @plural {n} result|{n} results {n} resultat|{n} resultats @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultat. Continueu escrivint per reduir-los.|{shown} de {n} resultats. Continueu escrivint per reduir-los. Recent Commands Ordres recents diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index aa95a8140d..0c04e49f7a 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4499,6 +4499,9 @@ font-technology Variable Variabilní No menu item Žádná položka nabídky Toolbar Panel nástrojů {toolbar}, in the {tool} group {toolbar}, ve skupině {tool} + In the menu bar: {path} V řádku nabídek: {path} + In the {group} group: press and hold to open it Ve skupině {group}: stisknutím a podržením ji otevřete + {home}, not shown now {home}, nyní není zobrazeno @plural {n} result|{n} results {n} výsledek|{n} výsledky|{n} výsledků @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} z {n} výsledku. Pište dál a výsledky se zúží.|{shown} z {n} výsledků. Pište dál a výsledky se zúží.|{shown} z {n} výsledků. Pište dál a výsledky se zúží. Recent Commands Nedávné příkazy diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index b565df95a2..1cedc382f1 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6873,6 +6873,9 @@ font-technology Variable Variable No menu item Intet menupunkt Toolbar Værktøjslinje {toolbar}, in the {tool} group {toolbar}, i gruppen {tool} + In the menu bar: {path} I menulinjen: {path} + In the {group} group: press and hold to open it I gruppen {group}: tryk og hold for at åbne den + {home}, not shown now {home}, vises ikke nu @plural {n} result|{n} results {n} resultat|{n} resultater @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} af {n} resultat. Skriv videre for at indsnævre dem.|{shown} af {n} resultater. Skriv videre for at indsnævre dem. Recent Commands Seneste kommandoer diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 7080608618..c0594cad7f 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3259,6 +3259,9 @@ digits Malayalam Malayalam No menu item Kein Menüeintrag Toolbar Werkzeugleiste {toolbar}, in the {tool} group {toolbar}, in der Gruppe „{tool}“ + In the menu bar: {path} In der Menüleiste: {path} + In the {group} group: press and hold to open it In der Gruppe {group}: zum Öffnen gedrückt halten + {home}, not shown now {home}, derzeit nicht angezeigt Tool Werkzeug Command Befehl @plural {n} result|{n} results {n} Ergebnis|{n} Ergebnisse diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 81758e74be..046e5ecd3e 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3961,6 +3961,9 @@ digits Malayalam Μαλαγιάλαμ No menu item Χωρίς στοιχείο μενού Toolbar Γραμμή εργαλείων {toolbar}, in the {tool} group {toolbar}, στην ομάδα {tool} + In the menu bar: {path} Στη γραμμή μενού: {path} + In the {group} group: press and hold to open it Στην ομάδα {group}: πατήστε παρατεταμένα για να ανοίξει + {home}, not shown now {home}, δεν εμφανίζεται τώρα @plural {n} result|{n} results {n} αποτέλεσμα|{n} αποτελέσματα @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} από {n} αποτέλεσμα. Συνεχίστε να πληκτρολογείτε για να τα περιορίσετε.|{shown} από {n} αποτελέσματα. Συνεχίστε να πληκτρολογείτε για να τα περιορίσετε. Recent Commands Πρόσφατες εντολές diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index df7d42b3ef..fb4b0c72f6 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3297,6 +3297,9 @@ digits Malayalam Malayálam No menu item Sin elemento de menú Toolbar Barra de herramientas {toolbar}, in the {tool} group {toolbar}, en el grupo {tool} + In the menu bar: {path} En la barra de menús: {path} + In the {group} group: press and hold to open it En el grupo {group}: mantén pulsado para abrirlo + {home}, not shown now {home}, no se muestra ahora @plural {n} result|{n} results {n} resultado|{n} resultados @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultado. Sigue escribiendo para acotarlos.|{shown} de {n} resultados. Sigue escribiendo para acotarlos. Recent Commands Comandos recientes diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 9f6dbda3f5..88b919e7f1 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -4418,6 +4418,9 @@ font-technology Variable Muuttuvat No menu item Ei valikkokohdetta Toolbar Työkalurivi {toolbar}, in the {tool} group {toolbar}, ryhmässä {tool} + In the menu bar: {path} Valikkorivillä: {path} + In the {group} group: press and hold to open it Ryhmässä {group}: avaa painamalla pitkään + {home}, not shown now {home}, ei näkyvissä nyt @plural {n} result|{n} results {n} tulos|{n} tulosta @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown}/{n} tulosta. Kirjoita lisää rajataksesi tuloksia.|{shown}/{n} tulosta. Kirjoita lisää rajataksesi tuloksia. Recent Commands Viimeisimmät komennot diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 5b084deebc..1bbdf3f56a 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3285,6 +3285,9 @@ digits Malayalam Malayalam No menu item Aucun élément de menu Toolbar Barre d’outils {toolbar}, in the {tool} group {toolbar}, dans le groupe {tool} + In the menu bar: {path} Dans la barre des menus, sous {path} + In the {group} group: press and hold to open it Dans le groupe {group}, maintenez enfoncé pour l’ouvrir + {home}, not shown now {home}, non affiché pour l’instant @plural {n} result|{n} results {n} résultat|{n} résultats @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} sur {n} résultat. Continuez à taper pour les affiner.|{shown} sur {n} résultats. Continuez à taper pour les affiner. Recent Commands Commandes récentes diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index b7ba94dcd9..eb39b36683 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3400,6 +3400,9 @@ No menu item કોઈ મેનૂ આઇટમ નથી Toolbar ટૂલબાર {toolbar}, in the {tool} group {toolbar}, {tool} જૂથમાં + In the menu bar: {path} મેનૂ બારમાં: {path} + In the {group} group: press and hold to open it {group} જૂથમાં: ખોલવા માટે દબાવીને પકડી રાખો + {home}, not shown now {home}, હમણાં બતાવેલ નથી Tool ટૂલ Command કમાન્ડ Panel પેનલ diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 15a93243be..4843bacb7f 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4474,6 +4474,9 @@ antiAlias Sharp शार्प No menu item कोई मेनू आइटम नहीं Toolbar टूलबार {toolbar}, in the {tool} group {toolbar}, {tool} समूह में + In the menu bar: {path} मेनू बार में: {path} + In the {group} group: press and hold to open it {group} समूह में: खोलने के लिए दबाकर रखें + {home}, not shown now {home}, अभी नहीं दिखाया गया @plural {n} result|{n} results {n} परिणाम|{n} परिणाम @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} में से {shown} परिणाम। इन्हें सीमित करने के लिए लिखते रहें।|{n} में से {shown} परिणाम। इन्हें सीमित करने के लिए लिखते रहें। Recent Commands हाल के आदेश diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 708bcac172..a9902799c3 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3918,6 +3918,9 @@ mark-style Japanese Japán No menu item Nincs menüpont Toolbar Eszköztár {toolbar}, in the {tool} group {toolbar}, a(z) {tool} csoportjában + In the menu bar: {path} A menüsorban: {path} + In the {group} group: press and hold to open it A(z) {group} csoportban: a megnyitáshoz nyomja le és tartsa lenyomva + {home}, not shown now {home}, most nem látható @plural {n} result|{n} results {n} találat @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} találatból {shown} látható. Gépeljen tovább a szűkítéshez. Recent Commands Legutóbbi parancsok diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index d61a59f994..8ab7c786ae 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4150,6 +4150,9 @@ font-technology Variable Variabel No menu item Tidak ada item menu Toolbar Bilah alat {toolbar}, in the {tool} group {toolbar}, dalam grup {tool} + In the menu bar: {path} Di bilah menu: {path} + In the {group} group: press and hold to open it Di grup {group}: tekan dan tahan untuk membukanya + {home}, not shown now {home}, tidak ditampilkan sekarang @plural {n} result|{n} results {n} hasil @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} dari {n} hasil. Terus ketik untuk mempersempitnya. Recent Commands Perintah terbaru diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 57b6c23772..8c568e7d53 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3340,6 +3340,9 @@ digits Malayalam Malayalam No menu item Nessuna voce di menu Toolbar Barra degli strumenti {toolbar}, in the {tool} group {toolbar}, nel gruppo {tool} + In the menu bar: {path} Nella barra dei menu: {path} + In the {group} group: press and hold to open it Nel gruppo {group}: tieni premuto per aprirlo + {home}, not shown now {home}, ora non visibile Tool Strumento Command Comando @plural {n} result|{n} results {n} risultato|{n} risultati diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 240cbe4d7e..2e4896c640 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3218,6 +3218,9 @@ mark-style Japanese 日本式 No menu item メニュー項目なし Toolbar ツールバー {toolbar}, in the {tool} group {toolbar}、{tool} のグループ内 + In the menu bar: {path} メニューバー: {path} + In the {group} group: press and hold to open it {group} のグループ内: 長押しで開きます + {home}, not shown now {home}、現在は表示されていません @plural {n} result|{n} results {n} 件 @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} 件中 {shown} 件。続けて入力すると絞り込めます。 Recent Commands 最近使ったコマンド diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index b20ce14387..b5cdb3505d 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -6102,6 +6102,9 @@ font-technology Variable ცვლადი No menu item მენიუს ელემენტი არ არის Toolbar ხელსაწყოთა ზოლი {toolbar}, in the {tool} group {toolbar}, ჯგუფში {tool} + In the menu bar: {path} მენიუს ზოლში: {path} + In the {group} group: press and hold to open it ჯგუფში {group}: გასახსნელად დააჭირეთ და გეჭიროთ + {home}, not shown now {home}, ახლა არ ჩანს @plural {n} result|{n} results {n} შედეგი @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} შედეგიდან {shown}. გააგრძელეთ აკრეფა მათ შესამცირებლად. Recent Commands ბოლო ბრძანებები diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 6151b3b3a1..df53b2d97b 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3207,6 +3207,9 @@ mark-style Japanese 일본식 No menu item 메뉴 항목 없음 Toolbar 도구 모음 {toolbar}, in the {tool} group {toolbar}, {tool} 그룹 + In the menu bar: {path} 메뉴 막대: {path} + In the {group} group: press and hold to open it {group} 그룹: 길게 눌러 여세요 + {home}, not shown now {home}, 지금 표시되지 않음 Tool 도구 Command 명령 @plural {n} result|{n} results 결과 {n}개 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 375216b63e..f2e7e41cef 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4767,6 +4767,9 @@ font-technology Variable Variabel No menu item Geen menu-item Toolbar Gereedschapsbalk {toolbar}, in the {tool} group {toolbar}, in de groep {tool} + In the menu bar: {path} In de menubalk: {path} + In the {group} group: press and hold to open it In de groep {group}: ingedrukt houden om te openen + {home}, not shown now {home}, nu niet zichtbaar @plural {n} result|{n} results {n} resultaat|{n} resultaten @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} van {n} resultaat. Typ verder om ze te beperken.|{shown} van {n} resultaten. Typ verder om ze te beperken. Recent Commands Recente opdrachten diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 60b4a5da8b..483d00fdf9 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -4340,6 +4340,9 @@ font-technology Variable Zmienne No menu item Brak pozycji menu Toolbar Pasek narzędzi {toolbar}, in the {tool} group {toolbar}, w grupie {tool} + In the menu bar: {path} Na pasku menu: {path} + In the {group} group: press and hold to open it W grupie {group}: naciśnij i przytrzymaj, aby ją otworzyć + {home}, not shown now {home}, teraz niewidoczne @plural {n} result|{n} results {n} wynik|{n} wyniki|{n} wyników @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} z {n} wyniku. Pisz dalej, aby je zawęzić.|{shown} z {n} wyników. Pisz dalej, aby je zawęzić.|{shown} z {n} wyników. Pisz dalej, aby je zawęzić. Recent Commands Ostatnie polecenia diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 7d90f36d4b..21e82ad1a3 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2756,6 +2756,9 @@ digits Malayalam Malaiala No menu item Nenhum item de menu Toolbar Barra de Ferramentas {toolbar}, in the {tool} group {toolbar}, no grupo {tool} + In the menu bar: {path} Na barra de menus: {path} + In the {group} group: press and hold to open it No grupo {group}: mantenha pressionado para abri-lo + {home}, not shown now {home}, não exibido agora @plural {n} result|{n} results {n} resultado|{n} resultados @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} de {n} resultado. Continue digitando para filtrá-los.|{shown} de {n} resultados. Continue digitando para filtrá-los. Recent Commands Comandos recentes diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 6bd50f8acf..62c73c5b9a 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3329,6 +3329,9 @@ digits Malayalam Малаялам No menu item Нет пункта меню Toolbar Панель инструментов {toolbar}, in the {tool} group {toolbar}, в группе «{tool}» + In the menu bar: {path} В строке меню: {path} + In the {group} group: press and hold to open it В группе {group}: нажмите и удерживайте, чтобы открыть её + {home}, not shown now {home}, сейчас не показано @plural {n} result|{n} results {n} результат|{n} результата|{n} результатов @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} из {n} результата. Продолжайте вводить, чтобы сузить их.|{shown} из {n} результатов. Продолжайте вводить, чтобы сузить их.|{shown} из {n} результатов. Продолжайте вводить, чтобы сузить их. Recent Commands Недавние команды diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 2ac4d2e3cf..a707130a0e 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -3215,6 +3215,9 @@ digits Malayalam Malayalam No menu item Inget menyalternativ Toolbar Verktygsfält {toolbar}, in the {tool} group {toolbar}, i gruppen {tool} + In the menu bar: {path} I menyraden: {path} + In the {group} group: press and hold to open it I gruppen {group}: tryck och håll ned för att öppna den + {home}, not shown now {home}, visas inte nu @plural {n} result|{n} results {n} resultat|{n} resultat @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {shown} av {n} resultat. Fortsätt skriva för att begränsa dem.|{shown} av {n} resultat. Fortsätt skriva för att begränsa dem. Recent Commands Senaste kommandon diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index a756b478f7..6ca949c7f7 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3087,6 +3087,9 @@ digits Malayalam Malayalam No menu item Menü öğesi yok Toolbar Araç Çubuğu {toolbar}, in the {tool} group {toolbar}, {tool} grubunda + In the menu bar: {path} Menü çubuğunda: {path} + In the {group} group: press and hold to open it {group} grubunda: açmak için basılı tutun + {home}, not shown now {home}, şu anda gösterilmiyor @plural {n} result|{n} results {n} sonuç @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. {n} sonuçtan {shown} tanesi. Daraltmak için yazmaya devam edin. Recent Commands Son komutlar diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 047f5e3c92..7822b8747f 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3332,6 +3332,9 @@ digits Malayalam Малаялам No menu item Немає пункту меню Toolbar Панель інструментів {toolbar}, in the {tool} group {toolbar}, у групі «{tool}» + In the menu bar: {path} У рядку меню: {path} + In the {group} group: press and hold to open it У групі {group}: натисніть і утримуйте, щоб відкрити її + {home}, not shown now {home}, зараз не показано Tool Інструмент Command Команда @plural {n} result|{n} results {n} результат|{n} результати|{n} результатів diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index f8b6148789..a6c88ee160 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3675,6 +3675,9 @@ mark-style Japanese Kiểu Nhật No menu item Không có mục menu Toolbar Thanh công cụ {toolbar}, in the {tool} group {toolbar}, trong nhóm {tool} + In the menu bar: {path} Trên thanh menu: {path} + In the {group} group: press and hold to open it Trong nhóm {group}: nhấn giữ để mở + {home}, not shown now {home}, hiện không hiển thị Tool Công cụ Command Lệnh @plural {n} result|{n} results {n} kết quả diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index ab720c08fc..c1e7a2afc5 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -3159,6 +3159,9 @@ digits Malayalam 马拉雅拉姆数字 No menu item 无菜单项 Toolbar 工具栏 {toolbar}, in the {tool} group {toolbar},位于 {tool} 组中 + In the menu bar: {path} 在菜单栏中:{path} + In the {group} group: press and hold to open it 在“{group}”组中:按住即可打开 + {home}, not shown now {home},当前未显示 @plural {n} result|{n} results {n} 个结果 @plural {shown} of {n} result. Keep typing to narrow them.|{shown} of {n} results. Keep typing to narrow them. 共 {n} 个结果,显示 {shown} 个。继续输入以缩小范围。 Recent Commands 最近使用的命令 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 73edaec679..6a791458fc 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4465,6 +4465,9 @@ digits Malayalam 馬來亞拉姆數字 No menu item 無選單項目 Toolbar 工具列 {toolbar}, in the {tool} group {toolbar},位於 {tool} 群組中 + In the menu bar: {path} 在選單列中:{path} + In the {group} group: press and hold to open it 在「{group}」群組中:按住即可開啟 + {home}, not shown now {home},目前未顯示 Tool 工具 Command 指令 @plural {n} result|{n} results {n} 個結果 diff --git a/crates/ui-egui/src/menus/bar.rs b/crates/ui-egui/src/menus/bar.rs index 85588620e8..4481a1a9ce 100644 --- a/crates/ui-egui/src/menus/bar.rs +++ b/crates/ui-egui/src/menus/bar.rs @@ -37,6 +37,7 @@ pub fn menu_bar(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> f32 { for (title, items) in tree.iter() { let text = egui::RichText::new(tl!(title)).size(13.0).color(t.text); let resp = ui.add(egui::Button::new(text)); + crate::palette::note_spot(ui, resp.rect, || crate::palette::SpotAt::Menu((*title).to_string())); egui::Popup::menu(&resp).show(|ui| menu_body(app, ui, items, &mut clicked)); if *title == "File" { file_open = egui::Popup::is_id_open(ui.ctx(), egui::Popup::default_response_id(&resp)); diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index f1ec0e5dd4..1c9c42d1fb 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -560,6 +560,276 @@ fn row_label(e: &Entry, home: &str) -> String { if shortcut.is_empty() { start } else { format!("{start}, {shortcut}") } } +/// A control the highlighted result's callout can point at ([`note_spot`]). +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) enum SpotAt { + /// A title of the in-window menu bar, by its English name. + Menu(String), + /// A slot's button on the Tools panel (toolbar none) or on the toolbar made with New Toolbar of + /// this name, and the ids of the tools its group holds. + Slot(Option, Vec), + /// A tool's button on a strip torn off the Tools panel (toolbar none) or off the toolbar made + /// with New Toolbar of this name, and the tool's id. + Strip(Option, String), +} + +/// Where a control was drawn: the viewport and pass, its layer, the clip rectangle and its own. +#[derive(Clone, Debug)] +struct Spot { + at: SpotAt, + viewport: egui::ViewportId, + pass: u64, + layer: egui::LayerId, + clip: egui::Rect, + rect: egui::Rect, +} + +fn spots_id() -> egui::Id { + egui::Id::unique("palette-spots") +} + +/// Where the palette says whether it is open, for [`note_spot`]. +fn spots_wanted_id() -> egui::Id { + egui::Id::unique("palette-spots-wanted") +} + +/// While the palette is open, notes that `ui` drew the control `at` at `rect` in this pass, so the +/// highlighted result's callout can point at it. The menu bar and the toolbars draw before the +/// palette in each pass; `at` is built only while the palette is open. A control that is not +/// wholly in view ([`in_view`]) is not noted, so a pass notes no more controls than the window +/// shows. +pub(crate) fn note_spot(ui: &egui::Ui, rect: egui::Rect, at: impl FnOnce() -> SpotAt) { + let ctx = ui.ctx(); + if !ctx.data(|d| d.get_temp::(spots_wanted_id())).unwrap_or(false) || !in_view(ctx.content_rect(), ui.clip_rect(), rect) { + return; + } + let viewport = ctx.viewport_id(); + let pass = ctx.cumulative_pass_nr_for(viewport); + let spot = Spot { at: at(), viewport, pass, layer: ui.layer_id(), clip: ui.clip_rect(), rect }; + ctx.data_mut(|d| add_spot(d.get_temp_mut_or_default::>(spots_id()), spot)); +} + +/// Adds `spot` to `list`. The first control a viewport notes in a pass drops every control it +/// noted in earlier passes, so the list holds at most one pass of each viewport: no more controls +/// than its windows drew wholly in view. +fn add_spot(list: &mut Vec, spot: Spot) { + if list.iter().rev().find(|s| s.viewport == spot.viewport).is_some_and(|s| s.pass != spot.pass) { + list.retain(|s| s.viewport != spot.viewport || s.pass == spot.pass); + } + list.push(spot); +} + +/// Is `rect`, drawn clipped to `clip`, wholly in view: inside `clip` and inside the window `screen`? +fn in_view(screen: egui::Rect, clip: egui::Rect, rect: egui::Rect) -> bool { + rect.is_finite() && clip.expand(0.5).contains_rect(rect) && screen.expand(0.5).contains_rect(rect) +} + +/// The control noted as `at` in this pass of this viewport, when it is wholly in view and no +/// window or toolbar lies over it ([`covered`]). +fn spot(ctx: &egui::Context, at: impl Fn(&SpotAt) -> bool) -> Option { + let viewport = ctx.viewport_id(); + let pass = ctx.cumulative_pass_nr_for(viewport); + let screen = ctx.content_rect(); + let found = ctx.data_mut(|d| { + d.get_temp_mut_or_default::>(spots_id()) + .iter() + .find(|s| s.viewport == viewport && s.pass == pass && at(&s.at) && in_view(screen, s.clip, s.rect)) + .cloned() + })?; + (!covered(ctx, &found)).then_some(found) +} + +/// Does a shown area above the control `s`'s layer overlap it: a floating panel, a toolbar or a +/// menu? The palette's own backdrop, popup and Recent Commands list do not count (the callout keeps +/// off the popup itself, [`aim`]), nor do tooltips. A layer that is not an area (a docked panel's) +/// is under every area of a higher order. +fn covered(ctx: &egui::Context, s: &Spot) -> bool { + let own = [egui::Id::unique("palette-backdrop"), egui::Id::unique("palette"), recent_list_id()]; + ctx.memory(|m| { + let order: Vec = m.layer_ids().collect(); + let at = order.iter().position(|l| *l == s.layer); + order.iter().enumerate().any(|(i, l)| { + let above = match at { + Some(at) => i > at, + None => l.order > s.layer.order, + }; + above + && l.order < egui::Order::Tooltip + && !own.contains(&l.id) + && m.areas().is_visible(l) + && m.area_rect(l.id).is_some_and(|r| r.intersects(s.rect)) + }) + }) +} + +/// Where the highlighted result lives, as the palette points at it. +enum Pointer { + /// The control that shows the home, the callout's text, and the footer line that names the + /// home when the popup covers the control. + At(Spot, String, String), + /// No control in view shows the home: the footer shows the text. + Footer(String), +} + +/// The footer line for a home that no control in view shows. +fn unseen_line(home: &str) -> String { + crate::i18n::fmt(tl!("{home}, not shown now"), &[("home", home)]) +} + +fn unseen(home: &str) -> Pointer { + Pointer::Footer(unseen_line(home)) +} + +/// How the callout at a control keeps off the palette's popup and off the control. +#[derive(Clone, Copy, PartialEq, Debug)] +enum Aim { + /// Outline the control and show the text in a box beside it. + Box, + /// Outline the control and show the text in the footer: a box beside the control would cover + /// the popup or the control. + Outline, + /// The popup covers the control: no callout, and the footer names the home. + Covered, +} + +/// How the callout at `place` with `text` keeps off the popup at `popup` and off the control. +fn aim(ctx: &egui::Context, popup: Option, place: &Spot, text: &str) -> Aim { + if popup.is_some_and(|p| p.intersects(place.rect)) { + return Aim::Covered; + } + let boxed = callout_box(ctx, place, text, popup).0; + if popup.is_some_and(|p| p.intersects(boxed)) || boxed.intersects(place.rect) { Aim::Outline } else { Aim::Box } +} + +/// The callout for the highlighted result `e`. A tool points at its slot's button on a shown +/// toolbar, in the order of [`tool_home`], or at its button on a strip torn off its group; a +/// result with an item of the in-window menu bar points at the menu's title. A native menu bar, +/// a home that is not in view now and a result with no menu item get a footer line instead. +fn pointer(app: &VectorcraftApp, ctx: &egui::Context, e: &Entry) -> Pointer { + let lang = crate::i18n::current(); + if let Some(id) = e.id.strip_prefix("tool:") { + let Some(tool) = vectorcraft_tools::tool_info(id) else { return unseen(&tool_home(app, id)) }; + let Ok(found) = crate::panels::learn::locate::find(app, tool.id, true) else { return unseen(&tool_home(app, id)) }; + let bar = match &found.target { + crate::panels::learn::locate::Target::Tools => None, + crate::panels::learn::locate::Target::Custom(name) => Some(name.as_str()), + crate::panels::learn::locate::Target::AllTools => return unseen(&tool_home(app, id)), + }; + let place = if found.location == "strip" { + spot(ctx, |at| matches!(at, SpotAt::Strip(b, t) if b.as_deref() == bar && t == tool.id)) + } else { + spot(ctx, |at| matches!(at, SpotAt::Slot(b, tools) if b.as_deref() == bar && tools.iter().any(|t| t == tool.id))) + }; + let Some(place) = place else { return unseen(&tool_home(app, id)) }; + let text = match found.shown.filter(|_| found.location == "flyout").and_then(vectorcraft_tools::tool_info) { + Some(group) => crate::i18n::fmt(tl!("In the {group} group: press and hold to open it"), &[("group", crate::i18n::tr(lang, group.label))]), + None => crate::i18n::tr(lang, tool.label).to_string(), + }; + return Pointer::At(place, text, tool_home(app, id)); + } + let Some(path) = &e.home else { + let shortcut = menus::shown_shortcut(&e.shortcut); + let none = tl!("No menu item"); + return Pointer::Footer(if shortcut.is_empty() { none.to_string() } else { format!("{none}, {shortcut}") }); + }; + // The native bar's application menu gives its items no label of their own. + let full = match e.menu_item { + "" => shown_label(lang, path), + item => format!("{} › {}", shown_label(lang, path), crate::i18n::tr(lang, item)), + }; + let in_bar = crate::i18n::fmt(tl!("In the menu bar: {path}"), &[("path", &full)]); + if app.services.native_menu.is_some() { + return Pointer::Footer(in_bar); + } + let title = path.split(" › ").next().unwrap_or_default(); + match spot(ctx, |at| matches!(at, SpotAt::Menu(t) if t == title)) { + Some(place) => Pointer::At(place, full, in_bar), + None => unseen(&full), + } +} + +/// The callout drawn in the last pass: the outlined control, the box (none when the footer shows +/// the text) and the text. Only tests keep it. +type Callout = Option<(egui::Rect, Option, String)>; + +#[cfg(test)] +fn callout_id() -> egui::Id { + egui::Id::unique("palette-callout") +} + +/// The callout's layer, above the palette's backdrop and popup. +fn callout_painter(ctx: &egui::Context) -> egui::Painter { + ctx.layer_painter(egui::LayerId::new(egui::Order::Tooltip, egui::Id::unique("palette-callout-layer"))).with_clip_rect(ctx.content_rect()) +} + +/// Where the box with `text` goes beside the control `place`, and its text laid out: under a menu +/// title, and on the canvas side of a toolbar's button (its right when the button is in the +/// window's left half). Beside a button, the text wraps to at most [`BOX_ROWS`] rows to fit +/// between the button and the window's edge, or the palette's popup at `popup` when the popup is +/// on that side. The box stays inside the window. +fn callout_box(ctx: &egui::Context, place: &Spot, text: &str, popup: Option) -> (egui::Rect, Arc) { + let t = Tokens::get(ctx); + let screen = ctx.content_rect(); + let r = place.rect; + let menu = matches!(place.at, SpotAt::Menu(_)); + let right = r.center().x <= screen.center().x; + let mut width = screen.width() - 2.0 * BOX_PAD.x - 8.0; + if !menu { + // Beside a button, the text wraps to fit between the button and the window's edge. + // Narrower room than this leaves the box over the button, and the footer shows the text + // instead ([`aim`]). + let room = if right { screen.right() - r.right() } else { r.left() - screen.left() } - 10.0 - 2.0 * BOX_PAD.x; + if room >= 80.0 { + width = width.min(room); + } + } + if let Some(p) = popup.filter(|_| !menu) { + let room = if right { p.left() - r.right() } else { r.left() - p.right() } - 10.0 - 2.0 * BOX_PAD.x; + // Narrower room than this leaves the box where it would cover the popup, and the footer + // shows the text instead ([`aim`]). + if room >= 80.0 { + width = width.min(room); + } + } + let mut job = egui::text::LayoutJob::simple(text.to_owned(), egui::FontId::proportional(12.0), t.text, width.max(0.0)); + job.wrap = egui::text::TextWrapping { + max_width: width.max(0.0), + max_rows: if menu { 1 } else { BOX_ROWS }, + break_anywhere: false, + overflow_character: Some('…'), + }; + let galley = callout_painter(ctx).layout_job(job); + let size = galley.size() + 2.0 * BOX_PAD; + let at = if menu { + egui::pos2(r.left(), r.bottom() + 4.0) + } else if right { + egui::pos2(r.right() + 6.0, r.center().y - size.y / 2.0) + } else { + egui::pos2(r.left() - 6.0 - size.x, r.center().y - size.y / 2.0) + }; + let x = at.x.min(screen.right() - 4.0 - size.x).max(screen.left() + 4.0); + let y = at.y.min(screen.bottom() - 4.0 - size.y).max(screen.top() + 4.0); + (egui::Rect::from_min_size(egui::pos2(x, y), size), galley) +} + +/// How many rows the text of a box beside a toolbar's button wraps to at most. +const BOX_ROWS: usize = 3; + +/// The space between the callout box's border and its text. +const BOX_PAD: egui::Vec2 = egui::vec2(6.0, 3.0); + +/// Outline the control `place`, and with `text` show it in a box beside it ([`callout_box`], with +/// the popup at `popup`). Returns the box. +fn callout(ctx: &egui::Context, place: &Spot, text: Option<&str>, popup: Option) -> Option { + let t = Tokens::get(ctx); + let painter = callout_painter(ctx); + crate::panels::learn::locate::outline(&painter.with_clip_rect(place.clip.intersect(ctx.content_rect())), place.rect, t.selection); + let (rect, galley) = callout_box(ctx, place, text?, popup); + painter.rect(rect, 4.0, t.panel, egui::Stroke::new(1.0, t.selection), egui::StrokeKind::Inside); + painter.galley(rect.min + BOX_PAD, galley, t.text); + Some(rect) +} + /// The line under the results: how many results matched, how many of them the list holds when it /// can't hold them all, or that none matched. fn footer(listed: usize, total: usize) -> String { @@ -711,6 +981,18 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { // closed it focused another widget, such as a field in a window above the backdrop. let focus_id = egui::Id::unique("palette-focus-before"); let field_id = egui::Id::unique("palette-field"); + // The menu bar and the toolbars note where they draw their controls only while the palette is + // open; the pass that opens it asks for another, which they draw noting them. + let wanted = ctx.data_mut(|d| std::mem::replace(d.get_temp_mut_or_default::(spots_wanted_id()), app.ui.palette_open)); + if app.ui.palette_open && !wanted { + ctx.request_repaint(); + } else if !app.ui.palette_open && wanted { + ctx.data_mut(|d| { + d.remove::>(spots_id()); + #[cfg(test)] + d.remove::(callout_id()); + }); + } if !app.ui.palette_open { let field = ctx.data_mut(|d| { let field = d.get_temp::(field_id); @@ -812,6 +1094,12 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let screen = ctx.content_rect(); // The highlighted result the rows and the field's description are drawn with. let mut drawn = sel; + // The control that shows where the highlighted result lives, the callout's text, and how the + // footer drawn in this pass keeps the callout off the popup. + let mut pointed: Option<(Spot, String, Aim)> = None; + // The popup as the last pass laid it out: the footer is drawn before this pass's popup has its + // size, and the callout is checked again against that size after the popup is drawn. + let last_popup = ctx.memory(|m| m.area_rect(egui::Id::unique("palette"))); // The backdrop covers the canvas, the toolbars, the docked panels and the app bar under the // popup, in the order of a modal dialog's backdrop (`dialogs::modal::backdrop`), so the press // that closes the palette does not press a control under it. Windows in the Foreground order @@ -821,7 +1109,8 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { }); // The area keeps itself inside the window (egui's `Area::constrain` is on), so in a window too // short for the field, one row and the footer below TOP, the popup moves up. - egui::Area::new(egui::Id::unique("palette")).order(egui::Order::Foreground).anchor(egui::Align2::CENTER_TOP, [0.0, TOP]).show(ctx, |ui| { + let popup_area = egui::Area::new(egui::Id::unique("palette")).order(egui::Order::Foreground).anchor(egui::Align2::CENTER_TOP, [0.0, TOP]); + let area = popup_area.show(ctx, |ui| { let margin: i8 = 10; egui::Frame::popup(ui.style()).fill(t.panel).inner_margin(egui::Margin::same(margin)).show(ui, |ui| { ui.set_width(520.0); @@ -876,12 +1165,14 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let resized = (view - last_view).abs() > 0.5; // Screen readers stay on the field: its description names the highlighted result and // its place among every match, as the footer counts them. + let mut described = None; if let Some(e) = matches.get(sel) { let rank = if sel + 1 == matches.len() { kept.unwrap_or(sel) } else { sel }; let pos = (rank + 1).to_string(); let of = total.to_string(); let name = row_label(e, &home_text(app, e)); let said = crate::i18n::fmt(tl!("{pos} of {total}: {name}"), &[("pos", &pos), ("total", &of), ("name", &name)]); + described = Some(said.clone()); ui.ctx().accesskit_node_builder(r.id, |node| node.set_description(said)); } if n > 0 { @@ -945,7 +1236,45 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { }); } ui.add_space(6.0); - ui.label(egui::RichText::new(footer(n, total)).color(t.text_dim)); + // The highlighted result's home, after a pointer or a scroll moved the highlight too. In + // the pass that opens the palette, the menu bar and the toolbars have noted nothing yet, + // and the next pass shows it. + let mut hint = None; + match matches.get(sel).filter(|_| wanted).map(|e| pointer(app, ui.ctx(), e)) { + Some(Pointer::At(place, text, covered)) => { + let how = aim(ui.ctx(), last_popup, &place, &text); + hint = match how { + Aim::Box => None, + Aim::Outline => Some(text.clone()), + Aim::Covered => Some(covered), + }; + // Screen readers get the text of a box beside a tool's button, such as how to + // open the group that hides the tool, with the field's description, unless the + // description already holds it. + if how == Aim::Box + && !matches!(place.at, SpotAt::Menu(_)) + && sel == drawn + && let Some(said) = &described + && !said.contains(text.as_str()) + { + let said = format!("{said}, {text}"); + ui.ctx().accesskit_node_builder(r.id, |node| node.set_description(said)); + } + pointed = Some((place, text, how)); + } + Some(Pointer::Footer(text)) => hint = Some(text), + None => {} + } + ui.scope(|ui| { + // The footer stays one line of text tall, as the list's height counts it. + ui.spacing_mut().interact_size.y = 0.0; + ui.horizontal(|ui| { + ui.label(egui::RichText::new(footer(n, total)).color(t.text_dim)); + if let Some(hint) = hint { + ui.add(egui::Label::new(egui::RichText::new(hint).color(t.text_dim)).truncate()); + } + }); + }); if !list_open && !history_focused && ui.input(|i| i.key_pressed(egui::Key::Enter)) @@ -970,6 +1299,24 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let popup = egui::LayerId::new(egui::Order::Foreground, egui::Id::unique("palette")); let list = egui::LayerId::new(egui::Order::Foreground, recent_list_id()); let outside = presses.into_iter().any(|p| !ctx.layer_id_at(p).is_some_and(|l| l == popup || l == list)); + // The callout keeps off the popup as drawn in this pass. When the popup's new size changes + // which of the three cases applies, the next pass draws the footer to match. + let now = Some(area.response.rect); + let shown: Callout = pointed.and_then(|(place, text, before)| { + let how = aim(ctx, now, &place, &text); + if how != before { + ctx.request_repaint(); + } + match how { + Aim::Covered => None, + Aim::Outline => Some((place.rect, callout(ctx, &place, None, now), text)), + Aim::Box => Some((place.rect, callout(ctx, &place, Some(&text), now), text)), + } + }); + #[cfg(test)] + ctx.data_mut(|d| d.insert_temp::(callout_id(), shown)); + #[cfg(not(test))] + drop(shown); // The pointer or a scroll moved the highlight after the rows were drawn: the next frame draws // it where it now is. if sel != drawn { @@ -2996,4 +3343,517 @@ mod tests { assert!(rows(&nodes).iter().any(|r| r.1 && r.0 == label), "its row is drawn and highlighted"); assert_eq!(field_description(&nodes), format!("{} of {}: {label}", MAX_RESULTS + 1, ranked.len())); } + + impl Window { + /// Opens the palette on `query` and draws until the toolbars and the menu bar have noted + /// their controls: the last frame's screen-reader tree. + fn search(&mut self, query: &str) -> Vec { + self.app.ui.palette_open = true; + self.app.ui.palette_query = query.into(); + self.frame(vec![]); + self.frame(vec![]) + } + + /// The highlighted result's id. + fn highlighted(&self) -> String { + self.ctx.data(|d| d.get_temp::(egui::Id::unique("palette-selected"))).unwrap().4 + } + + /// The callout the last frame drew: the outlined control, the box and its text. + fn callout(&self) -> Callout { + self.ctx.data(|d| d.get_temp::(callout_id())).flatten() + } + + /// The text of the labels in the popup in the screen-reader tree `nodes`: the footer's. + fn popup_labels(&self, nodes: &[egui::accesskit::Node]) -> Vec { + let popup = self.popup(); + nodes + .iter() + .filter(|n| n.role() == egui::accesskit::Role::Label) + .filter(|n| n.bounds().is_some_and(|b| popup.contains(egui::pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)))) + .filter_map(|n| n.label().or(n.value()).map(str::to_string)) + .collect() + } + } + + /// The bounds of the control whose screen-reader name is `name`, alone or followed by its + /// shortcut in parentheses. + fn bounds_of(nodes: &[egui::accesskit::Node], name: &str) -> egui::Rect { + let at = button_at(nodes, name); + let node = nodes + .iter() + .filter(|n| n.role() == egui::accesskit::Role::Button) + .find(|n| n.bounds().is_some_and(|b| ((b.x0 + b.x1) / 2.0) as f32 == at.x && ((b.y0 + b.y1) / 2.0) as f32 == at.y)) + .unwrap(); + let b = node.bounds().unwrap(); + 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)) + } + + /// Highlighting a result with an item of the in-window menu bar outlines that menu's title, as + /// drawn in the same frame, and the box under it shows the item's whole path. + #[test] + fn the_highlighted_result_outlines_its_menu_title() { + let mut window = Window::new(); + let nodes = window.search("round corners"); + assert_eq!(window.highlighted(), "effect:stylize.roundCorners"); + let (outlined, callout, text) = window.callout().expect("a callout"); + assert_eq!(text, "Effect › Stylize › Round Corners…"); + assert_eq!(outlined, bounds_of(&nodes, "Effect")); + let callout = callout.expect("a box"); + assert!(callout.top() >= outlined.bottom(), "the box is under the title: {callout:?} {outlined:?}"); + // A panel's home is the Window menu. + window.search("layers"); + assert_eq!(window.highlighted(), "panel:layers"); + let (outlined, _, text) = window.callout().expect("a callout"); + assert_eq!(text, "Window › Layers"); + assert_eq!(outlined, bounds_of(&window.frame(vec![]), "Window")); + // Closing the palette ends the callout. + window.app.ui.palette_open = false; + window.frame(vec![]); + assert_eq!(window.callout(), None); + } + + struct NativeMenus; + impl crate::native_menu::Backend for NativeMenus { + fn sync(&mut self, _: &crate::native_menu::MenuBar) {} + fn drain(&mut self) -> Vec { + Vec::new() + } + } + + /// With the system's menu bar, nothing is drawn over it: the footer names the menu path. + #[test] + fn with_a_native_menu_bar_the_footer_names_the_path() { + let mut window = Window::new(); + window.app.services.native_menu = Some(crate::native_menu::NativeMenu::new(Box::new(NativeMenus))); + let nodes = window.search("round corners"); + assert_eq!(window.highlighted(), "effect:stylize.roundCorners"); + assert_eq!(window.callout(), None); + assert!(labels(&nodes).contains(&"In the menu bar: Effect › Stylize › Round Corners…".to_string()), "{:?}", labels(&nodes)); + // The application menu's items have no label of their own: the path ends at the menu. + let nodes = window.search("help.about"); + assert_eq!(window.highlighted(), "help.about"); + let menu = format!("In the menu bar: {}", crate::native_menu::APP_NAME); + assert!(labels(&nodes).contains(&menu), "{:?}", labels(&nodes)); + } + + /// A tool hidden in a group outlines its group's button and says how to open the group; once + /// chosen from the group, the button shows it and the box names the tool alone. The box is on + /// the canvas side of the toolbar. + #[test] + fn a_tool_result_outlines_its_toolbar_slot() { + let mut window = Window::new(); + let nodes = window.search("group selection tool"); + assert_eq!(window.highlighted(), "tool:groupSelection"); + let (outlined, callout, text) = window.callout().expect("a callout"); + assert_eq!(text, "In the Direct Selection Tool group: press and hold to open it"); + assert_eq!(outlined, bounds_of(&nodes, "Direct Selection Tool")); + // Screen readers hear how to open the group with the search field's description. + let said: Vec<_> = nodes.iter().filter(|n| n.role() == egui::accesskit::Role::TextInput).filter_map(|n| n.description()).collect(); + assert!(said.iter().any(|d| d.ends_with(", In the Direct Selection Tool group: press and hold to open it")), "{said:?}"); + let callout = callout.expect("a box"); + assert!(callout.left() > outlined.right(), "right of a toolbar docked left: {callout:?} {outlined:?}"); + window.app.select_tool("groupSelection"); + let nodes = window.search("group selection tool"); + let (outlined, _, text) = window.callout().unwrap_or_else(|| panic!("a callout: {:?} {:?}", labels(&nodes), window.popup())); + assert_eq!(text, "Group Selection Tool"); + assert_eq!(outlined, bounds_of(&nodes, "Group Selection Tool")); + // Docked right, the box goes on its left. The Zoom Tool's slot is below the popup. + window.app.ui.toolbar_right = true; + window.frame(vec![]); + let nodes = window.search("zoom tool"); + assert_eq!(window.highlighted(), "tool:zoom"); + let (outlined, callout, text) = window.callout().unwrap_or_else(|| panic!("a callout: {:?} {:?}", labels(&nodes), window.popup())); + assert_eq!(text, "Zoom Tool"); + assert!(!window.popup().intersects(outlined), "{outlined:?} {:?}", window.popup()); + let callout = callout.expect("a box"); + assert!(callout.right() < outlined.left(), "left of a toolbar docked right: {callout:?} {outlined:?}"); + } + + /// A shown toolbar made with New Toolbar called Drawing that floats at `pos` and holds the Pen + /// Tool and the Curvature Tool in one group. + fn drawing_toolbar(pos: [f32; 2]) -> crate::state::CustomToolbar { + crate::state::CustomToolbar { + name: "Drawing".into(), + slots: vec![vec!["pen".into(), "curvature".into()]], + shown: true, + pos, + dock: None, + dock_right: false, + slot_tool: Default::default(), + double: false, + floating: vec![], + } + } + + /// With the Tools panel hidden, a shown toolbar made with New Toolbar that holds the tool gets + /// the outline; a group torn off it into a strip has the tool's own button outlined. + #[test] + fn a_tool_on_a_toolbar_made_with_new_toolbar_is_outlined_there() { + let mut window = Window::new(); + window.app.ui.toolbar = false; + window.app.ui.custom_toolbars.push(drawing_toolbar([100.0, 200.0])); + let nodes = window.search("pen tool"); + assert_eq!(window.highlighted(), "tool:pen"); + let (outlined, callout, text) = window.callout().expect("a callout"); + assert_eq!(text, "Pen Tool"); + assert!(callout.is_some()); + assert_eq!(outlined, bounds_of(&nodes, "Pen Tool")); + assert!(outlined.left() >= 100.0, "on the toolbar made with New Toolbar: {outlined:?}"); + // The group torn off into a strip. + window.app.ui.custom_toolbars[0] + .floating + .push(crate::state::FloatingFlyout { tools: vec!["pen".into(), "curvature".into()], pos: [600.0, 500.0] }); + window.frame(vec![]); + window.frame(vec![]); + let (outlined, _, text) = window.callout().expect("a callout"); + assert_eq!(text, "Pen Tool"); + assert!(outlined.left() >= 600.0 && outlined.top() >= 500.0, "on the strip: {outlined:?}"); + } + + /// A group torn off the Tools panel into a strip has the tool's own button on the strip + /// outlined, with the tool's name. + #[test] + fn a_strip_torn_off_the_tools_panel_is_pointed_at() { + let mut window = Window::new(); + let slot = crate::toolbar::slots(&window.app).into_iter().map(|(_, s)| s).find(|s| s.contains(&"groupSelection")).expect("the group"); + let tools = slot.iter().map(|t| t.to_string()).collect(); + window.app.ui.floating_flyouts.push(crate::state::FloatingFlyout { tools, pos: [600.0, 500.0] }); + window.frame(vec![]); + window.search("group selection tool"); + assert_eq!(window.highlighted(), "tool:groupSelection"); + let (outlined, callout, text) = window.callout().expect("a callout"); + assert_eq!(text, "Group Selection Tool"); + assert!(callout.is_some()); + assert!(outlined.left() >= 600.0 && outlined.top() >= 500.0, "on the strip: {outlined:?}"); + } + + /// Two viewports that note controls in turn keep one pass each in the list, whichever noted + /// first, also after one of them stops noting controls. + #[test] + fn the_noted_controls_hold_one_pass_per_viewport() { + let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(10.0, 10.0)); + let spot = |viewport: egui::ViewportId, pass: u64| Spot { + at: SpotAt::Menu("File".into()), + viewport, + pass, + layer: egui::LayerId::background(), + clip: rect, + rect, + }; + let (a, b) = (egui::ViewportId::ROOT, egui::ViewportId::from_hash_of("another window")); + let mut list = Vec::new(); + for pass in 0..20 { + for _ in 0..3 { + add_spot(&mut list, spot(a, pass)); + } + for _ in 0..2 { + add_spot(&mut list, spot(b, pass)); + } + assert_eq!(list.len(), 5, "pass {pass}"); + assert!(list.iter().all(|s| s.pass == pass), "pass {pass}"); + } + // The other window stops noting controls. + for pass in 20..40 { + for _ in 0..3 { + add_spot(&mut list, spot(a, pass)); + } + assert_eq!(list.len(), 5, "pass {pass}"); + } + } + + /// Beside a button, the box's text wraps to at most three rows to fit between the button and + /// the popup; with no popup beside it, it is one row. + #[test] + fn a_box_beside_a_button_wraps_to_fit_beside_the_popup() { + let ctx = egui::Context::default(); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0)); + let mut checked = false; + let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| { + let ctx = ui.ctx(); + let rect = egui::Rect::from_min_size(egui::pos2(20.0, 100.0), egui::vec2(28.0, 28.0)); + let place = Spot { at: SpotAt::Slot(None, vec![]), viewport: ctx.viewport_id(), pass: 0, layer: ui.layer_id(), clip: screen, rect }; + let popup = egui::Rect::from_min_size(egui::pos2(rect.right() + 150.0, 50.0), egui::vec2(400.0, 300.0)); + let text = "In the Direct Selection Tool group: press and hold to open it"; + let (boxed, galley) = callout_box(ctx, &place, text, Some(popup)); + assert!((2..=BOX_ROWS).contains(&galley.rows.len()), "{} rows", galley.rows.len()); + assert!(boxed.left() > rect.right() && boxed.right() <= popup.left(), "{boxed:?} {popup:?}"); + let (_, one) = callout_box(ctx, &place, text, None); + assert_eq!(one.rows.len(), 1); + checked = true; + }); + out.textures_delta.clear(); + assert!(checked); + } + + /// The box never covers the button it points at: in a narrow window it wraps to fit between + /// the button and the window's edge, and where it cannot, only the outline is drawn and the + /// footer shows the text. + #[test] + fn the_box_keeps_off_its_button() { + let text = "In the Direct Selection Tool group: press and hold to open it"; + let check = |width: f32, left: f32| { + let ctx = egui::Context::default(); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(width, 300.0)); + let mut how = None; + let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| { + let ctx = ui.ctx(); + let rect = egui::Rect::from_min_size(egui::pos2(left, 100.0), egui::vec2(28.0, 28.0)); + let place = Spot { at: SpotAt::Slot(None, vec![]), viewport: ctx.viewport_id(), pass: 0, layer: ui.layer_id(), clip: screen, rect }; + let aimed = aim(ctx, None, &place, text); + if aimed == Aim::Box { + let (boxed, _) = callout_box(ctx, &place, text, None); + assert!(!boxed.intersects(rect) && screen.contains_rect(boxed), "{boxed:?} {rect:?}"); + } + how = Some(aimed); + }); + out.textures_delta.clear(); + how + }; + assert_eq!(check(400.0, 180.0), Some(Aim::Box)); + assert_eq!(check(400.0, 192.0), Some(Aim::Box)); + assert_eq!(check(180.0, 60.0), Some(Aim::Outline)); + } + + /// The callout never covers the palette: a button under the popup is not pointed at, and a + /// button whose box would cover the popup is outlined with its text in the footer. + #[test] + fn the_callout_stays_off_the_palette() { + let mut window = Window::new(); + window.app.ui.toolbar = false; + window.app.ui.custom_toolbars.push(drawing_toolbar([600.0, 120.0])); + let nodes = window.search("pen tool"); + assert_eq!(window.highlighted(), "tool:pen"); + assert!(window.popup().contains(egui::pos2(620.0, 140.0)), "the toolbar is under the popup: {:?}", window.popup()); + assert_eq!(window.callout(), None); + // The toolbar is shown, under the popup: the footer names it and does not say it is hidden. + let footer = window.popup_labels(&nodes); + assert!(footer.contains(&"Drawing".to_string()), "{footer:?}"); + assert!(!footer.iter().any(|l| l.contains("not shown now")), "{footer:?}"); + // Left of the popup, with the box's place to its right on the popup. + let popup = window.popup(); + window.app.ui.custom_toolbars[0].pos = [popup.left() - 60.0, popup.top() + 30.0]; + window.frame(vec![]); + let nodes = window.frame(vec![]); + let (outlined, callout, text) = window.callout().expect("a callout"); + assert!(!popup.intersects(outlined), "{outlined:?} {popup:?}"); + assert_eq!((callout, text.as_str()), (None, "Pen Tool")); + assert!(labels(&nodes).contains(&"Pen Tool".to_string()), "{:?}", labels(&nodes)); + } + + /// In the pass where more results make the popup taller and it now covers the button, the + /// callout is checked against the popup's new size, and the next pass's footer names the home. + #[test] + fn the_callout_keeps_off_a_popup_that_grew_in_the_same_pass() { + let mut window = Window::new(); + window.app.ui.toolbar = false; + window.app.ui.custom_toolbars.push(drawing_toolbar([100.0, 120.0])); + window.search("pen tool"); + let small = window.popup(); + window.app.ui.custom_toolbars[0].pos = [small.center().x, small.bottom() + 2.0]; + window.frame(vec![]); + window.frame(vec![]); + assert_eq!(window.highlighted(), "tool:pen"); + let (outlined, ..) = window.callout().expect("a callout below the popup"); + window.app.ui.palette_query = "pen".into(); + window.frame(vec![]); + assert_eq!(window.highlighted(), "tool:pen"); + assert!(window.popup().intersects(outlined), "the popup grew over the button: {:?} {outlined:?}", window.popup()); + assert_eq!(window.callout(), None); + let nodes = window.frame(vec![]); + let footer = window.popup_labels(&nodes); + assert!(footer.contains(&"Drawing".to_string()), "{footer:?}"); + assert!(!footer.iter().any(|l| l.contains("not shown now")), "{footer:?}"); + } + + /// No callout where no control in view shows the home: in Presentation Mode, with the Tools + /// panel hidden, and for a command with no menu item. The footer says where it lives. + #[test] + fn a_home_out_of_view_is_named_in_the_footer() { + let mut window = Window::new(); + window.app.ui.screen_mode = 3; + let nodes = window.search("pen tool"); + assert_eq!(window.highlighted(), "tool:pen"); + assert_eq!(window.callout(), None); + assert!(labels(&nodes).contains(&"Toolbar, not shown now".to_string()), "{:?}", labels(&nodes)); + window.app.ui.screen_mode = 0; + window.app.ui.toolbar = false; + let nodes = window.search("pen tool"); + assert_eq!(window.callout(), None); + assert!(labels(&nodes).contains(&"Toolbar, not shown now".to_string()), "{:?}", labels(&nodes)); + // Toolbars hidden with Tab. + window.app.ui.toolbar = true; + window.app.run("window.dock", serde_json::json!({})).expect("Tab"); + assert!(window.app.ui.tab_hid.is_some()); + let nodes = window.search("pen tool"); + assert_eq!(window.highlighted(), "tool:pen"); + assert_eq!(window.callout(), None); + assert!(labels(&nodes).contains(&"Toolbar, not shown now".to_string()), "{:?}", labels(&nodes)); + window.app.run("window.dock", serde_json::json!({})).expect("Tab"); + assert!(window.app.ui.tab_hid.is_none() && window.app.ui.toolbar); + let entries = entries(&window.ctx, Lang::EN); + let none = entries.iter().find(|e| e.home.is_none() && !e.id.starts_with("tool:") && e.shortcut.is_empty()).expect("no menu item"); + let nodes = window.search(&none.id); + assert_eq!(window.highlighted(), none.id); + assert_eq!(window.callout(), None); + assert!(labels(&nodes).contains(&"No menu item".to_string()), "{:?}", labels(&nodes)); + // With a shortcut, the footer gives it. + let keyed = entries.iter().find(|e| e.home.is_none() && !e.id.starts_with("tool:") && !e.shortcut.is_empty()).expect("a shortcut"); + let nodes = window.search(&keyed.id); + assert_eq!(window.highlighted(), keyed.id); + assert_eq!(window.callout(), None); + let line = format!("No menu item, {}", menus::shown_shortcut(&keyed.shortcut)); + assert!(labels(&nodes).contains(&line), "{line} in {:?}", labels(&nodes)); + } + + /// In the pass that opens the palette, the menu bar and the toolbars have noted no control yet: + /// the footer does not call a home that is in view "not shown now", and the next pass points + /// at it. + #[test] + fn the_pass_that_opens_the_palette_names_no_home_as_hidden() { + let mut window = Window::new(); + // Opened once and closed, the popup has its size, so the pass that opens it again draws + // it. One pass a frame, so the frame shows that pass. + window.search("pen tool"); + window.app.ui.palette_open = false; + window.frame(vec![]); + window.ctx.options_mut(|o| o.max_passes = std::num::NonZeroUsize::MIN); + window.app.ui.palette_open = true; + let nodes = window.frame(vec![]); + assert_eq!(window.highlighted(), "tool:pen"); + let footer = window.popup_labels(&nodes); + assert!(!footer.is_empty(), "the popup is drawn: {:?}", labels(&nodes)); + assert!(!footer.iter().any(|l| l.contains("not shown now")), "{footer:?}"); + window.frame(vec![]); + assert!(window.callout().is_some()); + } + + /// Moving the pointer onto a row moves the callout to that result's home in the same frame. + #[test] + fn the_callout_follows_the_pointer() { + let mut window = Window::new(); + let nodes = window.search("select"); + let entries = entries(&window.ctx, Lang::EN); + let x = window.popup().center().x; + let target = rows(&nodes) + .into_iter() + .filter(|r| !r.1) + .find_map(|r| { + let e = entries.iter().find(|e| row_label(e, &home_text(&window.app, e)) == r.0)?; + let path = e.home.as_ref().filter(|_| !e.id.starts_with("tool:") && !e.menu_item.is_empty())?; + Some((e.id.clone(), format!("{path} › {}", e.menu_item), (r.2 + r.3) / 2.0)) + }) + .expect("a row with a menu item"); + let (id, text, y) = target; + window.frame(vec![egui::Event::PointerMoved(egui::pos2(x, y as f32 - 3.0))]); + window.frame(vec![egui::Event::PointerMoved(egui::pos2(x, y as f32))]); + assert_eq!(window.highlighted(), id); + assert_eq!(window.callout().map(|c| c.2), Some(text)); + } + + /// Down moves the callout to the next result's home in the same frame, and moving the + /// highlight changes no toolbar, flyout, drawer or tool. + #[test] + fn the_callout_follows_the_highlight_and_reveals_nothing() { + let mut window = Window::new(); + window.search("select"); + let before = (window.app.ui.flyout, window.app.ui.tools_drawer, window.app.ui.toolbar, window.app.session.tool_id()); + let entries = entries(&window.ctx, Lang::EN); + for _ in 0..6 { + let key = + egui::Event::Key { key: egui::Key::ArrowDown, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }; + window.frame(vec![key]); + let id = window.highlighted(); + let e = entries.iter().find(|e| e.id == id).unwrap(); + let callout = window.callout(); + if let Some(path) = e.home.as_ref().filter(|_| !id.starts_with("tool:")) { + assert_eq!(callout.map(|c| c.2), Some(format!("{path} › {}", e.menu_item)), "{id}"); + } + assert!(window.app.ui.learn_locate.is_none()); + } + let after = (window.app.ui.flyout, window.app.ui.tools_drawer, window.app.ui.toolbar, window.app.session.tool_id()); + assert_eq!(before, after); + } + + /// Every catalog translates the callout's and the footer's words. + #[test] + fn catalogs_translate_the_callout_words() { + let words = ["In the menu bar: {path}", "In the {group} group: press and hold to open it", "{home}, not shown now"]; + let missing: Vec = Lang::all() + .filter(|l| *l != Lang::EN) + .flat_map(|l| words.iter().filter(move |w| !crate::i18n::has(l, w)).map(move |w| format!("{}: {w}", l.code()))) + .collect(); + assert!(missing.is_empty(), "{missing:?}"); + } + + /// A control noted in an earlier pass, in another viewport or clipped by its scroll area is not + /// pointed at; the box stays inside a narrow window. + #[test] + fn only_a_control_in_view_in_this_pass_is_pointed_at() { + let ctx = egui::Context::default(); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(300.0, 200.0)); + let mut checked = false; + for _ in 0..2 { + let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| { + let ctx = ui.ctx(); + let pass = ctx.cumulative_pass_nr_for(ctx.viewport_id()); + let rect = egui::Rect::from_min_size(egui::pos2(270.0, 10.0), egui::vec2(28.0, 28.0)); + let at = |name: &str| SpotAt::Menu(name.into()); + let spot = |name: &str, viewport, pass, clip| Spot { at: at(name), viewport, pass, layer: ui.layer_id(), clip, rect }; + let list = vec![ + spot("old", ctx.viewport_id(), pass.wrapping_sub(1), screen), + spot("other", egui::ViewportId::from_hash_of("detached"), pass, screen), + spot("clipped", ctx.viewport_id(), pass, egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(280.0, 200.0))), + spot("shown", ctx.viewport_id(), pass, screen), + ]; + ctx.data_mut(|d| d.insert_temp(spots_id(), list)); + for name in ["old", "other", "clipped"] { + assert!(super::spot(ctx, |a| *a == at(name)).is_none(), "{name}"); + } + let shown = super::spot(ctx, |a| *a == at("shown")).expect("shown"); + let text = "Effect › Stylize › Round Corners… and a long tail of words"; + let r = callout(ctx, &Spot { at: SpotAt::Slot(None, vec![]), ..shown.clone() }, Some(text), None).unwrap(); + assert!(screen.contains_rect(r), "{r:?}"); + let r = callout(ctx, &shown, Some(text), None).unwrap(); + assert!(screen.contains_rect(r), "{r:?}"); + checked = true; + }); + out.textures_delta.clear(); + } + assert!(checked); + } + + /// A control under a window drawn above its layer is not pointed at; with the window moved off + /// it, it is. + #[test] + fn a_control_under_a_window_is_not_pointed_at() { + let ctx = egui::Context::default(); + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(400.0, 300.0)); + let rect = egui::Rect::from_min_size(egui::pos2(20.0, 20.0), egui::vec2(28.0, 28.0)); + let at = || SpotAt::Menu("bar".into()); + for (cover_at, pointed) in [(egui::pos2(10.0, 10.0), false), (egui::pos2(200.0, 150.0), true)] { + let mut seen = None; + // The second pass sees both areas laid out. + for _ in 0..2 { + let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| { + let ctx = ui.ctx().clone(); + ctx.data_mut(|d| d.insert_temp(spots_wanted_id(), true)); + egui::Area::new(egui::Id::unique("test-toolbar")).order(egui::Order::Middle).fixed_pos(egui::Pos2::ZERO).show(&ctx, |ui| { + ui.allocate_rect(rect, egui::Sense::hover()); + note_spot(ui, rect, at); + }); + egui::Area::new(egui::Id::unique("test-cover")).order(egui::Order::Middle).fixed_pos(cover_at).show(&ctx, |ui| { + ui.allocate_space(egui::vec2(80.0, 80.0)); + }); + seen = Some(super::spot(&ctx, |a| *a == at()).is_some()); + }); + out.textures_delta.clear(); + } + assert_eq!(seen, Some(pointed), "{cover_at:?}"); + } + } } diff --git a/crates/ui-egui/src/panels/learn/locate.rs b/crates/ui-egui/src/panels/learn/locate.rs index 607da1c45c..b678049c0e 100644 --- a/crates/ui-egui/src/panels/learn/locate.rs +++ b/crates/ui-egui/src/panels/learn/locate.rs @@ -103,8 +103,12 @@ pub(crate) fn mark(app: &mut VectorcraftApp, ctx: &Context, layer: LayerId, clip l.drawn = true; ctx.request_repaint_after_secs(left as f32); let t = Tokens::get(ctx); - let painter = ctx.layer_painter(layer).with_clip_rect(clip.intersect(ctx.content_rect())); - painter.rect_stroke(rect.shrink(1.0), CornerRadius::same(6), Stroke::new(MARK_WIDTH, t.selection), StrokeKind::Inside); + outline(&ctx.layer_painter(layer).with_clip_rect(clip.intersect(ctx.content_rect())), rect, t.selection); +} + +/// Outline `rect`, a control that a mark points at, with `painter` in `color`. +pub(crate) fn outline(painter: &egui::Painter, rect: Rect, color: egui::Color32) { + painter.rect_stroke(rect.shrink(1.0), CornerRadius::same(6), Stroke::new(MARK_WIDTH, color), StrokeKind::Inside); } /// After the toolbars and panels have drawn: Escape ends the locate, also an Escape that closed the @@ -161,46 +165,76 @@ pub(crate) fn locate_tool(app: &mut VectorcraftApp, p: &Value) -> Result return Err(format!("`{key}` must be a string")), }; let tool = vectorcraft_tools::tool_info(tool).ok_or_else(|| format!("unknown tool `{tool}`"))?.id; + let found = match find(app, tool, false) { + Ok(found) => found, + Err(reason) => return Ok(unavailable(tool, reason)), + }; + match found.target { + Target::Tools => { + app.ui.toolbar = true; + start(app, tool, Target::Tools); + Ok(json!({"tool": tool, "location": found.location, "toolbar": null})) + } + Target::Custom(name) => { + start(app, tool, Target::Custom(name.clone())); + Ok(json!({"tool": tool, "location": found.location, "toolbar": name})) + } + Target::AllTools => { + app.run("window.editToolbar", json!({"open": true}))?; + start(app, tool, Target::AllTools); + Ok(json!({"tool": tool, "location": "allTools", "toolbar": null})) + } + } +} + +/// Where a toolbar holds a tool: [`find`]'s answer. +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct Found { + /// The control that shows the tool. + pub target: Target, + /// `toolbar` (its slot's button shows it), `flyout` (it is hidden in its slot's group), + /// `strip` (its group is torn off into a strip) or `allTools`. + pub location: &'static str, + /// The tool the slot's button shows, for `toolbar` and `flyout`. + pub shown: Option<&'static str>, +} + +/// Where `tool` is in the current layout, without showing or opening anything: the Tools panel's +/// toolbar first, also while Window › Tools hides it, then the shown toolbars made with New +/// Toolbar, else the All Tools drawer. With `shown_first`, a hidden Tools panel comes after the +/// toolbars made with New Toolbar. An error names why no toolbar can show the tool now. +pub(crate) fn find(app: &VectorcraftApp, tool: &'static str, shown_first: bool) -> Result { if app.ui.screen_mode >= 3 { - return Ok(unavailable(tool, "Presentation Mode hides the toolbars: change the screen mode to show them")); + return Err("Presentation Mode hides the toolbars: change the screen mode to show them"); } // Tab hides the toolbars made with New Toolbar until the next Tab, also once Window › Tools // shows the Tools panel again. let tab_hid = app.ui.tab_hid.is_some(); if tab_hid && !app.ui.toolbar { - return Ok(unavailable(tool, "Tab has hidden the toolbars: press Tab to show them")); + return Err("Tab has hidden the toolbars: press Tab to show them"); } - if let Some(slot) = crate::toolbar::slots(app).into_iter().map(|(_, s)| s).find(|s| s.contains(&tool)) { - let location = if slot.len() > 1 && crate::toolbar::is_floating(app, None, slot[0]) { - "strip" - } else if crate::toolbar::shown_tool(app, &slot) == tool { - "toolbar" + let main = crate::toolbar::slots(app).into_iter().map(|(_, s)| s).find(|s| s.contains(&tool)).map(|slot| { + if slot.len() > 1 && crate::toolbar::is_floating(app, None, slot[0]) { + Found { target: Target::Tools, location: "strip", shown: None } } else { - "flyout" - }; - app.ui.toolbar = true; - start(app, tool, Target::Tools); - return Ok(json!({"tool": tool, "location": location, "toolbar": null})); + let shown = crate::toolbar::shown_tool(app, &slot); + Found { target: Target::Tools, location: if shown == tool { "toolbar" } else { "flyout" }, shown: Some(shown) } + } + }); + if let Some(main) = main.clone().filter(|_| !shown_first || app.ui.toolbar) { + return Ok(main); } let active = app.session.tool_id(); let custom = app.ui.custom_toolbars.iter().filter(|b| b.shown && !tab_hid).find_map(|bar| { let slot = bar.slots.iter().find(|s| s.iter().any(|t| t == tool))?; let tools: Vec<&'static str> = slot.iter().filter_map(|id| vectorcraft_tools::tool_info(id).map(|t| t.id)).collect(); let first = *tools.first()?; - let location = if tools.len() > 1 && crate::toolbar::is_floating(app, Some(&bar.name), first) { - "strip" - } else if crate::custom_toolbars::shown_tool(bar, active, &tools) == Some(tool) { - "toolbar" - } else { - "flyout" - }; - Some((bar.name.clone(), location)) + let target = Target::Custom(bar.name.clone()); + if tools.len() > 1 && crate::toolbar::is_floating(app, Some(&bar.name), first) { + return Some(Found { target, location: "strip", shown: None }); + } + let shown = crate::custom_toolbars::shown_tool(bar, active, &tools); + Some(Found { target, location: if shown == Some(tool) { "toolbar" } else { "flyout" }, shown }) }); - if let Some((name, location)) = custom { - start(app, tool, Target::Custom(name.clone())); - return Ok(json!({"tool": tool, "location": location, "toolbar": name})); - } - app.run("window.editToolbar", json!({"open": true}))?; - start(app, tool, Target::AllTools); - Ok(json!({"tool": tool, "location": "allTools", "toolbar": null})) + Ok(custom.or(main).unwrap_or(Found { target: Target::AllTools, location: "allTools", shown: None })) } diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index c8cbd94cfd..7372d424f7 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -299,6 +299,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, cols: usize, floating: Option, key: &str) -> egui::Id { /// One icon button per tool, the active one lit, with its name and shortcut on hover. Returns the /// tool clicked and the button of `locate`. -fn tool_strip(ui: &mut Ui, t: &Tokens, active: &str, tools: &[String], locate: Option<&str>) -> (Option<&'static str>, Option) { +fn tool_strip( + ui: &mut Ui, + t: &Tokens, + active: &str, + tools: &[String], + toolbar: Option<&str>, + locate: Option<&str>, +) -> (Option<&'static str>, Option) { let mut chosen = None; let mut located = None; for tool in tools.iter().filter_map(|id| tool_info(id)) { let (r, resp) = ui.allocate_exact_size(STRIP_BUTTON, Sense::click()); + crate::palette::note_spot(ui, r, || crate::palette::SpotAt::Strip(toolbar.map(str::to_string), tool.id.to_string())); let well = r.shrink(1.0); if active == tool.id { ui.painter().rect_filled(well, CornerRadius::same(6), t.tool_active); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 2059f3d35d..ed127fd7a2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1337,6 +1337,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A Command Palette query word also finds a result whose name or menu path holds a word with the same meaning: "remove bg" lists Remove Background… first, "outline text" lists Type › Create Outlines first, and "flip", "combine", "vectorize" and "colour" list Reflect…, Unite, an Image Trace command and the Color panel among the first 3 results. The words come from VectorCraft's own table of 21 groups of English words (`palette/words.rs`, at most 60 groups of at most 6 words); a word that is the whole label of another command, such as Merge or Mirror, is in no group, and neither is Insert. A word or its English base word that is in a group meets the other words of its group in labels and menu paths, and their base words, but not ids or word starts. A result whose label holds the word itself ranks above one whose label holds a word with the same meaning, which ranks above one whose menu path holds the word, so "type" now lists Scale Text Attributes above Type › Orientation › Vertical. A catalog may add a group's words in its language with a row in the `search` context (the group's English words joined by ", ", then that language's words), used while that language is the UI language; no catalog has to have these rows (`palette::search` tests `a_word_with_the_same_meaning_finds_the_result`, `a_catalog_row_adds_words_to_a_group`, `words_with_the_same_meaning_find_the_command`; `palette::words` tests; `i18n` test `search_rows_name_a_group_and_add_single_words`). A Command Palette query word also finds a command by what the command's description says: "transparent background" lists Remove Background… among the first 3 results, and "png" lists it after every result with "png" in its name or menu path. The description is the command's params text (an engine or plug-in command's, a UI command's, or an effect's) without each `{…}` group that is not inside a `{`, `[` or `(` group, without each such `[…]` or `(…)` group just after a `→`, and without the `→` before a removed group, cut to its first 300 characters at the end of a word. The words of a schema ("corners" for Remove Background…) and of a result written as a group do not find the command; a result written as words after a `→` stays in the description. Words of 2 characters or fewer, words with no letter, and "the", "and", "ids", "true", "false" and "null" are left out. A query word that is a word of a description, shares an English base word with one, starts one or has the same meaning as one finds the result, and such a result ranks below every result that the query matches in its name, menu path or id, as text inside a word or through a typo. Descriptions are English only, and a typo does not match them. Tools, panels and filter plug-ins have no description (`palette::search` tests `a_description_leaves_out_the_schema_and_the_result`, `a_word_of_the_description_finds_the_result`, `a_description_match_ranks_below_a_typo`, `words_of_a_description_find_the_command`). Each Command Palette row starts with an icon for its kind (a tool's own icon, or one for a panel, an effect, a filter plug-in or a command) and shows where the result lives after its label, in smaller dim text: the menu path of the menu bar item that runs it, with that item's label when it differs from the result's ("File › Exit" for Quit VectorCraft), and "No menu item" for a command no item runs. A panel's row shows "Window". A row with a home shows its label without the menu path in front of it. A path that keeps two results' names apart stays in the label, unless the row's home shows the same path; a tool's row drops the "Tools" in front of its name. A tool's row names the toolbar it is on: "Toolbar" for its button on the Tools panel, or the name of a toolbar made with New Toolbar, followed by ", in the group" when the tool is hidden in the group of a slot whose button shows another tool ("Toolbar, in the Direct Selection Tool group" for the Group Selection Tool), and "All Tools" when no toolbar holds it. A toolbar shown now comes first (the Tools panel, then the toolbars made with New Toolbar), then a hidden Tools panel, then hidden toolbars made with New Toolbar; toolbars count as hidden in Presentation Mode and while Tab hides the panels. The Learn command (`window.learn`), which Window › Learn runs, takes the Window menu as its home, so a search reads its menu path like any other result's, and among results that tie on everything else it ranks as a command of the menu bar, before panels and after tools. The home is cut short with "…" before the label, and a label too long for the row keeps the id it shows after its name unless the id alone is wider than the row. A cut row shows all its text while the pointer rests on it, and screen readers read the kind, the label, the home and the shortcut. The row height is unchanged (`palette` tests `rows_show_where_each_result_lives`, `no_two_rows_read_alike`, `a_tool_row_names_its_toolbar_slot`, `a_narrow_row_cuts_the_home_first_and_keeps_the_id`, `screen_readers_hear_the_kind_and_home`, `catalogs_translate_the_kind_and_home_words`). + While the Command Palette is open, the highlighted result points to where it lives, in the same frame the arrow keys or the pointer move the highlight. A result with an item of the in-window menu bar has that menu's title outlined, with the item's whole path in a box under it ("Effect › Stylize › Round Corners…"); a panel points at the Window menu. A tool has its slot's button outlined on the toolbar the row names, or its own button on a strip torn off its group, with a box on the canvas side of the toolbar that names the tool, or says "In the Direct Selection Tool group: press and hold to open it" for a tool hidden in a group; screen readers hear that sentence with the search field's description. The box stays inside the window and off the button and the palette's popup: beside a button, its text wraps to up to three rows to fit before the popup or the window's edge, and where it still does not fit, the footer shows the text and only the outline is drawn; when the popup covers the control, nothing is drawn and the footer names the home. Nothing opens or shows: no menu, flyout, toolbar or All Tools drawer, and the chosen tool stays. With the system's menu bar, the footer reads "In the menu bar:" and the path instead; when no control in view shows the home (Presentation Mode, toolbars hidden by Window › Tools or Tab, a button scrolled out of view or under a floating panel or another toolbar) the footer names the home followed by "not shown now", and a command with no menu item reads "No menu item" with its shortcut. The menu bar and the toolbars note where they drew their controls only while the palette is open, and the palette uses only what this pass drew in its own window (`palette` tests `the_highlighted_result_outlines_its_menu_title`, `with_a_native_menu_bar_the_footer_names_the_path`, `a_tool_result_outlines_its_toolbar_slot`, `a_tool_on_a_toolbar_made_with_new_toolbar_is_outlined_there`, `a_strip_torn_off_the_tools_panel_is_pointed_at`, `a_box_beside_a_button_wraps_to_fit_beside_the_popup`, `the_box_keeps_off_its_button`, `the_callout_stays_off_the_palette`, `the_callout_keeps_off_a_popup_that_grew_in_the_same_pass`, `a_home_out_of_view_is_named_in_the_footer`, `the_pass_that_opens_the_palette_names_no_home_as_hidden`, `the_callout_follows_the_pointer`, `the_callout_follows_the_highlight_and_reveals_nothing`, `only_a_control_in_view_in_this_pass_is_pointed_at`, `a_control_under_a_window_is_not_pointed_at`, `the_noted_controls_hold_one_pass_per_viewport`, `catalogs_translate_the_callout_words`). `object.setProps` with `visible: false` or `locked: true` deselects every selected object that is then hidden or locked, the key object included, as the eye and lock columns do. Ctrl/Cmd+Alt-clicking an eye switches the other layers to Outline and the row's layer to Preview, or switches all layers back to Preview when the others are in Outline (`layer.outlineOthers`, `layer.previewAll`). Ctrl/Cmd+Alt-clicking New Layer adds a layer directly below the current layer, at its level (`layer.new {below: true}`), and Ctrl/Cmd+Alt-clicking New Sublayer adds a sublayer under the contents of the layer it goes into (`layer.newSublayer {bottom: true}`), each in one undo step. The reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists these clicks for placing a layer below the selected layer and a new sublayer at the bottom of the layer list. From c8a0650bcdd589204914a4f41087dc03a3ee0990 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:19:55 -0800 Subject: [PATCH 2/4] Command Palette: an effect's item in the path translates as the Effect menu's does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The callout, the row's home and the search index named a built-in effect's menu item with the plain translation of its English label, while the Effect menu translates it by the effect id (Effect › Pathfinder › Réunion in French). They now use the effect id first, and a live-effect plug-in's name stays as written, as in the menu. --- crates/ui-egui/src/palette.rs | 49 ++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 1c9c42d1fb..1a5cd0b1ef 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -268,6 +268,17 @@ fn shown_label(lang: crate::i18n::Lang, label: &str) -> String { label.split(" › ").map(|s| crate::i18n::tr(lang, s)).collect::>().join(" › ") } +/// The label of the item of the menu bar that runs `e`, in `lang`. A built-in effect's item +/// translates by its effect id first, as the Effect menu's does, and a live-effect plug-in's name +/// does not translate. +fn item_label(lang: crate::i18n::Lang, e: &Entry) -> &'static str { + match e.id.strip_prefix("effect:") { + Some(effect) if vectorcraft_plugins::effect::plugin_id(effect).is_some() => e.menu_item, + Some(effect) => crate::i18n::tr_id(lang, effect, e.menu_item), + None => crate::i18n::tr(lang, e.menu_item), + } +} + /// One palette entry, with what it shows and what a query matches worked out once. pub(crate) struct Entry { id: String, @@ -343,7 +354,7 @@ fn entries_in(ctx: &egui::Context, lang: crate::i18n::Lang, native: bool) -> Arc fn catalog(lang: crate::i18n::Lang, native: bool) -> Catalog { let list = build_in(lang, native); let shown_homes: Vec> = - list.iter().map(|e| e.home.as_deref().map(|h| format!("{} › {}", shown_label(lang, h), crate::i18n::tr(lang, e.menu_item)))).collect(); + list.iter().map(|e| e.home.as_deref().map(|h| format!("{} › {}", shown_label(lang, h), item_label(lang, e)))).collect(); // A group's row in the `search` context gives its words in `lang`; a plain row is not read. let search_row = |key: &str| crate::i18n::tr_ctx_row(lang, words::CONTEXT, key).map(str::to_string); let index = search::Index::build(&list, &shown_homes, ¶ms_texts(&list), search_row); @@ -508,7 +519,7 @@ fn home_text(app: &VectorcraftApp, e: &Entry) -> String { return tool_home(app, tool); } match &e.home { - Some(path) if e.names_item => format!("{} › {}", shown_label(lang, path), crate::i18n::tr(lang, e.menu_item)), + Some(path) if e.names_item => format!("{} › {}", shown_label(lang, path), item_label(lang, e)), Some(path) => shown_label(lang, path), None => tl!("No menu item").to_string(), } @@ -735,7 +746,7 @@ fn pointer(app: &VectorcraftApp, ctx: &egui::Context, e: &Entry) -> Pointer { // The native bar's application menu gives its items no label of their own. let full = match e.menu_item { "" => shown_label(lang, path), - item => format!("{} › {}", shown_label(lang, path), crate::i18n::tr(lang, item)), + _ => format!("{} › {}", shown_label(lang, path), item_label(lang, e)), }; let in_bar = crate::i18n::fmt(tl!("In the menu bar: {path}"), &[("path", &full)]); if app.services.native_menu.is_some() { @@ -3437,6 +3448,38 @@ mod tests { assert!(labels(&nodes).contains(&menu), "{:?}", labels(&nodes)); } + /// A built-in effect's item in the path translates by its effect id, as the Effect menu shows + /// it. + #[test] + fn the_path_names_an_effect_item_as_the_effect_menu_does() { + let mut window = Window::new(); + window.app.services.native_menu = Some(crate::native_menu::NativeMenu::new(Box::new(NativeMenus))); + let fr = Lang::from_code("fr").unwrap(); + crate::i18n::set_current(fr); + let list = entries(&window.ctx, fr); + let add = list.iter().find(|e| e.id == "effect:pathfinder.add").expect("the Add effect"); + let shown = match pointer(&window.app, &window.ctx, add) { + Pointer::Footer(text) => text, + Pointer::At(_, text, _) => text, + }; + crate::i18n::set_current(Lang::EN); + assert!(shown.ends_with(" › Réunion"), "{shown}"); + // A live-effect plug-in's name stays as written, as the Effect menu shows it. + let plugin = Entry { + id: format!("effect:{}", vectorcraft_plugins::effect::effect_id("test.ui.add")), + shortcut: String::new(), + shown: "Add".into(), + haystack: String::new(), + home: Some("Effect › Plug-ins".into()), + menu_item: "Add", + kind: 0, + label_at: 0, + names_item: false, + }; + assert_ne!(crate::i18n::tr(fr, "Add"), "Add"); + assert_eq!(item_label(fr, &plugin), "Add"); + } + /// A tool hidden in a group outlines its group's button and says how to open the group; once /// chosen from the group, the button shows it and the box names the tool alone. The box is on /// the canvas side of the toolbar. From 046dc65db8d5d0be1e0a07b23e939c5ae2bd9337 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:34:44 -0800 Subject: [PATCH 3/4] Command Palette: a tool on a torn-off strip is named without its group A row's home, the footer and the screen-reader text named a tool on a strip torn off a group as hidden "in the ... group", while the strip shows each of its tools on its own button and the callout outlines that button. A torn-off group's tools are now named by their toolbar alone, on the Tools panel and on toolbars made with New Toolbar. --- crates/ui-egui/src/palette.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 1a5cd0b1ef..122b09c7c3 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -527,7 +527,8 @@ fn home_text(app: &VectorcraftApp, e: &Entry) -> String { /// Where `tool` is in the current layout: "Toolbar" for its button on the Tools panel, or the name /// of the toolbar made with New Toolbar that holds it, followed by ", in the group", naming -/// the tool its slot's button shows, when the tool is hidden in that slot's group; "All Tools" +/// the tool its slot's button shows, when the tool is hidden in that slot's group and the group is +/// not torn off into a strip; "All Tools" /// when no toolbar holds it. A toolbar shown now comes first: the Tools panel, then the toolbars /// made with New Toolbar; then a hidden Tools panel, then hidden toolbars made with New Toolbar. /// Toolbars are hidden in Presentation Mode and while Tab hides the panels. @@ -540,12 +541,19 @@ fn tool_home(app: &VectorcraftApp, tool: &str) -> String { }; let toolbars_shown = app.ui.screen_mode < 3 && app.ui.tab_hid.is_none(); let main = crate::toolbar::slots(app).into_iter().map(|(_, s)| s).find(|s| s.contains(&tool)); - let main = main.map(|slot| place(tl!("Toolbar"), Some(crate::toolbar::shown_tool(app, &slot)))); + // A group torn off into a strip shows each of its tools on its own button. + let main = main.map(|slot| { + let torn_off = slot.len() > 1 && crate::toolbar::is_floating(app, None, slot[0]); + place(tl!("Toolbar"), if torn_off { None } else { Some(crate::toolbar::shown_tool(app, &slot)) }) + }); let active = app.session.tool_id(); let custom = |shown: bool| { app.ui.custom_toolbars.iter().filter(|b| b.shown == shown).find_map(|bar| { let slot = bar.slots.iter().find(|s| s.iter().any(|t| t == tool))?; let tools: Vec<&'static str> = slot.iter().filter_map(|id| vectorcraft_tools::tool_info(id).map(|t| t.id)).collect(); + if tools.len() > 1 && tools.first().is_some_and(|first| crate::toolbar::is_floating(app, Some(&bar.name), first)) { + return Some(place(&bar.name, None)); + } Some(place(&bar.name, crate::custom_toolbars::shown_tool(bar, active, &tools))) }) }; @@ -3543,6 +3551,8 @@ mod tests { assert!(callout.is_some()); assert_eq!(outlined, bounds_of(&nodes, "Pen Tool")); assert!(outlined.left() >= 100.0, "on the toolbar made with New Toolbar: {outlined:?}"); + let bar = window.app.ui.custom_toolbars[0].name.clone(); + assert_eq!(tool_home(&window.app, "curvature"), format!("{bar}, in the Pen Tool group")); // The group torn off into a strip. window.app.ui.custom_toolbars[0] .floating @@ -3552,6 +3562,8 @@ mod tests { let (outlined, _, text) = window.callout().expect("a callout"); assert_eq!(text, "Pen Tool"); assert!(outlined.left() >= 600.0 && outlined.top() >= 500.0, "on the strip: {outlined:?}"); + // The row's home names no group: the strip shows each tool on its own button. + assert_eq!(tool_home(&window.app, "curvature"), bar); } /// A group torn off the Tools panel into a strip has the tool's own button on the strip @@ -3569,6 +3581,8 @@ mod tests { assert_eq!(text, "Group Selection Tool"); assert!(callout.is_some()); assert!(outlined.left() >= 600.0 && outlined.top() >= 500.0, "on the strip: {outlined:?}"); + // The row's home names no group: the strip shows each tool on its own button. + assert_eq!(tool_home(&window.app, "groupSelection"), "Toolbar"); } /// Two viewports that note controls in turn keep one pass each in the list, whichever noted From f053c280a529f7b7f1a6f7d020886895628ed876 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 17:14:07 -0800 Subject: [PATCH 4/4] Command Palette: a menu item in the path is named as the menu bar draws it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The callout, the row's home and the search index translated a filter plug-in's name, which Object › Plug-ins shows as written, and translated other items by their English label alone, while the menu bar translates them by the command id first (File › Close is Cerrar archivo in Spanish). They now use the menu bar's rule. --- crates/ui-egui/src/palette.rs | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs index 122b09c7c3..5ce4f9014b 100644 --- a/crates/ui-egui/src/palette.rs +++ b/crates/ui-egui/src/palette.rs @@ -268,15 +268,26 @@ fn shown_label(lang: crate::i18n::Lang, label: &str) -> String { label.split(" › ").map(|s| crate::i18n::tr(lang, s)).collect::>().join(" › ") } -/// The label of the item of the menu bar that runs `e`, in `lang`. A built-in effect's item -/// translates by its effect id first, as the Effect menu's does, and a live-effect plug-in's name -/// does not translate. +/// The label of the item of the menu bar that runs `e`, in `lang`, as the menu bar draws it +/// ([`menus::display_label`]). A built-in effect's item translates by its effect id first, as the +/// Effect menu's does. Any other item translates by the id of the command it runs first (File › +/// Close is Cerrar archivo in Spanish), and a name the menu shows as written ([`menus::shows_a_name`]: +/// a filter or live-effect plug-in's) does not translate. fn item_label(lang: crate::i18n::Lang, e: &Entry) -> &'static str { - match e.id.strip_prefix("effect:") { - Some(effect) if vectorcraft_plugins::effect::plugin_id(effect).is_some() => e.menu_item, - Some(effect) => crate::i18n::tr_id(lang, effect, e.menu_item), - None => crate::i18n::tr(lang, e.menu_item), + if let Some(effect) = e.id.strip_prefix("effect:") { + return match vectorcraft_plugins::effect::plugin_id(effect) { + Some(_) => e.menu_item, + None => crate::i18n::tr_id(lang, effect, e.menu_item), + }; } + // The command the menu item runs: `plugin.dialog` for a filter, `window.panel` for a panel and + // the engine command a UI command wraps. + let id = match e.id.as_str() { + id if id.starts_with("plugin:") => "plugin.dialog", + id if id.starts_with("panel:") => "window.panel", + id => WRAPPED.iter().find(|(_, ui)| *ui == id).map_or(id, |(engine, _)| engine), + }; + if menus::shows_a_name(id, e.menu_item) { e.menu_item } else { crate::i18n::tr_id(lang, id, e.menu_item) } } /// One palette entry, with what it shows and what a query matches worked out once. @@ -3457,7 +3468,7 @@ mod tests { } /// A built-in effect's item in the path translates by its effect id, as the Effect menu shows - /// it. + /// it, another item by its command id, and a plug-in's name stays as written. #[test] fn the_path_names_an_effect_item_as_the_effect_menu_does() { let mut window = Window::new(); @@ -3486,6 +3497,14 @@ mod tests { }; assert_ne!(crate::i18n::tr(fr, "Add"), "Add"); assert_eq!(item_label(fr, &plugin), "Add"); + // So does a filter plug-in's name, as Object › Plug-ins shows it. + let filter = Entry { id: "plugin:test.ui.add".into(), home: Some("Object › Plug-ins".into()), ..plugin }; + assert_eq!(item_label(fr, &filter), "Add"); + // Another item translates by the id of the command it runs, as the menu bar draws it. + let es = Lang::from_code("es").unwrap(); + let close = entries(&window.ctx, es).iter().find(|e| e.id == "file.close").map(|e| (e.menu_item, item_label(es, e))); + assert_ne!(crate::i18n::tr(es, "Close"), "Cerrar archivo"); + assert_eq!(close, Some(("Close", "Cerrar archivo"))); } /// A tool hidden in a group outlines its group's button and says how to open the group; once