diff options
author | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2020-09-28 02:16:37 +0200 |
---|---|---|
committer | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2020-09-28 02:36:04 +0200 |
commit | affa688b44a522948ece0962cea5e14c79f65ba7 (patch) | |
tree | 45f2814fb3e6a306fa519414dcb1aee395765e60 | |
parent | e7adc6269c8a054d5a4e1139ccc6b667407b108e (diff) | |
download | wlclock-affa688b44a522948ece0962cea5e14c79f65ba7.tar.gz wlclock-affa688b44a522948ece0962cea5e14c79f65ba7.tar.bz2 |
Change face/hand line width configuration
Also decided there will be no additional hand styles, so removed
--hand-style option. Xclock like hands can be enabled by setting the
hand width to 0 (default).
-rw-r--r-- | doc/wlclock.1.scd | 18 | ||||
-rw-r--r-- | src/render.c | 12 | ||||
-rw-r--r-- | src/wlclock.c | 50 | ||||
-rw-r--r-- | src/wlclock.h | 9 |
4 files changed, 30 insertions, 59 deletions
diff --git a/doc/wlclock.1.scd b/doc/wlclock.1.scd index 05638df..8641d66 100644 --- a/doc/wlclock.1.scd +++ b/doc/wlclock.1.scd @@ -55,18 +55,9 @@ to work. default is "stationary". The exact implementation is compositor dependant; A compositor may choose to ignore the requested exclusive zone of surfaces. -*--face-line-size* <size> - The width of lines on the clock face, such as the minute markers. - The default is 1. - -*--hand-line-size* <size> - The width of lines of the clock hands, if hand style is set to "lines". - The default is 1. - -*--hand-style* <style> - Style of the clock hands. Can be "xclock", where wlclock draws xclock-esque - triangles, and "lines", where wlclock draws straight lines. The default is - "xclock". +*--hand-width* <size> + The width of the clock hands. If set to 0, wlclock will draw xclock-like + clock hands. The default is 0. *--layer* <layer> Layer of the layer surface. Can be "overlay", "top", "bottom" or @@ -79,6 +70,9 @@ to work. Set the margin. Requires either one argument, to set all margins, or four arguments, to set the margins individually. The default margin is 0. +*--marking-width* <size> + The width of the markings on the clock face. The default is 1. + *--namespace* <namespace> The namespace of the layers surface. Some compositors may treat layer surfaces differently based on their namespace. The default is "wlclock". diff --git a/src/render.c b/src/render.c index b5ad557..975b393 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->face_line_size == 0 ) + if ( clock->marking_width == 0 ) return; /* Radii are choosen to roughly mimic xclock. */ @@ -137,7 +137,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->face_line_size * scale); + cairo_set_line_width(cairo, clock->marking_width * scale); colour_set_cairo_source(cairo, &clock->clock_colour); cairo_stroke(cairo); cairo_restore(cairo); @@ -164,8 +164,10 @@ static void draw_clock_hands (cairo_t *cairo, int32_t size, int32_t scale, struc cairo_save(cairo); colour_set_cairo_source(cairo, &clock->clock_colour); - if ( clock->hand_style == STYLE_XCLOCK ) + if ( clock->hand_width == 0 ) { + /* Xclock-esque clock hands. Not pixel-perfect, but close enough. */ + /* Minutes */ cairo_move_to(cairo, cxy + mr * cos(phi_min), cxy + mr * sin(phi_min)); cairo_line_to(cairo, cxy + ir * cos(phi_min + 2.0 / 3.0 * PI), @@ -185,7 +187,7 @@ static void draw_clock_hands (cairo_t *cairo, int32_t size, int32_t scale, struc cairo_close_path(cairo); cairo_fill(cairo); } - else if ( clock->hand_style == STYLE_LINES ) + else { /* Minutes */ cairo_move_to(cairo, cxy + mr * cos(phi_min), cxy + mr * sin(phi_min)); @@ -195,7 +197,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->hand_line_size); + cairo_set_line_width(cairo, scale * clock->hand_width); cairo_stroke(cairo); } diff --git a/src/wlclock.c b/src/wlclock.c index 89b6e5f..35dffc7 100644 --- a/src/wlclock.c +++ b/src/wlclock.c @@ -183,11 +183,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) CLOCK_COLOUR, CORNER_RADIUS, EXCLUSIVE_ZONE, - FACE_LINE_SIZE, - HAND_LINE_SIZE, - HAND_STYLE, + HAND_WIDTH, LAYER, MARGIN, + MARKING_WIDTH, NAMEPSACE, NO_INPUT, OUTPUT, @@ -207,11 +206,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) {"clock-colour", required_argument, NULL, CLOCK_COLOUR}, {"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}, + {"hand-width", required_argument, NULL, HAND_WIDTH}, {"layer", required_argument, NULL, LAYER}, {"margin", required_argument, NULL, MARGIN}, + {"marking-width", required_argument, NULL, MARKING_WIDTH}, {"namespace", required_argument, NULL, NAMEPSACE}, {"no-input", no_argument, NULL, NO_INPUT}, {"output", required_argument, NULL, OUTPUT}, @@ -232,11 +230,10 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) " --clock-colour Colour of the clock elements.\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" + " --hand-width Width of the clock hands.\n" " --layer Layer of the layer surface.\n" " --margin Directional margins.\n" + " --marking-width Width of the markings on the clock face.\n" " --namespace Namespace of the layer surface.\n" " --no-input Let inputs surface pass trough the layer surface.\n" " --output The output which the clock will be displayed.\n" @@ -342,20 +339,20 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) return false; break; - case FACE_LINE_SIZE: - clock->face_line_size = atoi(optarg); - if ( clock->face_line_size < 0 ) + case MARKING_WIDTH: + clock->marking_width = atoi(optarg); + if ( clock->marking_width < 0 ) { - clocklog(NULL, 0, "ERROR: Face line size may not be smaller than 0.\n"); + clocklog(NULL, 0, "ERROR: Marking width may not be smaller than zero.\n"); return false; } break; - case HAND_LINE_SIZE: - clock->hand_line_size = atoi(optarg); - if ( clock->hand_line_size < 1 ) + case HAND_WIDTH: + clock->hand_width = atoi(optarg); + if ( clock->hand_width < 0 ) { - clocklog(NULL, 0, "ERROR: Hand line size may not be smaller than 1.\n"); + clocklog(NULL, 0, "ERROR: Hand width may not be smaller than zero.\n"); return false; } break; @@ -479,20 +476,6 @@ static bool handle_command_flags (struct Wlclock *clock, int argc, char *argv[]) } break; - case HAND_STYLE: - if (! strcmp(optarg, "xclock")) - clock->hand_style = STYLE_XCLOCK; - else if (! strcmp(optarg, "lines")) - clock->hand_style = STYLE_LINES; - else - { - clocklog(NULL, 0, "ERROR: Unrecognized hand style \"%s\".\n" - "INFO: Possible hand styles are " - "'xclock' and 'lines'.\n", optarg); - return false; - } - break; - default: return false; } @@ -637,9 +620,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.face_line_size = 1; - clock.hand_line_size = 1; - clock.hand_style = STYLE_XCLOCK; + clock.marking_width = 1; + clock.hand_width = 0; colour_from_string(&clock.background_colour, "#FFFFFF"); colour_from_string(&clock.border_colour, "#000000"); colour_from_string(&clock.clock_colour, "#000000"); diff --git a/src/wlclock.h b/src/wlclock.h index a2dd9ce..bf2c19e 100644 --- a/src/wlclock.h +++ b/src/wlclock.h @@ -10,12 +10,6 @@ #include"colour.h" -enum Hand_style -{ - STYLE_XCLOCK, - STYLE_LINES -}; - struct Wlclock_dimensions { /* Width and height of entire surface (size + borders). */ @@ -47,14 +41,13 @@ struct Wlclock enum zwlr_layer_shell_v1_layer layer; struct Wlclock_dimensions dimensions; char *namespace; - int32_t face_line_size, hand_line_size; + int32_t marking_width, hand_width; int32_t exclusive_zone; int32_t border_top, border_right, border_bottom, border_left; int32_t margin_top, margin_right, margin_bottom, margin_left; int32_t radius_top_left, radius_top_right, radius_bottom_left, radius_bottom_right; int32_t anchor; bool input, snap; - enum Hand_style hand_style; struct Wlclock_colour background_colour; struct Wlclock_colour border_colour; |