refactor(ui): adopt material::SegmentedControl for the receive All/Z/T filter

UI-standardization audit: the receive address-type filter (All/Z/T) was three
hand-rolled gapped ImGui::Button pills with per-segment PushStyleColor. Replace
with the shared material::SegmentedControl (rounded track + Primary inset-pill
on the active cell + centered caption labels), the same control the market
portfolio editor uses. Keeps the same right-aligned footprint (toggleTotalW)
and drives s_addr_type_filter from the returned clicked index. Verified across
all 9 skins via the screenshot sweep.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-04 20:58:58 -05:00
parent f1e66c08d1
commit 1c8e97c0a4

View File

@@ -132,27 +132,15 @@ static void RenderAddressDropdown(App* app, float width) {
float toggleBtnW = std::max(schema::UI().drawElement("tabs.receive", "toggle-btn-min-width").size, schema::UI().drawElement("tabs.receive", "toggle-btn-width").size * Layout::hScale(width));
float toggleGap = schema::UI().drawElement("tabs.receive", "toggle-gap").size;
float toggleTotalW = toggleBtnW * 3 + toggleGap * 2;
float segH = ImGui::GetFrameHeight();
ImGui::SameLine(width - toggleTotalW);
ImVec2 segOrigin = ImGui::GetCursorScreenPos();
const char* filterLabels[] = { TR("all_filter"), "Z", "T" };
for (int i = 0; i < 3; i++) {
bool isActive = (s_addr_type_filter == i);
if (isActive) {
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::ColorConvertU32ToFloat4(PrimaryVariant()));
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
} else {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0.06f));
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceMedium()));
}
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, schema::UI().drawElement("tabs.receive", "toggle-rounding").size);
char toggleId[32];
snprintf(toggleId, sizeof(toggleId), "%s##addrFilter", filterLabels[i]);
if (ImGui::Button(toggleId, ImVec2(toggleBtnW, 0))) {
s_addr_type_filter = i;
}
ImGui::PopStyleVar();
ImGui::PopStyleColor(2);
if (i < 2) ImGui::SameLine(0, toggleGap);
}
int segClk = material::SegmentedControl(ImGui::GetWindowDrawList(), segOrigin, toggleTotalW, segH,
filterLabels, 3, s_addr_type_filter, Type().caption(),
"##addrFilter", Layout::dpiScale());
if (segClk >= 0) s_addr_type_filter = segClk;
ImGui::Dummy(ImVec2(toggleTotalW, segH));
ImGui::Dummy(ImVec2(0, Layout::spacingSm()));