Fix File Info field semantics and add layer-under-cursor selection

Co-authored-by: Codex <[email protected]>
This commit is contained in:
channelrambleandCodex authored and skylar taylor-barrick committed 2026-10-15 19:37:04 -06:00
1 parent 25993c06c6
commit c17761d032
26 files changed
+211 -4

No files matched your search

+1
View File
@@ -7,6 +7,7 @@
/// Shell commands: id, label, menu path, default shortcut.
pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[
("layer.selectUnderCursor", "Select Layer Under Cursor", &[], None),
("ui.symmetryTransform", "Transform Symmetry", &[], None),
// Right-click the options bar's tool icon (#2825); `tool.resetAll` asks first.
("tool.reset", "Reset Tool", &[], None),
+5 -1
View File
@@ -1015,7 +1015,11 @@ mod tests {
let ctx = h.ctx.clone();
crate::menus::invoke(h.state_mut(), &ctx, "file.fileInfo", json!({})).unwrap();
h.run_steps(4);
for (label, key) in [("Description", "description"), ("Keywords", "keywords"), ("Copyright", "copyright")] {
let labels = ["Document Title", "Author", "Author title", "Description", "Keywords", "Copyright status", "Copyright Notice", "Copyright Info URL"];
for pair in labels.windows(2) {
assert!(h.get_by_label(pair[0]).rect().center().y < h.get_by_label(pair[1]).rect().center().y, "field order: {pair:?}");
}
for (label, key) in [("Description", "description"), ("Keywords", "keywords"), ("Copyright Notice", "copyright")] {
h.get_by_label(label).click();
h.run_steps(1);
h.event(egui::Event::Text("First".into()));
+6
View File
@@ -3808,3 +3808,9 @@ navigator Zoom Zvětšení
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Volná transformace se stále použije; zkuste to znovu, až skončí.
The transform couldn't be applied. Transformaci nelze použít.
# File Info metadata labels
Document Title Název dokumentu
Copyright Notice Oznámení o autorských právech
Copyright Info URL URL informací o autorských právech
Select Layer Under Cursor Vybrat vrstvu pod kurzorem
Can't render this file because it contains an unexpected character in line 6 and column 47.
+6
View File
@@ -3202,3 +3202,9 @@ curves Smooth Glätten
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Frei transformieren wird noch angewendet; versuchen Sie es erneut, wenn es fertig ist.
The transform couldn't be applied. Die Transformation konnte nicht angewendet werden.
# File Info metadata labels
Document Title Dokumenttitel
Copyright Notice Urheberrechtsvermerk
Copyright Info URL URL der Urheberrechtsinformationen
Select Layer Under Cursor Ebene unter dem Cursor auswählen
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -3900,3 +3900,8 @@ curves Smooth Εξομάλυνση
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Ο Ελεύθερος μετασχηματισμός εφαρμόζεται ακόμη· δοκιμάστε ξανά όταν ολοκληρωθεί.
The transform couldn't be applied. Δεν ήταν δυνατή η εφαρμογή του μετασχηματισμού.
# File Info metadata labels
Document Title Τίτλος εγγράφου
Copyright Notice Σημείωση πνευματικών δικαιωμάτων
Select Layer Under Cursor Επιλογή επιπέδου κάτω από τον δρομέα
Can't render this file because it contains an unexpected character in line 1030 and column 18.
+5
View File
@@ -4162,3 +4162,8 @@ navigator Zoom Zoom
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Transformación libre aún se está aplicando; inténtelo de nuevo cuando termine.
The transform couldn't be applied. No se pudo aplicar la transformación.
# File Info metadata labels
Document Title Título del documento
Copyright Notice Aviso de copyright
Select Layer Under Cursor Seleccionar capa bajo el cursor
Can't render this file because it contains an unexpected character in line 4 and column 47.
+5
View File
@@ -3205,3 +3205,8 @@ curves Smooth Lisser
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. La transformation manuelle est encore en cours d'application ; réessayez quand elle sera terminée.
The transform couldn't be applied. Impossible d'appliquer la transformation.
# File Info metadata labels
Document Title Titre du document
Copyright Notice Mention de copyright
Select Layer Under Cursor Sélectionner le calque sous le curseur
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -4119,3 +4119,8 @@ cameraRaw Yellow Sárga
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. A szabad alakítás alkalmazása még folyamatban van; próbáld újra, ha befejeződött.
The transform couldn't be applied. Az átalakítás nem alkalmazható.
# File Info metadata labels
Document Title Dokumentum címe
Copyright Notice Szerzői jogi közlemény
Select Layer Under Cursor Kurzor alatti réteg kijelölése
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -3192,3 +3192,8 @@ curves Smooth Haluskan
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Transformasi Bebas masih diterapkan; coba lagi setelah selesai.
The transform couldn't be applied. Transformasi tidak dapat diterapkan.
# File Info metadata labels
Document Title Judul Dokumen
Copyright Notice Pemberitahuan Hak Cipta
Select Layer Under Cursor Pilih Lapisan di Bawah Kursor
Can't render this file because it contains an unexpected character in line 4 and column 47.
+5
View File
@@ -4321,3 +4321,8 @@ shape Appearance Aspetto
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Trasformazione libera è ancora in corso di applicazione; riprova quando è terminata.
The transform couldn't be applied. Impossibile applicare la trasformazione.
# File Info metadata labels
Document Title Titolo del documento
Copyright Notice Avviso di copyright
Select Layer Under Cursor Seleziona livello sotto il cursore
Can't render this file because it contains an unexpected character in line 2654 and column 53.
+5
View File
@@ -3876,3 +3876,8 @@ curves Smooth スムーズ
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 自由変形を適用中です。完了してからもう一度お試しください。
The transform couldn't be applied. 変形を適用できませんでした。
# File Info metadata labels
Document Title ドキュメントのタイトル
Copyright Notice 著作権表示
Select Layer Under Cursor カーソル下のレイヤーを選択
Can't render this file because it contains an unexpected character in line 6 and column 47.
+6
View File
@@ -3378,3 +3378,9 @@ curves Smooth 매끄럽게
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 자유 변형을 아직 적용하는 중입니다. 완료된 후 다시 시도하세요.
The transform couldn't be applied. 변형을 적용할 수 없습니다.
# File Info metadata labels
Document Title 문서 제목
Copyright Notice 저작권 고지
Copyright Info URL 저작권 정보 URL
Select Layer Under Cursor 커서 아래 레이어 선택
Can't render this file because it contains an unexpected character in line 3166 and column 53.
+5
View File
@@ -3960,3 +3960,8 @@ curves Smooth Vloeiend maken
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Vrije transformatie wordt nog toegepast; probeer het opnieuw als die klaar is.
The transform couldn't be applied. De transformatie kon niet worden toegepast.
# File Info metadata labels
Document Title Documenttitel
Copyright Notice Copyrightvermelding
Select Layer Under Cursor Laag onder cursor selecteren
Can't render this file because it contains an unexpected character in line 8 and column 34.
+5
View File
@@ -3798,3 +3798,8 @@ curves Smooth Wygładź
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Przekształcanie swobodne jest nadal stosowane; spróbuj ponownie, gdy się zakończy.
The transform couldn't be applied. Nie można zastosować przekształcenia.
# File Info metadata labels
Document Title Tytuł dokumentu
Copyright Notice Informacja o prawach autorskich
Select Layer Under Cursor Zaznacz warstwę pod kursorem
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -3990,3 +3990,8 @@ layerLabel No Color Sem cor
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. A Transformação livre ainda está sendo aplicada; tente novamente quando terminar.
The transform couldn't be applied. Não foi possível aplicar a transformação.
# File Info metadata labels
Document Title Título do documento
Copyright Notice Aviso de direitos autorais
Select Layer Under Cursor Selecionar camada sob o cursor
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -3170,3 +3170,8 @@ curves Smooth Сгладить
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Свободное трансформирование ещё применяется; повторите попытку, когда оно завершится.
The transform couldn't be applied. Не удалось применить трансформирование.
# File Info metadata labels
Document Title Название документа
Copyright Notice Уведомление об авторских правах
Select Layer Under Cursor Выбрать слой под курсором
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -4273,3 +4273,8 @@ shape Appearance Izgled
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Slobodna transformacija se još primenjuje; pokušajte ponovo kad se završi.
The transform couldn't be applied. Transformacija nije mogla da se primeni.
# File Info metadata labels
Document Title Naslov dokumenta
Copyright Notice Obaveštenje o autorskim pravima
Select Layer Under Cursor Izaberi sloj ispod kursora
Can't render this file because it contains an unexpected character in line 6 and column 47.
+5
View File
@@ -3930,3 +3930,8 @@ cameraData Lens Lens
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Serbest Dönüştürme hâlâ uygulanıyor; bittiğinde yeniden deneyin.
The transform couldn't be applied. Dönüştürme uygulanamadı.
# File Info metadata labels
Document Title Belge Başlığı
Copyright Notice Telif Hakkı Bildirimi
Select Layer Under Cursor İmlecin Altındaki Katmanı Seç
Can't render this file because it contains an unexpected character in line 8 and column 34.
+5
View File
@@ -3899,3 +3899,8 @@ curves Smooth Згладити
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Вільне трансформування ще застосовується; спробуйте знову, коли воно завершиться.
The transform couldn't be applied. Не вдалося застосувати трансформування.
# File Info metadata labels
Document Title Назва документа
Copyright Notice Повідомлення про авторські права
Select Layer Under Cursor Вибрати шар під курсором
Can't render this file because it contains an unexpected character in line 1388 and column 18.
+6
View File
@@ -3686,3 +3686,9 @@ curves Smooth Làm mượt
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. Biến đổi tự do vẫn đang được áp dụng; hãy thử lại khi hoàn tất.
The transform couldn't be applied. Không thể áp dụng phép biến đổi.
# File Info metadata labels
Document Title Tiêu đề tài liệu
Copyright Notice Thông báo bản quyền
Copyright Info URL URL thông tin bản quyền
Select Layer Under Cursor Chọn lớp dưới con trỏ
Can't render this file because it contains an unexpected character in line 6 and column 47.
+6
View File
@@ -2816,3 +2816,9 @@ curves Smooth 平滑
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 自由变换仍在应用中;请在完成后重试。
The transform couldn't be applied. 无法应用变换。
# File Info metadata labels
Document Title 文档标题
Copyright Notice 版权声明
Copyright Info URL 版权信息网址
Select Layer Under Cursor 选择光标下的图层
Can't render this file because it contains an unexpected character in line 2600 and column 53.
+6
View File
@@ -2801,3 +2801,9 @@ curves Smooth 平滑
# Free Transform: a new layer while the box is open (#5859)
Free Transform is still being applied; try again when it has finished. 任意變形仍在套用中;請在完成後再試一次。
The transform couldn't be applied. 無法套用變形。
# File Info metadata labels
Document Title 文件標題
Copyright Notice 著作權聲明
Copyright Info URL 著作權資訊網址
Select Layer Under Cursor 選取游標下的圖層
Can't render this file because it contains an unexpected character in line 6 and column 47.
+48
View File
@@ -1116,3 +1116,51 @@ fn move_tool_controls_rotate_from_just_outside_the_box() {
let tilt = (end[1][1] - end[0][1]).atan2(end[1][0] - end[0][0]).to_degrees();
assert!((tilt - 90.0).abs() < 8.0 || (tilt + 270.0).abs() < 8.0, "rotated about a quarter turn, got {tilt}° (zoom {zoom})");
}
#[test]
fn assignable_pick_layer_shortcut_follows_transformed_canvas_without_editing() {
let mut h = harness();
let base = h.state().session.active().unwrap().active_layer.unwrap();
h.state_mut().run("layer.new.layer", json!({"name": "Paint"})).unwrap();
let paint = h.state().session.active().unwrap().active_layer.unwrap();
h.state_mut().run("select.rect", json!({"x": 100, "y": 100, "width": 40, "height": 40})).unwrap();
h.state_mut().run("edit.fill", json!({"color": "#ff0000"})).unwrap();
h.state_mut().run("select.deselect", json!({})).unwrap();
h.state_mut().run("layer.new.layer", json!({"name": "Empty"})).unwrap();
h.state_mut().run("prefs.set", json!({"path": "shortcuts.layer.selectUnderCursor", "value": "Cmd+Alt+K"})).unwrap();
h.state_mut().ui.tool = crate::state::Tool::Brush;
for (zoom, rotation, flip) in [(1.0, 0.0, false), (2.0, 37.0, true), (0.5, -90.0, false)] {
h.state_mut().ui.views[0].zoom = zoom;
h.state_mut().ui.views[0].rotation = rotation;
h.state_mut().ui.views[0].center = [180.0, 145.0];
h.state_mut().ui.view.flip_horizontal = flip;
h.run_steps(2);
for (point, expected) in [([120.0, 120.0], paint), ([155.0, 155.0], base)] {
let pos = crate::canvas::ViewXform::active(h.state()).unwrap().to_screen(point[0], point[1]);
let history = h.state().session.active().unwrap().history.past_len();
h.hover_at(pos);
h.key_press_modifiers(Modifiers::COMMAND | Modifiers::ALT, Key::K);
h.run_steps(2);
assert_eq!(h.state().session.active().unwrap().active_layer, Some(expected));
assert_eq!(h.state().session.active().unwrap().history.past_len(), history, "picking never adds a document edit");
assert!(!h.state().session.journal.iter().any(|(id, _)| id == "paint.stroke"));
}
}
h.state_mut().run("layer.setProps", json!({"layer": paint.0, "visible": false})).unwrap();
let p = crate::canvas::ViewXform::active(h.state()).unwrap().to_screen(120.0, 120.0);
h.hover_at(p);
h.key_press_modifiers(Modifiers::COMMAND | Modifiers::ALT, Key::K);
h.run_steps(2);
assert_eq!(h.state().session.active().unwrap().active_layer, Some(base));
// Outside the document and modal dialogs preserve the current selection.
h.state_mut().run("layer.select", json!({"layer": paint.0})).unwrap();
h.hover_at(pos2(0.0, 0.0));
h.key_press_modifiers(Modifiers::COMMAND | Modifiers::ALT, Key::K);
h.run_steps(2);
assert_eq!(h.state().session.active().unwrap().active_layer, Some(paint));
open_dialog(&mut h);
h.hover_at(p);
h.key_press_modifiers(Modifiers::COMMAND | Modifiers::ALT, Key::K);
h.run_steps(2);
assert_eq!(h.state().session.active().unwrap().active_layer, Some(paint));
}
+26
View File
@@ -253,6 +253,7 @@ pub(crate) fn invoke_unguarded(app: &mut PhotocraftApp, ctx: &egui::Context, id:
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
Ok(Value::Null)
}
"layer.selectUnderCursor" => select_layer_under_cursor(app, ctx),
"file.clearRecent" => {
app.clear_recent();
Ok(Value::Null)
@@ -640,6 +641,9 @@ fn open_path(app: &mut PhotocraftApp, path: &str) -> Result<Value, String> {
}
pub fn is_enabled(app: &PhotocraftApp, id: &str) -> bool {
if id == "layer.selectUnderCursor" {
return app.session.active().is_some() && app.drag.is_none() && app.brush_resize.is_none();
}
if crate::tool_shortcuts::tool(id).is_some() {
return true;
}
@@ -2235,3 +2239,25 @@ mod window_documents_tests {
assert_eq!(app.session.active_index(), Some(0));
}
}
/// Pointer-dependent shell command; pixel picking and selection remain engine commands.
fn select_layer_under_cursor(app: &mut PhotocraftApp, ctx: &egui::Context) -> Result<Value, String> {
if app.drag.is_some() || app.brush_resize.is_some() {
return Ok(json!({"layer": null}));
}
let Some(xf) = crate::canvas::ViewXform::active(app) else { return Ok(json!({"layer": null})) };
let Some(pointer) = ctx.pointer_hover_pos().filter(|p| xf.rect.contains(*p)) else { return Ok(json!({"layer": null})) };
let [x, y] = xf.to_doc(pointer);
let inside = app
.session
.active()
.is_some_and(|st| x.is_finite() && y.is_finite() && x >= 0.0 && y >= 0.0 && x < f64::from(st.doc.size.width) && y < f64::from(st.doc.size.height));
if !inside {
return Ok(json!({"layer": null}));
}
let picked = app.run("layer.pickAt", json!({"x": x, "y": y, "target": "layer", "select": false}))?;
if let Some(layer) = picked.get("layer").and_then(Value::as_u64) {
app.run("layer.select", json!({"layer": layer, "mode": "replace"}))?;
}
Ok(picked)
}
+21 -3
View File
@@ -1065,8 +1065,23 @@ pub fn form_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
// Data-driven labels (a per-part checkbox shows the part's name, not a catalogue entry)
// come from `__labels` verbatim; everything else goes through the catalogue.
let labels = f.get("__labels").cloned().unwrap_or(Value::Null);
let label = |k: &str| labels.get(k).and_then(Value::as_str).map_or_else(|| label_of(k), str::to_string);
let keys: Vec<String> = f.keys().filter(|k| !k.starts_with("__")).cloned().collect();
let file_info = f.get("__command").and_then(Value::as_str) == Some("file.fileInfo");
let label = |k: &str| {
if file_info {
match k {
"title" => return tl!("Document Title").to_owned(),
"copyright" => return tl!("Copyright Notice").to_owned(),
"copyrightUrl" => return tl!("Copyright Info URL").to_owned(),
_ => {}
}
}
labels.get(k).and_then(Value::as_str).map_or_else(|| label_of(k), str::to_string)
};
let mut keys: Vec<String> = f.keys().filter(|k| !k.starts_with("__")).cloned().collect();
if file_info {
const ORDER: &[&str] = &["title", "author", "authorTitle", "description", "keywords", "copyrightStatus", "copyright", "copyrightUrl"];
keys.sort_by_key(|k| ORDER.iter().position(|field| *field == k).unwrap_or(ORDER.len()));
}
egui::Grid::new("form-dialog").num_columns(2).spacing([12.0, 6.0]).show(ui, |ui| {
for k in keys {
let v = f.get(&k).cloned().unwrap_or(Value::Null);
@@ -1124,7 +1139,10 @@ pub fn form_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
});
} else {
ui.add(egui::TextEdit::singleline(&mut s).desired_width(260.0));
let response = ui.add(egui::TextEdit::singleline(&mut s).desired_width(260.0));
if file_info {
response.labelled_by(field_label.id);
}
}
}
}
+4
View File
@@ -652,3 +652,7 @@ dock target. The panel menu and icon rail remain
available in custom workspaces. `window.panel.<id> {show:true}` always reveals, selects
and expands the panel, including when another tab is selected. Workspace snapshots
retain custom collapse settings and Timeline visibility.
### Select the layer under the pointer
Assign **Select Layer Under Cursor** in Keyboard Shortcuts to choose the topmost visible, pickable layer beneath the canvas pointer. Empty pixels and points outside the document leave the selection unchanged; dialogs, strokes and brush-resize gestures block it. The command follows zoom, pan, view rotation and horizontal flipping. Agents can invoke `ui.menu.invoke {"id":"layer.selectUnderCursor"}` after moving the screen pointer with `ui.move {"x": ..., "y": ...}`. The command has no default shortcut.