From 50f5277f5ce2d7b685ddf12b3ce5e53d59071d07 Mon Sep 17 00:00:00 2001 From: baketnk Date: Thu, 24 Sep 2026 16:43:20 -0400 Subject: [PATCH] Match external handles to the panel gradient --- src/panel_surface.cpp | 11 +++++++++++ tests/panel_test.cpp | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/panel_surface.cpp b/src/panel_surface.cpp index ed6f732..8702267 100644 --- a/src/panel_surface.cpp +++ b/src/panel_surface.cpp @@ -353,6 +353,17 @@ struct PanelSurface::Impl { rounded({400, 721, 200, 6}, 3, handle, handle); rounded({1008, 721, 36, 6}, 3, handle, handle); rounded({1038, 691, 6, 36}, 3, handle, handle); + // Give each handle the same full mint-to-blue theme gradient as the + // main frame, without changing its antialiased alpha coverage. + for (Rect bounds : {Rect{400, 721, 200, 6}, Rect{1008, 691, 36, 36}}) + for (int y = bounds.y; y < bounds.y + bounds.h; ++y) + for (int x = bounds.x; x < bounds.x + bounds.w; ++x) { + auto* dst = pixels.data() + (size_t(y) * W + x) * 4; + if (!dst[3]) continue; + const auto color = mix(theme.frame_start, theme.frame_end, + float(x - bounds.x) / (bounds.w - 1)); + std::copy_n(color.begin(), 3, dst); + } dirty = false; return true; } diff --git a/tests/panel_test.cpp b/tests/panel_test.cpp index ade6df5..6fce769 100644 --- a/tests/panel_test.cpp +++ b/tests/panel_test.cpp @@ -89,6 +89,20 @@ int main(int argc, char** argv) { assert(alpha(500, 690) == 0 && alpha(1030, 704) == 0); // Antialiased handle edges carry real alpha, not RGB hidden at alpha zero. assert(alpha(401, 721) > 0 && alpha(401, 721) < 255); + // Both external handles use the configured full frame gradient, not a + // fixed blue or a tint that fills in their transparent surroundings. + Theme gradient_theme; + gradient_theme.frame_start = {255, 0, 0, 255}; + gradient_theme.frame_end = {0, 0, 255, 255}; + PanelSurface gradient_surface(argv[1], Mount::World, gradient_theme); + gradient_surface.render(p); + const auto channel = [&](int x, int y, int c) { + return gradient_surface.pixels()[(y * PanelSurface::width + x) * 4 + c]; + }; + assert(channel(410, 723, 0) > 230 && channel(590, 723, 2) > 230); + assert(channel(1012, 723, 0) > 220 && channel(1040, 705, 2) > 220); + assert(channel(1030, 704, 3) == 0 && channel(800, 724, 3) == 0); + assert(channel(401, 721, 3) == alpha(401, 721)); p.enabled = true; p.record_available = false;