From 8c04196d49bf66a466d92b1be3fb546f73dc6e8c Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Wed, 28 Oct 2026 03:19:08 +0300 Subject: [PATCH] Desktop: the engine panel keeps its height between positions For one frame after each move the panel had no lines (the old ones gone, the new not yet come) and was 42 px shorter: the notation below jumped up and back. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ apps/desktop/src/analysis.rs | 7 +++++++ apps/desktop/src/game_view.rs | 22 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4c9779..cfb9ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https ## [Unreleased] +- Desktop: the notation no longer jumps on every move with the engine on. Between two + positions the old lines go at once and the new ones come a frame later; the engine + panel now keeps their room, so what is below it stays still. + - The moves of the notation and the signs after them are bold (Ubuntu Bold on the desktop, the bold system font on Android), and so are the marks in the circles on the board. In Russian the report's rows read «Блестящий» and «Замечательный». diff --git a/apps/desktop/src/analysis.rs b/apps/desktop/src/analysis.rs index f9cbbc9..d0be947 100644 --- a/apps/desktop/src/analysis.rs +++ b/apps/desktop/src/analysis.rs @@ -59,6 +59,13 @@ pub struct Analysis { pub engine_path: Option, } +impl Analysis { + /// Lines the engine is asked for (the panel keeps their room while they come). + pub fn line_count(&self) -> usize { + self.multipv.max(1) as usize + } +} + impl Analysis { pub fn new() -> Self { Self { diff --git a/apps/desktop/src/game_view.rs b/apps/desktop/src/game_view.rs index 95cab71..627d6a1 100644 --- a/apps/desktop/src/game_view.rs +++ b/apps/desktop/src/game_view.rs @@ -60,6 +60,8 @@ pub struct GameView { flipped: bool, preview: Option, scroll_to_cursor: bool, + /// Height of one engine line in the panel (its room is kept while lines come). + pv_row_height: f32, /// The comment being written (user-comments.md). editor: Option, /// A game against Maia in progress (play-mode.md). @@ -179,6 +181,7 @@ impl GameView { flipped, preview: None, scroll_to_cursor: true, + pv_row_height: 0.0, editor: None, play: None, play_end: None, @@ -1602,6 +1605,10 @@ impl GameView { .strong() .size(20.0), ); + } else if analysis.is_on() { + // As tall as the evaluation that is coming: the row keeps its + // height between two positions. + ui.label(RichText::new("…").strong().size(20.0).weak()); } } } @@ -1703,7 +1710,7 @@ impl GameView { .preview .as_ref() .is_some_and(|p| p.base == base && p.san == line.san); - ui.horizontal(|ui| { + let row = ui.horizontal(|ui| { ui.spacing_mut().item_spacing.x = 3.0; // The line being stepped through on the board: added from here. if previewed @@ -1769,6 +1776,19 @@ impl GameView { }); }); }); + self.pv_row_height = row.response.rect.height(); + } + // Room for the lines still to come: between two positions the old lines are + // gone at once (never shown for the new one) and the new ones come a moment + // later; without it the notation below jumped up and back on every move. + let missing = analysis.line_count().saturating_sub(lines.len()); + if missing > 0 { + let row = if self.pv_row_height > 0.0 { + self.pv_row_height + } else { + ui.spacing().interact_size.y + }; + ui.add_space(missing as f32 * (row + ui.spacing().item_spacing.y)); } if insert { self.insert_preview(actions);