From c09a2374f2686e1de4dacaf0f2d82e7e26b180bf Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 20 Nov 2026 16:47:39 -0600 Subject: [PATCH] feat(balance): mining-rewards shield parity across all layouts (F040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UX audit (deferred item): the "Mining Rewards" element is now shield-aware in every balance layout, not just the classic card. A shared helper set (miningRewardsActivate/Tooltip/Hover) shields waiting coinbase on click (ShieldDialog::showShieldCoinbase when unshielded, else opens Receive) with the same tooltip the card uses. The classic card and the dashboard tile loop (new TileInfo.isMiningRewards flag) route through it; the 8 previously non-interactive layouts (donut, consolidated, vertical-stack/2x2, shield, timeline, two-row, minimal) gain a hit-rect with the same behavior — no layout geometry changed. Build + tests green. (Analyzed read-only in a workflow; every old_string verified against the file and the helper logic reviewed before applying.) Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/balance_tab.cpp | 59 ++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/src/ui/windows/balance_tab.cpp b/src/ui/windows/balance_tab.cpp index 585aabb..3d31f55 100644 --- a/src/ui/windows/balance_tab.cpp +++ b/src/ui/windows/balance_tab.cpp @@ -56,6 +56,29 @@ static void FormatFiatFallback(char* buf, size_t n, double price_usd) { else snprintf(buf, n, "%s", TR("price_unavailable")); } +// Shared "Mining Rewards" behavior for every balance layout: waiting (unshielded) rewards are shielded +// on click, otherwise the click opens Receive. Tooltip matches the classic card. +static bool miningRewardsUnshielded() { return s_dispTransparent > 0.0; } + +static void miningRewardsActivate(App* app) { + if (miningRewardsUnshielded()) ShieldDialog::showShieldCoinbase(); + else app->setCurrentPage(NavPage::Receive); +} + +static void miningRewardsTooltip() { + const bool unshielded = miningRewardsUnshielded(); + material::Tooltip("%s%s%s", TR("mining_card_tooltip"), unshielded ? "\n\n" : "", + unshielded ? TR("mining_card_click_to_shield") : ""); +} + +// Hit-rect for layouts that draw the Mining Rewards element with the draw list (no ImGui item). +static void miningRewardsHover(App* app, ImVec2 mn, ImVec2 mx) { + if (!material::IsRectHovered(mn, mx)) return; + ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + miningRewardsTooltip(); + if (ImGui::IsMouseClicked(0)) miningRewardsActivate(app); +} + static void RenderBalanceClassic(App* app); static void RenderBalanceDonut(App* app); static void RenderBalanceConsolidated(App* app); @@ -597,12 +620,8 @@ static void RenderBalanceClassic(App* app) dl->AddRect(cMin, cMax, IM_COL32(255, 255, 255, (int)S.drawElement("tabs.balance", "hover-glow-alpha").sizeOr(40.0f)), cardSpec.rounding, 0, S.drawElement("tabs.balance", "hover-glow-thickness").sizeOr(1.5f) * dp); ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); - material::Tooltip("%s%s%s", TR("mining_card_tooltip"), unshielded ? "\n\n" : "", - unshielded ? TR("mining_card_click_to_shield") : ""); - if (ImGui::IsMouseClicked(0)) { - if (unshielded) ShieldDialog::showShieldCoinbase(); - else app->setCurrentPage(NavPage::Receive); - } + miningRewardsTooltip(); + if (ImGui::IsMouseClicked(0)) miningRewardsActivate(app); } } @@ -865,6 +884,11 @@ static void RenderBalanceDonut(App* app) { dl->AddCircleFilled(ImVec2(legendX + 5 * dp, legendY + capFont->LegacySize * 0.5f), legendDotR, Warning()); snprintf(buf, sizeof(buf), TR("baltab_mining_amount"), s_dispTransparent); dl->AddText(capFont, capFont->LegacySize, ImVec2(legendX + legendXOff, legendY), Warning(), buf); + { // Mining Rewards legend line: shield-aware tooltip + click + float legW = capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, buf).x; + miningRewardsHover(app, ImVec2(legendX, legendY), + ImVec2(legendX + legendXOff + legW, legendY + capFont->LegacySize)); + } legendY += capFont->LegacySize + legendSectionGap; // Market price @@ -1055,6 +1079,8 @@ static void RenderBalanceConsolidated(App* app) { barY += barH + 2 * dp; snprintf(buf, sizeof(buf), "%.8f (%.0f%%)", s_dispTransparent, transRatio * 100.0f); dl->AddText(capFont, capFont->LegacySize, ImVec2(transX, barY), OnSurfaceMedium(), buf); + miningRewardsHover(app, ImVec2(transX, divY + Layout::spacingSm()), + ImVec2(transX + halfW, barY + capFont->LegacySize)); // Sync bar at card bottom — clipped to rounded corners if (state.sync.syncing && state.sync.headers > 0) { @@ -1154,6 +1180,7 @@ static void RenderBalanceDashboard(App* app) { const char* icon; NavPage nav; bool isAction; + bool isMiningRewards = false; }; snprintf(buf, sizeof(buf), "%.8f", s_dispShielded); @@ -1172,7 +1199,7 @@ static void RenderBalanceDashboard(App* app) { TileInfo tiles[4] = { {lblShielded.c_str(), shBuf, S.resolveColor("var(--accent-shielded)", Success()), ICON_MD_SHIELD, NavPage::Receive, false}, - {lblTransparent.c_str(), trBuf, S.resolveColor("var(--accent-transparent)", Warning()), ICON_MD_CIRCLE, NavPage::Receive, false}, + {lblTransparent.c_str(), trBuf, S.resolveColor("var(--accent-transparent)", Warning()), ICON_MD_CIRCLE, NavPage::Receive, false, true}, {lblQuickSend.c_str(), "Send", S.resolveColor("var(--accent-action)", Primary()), ICON_MD_CALL_MADE, NavPage::Send, true}, {lblQuickReceive.c_str(), "Receive", S.resolveColor("var(--accent-action)", Primary()), ICON_MD_CALL_RECEIVED, NavPage::Receive, true}, }; @@ -1228,8 +1255,11 @@ static void RenderBalanceDashboard(App* app) { dl->AddRect(tMin, tMax, IM_COL32(255, 255, 255, (int)S.drawElement("tabs.balance", "hover-glow-alpha").sizeOr(40.0f)), tileSpec.rounding, 0, S.drawElement("tabs.balance", "hover-glow-thickness").sizeOr(1.5f) * dp); ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); - if (ImGui::IsMouseClicked(0)) - app->setCurrentPage(tiles[i].nav); + if (tiles[i].isMiningRewards) miningRewardsTooltip(); + if (ImGui::IsMouseClicked(0)) { + if (tiles[i].isMiningRewards) miningRewardsActivate(app); + else app->setCurrentPage(tiles[i].nav); + } } } @@ -1343,6 +1373,7 @@ static void RenderBalanceVerticalStack(App* app) { // Label dl->AddText(capFont, capFont->LegacySize, ImVec2(px, cy), OnSurfaceMedium(), rowInfos[i].label); + if (i == 2) miningRewardsHover(app, rowPos, rowEnd); // Mining Rewards row // Amount (right side) if (i < 3) { @@ -1551,6 +1582,7 @@ static void RenderBalanceVertical2x2(App* app) { // Label dl->AddText(capFont, capFont->LegacySize, ImVec2(px, cy), OnSurfaceMedium(), cell.label); + if (row == 1 && col == 1) miningRewardsHover(app, cellMin, cellMax); // Mining Rewards cell // Amount (right-aligned) if (!cell.isMarket) { @@ -1802,10 +1834,16 @@ static void RenderBalanceShield(App* app) { dl->AddText(capFont, capFont->LegacySize, ImVec2(infoX, infoY), Success(), buf); infoY += capFont->LegacySize + 6 * dp; + const float trTop = infoY; dl->AddText(ovFont, ovFont->LegacySize, ImVec2(infoX, infoY), Warning(), transLabelUpper.c_str()); infoY += ovFont->LegacySize + 2 * dp; snprintf(buf, sizeof(buf), "%.8f", s_dispTransparent); dl->AddText(capFont, capFont->LegacySize, ImVec2(infoX, infoY), Warning(), buf); + { // Mining Rewards label+amount block: shield-aware tooltip + click + float trW = std::max(ovFont->CalcTextSizeA(ovFont->LegacySize, 10000, 0, transLabelUpper.c_str()).x, + capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, buf).x); + miningRewardsHover(app, ImVec2(infoX, trTop), ImVec2(infoX + trW, infoY + capFont->LegacySize)); + } infoY += capFont->LegacySize + 6 * dp; const auto& market = state.market; @@ -1988,6 +2026,7 @@ static void RenderBalanceTimeline(App* app) { snprintf(buf, sizeof(buf), "%.8f", cards[i].val); } dl->AddText(capFont, capFont->LegacySize, ImVec2(cx, cy), cards[i].col, buf); + if (i == 1) miningRewardsHover(app, cMin, cMax); // Mining Rewards card } ImGui::Dummy(ImVec2(availW, cardH)); } @@ -2131,6 +2170,7 @@ static void RenderBalanceTwoRow(App* app) { dl->AddText(capFont, capFont->LegacySize, ImVec2(cMax.x - pctSz.x - miniPad, cy), WithAlpha(Warning(), 160), buf); + miningRewardsHover(app, cMin, cMax); // Mining Rewards mini-card } // Market mini-card @@ -2248,6 +2288,7 @@ static void RenderBalanceMinimal(App* app) { ImGui::SameLine(0, Layout::spacingLg()); snprintf(buf, sizeof(buf), TR("balance_mining_fmt"), s_dispTransparent); Type().textColored(TypeStyle::Caption, Warning(), buf); + miningRewardsHover(app, ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); // USD value double usd_value = state.getBalanceUSD();