Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Paths panel: rename a path in place, and name the Work Path when saving it (part of #6238)

Marco Arnulfoa1502432e525
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 6c8f21418..6bb36f9b7 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -2862,6 +2862,7 @@ cameraData Lens Objektiv
Duplicate Layer Comp Duplikovat kompozici vrstev
Duplicate Layers Duplikovat vrstvy
Duplicate Path Duplikovat cestu
+ Rename Path… Přejmenovat cestu…
Duplication Duplikace
Duration Doba trvání
Dust & Scratches Prach a škrábance
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 2bb1c57f1..25c5b8ff6 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -2245,6 +2245,7 @@
Fill Path Pfad füllen
Stroke Path Pfad nachziehen
Delete Path Pfad löschen
+ Rename Path… Pfad umbenennen…
W B
H H
Ruler Lineal
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index 48d23d13b..33f2f4f02 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -2348,6 +2348,7 @@
Drag to move the active shape's path or the Work Path Σύρετε για μετακίνηση της διαδρομής του ενεργού σχήματος ή της διαδρομής εργασίας
Dual Brush Διπλό πινέλο
Duplicate Path Διπλασιασμός διαδρομής
+ Rename Path… Μετονομασία διαδρομής…
Duplicate style Διπλασιασμός στυλ
Dust & Scratches Σκόνη και γρατζουνιές
Dust & Scratches… Σκόνη και γρατζουνιές…
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index a7338795a..97d051088 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2936,6 +2936,7 @@ curves Smooth Suavizar
Clipping Path Trazado de recorte
New Path Nuevo trazado
Duplicate Path Duplicar trazado
+ Rename Path… Cambiar nombre del trazado…
Auto-Hide Ocultar automáticamente
X X
Y Y
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index ba1de7b70..918c6dea3 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -2366,6 +2366,7 @@
Clipping Path Tracé de détourage
New Path Nouveau tracé
Duplicate Path Dupliquer le tracé
+ Rename Path… Renommer le tracé…
Delete Path Supprimer le tracé
Auto-Hide Masquage automatique
W L
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index e26f3ec3b..620702ac8 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -3193,6 +3193,7 @@ cameraRaw Yellow Sárga
Drop an image or PSD anywhere to open it. Húzz ide bárhová egy képet vagy PSD-fájlt a megnyitásához.
Duplicate Layer Comp Rétegkompozíció kettőzése
Duplicate Path Útvonal kettőzése
+ Rename Path… Útvonal átnevezése…
Duplication Kettőzés
East asian Kelet-ázsiai
Edge Extension Szélek kiterjesztése
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index d13db9f0c..86e920709 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -2357,6 +2357,7 @@
Clipping Path Clipping Path
New Path Path Baru
Duplicate Path Duplikat Path
+ Rename Path… Ganti Nama Path…
Delete Path Hapus Path
Auto-Hide Sembunyi Otomatis
W W
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 1779c1259..6e89a8465 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -2928,6 +2928,7 @@ curves Smooth Leviga
Clipping Path Tracciato di ritaglio
New Path Nuovo tracciato
Duplicate Path Duplica tracciato
+ Rename Path… Rinomina tracciato…
Auto-Hide Nascondi automaticamente
X X
Y Y
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index dd0cca727..33e2ea9a2 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -2872,6 +2872,7 @@ fontWeight Italic 斜体
Duplicate Layer Comp レイヤーカンプを複製
Duplicate Layers レイヤーを複製
Duplicate Path パスを複製
+ Rename Path… パス名を変更…
Dust & Scratches ダスト&スクラッチ
EXIF EXIF
Export As 書き出し形式を指定
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index f5c243d1e..5eea8a298 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -1390,6 +1390,7 @@
Rename 이름 바꾸기
Rename Group… 그룹 이름 바꾸기…
Rename Layer… 레이어 이름 바꾸기…
+ Rename Path… 패스 이름 바꾸기…
Rename Tool Preset… 도구 사전 설정 이름 바꾸기…
Rename… 이름 바꾸기…
Resample 리샘플링
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index aea44757c..161ba124f 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3347,6 +3347,7 @@ cameraRaw Color Kleur
Do you want to save you made to “{name}” before quitting? Wil je de wijzigingen in “{name}” opslaan voordat je afsluit?
Dodge/Burn Tegenhouden/doordrukken
Duplicate Path Pad dupliceren
+ Rename Path… Pad hernoemen…
Dust & Scratches Stof en krassen
Dynamics Dynamiek
Edit Plane Vlak bewerken
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 17feb459a..c7891648f 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -2389,6 +2389,7 @@
Clipping Path Ścieżka przycinająca
New Path Nowa ścieżka
Duplicate Path Duplikuj ścieżkę
+ Rename Path… Zmień nazwę ścieżki…
Delete Path Usuń ścieżkę
Auto-Hide Ukrywanie automatyczne
W Sz.
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 0e9559c80..b42fc3710 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -2361,6 +2361,7 @@
Clipping Path Demarcador de corte
New Path Novo demarcador
Duplicate Path Duplicar demarcador
+ Rename Path… Renomear demarcador…
Delete Path Excluir demarcador
Auto-Hide Ocultar automaticamente
W L
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 78e10a10c..b602fa9c2 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -1190,6 +1190,7 @@
Clipping Path Обтравочный контур
New Path Новый контур
Duplicate Path Дублировать контур
+ Rename Path… Переименовать контур…
Delete Path Удалить контур
Current Path Текущий контур
Vector Mask from Current Path Векторная маска из текущего контура
diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv
index f4a8552fb..ecfc33a54 100644
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@ -2343,6 +2343,7 @@
Clipping Path Putanja isecanja
New Path Nova putanja
Duplicate Path Dupliraj putanju
+ Rename Path… Preimenuj putanju…
Delete Path Obriši putanju
Auto-Hide Automatski sakrij
W Š
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index b11f51a80..bdd8a2f8e 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -3319,6 +3319,7 @@ cameraRaw Color Renk
Do you want to save you made to “{name}” before quitting? Çıkmadan önce yaptığınız işi “{name}” konumuna kaydetmek istiyor musunuz?
Dodge/Burn Soldurma/Yakma
Duplicate Path Yinelenen Yol
+ Rename Path… Yolu Yeniden Adlandır…
Dust & Scratches Toz ve Çizikler
Dynamics Dinamik
Edit Plane Düzlemi Düzenle
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index e563354fd..79daa2209 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -1165,6 +1165,7 @@
Clipping Path Відсічний контур
New Path Новий контур
Duplicate Path Дублювати контур
+ Rename Path… Перейменувати контур…
Delete Path Видалити контур
Current Path Поточний контур
Vector Mask from Current Path Векторна маска з поточного контуру
diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv
index 6907be96a..97ea1d458 100644
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@ -1272,6 +1272,7 @@
Stroke Path Đi nét đường dẫn
Save Path Lưu đường dẫn
Duplicate Path Nhân bản đường dẫn
+ Rename Path… Đổi tên đường dẫn…
Delete Path Xóa đường dẫn
Delete Vector Mask Xóa mặt nạ vector
Draw with the Pen tool (P) or make a work path from a selection. Vẽ bằng công cụ Bút (P) hoặc tạo đường dẫn làm việc từ vùng chọn.
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index 3962f46d6..3b3b5098f 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -1430,6 +1430,7 @@
Rename 重命名
Rename Group… 重命名组…
Rename Layer… 重命名图层…
+ Rename Path… 重命名路径…
Rename Tool Preset… 重命名工具预设…
Rename… 重命名…
Resample 重新采样
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 005c992e2..5d96e2034 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -1427,6 +1427,7 @@
Rename 重新命名
Rename Group… 重新命名群組…
Rename Layer… 重新命名圖層…
+ Rename Path… 重新命名路徑…
Rename Tool Preset… 重新命名工具預設集…
Rename… 重新命名…
Resample 重新取樣
diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs
index 01bb3c133..b6aff620a 100644
--- a/crates/ui-egui/src/vector_ui.rs
+++ b/crates/ui-egui/src/vector_ui.rs
@@ -1690,6 +1690,32 @@ pub fn paths_footer(ctx: &egui::Context) -> Option<Rect> {
ctx.data(|d| d.get_temp(footer_id()))
}
+/// Photoshop's default name for a saved path: the first free "Path N", counting from the number of
+/// saved paths.
+fn free_path_name(doc: &Document) -> String {
+ let mut n = doc.paths.len().saturating_add(1);
+ while doc.paths.iter().any(|p| p.name == format!("Path {n}")) {
+ n = n.saturating_add(1);
+ if n == usize::MAX {
+ break;
+ }
+ }
+ format!("Path {n}")
+}
+
+/// A Paths panel name being typed in place: the row's key ("work" or the saved path's name) and
+/// the text so far. It lives in egui's temp data, like the Channels panel's rename field.
+#[derive(Clone)]
+struct PathRename {
+ key: String,
+ text: String,
+ focused: bool,
+}
+
+fn rename_id(doc: &Document) -> egui::Id {
+ egui::Id::new(("path-rename", doc.id.0))
+}
+
/// Commands offered by a Paths row's context menu. The row's path is passed explicitly so a
/// right-click acts on that row even when another path is selected in the panel.
fn path_context_actions(entry: &PathEntry, doc: &Document) -> Vec<(&'static str, &'static str, Value)> {
@@ -1704,14 +1730,7 @@ fn path_context_actions(entry: &PathEntry, doc: &Document) -> Vec<(&'static str,
("Stroke Path…", "path.stroke", json!({"name": key})),
];
if entry.kind == PathRow::Work {
- let mut n = doc.paths.len().saturating_add(1);
- while doc.paths.iter().any(|p| p.name == format!("Path {n}")) {
- n = n.saturating_add(1);
- if n == usize::MAX {
- break;
- }
- }
- actions.push(("Save Path", "path.rename", json!({"name": "work", "to": format!("Path {n}")})));
+ actions.push(("Save Path", "path.rename", json!({"name": "work", "to": free_path_name(doc)})));
} else {
let mut n = 1usize;
while doc.paths.iter().any(|p| p.name == format!("{} copy {n}", entry.name)) {
@@ -1723,6 +1742,10 @@ fn path_context_actions(entry: &PathEntry, doc: &Document) -> Vec<(&'static str,
let copy_name = format!("{} copy {n}", entry.name);
actions.push(("Duplicate Path", "path.set", json!({"name": copy_name, "path": photocraft_engine::vector_cmds::path_json(&entry.path)})));
}
+ if entry.kind == PathRow::Saved {
+ // No `to`: the panel asks for the new name in place.
+ actions.push(("Rename Path…", "path.rename", json!({"name": key})));
+ }
if entry.kind != PathRow::Layer {
actions.push(("Delete Path", "path.delete", json!({"name": key})));
} else if entry.name.ends_with(" Vector Mask") {
@@ -1742,6 +1765,7 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let has_layer_path = rows.iter().any(|r| r.kind == PathRow::Layer);
let mut action: Option<(&str, Value)> = None;
let mut stroke_dialog: Option<String> = None;
+ let rename_id = rename_id(&doc);
// The buttons sit in a footer at the panel's bottom, like Photoshop's.
let footer = crate::widgets::footer_height(ui) + ui.spacing().item_spacing.y;
let fill = ui.available_height() > footer + 60.0;
@@ -1777,8 +1801,38 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
0.0,
egui::TextFormat { font_id: egui::FontId::proportional(12.0), color: t.text, italics, ..Default::default() },
);
- let g = ui.painter().layout_job(job);
- ui.painter().galley(pos2(r.left() + 46.0, r.center().y - g.size().y / 2.0), g, t.text);
+ let renaming = ui.ctx().data(|d| d.get_temp::<PathRename>(rename_id)).filter(|e| e.key == key);
+ if let Some(mut edit) = renaming {
+ let field = Rect::from_min_max(pos2(r.left() + 43.0, r.center().y - 11.0), pos2(r.right() - 8.0, r.center().y + 11.0));
+ let id = rename_id.with("field");
+ let te = ui.put(field, egui::TextEdit::singleline(&mut edit.text).id(id).font(egui::FontId::proportional(12.0)));
+ let (enter, esc) = ui.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape)));
+ if !edit.focused {
+ te.request_focus();
+ // Like Photoshop, the whole name starts selected so typing replaces it.
+ if let Some(mut state) = egui::TextEdit::load_state(ui.ctx(), id) {
+ let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(edit.text.chars().count()));
+ state.cursor.set_char_range(Some(all));
+ state.store(ui.ctx(), id);
+ }
+ edit.focused = true;
+ ui.ctx().data_mut(|d| d.insert_temp(rename_id, edit));
+ } else if esc {
+ ui.ctx().data_mut(|d| d.remove::<PathRename>(rename_id));
+ } else if enter || te.lost_focus() || !te.has_focus() {
+ ui.ctx().data_mut(|d| d.remove::<PathRename>(rename_id));
+ let to = edit.text.trim();
+ // The Work Path is saved even under its proposed name; an unchanged saved name is left alone.
+ if !to.is_empty() && (*kind == PathRow::Work || to != name) {
+ action = Some(("path.rename", json!({"name": key, "to": to})));
+ }
+ } else {
+ ui.ctx().data_mut(|d| d.insert_temp(rename_id, edit));
+ }
+ } else {
+ let g = ui.painter().layout_job(job);
+ ui.painter().galley(pos2(r.left() + 46.0, r.center().y - g.size().y / 2.0), g, t.text);
+ }
// Ctrl/Cmd-click loads only the thumbnail's path, without changing the panel target.
let modifiers = ui.input(|i| i.modifiers);
let load = resp.clicked() && modifiers.command && resp.interact_pointer_pos().is_some_and(|p| thumbnail.contains(p));
@@ -1791,10 +1845,18 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
} else if resp.clicked() {
app.ui.selected_path = Some(key.clone());
}
- // Double-clicking the Work Path saves it (Photoshop's "Save Path").
- if !load && resp.double_clicked() && *kind == PathRow::Work {
- let n = doc.paths.len() + 1;
- action = Some(("path.rename", json!({"name": "work", "to": format!("Path {n}")})));
+ // As in Photoshop, double-clicking a saved path's name renames it, and double-clicking
+ // the Work Path asks for the name to save it under (#6238).
+ let proposed = match kind {
+ PathRow::Work => Some(free_path_name(&doc)),
+ PathRow::Saved => Some(name.clone()),
+ PathRow::Layer => None,
+ };
+ if !load
+ && resp.double_clicked()
+ && let Some(text) = proposed
+ {
+ ui.ctx().data_mut(|d| d.insert_temp(rename_id, PathRename { key: key.clone(), text, focused: false }));
}
resp.context_menu(|ui| {
crate::widgets::menu_scroll(ui, |ui| {
@@ -1807,6 +1869,9 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if cmd == "path.stroke" {
// Stroke Path… asks for the tool first, as in Photoshop (#2978).
stroke_dialog = Some(params.get("name").and_then(Value::as_str).unwrap_or("work").to_string());
+ } else if cmd == "path.rename" && params.get("to").is_none() {
+ let edit = PathRename { key: key.clone(), text: name.clone(), focused: false };
+ ui.ctx().data_mut(|d| d.insert_temp(rename_id, edit));
} else {
action = Some((cmd, params));
}
@@ -1869,11 +1934,20 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if let Some(name) = stroke_dialog {
crate::canvas_tool_menu::stroke_path_dialog(app, &name);
}
- if let Some((cmd, p)) = action
- && let Err(e) = app.run(cmd, p)
- {
- app.ui.status = e;
- app.ui.status_error = true;
+ if let Some((cmd, p)) = action {
+ let renamed = if cmd == "path.rename" { p.get("to").and_then(Value::as_str).map(str::to_string) } else { None };
+ match app.run(cmd, p) {
+ // The renamed (or just saved) path stays the panel's target.
+ Ok(_) => {
+ if renamed.is_some() {
+ app.ui.selected_path = renamed;
+ }
+ }
+ Err(e) => {
+ app.ui.status = e;
+ app.ui.status_error = true;
+ }
+ }
}
}
@@ -2017,6 +2091,61 @@ mod tests {
assert!(!entries.iter().any(|(_, id, _)| *id == "path.delete"));
}
+ /// #6238: double-clicking a saved path's name renames it in place, and double-clicking the
+ /// Work Path saves it under the name typed (it used to save it as "Path N" straight away).
+ #[test]
+ fn double_clicking_a_path_name_renames_it_in_place() {
+ use egui_kittest::{Harness, kittest::Queryable};
+ let mut app = app();
+ let path = json!({"subpaths": [{"closed": true, "knots": [
+ {"anchor": [10, 10], "in": [10, 10], "out": [10, 10]},
+ {"anchor": [80, 10], "in": [80, 10], "out": [80, 10]},
+ {"anchor": [80, 80], "in": [80, 80], "out": [80, 80]}
+ ]}]});
+ app.run("path.set", json!({"name": "First", "path": path})).unwrap();
+ app.run("path.set", json!({"name": "work", "path": path})).unwrap();
+ // 60 fps steps, so two clicks a frame apart count as a double-click.
+ let mut h = Harness::builder().with_size(vec2(320.0, 260.0)).with_step_dt(1.0 / 60.0).build_ui_state(|ui, app| paths_panel(app, ui), app);
+ h.run_steps(3);
+ let rename = |h: &mut Harness<'_, PhotocraftApp>, row: &str, text: &str| {
+ let name = h.get_by_label(row).rect().left_center() + vec2(60.0, 0.0);
+ h.event(egui::Event::PointerMoved(name));
+ h.run_steps(30);
+ for pressed in [true, false, true, false] {
+ h.event(egui::Event::PointerButton { pos: name, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });
+ h.step();
+ }
+ h.run_steps(3);
+ h.event(egui::Event::Text(text.into()));
+ h.run_steps(1);
+ h.key_press(egui::Key::Enter);
+ h.run_steps(3);
+ };
+ let names = |h: &Harness<'_, PhotocraftApp>| h.state().session.active().unwrap().doc.paths.iter().map(|p| p.name.clone()).collect::<Vec<_>>();
+ rename(&mut h, "First", "Outline");
+ assert_eq!(names(&h), ["Outline"]);
+ assert!(h.state().session.active().unwrap().doc.work_path.is_some(), "renaming a saved path leaves the work path alone");
+ rename(&mut h, "Work Path", "Circle");
+ assert_eq!(names(&h), ["Outline", "Circle"]);
+ assert!(h.state().session.active().unwrap().doc.work_path.is_none());
+ assert_eq!(h.state().ui.selected_path.as_deref(), Some("Circle"));
+ }
+
+ /// #6238: a saved path's context menu offers Rename Path…, as the Layers panel's does.
+ #[test]
+ fn saved_path_context_menu_offers_rename() {
+ let mut app = app();
+ app.run("path.set", json!({"name": "First", "path": {"subpaths": []}})).unwrap();
+ app.run("path.set", json!({"name": "work", "path": {"subpaths": []}})).unwrap();
+ let doc = &app.session.active().unwrap().doc;
+ let rename = |kind| {
+ let entry = path_rows(doc, None).into_iter().find(|r| r.kind == kind).unwrap();
+ path_context_actions(&entry, doc).into_iter().find(|(label, _, _)| *label == "Rename Path…").map(|(_, id, p)| (id, p))
+ };
+ assert_eq!(rename(PathRow::Saved), Some(("path.rename", json!({"name": "First"}))));
+ assert_eq!(rename(PathRow::Work), None, "the work path is saved, not renamed");
+ }
+
/// How many shapes the path overlay paints for `app` this frame.
fn overlay_shapes(app: &PhotocraftApp, ctx: &egui::Context) -> usize {
let doc = app.session.active().unwrap().doc.clone();