mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 12:27:37 +00:00
Layers: with Show Layers Only on, Locate Object becomes Locate Layer
With Panel Options > Show Layers Only on, the panel lists no object
rows, so Locate Object highlighted a row that was not there. The panel
menu, the bottom bar's button and a row's menu now read Locate Layer in
that mode and send layer.locate with layersOnly: true, which highlights
the innermost layer or sublayer holding the object (a layer locates
itself) and returns {id, objectId, ancestry}. The panel opens the layers
around it and scrolls to it. With the option off nothing changes.
Help page: https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/locate-objects-in-the-layers-panel.html
Adds Locate Layer rows to the 28 catalogs that translate Locate Object.
This commit is contained in:
@@ -132,7 +132,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Locate Object",
|
||||
["Window", "Layers"],
|
||||
None,
|
||||
"{id?} (default: the last selected object) highlight the object's row; the Layers panel opens the layers around it and scrolls to it → {id, ancestry: [layer…, id]}",
|
||||
"{id?, layersOnly?} (default: the last selected object) highlight the object's row; the Layers panel opens the layers around it and scrolls to it → {id, ancestry: [layer…, id]}. layersOnly (default false; the panel sends true while Show Layers Only is on, as Locate Layer) highlights the innermost layer or sublayer holding the object instead, or a layer id itself → {id: layer, objectId, ancestry: [layer…]}",
|
||||
has_doc,
|
||||
locate
|
||||
),
|
||||
@@ -435,10 +435,18 @@ fn reverse(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
|
||||
fn locate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let id = object_param(p, "id", "layer.locate")?;
|
||||
let layers_only = switch_or(p, "layersOnly", false, "layer.locate")?;
|
||||
let st = s.doc_mut()?;
|
||||
let id = id.or_else(|| st.selection.objects.last().copied()).ok_or_else(|| bad("layer.locate", "nothing selected"))?;
|
||||
let ancestry = st.doc.ancestry(id).ok_or(EngineError::NoNode(id))?;
|
||||
st.layer_rows = vec![id];
|
||||
let mut ancestry = st.doc.ancestry(id).ok_or(EngineError::NoNode(id))?;
|
||||
if layers_only {
|
||||
// Locate Layer: the innermost layer or sublayer holding the object (a layer locates itself).
|
||||
let at = ancestry.iter().rposition(|a| st.doc.node(*a).is_some_and(Node::is_layer)).ok_or(EngineError::NoNode(id))?;
|
||||
ancestry.truncate(at + 1);
|
||||
}
|
||||
let row = ancestry.last().copied().ok_or(EngineError::NoNode(id))?;
|
||||
st.layer_rows = vec![row];
|
||||
st.revision += 1;
|
||||
Ok(json!({ "id": id.0, "ancestry": ancestry.iter().map(|i| i.0).collect::<Vec<_>>() }))
|
||||
let ancestry: Vec<u64> = ancestry.iter().map(|i| i.0).collect();
|
||||
Ok(if layers_only { json!({ "id": row.0, "objectId": id.0, "ancestry": ancestry }) } else { json!({ "id": id.0, "ancestry": ancestry }) })
|
||||
}
|
||||
|
||||
@@ -904,6 +904,31 @@ fn locate_object_highlights_its_row() {
|
||||
assert!(s.execute("layer.locate", &json!({})).is_err());
|
||||
}
|
||||
|
||||
/// Locate Layer (`layersOnly`, sent while Show Layers Only is on) highlights the innermost layer
|
||||
/// or sublayer holding the object, through any groups; a layer locates itself.
|
||||
#[test]
|
||||
fn locate_layer_highlights_the_layer_holding_the_object() {
|
||||
let mut s = session();
|
||||
let (layer, sub, _, g, b, c) = tree(&mut s);
|
||||
run(&mut s, "select.set", json!({"ids": [b.0]}));
|
||||
let r = run(&mut s, "layer.locate", json!({"layersOnly": true}));
|
||||
assert_eq!(r, json!({"id": sub.0, "objectId": b.0, "ancestry": [layer.0, sub.0]}), "the group's sublayer");
|
||||
assert_eq!(s.doc().unwrap().highlighted_rows(), vec![sub]);
|
||||
assert_eq!(run(&mut s, "layer.locate", json!({"id": c.0, "layersOnly": true}))["id"], layer.0, "art directly in a layer");
|
||||
assert_eq!(s.doc().unwrap().highlighted_rows(), vec![layer]);
|
||||
let r = run(&mut s, "layer.locate", json!({"id": sub.0, "layersOnly": true}));
|
||||
assert_eq!((r["id"].clone(), r["objectId"].clone()), (json!(sub.0), json!(sub.0)), "a sublayer locates itself");
|
||||
// Off, the object's own row is highlighted, as before.
|
||||
assert_eq!(run(&mut s, "layer.locate", json!({"id": g.0, "layersOnly": false})), json!({"id": g.0, "ancestry": [layer.0, sub.0, g.0]}));
|
||||
// Bad input changes nothing.
|
||||
for p in [json!({"id": b.0, "layersOnly": "yes"}), json!({"id": 999_999, "layersOnly": true})] {
|
||||
assert!(s.execute("layer.locate", &p).is_err(), "{p}");
|
||||
assert_eq!(s.doc().unwrap().highlighted_rows(), vec![g], "{p}");
|
||||
}
|
||||
run(&mut s, "select.none", json!({}));
|
||||
assert!(s.execute("layer.locate", &json!({"layersOnly": true})).is_err(), "nothing selected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_clipping_mask_button_acts_on_the_highlighted_group() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -1949,6 +1949,7 @@ font-technology Variable Променливи
|
||||
Load SVG into Clipboard Зареждане на SVG в клипборда
|
||||
Load Text into Clipboard Зареждане на текст в клипборда
|
||||
Local Libraries Локални библиотеки
|
||||
Locate Layer Намиране на слой
|
||||
Locate Object Намиране на обект
|
||||
Locate Selected Objects Намиране на избраните обекти
|
||||
Location Местоположение
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3711,6 +3711,7 @@ theme Appearance Izgled
|
||||
Select Art Odaberi crtež
|
||||
Set Current Layer Postavi trenutni sloj
|
||||
Flatten Artwork Spljošti crtež
|
||||
Locate Layer Pronađi sloj
|
||||
Locate Object Pronađi objekat
|
||||
Lock Others Zaključaj ostale
|
||||
Merge Selected Spoji odabrano
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2543,6 +2543,7 @@ digits Malayalam Malaiàlam
|
||||
Loads native code Carrega codi natiu
|
||||
Local Libraries Biblioteques locals
|
||||
Locate Library… Localitza la biblioteca…
|
||||
Locate Layer Localitza la capa
|
||||
Locate Object Localitza l’objecte
|
||||
Locate Selected Objects Localitza els objectes seleccionats
|
||||
Location Ubicació
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3813,6 +3813,7 @@ theme Appearance Motiv
|
||||
Select Art Vybrat kresbu
|
||||
Set Current Layer Nastavit aktuální vrstvu
|
||||
Flatten Artwork Sloučit kresbu
|
||||
Locate Layer Najít vrstvu
|
||||
Locate Object Najít objekt
|
||||
Lock Others Zamknout ostatní
|
||||
Merge Selected Sloučit vybrané
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6235,6 +6235,7 @@ theme Appearance Udseende
|
||||
Select Art Markér grafik
|
||||
Set Current Layer Angiv aktuelt lag
|
||||
Flatten Artwork Fladgør grafik
|
||||
Locate Layer Lokalisér lag
|
||||
Locate Object Lokalisér objekt
|
||||
Lock Others Lås andre
|
||||
Merge Selected Flet valgte
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2031,6 +2031,7 @@ file-filter Templates Vorlagen
|
||||
Load SVG into Clipboard SVG in die Zwischenablage laden
|
||||
Load Text into Clipboard Text in die Zwischenablage laden
|
||||
Local Libraries Lokale Bibliotheken
|
||||
Locate Layer Ebene ausfindig machen
|
||||
Locate Object Objekt ausfindig machen
|
||||
Locate Selected Objects Ausgewählte Objekte ausfindig machen
|
||||
Location Speicherort
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3110,6 +3110,7 @@ theme Appearance Εμφάνιση
|
||||
Load SVG into Clipboard Φόρτωση SVG στο πρόχειρο
|
||||
Load Text into Clipboard Φόρτωση κειμένου στο πρόχειρο
|
||||
Local Libraries Τοπικές βιβλιοθήκες
|
||||
Locate Layer Εντοπισμός επιπέδου
|
||||
Locate Object Εντοπισμός αντικειμένου
|
||||
Locate Selected Objects Εντοπισμός επιλεγμένων αντικειμένων
|
||||
Lock (⌘2) Κλείδωμα (⌘2)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2030,6 +2030,7 @@ font-technology Variable Variables
|
||||
Load SVG into Clipboard Cargar SVG en el portapapeles
|
||||
Load Text into Clipboard Cargar texto en el portapapeles
|
||||
Local Libraries Bibliotecas locales
|
||||
Locate Layer Localizar capa
|
||||
Locate Object Localizar objeto
|
||||
Locate Selected Objects Localizar objetos seleccionados
|
||||
Location Ubicación
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3751,6 +3751,7 @@ theme Appearance Ulkoasu
|
||||
Select Art Valitse kuvitus
|
||||
Set Current Layer Aseta nykyinen taso
|
||||
Flatten Artwork Litistä kuvitus
|
||||
Locate Layer Paikanna taso
|
||||
Locate Object Paikanna objekti
|
||||
Lock Others Lukitse muut
|
||||
Merge Selected Yhdistä valitut
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2020,6 +2020,7 @@ font-technology Variable Variables
|
||||
Load SVG into Clipboard Charger un SVG dans le presse-papiers
|
||||
Load Text into Clipboard Charger du texte dans le presse-papiers
|
||||
Local Libraries Bibliothèques locales
|
||||
Locate Layer Localiser le calque
|
||||
Locate Object Localiser l’objet
|
||||
Locate Selected Objects Localiser les objets sélectionnés
|
||||
Location Emplacement
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2093,6 +2093,7 @@
|
||||
Loads native code નેટિવ કોડ લોડ કરે છે
|
||||
Local Libraries સ્થાનિક લાઇબ્રેરીઓ
|
||||
Locate Library… લાઇબ્રેરી શોધો…
|
||||
Locate Layer લેયર શોધો
|
||||
Locate Object ઑબ્જેક્ટ શોધો
|
||||
Locate Selected Objects પસંદ કરેલા ઑબ્જેક્ટ શોધો
|
||||
Location સ્થાન
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -2787,6 +2787,7 @@ antiAlias Sharp शार्प
|
||||
Loads native code मूल कोड लोड करता है
|
||||
Local Libraries स्थानीय लाइब्रेरी
|
||||
Locate Library… लाइब्रेरी…
|
||||
Locate Layer लेयर का पता लगाएं
|
||||
Locate Object ऑब्जेक्ट का पता लगाएं
|
||||
Locate Selected Objects सिलेक्टेड ऑब्जेक्ट्स का पता लगाएँ
|
||||
Location स्थान
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2531,6 +2531,7 @@ file-filter Templates Sablonok
|
||||
Load Texture… Textúra betöltése…
|
||||
Loaded Texture Betöltött textúra
|
||||
Local Libraries Helyi könyvtárak
|
||||
Locate Layer Réteg megkeresése
|
||||
Locate Object Objektum megkeresése
|
||||
Locate Selected Objects Kijelölt objektumok megkeresése
|
||||
Location Hely
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3487,6 +3487,7 @@ theme Appearance Tampilan
|
||||
Select Art Pilih karya seni
|
||||
Set Current Layer Tetapkan lapisan saat ini
|
||||
Flatten Artwork Ratakan karya seni
|
||||
Locate Layer Temukan lapisan
|
||||
Locate Object Temukan objek
|
||||
Lock Others Kunci lainnya
|
||||
Merge Selected Gabungkan terpilih
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2511 and column 5.
|
@@ -2068,6 +2068,7 @@ file-filter Templates Modelli
|
||||
Load SVG into Clipboard Carica SVG negli appunti
|
||||
Load Text into Clipboard Carica testo negli appunti
|
||||
Local Libraries Librerie locali
|
||||
Locate Layer Individua livello
|
||||
Locate Object Individua oggetto
|
||||
Locate Selected Objects Individua oggetti selezionati
|
||||
Location Posizione
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2333,6 +2333,7 @@ antiAlias Sharp シャープ
|
||||
Load SVG into Clipboard SVG をクリップボードに読み込む
|
||||
Load Text into Clipboard テキストをクリップボードに読み込む
|
||||
Local Libraries ローカルライブラリ
|
||||
Locate Layer レイヤーを検索
|
||||
Locate Object オブジェクトを検索
|
||||
Locate Selected Objects 選択したオブジェクトを検索
|
||||
Location 場所
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5580,6 +5580,7 @@ theme Appearance იერსახე
|
||||
Select Art ნახატის მონიშვნა
|
||||
Set Current Layer მიმდინარე შრედ დაყენება
|
||||
Flatten Artwork ნახატის გაბრტყელება
|
||||
Locate Layer შრის მოძებნა
|
||||
Locate Object ობიექტის მოძებნა
|
||||
Lock Others დანარჩენების ჩაკეტვა
|
||||
Merge Selected მონიშნულების შერწყმა
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2323,6 +2323,7 @@ antiAlias Sharp 날카롭게
|
||||
Load SVG into Clipboard SVG를 클립보드로 불러오기
|
||||
Load Text into Clipboard 텍스트를 클립보드로 불러오기
|
||||
Local Libraries 로컬 라이브러리
|
||||
Locate Layer 레이어 찾기
|
||||
Locate Object 개체 찾기
|
||||
Locate Selected Objects 선택한 개체 찾기
|
||||
Location 위치
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4109,6 +4109,7 @@ theme Appearance Vormgeving
|
||||
Select Art Kunst selecteren
|
||||
Set Current Layer Huidige laag instellen
|
||||
Flatten Artwork Kunst afvlakken
|
||||
Locate Layer Laag lokaliseren
|
||||
Locate Object Object lokaliseren
|
||||
Lock Others Overigen vergrendelen
|
||||
Merge Selected Selectie samenvoegen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3692,6 +3692,7 @@ theme Appearance Wygląd
|
||||
Select Art Zaznacz kompozycję
|
||||
Set Current Layer Ustaw bieżącą warstwę
|
||||
Flatten Artwork Spłaszcz kompozycję
|
||||
Locate Layer Znajdź warstwę
|
||||
Locate Object Znajdź obiekt
|
||||
Lock Others Zablokuj pozostałe
|
||||
Merge Selected Scal zaznaczone
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1712,6 +1712,7 @@ antiAlias Sharp Nítido
|
||||
Load SVG into Clipboard Carregar SVG na Área de Transferência
|
||||
Load Text into Clipboard Carregar Texto na Área de Transferência
|
||||
Local Libraries Bibliotecas Locais
|
||||
Locate Layer Localizar Camada
|
||||
Locate Object Localizar Objeto
|
||||
Location Local
|
||||
Location: Local:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2057,6 +2057,7 @@ file-filter Templates Шаблоны
|
||||
Load SVG into Clipboard Загрузить SVG в буфер обмена
|
||||
Load Text into Clipboard Загрузить текст в буфер обмена
|
||||
Local Libraries Локальные библиотеки
|
||||
Locate Layer Найти слой
|
||||
Locate Object Найти объект
|
||||
Locate Selected Objects Находить выделенные объекты
|
||||
Location Расположение
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1965,6 +1965,7 @@ font-technology Variable Variabla
|
||||
Load SVG into Clipboard Läs in SVG till urklipp
|
||||
Load Text into Clipboard Läs in text till urklipp
|
||||
Local Libraries Lokala bibliotek
|
||||
Locate Layer Hitta lager
|
||||
Locate Object Hitta objekt
|
||||
Locate Selected Objects Hitta markerade objekt
|
||||
Location Plats
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1851,6 +1851,7 @@ font-technology Variable Değişken
|
||||
Load SVG into Clipboard SVG'yi Panoya yükleyin
|
||||
Load Text into Clipboard Metni Panoya Yükle
|
||||
Local Libraries Yerel Kütüphaneler
|
||||
Locate Layer Katmanı Bul
|
||||
Locate Object Nesneyi Bul
|
||||
Location Konum
|
||||
Location: Konum:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2062,6 +2062,7 @@ file-filter Templates Шаблони
|
||||
Load SVG into Clipboard Завантажити SVG у буфер обміну
|
||||
Load Text into Clipboard Завантажити текст у буфер обміну
|
||||
Local Libraries Локальні бібліотеки
|
||||
Locate Layer Знайти шар
|
||||
Locate Object Знайти об’єкт
|
||||
Locate Selected Objects Знаходити виділені об’єкти
|
||||
Location Розташування
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2367,6 +2367,7 @@ digits Hindi Hindi
|
||||
Load Texture… Tải kết cấu…
|
||||
Loaded Texture Kết cấu đã tải
|
||||
Local Libraries Thư viện cục bộ
|
||||
Locate Layer Xác định vị trí lớp
|
||||
Locate Object Xác định vị trí đối tượng
|
||||
Locate Selected Objects Xác định vị trí đối tượng đã chọn
|
||||
Location Vị trí
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 205 and column 5.
|
@@ -1939,6 +1939,7 @@ file-filter Templates 模板
|
||||
Load SVG into Clipboard 将 SVG 载入剪贴板
|
||||
Load Text into Clipboard 将文本载入剪贴板
|
||||
Local Libraries 本地库
|
||||
Locate Layer 查找图层
|
||||
Locate Object 查找对象
|
||||
Locate Selected Objects 查找所选对象
|
||||
Location 位置
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3184,6 +3184,7 @@ liquify-list-end {0}, {1} {0}和{1}
|
||||
Load SVG into Clipboard 將 SVG 載入剪貼簿
|
||||
Load Text into Clipboard 將文字載入剪貼簿
|
||||
Local Libraries 本機資料庫
|
||||
Locate Layer 尋找圖層
|
||||
Locate Object 尋找物件
|
||||
Locate Selected Objects 尋找選取的物件
|
||||
Location 位置
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -116,8 +116,11 @@ pub(super) fn bottom_bar(app: &mut VectorcraftApp, ui: &mut Ui, view: &View, doc
|
||||
if widgets::icon_button(&mut child, "frame", tl!("Make/Release Clipping Mask"), false, 24.0).clicked() {
|
||||
actions.push(("layer.clippingMask.toggle".into(), json!({})));
|
||||
}
|
||||
if widgets::icon_button(&mut child, "search", tl!("Locate Object"), false, 24.0).clicked() {
|
||||
actions.push(("layer.locate".into(), json!({})));
|
||||
// With Show Layers Only on, Locate Object becomes Locate Layer: it highlights the layer row.
|
||||
let layers_only = view.opts.layers_only;
|
||||
let locate = if layers_only { tl!("Locate Layer") } else { tl!("Locate Object") };
|
||||
if widgets::icon_button(&mut child, "search", locate, false, 24.0).clicked() {
|
||||
actions.push(("layer.locate".into(), json!({ "layersOnly": layers_only })));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +135,7 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let current = st.current_layer();
|
||||
let has_sel = !st.selection.is_empty();
|
||||
let isolated = st.isolation.is_some();
|
||||
let layers_only = app.ui.layers_panel.layers_only;
|
||||
let targets: Vec<NodeId> = if rows.is_empty() { current.into_iter().collect() } else { rows.clone() };
|
||||
let one_container = match targets.as_slice() {
|
||||
[id] => doc.node(*id).is_some_and(|n| matches!(n.kind, NodeKind::Layer { .. } | NodeKind::Group { .. })),
|
||||
@@ -166,7 +170,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
items.extend([
|
||||
None,
|
||||
Some(("Locate Object", "layer.locate", json!({}), has_sel, false)),
|
||||
Some(if layers_only {
|
||||
("Locate Layer", "layer.locate", json!({"layersOnly": true}), has_sel, false)
|
||||
} else {
|
||||
("Locate Object", "layer.locate", json!({}), has_sel, false)
|
||||
}),
|
||||
// Sentinel: rendered as the Save Selection submenu (the Select menu's saved-selection items).
|
||||
Some(("Save Selection", "", json!({}), true, false)),
|
||||
None,
|
||||
|
||||
@@ -510,9 +510,10 @@ fn row_context_menu(ui: &mut Ui, view: &View, n: &Node, collect_ids: &[u64], out
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
// Locate Object
|
||||
if widgets::menu_item(ui, "Locate Object", true, false) {
|
||||
out.actions.push(("layer.locate".into(), json!({ "id": n.id.0 })));
|
||||
// Locate Object, or Locate Layer with Show Layers Only on
|
||||
let layers_only = view.opts.layers_only;
|
||||
if widgets::menu_item(ui, if layers_only { "Locate Layer" } else { "Locate Object" }, true, false) {
|
||||
out.actions.push(("layer.locate".into(), json!({ "id": n.id.0, "layersOnly": layers_only })));
|
||||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
|
||||
@@ -2133,6 +2133,50 @@ fn the_panel_menu_lists_every_operation() {
|
||||
}
|
||||
}
|
||||
|
||||
/// With Show Layers Only on, Locate Object becomes Locate Layer in the panel menu and a row's
|
||||
/// menu, and the bottom bar's Locate button highlights the sublayer holding the selected art,
|
||||
/// opening the layer around it. Off, the button highlights the art's own row.
|
||||
#[test]
|
||||
fn with_show_layers_only_locate_object_becomes_locate_layer() {
|
||||
let (mut app, [layer, sub, _, b, _, _]) = nested();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let shown = |app: &mut VectorcraftApp, events: Vec<egui::Event>, f: fn(&mut VectorcraftApp, &mut egui::Ui)| {
|
||||
super::super::tests_appearance::frame_events(&ctx, app, events, f).into_iter().map(|(t, _)| t.trim().to_string()).collect::<Vec<_>>()
|
||||
};
|
||||
let has = |texts: &[String], s: &str| texts.iter().any(|t| t == s);
|
||||
app.session.execute("select.set", &json!({"ids": [b.0]})).unwrap();
|
||||
let off = shown(&mut app, vec![], menu);
|
||||
assert!(has(&off, "Locate Object") && !has(&off, "Locate Layer"), "{off:?}");
|
||||
let locate = |app: &mut VectorcraftApp| {
|
||||
let at = bar_buttons(app, &ctx)[4];
|
||||
click_with(app, &ctx, at, egui::Modifiers::NONE);
|
||||
};
|
||||
locate(&mut app);
|
||||
assert_eq!(rows_of(&app), vec![b], "off: the art's own row");
|
||||
|
||||
app.ui.layers_panel.layers_only = true;
|
||||
let on = shown(&mut app, vec![], menu);
|
||||
assert!(has(&on, "Locate Layer") && !has(&on, "Locate Object"), "{on:?}");
|
||||
app.session.active_mut().unwrap().layers_open.set(layer, false);
|
||||
shown(&mut app, vec![], show);
|
||||
locate(&mut app);
|
||||
assert_eq!(rows_of(&app), vec![sub], "on: the sublayer holding the art");
|
||||
shown(&mut app, vec![], show);
|
||||
assert!(app.session.active().unwrap().layers_open.contains(layer), "the layer around the sublayer opens");
|
||||
assert!(has(&shown(&mut app, vec![], show), "Sub"), "the sublayer's row shows");
|
||||
|
||||
// A row's menu says Locate Layer too.
|
||||
let c = frame(&mut app, &ctx, vec![], false).0;
|
||||
let at = egui::pos2(150.0, c[0].y);
|
||||
let right = egui::PointerButton::Secondary;
|
||||
for e in [egui::Event::PointerMoved(at), button_by(at, true, right), button_by(at, false, right)] {
|
||||
frame(&mut app, &ctx, vec![e], false);
|
||||
}
|
||||
let row_menu = shown(&mut app, vec![], show);
|
||||
assert!(has(&row_menu, "Locate Layer") && !has(&row_menu, "Locate Object"), "{row_menu:?}");
|
||||
}
|
||||
|
||||
/// ≡ › Save Selection lists the saved selections: choosing one recalls it, Update Selection
|
||||
/// makes it hold the selected objects, and Save Selection… opens the name dialog.
|
||||
#[test]
|
||||
|
||||
+3
-1
@@ -5413,7 +5413,9 @@ and `layerRows`, the rows highlighted in the panel.
|
||||
locked or nested art included, dialog `confirm` asks "Delete this layer and its artwork?" for one layer, else "Delete
|
||||
the selected items and their artwork?"; OK deletes the rows it asked about in that document, one undo step, and
|
||||
Cancel keeps them; an empty layer, a layer with only guides, and groups or objects alone are deleted at once),
|
||||
`layer.locate {id?}` (highlights the selected object's row; the panel opens the rows around it)
|
||||
`layer.locate {id?, layersOnly?}` (highlights the selected object's row; the panel opens the rows around it;
|
||||
`layersOnly: true`, which the panel sends while Show Layers Only is on, as Locate Layer, highlights the innermost
|
||||
layer or sublayer holding the object instead, or a layer `id` itself, and returns `{id, objectId, ancestry}`)
|
||||
and `layer.clippingMask.toggle`.
|
||||
- **Panel menu**: `layer.duplicate {ids?}`, `layer.merge {ids?}` (into the layer highlighted last, keeping the
|
||||
stacking order), `layer.flatten {id?}` (every other visible layer's art into one layer; hidden layers are deleted,
|
||||
|
||||
@@ -1386,6 +1386,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Layer Options for several highlighted rows shows the first row's settings, and OK changes only the settings set in the dialog: each row keeps its own color, Template, Lock, Show, Print, Preview and Dim Images otherwise (`crates/ui-egui/src/dialogs/layer_options.rs` tests).
|
||||
As VectorCraft's own rule, a layer color (`layer.setProps`, `layer.new`, `layer.newSublayer`) or a Live Paint Gap Preview Color (`livePaint.gapOptions`) given as a hex color with an alpha part (`#rrggbbaa` or `#rgba`) is an error and changes nothing, instead of being set without its alpha. Regression tests: `a_layer_color_with_an_alpha_part_is_refused` in `crates/engine/src/tests/layers.rs` and `a_gap_color_with_an_alpha_part_is_refused` in `crates/engine/src/tests/build.rs`.
|
||||
Panel Options › Locate Selected Objects (beyond Illustrator, off by default): when the last selected object changes on the canvas or by a command, the panel opens the layers and groups around it and scrolls to its row, as Locate Object does, without highlighting the row; when Show Layers Only, a search or the filter leaves the object without a row, the panel opens no rows for it and scrolls as with the option off.
|
||||
With Panel Options › Show Layers Only on, Locate Object is named Locate Layer and highlights the layer that holds the selected object instead of the object's own row, which that mode does not list (help page: https://helpx.adobe.com/illustrator/desktop/manage-layers/create-and-organize-layers/locate-objects-in-the-layers-panel.html). As VectorCraft's own rules, the bottom bar's button and a row's menu are renamed too, the innermost sublayer holding the object is the one highlighted, a layer row locates itself, and the panel opens the layers around it (`locate_layer_highlights_the_layer_holding_the_object` in `crates/engine/src/tests/layers.rs`, `with_show_layers_only_locate_object_becomes_locate_layer` in `crates/ui-egui/src/panels/layers/tests.rs`).
|
||||
- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't, except the anchor the Selection tool grabbed it by). A selection the Selection tool grabs by one of its anchors snaps that anchor onto the other objects' paths ("path"), and where a path crosses another path or a ruler guide ("intersect"), in the order Direct Selection uses for a dragged anchor; when the anchor lands on a path, the selection's bounds do not also line up with other objects (#7411). The archived 2007 [user guide](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=55) (page 49) says Smart Guides align the pointer of a moved object to existing paths. Snapping onto paths only when the selection was grabbed by an anchor is VectorCraft's own rule; a selection grabbed anywhere else still lines its bounds up. Tests: `select::tests::a_move_grabbed_by_an_anchor_lands_it_on_another_path`, `a_move_grabbed_by_an_anchor_lands_it_where_paths_cross` and `a_move_grabbed_by_an_anchor_lands_it_where_a_path_crosses_a_ruler_guide`. With Smart Guides › Measurement Labels on, the Line Segment tool labels the segment being drawn with its distance, angle and X and Y offsets (`D`, `Angle`, `dX`, `dY`), and the Pen, Curvature and Smart Pen tools label their rubber band the same way when Enable Rubber Band is on (#2983).
|
||||
A move that Shift keeps level, upright or diagonal stays on that line when it snaps, with the Selection, Group Selection or Direct Selection tool. It slides along the line until the selection lands on the grid or on whole pixels, lines up with the other objects or is spaced evenly with them, or until the line passes an anchor or crosses a ruler guide near the point the selection was grabbed by. A level or upright move snaps along its own axis only.
|
||||
Snap to Last Location: with Smart Guides on and Preferences › Smart Guides › Snap to Last Location on (off by default, VectorCraft's own choice), a selection moved by dragging with the Selection, Group Selection or Direct Selection tool, Shift too, goes back to where the move began while it is within Snapping Tolerance of it, labeled "last location"; an Alt copy is not pulled back onto its original, and with View › Snap to Grid or Snap to Pixel on the move snaps to the grid or to whole pixels instead (`prefs.set` key `snapToLastLocation`). The public [Smart Guides options](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html) page lists the option as snapping objects back to their previous position; the distance, the label, the copy rule and the grid and pixel rule are VectorCraft's own. Tests: `select::tests::snap_to_last_location_puts_a_move_back_where_it_began`, `select::tests::snap_to_pixel_wins_over_snap_to_last_location`, `direct::tests::snap_to_last_location_puts_a_path_moved_by_its_anchor_back`, `direct::tests::snap_to_pixel_wins_over_snap_to_last_location_for_a_path_moved_by_its_anchor`, `tests_prefs::snap_to_last_location_puts_a_dragged_square_back`.
|
||||
|
||||
Reference in New Issue
Block a user