refactor(ui): add material::IconButton helper + adopt at 8 frameless icon buttons
UI-standardization audit (icon-button discovery pass): the app had ~22 clean hand-rolled icon buttons repeating the same "InvisibleButton hit-target + centered glyph + hover feedback + tooltip" boilerplate. Add a shared material::IconButton(id, glyph, font, size, IconButtonStyle) — centered glyph, optional resting + hover backgrounds (pill/rounded-rect), hover recolor, hand cursor + tooltip; caller resolves state-dependent glyph/colors and returns clicked. Adopt at the homogeneous, self-contained sites, pixel-faithful: - mining_mode_toggle: pool/worker dropdown + bookmark + reset (×5) - network: server hide/unhide eye (×1) - mining_controls: pool benchmark start (×1) - mining_stats: pool-balance refresh (×1) Deferred (own follow-up + sweep): the idle/scale/gpu active-pill toggles use a "draw pill+glyph earlier, hit-test later" idiom needing restructuring; the raw-rect (IsRectHovered, no InvisibleButton) sites in market/mining_stats/ balance are a different hit-test mechanism left intentionally. Framed icon pagers already ride TactileButton after the prior commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -258,24 +258,16 @@ static void RenderLeftPoolCard(App* app, const WalletState& state, ImDrawList* d
|
||||
(int)util::knownPools().size());
|
||||
dl->AddText(ovFont, ovFont->LegacySize, ImVec2(x, y), OnSurfaceMedium(), hdr);
|
||||
|
||||
ImFont* icoFont = Type().iconSmall();
|
||||
const char* icon = ICON_MD_REFRESH;
|
||||
ImVec2 iSz = icoFont->CalcTextSizeA(icoFont->LegacySize, FLT_MAX, 0, icon);
|
||||
float btnS = ovFont->LegacySize + 6 * dp;
|
||||
ImVec2 rbMin(x + w - btnS, y - 2 * dp);
|
||||
ImVec2 rbMax(x + w, y - 2 * dp + btnS);
|
||||
material::IconButtonStyle st;
|
||||
st.color = OnSurfaceMedium();
|
||||
st.hoverBg = StateHover();
|
||||
st.bgRounding = 3 * dp;
|
||||
st.tooltip = TR("mining_refresh");
|
||||
ImGui::SetCursorScreenPos(rbMin);
|
||||
ImGui::InvisibleButton("##PoolRefresh", ImVec2(btnS, btnS));
|
||||
bool rhov = ImGui::IsItemHovered();
|
||||
if (rhov) {
|
||||
dl->AddRectFilled(rbMin, rbMax, StateHover(), 3 * dp);
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
material::Tooltip("%s", TR("mining_refresh"));
|
||||
}
|
||||
dl->AddText(icoFont, icoFont->LegacySize,
|
||||
ImVec2((rbMin.x + rbMax.x - iSz.x) * 0.5f, (rbMin.y + rbMax.y - iSz.y) * 0.5f),
|
||||
OnSurfaceMedium(), icon);
|
||||
if (ImGui::IsItemClicked()) app->requestPoolBalanceRefresh();
|
||||
if (material::IconButton("##PoolRefresh", ICON_MD_REFRESH, Type().iconSmall(), ImVec2(btnS, btnS), st))
|
||||
app->requestPoolBalanceRefresh();
|
||||
}
|
||||
y += ovFont->LegacySize + 4 * dp;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user