From f03a0d2a4ba0e8254583ab30fb6883b39b6f9abf Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Sun, 25 Oct 2026 03:22:51 +0300 Subject: [PATCH] =?UTF-8?q?No=20preview=20strip:=20=C2=AB+=20Add=20as=20va?= =?UTF-8?q?riation=C2=BB=20at=20the=20end=20of=20the=20line=20being=20show?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 5 ++++ apps/desktop/src/game_view.rs | 46 ++++++++++++----------------- apps/desktop/src/i18n.rs | 55 ++++++++++++++--------------------- apps/desktop/src/notation.rs | 14 +++++++++ 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d900aa..c0ab019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https deleted (Ctrl+Z puts them back); their `[%clk]`, `[%eval]` and board commands are kept, an untouched comment keeps its bytes. One edit is one undo step; the game is marked modified and Ctrl+S saves it. Paragraphs of comments survive writing now. +- The strip «Engine line preview … Add as variation · Exit» above the notation is gone: + stepping through a line of the report or of the engine panel just shows it on the + board, Esc leaves it, and a small «+ Add as variation» stands at the end of the line + being shown. Moves of variations and of the report's better lines keep their size under + the mouse. ## [1.1.0] — 2026-10-25 diff --git a/apps/desktop/src/game_view.rs b/apps/desktop/src/game_view.rs index ad74a6f..9ed08dc 100644 --- a/apps/desktop/src/game_view.rs +++ b/apps/desktop/src/game_view.rs @@ -1323,6 +1323,9 @@ impl GameView { Some(EditorOutcome::Cancel) => self.cancel_editor(), None => {} } + if resp.insert_preview { + self.insert_preview(actions); + } if let Some(slot) = resp.edit { self.open_editor(slot); } @@ -1504,9 +1507,25 @@ impl GameView { let base = self.cursor; let root = self.game.position(base).cloned(); let lines: Vec = analysis.lines.clone(); + let mut insert = false; for line in &lines { + let previewed = self + .preview + .as_ref() + .is_some_and(|p| p.base == base && p.san == line.san); ui.horizontal(|ui| { ui.spacing_mut().item_spacing.x = 3.0; + // The line being stepped through on the board: added from here. + if previewed + && ui + .small_button(tr("+ Add as variation")) + .on_hover_text(tr( + "Puts the line into the game as a variation (Ctrl+Z to undo)", + )) + .clicked() + { + insert = true; + } ui.label( RichText::new(analysis::format_eval(&line.score)) .strong() @@ -1561,35 +1580,8 @@ impl GameView { }); }); } - } - if let Some(p) = &self.preview { - let mut exit = false; - let mut insert = false; - egui::Frame::new() - .fill(ui.visuals().selection.bg_fill.gamma_multiply(0.35)) - .inner_margin(6) - .show(ui, |ui| { - ui.horizontal_wrapped(|ui| { - ui.label(RichText::new(tr("Engine line preview")).strong()); - ui.label( - RichText::new(trf( - "move {a}/{b}", - &[("a", &p.shown), ("b", &p.moves.len())], - )) - .weak(), - ); - if ui.button(tr("Add as variation")).clicked() { - insert = true; - } - if ui.button(tr("Exit (Esc)")).clicked() { - exit = true; - } - }); - }); if insert { self.insert_preview(actions); - } else if exit { - self.preview = None; } } ui.add_space(4.0); diff --git a/apps/desktop/src/i18n.rs b/apps/desktop/src/i18n.rs index 3e12ec0..18b37a9 100644 --- a/apps/desktop/src/i18n.rs +++ b/apps/desktop/src/i18n.rs @@ -7392,28 +7392,6 @@ const ROWS: &[[&str; 9]] = &[ "Dvigatel sozlamalari", "Қозғалтқыш баптаулары", ], - [ - "Engine line preview", - "Предпросмотр линии движка", - "Aperçu de la ligne du moteur", - "Vorschau der Engine-Variante", - "Vista previa de la línea del motor", - "Anteprima della linea del motore", - "Prévia da linha do motor", - "Dvigatel liniyasini ko‘rish", - "Қозғалтқыш вариантын алдын ала көру", - ], - [ - "move {a}/{b}", - "ход {a}/{b}", - "coup {a}/{b}", - "Zug {a}/{b}", - "jugada {a}/{b}", - "mossa {a}/{b}", - "lance {a}/{b}", - "yurish {a}/{b}", - "жүріс {a}/{b}", - ], [ "Add as variation", "Добавить как вариант", @@ -7425,17 +7403,6 @@ const ROWS: &[[&str; 9]] = &[ "Variant sifatida qo‘shish", "Вариант ретінде қосу", ], - [ - "Exit (Esc)", - "Выйти (Esc)", - "Quitter (Échap)", - "Beenden (Esc)", - "Salir (Esc)", - "Esci (Esc)", - "Sair (Esc)", - "Chiqish (Esc)", - "Шығу (Esc)", - ], [ "Line added as a variation (Ctrl+Z to undo)", "Линия добавлена как вариант (Ctrl+Z — отменить)", @@ -10199,6 +10166,28 @@ const ROWS: &[[&str; 9]] = &[ "Qoralar yutmoqda", "Қаралар ұтып жатыр", ], + [ + "+ Add as variation", + "+ Добавить как вариант", + "+ Ajouter comme variante", + "+ Als Variante hinzufügen", + "+ Añadir como variante", + "+ Aggiungi come variante", + "+ Adicionar como variante", + "+ Variant sifatida qo‘shish", + "+ Нұсқа ретінде қосу", + ], + [ + "Puts the line into the game as a variation (Ctrl+Z to undo)", + "Запишет линию в партию вариантом (Ctrl+Z — отменить)", + "Ajoute la ligne à la partie comme variante (Ctrl+Z pour annuler)", + "Nimmt die Linie als Variante in die Partie auf (Ctrl+Z zum Rückgängigmachen)", + "Añade la línea a la partida como variante (Ctrl+Z para deshacer)", + "Aggiunge la linea alla partita come variante (Ctrl+Z per annullare)", + "Adiciona a linha à partida como variante (Ctrl+Z para desfazer)", + "Liniyani o‘yinga variant sifatida yozadi (Ctrl+Z — bekor qilish)", + "Желіні партияға нұсқа ретінде жазады (Ctrl+Z — болдырмау)", + ], ]; #[cfg(test)] diff --git a/apps/desktop/src/notation.rs b/apps/desktop/src/notation.rs index ca77c11..3807715 100644 --- a/apps/desktop/src/notation.rs +++ b/apps/desktop/src/notation.rs @@ -39,6 +39,8 @@ pub struct NotationResponse { pub nag: Option<(NodeId, Nag)>, /// The editor's «Done» or «Cancel». pub editor: Option, + /// The engine line shown on the board goes into the game as a variation. + pub insert_preview: bool, } #[derive(Clone, Copy, Debug)] @@ -553,6 +555,18 @@ fn mark_block(ui: &mut Ui, n: &Notation, id: NodeId, mark: &Mark, out: &mut Nota if mark.best_san.len() > visible { ui.label(RichText::new("…").weak()); } + // The line being stepped through on the board: added from here (there is + // no separate strip for it). + if shown.is_some() + && ui + .small_button(tr("+ Add as variation")) + .on_hover_text(tr( + "Puts the line into the game as a variation (Ctrl+Z to undo)", + )) + .clicked() + { + out.insert_preview = true; + } }); }); }