From 319e8808ab9415d4615976a88602a981387b1321 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Sun, 25 Oct 2026 15:21:04 +0300 Subject: [PATCH] Library title row in three groups: databases | a game to enter | Play MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The owner's order: «+ Add database · ✚ New database · 🌐 Online games», a line, «♟ New game · 📋 Paste PGN», a line, «♞ Play»; Settings on the right. The narrow row (the database list) keeps the same groups. Co-Authored-By: Claude Opus 5.5 --- apps/desktop/src/library.rs | 54 ++++++++++++++++++++++--------------- docs/decisions.md | 4 +++ 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/apps/desktop/src/library.rs b/apps/desktop/src/library.rs index 749ef9f..512a9ee 100644 --- a/apps/desktop/src/library.rs +++ b/apps/desktop/src/library.rs @@ -114,9 +114,9 @@ fn legacy_pgn(path: &Path) -> bool { guess.encoding != chess_core::TextEncoding::Utf8 && !guess.ascii_only } -/// The width of the game buttons and of the program's ones (`Library::game_buttons`, -/// `Library::app_buttons`), with the gap that sets the game ones apart from the -/// database actions. +/// The width of the game buttons, «Play» and the program's ones +/// (`Library::game_buttons`, `Library::play_button`, `Library::app_buttons`), with +/// the two lines between the groups. fn shelf_buttons_w(ui: &Ui, update: Option<&str>, icons: bool) -> f32 { let texts: [&str; 4] = if icons { ["⚙", "📋", "♟", "♞"] @@ -130,7 +130,7 @@ fn shelf_buttons_w(ui: &Ui, update: Option<&str>, icons: bool) -> f32 { }; texts.iter().map(|t| button_w(ui, t)).sum::() + update.map_or(0.0, |v| button_w(ui, v)) - + GROUP_GAP + + 2.0 * GROUP_GAP } /// A shelf button's tooltip: with icons only, its name first. @@ -671,9 +671,7 @@ impl Library { if let Some(p) = pick { self.select_db(&p, ui.ctx()); } - self.game_buttons(ui, icons, actions); - ui.add_space(GROUP_GAP - ui.spacing().item_spacing.x); - self.shelf_actions(ui, true, actions); + self.groups(ui, true, icons, actions); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { self.app_buttons(ui, icons, actions); }); @@ -698,7 +696,33 @@ impl Library { } } - /// "♟ New game · 📋 Paste PGN" before the database actions: what to put in, together. + /// The three groups of the title row, apart by a line: the databases (add, new, + /// online games) | a game to enter (new, paste) | play against Maia. + fn groups(&self, ui: &mut Ui, folded: bool, icons: bool, actions: &mut Vec) { + self.shelf_actions(ui, folded, actions); + ui.separator(); + self.game_buttons(ui, icons, actions); + ui.separator(); + self.play_button(ui, icons, actions); + } + + /// "♞ Play": a game against Maia, a group of its own. + fn play_button(&self, ui: &mut Ui, icons: bool, actions: &mut Vec) { + let label = if icons { "♞" } else { tr("♞ Play") }; + if ui + .button(label) + .on_hover_text(shelf_hint( + icons, + tr("♞ Play"), + tr("A game against Maia, which plays like a human of the chosen rating (Ctrl+G)"), + )) + .clicked() + { + actions.push(LibraryAction::Play); + } + } + + /// "♟ New game · 📋 Paste PGN": a game to enter. fn game_buttons(&self, ui: &mut Ui, icons: bool, actions: &mut Vec) { let label = |full: &'static str, icon: &'static str| if icons { icon } else { full }; let hint = |full: &str, hint: &str| shelf_hint(icons, full, hint); @@ -712,16 +736,6 @@ impl Library { { actions.push(LibraryAction::NewGame); } - if ui - .button(label(tr("♞ Play"), "♞")) - .on_hover_text(hint( - tr("♞ Play"), - tr("A game against Maia, which plays like a human of the chosen rating (Ctrl+G)"), - )) - .clicked() - { - actions.push(LibraryAction::Play); - } if ui .button(label(tr("📋 Paste PGN"), "📋")) .on_hover_text(hint( @@ -762,9 +776,7 @@ impl Library { ui.heading(tr("Databases")); ui.add_space(16.0 - ui.spacing().item_spacing.x); } - self.game_buttons(ui, icons, actions); - ui.add_space(GROUP_GAP - ui.spacing().item_spacing.x); - self.shelf_actions(ui, folded, actions); + self.groups(ui, folded, icons, actions); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { self.app_buttons(ui, icons, actions); }); diff --git a/docs/decisions.md b/docs/decisions.md index 5399904..859bf44 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -87,6 +87,10 @@ - **Игра с хода:** новая партия = ходы исходной партии до выбранного хода + игра. Пункт меню «Играть отсюда…». Цвет по умолчанию — сторона, чья очередь ходить. Реванш — тем же цветом. Кнопки «добавить вариантом в исходную партию» нет: сыгранную партию сохраняют в базу как обычную. - **Изучение дебюта:** ходы за обе стороны всегда делает пользователь; режима «один цвет против программы» не будет. После третьей неверной попытки на одном ходе — ссылка «Показать ход» (стрелка по запросу), прохождение помечается «с подсказкой» (понято из ответа «5. ок»; уточнить, если иначе). Каждая неверная попытка считается. +## Строка заголовка библиотеки (2026-10-25) + +- Три группы, разделённые вертикальной чертой: базы («+ Добавить базу · ✚ Новая база · 🌐 Онлайн-партии») | ввод партии («♟ Новая партия · 📋 Вставить PGN») | «♞ Играть»; «⚙ Настройки» — справа. Заменяет прежний порядок, где ввод партии стоял первым. + ## Предложения, требующие согласования - Русский интерфейс по умолчанию с архитектурой для последующего английского перевода.