From cf3e47d513795516f1f17c944cbe2e028501e8bb Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 01:40:34 -0800 Subject: [PATCH] Align: Align to Key Object names the Artboard tool when that blocks it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - With the Artboard tool chosen, align.toKeyObject fails with "Align to Key Object isn't available with the Artboard tool" instead of "no key object": the selected objects can still have a key in that state. The message has a row in every catalog that has "no key object". - Align to Key Object is off in Object › Align and the Align panel when the topmost selected object is inside another selected object, the case where choosing it already failed. - The align.toSelection params text says the selected objects keep their key with the Artboard tool chosen; ui_catalog.rs regenerated. - A test pins Align to Key Object with a key anchor: checked, the menu name kept, and the key anchor kept. --- crates/mcp/src/ui_catalog.rs | 4 +-- crates/ui-egui/src/i18n/bg.tsv | 1 + crates/ui-egui/src/i18n/bs.tsv | 1 + crates/ui-egui/src/i18n/ca.tsv | 1 + crates/ui-egui/src/i18n/cs.tsv | 1 + crates/ui-egui/src/i18n/da.tsv | 1 + crates/ui-egui/src/i18n/de.tsv | 1 + crates/ui-egui/src/i18n/el.tsv | 1 + crates/ui-egui/src/i18n/es.tsv | 1 + crates/ui-egui/src/i18n/fi.tsv | 1 + crates/ui-egui/src/i18n/fr.tsv | 1 + crates/ui-egui/src/i18n/hi.tsv | 1 + crates/ui-egui/src/i18n/hu.tsv | 1 + crates/ui-egui/src/i18n/id.tsv | 1 + crates/ui-egui/src/i18n/it.tsv | 1 + crates/ui-egui/src/i18n/ja.tsv | 1 + crates/ui-egui/src/i18n/ka.tsv | 1 + crates/ui-egui/src/i18n/ko.tsv | 1 + crates/ui-egui/src/i18n/nl.tsv | 1 + crates/ui-egui/src/i18n/pl.tsv | 1 + crates/ui-egui/src/i18n/pt-br.tsv | 1 + crates/ui-egui/src/i18n/ru.tsv | 1 + crates/ui-egui/src/i18n/sv.tsv | 1 + crates/ui-egui/src/i18n/tr.tsv | 1 + crates/ui-egui/src/i18n/uk.tsv | 1 + crates/ui-egui/src/i18n/vi.tsv | 1 + crates/ui-egui/src/i18n/zh-hans.tsv | 1 + crates/ui-egui/src/i18n/zh-hant.tsv | 1 + crates/ui-egui/src/menus/ui_commands.rs | 4 +-- crates/ui-egui/src/panels/align.rs | 45 +++++++++++++++--------- crates/ui-egui/src/panels/align/tests.rs | 26 ++++++++++++-- docs/mcp.md | 10 +++--- 32 files changed, 89 insertions(+), 27 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 8c3bcef98e..caa2104e76 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -378,13 +378,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "align.toSelection", "Align to Selection", "", - "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}; with the Artboard tool chosen the selected objects keep their key", ), ( "align.toKeyObject", "Align to Key Object", "", - "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, which includes a topmost selected object inside another selected object; an error (\"Align to Key Object isn't available with the Artboard tool\") with the Artboard tool chosen", ), ( "align.toArtboard", diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 8d833f9cdb..4d76241b8d 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -4775,6 +4775,7 @@ axis Both И двете @msg no graphic style `{n}` няма графичен стил `{n}` @msg no interaction in progress няма текущо взаимодействие @msg no key object няма основен обект +@msg Align to Key Object isn't available with the Artboard tool „Подравняване спрямо ключов обект“ не е налично с инструмента „Работна област“ @msg no library `{key}` (see {list}) няма библиотека `{key}` (вижте {list}) @msg no native format няма нативен формат @msg no pages няма страници diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 280056bb88..c8c3993c65 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -5183,6 +5183,7 @@ imageTrace Outline Obris @msg no graphic style `{n}` nema grafičkog stila `{n}` @msg no interaction in progress nema interakcije u toku @msg no key object nema ključnog objekta +@msg Align to Key Object isn't available with the Artboard tool „Poravnaj s ključnim objektom“ nije dostupno s alatom radna ploča @msg no library `{key}` (see {list}) nema biblioteke `{key}` (vidi {list}) @msg no native format nema izvornog formata @msg no pages nema stranica diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 5d0db6ef1d..96f2aee5ee 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6344,6 +6344,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg no history state {v} no hi ha cap estat de l’historial {v} @msg no interaction in progress no hi ha cap interacció en curs @msg no key object no hi ha objecte clau +@msg Align to Key Object isn't available with the Artboard tool «Alinea a l’objecte clau» no està disponible amb l’eina de tauler @msg no library `{id}` no hi ha la biblioteca `{id}` @msg the library has another item of that kind named `{name}` la biblioteca ja té un altre element d’aquest tipus anomenat `{name}` @msg no library `{key}` (see {list}) no hi ha la biblioteca `{key}` (vegeu {list}) diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 3076fe7875..7ab54c355a 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5497,6 +5497,7 @@ liquify-list-end {0}, {1} {0} a {1} @msg no graphic style `{n}` grafický styl `{n}` neexistuje @msg no interaction in progress neprobíhá žádná interakce @msg no key object žádný klíčový objekt +@msg Align to Key Object isn't available with the Artboard tool „Zarovnat ke klíčovému objektu“ není s nástrojem Pracovní plocha k dispozici @msg no library `{key}` (see {list}) knihovna `{key}` neexistuje (viz {list}) @msg no native format chybí nativní formát @msg no pages žádné stránky diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index b610b9116d..a86d95d91e 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -7671,6 +7671,7 @@ imageTrace Outline Kontur @msg no graphic style `{n}` ingen grafisk stil `{n}` @msg no interaction in progress ingen interaktion i gang @msg no key object intet nøgleobjekt +@msg Align to Key Object isn't available with the Artboard tool Juster til nøgleobjekt er ikke tilgængelig med tegnebrætværktøjet @msg no library `{key}` (see {list}) intet bibliotek `{key}` (se {list}) @msg no native format intet indbygget format @msg no pages ingen sider diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9f0b61afac..4af672551a 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5091,6 +5091,7 @@ liquify-list-end {0}, {1} {0} und {1} @msg no graphic style `{n}` kein Grafikstil `{n}` @msg no interaction in progress keine Interaktion im Gange @msg no key object kein Basisobjekt +@msg Align to Key Object isn't available with the Artboard tool „An Basisobjekt ausrichten“ ist mit dem Zeichenflächen-Werkzeug nicht verfügbar @msg no library `{key}` (see {list}) keine Bibliothek `{key}` (siehe {list}) @msg no native format kein natives Format @msg no pages keine Seiten diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index a15c2c555f..4c376a4f18 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5154,6 +5154,7 @@ digits Malayalam Μαλαγιάλαμ @msg no graphic style `{n}` δεν υπάρχει στυλ γραφικών `{n}` @msg no interaction in progress δεν υπάρχει αλληλεπίδραση σε εξέλιξη @msg no key object δεν υπάρχει βασικό αντικείμενο +@msg Align to Key Object isn't available with the Artboard tool η «Στοίχιση ως προς το βασικό αντικείμενο» δεν είναι διαθέσιμη με το εργαλείο πίνακα σχεδίασης @msg no library `{key}` (see {list}) δεν υπάρχει βιβλιοθήκη `{key}` (δείτε {list}) @msg no native format δεν υπάρχει εγγενής μορφή @msg no pages δεν υπάρχουν σελίδες diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 5af6a75d82..a3730586df 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5204,6 +5204,7 @@ liquify-list-end {0}, {1} {0}, {1} @msg no graphic style `{n}` no existe el estilo gráfico `{n}` @msg no interaction in progress no hay ninguna interacción en curso @msg no key object no hay objeto clave +@msg Align to Key Object isn't available with the Artboard tool «Alinear con el objeto clave» no está disponible con la herramienta Mesa de trabajo @msg no library `{key}` (see {list}) no existe la biblioteca `{key}` (consulta {list}) @msg no native format no hay formato nativo @msg no pages no hay páginas diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 1a3f52e96d..f1e36c4d9f 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5420,6 +5420,7 @@ liquify-list-end {0}, {1} {0} ja {1} @msg no graphic style `{n}` ei grafiikkatyyliä `{n}` @msg no interaction in progress mikään vuorovaikutus ei ole käynnissä @msg no key object ei avainobjektia +@msg Align to Key Object isn't available with the Artboard tool ”Tasaa avainobjektiin” ei ole käytettävissä piirtoalustatyökalulla @msg no library `{key}` (see {list}) ei kirjastoa `{key}` (ks. {list}) @msg no native format ei omaa tiedostomuotoa @msg no pages ei sivuja diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index e2adbffc29..8b2c99741f 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5163,6 +5163,7 @@ liquify-list-end {0}, {1} {0} et {1} @msg no graphic style `{n}` aucun style graphique `{n}` @msg no interaction in progress aucune interaction en cours @msg no key object aucun objet clé +@msg Align to Key Object isn't available with the Artboard tool L’alignement sur l’objet clé n’est pas disponible avec l’outil Plan de travail @msg no library `{key}` (see {list}) aucune bibliothèque `{key}` (voir {list}) @msg no native format aucun format natif @msg no pages aucune page diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index e63af675f2..c009cb8cc7 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7883,6 +7883,7 @@ liquify-list-end {0}, {1} {0} और {1} @msg no item at index {from} इंडेक्स {from} पर कोई आइटम नहीं @msg no item at one of the indices {idx} indices {idx} में से एक पर कोई आइटम नहीं @msg no key object कोई कुंजी ऑब्जेक्ट नहीं +@msg Align to Key Object isn't available with the Artboard tool आर्टबोर्ड टूल के साथ "मुख्य ऑब्जेक्ट पर संरेखित करें" उपलब्ध नहीं है @msg no layer कोई लेयर नहीं @msg no layer {id} (see layer.list) कोई लेयर {id} (layer.list देखें) @msg no layers to export निर्यात करने के लिए कोई लेयरें नहीं diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 68a8c82cf2..24f8ded896 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5869,6 +5869,7 @@ liquify-list-end {0}, {1} {0} és {1} @msg no graphic style `{n}` nincs ilyen grafikai stílus: `{n}` @msg no interaction in progress nincs folyamatban lévő művelet @msg no key object nincs kulcsobjektum +@msg Align to Key Object isn't available with the Artboard tool az „Igazítás a kulcsobjektumhoz” nem érhető el a Rajztábla eszközzel @msg no library `{id}` nincs ilyen könyvtár: `{id}` @msg the library has another item of that kind named `{name}` a könyvtárban már van egy másik ilyen fajta elem `{name}` néven @msg no library `{key}` (see {list}) nincs ilyen könyvtár: `{key}` (lásd: {list}) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index b5ca49a56b..e6c3aaf72e 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4882,6 +4882,7 @@ imageTrace Outline Kontur @msg no graphic style `{n}` tidak ada gaya grafis `{n}` @msg no interaction in progress tidak ada interaksi yang berlangsung @msg no key object tidak ada objek kunci +@msg Align to Key Object isn't available with the Artboard tool Ratakan ke objek kunci tidak tersedia dengan alat artboard @msg no library `{key}` (see {list}) tidak ada pustaka `{key}` (lihat {list}) @msg no native format tidak ada format asli @msg no pages tidak ada halaman diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index c09271ca2b..d8980a6a4f 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5228,6 +5228,7 @@ liquify-list-end {0}, {1} {0} e {1} @msg no graphic style `{n}` nessuno stile grafico `{n}` @msg no interaction in progress nessuna interazione in corso @msg no key object nessun oggetto chiave +@msg Align to Key Object isn't available with the Artboard tool «Allinea all'oggetto chiave» non è disponibile con lo strumento Tavola da disegno @msg no library `{key}` (see {list}) nessuna libreria `{key}` (vedi {list}) @msg no native format nessun formato nativo @msg no pages nessuna pagina diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d3b9bef584..4b2a28a762 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -4959,6 +4959,7 @@ variable-list-end {0}, {1} {0}、{1} @msg no bounds 境界がありません @msg no current layer 現在のレイヤーがありません @msg no key object キーオブジェクトが設定されていません +@msg Align to Key Object isn't available with the Artboard tool アートボードツールでは「キーオブジェクトに整列」を使用できません @msg no previous transform 前回の変形がありません @msg nothing to align 整列するものがありません @msg select a clip group クリップグループを選択してください diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index cc03030df2..edeb02faeb 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -6960,6 +6960,7 @@ font-technology Variable ცვლადი @msg no graphic style `{n}` გრაფიკული სტილი `{n}` არ არის @msg no interaction in progress მიმდინარე ურთიერთქმედება არ არის @msg no key object საკვანძო ობიექტი არ არის +@msg Align to Key Object isn't available with the Artboard tool „საკვანძო ობიექტზე სწორება“ სამუშაო დაფის ხელსაწყოსთან მიუწვდომელია @msg no library `{key}` (see {list}) ბიბლიოთეკა `{key}` არ არის (იხ. {list}) @msg no native format საკუთარი ფორმატი არ არის @msg no pages გვერდები არ არის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 4fa5ba90d8..7c805dd002 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -4886,6 +4886,7 @@ variable-list-end {0}, {1} {0} 및 {1} @msg no bounds 경계가 없습니다 @msg no current layer 현재 레이어가 없습니다 @msg no key object 키 개체가 없습니다 +@msg Align to Key Object isn't available with the Artboard tool 아트보드 도구에서는 키 개체에 정렬을 사용할 수 없습니다 @msg no previous transform 이전 변형이 없습니다 @msg nothing to align 정렬할 항목이 없습니다 @msg select a clip group 클립 그룹을 선택하세요 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index e726eae41b..237f4b978f 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5550,6 +5550,7 @@ imageTrace Outline Contour @msg no graphic style `{n}` geen grafische stijl `{n}` @msg no interaction in progress geen interactie gaande @msg no key object geen sleutelobject +@msg Align to Key Object isn't available with the Artboard tool Uitlijnen op sleutelobject is niet beschikbaar met het tekengebied-gereedschap @msg no library `{key}` (see {list}) geen bibliotheek `{key}` (zie {list}) @msg no native format geen eigen indeling @msg no pages geen pagina's diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 8cd18cdcb2..e996ff50d2 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5314,6 +5314,7 @@ liquify-list-end {0}, {1} {0} i {1} @msg no graphic style `{n}` brak stylu graficznego `{n}` @msg no interaction in progress brak trwającej interakcji @msg no key object brak obiektu kluczowego +@msg Align to Key Object isn't available with the Artboard tool „Wyrównaj do obiektu kluczowego” jest niedostępne z narzędziem Obszar kompozycji @msg no library `{key}` (see {list}) brak biblioteki `{key}` (patrz {list}) @msg no native format brak formatu natywnego @msg no pages brak stron diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index bba7ed642c..b302d733c9 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4460,6 +4460,7 @@ axis Both Ambos @msg no graphic style `{n}` nenhum estilo gráfico `{n}` @msg no interaction in progress nenhuma interação em andamento @msg no key object nenhum objeto-chave +@msg Align to Key Object isn't available with the Artboard tool Alinhar ao Objeto-Chave não está disponível com a Ferramenta Mesa de Trabalho @msg no library `{key}` (see {list}) nenhuma biblioteca `{key}` (veja {list}) @msg no native format sem formato nativo @msg no pages sem páginas diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e2ab3a9097..691c5ec468 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5225,6 +5225,7 @@ liquify-list-end {0}, {1} {0} и {1} @msg no graphic style `{n}` нет графического стиля `{n}` @msg no interaction in progress нет взаимодействия в процессе @msg no key object нет ключевого объекта +@msg Align to Key Object isn't available with the Artboard tool «Выровнять по ключевому объекту» недоступно с инструментом «Монтажная область» @msg no library `{key}` (see {list}) нет библиотеки `{key}` (см. {list}) @msg no native format нет собственного формата @msg no pages нет страниц diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 4893ecc8ce..db6fe3dd59 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5094,6 +5094,7 @@ liquify-list-end {0}, {1} {0} och {1} @msg no graphic style `{n}` ingen grafisk stil `{n}` @msg no interaction in progress ingen interaktion pågår @msg no key object inget nyckelobjekt +@msg Align to Key Object isn't available with the Artboard tool Justera mot nyckelobjekt är inte tillgängligt med ritytsverktyget @msg no library `{key}` (see {list}) inget bibliotek `{key}` (se {list}) @msg no native format inget eget format @msg no pages inga sidor diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 3f6be1e0f9..12429053aa 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4916,6 +4916,7 @@ liquify-list-end {0}, {1} {0} ve {1} @msg no graphic style `{n}` grafik stili yok `{n}` @msg no interaction in progress herhangi bir etkileşim devam etmiyor @msg no key object anahtar nesne yok +@msg Align to Key Object isn't available with the Artboard tool Anahtar Nesneye Hizala, Çalışma Yüzeyi Aracı ile kullanılamaz @msg no library `{key}` (see {list}) `{key}` kitaplığı yok (bkz. {list}) @msg no native format yerel format yok @msg no pages sayfa yok diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 845010a40f..5cb7d71a6a 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5212,6 +5212,7 @@ liquify-list-end {0}, {1} {0} і {1} @msg no graphic style `{n}` немає графічного стилю `{n}` @msg no interaction in progress немає взаємодії у процесі @msg no key object немає ключового об’єкта +@msg Align to Key Object isn't available with the Artboard tool «Вирівняти за ключовим об’єктом» недоступно з інструментом «Монтажна область» @msg no library `{key}` (see {list}) немає бібліотеки `{key}` (див. {list}) @msg no native format немає власного формату @msg no pages немає сторінок diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index d501f87e17..7744045bef 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5560,6 +5560,7 @@ liquify-list-end {0}, {1} {0} và {1} @msg no graphic style `{n}` không có kiểu đồ họa `{n}` @msg no interaction in progress không có tương tác nào đang tiến hành @msg no key object không có đối tượng khóa +@msg Align to Key Object isn't available with the Artboard tool không thể dùng Căn theo đối tượng chính với Công cụ Bảng vẽ @msg no library `{id}` không có thư viện `{id}` @msg the library has another item of that kind named `{name}` thư viện đã có một mục khác cùng loại tên là `{name}` @msg no library `{key}` (see {list}) không có thư viện `{key}` (xem {list}) diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index a0ffedd15c..2b0693c357 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -4654,6 +4654,7 @@ imageTrace Outline 轮廓 @msg no bounds 没有边界 @msg no current layer 没有当前图层 @msg no key object 没有关键对象 +@msg Align to Key Object isn't available with the Artboard tool 使用画板工具时无法对齐关键对象 @msg no previous transform 没有上一次变换 @msg nothing to align 没有可对齐的内容 @msg select a clip group 请选择一个剪切组 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 86a856ddde..5a43976c8c 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2123,6 +2123,7 @@ file-filter Templates 範本 @msg no bounds 沒有邊界 @msg no current layer 沒有目前圖層 @msg no key object 沒有關鍵物件 +@msg Align to Key Object isn't available with the Artboard tool 使用工作區域工具時無法對齊關鍵物件 @msg no previous transform 沒有上一次的變形 @msg nothing to align 沒有可對齊的內容 @msg select a clip group 請選取剪裁群組 diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 5c24ca9db9..316f740872 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -379,13 +379,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "align.toSelection", "Align to Selection", "", - "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}", + "{} the Align panel's Align to Selection button: Align To becomes Selection (saved with the preferences, ui.inspect › ui.align_to) and the key object, key guide or key anchor is let go → {alignTo: the choice the Align panel then shows: \"selection\", or \"artboard\" while one object is selected, since one object aligns to the artboard}; with the Artboard tool chosen the selected objects keep their key", ), ( "align.toKeyObject", "Align to Key Object", "", - "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, when the topmost selected object can't be the key (it is inside another selected object), or with the Artboard tool chosen", + "{} the Align panel's Align to Key Object button: with no key, the topmost of two or more selected objects becomes the key object, or a ruler guide selected with one object the key guide; the stored Selection or Artboard choice stays → {alignTo: \"key\"}; an error (\"no key object\") when there is no key and nothing to make one of, which includes a topmost selected object inside another selected object; an error (\"Align to Key Object isn't available with the Artboard tool\") with the Artboard tool chosen", ), ( "align.toArtboard", diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index b7de2bb612..ca838c03b9 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -336,20 +336,32 @@ pub(crate) fn shown_align_to(app: &VectorcraftApp) -> AlignTo { aligns_to(align_to(app), objects_aligned(app)) } -/// Whether Align To choice `v` can be chosen. Align to Key Object needs a key object or a key -/// guide, or something to make one of: two or more selected objects, or a guide selected with -/// objects. With the Artboard tool chosen it is off: Align to Artboard keeps the active artboard -/// in place. +/// What Align to Key Object makes the key while there is none, as `select.key` params: the topmost +/// of two or more selected objects when no other selected object holds it, or with one object, a +/// ruler guide selected with it. `None`: nothing can be made the key. +fn key_pick(app: &VectorcraftApp) -> Option { + if selection_len(app) < 2 { + return guide_for_key(app).map(|g| json!({"guide": g})); + } + let id = topmost(app)?; + let st = app.session.active()?; + let inside = st.doc.ancestry(id).unwrap_or_default().into_iter().any(|a| a != id && st.selection.contains(a)); + if inside { None } else { Some(json!({"id": id.0})) } +} + +/// Whether Align To choice `v` can be chosen. Align to Key Object needs a key object, a key guide +/// or a key anchor, or something to make the key ([`key_pick`]). With the Artboard tool chosen it +/// is off: Align to Artboard keeps the active artboard in place. pub(crate) fn can_choose(app: &VectorcraftApp, v: AlignTo) -> bool { if on_artboards(app) { return v != AlignTo::Key; } - v != AlignTo::Key || selection_len(app) >= 2 || has_key(app) || guide_for_key(app).is_some() + v != AlignTo::Key || has_key(app) || key_pick(app).is_some() } /// Chooses Align To `v`, as the Align panel's Align To buttons and the Control bar's Align To menu -/// do. Align to Key Object makes the topmost selected object the key object, unless there is one -/// already; with one object, a guide selected with it becomes the key. The stored choice stays as +/// do. Align to Key Object makes the key what [`key_pick`] gives, unless there is a key already: +/// the topmost selected object, or with one object, a guide selected with it. The stored choice stays as /// it was, and Align To shows it again once the key is cleared. Align to Selection and Align to /// Artboard store the choice and let go of the key object. With the Artboard tool chosen, the /// choice is stored and the selected objects keep their key. @@ -362,12 +374,10 @@ pub(crate) fn choose_align_to(app: &mut VectorcraftApp, v: AlignTo) { return; } if v == AlignTo::Key { - if !has_key(app) { - match (topmost(app).filter(|_| selection_len(app) >= 2), guide_for_key(app)) { - (Some(id), _) => app.run("select.key", json!({"id": id.0})).ok(), - (None, Some(g)) => app.run("select.key", json!({"guide": g})).ok(), - (None, None) => None, - }; + if !has_key(app) + && let Some(p) = key_pick(app) + { + app.run("select.key", p).ok(); } } else { app.ui.align_to = v; @@ -390,10 +400,13 @@ pub(crate) fn align_to_command(id: &str) -> Option { /// Runs the UI command of Align To choice `v`: chooses it as the Align panel's Align To buttons do /// ([`choose_align_to`]) → `{alignTo}`, the choice the Align panel then shows. An error when it -/// can't be chosen: Align to Key Object with no key object and nothing to make one of, with the -/// Artboard tool chosen, or when the topmost selected object can't be the key (it is inside -/// another selected object). +/// can't be chosen: Align to Key Object with the Artboard tool chosen, or with no key and nothing +/// to make the key ([`key_pick`]), which includes a topmost selected object inside another +/// selected object. pub(crate) fn run_align_to(app: &mut VectorcraftApp, v: AlignTo) -> Result { + if v == AlignTo::Key && on_artboards(app) { + return Err("Align to Key Object isn't available with the Artboard tool".into()); + } if !can_choose(app, v) { return Err("no key object".into()); } diff --git a/crates/ui-egui/src/panels/align/tests.rs b/crates/ui-egui/src/panels/align/tests.rs index f2efcf6e35..ffdc0b10a3 100644 --- a/crates/ui-egui/src/panels/align/tests.rs +++ b/crates/ui-egui/src/panels/align/tests.rs @@ -689,7 +689,7 @@ fn align_to_commands_with_the_artboard_tool() { assert!(has_key(&app), "choosing the Artboard tool keeps the key"); let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); assert!(!key_item.enabled, "the Artboard tool"); - assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "Align to Key Object isn't available with the Artboard tool"); assert_eq!(app.run("align.toArtboard", json!({})).unwrap(), json!({"alignTo": "artboard"})); assert_eq!(app.ui.align_to, AlignTo::Artboard); assert_eq!(align_to_checks(&app), [Some(false), Some(false), Some(true)]); @@ -699,18 +699,38 @@ fn align_to_commands_with_the_artboard_tool() { assert_eq!(app.session.active().unwrap().selection.key.map(|k| k.0), front.as_u64(), "the key stays"); } -/// Align to Key Object fails when the topmost selected object can't be the key: a group selected -/// with an object inside it. +/// Align to Key Object is off and fails when the topmost selected object can't be the key: a group +/// selected with an object inside it. #[test] fn align_to_key_object_fails_when_the_topmost_object_cannot_be_the_key() { let (mut app, _, front) = back_and_front(); let group = app.run("object.group", json!({})).unwrap()["id"].clone(); app.run("select.set", json!({"ids": [group, front]})).unwrap(); assert_eq!(app.session.active().unwrap().selection.objects.len(), 2, "the group and its member"); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert!(!key_item.enabled, "the topmost object is inside the group"); + assert!(!can_choose(&app, AlignTo::Key), "the panel's button is off too"); assert_eq!(app.run("align.toKeyObject", json!({})).unwrap_err(), "no key object"); assert!(!has_key(&app)); } +/// With a key anchor, Object → Align shows Align to Key Object checked under its menu name, and +/// the command keeps the key anchor → `{alignTo: "key"}`. +#[test] +fn align_to_key_object_with_a_key_anchor() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let id = app.run("path.create", json!({"d": "M100 40 L200 60 L150 160 Z"})).unwrap()["id"].as_u64().unwrap(); + app.run("select.anchors", json!({"id": id, "anchors": [[0, 0], [0, 2]], "mode": "set"})).unwrap(); + app.run("select.key", json!({"id": id, "anchor": [0, 2]})).unwrap(); + assert_eq!(align_to_checks(&app), [Some(false), Some(true), Some(false)]); + let key_item = crate::menus::menu_entries(&app).into_iter().find(|e| e.command.as_deref() == Some("align.toKeyObject")).unwrap(); + assert_eq!((key_item.label.as_str(), key_item.enabled), ("Align to Key Object", true)); + assert_eq!(app.run("align.toKeyObject", json!({})).unwrap(), json!({"alignTo": "key"})); + let key_anchor = app.session.active().unwrap().selection.key_anchor.map(|(k, a)| (k.0, a)); + assert_eq!(key_anchor, Some((id, (0, 2))), "the key anchor stays"); +} + /// With anchor points selected, Object → Align sends its params unchanged: two anchor points of /// one path align to their own bounds with Align to Selection and with Align to Artboard chosen. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 70e64f9771..4d8e141427 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6994,10 +6994,12 @@ panel then shows (`align.toSelection` returns `"artboard"` while one object is s `align.toSelection` and `align.toArtboard` store the choice (`ui.inspect` › `ui.align_to`) and let the key go; with the Artboard tool chosen they store it and the selected objects keep their key. With no key, `align.toKeyObject` makes the topmost of two or more selected objects the key object, or a ruler guide selected with one object the key guide, and -keeps the stored choice. It fails with "no key object" when there is nothing to make the key, when the topmost selected -object is inside another selected object and can't be the key, and with the Artboard tool chosen. Object › Align lists -the three after its align items, with the choice the panel shows checked, and Edit › Keyboard Shortcuts lists them -under Align with no default shortcut. +keeps the stored choice. It fails with "no key object" when there is nothing to make the key, which includes a topmost +selected object inside another selected object, and with "Align to Key Object isn't available with the Artboard tool" +while the Artboard tool is chosen; its menu item and the panel's button are off in both cases. Object › Align lists the +three after its align items, with the choice the panel shows checked, and Edit › Keyboard Shortcuts lists them under +Align with no default shortcut. While the key is a key anchor, the panel names its choice Align to Key Anchor and the +menu item keeps the name Align to Key Object. With the Artboard tool chosen, the same buttons and UI commands, and the Control bar's Align and Distribute buttons, run `artboard.align`, `artboard.distribute` and `artboard.distributeSpacing` on the artboards the tool has selected.