From 06b692b140ea2057bfc5b8ebf45f370ed64d7a51 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sat, 1 Aug 2026 17:11:48 +0100 Subject: [PATCH] Leaderboard: two-column grid with right-aligned LCD time panels Difficulty names left-aligned, times right-aligned in compact status-panel chips so all columns line up; separator under the title. --- src/window.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/window.cpp b/src/window.cpp index 2ec3101..88a870d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -39,6 +39,10 @@ popover.background > contents { background-color: @theme_bg_color; } font-family: monospace; font-weight: bold; } +.status-panel.compact { + padding: 2px 10px; + font-weight: normal; +} .status-bar button { background-image: linear-gradient(to top, alpha(@theme_fg_color, 0.16), alpha(@theme_fg_color, 0.05)); border: 1px solid alpha(@theme_fg_color, 0.3); @@ -167,17 +171,33 @@ void MainWindow::refresh_leaderboard() { auto* title = Gtk::make_managed(); title->set_markup("Best Times"); + title->set_xalign(0.0f); box_leaderboard_.append(*title); + box_leaderboard_.append(*Gtk::make_managed(Gtk::Orientation::HORIZONTAL)); + + auto* grid = Gtk::make_managed(); + grid->set_column_spacing(16); + grid->set_row_spacing(3); + + int row = 0; for (const auto& diff : {Minefield::DifficultyEasy, Minefield::DifficultyMedium, Minefield::DifficultyHard, Minefield::DifficultyExpert}) { - auto* row = Gtk::make_managed(); - row->set_xalign(0.0f); + auto* name = Gtk::make_managed(diff.name); + name->set_xalign(0.0f); + grid->attach(*name, 0, row, 1, 1); + + auto* time = Gtk::make_managed(); auto best = leaderboard_.best_time(diff.name); - std::string time_str = best ? format_time(*best) : "—"; - row->set_text(diff.name + ": " + time_str); - box_leaderboard_.append(*row); + time->set_text(best ? format_time(*best) : "—"); + time->set_hexpand(true); + time->set_xalign(1.0f); // Right-align all times in one column + time->add_css_class("status-panel"); + time->add_css_class("compact"); + grid->attach(*time, 1, row, 1, 1); + ++row; } + box_leaderboard_.append(*grid); auto* clear_btn = Gtk::make_managed("Clear scores"); clear_btn->set_margin_top(8);