diff options
author | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2020-09-26 07:17:46 +0200 |
---|---|---|
committer | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2020-09-26 07:17:46 +0200 |
commit | 4a1859161d80530ba62d970f4afab2c10876e3bc (patch) | |
tree | 84127b2218364f38d1113faa554f52f2ed3fb0a4 /src | |
parent | cf5a15f4678790fcd35aff621ed2957c60781651 (diff) | |
download | wlclock-4a1859161d80530ba62d970f4afab2c10876e3bc.tar.gz wlclock-4a1859161d80530ba62d970f4afab2c10876e3bc.tar.bz2 |
Improve line size configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/render.c | 6 | ||||
-rw-r--r-- | src/wlclock.c | 29 | ||||
-rw-r--r-- | src/wlclock.h | 2 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/render.c b/src/render.c index 8b9845b..f58a4bd 100644 --- a/src/render.c +++ b/src/render.c @@ -116,7 +116,7 @@ static void draw_background (cairo_t *cairo, struct Wlclock_dimensions *dimensio static void draw_clock_face (cairo_t *cairo, struct Wlclock_dimensions *dimensions, int32_t scale, struct Wlclock *clock) { - if ( clock->clock_size == 0 ) + if ( clock->face_line_size == 0 ) return; double cx = scale * (dimensions->center_x + (dimensions->center_size / 2)); @@ -136,7 +136,7 @@ static void draw_clock_face (cairo_t *cairo, struct Wlclock_dimensions *dimensio else cairo_line_to(cairo, cx + ir * cos(phi), cy + ir * sin(phi)); } - cairo_set_line_width(cairo, clock->clock_size * scale); + cairo_set_line_width(cairo, clock->face_line_size * scale); colour_set_cairo_source(cairo, &clock->clock_colour); cairo_stroke(cairo); cairo_restore(cairo); @@ -191,7 +191,7 @@ static void draw_clock_hands (cairo_t *cairo, int32_t size, int32_t scale, struc cairo_move_to(cairo, cxy + hr * cos(phi_h), cxy + hr * sin(phi_h)); cairo_line_to(cairo, cxy + ir * cos(phi_h + PI), cxy + ir * sin(phi_h +PI)); - cairo_set_line_width(cairo, scale * clock->clock_size); + cairo_set_line_width(cairo, scale * clock->hand_line_size); cairo_stroke(cairo); } diff --git a/src/wlclock.c b/src/wlclock.c index affb641..47154b8 100644 --- a/src/wlclock.c +++ b/src/wlclock.c @@ -181,9 +181,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) BORDER_COLOUR, BORDER_SIZE, CLOCK_COLOUR, - CLOCK_FACE_SIZE, CORNER_RADIUS, EXCLUSIVE_ZONE, + FACE_LINE_SIZE, + HAND_LINE_SIZE, HAND_STYLE, LAYER, MARGIN, @@ -204,9 +205,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) {"border-colour", required_argument, NULL, BORDER_COLOUR}, {"border-size", required_argument, NULL, BORDER_SIZE}, {"clock-colour", required_argument, NULL, CLOCK_COLOUR}, - {"clock-face-size", required_argument, NULL, CLOCK_FACE_SIZE}, {"corner-radius", required_argument, NULL, CORNER_RADIUS}, {"exclusive-zone", required_argument, NULL, EXCLUSIVE_ZONE}, + {"face-line-size", required_argument, NULL, FACE_LINE_SIZE}, + {"hand-line-size", required_argument, NULL, HAND_LINE_SIZE}, {"hand-style", required_argument, NULL, HAND_STYLE}, {"layer", required_argument, NULL, LAYER}, {"margin", required_argument, NULL, MARGIN}, @@ -228,9 +230,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) " --border-colour Border colour.\n" " --border-size Size of the border.\n" " --clock-colour Colour of the clock elements.\n" - " --clock-face-size Size of clock face lines.\n" " --corner-radius Corner radii.\n" " --exclusive-zone Exclusive zone of the layer surface.\n" + " --face-line-size Width of lines on the clock face.\n" + " --hand-line-size Width of lines of the clock hands.\n" " --hand-style Style of the clock hands.\n" " --layer Layer of the layer surface.\n" " --margin Directional margins.\n" @@ -339,11 +342,20 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) return false; break; - case CLOCK_FACE_SIZE: - clock->clock_size = atoi(optarg); - if ( clock->clock_size < 0 ) + case FACE_LINE_SIZE: + clock->face_line_size = atoi(optarg); + if ( clock->face_line_size < 0 ) { - clocklog(NULL, 0, "ERROR: Size of clock face elements may not be smaller then 0.\n"); + clocklog(NULL, 0, "ERROR: Face line size may not be smaller than 0.\n"); + return false; + } + break; + + case HAND_LINE_SIZE: + clock->hand_line_size = atoi(optarg); + if ( clock->hand_line_size < 1 ) + { + clocklog(NULL, 0, "ERROR: Hand line size may not be smaller than 1.\n"); return false; } break; @@ -623,7 +635,8 @@ int main (int argc, char *argv[]) = clock.radius_top_left = clock.radius_top_right = 0; clock.margin_bottom = clock.margin_top = clock.margin_left = clock.margin_right = 0; - clock.clock_size = 1; + clock.face_line_size = 1; + clock.hand_line_size = 1; clock.hand_style = STYLE_XCLOCK; colour_from_string(&clock.background_colour, "#FFFFFF"); colour_from_string(&clock.border_colour, "#000000"); diff --git a/src/wlclock.h b/src/wlclock.h index 48a2147..8f75233 100644 --- a/src/wlclock.h +++ b/src/wlclock.h @@ -49,7 +49,7 @@ struct Wlclock enum zwlr_layer_shell_v1_layer layer; struct Wlclock_dimensions dimensions; char *namespace; - int32_t clock_size; + int32_t face_line_size, hand_line_size; int32_t exclusive_zone; int32_t border_top, border_right, border_bottom, border_left; int32_t margin_top, margin_right, margin_bottom, margin_left; |