Skip to content

Commit

Permalink
fixup! Always render choice boxes
Browse files Browse the repository at this point in the history
Address feedback from pull request.
  • Loading branch information
tmccombs committed Aug 25, 2020
1 parent b79488c commit 775f0cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand All @@ -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':
Expand Down
6 changes: 3 additions & 3 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion slurp.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 775f0cb

Please sign in to comment.