Center fixture rows around scores and inner crests (by Codex)

This commit is contained in:
Codex committed 2026-10-24 01:32:59 +02:00
1 parent 9a93c4fcc8
commit af60e499a2
7 files changed
+144 -29

No files matched your search

+5 -5
View File
@@ -18,15 +18,15 @@ std::string report_zone(int rank, int count, int tier) {
}
} // namespace
std::string App::report_club_button(const std::string &id, bool away) {
std::string App::report_club_button(const std::string &id, bool name_first) {
const auto *c = world_->find("clubs", id);
if (!c)
return "<span>—</span>";
const auto name = esc(world_->name(*c));
const auto text = "<span class=\"report-club-name\" title=\"" + name +
"\">" + name + "</span>";
return btn("club-detail", away ? text + crest(c, 42) : crest(c, 42) + text,
std::string("report-club-button ") + (away ? "away " : "") +
return btn("club-detail", name_first ? text + crest(c, 42) : crest(c, 42) + text,
std::string("report-club-button ") + (name_first ? "name-first " : "") +
(manager(snap()).value("club", "") == id ? "current" : ""),
"id=\"report-club-" + esc(id) + "\" data-id=\"" + esc(id) + "\"");
}
@@ -55,7 +55,7 @@ std::string App::render_reports(const std::string &mode) {
{"points", "Punkte"}, {"gf", "Tore"}, {"diff", "Diff."}};
std::vector<double> widths;
if (matches)
widths = {1104, 400, 1104}; // Match card has two 2dp borders.
widths = {1224, 160, 1224}; // Match card has two 2dp borders.
else if (strengths) {
widths.push_back(2612 * .38);
for (int i = 0; i < 5; ++i) widths.push_back(2612 * .62 / 5);
@@ -123,7 +123,7 @@ std::string App::render_reports(const std::string &mode) {
(!matches && !strengths && column == 5 ? " form" : "") +
"\" role=\"cell\" style=\"width:" + scalar(widths[column]) + "dp;\">";
if (matches && column != 1)
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 2);
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 0);
else if (!matches && column == 0) {
if (!strengths) {
const auto zone = report_zone(row.value("rank", 0), int(rows.size()), tier);
+13 -23
View File
@@ -562,27 +562,17 @@ std::string App::render_opening() {
const size_t a = size_t(index * 2), b = a + 1;
if (b >= pool.size())
return std::string();
const auto label_for = [&](const Json *c, bool home) {
return "<span class=\"club-label\" style=\"flex:1;justify-content:" +
std::string(home ? "flex-end" : "flex-start") + ";\">" +
(home ? "<span>" + esc(world_->name(*c)) + "</span>" +
crest(c, size)
: crest(c, size) + "<span>" + esc(world_->name(*c)) +
"</span>") +
"</span>";
const auto label_for = [&](const Json *c, bool home, bool visible) {
const auto text = "<span class=\"opening-pair-name\">" +
(visible ? esc(world_->name(*c)) : home ? "Heim" : "Noch nicht gezogen") + "</span>";
const auto logo = visible ? crest(c, size) : "";
return "<span class=\"opening-pair-side " + std::string(home ? "home" : "away") + "\">" +
(home ? text + logo : logo + text) + "</span>";
};
return "<div class=\"row\" style=\"height:100%;gap:18dp;\"><span "
"class=\"small\" style=\"width:40dp;text-align:right;\">" +
std::to_string(index + 1) + "</span>" +
(known > 0 ? label_for(pool[a], true)
: "<span class=\"muted\" "
"style=\"flex:1;text-align:right;\">Heim</span>") +
"<span class=\"muted\" "
"style=\"width:30dp;text-align:center;\">–</span>" +
(known > 1 ? label_for(pool[b], false)
: "<span class=\"muted\" style=\"flex:1;\">Noch nicht "
"gezogen</span>") +
"</div>";
return "<div class=\"opening-pair-row " + std::string(size == 36 ? "compact" : size == 66 ? "current" : "") +
"\"><span class=\"opening-pair-number\"><span>" + std::to_string(index + 1) + "</span></span>" +
label_for(pool[a], true, known > 0) + "<span class=\"opening-pair-versus\"><span>–</span></span>" +
label_for(pool[b], false, known > 1) + "<span class=\"opening-pair-counter\" aria-hidden=\"true\"></span></div>";
};
body = "<h2 style=\"font-size:46dp;\">" +
std::string(opening_page_ == 3 ? "1. Runde" : "DFB-Pokal") +
@@ -600,13 +590,13 @@ std::string App::render_opening() {
const int current = std::max(0, (draw_revealed_ - 1) / 2),
known = draw_revealed_ ? draw_revealed_ - current * 2 : 0;
body += "<div class=\"panel\" style=\"position:absolute;" +
rect(130, 1026, 2348, 126) +
rect(130, 1026, 2352, 126) +
"padding:10dp 28dp;font-size:38dp;\">" +
pair(current, known, 66) + "</div>";
for (int i = std::max(0, current - 3); i < current; ++i)
body +=
"<div style=\"position:absolute;" +
rect(158, 1190 + (i - std::max(0, current - 3)) * 155, 2292, 145) +
rect(158, 1190 + (i - std::max(0, current - 3)) * 155, 2296, 145) +
"border-bottom:2dp var(--border);\">" + pair(i, 2, 42) + "</div>";
body += "<div class=\"bottom-controls\" "
"style=\"justify-content:flex-end;\">" +
@@ -618,7 +608,7 @@ std::string App::render_opening() {
} else {
for (int column = 0; column < 2; ++column) {
body += "<div class=\"panel\" style=\"position:absolute;" +
rect(column * 1321, 154, 1287, 1500) + "padding:12dp 18dp;\">";
rect(column * 1323, 154, 1289, 1500) + "padding:12dp 18dp;\">";
for (int row = 0; row < 16; ++row)
body += "<div style=\"height:92dp;font-size:27dp;border-bottom:1dp "
"var(--border);\">" +
+28 -1
View File
@@ -307,6 +307,7 @@ class App final : public Rml::EventListener {
std::string last_rendered_menu_;
std::optional<float> training_scroll_;
std::optional<float> report_scroll_;
float fixture_half_width_ = -1.f;
std::string last_report_state_, report_picker_, report_detail_kind_,
report_detail_club_, report_detail_player_, report_detail_return_focus_,
report_option_to_scroll_;
@@ -603,7 +604,7 @@ class App final : public Rml::EventListener {
void init_desktop();
std::string widget(const std::string &, const Json &);
std::string render_reports(const std::string &);
std::string report_club_button(const std::string &, bool away = false);
std::string report_club_button(const std::string &, bool name_first = false);
std::string render_report_detail();
bool report_detail_action(const std::string &, Rml::Element *);
std::string report_picker(const std::string &, double, double);
@@ -686,6 +687,7 @@ class App final : public Rml::EventListener {
dirty_ = true;
}
void render() {
fixture_half_width_ = -1.f;
// A window-close save prompt can leave a menu while its local dialog is
// open. Never keep that menu's modal/input gate in the destination view.
if (menu_ != last_rendered_menu_) {
@@ -790,6 +792,29 @@ class App final : public Rml::EventListener {
if (auto *button = element("popup")->QuerySelector("button"))
button->Focus();
}
bool center_fixture_columns() {
auto *list = element("report-list");
if (!list || !list->IsClassSet("match-list"))
return false;
auto *score = list->QuerySelector(".report-cell.score");
if (!score)
return false;
const auto &box = list->GetBox();
// Rml rounds borders to physical pixels. Use the actual full inner width,
// independently of the scrollport, so fractional density cannot move scores.
const float inner = box.GetSize(Rml::BoxArea::Border).x -
box.GetEdge(Rml::BoxArea::Border, Rml::BoxEdge::Left) -
box.GetEdge(Rml::BoxArea::Border, Rml::BoxEdge::Right);
const float half = std::max(0.f, (inner - score->GetBox().GetSize(Rml::BoxArea::Border).x) / 2.f);
if (std::abs(half - fixture_half_width_) < .001f)
return false;
fixture_half_width_ = half;
Rml::ElementList sides;
list->QuerySelectorAll(sides, ".report-cell.first,.report-cell:last-child");
for (auto *side : sides)
side->SetProperty("width", scalar(half) + "px");
return true;
}
void frame() {
flush_selects();
if (ticket_)
@@ -801,6 +826,8 @@ class App final : public Rml::EventListener {
context_->Update();
if (center_selects(*doc_))
context_->Update();
if (center_fixture_columns())
context_->Update();
if (training_scroll_) {
if (auto *roster = element("training-roster"))
roster->SetScrollTop(*training_scroll_);