client: skip used grants; scale the engineering UI with the window
Foundation / checks (deploy) (push) Successful in 3m26s
Foundation / checks (ecs) (push) Successful in 2m2s
Foundation / checks (client) (push) Successful in 12m47s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 11m44s
Foundation / checks (checks) (push) Canceled after 17m14s
Foundation / checks (postgres) (push) Canceled after 4m27s
Foundation / checks (deploy) (push) Successful in 3m26s
Foundation / checks (ecs) (push) Successful in 2m2s
Foundation / checks (client) (push) Successful in 12m47s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 11m44s
Foundation / checks (checks) (push) Canceled after 17m14s
Foundation / checks (postgres) (push) Canceled after 4m27s
- A stale_grant before Welcome spends only that grant: the session tries the next one in the bundle and ends as exhausted when none is left (other refusals still stop). - UI scale (ADR-0084 amendment): embedded scalable font (ProggyForever), scale from logical window height (720 reference, 1.0-2.5) times a Ctrl+= / Ctrl+- nudge; panel sizes and table columns in logical units; movable panels placed again per scale. - --size W,H for engineering review screenshots. - Tests: client_remote_session (stale grant, exhausted), client_ui_state (scale). Refresh the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -276,6 +276,12 @@ int main(int argc, char** argv) try {
|
||||
scripted_pick = parse_point(argv[++i]);
|
||||
if (!scripted_pick)
|
||||
return 2;
|
||||
} else if (arg == "--size" && i + 1 < argc) { // Initial window size, WIDTH,HEIGHT.
|
||||
const auto size = parse_point(argv[++i]);
|
||||
if (!size || size->x < 320 || size->y < 240)
|
||||
return 2;
|
||||
config.width = static_cast<int>(size->x);
|
||||
config.height = static_cast<int>(size->y);
|
||||
} else if (arg == "--screenshot" && i + 1 < argc) { // Last frame, as BMP.
|
||||
screenshot = argv[++i];
|
||||
} else if (arg == "--controls" && i + 1 < argc) {
|
||||
@@ -286,7 +292,7 @@ int main(int argc, char** argv) try {
|
||||
show_controls = true;
|
||||
} else {
|
||||
std::fputs("usage: evo-client [--version] [--renderer NAME] [--hidden] "
|
||||
"[--frames 1..100000]\n"
|
||||
"[--frames 1..100000] [--size W,H]\n"
|
||||
" [--fixture | --connect HOST:PORT --server-name NAME "
|
||||
"--ca FILE --grants FILE]\n"
|
||||
" [--layer water|nitrogen|...|heat|moisture]\n"
|
||||
|
||||
+51
-32
@@ -9,6 +9,18 @@
|
||||
namespace evo::client_app {
|
||||
namespace {
|
||||
using client::LaunchPhase;
|
||||
// Logical sizes at the current UI scale (window height and Ctrl+= / Ctrl+-).
|
||||
float px(float v) {
|
||||
return v * ImGui::GetStyle().FontScaleMain;
|
||||
}
|
||||
// A panel placed once (the user may move or resize it), and again at each new UI scale.
|
||||
ImGuiCond placed(float& seen) {
|
||||
const float scale = ImGui::GetStyle().FontScaleMain;
|
||||
if (scale == seen)
|
||||
return ImGuiCond_FirstUseEver;
|
||||
seen = scale;
|
||||
return ImGuiCond_Always;
|
||||
}
|
||||
ImVec4 color(render::Color c) {
|
||||
return {static_cast<float>(c.red) / 255.0F, static_cast<float>(c.green) / 255.0F,
|
||||
static_cast<float>(c.blue) / 255.0F, static_cast<float>(c.alpha) / 255.0F};
|
||||
@@ -31,7 +43,7 @@ void row(const char* label, const std::string& value, const std::string& unit =
|
||||
}
|
||||
void swatch(const char* id, render::Color c, const char* label) {
|
||||
ImGui::ColorButton(id, color(c), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoAlpha,
|
||||
{14, 14});
|
||||
{px(14), px(14)});
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted(label);
|
||||
}
|
||||
@@ -93,14 +105,14 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
|
||||
{0.5F, 0.5F});
|
||||
ImGui::SetNextWindowSize({520, 0}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({std::min(px(520), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
|
||||
ImGui::Begin("Aeternalis Evolution - engineering client", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
ImGui::TextWrapped("Choose a data source. Nothing here is a game or a player account.");
|
||||
if (ImGui::SmallButton("Controls..."))
|
||||
a.open_controls = true;
|
||||
ImGui::Separator();
|
||||
if (ImGui::Button("Local fixture", {160, 0}))
|
||||
if (ImGui::Button("Local fixture", {px(160), 0}))
|
||||
a.fixture = true;
|
||||
ImGui::SameLine();
|
||||
ImGui::TextWrapped("In-memory stand-in: environment changes and static organisms. Not a "
|
||||
@@ -112,7 +124,7 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
||||
ImGui::InputText("Server name", form.server_name.data(), form.server_name.size());
|
||||
ImGui::InputText("Dev CA file", form.authority.data(), form.authority.size());
|
||||
ImGui::InputText("Grant bundle file", form.grants.data(), form.grants.size());
|
||||
const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {160, 0});
|
||||
const bool start = phase == LaunchPhase::choosing && ImGui::Button("Connect", {px(160), 0});
|
||||
ImGui::EndDisabled();
|
||||
if (start)
|
||||
a.connect = true;
|
||||
@@ -122,15 +134,15 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
||||
error_text(*v.form_error);
|
||||
if (phase == LaunchPhase::connecting) {
|
||||
ImGui::TextColored(amber, "Connecting (TLS handshake and grant check)...");
|
||||
if (ImGui::Button("Cancel", {120, 0}))
|
||||
if (ImGui::Button("Cancel", {px(120), 0}))
|
||||
a.cancel = true;
|
||||
}
|
||||
if (phase == LaunchPhase::failed) {
|
||||
error_text(v.launcher->error());
|
||||
if (ImGui::Button("Retry", {120, 0}))
|
||||
if (ImGui::Button("Retry", {px(120), 0}))
|
||||
a.retry = true;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", {120, 0}))
|
||||
if (ImGui::Button("Cancel", {px(120), 0}))
|
||||
a.cancel = true;
|
||||
}
|
||||
ImGui::TextDisabled("Files are read when you connect; nothing is saved.");
|
||||
@@ -139,7 +151,7 @@ void launcher(const PanelView& v, FormBuffers& form, PanelActions& a) {
|
||||
|
||||
void banner(const PanelView& v, PanelActions& a) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, 4}, ImGuiCond_Always, {0.5F, 0});
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, px(4)}, ImGuiCond_Always, {0.5F, 0});
|
||||
ImGui::Begin("##mode", nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
|
||||
@@ -166,8 +178,10 @@ void banner(const PanelView& v, PanelActions& a) {
|
||||
}
|
||||
|
||||
void legend(const PanelView& v, render::EnvironmentDisplay& display) {
|
||||
ImGui::SetNextWindowPos({8, 40}, ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize({300, 0}, ImGuiCond_FirstUseEver);
|
||||
static float seen = 0;
|
||||
const auto when = placed(seen);
|
||||
ImGui::SetNextWindowPos({px(8), px(40)}, when);
|
||||
ImGui::SetNextWindowSize({px(300), 0}, when);
|
||||
ImGui::Begin("Legend");
|
||||
int current = display.mode == render::EnvironmentDisplay::Mode::moisture
|
||||
? static_cast<int>(world::field_count)
|
||||
@@ -213,8 +227,10 @@ void legend(const PanelView& v, render::EnvironmentDisplay& display) {
|
||||
|
||||
void inspector(const PanelView& v) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, 40}, ImGuiCond_FirstUseEver, {1, 0});
|
||||
ImGui::SetNextWindowSize({420, 0}, ImGuiCond_FirstUseEver);
|
||||
static float seen = 0;
|
||||
const auto when = placed(seen);
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), px(40)}, when, {1, 0});
|
||||
ImGui::SetNextWindowSize({px(420), 0}, when);
|
||||
ImGui::Begin("Inspector");
|
||||
const auto* env = v.environment ? v.environment->current() : nullptr;
|
||||
const auto* orgs = v.organisms ? v.organisms->current() : nullptr;
|
||||
@@ -235,7 +251,7 @@ void inspector(const PanelView& v) {
|
||||
}
|
||||
if (cell != nullptr && ImGui::BeginTable("fields", 2, ImGuiTableFlags_RowBg)) {
|
||||
// Values wrap inside the column so missing/not-requested explanations stay readable.
|
||||
ImGui::TableSetupColumn("field", ImGuiTableColumnFlags_WidthFixed, 150);
|
||||
ImGui::TableSetupColumn("field", ImGuiTableColumnFlags_WidthFixed, px(150));
|
||||
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
|
||||
for (std::size_t k = 0; k < world::field_count; ++k) {
|
||||
const auto field = static_cast<world::Field>(k);
|
||||
@@ -274,7 +290,7 @@ void controls(const PanelView& v, PanelActions& a) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x * 0.5F, io.DisplaySize.y * 0.5F}, ImGuiCond_Always,
|
||||
{0.5F, 0.5F});
|
||||
ImGui::SetNextWindowSize({std::min(460.0F, io.DisplaySize.x - 16), 0}, ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize({std::min(px(460), io.DisplaySize.x - px(16)), 0}, ImGuiCond_Always);
|
||||
ImGui::Begin("Controls", nullptr,
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoSavedSettings);
|
||||
@@ -282,8 +298,8 @@ void controls(const PanelView& v, PanelActions& a) {
|
||||
"wheel (zoom) are fixed. Escape cancels a key capture.");
|
||||
if (ImGui::BeginTable("bindings", 3, ImGuiTableFlags_RowBg)) {
|
||||
ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Primary", ImGuiTableColumnFlags_WidthFixed, 120);
|
||||
ImGui::TableSetupColumn("Secondary", ImGuiTableColumnFlags_WidthFixed, 150);
|
||||
ImGui::TableSetupColumn("Primary", ImGuiTableColumnFlags_WidthFixed, px(120));
|
||||
ImGui::TableSetupColumn("Secondary", ImGuiTableColumnFlags_WidthFixed, px(150));
|
||||
ImGui::TableHeadersRow();
|
||||
for (std::size_t k = 0; k < client::action_count; ++k) {
|
||||
const auto action = static_cast<client::Action>(k);
|
||||
@@ -299,7 +315,7 @@ void controls(const PanelView& v, PanelActions& a) {
|
||||
(v.capturing == here ? std::string{"Press a key"} : key_label(key)) + "##" +
|
||||
std::to_string(k) + (secondary ? "s" : "p");
|
||||
ImGui::BeginDisabled(v.capturing.has_value());
|
||||
if (ImGui::Button(label.c_str(), {100, 0}))
|
||||
if (ImGui::Button(label.c_str(), {px(100), 0}))
|
||||
a.capture_key = here;
|
||||
if (secondary && key != client::no_key) {
|
||||
ImGui::SameLine();
|
||||
@@ -314,7 +330,7 @@ void controls(const PanelView& v, PanelActions& a) {
|
||||
if (v.capturing) {
|
||||
ImGui::TextColored(amber, "Press a key for %s (Escape cancels).",
|
||||
std::string{client::action_name(v.capturing->action)}.c_str());
|
||||
if (ImGui::Button("Cancel capture", {140, 0}))
|
||||
if (ImGui::Button("Cancel capture", {px(140), 0}))
|
||||
a.cancel_capture = true;
|
||||
}
|
||||
if (v.controls_problem) {
|
||||
@@ -323,13 +339,13 @@ void controls(const PanelView& v, PanelActions& a) {
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::BeginDisabled(v.capturing.has_value());
|
||||
if (ImGui::Button("Apply", {100, 0}))
|
||||
if (ImGui::Button("Apply", {px(100), 0}))
|
||||
a.apply_controls = true;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reset defaults", {130, 0}))
|
||||
if (ImGui::Button("Reset defaults", {px(130), 0}))
|
||||
a.reset_controls = true;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", {100, 0}))
|
||||
if (ImGui::Button("Cancel", {px(100), 0}))
|
||||
a.close_controls = true;
|
||||
ImGui::EndDisabled();
|
||||
ImGui::End();
|
||||
@@ -339,8 +355,10 @@ void session(const PanelView& v) {
|
||||
if (!v.remote)
|
||||
return;
|
||||
const auto& io = ImGui::GetIO();
|
||||
ImGui::SetNextWindowPos({8, io.DisplaySize.y - 8}, ImGuiCond_FirstUseEver, {0, 1});
|
||||
ImGui::SetNextWindowSize({360, 0}, ImGuiCond_FirstUseEver);
|
||||
static float seen = 0;
|
||||
const auto when = placed(seen);
|
||||
ImGui::SetNextWindowPos({px(8), io.DisplaySize.y - px(8)}, when, {0, 1});
|
||||
ImGui::SetNextWindowSize({px(360), 0}, when);
|
||||
ImGui::Begin("Session");
|
||||
const auto& s = *v.remote;
|
||||
if (ImGui::BeginTable("status", 3, ImGuiTableFlags_SizingFixedFit)) {
|
||||
@@ -406,9 +424,9 @@ void session(const PanelView& v) {
|
||||
// once space frees). Notices are not the outcome record (Session panel is).
|
||||
void notices(const PanelView& v, PanelActions& a) {
|
||||
const auto& io = ImGui::GetIO();
|
||||
const float width = std::min(notice_width, io.DisplaySize.x - 16);
|
||||
const float width = std::min(px(notice_width), io.DisplaySize.x - px(16));
|
||||
const float top = io.DisplaySize.y * 0.4F;
|
||||
float y = io.DisplaySize.y - 8;
|
||||
float y = io.DisplaySize.y - px(8);
|
||||
const auto list = v.ui->notices();
|
||||
std::size_t hidden = 0;
|
||||
for (auto it = list.rbegin(); it != list.rend(); ++it) {
|
||||
@@ -417,7 +435,7 @@ void notices(const PanelView& v, PanelActions& a) {
|
||||
++hidden;
|
||||
continue;
|
||||
}
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::SetNextWindowSize({width, 0}, ImGuiCond_Always);
|
||||
const std::string id = notice_window_prefix + std::to_string(n.id);
|
||||
ImGui::Begin(id.c_str(), nullptr,
|
||||
@@ -425,7 +443,8 @@ void notices(const PanelView& v, PanelActions& a) {
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
if (ImGui::BeginTable("notice", 2)) {
|
||||
ImGui::TableSetupColumn("text", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed, notice_close_width);
|
||||
ImGui::TableSetupColumn("close", ImGuiTableColumnFlags_WidthFixed,
|
||||
px(notice_close_width));
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, n.level == client::NoticeLevel::error ? red
|
||||
@@ -434,15 +453,15 @@ void notices(const PanelView& v, PanelActions& a) {
|
||||
ImGui::TextWrapped("%s", n.text.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button(("x" + id).c_str(), {notice_close_width, 0}))
|
||||
if (ImGui::Button(("x" + id).c_str(), {px(notice_close_width), 0}))
|
||||
a.dismiss_notice = n.id;
|
||||
ImGui::EndTable();
|
||||
}
|
||||
y -= ImGui::GetWindowHeight() + 4;
|
||||
y -= ImGui::GetWindowHeight() + px(4);
|
||||
ImGui::End();
|
||||
}
|
||||
if (v.ui->evicted_notices() > 0 || hidden > 0) {
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - 8, y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::SetNextWindowPos({io.DisplaySize.x - px(8), y}, ImGuiCond_Always, {1, 1});
|
||||
ImGui::Begin("##evicted", nullptr,
|
||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
@@ -463,10 +482,10 @@ void dialog(const PanelView& v, PanelActions& a) {
|
||||
ImGui::OpenPopup(id.c_str());
|
||||
if (ImGui::BeginPopupModal(id.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::TextWrapped("%s", d->body.c_str());
|
||||
if (ImGui::Button("Confirm", {120, 0}))
|
||||
if (ImGui::Button("Confirm", {px(120), 0}))
|
||||
a.confirm_dialog = d->id;
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", {120, 0}))
|
||||
if (ImGui::Button("Cancel", {px(120), 0}))
|
||||
a.cancel_dialog = d->id;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -609,7 +609,13 @@ class RemoteSession {
|
||||
reason == SessionCloseReason::rate_limited ||
|
||||
reason == SessionCloseReason::stale_epoch ||
|
||||
(was_established && reason == SessionCloseReason::expired);
|
||||
if (reason == SessionCloseReason::superseded) {
|
||||
if (reason == SessionCloseReason::stale_grant && !was_established) {
|
||||
// This grant (or a newer one) was already presented, by this or another client:
|
||||
// only this grant is spent, so try the next one; an empty bundle ends as exhausted.
|
||||
launcher.observe(client::ConnectSignal::not_ready);
|
||||
notify(ui, "That grant was already used; trying the next one.",
|
||||
client::NoticeLevel::info);
|
||||
} else if (reason == SessionCloseReason::superseded) {
|
||||
// Another client holds this account's newer grant: never fight it.
|
||||
launcher.fail(client::LaunchError::grant_refused);
|
||||
notify(ui, "Another client opened a session with this account.",
|
||||
|
||||
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261009T144507-0d1e:1791570907"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261009T160344-74ca:1791575624"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
@@ -116,3 +116,18 @@ one frame late for same-batch input. This internal use is tied to the 1.92.9b pi
|
||||
and must be rechecked on any toolkit update (the lifecycle and panel tests fail if
|
||||
it regresses). External capture no longer cancels the Tab toggle. Mode and remote
|
||||
session lifetime are owned together (`SessionHost`).
|
||||
|
||||
## Amendment (2026-10-09): scalable font and UI scale
|
||||
The maintainer asked that the UI grow with the window, after a maximized window left it
|
||||
at 13 px.
|
||||
- **Font.** The client now loads Dear ImGui's embedded scalable font, ProggyForever
|
||||
(`AddFontDefaultVector`), in place of the ProggyClean bitmap font. Both are embedded
|
||||
in the pinned 1.92.9b sources, and the package's notice inventory already lists
|
||||
them. No new dependency.
|
||||
- **UI scale.** Logical window height over 720, clamped to 1.0–2.5, times a user nudge
|
||||
of 0.5–2.0 in steps of 0.1 (Ctrl+= and Ctrl+-, consumed before world input and not
|
||||
saved). Display DPI is already in the logical size, through SDL's high-pixel-density
|
||||
window and the renderer's framebuffer scale.
|
||||
- **Applying it.** The scale goes to ImGui's `FontScaleMain` and to `ScaleAllSizes`,
|
||||
taken from the unscaled style. Panel sizes are given in logical units at that scale.
|
||||
Movable panels return to their default place and size once, at each new scale.
|
||||
|
||||
@@ -5325,3 +5325,31 @@ Executed:
|
||||
- Windows `client` 9/9.
|
||||
- Windows `client-network` 15/15. This also covers the session-cap change above, whose
|
||||
`client-network` run had been blocked by the running client.
|
||||
|
||||
## 2026-10-09 — engineering client: used grants and UI scale
|
||||
|
||||
The maintainer found that their login failures came from a grant that had already been
|
||||
used. The client had given up on the first `stale_grant`. Now a used grant spends only
|
||||
itself: the session tries the next grant in the bundle, and a bundle of used grants ends
|
||||
as exhausted. Other refusals still stop at once. The maintainer also reported that the
|
||||
UI stayed at 13 px in a maximized window.
|
||||
|
||||
ADR-0084 amendment:
|
||||
- the embedded scalable font;
|
||||
- a UI scale from window height (720-point reference, 1.0–2.5) times a Ctrl+= / Ctrl+-
|
||||
nudge;
|
||||
- panel sizes and table columns in logical units;
|
||||
- movable panels placed again at each new scale.
|
||||
|
||||
`--size W,H` sets the initial window size, for engineering review.
|
||||
|
||||
Executed:
|
||||
- `client_remote_session`: a stale grant moves to the next grant; an all-used bundle
|
||||
ends as exhausted.
|
||||
- `client_ui_state`: scale clamps, nudge grid, nonsense inputs.
|
||||
- Windows `client` 9/9 and `client-network` 15/15.
|
||||
- Screenshots of the launcher and the fixture at 960×640 and 1920×1080, reviewed: the
|
||||
scale is 1.5 at 1080, text is crisp, and the inspector labels fit.
|
||||
|
||||
Not run: an RDP display-scale check. Under RDP the logical height drives the scale, the
|
||||
same as on a local display.
|
||||
|
||||
@@ -46,4 +46,14 @@ class UiState {
|
||||
std::vector<Notice> notices_;
|
||||
std::optional<Dialog> dialog_;
|
||||
};
|
||||
|
||||
// Engineering UI scale. The UI grows with the window: logical height over a 720-point
|
||||
// reference, clamped to [1, 2.5] (display DPI is already in the logical size), times the
|
||||
// user's nudge, clamped to [0.5, 2]. A non-finite or non-positive input counts as 1.
|
||||
inline constexpr float ui_reference_height = 720.0F;
|
||||
inline constexpr float ui_window_min = 1.0F, ui_window_max = 2.5F;
|
||||
inline constexpr float ui_user_min = 0.5F, ui_user_max = 2.0F, ui_user_step = 0.1F;
|
||||
[[nodiscard]] float ui_scale(int logical_height, float user) noexcept;
|
||||
// One nudge up (+1) or down (-1), kept on the 0.1 grid and within the user range.
|
||||
[[nodiscard]] float ui_user_nudge(float user, int direction) noexcept;
|
||||
} // namespace evo::client
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "evo/client/application.hpp"
|
||||
#include "evo/client/ui_state.hpp"
|
||||
#include "render/sdl_renderer.hpp"
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include <SDL3/SDL_main.h>
|
||||
@@ -41,11 +42,26 @@ struct Toolkit {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.IniFilename = nullptr; // Nothing is persisted (no paths, no window layout).
|
||||
io.LogFilename = nullptr;
|
||||
if (io.Fonts->AddFontDefaultBitmap() == nullptr)
|
||||
// The embedded scalable font (ProggyForever, notices kept per ADR-0084): the UI
|
||||
// scales with the window, which the bitmap font cannot do cleanly.
|
||||
if (io.Fonts->AddFontDefaultVector() == nullptr)
|
||||
return false;
|
||||
base_style = ImGui::GetStyle();
|
||||
platform = ImGui_ImplSDL3_InitForSDLRenderer(window, target);
|
||||
return platform && attach_renderer(target);
|
||||
}
|
||||
// Applies a UI scale to sizes and fonts from the unscaled style, only when it changes.
|
||||
void scale(float factor) {
|
||||
if (factor == applied)
|
||||
return;
|
||||
auto& style = ImGui::GetStyle();
|
||||
style = base_style;
|
||||
style.ScaleAllSizes(factor);
|
||||
style.FontScaleMain = factor;
|
||||
applied = factor;
|
||||
}
|
||||
ImGuiStyle base_style;
|
||||
float applied{1};
|
||||
bool attach_renderer(SDL_Renderer* target) {
|
||||
renderer = ImGui_ImplSDLRenderer3_Init(target);
|
||||
return renderer;
|
||||
@@ -120,7 +136,8 @@ struct Application::Impl {
|
||||
std::string renderer_name;
|
||||
WindowState state;
|
||||
std::optional<Error> failure;
|
||||
Toolkit toolkit; // After window/renderer: destroyed first.
|
||||
Toolkit toolkit; // After window/renderer: destroyed first.
|
||||
float ui_user{1}; // The user's UI scale nudge (Ctrl+= / Ctrl+-); not persisted.
|
||||
Overlay overlay;
|
||||
InputState input;
|
||||
Bindings bindings{Bindings::defaults()};
|
||||
@@ -322,6 +339,20 @@ std::expected<void, Error> Application::poll_events() {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// UI scale nudge, a view setting (Ctrl+= / Ctrl+-): consumed before the toolkit and
|
||||
// the world, and its repeats and release with it.
|
||||
if (keyboard && known && event.type == SDL_EVENT_KEY_DOWN &&
|
||||
(event.key.mod & SDL_KMOD_CTRL) != 0) {
|
||||
const auto k = event.key.key;
|
||||
const int direction = k == SDLK_EQUALS || k == SDLK_PLUS || k == SDLK_KP_PLUS ? 1
|
||||
: k == SDLK_MINUS || k == SDLK_KP_MINUS ? -1
|
||||
: 0;
|
||||
if (direction != 0) {
|
||||
p.ui_user = client::ui_user_nudge(p.ui_user, direction);
|
||||
p.owned_keys.set(code);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Toolkit first: widgets see every event before world input is derived.
|
||||
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||
if (event.type == SDL_EVENT_QUIT)
|
||||
@@ -472,6 +503,7 @@ std::expected<Step, Error> Application::present(const render::Frame& frame) {
|
||||
}
|
||||
if (p.overlay) {
|
||||
// Engineering UI over the immutable frame; the callback reads copies only.
|
||||
p.toolkit.scale(client::ui_scale(p.state.logical_height, p.ui_user));
|
||||
ImGui_ImplSDLRenderer3_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "evo/client/ui_state.hpp"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
namespace evo::client {
|
||||
@@ -53,4 +54,19 @@ bool UiState::close_dialog(std::uint64_t id) {
|
||||
dialog_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
float ui_scale(int logical_height, float user) noexcept {
|
||||
const auto clamp = [](float v, float lo, float hi) {
|
||||
return !std::isfinite(v) || v <= 0 ? 1.0F : std::clamp(v, lo, hi);
|
||||
};
|
||||
const float window =
|
||||
logical_height > 0 ? static_cast<float>(logical_height) / ui_reference_height : 1.0F;
|
||||
return clamp(window, ui_window_min, ui_window_max) * clamp(user, ui_user_min, ui_user_max);
|
||||
}
|
||||
|
||||
float ui_user_nudge(float user, int direction) noexcept {
|
||||
const float base = !std::isfinite(user) || user <= 0 ? 1.0F : user;
|
||||
const float tenths = std::round(base / ui_user_step) + static_cast<float>(direction);
|
||||
return std::clamp(tenths * ui_user_step, ui_user_min, ui_user_max);
|
||||
}
|
||||
} // namespace evo::client
|
||||
|
||||
@@ -323,6 +323,22 @@ void refusals(Region& r) {
|
||||
r.epoch = 5;
|
||||
CHECK(one.until(r, [&] { return one.phase() == LaunchPhase::failed; }));
|
||||
CHECK(one.host.launcher().error() == LaunchError::grants_exhausted);
|
||||
// A used grant spends only itself: the next grant in the bundle connects, and a bundle
|
||||
// of used grants ends as exhausted rather than refused.
|
||||
Client first;
|
||||
CHECK(first.host.connect(RemoteSession::open(r.material({r.grant(account(5), 2)}))));
|
||||
CHECK(first.until(r, [&] { return first.phase() == LaunchPhase::connected; }));
|
||||
first.host.cancel();
|
||||
Client next;
|
||||
CHECK(next.host.connect(RemoteSession::open(
|
||||
r.material({r.grant(account(5), 1), r.grant(account(5), 2), r.grant(account(5), 3)}))));
|
||||
CHECK(next.until(r, [&] { return next.phase() == LaunchPhase::connected; }, 20));
|
||||
next.host.cancel();
|
||||
Client used;
|
||||
CHECK(used.host.connect(
|
||||
RemoteSession::open(r.material({r.grant(account(5), 2), r.grant(account(5), 3)}))));
|
||||
CHECK(used.until(r, [&] { return used.phase() == LaunchPhase::failed; }, 20));
|
||||
CHECK(used.host.launcher().error() == LaunchError::grants_exhausted);
|
||||
// Nothing to open: an unresolvable endpoint or an empty bundle.
|
||||
auto bad = r.material({r.grant(account(4), 1)});
|
||||
bad.endpoint.host = "no-such-host.invalid";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "evo/client/ui_state.hpp"
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
@@ -9,6 +10,20 @@ void check(bool ok) {
|
||||
throw std::runtime_error("UI state contract");
|
||||
}
|
||||
int main() try {
|
||||
// UI scale: grows with the window from a 720-point reference, clamped, times the
|
||||
// user's nudge on a 0.1 grid; nonsense inputs count as 1.
|
||||
const auto near = [](float a, float b) { return std::fabs(a - b) < 1e-4F; };
|
||||
check(near(ui_scale(640, 1), 1.0F) && near(ui_scale(720, 1), 1.0F));
|
||||
check(near(ui_scale(1080, 1), 1.5F) && near(ui_scale(2160, 1), 2.5F)); // Clamped.
|
||||
check(near(ui_scale(1080, 1.2F), 1.8F) && near(ui_scale(720, 5), 2.0F));
|
||||
check(near(ui_scale(0, 1), 1.0F) && near(ui_scale(720, -1), 1.0F) &&
|
||||
near(ui_scale(720, std::nanf("")), 1.0F));
|
||||
check(near(ui_user_nudge(1, 1), 1.1F) && near(ui_user_nudge(1.1F, -1), 1.0F));
|
||||
check(near(ui_user_nudge(2, 1), 2.0F) && near(ui_user_nudge(0.5F, -1), 0.5F));
|
||||
float user = 1;
|
||||
for (int i = 0; i < 7; ++i)
|
||||
user = ui_user_nudge(user, 1);
|
||||
check(near(user, 1.7F)); // No drift off the grid.
|
||||
UiState ui;
|
||||
check(ui.advance(100).has_value());
|
||||
auto first = ui.notify("Connected", NoticeLevel::info, 10);
|
||||
|
||||
Reference in New Issue
Block a user