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:
@@ -294,25 +294,18 @@ void RenderLiteNetworkTab(App* app)
|
||||
}
|
||||
|
||||
// Hide / unhide button (far-right strip).
|
||||
ImVec2 hideMin(cardMin.x + cardBtnW, cardMin.y);
|
||||
ImGui::SetCursorScreenPos(hideMin);
|
||||
ImGui::InvisibleButton(("##litehide_" + sv.url).c_str(), ImVec2(hideW, cardH));
|
||||
bool hideHov = ImGui::IsItemHovered();
|
||||
if (hideHov) {
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
|
||||
material::Tooltip("%s", hiddenList ? TR("lite_net_unhide") : TR("lite_net_hide"));
|
||||
}
|
||||
if (ImGui::IsItemClicked()) {
|
||||
ImGui::SetCursorScreenPos(ImVec2(cardMin.x + cardBtnW, cardMin.y));
|
||||
material::IconButtonStyle hideSt;
|
||||
hideSt.color = OnSurfaceDisabled();
|
||||
hideSt.hoverColor = OnSurface();
|
||||
hideSt.tooltip = hiddenList ? TR("lite_net_unhide") : TR("lite_net_hide");
|
||||
if (material::IconButton(("##litehide_" + sv.url).c_str(),
|
||||
hiddenList ? ICON_MD_VISIBILITY : ICON_MD_VISIBILITY_OFF,
|
||||
Type().iconSmall(), ImVec2(hideW, cardH), hideSt)) {
|
||||
if (hiddenList) st->unhideLiteServer(sv.url);
|
||||
else st->hideLiteServer(sv.url);
|
||||
st->save();
|
||||
}
|
||||
ImFont* ico = Type().iconSmall();
|
||||
const char* eye = hiddenList ? ICON_MD_VISIBILITY : ICON_MD_VISIBILITY_OFF;
|
||||
ImVec2 icoSz = ico->CalcTextSizeA(ico->LegacySize, FLT_MAX, 0, eye);
|
||||
dl->AddText(ico, ico->LegacySize,
|
||||
ImVec2(hideMin.x + (hideW - icoSz.x) * 0.5f, cardMin.y + (cardH - icoSz.y) * 0.5f),
|
||||
hideHov ? OnSurface() : OnSurfaceDisabled(), eye);
|
||||
|
||||
// Advance to the next card via a real item (Dummy) below the card, so the scroll region's
|
||||
// content height actually grows — ImGui won't extend bounds from a bare SetCursorScreenPos.
|
||||
|
||||
Reference in New Issue
Block a user