A number pad with soft keys and a column of function keys; no coloured left edges

The entry of a number shows its value in a display with the allowed range, proposals
as chips, the digits as soft keys and backspace, clear and maximum as a coloured
column. The first digit key replaces the offered value. Marked rows and the bank's
readings no longer carry a coloured bar at their left edge.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 21:00:05 +01:00
1 parent b3e5ef4b4d
commit fe4b034181
7 files changed
+64 -57

No files matched your search

+21 -7
View File
@@ -27,6 +27,7 @@ void App::open_amount(AmountRequest request) {
request.return_focus = context_->GetFocusElement()->GetId();
amount_ = AmountDraft{std::move(request), {}, {}, menu_, false, input_revision(), world_};
amount_->raw = std::to_string(amount_->request.value);
amount_untouched_ = true;
amount_select_all_ = true;
amount_caret_end_ = false;
focus_after_render_ = "calculator-value";
@@ -95,12 +96,16 @@ std::string App::render_amount() {
}
out += "<section class=\"amount-box\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"calculator-title\">"
"<header class=\"amount-header\">" + button("calc-cancel", "×", "amount-close", "id=\"calculator-close\" aria-label=\"Zahleneingabe schließen\"") +
"<h2 id=\"calculator-title\">" + esc(r.title) + "</h2></header><label class=\"amount-label\">" +
"<h2 id=\"calculator-title\">" + esc(r.title) + "</h2></header><div class=\"amount-display\"></div><label class=\"amount-label\">" +
esc(r.unit == "Stück" ? "Stückzahl" : r.unit.empty() ? "Wert" : r.unit == "€" ? "Betrag in Euro" : "Betrag in " + r.unit) +
"</label><input type=\"text\" id=\"calculator-value\" maxlength=\"8\" value=\"" + esc(amount_->raw) +
"\" aria-label=\"" + esc(r.title) + "\"/><div class=\"amount-context\"><span class=\"amount-limit\"><span>" +
esc(number(r.min) + " – " + number(r.max) + (r.unit.empty() ? "" : " " + r.unit)) + "</span></span>" +
button("calc-clear", "C", "amount-clear", "id=\"calculator-clear\"") + button("calc-max", "MAX", "amount-max", "id=\"calculator-max\"") + "</div>";
esc("Möglich: " + number(r.min) + " – " + number(r.max) + (r.unit.empty() ? "" : " " + r.unit)) + "</span></span></div>"
"<p class=\"amount-proposals-label\">Vorschläge</p>";
// a pad of digits; beside it the three keys that act on the whole number
const double pad_top = 518, key_width = 200, key_height = 110, key_gap = 16;
out += button("calc-clear", "C", "amount-function amount-clear", "id=\"calculator-clear\" aria-label=\"Eingabe löschen\" style=\"" + rect(26 + 3 * (key_width + key_gap), pad_top + 162, key_width, 152) + "\"") +
button("calc-max", "MAX", "amount-function amount-max", "id=\"calculator-max\" aria-label=\"Höchstwert einsetzen\" style=\"" + rect(26 + 3 * (key_width + key_gap), pad_top + 324, key_width, 164) + "\"");
const int64_t first = std::max<int64_t>(1, (r.min + r.suggestion_step - 1) / r.suggestion_step);
const auto value = amount_value();
for (int i = 0; i < 6; ++i) {
@@ -108,12 +113,18 @@ std::string App::render_amount() {
const bool enabled = proposal >= r.min && proposal <= r.max && (proposal - r.min) % r.step == 0;
out += button("calc-preset", number(proposal), "amount-proposal" + std::string(value && *value == proposal ? " selected" : ""),
"id=\"calculator-preset-" + std::to_string(i) + "\" data-value=\"" + std::to_string(proposal) + "\" style=\"" +
rect(26 + (i % 2) * 388, 334 + (i / 2) * 74, 376, 64) + "\" " + (enabled ? "" : "disabled"));
rect(26 + (i % 3) * 288, 356 + (i / 3) * 76, 272, 64) + "\" " + (enabled ? "" : "disabled"));
}
const std::array<const char *, 12> keys = {"7","8","9","4","5","6","1","2","3","0","00","←"};
for (int i = 0; i < 12; ++i)
out += button("calc-digit", keys[size_t(i)], "amount-key", "id=\"calculator-key-" + std::to_string(i) + "\" data-id=\"" +
keys[size_t(i)] + "\" style=\"" + rect(26 + (i % 3) * 258, 566 + (i / 3) * 98, 248, 88) + "\"");
for (int i = 0; i < 12; ++i) {
// 0 is two keys wide; the backspace heads the column of function keys
const auto place = i == 11 ? rect(26 + 3 * (key_width + key_gap), pad_top, key_width, 152)
: i == 9 ? rect(26, pad_top + 3 * (key_height + key_gap), 2 * key_width + key_gap, key_height)
: i == 10 ? rect(26 + 2 * (key_width + key_gap), pad_top + 3 * (key_height + key_gap), key_width, key_height)
: rect(26 + (i % 3) * (key_width + key_gap), pad_top + (i / 3) * (key_height + key_gap), key_width, key_height);
out += button("calc-digit", keys[size_t(i)], i == 11 ? "amount-function amount-erase" : "amount-key",
"id=\"calculator-key-" + std::to_string(i) + "\" data-id=\"" + keys[size_t(i)] + "\" " + (i == 11 ? "aria-label=\"Letzte Ziffer löschen\" " : "") + "style=\"" + place + "\"");
}
const auto error = amount_error();
out += "<p id=\"calculator-feedback\" class=\"amount-feedback " + std::string(error.empty() ? "" : "invalid") + "\"><span>" +
esc(error.empty() ? r.review ? "Nach „Übernehmen“ wird der Betrag noch einmal bestätigt." : "Erst „Übernehmen“ bestätigt den Wert." : error) +
@@ -163,6 +174,7 @@ bool App::amount_action(const std::string &action, Rml::Element *target) {
if (auto *input = dynamic_cast<Rml::ElementFormControlInput *>(element("calculator-value"))) input->GetSelection(&start, &end, nullptr);
start = std::clamp(start, 0, int(amount_->raw.size()));
end = std::clamp(end, start, int(amount_->raw.size()));
if (amount_untouched_) { start = 0; end = int(amount_->raw.size()); }
if (digit == "←") {
if (start == end && start) --start;
amount_->raw.erase(size_t(start), size_t(end - start));
@@ -173,6 +185,7 @@ bool App::amount_action(const std::string &action, Rml::Element *target) {
if (next.size() <= 8) amount_->raw = std::move(next);
}
} else return false;
amount_untouched_ = false;
update_amount(true);
return true;
}
@@ -205,6 +218,7 @@ bool App::amount_event(Rml::Event &event) {
if ((type == "input" || type == "change") && target->GetId() == "calculator-value") {
if (!amount_->review) {
amount_->raw = dynamic_cast<Rml::ElementFormControlInput *>(target)->GetValue();
amount_untouched_ = false;
update_amount();
}
event.StopImmediatePropagation(); return true;
+2
View File
@@ -452,6 +452,8 @@ class App final : public Rml::EventListener {
std::string almanac_day_, almanac_match_, almanac_tab_ = "lineups";
std::optional<AmountDraft> amount_;
bool amount_select_all_ = false, amount_caret_end_ = false;
// the offered value is still as it was opened: the first digit key replaces it
bool amount_untouched_ = false;
std::string bank_view_ = "entrance", bank_hint_;
int bank_property_ = 0, bank_owned_ = 0, bank_stock_ = 11;
bool balance_future_ = false;