Desktop: narrow side panel polish (designer review)
- The engine row: the name and depth go under the row when they do not fit beside the evaluation (⚙ covered them in a 240 pt panel); alone, the name is centred. - Stacked: the notation part grows by the engine's lines and settings. - The toolbar wraps a group at a time, without a separator at a row's end. - A move's cell is at most 160 pt (the notation under the board). - The filters over the list cast their shadow to the left; the counter on a line of its own loses its leading dot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4ebb1bb683
commit
c17f5bc1cb
5 changed files with 150 additions and 51 deletions
|
|
@ -299,12 +299,18 @@ impl GameView {
|
|||
let side = if stacked {
|
||||
// The notation under the board, as high as the board leaves; dragging its
|
||||
// edge up gives the notation more and the board less.
|
||||
let rest = (height - board_stack - graph_h - 16.0).max(STACK_BOTTOM_MIN);
|
||||
// The engine's lines and settings come on top of the notation's least
|
||||
// part (their height as last drawn); the board gives way for them.
|
||||
let engine =
|
||||
egui::containers::panel::PanelState::load(ui.ctx(), egui::Id::new("engine_panel"))
|
||||
.map_or(0.0, |p| (p.size().y - ENGINE_ROW).max(0.0));
|
||||
let most = (height - BOARD_MIN - graph_h - 16.0).max(STACK_BOTTOM_MIN);
|
||||
let bottom_least = (STACK_BOTTOM_MIN + engine).min(most);
|
||||
let rest = (height - board_stack - graph_h - 16.0).clamp(bottom_least, most);
|
||||
egui::Panel::bottom("game_side_stacked")
|
||||
.resizable(true)
|
||||
.default_size(rest)
|
||||
.size_range(STACK_BOTTOM_MIN..=most)
|
||||
.size_range(bottom_least..=most)
|
||||
.show(ui, |ui| {
|
||||
self.side_panel(ui, settings, analysis, reference, hub, &mut actions)
|
||||
})
|
||||
|
|
@ -1001,6 +1007,7 @@ impl GameView {
|
|||
actions: &mut Vec<GameAction>,
|
||||
) {
|
||||
ui.add_space(4.0);
|
||||
let mut below = None;
|
||||
ui.horizontal(|ui| {
|
||||
let mut on = analysis.is_on();
|
||||
let label = if on {
|
||||
|
|
@ -1029,50 +1036,69 @@ impl GameView {
|
|||
}
|
||||
}
|
||||
}
|
||||
ui.vertical(|ui| {
|
||||
let name = if analysis.is_on() {
|
||||
analysis.engine_name.clone()
|
||||
} else {
|
||||
settings
|
||||
.active_engine()
|
||||
.map(|e| e.name.clone())
|
||||
.unwrap_or_else(|| tr("No engine selected").into())
|
||||
};
|
||||
ui.label(RichText::new(name).small());
|
||||
match &analysis.status {
|
||||
Status::Starting => {
|
||||
ui.label(RichText::new(tr("starting…")).small().weak());
|
||||
// The engine's name and how it goes: beside the evaluation (two small lines,
|
||||
// or one centred line when there is no status); in a narrow panel, on a line
|
||||
// of their own under the row, shortened.
|
||||
let name = if analysis.is_on() {
|
||||
analysis.engine_name.clone()
|
||||
} else {
|
||||
settings
|
||||
.active_engine()
|
||||
.map(|e| e.name.clone())
|
||||
.unwrap_or_else(|| tr("No engine selected").into())
|
||||
};
|
||||
let status = match &analysis.status {
|
||||
Status::Starting => Some(RichText::new(tr("starting…")).small().weak()),
|
||||
Status::Running => {
|
||||
let depth = analysis.best().map(|l| l.depth).unwrap_or(0);
|
||||
let tail = if analysis.finished {
|
||||
tr(" · done").to_string()
|
||||
} else {
|
||||
trf(
|
||||
" · {n} Mn/s",
|
||||
&[("n", &format!("{:.1}", analysis.nps as f64 / 1e6))],
|
||||
)
|
||||
};
|
||||
Some(
|
||||
RichText::new(format!("{}{tail}", trf("Depth {n}", &[("n", &depth)])))
|
||||
.small()
|
||||
.weak(),
|
||||
)
|
||||
}
|
||||
Status::Failed(e) => {
|
||||
Some(RichText::new(e).small().color(ui.visuals().error_fg_color))
|
||||
}
|
||||
Status::Off => self.review.running().then(|| {
|
||||
RichText::new(tr("paused: the game is being analysed"))
|
||||
.small()
|
||||
.weak()
|
||||
}),
|
||||
};
|
||||
let small = |t: &str| text_width(ui, t, egui::TextStyle::Small);
|
||||
let block = small(&name).max(status.as_ref().map_or(0.0, |s| small(s.text())));
|
||||
let gear = ui
|
||||
.painter()
|
||||
.layout_no_wrap("⚙".into(), egui::FontId::proportional(18.0), Color32::WHITE)
|
||||
.size()
|
||||
.x
|
||||
+ 2.0 * ui.spacing().button_padding.x
|
||||
+ ui.spacing().item_spacing.x;
|
||||
let beside = block + ui.spacing().item_spacing.x <= ui.available_width() - gear;
|
||||
if beside {
|
||||
match &status {
|
||||
Some(st) => {
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(&name).small());
|
||||
ui.label(st.clone());
|
||||
});
|
||||
}
|
||||
Status::Running => {
|
||||
let depth = analysis.best().map(|l| l.depth).unwrap_or(0);
|
||||
let tail = if analysis.finished {
|
||||
tr(" · done").to_string()
|
||||
} else {
|
||||
trf(
|
||||
" · {n} Mn/s",
|
||||
&[("n", &format!("{:.1}", analysis.nps as f64 / 1e6))],
|
||||
)
|
||||
};
|
||||
ui.label(
|
||||
RichText::new(format!("{}{tail}", trf("Depth {n}", &[("n", &depth)])))
|
||||
.small()
|
||||
.weak(),
|
||||
);
|
||||
}
|
||||
Status::Failed(e) => {
|
||||
ui.label(RichText::new(e).small().color(ui.visuals().error_fg_color));
|
||||
}
|
||||
Status::Off => {
|
||||
if self.review.running() {
|
||||
ui.label(
|
||||
RichText::new(tr("paused: the game is being analysed"))
|
||||
.small()
|
||||
.weak(),
|
||||
);
|
||||
}
|
||||
None => {
|
||||
ui.label(RichText::new(&name).small());
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
below = Some((name, status));
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.toggle_value(
|
||||
&mut self.engine_settings_open,
|
||||
|
|
@ -1081,6 +1107,20 @@ impl GameView {
|
|||
.on_hover_text(tr("Engine settings"));
|
||||
});
|
||||
});
|
||||
if let Some((name, status)) = below {
|
||||
ui.horizontal(|ui| {
|
||||
let name = RichText::new(name).small();
|
||||
match status {
|
||||
Some(st) => {
|
||||
ui.label(name);
|
||||
ui.add(egui::Label::new(st).truncate());
|
||||
}
|
||||
None => {
|
||||
ui.add(egui::Label::new(name).truncate());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if self.engine_settings_open {
|
||||
engine_settings(ui, settings, actions);
|
||||
}
|
||||
|
|
@ -1203,10 +1243,33 @@ impl GameView {
|
|||
|
||||
fn toolbar(&mut self, ui: &mut Ui, actions: &mut Vec<GameAction>) {
|
||||
ui.add_space(4.0);
|
||||
// Wraps onto a second row when the side panel is narrow.
|
||||
// Wraps onto a second row when the side panel is narrow, a group at a time
|
||||
// (moves, board and edits, copying, the game analysis): a group that does not
|
||||
// fit the rest of the row starts the next one, without a separator.
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 5.0;
|
||||
let big = |s: &str| RichText::new(s).size(18.0);
|
||||
let next_group = |ui: &mut Ui, icons: &[&str], extra: f32| {
|
||||
let font = egui::FontId::proportional(18.0);
|
||||
let gap = ui.spacing().item_spacing.x;
|
||||
let width: f32 = icons
|
||||
.iter()
|
||||
.map(|i| {
|
||||
ui.painter()
|
||||
.layout_no_wrap((*i).to_owned(), font.clone(), Color32::WHITE)
|
||||
.size()
|
||||
.x
|
||||
+ 2.0 * ui.spacing().button_padding.x
|
||||
+ gap
|
||||
})
|
||||
.sum::<f32>()
|
||||
+ extra;
|
||||
if ui.available_size_before_wrap().x < width + 2.0 * gap + 1.0 {
|
||||
ui.end_row();
|
||||
} else {
|
||||
ui.separator();
|
||||
}
|
||||
};
|
||||
if ui
|
||||
.button(big("⏮"))
|
||||
.on_hover_text(tr("To start (Home)"))
|
||||
|
|
@ -1232,7 +1295,7 @@ impl GameView {
|
|||
let end = self.game.line_end(self.cursor);
|
||||
self.goto(end);
|
||||
}
|
||||
ui.separator();
|
||||
next_group(ui, &["🔃", "↩", "↪"], 0.0);
|
||||
if ui
|
||||
.button(big("🔃"))
|
||||
.on_hover_text(tr("Flip board (F)"))
|
||||
|
|
@ -1254,7 +1317,7 @@ impl GameView {
|
|||
{
|
||||
self.redo();
|
||||
}
|
||||
ui.separator();
|
||||
next_group(ui, &["☰", "📋"], 0.0);
|
||||
ui.menu_button(big("☰"), |ui| {
|
||||
if ui.button(tr("Copy PGN")).clicked() {
|
||||
actions.push(self.copy_pgn());
|
||||
|
|
@ -1304,7 +1367,12 @@ impl GameView {
|
|||
{
|
||||
actions.push(self.copy_pgn());
|
||||
}
|
||||
ui.separator();
|
||||
// A running analysis shows its progress (70) and its × (22) instead.
|
||||
if self.review.progress().is_some() {
|
||||
next_group(ui, &[], 70.0 + 22.0 + 2.0 * 5.0);
|
||||
} else {
|
||||
next_group(ui, &["📈"], 0.0);
|
||||
}
|
||||
self.review_button(ui, actions);
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
|
|
@ -1602,6 +1670,8 @@ const REF_MIN: f32 = 320.0;
|
|||
const BOARD_MIN: f32 = 220.0;
|
||||
const STACK_BOTTOM_MIN: f32 = 300.0;
|
||||
const EVAL_BAR: f32 = 26.0;
|
||||
/// The engine row alone (the "Analysis" toggle), as counted in `STACK_BOTTOM_MIN`.
|
||||
const ENGINE_ROW: f32 = 44.0;
|
||||
|
||||
const SEARCH_TIMES: [Option<u32>; 11] = [
|
||||
Some(2),
|
||||
|
|
|
|||
|
|
@ -1674,8 +1674,14 @@ impl LargeView {
|
|||
let with_format = one_line.is_some_and(|(_, f)| f);
|
||||
let mut back_to_list = false;
|
||||
let alone = self.board_alone();
|
||||
// On a line of its own the counter loses its leading "· ".
|
||||
let counter_text = if one_line.is_some() {
|
||||
counter.as_str()
|
||||
} else {
|
||||
counter.trim_start_matches("· ")
|
||||
};
|
||||
let mut info = |ui: &mut Ui| {
|
||||
let mut text = RichText::new(&counter);
|
||||
let mut text = RichText::new(counter_text);
|
||||
if progress.is_some() {
|
||||
text = text.weak();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -428,7 +428,14 @@ impl Library {
|
|||
.show(ui.ctx(), |ui| {
|
||||
let frame = egui::Frame::side_top_panel(ui.style())
|
||||
.stroke(ui.visuals().window_stroke)
|
||||
.shadow(ui.visuals().window_shadow);
|
||||
// To the left, over the list (the window's own shadow falls
|
||||
// right and down, off the window).
|
||||
.shadow(egui::Shadow {
|
||||
offset: [-6, 0],
|
||||
blur: 16,
|
||||
spread: 0,
|
||||
color: egui::Color32::from_black_alpha(110),
|
||||
});
|
||||
frame.show(ui, |ui| {
|
||||
let inner = rect.shrink2(frame.total_margin().sum() / 2.0);
|
||||
ui.set_min_size(inner.size());
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ pub enum NotationCommand {
|
|||
|
||||
const ROW_H: f32 = 26.0;
|
||||
const NUM_W: f32 = 38.0;
|
||||
/// A move's cell is no wider than this: in a wide panel (the notation under the board)
|
||||
/// the two moves of a row stay together.
|
||||
const CELL_MAX: f32 = 160.0;
|
||||
/// Moves of an engine's better line shown under a marked move.
|
||||
const MARK_LINE_MOVES: usize = 6;
|
||||
|
||||
|
|
@ -136,7 +139,7 @@ impl Row {
|
|||
FontId::proportional(14.0),
|
||||
visuals.weak_text_color(),
|
||||
);
|
||||
let cell_w = (width - NUM_W) / 2.0;
|
||||
let cell_w = ((width - NUM_W) / 2.0).min(CELL_MAX);
|
||||
let cells = [(self.white, 0.0), (self.black, cell_w)];
|
||||
for (id, off) in cells {
|
||||
let cell =
|
||||
|
|
|
|||
|
|
@ -197,13 +197,15 @@ board_stack = min(W − 16 − 26, H − STACK_BOTTOM_MIN − 16)
|
|||
├═════════════════════ разделитель (тянуть) ═══════════════════┤
|
||||
│ Анализ: выкл · Stockfish 19 ⚙ │
|
||||
│ [Нотация] Справочник Отчёт │
|
||||
│ 1 e4 c5 2 Nc3 d6 3 f4 Nf6 │
|
||||
│ 1 │ e4 c5 │ │
|
||||
│ … │
|
||||
│ ⏮ ◀ ▶ ⏭ │ 🔃 ↩ ↪ │ ☰ 📋 │ 📈 │
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- Вместо `Panel::right(side_id)` — `Panel::bottom("game_side_stacked")` с **тем же** содержимым `side_panel()` (строка движка, вкладки, содержимое, панель инструментов). Порядок блоков не меняется; панель инструментов при ширине ≥ 600 — в одну строку.
|
||||
- Нотация в стопке — та же таблица «№ · белые · чёрные» (комментарии и варианты вставлены между строками, поэтому несколько пар в строку невозможны). Ширина клетки хода ограничена `CELL_MAX = 160` (`notation.rs`, `Row::flush`): таблица прижата влево, выделенный ход не растягивается на полэкрана; блоки комментариев и вариантов занимают всю ширину.
|
||||
- Высота нижней части учитывает движок: нижняя граница диапазона — `STACK_BOTTOM_MIN` плюс высота линий движка (когда анализ включён) и панели настроек движка (когда открыта), но не больше верхней границы (доска ≥ `BOARD_MIN`). Доска при этом уменьшается — компоновка (стопка) не меняется. Иначе при включённом анализе нотации остаётся одна строка.
|
||||
- Высота нижней части: по умолчанию — всё, что осталось под доской `board_stack` и графиком; `resizable(true)`, диапазон `STACK_BOTTOM_MIN ..= H − BOARD_MIN − график − 16`. Тянут вверх — доска уменьшается, нотация растёт. egui запоминает высоту отдельно от ширины правой панели (свой `id`).
|
||||
- Доска и полоса оценки — по центру по горизонтали, график оценки — под доской, как сейчас.
|
||||
- «Справочник» в стопке получает всю ширину окна — его колонки помещаются; высоты меньше, таблицы прокручиваются.
|
||||
|
|
@ -233,6 +235,17 @@ board_stack = min(W − 16 − 26, H − STACK_BOTTOM_MIN − 16)
|
|||
- `board_area()`: нижняя граница доски `BOARD_MIN = 220`;
|
||||
- правая панель: верхняя граница `W − BOARD_MIN − 26 − 24`, нижняя — минимум вкладки (§1).
|
||||
|
||||
## 4a. Общие элементы узкой правой панели
|
||||
|
||||
- **Панель инструментов** переносится только между группами (`⏮ ◀ ▶ ⏭` · `🔃 ↩ ↪` · `☰ 📋` · `📈`): группа не разрывается. Ширина группы измеряется до раскладки; если группа не помещается в остаток строки — новая строка; разделитель в конце строки не рисуется.
|
||||
- **Строка движка** при ширине панели меньше нужной для «переключатель · оценка · имя/глубина · ⚙» (измерить): первая строка — «Анализ: вкл +0.19 … ⚙», вторая — «Stockfish 19 · глубина 22 · 2.6 Музл/с» мелким приглушённым текстом, сокращается с «…». ⚙ никогда не рисуется поверх текста. Имя движка без строки состояния (анализ выключен) выравнивается по центру строки, а не по её верху.
|
||||
- **Выдвижная панель фильтров:** тень видна слева: `Shadow { offset: [-6, 0], blur: 16, spread: 0, color: black α 110 }` вместо `window_shadow` (у него смещение вправо-вниз, за край окна, и на тёмной теме тени не видно).
|
||||
- **Шапка таблицы в две строки:** вторая строка начинается со счётчика без ведущего «· ».
|
||||
|
||||
## 5. Проверка
|
||||
|
||||
Снимки при 640×480, 640×800, 640×1000, 720×1000, 800×600, 800×1000, 820/819 × 900, 880/879 × 900, 960×1050, 1400×900: библиотека (фильтры закрыты и открыты поверх, доска), партия («Нотация», «Справочник», анализ включён, отчёт с графиком). Признаки правильности: ничего не обрезано слева, тексты не налезают друг на друга, таблица не уже `TABLE_MIN`, доска не меньше 220, на границах порогов компоновка меняется один раз и не мигает при медленном перетаскивании края окна.
|
||||
|
||||
## Изменения
|
||||
|
||||
- 2026-10-24 (ревью реализации f65668c, 0a2c924, 4ebb1bb): §3.3 — нотация в стопке таблицей с `CELL_MAX` вместо нескольких пар в строку; высота нижней части учитывает движок; добавлен §4a (перенос панели инструментов по группам, строка движка в узкой панели, тень выдвижной панели, вторая строка шапки без «· »). Порог доски поиска «≈ 880» — по формуле `TABLE_MIN_pos + 340`, фактически ≈ 870 (879 — ещё рядом).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue