From 613d14bfdd3a3839d07cb971d121686760916b01 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 27 Nov 2026 09:23:54 +0300 Subject: [PATCH] =?UTF-8?q?opening=20trainer:=20the=20table's=20bar=20is?= =?UTF-8?q?=20green/blue=20on=20a=20visible=20track=20(white=20on=20a=20da?= =?UTF-8?q?rk=20selection),=20=C2=ABlearning=20Z=C2=BB=20instead=20of=20?= =?UTF-8?q?=C2=AB0/Y=C2=BB,=20column=20=C2=ABProgress=C2=BB,=20the=20next?= =?UTF-8?q?=20review=20under=20=C2=ABToday=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop/src/i18n.rs | 11 ++++++ apps/desktop/src/repertoire_ui.rs | 66 ++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/apps/desktop/src/i18n.rs b/apps/desktop/src/i18n.rs index 19b6c24..9d3444d 100644 --- a/apps/desktop/src/i18n.rs +++ b/apps/desktop/src/i18n.rs @@ -854,6 +854,17 @@ const ROWS: &[[&str; 9]] = &[ "O‘rganilgan {x}, o‘rganilmoqda {z}, jami {y} yurish. Yurish ketma-ket uchta to‘g‘ri javobdan keyin (yordamsiz) o‘rganilgan hisoblanadi — odatda bir necha kunlik takrorlashda.", "Үйренілген {x}, үйренілуде {z}, барлығы {y} жүріс. Жүріс кеңессіз қатарынан үш дұрыс жауаптан кейін үйренілген саналады — әдетте бірнеше күндік қайталауда.", ], + [ + "Progress", + "Прогресс", + "Progression", + "Fortschritt", + "Progreso", + "Progressi", + "Progresso", + "Taraqqiyot", + "Ілгерілеу", + ], [ "New moves left", "Новых ходов осталось", diff --git a/apps/desktop/src/repertoire_ui.rs b/apps/desktop/src/repertoire_ui.rs index c4f6ae8..9efb969 100644 --- a/apps/desktop/src/repertoire_ui.rs +++ b/apps/desktop/src/repertoire_ui.rs @@ -12,7 +12,7 @@ use std::time::Duration; use chess_core::shakmaty::{Chess, Color, Position, Square}; use chess_core::{Game, NodeId, PgnDatabase, Severity}; -use egui::{Key, Modifiers, RichText, Ui, vec2}; +use egui::{Color32, Key, Modifiers, RichText, Ui, vec2}; use trainer::repertoire::{ LearningData, LearningItemKey, LearningSide, LearningStore, LearningStoreData, Library, LibraryStore, MergeReport, RepertoireId, ResetImpactProjection, SrsSettings, StatsScope, @@ -1691,7 +1691,7 @@ impl RepertoireUi { ui.add(egui::Label::new(RichText::new(tr("Name")).strong()).truncate()); }); header.col(|_| {}); - for key in ["Today", "Learned"] { + for key in ["Today", "Progress"] { header.col(|ui| { ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.add(egui::Label::new(RichText::new(tr(key)).strong()).truncate()); @@ -1729,6 +1729,17 @@ impl RepertoireUi { &[("n", &stats.due), ("m", &stats.new_today())], )); } + // Nothing today: when the next review is. + Some(Ok(RowStats { + next: Some((at, _)), + .. + })) => { + let when = layout::when(*at, layout::now()); + ui.add( + egui::Label::new(RichText::new(&when).weak()).truncate(), + ) + .on_hover_text(format!("{}: {when}", tr("Next review"))); + } Some(_) => { ui.label(RichText::new("—").weak()); } @@ -1750,8 +1761,17 @@ impl RepertoireUi { } Some(Ok(stats)) if stats.total > 0 => { let hint = learned_hint(stats); - ui.label(format!("{}/{}", stats.learnt, stats.total)) - .on_hover_text(&hint); + // «0/17» reads as «nothing done»: name what is under way. + let text = if stats.learnt == 0 && stats.learning > 0 { + RichText::new(trf( + "learning {k}", + &[("k", &stats.learning)], + )) + .weak() + } else { + RichText::new(format!("{}/{}", stats.learnt, stats.total)) + }; + ui.label(text).on_hover_text(&hint); let room = ui.available_width() - ui.spacing().item_spacing.x; if room >= 16.0 { let (bar, response) = ui.allocate_exact_size( @@ -2487,35 +2507,45 @@ fn learned_hint(stats: &RowStats) -> String { } /// The two segments: learned, then learning (paler). -/// On a selected table row the selection colour is the row's own: the segments take -/// the colour of the text on the selection instead. +/// Learned — the green of a correct move; learning — the accent blue; the track stands +/// out from the row. On a selected dark row: white, half-white and a dark track. fn progress_bar(ui: &Ui, bar: egui::Rect, stats: Option<&RowStats>, selected: bool) { - let painter = ui.painter(); - // In the light theme the extreme colour is the rows' white: the track is a button's grey. - let track = if ui.visuals().dark_mode { - ui.visuals().extreme_bg_color + let visuals = ui.visuals(); + let (track, learnt_fill, learning_fill) = if selected && visuals.dark_mode { + ( + Color32::from_black_alpha(90), + Color32::WHITE, + Color32::from_white_alpha(128), + ) + } else if selected { + // The light selection is pale: white would vanish, the selection's text colour shows. + let ink = visuals.selection.stroke.color; + (Color32::from_white_alpha(170), ink, ink.gamma_multiply(0.5)) } else { - ui.visuals().widgets.inactive.bg_fill + let green = crate::notation::assessment_text_color(chess_core::Nag(1), visuals.dark_mode) + .unwrap_or(visuals.selection.bg_fill); + let track = if visuals.dark_mode { + visuals.widgets.inactive.bg_fill + } else { + visuals.widgets.inactive.bg_fill.gamma_multiply(0.9) + }; + (track, green, visuals.hyperlink_color) }; + let painter = ui.painter(); painter.rect_filled(bar, 2.0, track); if let Some(stats) = stats.filter(|stats| stats.total > 0) { let total = stats.total as f32; let learnt = bar.width() * stats.learnt as f32 / total; let learning = bar.width() * stats.learning as f32 / total; - let fill = if selected { - ui.visuals().selection.stroke.color - } else { - ui.visuals().selection.bg_fill - }; painter.rect_filled( egui::Rect::from_min_size(bar.min, vec2(learnt, bar.height())), 2.0, - fill, + learnt_fill, ); painter.rect_filled( egui::Rect::from_min_size(bar.min + vec2(learnt, 0.0), vec2(learning, bar.height())), 0.0, - fill.gamma_multiply(0.45), + learning_fill, ); } }