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.
This commit is contained in:
+25
-5
@@ -39,6 +39,10 @@ popover.background > contents { background-color: @theme_bg_color; }
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.status-panel.compact {
|
||||||
|
padding: 2px 10px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
.status-bar button {
|
.status-bar button {
|
||||||
background-image: linear-gradient(to top, alpha(@theme_fg_color, 0.16), alpha(@theme_fg_color, 0.05));
|
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);
|
border: 1px solid alpha(@theme_fg_color, 0.3);
|
||||||
@@ -167,17 +171,33 @@ void MainWindow::refresh_leaderboard() {
|
|||||||
|
|
||||||
auto* title = Gtk::make_managed<Gtk::Label>();
|
auto* title = Gtk::make_managed<Gtk::Label>();
|
||||||
title->set_markup("<b>Best Times</b>");
|
title->set_markup("<b>Best Times</b>");
|
||||||
|
title->set_xalign(0.0f);
|
||||||
box_leaderboard_.append(*title);
|
box_leaderboard_.append(*title);
|
||||||
|
|
||||||
|
box_leaderboard_.append(*Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::HORIZONTAL));
|
||||||
|
|
||||||
|
auto* grid = Gtk::make_managed<Gtk::Grid>();
|
||||||
|
grid->set_column_spacing(16);
|
||||||
|
grid->set_row_spacing(3);
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
for (const auto& diff : {Minefield::DifficultyEasy, Minefield::DifficultyMedium,
|
for (const auto& diff : {Minefield::DifficultyEasy, Minefield::DifficultyMedium,
|
||||||
Minefield::DifficultyHard, Minefield::DifficultyExpert}) {
|
Minefield::DifficultyHard, Minefield::DifficultyExpert}) {
|
||||||
auto* row = Gtk::make_managed<Gtk::Label>();
|
auto* name = Gtk::make_managed<Gtk::Label>(diff.name);
|
||||||
row->set_xalign(0.0f);
|
name->set_xalign(0.0f);
|
||||||
|
grid->attach(*name, 0, row, 1, 1);
|
||||||
|
|
||||||
|
auto* time = Gtk::make_managed<Gtk::Label>();
|
||||||
auto best = leaderboard_.best_time(diff.name);
|
auto best = leaderboard_.best_time(diff.name);
|
||||||
std::string time_str = best ? format_time(*best) : "—";
|
time->set_text(best ? format_time(*best) : "—");
|
||||||
row->set_text(diff.name + ": " + time_str);
|
time->set_hexpand(true);
|
||||||
box_leaderboard_.append(*row);
|
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<Gtk::Button>("Clear scores");
|
auto* clear_btn = Gtk::make_managed<Gtk::Button>("Clear scores");
|
||||||
clear_btn->set_margin_top(8);
|
clear_btn->set_margin_top(8);
|
||||||
|
|||||||
Reference in New Issue
Block a user