From ea2eb95dd2d919f8ff0a44f295071c8a2e7ee129 Mon Sep 17 00:00:00 2001 From: bun137 Date: Sun, 17 Nov 2024 22:19:14 +0530 Subject: [PATCH] enhance: adds rounded corners to the bg for the hex code --- src/hyprpicker.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 00075c3..d62bd98 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -388,7 +388,7 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { // | | // | --------- | // - // (#hex code here) + // (hex code here) cairo_restore(PCAIRO); if (!m_bNoZoom) { @@ -430,12 +430,26 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { sprintf(hexBuffer, "#%02x%02x%02x", currentColor.r, currentColor.g, currentColor.b); cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5); - cairo_rectangle(PCAIRO, CLICKPOS.x, CLICKPOS.y + 20, 80, 30); + + double x = CLICKPOS.x; + double y = CLICKPOS.y + 19; + double width = 89; + double height = 30; + double radius = 6; + + cairo_move_to(PCAIRO, x + radius, y); + + cairo_arc(PCAIRO, x + width - radius, y + radius, radius, -M_PI_2, 0); + cairo_arc(PCAIRO, x + width - radius, y + height - radius, radius, 0, M_PI_2); + cairo_arc(PCAIRO, x + radius, y + height - radius, radius, M_PI_2, M_PI); + cairo_arc(PCAIRO, x + radius, y + radius, radius, M_PI, -M_PI_2); + + cairo_close_path(PCAIRO); cairo_fill(PCAIRO); cairo_set_source_rgba(PCAIRO, 1.0, 1.0, 1.0, 1.0); cairo_select_font_face(PCAIRO, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(PCAIRO, 18); + cairo_set_font_size(PCAIRO, 20); cairo_move_to(PCAIRO, CLICKPOS.x, CLICKPOS.y + 40); cairo_show_text(PCAIRO, hexBuffer);