feat(balance): show total period-earnings in every layout

#4 wired the total-earnings figure into the compact hero and the classic
layout only. This adds it to the remaining layouts in each one's native
style: donut / shield / timeline / minimal beside the USD line, consolidated
to the right of the USD, vertical-stack left of the Total row's amount, and
vertical-2x2 as a second line under the Total cell (dashboard and two-row
already show it via RenderCompactHero). All go through FormatTotalEarnings,
which returns nothing unless the global earnings toggle is on, so every
layout's default appearance is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 20:02:04 -05:00
co-authored by Claude Opus 4.8
parent 07437fb447
commit b47d55a3d0
+53
View File
@@ -721,6 +721,13 @@ static void RenderBalanceDonut(App* app) {
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
ImGui::SameLine(0, Layout::spacingMd());
Type().textColored(TypeStyle::Caption, earnCol, earnText.c_str());
}
}
}
RenderSyncBar(app, dl, vs);
ImGui::Dummy(ImVec2(0, cGap));
@@ -922,6 +929,13 @@ static void RenderBalanceConsolidated(App* app) {
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
dl->AddText(capFont, capFont->LegacySize, ImVec2(cx, cy), OnSurfaceDisabled(), buf);
{ // total period-earnings to the right of the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
float usdW = capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, buf).x;
dl->AddText(capFont, capFont->LegacySize, ImVec2(cx + usdW + Layout::spacingLg(), cy), earnCol, earnText.c_str());
}
}
// Market badge (top-right)
{
@@ -1297,6 +1311,15 @@ static void RenderBalanceVerticalStack(App* app) {
dl->AddText(capFont, capFont->LegacySize,
ImVec2(rowEnd.x - amtSz.x - rowPad, cy),
i == 0 ? OnSurface() : rowInfos[i].accent, buf);
if (i == 0) { // total period-earnings, left of the Total row's amount, when the toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
float earnW = capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, earnText.c_str()).x;
dl->AddText(capFont, capFont->LegacySize,
ImVec2(rowEnd.x - amtSz.x - rowPad - Layout::spacingMd() - earnW, cy),
earnCol, earnText.c_str());
}
}
// Proportion bar (for shielded/transparent rows — fills gap between label and amount)
if (i == 1 || i == 2) {
@@ -1496,6 +1519,15 @@ static void RenderBalanceVertical2x2(App* app) {
dl->AddText(capFont, capFont->LegacySize,
ImVec2(cellMax.x - amtSz.x - rowPad, cy),
cell.isMarket ? cell.accent : (row == 0 && col == 0 ? OnSurface() : cell.accent), buf);
if (row == 0 && col == 0) { // total period-earnings below the Total cell's amount, toggle on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
float earnW = capFont->CalcTextSizeA(capFont->LegacySize, 10000, 0, earnText.c_str()).x;
dl->AddText(capFont, capFont->LegacySize,
ImVec2(cellMax.x - earnW - rowPad, cy + capFont->LegacySize + 2.0f * dp),
earnCol, earnText.c_str());
}
}
// Proportion bar (shielded/transparent)
if (cell.hasBar) {
@@ -1603,6 +1635,13 @@ static void RenderBalanceShield(App* app) {
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
ImGui::SameLine(0, Layout::spacingMd());
Type().textColored(TypeStyle::Caption, earnCol, earnText.c_str());
}
}
}
RenderSyncBar(app, dl, vs);
ImGui::Dummy(ImVec2(0, cGap));
@@ -1785,6 +1824,13 @@ static void RenderBalanceTimeline(App* app) {
if (usd_value > 0.0) snprintf(buf, sizeof(buf), "$%.2f USD", usd_value);
else snprintf(buf, sizeof(buf), "$-.-- USD");
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
ImGui::SameLine(0, Layout::spacingMd());
Type().textColored(TypeStyle::Caption, earnCol, earnText.c_str());
}
}
}
RenderSyncBar(app, dl, vs);
ImGui::Dummy(ImVec2(0, cGap));
@@ -2151,6 +2197,13 @@ static void RenderBalanceMinimal(App* app) {
else snprintf(buf, sizeof(buf), "$-.-- USD");
ImGui::SameLine(0, Layout::spacingLg());
Type().textColored(TypeStyle::Caption, OnSurfaceDisabled(), buf);
{ // total period-earnings beside the USD when the earnings toggle is on
std::string earnText; ImU32 earnCol;
if (FormatTotalEarnings(app, earnText, earnCol)) {
ImGui::SameLine(0, Layout::spacingMd());
Type().textColored(TypeStyle::Caption, earnCol, earnText.c_str());
}
}
RenderSyncBar(app, dl, vs);