PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Patch Tool: say to drag the selection after the lasso and after a click that moves nothing (#1715) (#1720)
MarekSpodBiedry5538f3920dd3
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 5e8d93789..666ab17a8 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -3728,7 +3728,11 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) {let o = &app.ui.tool_options;// The Patch and Content-Aware Move tools have no Feather in their options bar.let feather = if d.tool == Tool::Lasso { o.feather } else { 0.0 };- let _ = app.run("select.lasso", json!({"points": pts, "mode": mode, "antiAlias": o.anti_alias, "feather": feather}));+ let made = app.run("select.lasso", json!({"points": pts, "mode": mode, "antiAlias": o.anti_alias, "feather": feather}));+ // The lasso only outlines the patch; say that it is dragged next (#1715).+ if made.is_ok() && d.tool != Tool::Lasso {+ crate::retouch_ui::patch_hint(app);+ }} else if app.session.is_enabled("select.deselect") {let _ = app.run("select.deselect", json!({}));}diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 31d16ddc8..1104066bb 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -2094,6 +2094,7 @@ cameraRaw Color BarvyPatch Tool Nástroj záplataPatch: Záplata:Lasso around an area, then drag the selection Obtáhněte oblast lasem a pak přetáhněte výběr+ Now drag the selection onto another area Nyní přetáhněte výběr na jiné místoEdit Type Upravit textdiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 8018a5f8b..651067408 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -2128,6 +2128,7 @@Grid: Raster:Highlight Clipping Warning (O) Lichter-Abschneidewarnung (O)Lasso around an area, then drag the selection Lasso um einen Bereich ziehen, dann die Auswahl verschieben+ Now drag the selection onto another area Jetzt die Auswahl auf einen anderen Bereich ziehenPatch: Korrektur:Shadow Clipping Warning (U) Tiefen-Abschneidewarnung (U)Show Lab Color Readouts Lab-Farbwerte anzeigendiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex 50606e083..75c659d6b 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -1596,6 +1596,7 @@Click to apply, ⌥-click to clear overrides, double-click for Style Options Κλικ για εφαρμογή, ⌥-κλικ για εκκαθάριση παρακάμψεων, διπλό κλικ για επιλογές στυλClick: corner · Drag: smooth · Click first point: close · ↩ finish · Esc cancel Κλικ: γωνία · Σύρσιμο: ομαλή καμπύλη · Κλικ στο πρώτο σημείο: κλείσιμο · ↩ ολοκλήρωση · Esc ακύρωσηLasso around an area, then drag the selection Σχεδιάστε επιλογή με το Lasso γύρω από μια περιοχή και σύρετέ την+ Now drag the selection onto another area Τώρα σύρετε την επιλογή σε άλλη περιοχήRulers (⌘R) Χάρακες (⌘R)Show Guides (⌘;) Εμφάνιση οδηγών (⌘;)Grid (⌘') Πλέγμα (⌘')diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex cff7a2d21..0b5de6879 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -2167,6 +2167,7 @@ cameraRaw Amount CantidadPatch Tool Herramienta ParchePatch: Parche:Lasso around an area, then drag the selection Rodee un área con el lazo y arrastre la selección+ Now drag the selection onto another area Ahora arrastre la selección a otra áreaEdit Type Editar textodiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 06169d00b..b14de4030 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2518,6 +2518,7 @@ cameraRaw Blending FusionPatch Tool Outil PiècePatch: Pièce :Lasso around an area, then drag the selection Entourez une zone au lasso, puis faites glisser la sélection+ Now drag the selection onto another area Faites maintenant glisser la sélection vers une autre zone# Warp grid presets (#388)3 x 3 3 × 3diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex fae5461ec..7df4c2498 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2492,6 +2492,7 @@ cameraRaw Blending PembauranPatch Tool Alat PatchPatch: Patch:Lasso around an area, then drag the selection Lingkari area dengan lasso, lalu seret seleksinya+ Now drag the selection onto another area Sekarang seret seleksi ke area lainRendering Mode Mode RenderingAutomatic (recommended) Otomatis (disarankan)CPU / Compatibility CPU / Kompatibilitasdiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex 21458bad7..7ccd9b4dd 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -2173,6 +2173,7 @@ cameraRaw Amount QuantitàPatch Tool Strumento ToppaPatch: Toppa:Lasso around an area, then drag the selection Seleziona un'area con lazo, poi trascina la selezione+ Now drag the selection onto another area Ora trascina la selezione su un'altra areaEdit Type Modifica testo# Strings added on main after this catalog was written (2026-10).diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex f4c2ead90..0f403d1e8 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -2077,6 +2077,7 @@ cameraRaw Color カラーPatch Tool パッチツールPatch: パッチ:Lasso around an area, then drag the selection 投げ縄で範囲を囲み、選択範囲をドラッグします+ Now drag the selection onto another area 選択範囲を別の場所へドラッグしますEdit Type 文字を編集diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex f98228066..644ec216c 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -2045,6 +2045,7 @@ cameraRaw Color 색상Patch Tool 패치 도구Patch: 패치:Lasso around an area, then drag the selection 올가미로 영역을 둘러싼 다음 선택 영역을 드래그하세요+ Now drag the selection onto another area 이제 선택 영역을 다른 영역으로 드래그하세요# Warp grid presets merged on main in #388.3 x 3 3 × 3diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex ef52dc956..2d51f6df7 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -2553,6 +2553,7 @@ cameraRaw Roughness ChropowatośćPatch Tool Narzędzie ŁatkaPatch: Łatka:Lasso around an area, then drag the selection Zakreśl obszar lassem, a następnie przeciągnij zaznaczenie+ Now drag the selection onto another area Teraz przeciągnij zaznaczenie na inny obszarEdit Type Edytuj tekstMake Default Ustaw jako domyślneReset to Default Przywróć domyślnediff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 720da9b26..b81316dc0 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2512,6 +2512,7 @@ cameraRaw Blending MesclagemPatch Tool Ferramenta CorreçãoPatch: Correção:Lasso around an area, then drag the selection Contorne uma área com o laço e arraste a seleção+ Now drag the selection onto another area Agora arraste a seleção para outra área3 x 3 3 × 34 x 4 4 × 45 x 5 5 × 5diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 4434bef23..562d630e4 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2370,6 +2370,7 @@ cameraRaw Roughness НеровностьPatch Tool ЗаплаткаPatch: Заплатка:Lasso around an area, then drag the selection Обведите область лассо, затем перетащите выделение+ Now drag the selection onto another area Теперь перетащите выделение на другую областьEdit Type Редактировать текстdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex b448be4a9..09a6de0f9 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -1970,6 +1970,7 @@ cameraRaw Blending 混合Patch Tool 修补工具Patch: 修补:Lasso around an area, then drag the selection 用套索圈出区域,然后拖动选区+ Now drag the selection onto another area 现在将选区拖动到另一个区域# Current shell labels and shortcut templates. Keep {key} platform-dependent.Add a mask (from the selection; {key} inverts) 添加蒙版 (基于选区;{key} 反相)Add to selection ({key}) 添加到选区 ({key})diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex e62610cff..0a46ee23e 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -2072,6 +2072,7 @@ cameraRaw Blending 混合Patch Tool 修補工具Patch: 修補:Lasso around an area, then drag the selection 用套索圈出區域,然後拖曳選取範圍+ Now drag the selection onto another area 現在將選取範圍拖曳到另一個區域Edit Type 編輯文字diff --git a/crates/ui-egui/src/retouch_ui.rs b/crates/ui-egui/src/retouch_ui.rsindex 62a99f04d..7b057e9e0 100644--- a/crates/ui-egui/src/retouch_ui.rs+++ b/crates/ui-egui/src/retouch_ui.rs@@ -154,10 +154,19 @@ pub fn patch_offset(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) ->[clamp(dx, canvas.x0 - b.x0, canvas.x1 - b.x1), clamp(dy, canvas.y0 - b.y0, canvas.y1 - b.y1)]}+/// Status-bar hint for the Patch and Content-Aware Move tools: the selection is the patch and it+/// has to be dragged somewhere. Without it a lasso, or a click inside the selection, changes+/// nothing on the canvas and the tool looks dead (#1715).+pub fn patch_hint(app: &mut PhotocraftApp) {+ app.ui.status = tl!("Now drag the selection onto another area").into();+ app.ui.status_error = false;+}+/// Patch Tool: the patch was dragged from `start` to `end`.pub fn finish_patch(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {let off = patch_offset(app, start, end);if off == [0, 0] {+ patch_hint(app);return;}let preview = crate::patch_preview::take(app);@@ -176,6 +185,7 @@ pub fn finish_patch(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {pub fn finish_content_aware_move(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {let off = patch_offset(app, start, end);if off == [0, 0] {+ patch_hint(app);return;}let o = &app.ui.tool_options;@@ -648,6 +658,28 @@ mod tests {assert_eq!(h.state().ui.tool_options.red_eye_darken, 50.0);}+ #[test]+ fn patch_tool_says_to_drag_the_selection_after_the_lasso_and_after_a_click() {+ let hint = tl!("Now drag the selection onto another area");+ let m = egui::Modifiers::NONE;+ let mut app = app();+ app.ui.tool = Tool::Patch;+ app.ui.status.clear();+ // No selection yet: the drag is a lasso, which outlines the patch and says what comes next.+ tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 10.0, pressure: 1.0 }, m);+ tool_event(&mut app, ToolEvent::Move { x: 40.0, y: 10.0, pressure: 1.0 }, m);+ tool_event(&mut app, ToolEvent::Move { x: 40.0, y: 30.0, pressure: 1.0 }, m);+ tool_event(&mut app, ToolEvent::Up { x: 20.0, y: 30.0 }, m);+ assert!(app.session.active().is_some_and(|st| st.doc.selection.is_some()), "the lasso made a selection");+ assert_eq!((app.ui.status.as_str(), app.ui.status_error), (hint, false));+ // A press and release inside the selection moves nothing: it says so instead of staying silent.+ app.ui.status.clear();+ tool_event(&mut app, ToolEvent::Down { x: 30.0, y: 20.0, pressure: 1.0 }, m);+ tool_event(&mut app, ToolEvent::Up { x: 30.0, y: 20.0 }, m);+ assert_eq!((app.ui.status.as_str(), app.ui.status_error), (hint, false));+ assert!(app.session.active().is_some_and(|st| st.doc.selection.is_some()), "the selection stays");+ }+#[test]fn red_eye_is_in_the_j_flyout() {let j = [Tool::SpotHealing, Tool::Healing, Tool::Patch, Tool::ContentAwareMove, Tool::RedEye];