From 1c8e97c0a49a354c7a0922b17d0de7d7537802f1 Mon Sep 17 00:00:00 2001 From: DanS Date: Sat, 4 Jul 2026 20:58:58 -0500 Subject: [PATCH] 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) --- src/ui/windows/receive_tab.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/ui/windows/receive_tab.cpp b/src/ui/windows/receive_tab.cpp index 12329f4..1e01250 100644 --- a/src/ui/windows/receive_tab.cpp +++ b/src/ui/windows/receive_tab.cpp @@ -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()));