From fca94078a7123eba55a6c729ef20c1df75dc5c7b Mon Sep 17 00:00:00 2001 From: bun137 Date: Sat, 16 Nov 2024 22:38:35 +0530 Subject: [PATCH 01/10] feat: adds hexcode below the cursor --- src/hyprpicker.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 3118116..9b82b04 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -388,6 +388,7 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { // | | // | --------- | // + // (#hex code here) cairo_restore(PCAIRO); if (!m_bNoZoom) { @@ -424,6 +425,22 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_clip(PCAIRO); cairo_paint(PCAIRO); + const auto THECOLOR = getColorFromPixel(pSurface, CLICKPOS); + printf("thecolor has been gotten and it is %d %d %d\n", THECOLOR.r, THECOLOR.g, THECOLOR.b); + + char hexBuffer[8]; + sprintf(hexBuffer, "#%02x%02x%02x", THECOLOR.r, THECOLOR.g, THECOLOR.b); + + cairo_set_source_rgba(PCAIRO, 1.0, 1.0, 1.0, 1.0); + printf("hallo\n"); + cairo_select_font_face(PCAIRO, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(PCAIRO, 18); + cairo_move_to(PCAIRO, CLICKPOS.x, CLICKPOS.y + 40); + printf("pos is %f %f\n", CLICKPOS.x, CLICKPOS.y); + printf("Rendering hex code at position: (%f, %f)\n", CLICKPOS.x, CLICKPOS.y + 40); + + printf("hexbuffer contains %s\n", hexBuffer); + cairo_show_text(PCAIRO, hexBuffer); cairo_surface_flush(PBUFFER->surface); cairo_restore(PCAIRO); @@ -447,7 +464,6 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_paint(PCAIRO); cairo_surface_flush(PBUFFER->surface); - cairo_pattern_destroy(PATTERNPRE); } From 20c592ad10801e4af970cfae910d32cb157e0728 Mon Sep 17 00:00:00 2001 From: bun137 Date: Sun, 17 Nov 2024 19:24:18 +0530 Subject: [PATCH 02/10] feat: adds hexcode below the cursor --- src/hyprpicker.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 9b82b04..a485ac4 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -425,26 +425,18 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_clip(PCAIRO); cairo_paint(PCAIRO); - const auto THECOLOR = getColorFromPixel(pSurface, CLICKPOS); - printf("thecolor has been gotten and it is %d %d %d\n", THECOLOR.r, THECOLOR.g, THECOLOR.b); - - char hexBuffer[8]; - sprintf(hexBuffer, "#%02x%02x%02x", THECOLOR.r, THECOLOR.g, THECOLOR.b); + const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); + char hexBuffer[8]; + sprintf(hexBuffer, "#%02x%02x%02x", currentColor.r, currentColor.g, currentColor.b); cairo_set_source_rgba(PCAIRO, 1.0, 1.0, 1.0, 1.0); - printf("hallo\n"); cairo_select_font_face(PCAIRO, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(PCAIRO, 18); cairo_move_to(PCAIRO, CLICKPOS.x, CLICKPOS.y + 40); - printf("pos is %f %f\n", CLICKPOS.x, CLICKPOS.y); - printf("Rendering hex code at position: (%f, %f)\n", CLICKPOS.x, CLICKPOS.y + 40); - - printf("hexbuffer contains %s\n", hexBuffer); cairo_show_text(PCAIRO, hexBuffer); - cairo_surface_flush(PBUFFER->surface); + cairo_surface_flush(PBUFFER->surface); cairo_restore(PCAIRO); - cairo_pattern_destroy(PATTERN); } } else if (!m_bRenderInactive) { From ac1b4f2418fb5567a7d166c7919d9822ee52d03d Mon Sep 17 00:00:00 2001 From: bun137 Date: Sun, 17 Nov 2024 21:45:32 +0530 Subject: [PATCH 03/10] enhance: adds bg to the hexcode text --- src/hyprpicker.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index a485ac4..00075c3 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -429,6 +429,10 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { char hexBuffer[8]; 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); + 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); From ea2eb95dd2d919f8ff0a44f295071c8a2e7ee129 Mon Sep 17 00:00:00 2001 From: bun137 Date: Sun, 17 Nov 2024 22:19:14 +0530 Subject: [PATCH 04/10] 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); From 6ba68b6ae3ae9066ca937db1ad9c085d2ea508ad Mon Sep 17 00:00:00 2001 From: bun137 Date: Tue, 19 Nov 2024 15:18:38 +0530 Subject: [PATCH 05/10] enhance: adds padding to on screen hex code with visibility throughout the screen --- src/hyprpicker.cpp | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index d62bd98..2905439 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -427,18 +427,27 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); char hexBuffer[8]; - sprintf(hexBuffer, "#%02x%02x%02x", currentColor.r, currentColor.g, currentColor.b); + sprintf(hexBuffer, "#%02X%02X%02X", currentColor.r, currentColor.g, currentColor.b); cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5); - double x = CLICKPOS.x; - double y = CLICKPOS.y + 19; - double width = 89; - double height = 30; - double radius = 6; + double x, y, width = 85, height = 28, radius = 6; + + if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + x = CLICKPOS.x - 80; + y = CLICKPOS.y - 40; + } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { + x = CLICKPOS.x; + y = CLICKPOS.y - 40; + } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + x = CLICKPOS.x - 80; + y = CLICKPOS.y + 20; + } else { + x = CLICKPOS.x; + y = CLICKPOS.y + 20; + } 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); @@ -449,8 +458,21 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { 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, 20); - cairo_move_to(PCAIRO, CLICKPOS.x, CLICKPOS.y + 40); + cairo_set_font_size(PCAIRO, 18); + + double padding = 5.0; + double textX = x + padding; + + if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); + } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); + } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); + } else { + cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); + } + cairo_show_text(PCAIRO, hexBuffer); cairo_surface_flush(PBUFFER->surface); From 2fa6623ef9468c425f90f5ac1fdbaf9a1a92e471 Mon Sep 17 00:00:00 2001 From: bun137 Date: Thu, 21 Nov 2024 20:37:39 +0530 Subject: [PATCH 06/10] chore: changes sprintf to std::format --- src/hyprpicker.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 2905439..5ebd075 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -425,9 +425,8 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_clip(PCAIRO); cairo_paint(PCAIRO); - const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); - char hexBuffer[8]; - sprintf(hexBuffer, "#%02X%02X%02X", currentColor.r, currentColor.g, currentColor.b); + const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); + std::string hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b); cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5); @@ -473,7 +472,7 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); } - cairo_show_text(PCAIRO, hexBuffer); + cairo_show_text(PCAIRO, hexBuffer.c_str()); cairo_surface_flush(PBUFFER->surface); cairo_restore(PCAIRO); From 5e6005056538a4547190bacb5d79429357c0d4da Mon Sep 17 00:00:00 2001 From: bun137 Date: Mon, 25 Nov 2024 17:32:50 +0530 Subject: [PATCH 07/10] feat: adds flag to disable live preview of hex code --- src/hyprpicker.cpp | 91 +++++++++++++++++++++++----------------------- src/hyprpicker.hpp | 3 +- src/main.cpp | 21 ++++------- 3 files changed, 56 insertions(+), 59 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 5ebd075..0f18477 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -424,57 +424,58 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_arc(PCAIRO, CLICKPOS.x, CLICKPOS.y, 100 / SCALEBUFS.x, 0, 2 * M_PI); cairo_clip(PCAIRO); cairo_paint(PCAIRO); + if (!m_bDisableLive) { + const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); + std::string hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b); + + cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5); + + double x, y, width = 85, height = 28, radius = 6; + + if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + x = CLICKPOS.x - 80; + y = CLICKPOS.y - 40; + } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { + x = CLICKPOS.x; + y = CLICKPOS.y - 40; + } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + x = CLICKPOS.x - 80; + y = CLICKPOS.y + 20; + } else { + x = CLICKPOS.x; + y = CLICKPOS.y + 20; + } - const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); - std::string hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b); - - cairo_set_source_rgba(PCAIRO, 0.0, 0.0, 0.0, 0.5); - - double x, y, width = 85, height = 28, radius = 6; - - if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { - x = CLICKPOS.x - 80; - y = CLICKPOS.y - 40; - } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { - x = CLICKPOS.x; - y = CLICKPOS.y - 40; - } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { - x = CLICKPOS.x - 80; - y = CLICKPOS.y + 20; - } else { - x = CLICKPOS.x; - y = CLICKPOS.y + 20; - } + 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_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_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_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); - - double padding = 5.0; - double textX = x + padding; - - if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { - cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); - } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { - cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); - } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { - cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); - } else { - cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); - } + double padding = 5.0; + double textX = x + padding; - cairo_show_text(PCAIRO, hexBuffer.c_str()); + if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); + } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); + } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); + } else { + cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); + } - cairo_surface_flush(PBUFFER->surface); + cairo_show_text(PCAIRO, hexBuffer.c_str()); + + cairo_surface_flush(PBUFFER->surface); + } cairo_restore(PCAIRO); cairo_pattern_destroy(PATTERN); } diff --git a/src/hyprpicker.hpp b/src/hyprpicker.hpp index c449daf..678f0c8 100644 --- a/src/hyprpicker.hpp +++ b/src/hyprpicker.hpp @@ -44,6 +44,7 @@ class CHyprpicker { bool m_bRenderInactive = false; bool m_bNoZoom = false; bool m_bNoFractional = false; + bool m_bDisableLive = false; bool m_bRunning = true; @@ -76,4 +77,4 @@ class CHyprpicker { private: }; -inline std::unique_ptr g_pHyprpicker; \ No newline at end of file +inline std::unique_ptr g_pHyprpicker; diff --git a/src/main.cpp b/src/main.cpp index 0d023e8..8a219d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,8 @@ static void help(void) { << " -q | --quiet | Disable most logs (leaves errors)\n" << " -v | --verbose | Enable more logs\n" << " -t | --no-fractional | Disable fractional scaling support\n" - << " -V | --version | Print version info\n"; + << " -V | --version | Print version info\n" + << " -d | --disable-live | Disable live preview of Hex code\n"; } int main(int argc, char** argv, char** envp) { @@ -23,19 +24,12 @@ int main(int argc, char** argv, char** envp) { while (true) { int option_index = 0; - static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'}, - {"format", required_argument, NULL, 'f'}, - {"help", no_argument, NULL, 'h'}, - {"no-fancy", no_argument, NULL, 'n'}, - {"render-inactive", no_argument, NULL, 'r'}, - {"no-zoom", no_argument, NULL, 'z'}, - {"no-fractional", no_argument, NULL, 't'}, - {"quiet", no_argument, NULL, 'q'}, - {"verbose", no_argument, NULL, 'v'}, - {"version", no_argument, NULL, 'V'}, - {NULL, 0, NULL, 0}}; + static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'}, {"format", required_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, + {"no-fancy", no_argument, NULL, 'n'}, {"render-inactive", no_argument, NULL, 'r'}, {"no-zoom", no_argument, NULL, 'z'}, + {"no-fractional", no_argument, NULL, 't'}, {"quiet", no_argument, NULL, 'q'}, {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, 'V'}, {"disable-live", no_argument, NULL, 'd'}, {NULL, 0, NULL, 0}}; - int c = getopt_long(argc, argv, ":f:hnarzqvtV", long_options, &option_index); + int c = getopt_long(argc, argv, ":f:hnarzqvtVd", long_options, &option_index); if (c == -1) break; @@ -64,6 +58,7 @@ int main(int argc, char** argv, char** envp) { case 't': g_pHyprpicker->m_bNoFractional = true; break; case 'q': Debug::quiet = true; break; case 'v': Debug::verbose = true; break; + case 'd': g_pHyprpicker->m_bDisableLive = true; break; case 'V': { std::cout << "hyprpicker v" << HYPRPICKER_VERSION << "\n"; exit(0); From 5ab9c327f4954bbe9b182e12e50766430bd86a93 Mon Sep 17 00:00:00 2001 From: bun137 Date: Tue, 26 Nov 2024 20:45:45 +0530 Subject: [PATCH 08/10] chore: renames live hexcode flag and follows style convensions --- src/hyprpicker.cpp | 9 ++++----- src/main.cpp | 38 +++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 0f18477..9a98567 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -462,15 +462,14 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { double padding = 5.0; double textX = x + padding; - if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50) && CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); - } else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) { + else if (CLICKPOS.y > (PBUFFER->pixelSize.y - 50)) cairo_move_to(PCAIRO, textX, CLICKPOS.y - 20); - } else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) { + else if (CLICKPOS.x > (PBUFFER->pixelSize.x - 100)) cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); - } else { + else cairo_move_to(PCAIRO, textX, CLICKPOS.y + 40); - } cairo_show_text(PCAIRO, hexBuffer.c_str()); diff --git a/src/main.cpp b/src/main.cpp index 8a219d3..2b91dcc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,17 +6,17 @@ static void help(void) { std::cout << "Hyprpicker usage: hyprpicker [arg [...]].\n\nArguments:\n" - << " -a | --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n" - << " -f | --format=fmt | Specifies the output format (cmyk, hex, rgb, hsl, hsv)\n" - << " -n | --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n" - << " -h | --help | Show this help message\n" - << " -r | --render-inactive | Render (freeze) inactive displays\n" - << " -z | --no-zoom | Disable the zoom lens\n" - << " -q | --quiet | Disable most logs (leaves errors)\n" - << " -v | --verbose | Enable more logs\n" - << " -t | --no-fractional | Disable fractional scaling support\n" - << " -V | --version | Print version info\n" - << " -d | --disable-live | Disable live preview of Hex code\n"; + << " -a | --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n" + << " -f | --format=fmt | Specifies the output format (cmyk, hex, rgb, hsl, hsv)\n" + << " -n | --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n" + << " -h | --help | Show this help message\n" + << " -r | --render-inactive | Render (freeze) inactive displays\n" + << " -z | --no-zoom | Disable the zoom lens\n" + << " -q | --quiet | Disable most logs (leaves errors)\n" + << " -v | --verbose | Enable more logs\n" + << " -t | --no-fractional | Disable fractional scaling support\n" + << " -d | --disable-hex-preview | Disable live preview of Hex code\n" + << " -V | --version | Print version info\n"; } int main(int argc, char** argv, char** envp) { @@ -24,10 +24,18 @@ int main(int argc, char** argv, char** envp) { while (true) { int option_index = 0; - static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'}, {"format", required_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, - {"no-fancy", no_argument, NULL, 'n'}, {"render-inactive", no_argument, NULL, 'r'}, {"no-zoom", no_argument, NULL, 'z'}, - {"no-fractional", no_argument, NULL, 't'}, {"quiet", no_argument, NULL, 'q'}, {"verbose", no_argument, NULL, 'v'}, - {"version", no_argument, NULL, 'V'}, {"disable-live", no_argument, NULL, 'd'}, {NULL, 0, NULL, 0}}; + static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'}, + {"format", required_argument, NULL, 'f'}, + {"help", no_argument, NULL, 'h'}, + {"no-fancy", no_argument, NULL, 'n'}, + {"render-inactive", no_argument, NULL, 'r'}, + {"no-zoom", no_argument, NULL, 'z'}, + {"no-fractional", no_argument, NULL, 't'}, + {"quiet", no_argument, NULL, 'q'}, + {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, 'V'}, + {"disable-hex-preview", no_argument, NULL, 'd'}, + {NULL, 0, NULL, 0}}; int c = getopt_long(argc, argv, ":f:hnarzqvtVd", long_options, &option_index); if (c == -1) From 28ce076581593467942037769ab82f41082f2c69 Mon Sep 17 00:00:00 2001 From: bun137 Date: Thu, 28 Nov 2024 17:16:43 +0530 Subject: [PATCH 09/10] chore: renames all flags internally --- src/hyprpicker.cpp | 3 ++- src/hyprpicker.hpp | 10 +++++----- src/main.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 9a98567..2e8dbbf 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -424,7 +424,8 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) { cairo_arc(PCAIRO, CLICKPOS.x, CLICKPOS.y, 100 / SCALEBUFS.x, 0, 2 * M_PI); cairo_clip(PCAIRO); cairo_paint(PCAIRO); - if (!m_bDisableLive) { + + if (!m_bDisableHexPreview) { const auto currentColor = getColorFromPixel(pSurface, CLICKPOS); std::string hexBuffer = std::format("#{:02X}{:02X}{:02X}", currentColor.r, currentColor.g, currentColor.b); diff --git a/src/hyprpicker.hpp b/src/hyprpicker.hpp index 678f0c8..2e75271 100644 --- a/src/hyprpicker.hpp +++ b/src/hyprpicker.hpp @@ -40,11 +40,11 @@ class CHyprpicker { bool m_bFancyOutput = true; - bool m_bAutoCopy = false; - bool m_bRenderInactive = false; - bool m_bNoZoom = false; - bool m_bNoFractional = false; - bool m_bDisableLive = false; + bool m_bAutoCopy = false; + bool m_bRenderInactive = false; + bool m_bNoZoom = false; + bool m_bNoFractional = false; + bool m_bDisableHexPreview = false; bool m_bRunning = true; diff --git a/src/main.cpp b/src/main.cpp index 2b91dcc..64a2862 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,8 +33,8 @@ int main(int argc, char** argv, char** envp) { {"no-fractional", no_argument, NULL, 't'}, {"quiet", no_argument, NULL, 'q'}, {"verbose", no_argument, NULL, 'v'}, - {"version", no_argument, NULL, 'V'}, {"disable-hex-preview", no_argument, NULL, 'd'}, + {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0}}; int c = getopt_long(argc, argv, ":f:hnarzqvtVd", long_options, &option_index); @@ -66,7 +66,7 @@ int main(int argc, char** argv, char** envp) { case 't': g_pHyprpicker->m_bNoFractional = true; break; case 'q': Debug::quiet = true; break; case 'v': Debug::verbose = true; break; - case 'd': g_pHyprpicker->m_bDisableLive = true; break; + case 'd': g_pHyprpicker->m_bDisableHexPreview = true; break; case 'V': { std::cout << "hyprpicker v" << HYPRPICKER_VERSION << "\n"; exit(0); From bbc4ace6510faceaf39531906f840c03e652bc9c Mon Sep 17 00:00:00 2001 From: bun137 Date: Thu, 28 Nov 2024 17:50:20 +0530 Subject: [PATCH 10/10] chore: swap 'V' and 'd' in getopt_long options --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 64a2862..5d435b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char** argv, char** envp) { {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0}}; - int c = getopt_long(argc, argv, ":f:hnarzqvtVd", long_options, &option_index); + int c = getopt_long(argc, argv, ":f:hnarzqvtdV", long_options, &option_index); if (c == -1) break;