2026-10-18 01:54:06 +03:00
|
|
|
|
//! Small shared widgets.
|
|
|
|
|
|
|
|
|
|
|
|
use egui::{Color32, Sense, Stroke, Ui, vec2};
|
|
|
|
|
|
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
|
/// Compact ✕ (e.g. to cancel a running task); the caller adds the tooltip.
|
|
|
|
|
|
pub fn small_close_button(ui: &mut Ui) -> egui::Response {
|
|
|
|
|
|
x_button(ui, vec2(22.0, 20.0), 4.5)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn x_button(ui: &mut Ui, size: egui::Vec2, d: f32) -> egui::Response {
|
|
|
|
|
|
let (rect, resp) = ui.allocate_exact_size(size, Sense::click());
|
2026-10-18 01:54:06 +03:00
|
|
|
|
if resp.hovered() {
|
|
|
|
|
|
ui.painter()
|
|
|
|
|
|
.rect_filled(rect, 4.0, Color32::from_rgb(0xc4, 0x2b, 0x1c));
|
|
|
|
|
|
}
|
|
|
|
|
|
let color = if resp.hovered() {
|
|
|
|
|
|
Color32::WHITE
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ui.visuals().text_color()
|
|
|
|
|
|
};
|
|
|
|
|
|
let c = rect.center();
|
|
|
|
|
|
let stroke = Stroke::new(1.6, color);
|
|
|
|
|
|
ui.painter()
|
|
|
|
|
|
.line_segment([c + vec2(-d, -d), c + vec2(d, d)], stroke);
|
|
|
|
|
|
ui.painter()
|
|
|
|
|
|
.line_segment([c + vec2(-d, d), c + vec2(d, -d)], stroke);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
|
resp
|
2026-10-18 01:54:06 +03:00
|
|
|
|
}
|
2026-10-19 19:48:14 +03:00
|
|
|
|
|
|
|
|
|
|
/// The quiet "ℹ n" of import notes: minor remarks, so no colour and no frame.
|
|
|
|
|
|
pub fn notes_button(ui: &mut egui::Ui, notes: usize) -> egui::Response {
|
|
|
|
|
|
ui.add(egui::Button::new(egui::RichText::new(format!("ℹ {notes}")).weak().small()).frame(false))
|
|
|
|
|
|
.on_hover_text(crate::i18n::tr("Import notes"))
|
|
|
|
|
|
}
|
2026-10-20 07:55:59 +03:00
|
|
|
|
|
|
|
|
|
|
/// "⬆ Update 0.8.0" (or the download's progress, "⟳ Restart for 0.8.0"): opens the
|
|
|
|
|
|
/// update window.
|
|
|
|
|
|
pub fn update_button(ui: &mut egui::Ui, label: &str) -> egui::Response {
|
|
|
|
|
|
ui.button(egui::RichText::new(label).color(ui.visuals().hyperlink_color))
|
|
|
|
|
|
.on_hover_text(crate::i18n::tr("A new version of ChessPenguin is out"))
|
|
|
|
|
|
}
|