feat(ui): width-responsiveness — content max-width cap + per-surface form/input clamps

Wide/ultrawide (1440-3440px) responsiveness was unhealthy: no page/content-level
max-width cap existed, and every card/form/table derived width from raw
GetContentRegionAvail().x with floor-only clamps, so surfaces stretched edge-to-edge
(2000-3000px inputs, ballooning cards, giant grid cells, 2000px+ dead row-voids).

Root cause: adopt the (previously dead-code) clamp helpers.
- New Layout::kContentMaxWidth() (~1600dp, tunable via ui.toml [layout]
  content-max-width; <=0 disables). Cap ##ContentArea to it and center the column in
  wider windows — every tab derives from this child, so one change tames the app at
  wide widths. No-op below the cap (fills as before), so 1080p/1440p are unaffected.

Per-surface upper-clamps (std::min(cap*dp, expr), floors preserved) where a single
element is still too wide even within the capped column:
- Settings: Theme/Layout/Language combos, the font-scale slider (~3000px -> 360dp),
  the effect sliders, Explorer URL and RPC credential fields.
- Send / Receive: cap the compose / receive cards to a readable form width and center
  them (Indent(pad+offset) so the auto-layout fields align with the hand-drawn card);
  the recent-tx lists below keep the full column width.
- Chat message bubbles + composer, mining pool URL/payout inputs + stats left/right
  split, contacts search, and the lite-network add-server row / server cards / status
  panel (capped + centered).
- Wizard: vertically center the cards when they fit (was top-anchored, leaving a void
  on tall monitors), compensating the content-height measurement so it can't oscillate.

The 1600 cap also subsumes the fixed-4-column balance grids (~400px cards) and the
right-anchored row dead-gaps (voids shrink from ~2700px to ~800px), so those are left
to the cap rather than blind column/row redesigns.

Verified at 1024/1280 (and via a temporary 900dp cap to exercise the cap+center path,
since the test display clamps to 1280) across full-node + Lite + Windows (ctest green)
and an adversarial diff review (clean). The true wide/ultrawide look and the 1600dp cap
value still want eyes on a real wide monitor.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-18 23:15:39 -05:00
parent ce8c7696d4
commit 9205addf55
11 changed files with 127 additions and 42 deletions

View File

@@ -399,7 +399,9 @@ void RenderMiningStats(const WalletState& state, const MiningInfo& mining,
ImVec2 cardMin = ImGui::GetCursorScreenPos();
// A bit wider than the old 25%/180dp so the pool rows fit the "<hashrate> N% fee" text.
float leftW = std::clamp(availWidth * 0.30f, 210.0f * dp, availWidth * 0.45f);
// Ratio ceiling (0.45) never binds on a wide window, so give leftW an
// absolute cap too — the pool card doesn't need to be enormous.
float leftW = std::clamp(availWidth * 0.30f, 210.0f * dp, 440.0f * dp);
float colGap = gap;
float rightW = availWidth - leftW - colGap;
@@ -414,6 +416,15 @@ void RenderMiningStats(const WalletState& state, const MiningInfo& mining,
RenderLeftPoolCard(app, state, dl, capFont, sub1, ovFont, dp, gap, pad,
leftMin, leftMax, s_pool_url, s_pool_settings_dirty);
// rightW is uncapped, so the chart/hint band it draws would sprawl the
// full panel on a wide window. Constrain just the drawn content to a
// centered ~1000dp band inside the panel's padded content region; the
// glass panel itself still fills rightW, leftover -> side margin.
const float rightContentW = rightW - pad * 2.0f;
const float chartBandW = std::min(rightContentW, 1000.0f * dp);
const float chartBandX = rightMin.x + pad
+ std::max(0.0f, (rightContentW - chartBandW) * 0.5f);
// Right panel: live log (if toggled + available) else the sparkline.
if (showLogView) {
float logPad = pad * 0.5f;
@@ -422,14 +433,14 @@ void RenderMiningStats(const WalletState& state, const MiningInfo& mining,
state.pool_mining.log_lines, "##PoolLogText");
} else if (hasChartContent) {
DrawHashrateSparkline(dl,
ImVec2(rightMin.x + pad, rightMin.y + statRowH * 0.5f),
ImVec2(rightMax.x - pad, rightMax.y),
ImVec2(chartBandX, rightMin.y + statRowH * 0.5f),
ImVec2(chartBandX + chartBandW, rightMax.y),
chartHistory, capFont, dp);
} else {
const char* hint = TR("mining_chart_start");
ImVec2 hs = capFont->CalcTextSizeA(capFont->LegacySize, FLT_MAX, 0, hint);
dl->AddText(capFont, capFont->LegacySize,
ImVec2((rightMin.x + rightMax.x - hs.x) * 0.5f,
ImVec2(chartBandX + (chartBandW - hs.x) * 0.5f,
(rightMin.y + rightMax.y - hs.y) * 0.5f),
OnSurfaceDisabled(), hint);
}