Retain live ticker controls during independent detail navigation (by Codex)

This commit is contained in:
Codex committed 2026-10-27 21:03:45 +01:00
1 parent d3ea650c07
commit 1fb6499b15
5 files changed
+116 -18

No files matched your search

+18 -5
View File
@@ -88,16 +88,20 @@ bool App::live_action(const std::string &action, Rml::Element *target) {
if (!action.starts_with("live-")) return false;
if (scene_ != "live" || !live_.available()) return true;
const auto id = target ? target->GetAttribute<Rml::String>("data-id", "") : "";
bool detail_only = false, ticker_only = false;
if (!live_dialog_.empty() && action != "live-dialog-cancel" && action != "live-dialog-apply" && action != "live-tactic-cycle") return true;
if (action == "live-back") { live_close(); return true; }
if (action == "live-owner-prev" || action == "live-owner-next") {
live_.cycle_owner(action == "live-owner-prev" ? -1 : 1); live_reset_detail_ = true;
if (!live_.cycle_owner(action == "live-owner-prev" ? -1 : 1)) return true;
live_reset_detail_ = detail_only = true;
} else if (action == "live-tab") {
if (id != "team" && id != "tactics" && id != "opponent" && id != "table" && id != "stats") return true;
live_tab_ = id; live_reset_detail_ = true;
if (live_tab_ == id) return true;
live_tab_ = id; live_reset_detail_ = detail_only = true;
} else if (action == "live-filter") {
if (id != "all" && id != "highlights" && id != "goal" && id != "yellow") return true;
live_filter_ = id; live_reset_ticker_ = true;
if (live_filter_ == id) return true;
live_filter_ = id; live_reset_ticker_ = ticker_only = true;
} else if (action == "live-coverage") {
if (id != "all" && id != "single" && id != "conference") return true;
live_coverage_ = id; live_reset_ticker_ = true;
@@ -114,7 +118,7 @@ bool App::live_action(const std::string &action, Rml::Element *target) {
} else if (action == "live-next") {
live_.next(); live_last_tick_ = SDL_GetTicks64();
} else if (action == "live-pause") {
live_set_speed(live_.speed() ? 0 : 1);
live_set_speed(live_.speed() ? 0 : 1); return true;
} else if (action == "live-review" && live_.finished()) {
postmatch_open();return true;
} else if (action == "live-review-back") {
@@ -140,6 +144,12 @@ bool App::live_action(const std::string &action, Rml::Element *target) {
} catch (const std::exception &) { return true; }
} else return true;
if (target && focus_after_render_.empty()) focus_after_render_ = target->GetId();
if (detail_only || ticker_only) {
live_detail_pending_ = live_detail_pending_ || detail_only;
live_ticker_pending_ = live_ticker_pending_ || ticker_only;
dirty_ = true;
return true;
}
refresh(); return true;
}
bool App::live_event(Rml::Event &event) {
@@ -151,7 +161,7 @@ bool App::live_event(Rml::Event &event) {
if (type == "mousedown" && speed_control) live_speed_dragging_ = true;
if (type == "mouseup" && live_speed_dragging_) {
live_speed_dragging_ = false; live_last_tick_ = SDL_GetTicks64();
focus_after_render_ = "live-speed"; needs_render_ = true;
focus_after_render_ = "live-speed"; dirty_ = true;
}
if ((type == "change" || type == "input") && speed_control) {
if (setting_menu_markup_) return true;
@@ -209,6 +219,9 @@ Json App::live_snapshot() const {
status["drafts"] = live_drafts_; status["dialog_draft"] = live_dialog_draft_;
status["ticker_scroll"] = element("live-ticker") ? element("live-ticker")->GetScrollTop() : live_ticker_scroll_;
status["frame"] = live_.frame();
// Diagnostic counts describe actual DOM updates, not hardware timing claims.
status["ui_updates"] = {{"document", document_generation_},
{"detail", live_detail_updates_}, {"ticker", live_ticker_updates_}};
if (live_.available()) { status["owners"] = live_.fixture().at("owners"); status["matches"] = live_.fixture().at("matches"); }
return status;
}
+66 -13
View File
@@ -136,6 +136,24 @@ std::string App::live_dialog_markup(const Json &owner) {
btn("live-dialog-apply", "Demovorschau anzeigen", "", "id=\"live-dialog-apply\" " + std::string(live_dialog_ == "lineup" && (live_out_.empty() || live_in_.empty()) ? "disabled" : "")) + "</div>";
return "<div class=\"live-dialog-layer\"><div id=\"live-dialog\" class=\"live-dialog\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"live-dialog-heading\">" + body + "</div></div>";
}
std::string App::live_ticker_events(const Json &frame, size_t &shown) {
const auto &fixture = live_.fixture();
shown = 0;
std::string out;
for (auto i = frame.at("events").rbegin(); i != frame.at("events").rend(); ++i) {
const auto &event = *i; const auto kind = event.value("kind", "");
if (live_coverage_ == "single" && event.at("match_id") != live_selected_match_) continue;
if (live_filter_ == "goal" && kind != "goal") continue;
if (live_filter_ == "yellow" && kind != "yellow" && kind != "red") continue;
if (live_filter_ == "highlights" && kind != "goal" && kind != "chance" && kind != "red") continue;
const auto &match = live_match_by_id(fixture.at("matches"), event.at("match_id"));
out += "<article class=\"live-event " + std::string(kind == "goal" ? "is-goal" : "") + "\" data-live-event=\"" + esc(event.at("id").get<std::string>()) + "\">" + live_text(std::to_string(event.at("minute").get<int>()) + "′", "live-event-time") + live_badge(match.at(event.at("side").get<std::string>()), 54) +
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
++shown;
}
if (!shown) out += "<p class=\"live-note\">" + live_text("Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
return out;
}
std::string App::render_live() {
if(live_review_) return render_postmatch();
if (!live_.available()) return "";
@@ -168,19 +186,8 @@ std::string App::render_live() {
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 4>{{{"all", "Alles"}, {"highlights", "Highlights"}, {"goal", "Tore"}, {"yellow", "Karten"}}}) out += btn("live-filter", label, live_filter_ == id ? "selected" : "", "id=\"live-filter-" + std::string(id) + "\" data-id=\"" + id + "\"");
out += "</nav><div id=\"live-ticker\" class=\"live-event-list\" tabindex=\"0\" aria-label=\"Gemeinsamer Ereignisverlauf\">";
size_t shown = 0;
for (auto i = frame.at("events").rbegin(); i != frame.at("events").rend(); ++i) {
const auto &event = *i; const auto kind = event.value("kind", "");
if (live_coverage_ == "single" && event.at("match_id") != live_selected_match_) continue;
if (live_filter_ == "goal" && kind != "goal") continue;
if (live_filter_ == "yellow" && kind != "yellow" && kind != "red") continue;
if (live_filter_ == "highlights" && kind != "goal" && kind != "chance" && kind != "red") continue;
const auto &match = live_match_by_id(fixture.at("matches"), event.at("match_id"));
out += "<article class=\"live-event " + std::string(kind == "goal" ? "is-goal" : "") + "\" data-live-event=\"" + esc(event.at("id").get<std::string>()) + "\">" + live_text(std::to_string(event.at("minute").get<int>()) + "′", "live-event-time") + live_badge(match.at(event.at("side").get<std::string>()), 54) +
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
++shown;
}
if (!shown) out += "<p class=\"live-note\">" + live_text("Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
out += "</div><footer class=\"live-ticker-footer\">" + live_text(std::to_string(shown) + " Meldungen · feste Aufzeichnung", "live-small") + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + live_text(owner.at("team").at("name")) + "</h2><p>" + live_text(owner.at("name")) + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
out += live_ticker_events(frame, shown);
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung") + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
btn("live-owner-prev", arrow(false), "", "id=\"live-owner-prev\" aria-label=\"Vorheriger Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + btn("live-owner-next", arrow(true), "", "id=\"live-owner-next\" aria-label=\"Nächster Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + "</nav></header><nav class=\"live-tabs\">";
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 5>{{{"team", "Team"}, {"tactics", "Taktik"}, {"opponent", "Gegner"}, {"table", "Live-Tabelle"}, {"stats", "Statistik"}}}) out += btn("live-tab", label, live_tab_ == id ? "selected" : "", "id=\"live-tab-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (live_tab_ == id ? "true" : "false") + "\"");
out += "</nav><div id=\"live-detail-body\" class=\"live-detail-body\" tabindex=\"0\">" + live_detail(owner, frame) + "</div><footer class=\"live-detail-footer\">" + btn("live-intervene-lineup", "Aufstellung & Wechsel", "", "id=\"live-lineup-edit\" " + std::string(live_.finished() ? "disabled" : "")) + "</footer></aside></div>";
@@ -200,3 +207,49 @@ void App::live_after_render() {
for (auto *node : controls) { node->SetProperty("pointer-events", "none"); node->SetAttribute("tabindex", "-1"); }
}
}
// Apply local navigation only after event dispatch. The untouched match cards,
// ticker and speed input retain their DOM identity, focus and pointer capture.
void App::live_update_parts() {
if (!live_detail_pending_ && !live_ticker_pending_ && focus_after_render_.empty()) return;
if (scene_ != "live" || live_review_ || !live_.available() ||
!live_dialog_.empty() || !popup_.empty()) {
live_detail_pending_ = live_ticker_pending_ = false;
return;
}
const auto frame = live_.frame();
if (live_detail_pending_) {
const auto owner = live_owner();
auto *body = element("live-detail-body");
auto *team = element("live-owner-team");
auto *name = element("live-owner-name");
if (!body || !team || !name) { refresh(); return; }
team->SetInnerRML(esc(owner.at("team").at("name").get<std::string>()));
name->SetInnerRML(esc(owner.at("name").get<std::string>()));
body->SetInnerRML(live_detail(owner, frame));
body->SetScrollTop(0); live_detail_scroll_ = 0; live_reset_detail_ = false;
Rml::ElementList tabs; doc_->QuerySelectorAll(tabs, "#live-detail .live-tabs button");
for (auto *tab : tabs) {
const bool selected = tab->GetAttribute<Rml::String>("data-id", "") == live_tab_;
tab->SetClass("selected", selected); tab->SetAttribute("aria-pressed", selected ? "true" : "false");
}
++live_detail_updates_;
}
if (live_ticker_pending_) {
auto *list = element("live-ticker"); auto *count = element("live-event-count");
if (!list || !count) { refresh(); return; }
size_t shown = 0; list->SetInnerRML(live_ticker_events(frame, shown));
count->SetInnerRML(esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung"));
list->SetScrollTop(0); live_ticker_scroll_ = 0; live_reset_ticker_ = false;
Rml::ElementList filters; doc_->QuerySelectorAll(filters, ".live-filters button");
for (auto *filter : filters)
filter->SetClass("selected", filter->GetAttribute<Rml::String>("data-id", "") == live_filter_);
++live_ticker_updates_;
}
live_detail_pending_ = live_ticker_pending_ = false;
if (!focus_after_render_.empty()) {
if (auto *node = element(focus_after_render_)) node->Focus(keyboard_navigation_);
focus_after_render_.clear();
}
dirty_ = true;
}
+4
View File
@@ -10,6 +10,10 @@
bool live_speed_dragging_ = false, live_review_ = false,
live_reset_detail_ = false, live_reset_ticker_ = false,
live_restore_scroll_ = false;
bool live_detail_pending_ = false, live_ticker_pending_ = false;
uint64_t live_detail_updates_ = 0, live_ticker_updates_ = 0;
std::string live_ticker_events(const Json &frame, size_t &shown);
void live_update_parts();
float live_ticker_scroll_ = 0, live_detail_scroll_ = 0;
std::string render_live();
std::string live_roster(const Json &owner);
+5
View File
@@ -369,6 +369,7 @@ class App final : public Rml::EventListener {
bool focus_ticket_ = false;
std::set<std::string> pending_selects_;
std::string focus_after_render_;
uint64_t document_generation_ = 0;
bool keyboard_navigation_ = false, setting_menu_markup_ = false;
std::string last_rendered_menu_;
std::optional<float> training_scroll_;
@@ -958,6 +959,8 @@ class App final : public Rml::EventListener {
markup += render_menu(menu_);
setting_menu_markup_ = true;
element("canvas")->SetInnerRML(markup);
++document_generation_;
live_detail_pending_ = live_ticker_pending_ = false;
element("canvas")->SetProperty("overflow", statistics_trophy_.contains("asset") ? "visible" : "hidden");
setting_menu_markup_ = false;
if (manager_confirm_ || manager_success_) {
@@ -1097,6 +1100,8 @@ class App final : public Rml::EventListener {
ticket_->update();
if (needs_render_)
render();
else
live_update_parts();
if(files_default_pending_&&!files_capturing_){update_files_default_thumbnail();render();}
persist_working_desktop();
render_popup();