From 2d93f0a2112c6031354681679d0ef6e8d6058bbf Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 27 Nov 2026 15:33:55 +0300 Subject: [PATCH] =?UTF-8?q?game:=20=C2=ABAnalyse=20game=C2=BB=20button=20i?= =?UTF-8?q?n=20the=20colour=20of=20=C2=AB!!=C2=BB=20(task=2026)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src/game_view.rs | 71 +++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/apps/desktop/src/game_view.rs b/apps/desktop/src/game_view.rs index 1498277..33d024c 100644 --- a/apps/desktop/src/game_view.rs +++ b/apps/desktop/src/game_view.rs @@ -1066,17 +1066,18 @@ impl GameView { .on_hover_text(tr( "Report: show or hide the evaluation graph and the report (Shift+A)", )); - } else if ui - .add_enabled(!self.engine_busy, egui::Button::new(big("📈"))) - .on_hover_text(format!( - "{}\n{}", - tr("Analyse game: accuracy, inaccuracies, mistakes, blunders (Shift+A)"), - self.review.estimate() - )) - .on_disabled_hover_text(tr( - "Opening errors are being searched — wait or stop it in the report", - )) - .clicked() + } else if review_colored(ui, !self.engine_busy, |ui| { + ui.add_enabled(!self.engine_busy, egui::Button::new(big("📈"))) + }) + .on_hover_text(format!( + "{}\n{}", + tr("Analyse game: accuracy, inaccuracies, mistakes, blunders (Shift+A)"), + self.review.estimate() + )) + .on_disabled_hover_text(tr( + "Opening errors are being searched — wait or stop it in the report", + )) + .clicked() { self.review_asked = true; } @@ -5549,6 +5550,54 @@ fn paste_line_full(line: &[(u32, Color, String)]) -> String { .join(" ") } +/// «📈 Analyse game» in the colour of «!!» (task 26): the report it makes marks its finds +/// with it. Hover and press stay visible (egui's own states, shaded); a disabled button +/// keeps the usual look. +fn review_colored( + ui: &mut egui::Ui, + enabled: bool, + add: impl FnOnce(&mut egui::Ui) -> egui::Response, +) -> egui::Response { + if !enabled { + return add(ui); + } + let dark = ui.visuals().dark_mode; + let Some(fill) = crate::notation::assessment_text_color(Nag(3), dark) else { + return add(ui); + }; + // The icon dark on the dark theme's teal, white on the light one's (contrast ≥ 4.5:1). + let icon = if dark { + egui::Color32::from_rgb(0x1b, 0x1b, 0x1b) + } else { + egui::Color32::WHITE + }; + let (hover, press) = if dark { + ( + fill.lerp_to_gamma(egui::Color32::WHITE, 0.18), + fill.lerp_to_gamma(egui::Color32::BLACK, 0.15), + ) + } else { + ( + fill.lerp_to_gamma(egui::Color32::BLACK, 0.15), + fill.lerp_to_gamma(egui::Color32::BLACK, 0.3), + ) + }; + ui.scope(|ui| { + let w = &mut ui.visuals_mut().widgets; + for (state, color) in [ + (&mut w.inactive, fill), + (&mut w.hovered, hover), + (&mut w.active, press), + ] { + state.weak_bg_fill = color; + state.bg_fill = color; + state.fg_stroke.color = icon; + } + add(ui) + }) + .inner +} + #[cfg(test)] mod tests { use super::*;