From 775f0cbaa30738c3145e3b99710f896464e52342 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Tue, 25 Aug 2020 00:48:29 -0600 Subject: [PATCH] fixup! Always render choice boxes Address feedback from pull request. --- main.c | 14 +++++++++----- render.c | 6 +++--- slurp.1.scd | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 433d5b1..0e0f63c 100644 --- a/main.c +++ b/main.c @@ -13,6 +13,10 @@ #include "slurp.h" #include "render.h" +#define BG_COLOR 0xFFFFFF40 +#define BORDER_COLOR 0x000000FF +#define SELECTION_COLOR 0x00000000 + static void noop() { // This space intentionally left blank } @@ -710,10 +714,10 @@ static void add_choice_box(struct slurp_state *state, int main(int argc, char *argv[]) { struct slurp_state state = { .colors = { - .background = 0xFFFFFF40, - .border = 0x000000FF, - .selection = 0x00000000, - .choice = 0xCCCCFF40, + .background = BG_COLOR, + .border = BORDER_COLOR, + .selection = SELECTION_COLOR, + .choice = BG_COLOR, }, .border_weight = 2, .display_dimensions = false, @@ -739,7 +743,7 @@ int main(int argc, char *argv[]) { case 's': state.colors.selection = parse_color(optarg); break; - case 'o': + case 'B': state.colors.choice = parse_color(optarg); break; case 'f': diff --git a/render.c b/render.c index 1e35c4e..af2bfd9 100644 --- a/render.c +++ b/render.c @@ -19,7 +19,7 @@ static void draw_rect(cairo_t *cairo, struct slurp_box *box, uint32_t color, int box->width * scale, box->height * scale); } -static void adjust_box(struct slurp_box *box, struct slurp_output *output) { +static void box_layout_to_output(struct slurp_box *box, struct slurp_output *output) { box->x -= output->logical_geometry.x; box->y -= output->logical_geometry.y; } @@ -41,7 +41,7 @@ void render(struct slurp_output *output) { if (box_intersect(&output->logical_geometry, choice_box)) { struct slurp_box b = *choice_box; - adjust_box(&b, output); + box_layout_to_output(&b, output); draw_rect(cairo, &b, state->colors.choice, scale); cairo_fill(cairo); } @@ -63,7 +63,7 @@ void render(struct slurp_output *output) { continue; } struct slurp_box b = current_selection->selection; - adjust_box(&b, output); + box_layout_to_output(&b, output); draw_rect(cairo, &b, state->colors.selection, scale); cairo_fill(cairo); diff --git a/slurp.1.scd b/slurp.1.scd index 331bc92..c9e8d98 100644 --- a/slurp.1.scd +++ b/slurp.1.scd @@ -40,7 +40,7 @@ held, the selection is moved instead of being resized. *-s* _color_ Set selection color. See *COLORS* for more detail. -*-o* _color_ +*-B* _color_ Set color for highlighting predefined rectangles from standard input when not selected.