refactor: rewrite sidebar layout with two-pass architecture
Replace fragile Dummy()-based cursor flow with a deterministic two-pass layout system: - Pass 1: compute exact Y positions for all elements (pure math) - Pass 2: render at computed positions using SetCursorScreenPos + draw list Eliminates the dual-coordinate mismatch that caused persistent centering and overflow bugs. Height is computed once, not estimated then measured. Also tune sidebar spacing via ui.toml: - button-spacing: 4 → 6 - section-gap: 4 → 8 - Add section-label-pad-bottom (4px) below category labels - bottom-padding: 0 → 4
This commit is contained in:
17
src/app.cpp
17
src/app.cpp
@@ -1507,8 +1507,16 @@ void App::renderStatusBar()
|
||||
}
|
||||
|
||||
if (s_blocks_per_sec > 0.1) {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Syncing %.1f%% (%d left, %.0f blk/s)",
|
||||
state_.sync.verification_progress * 100.0, blocksLeft, s_blocks_per_sec);
|
||||
int eta_sec = (int)(blocksLeft / s_blocks_per_sec);
|
||||
char eta[32];
|
||||
if (eta_sec >= 3600)
|
||||
snprintf(eta, sizeof(eta), "%dh %dm", eta_sec / 3600, (eta_sec % 3600) / 60);
|
||||
else if (eta_sec >= 60)
|
||||
snprintf(eta, sizeof(eta), "%dm %ds", eta_sec / 60, eta_sec % 60);
|
||||
else
|
||||
snprintf(eta, sizeof(eta), "%ds", eta_sec);
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Syncing %.1f%% (%d left, %.0f blk/s, ~%s)",
|
||||
state_.sync.verification_progress * 100.0, blocksLeft, s_blocks_per_sec, eta);
|
||||
} else {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.0f, 1.0f), "Syncing %.1f%% (%d left)",
|
||||
state_.sync.verification_progress * 100.0, blocksLeft);
|
||||
@@ -2799,11 +2807,10 @@ void App::renderLoadingOverlay(float contentH)
|
||||
const char* descText = state_.warmup_description.c_str();
|
||||
ImFont* capFont = Type().caption();
|
||||
if (!capFont) capFont = ImGui::GetFont();
|
||||
// Wrap to barW so long descriptions don't overflow
|
||||
ImVec2 ts = capFont->CalcTextSizeA(capFont->LegacySize, FLT_MAX, barW, descText);
|
||||
ImVec2 ts = capFont->CalcTextSizeA(capFont->LegacySize, FLT_MAX, 0.0f, descText);
|
||||
dl->AddText(capFont, capFont->LegacySize,
|
||||
ImVec2(wp.x + cx - ts.x * 0.5f, curY),
|
||||
IM_COL32(160, 160, 160, 200), descText, nullptr, barW);
|
||||
IM_COL32(160, 160, 160, 200), descText);
|
||||
curY += ts.y + gap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user