feat(balance): pending chip in the Donut, Shield and Timeline layouts too
Extends the labeled "Pending +X" chip (with its awaiting-confirmations tooltip) to three more layouts via a shared DrawPendingChip() helper. It draws on the ticker line (the USD value sits on the line below in these layouts, so there's no overlap) and is skipped if it would overflow the card. The remaining draw-list layouts with right-aligned content (Consolidated, Minimal, the grid variants) are left for a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,18 @@ bool FormatTotalEarnings(App* app, std::string& outText, ImU32& outCol) {
|
||||
}
|
||||
|
||||
// Render compact hero line: logo + balance + USD + mining on one line
|
||||
float DrawPendingChip(ImDrawList* dl, ImVec2 pos, float maxRight, ImFont* font, float fontSize) {
|
||||
using namespace material;
|
||||
if (s_dispUnconfirmed <= 1e-9) return 0.0f;
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), TR("baltab_pending_chip"), s_dispUnconfirmed);
|
||||
const float w = font->CalcTextSizeA(fontSize, 10000.0f, 0.0f, buf).x;
|
||||
if (pos.x + w > maxRight) return 0.0f; // would overflow the card — skip rather than overlap
|
||||
dl->AddText(font, fontSize, pos, WithAlpha(Warning(), 230), buf);
|
||||
if (IsRectHovered(pos, ImVec2(pos.x + w, pos.y + fontSize))) Tooltip("%s", TR("baltab_pending_tip"));
|
||||
return w;
|
||||
}
|
||||
|
||||
void RenderCompactHero(App* app, ImDrawList* dl, float availW, float hs, float vs, float heroHeightOverride) {
|
||||
using namespace material;
|
||||
char buf[64];
|
||||
|
||||
@@ -33,6 +33,11 @@ void RenderSharedAddressList(App* app, float listH, float availW, float glassRou
|
||||
void RenderSharedRecentTx(App* app, float recentH, float availW, float hs, float vs);
|
||||
void RenderSyncBar(App* app, ImDrawList* dl, float vs);
|
||||
|
||||
// Draws a labeled "Pending +X" chip (unconfirmed balance) at `pos`, via the draw list only, when there
|
||||
// is unconfirmed balance AND it fits left of `maxRight`. Returns the width drawn (0 if skipped). Adds a
|
||||
// hover tooltip. Shared by the balance layouts so pending isn't visible in only one of them.
|
||||
float DrawPendingChip(ImDrawList* dl, ImVec2 pos, float maxRight, ImFont* font, float fontSize);
|
||||
|
||||
// Total period-earnings for the whole wallet, formatted per the earnings settings. Returns false
|
||||
// (and leaves out* untouched) when the global earnings toggle is off, so layouts show it only when
|
||||
// the user has opted into the earnings view. Shared by RenderCompactHero and the layout totals.
|
||||
|
||||
@@ -748,6 +748,11 @@ static void RenderBalanceDonut(App* app) {
|
||||
dl->AddText(capFont, capFont->LegacySize,
|
||||
ImVec2(ImGui::GetCursorScreenPos().x, tickerY),
|
||||
OnSurfaceMedium(), DRAGONX_TICKER);
|
||||
DrawPendingChip(dl, ImVec2(ImGui::GetCursorScreenPos().x
|
||||
+ capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, DRAGONX_TICKER).x
|
||||
+ Layout::spacingMd(), tickerY),
|
||||
ImGui::GetCursorScreenPos().x + ImGui::GetContentRegionAvail().x,
|
||||
capFont, capFont->LegacySize);
|
||||
ImGui::NewLine();
|
||||
|
||||
// USD value
|
||||
@@ -1663,6 +1668,11 @@ static void RenderBalanceShield(App* app) {
|
||||
dl->AddText(capFont, capFont->LegacySize,
|
||||
ImVec2(ImGui::GetCursorScreenPos().x, pos.y + heroSz.y - capFont->LegacySize),
|
||||
OnSurfaceMedium(), DRAGONX_TICKER);
|
||||
DrawPendingChip(dl, ImVec2(ImGui::GetCursorScreenPos().x
|
||||
+ capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, DRAGONX_TICKER).x
|
||||
+ Layout::spacingMd(), pos.y + heroSz.y - capFont->LegacySize),
|
||||
ImGui::GetCursorScreenPos().x + ImGui::GetContentRegionAvail().x,
|
||||
capFont, capFont->LegacySize);
|
||||
ImGui::NewLine();
|
||||
|
||||
double usd_value = state.getBalanceUSD();
|
||||
@@ -1852,6 +1862,11 @@ static void RenderBalanceTimeline(App* app) {
|
||||
dl->AddText(capFont, capFont->LegacySize,
|
||||
ImVec2(ImGui::GetCursorScreenPos().x, pos.y + heroSz.y - capFont->LegacySize),
|
||||
OnSurfaceMedium(), DRAGONX_TICKER);
|
||||
DrawPendingChip(dl, ImVec2(ImGui::GetCursorScreenPos().x
|
||||
+ capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, DRAGONX_TICKER).x
|
||||
+ Layout::spacingMd(), pos.y + heroSz.y - capFont->LegacySize),
|
||||
ImGui::GetCursorScreenPos().x + ImGui::GetContentRegionAvail().x,
|
||||
capFont, capFont->LegacySize);
|
||||
ImGui::NewLine();
|
||||
|
||||
double usd_value = state.getBalanceUSD();
|
||||
|
||||
Reference in New Issue
Block a user