Align: Align to Key Object names the Artboard tool when that blocks it

- 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.
This commit is contained in:
dotCooCoo
2026-11-18 01:40:34 -08:00
parent 54e4b6e1f0
commit cf3e47d513
32 changed files with 89 additions and 27 deletions
+2 -2
View File
@@ -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",
+1
View File
@@ -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 няма страници
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -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})
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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 δεν υπάρχουν σελίδες
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -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
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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 निर्यात करने के लिए कोई लेयरें नहीं
Can't render this file because it is too large.
+1
View File
@@ -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})
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it contains an unexpected character in line 2538 and column 5.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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 クリップグループを選択してください
Can't render this file because it is too large.
+1
View File
@@ -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 გვერდები არ არის
Can't render this file because it is too large.
+1
View File
@@ -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 클립 그룹을 선택하세요
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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 нет страниц
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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
Can't render this file because it is too large.
+1
View File
@@ -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 немає сторінок
Can't render this file because it is too large.
+1
View File
@@ -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})
Can't render this file because it is too large.
+1
View File
@@ -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 请选择一个剪切组
Can't render this file because it is too large.
+1
View File
@@ -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 請選取剪裁群組
Can't render this file because it is too large.
+2 -2
View File
@@ -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",
+29 -16
View File
@@ -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<Value> {
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<AlignTo> {
/// 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<Value, String> {
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());
}
+23 -3
View File
@@ -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]
+6 -4
View File
@@ -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.