Skip to content

Commit 5321a4c

Browse files
authored
Make border-radius values follow clockwise direction
Closes: emersion#560
1 parent c7537bd commit 5321a4c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

render.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ static void move_to(cairo_t *cairo, double x, double y, int scale) {
3636
}
3737

3838
static void set_rounded_rectangle(cairo_t *cairo, double x, double y, double width, double height,
39-
int scale, int radius_top, int radius_right, int radius_bottom, int radius_left) {
39+
int scale, int radius_top_left, int radius_top_right, int radius_bottom_right, int radius_bottom_left) {
4040
if (width == 0 || height == 0) {
4141
return;
4242
}
4343
x *= scale;
4444
y *= scale;
4545
width *= scale;
4646
height *= scale;
47-
radius_top *= scale;
48-
radius_right *= scale;
49-
radius_bottom *= scale;
50-
radius_left *= scale;
47+
radius_top_left *= scale;
48+
radius_top_right *= scale;
49+
radius_bottom_right *= scale;
50+
radius_bottom_left *= scale;
5151
double degrees = M_PI / 180.0;
5252

5353
cairo_new_sub_path(cairo);
5454

55-
cairo_arc(cairo, x + width - radius_right, y + radius_right, radius_right, -90 * degrees, 0 * degrees);
56-
cairo_arc(cairo, x + width - radius_left, y + height - radius_left, radius_left, 0 * degrees, 90 * degrees);
57-
cairo_arc(cairo, x + radius_bottom, y + height - radius_bottom, radius_bottom, 90 * degrees, 180 * degrees);
58-
cairo_arc(cairo, x + radius_top, y + radius_top, radius_top, 180 * degrees, 270 * degrees);
55+
cairo_arc(cairo, x + radius_top_left, y + radius_top_left, radius_top_left, 180 * degrees, 270 * degrees);
56+
cairo_arc(cairo, x + width - radius_top_right, y + radius_top_right, radius_top_right, -90 * degrees, 0 * degrees);
57+
cairo_arc(cairo, x + width - radius_bottom_right, y + height - radius_bottom_right, radius_bottom_right, 0 * degrees, 90 * degrees);
58+
cairo_arc(cairo, x + radius_bottom_left, y + height - radius_bottom_left, radius_bottom_left, 90 * degrees, 180 * degrees);
5959

6060
cairo_close_path(cairo);
6161
}
@@ -101,10 +101,10 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct
101101
int border_size = 2 * style->border_size;
102102
int padding_height = style->padding.top + style->padding.bottom;
103103
int padding_width = style->padding.left + style->padding.right;
104-
int radius_top = style->border_radius.top;
105-
int radius_right = style->border_radius.right;
106-
int radius_bottom = style->border_radius.bottom;
107-
int radius_left = style->border_radius.left;
104+
int radius_top_left = style->border_radius.top;
105+
int radius_top_right = style->border_radius.right;
106+
int radius_bottom_right = style->border_radius.bottom;
107+
int radius_bottom_left = style->border_radius.left;
108108
int icon_radius = style->icon_border_radius;
109109
bool icon_vertical = style->icon_location == MAKO_ICON_LOCATION_TOP ||
110110
style->icon_location == MAKO_ICON_LOCATION_BOTTOM;
@@ -204,11 +204,11 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct
204204
if (icon != NULL && ! icon_vertical && icon->height > text_height) {
205205
notif_height = icon->height + border_size + padding_height;
206206
}
207-
if (notif_height < radius_top + radius_bottom) {
208-
notif_height = radius_top + radius_bottom + border_size;
207+
if (notif_height < radius_top_left + radius_bottom_left) {
208+
notif_height = radius_top_left + radius_bottom_left + border_size;
209209
}
210-
if (notif_height < radius_right + radius_left) {
211-
notif_height = radius_right + radius_left + border_size;
210+
if (notif_height < radius_top_right + radius_bottom_right) {
211+
notif_height = radius_top_right + radius_bottom_right + border_size;
212212
}
213213

214214
int notif_background_width = notif_width - style->border_size;
@@ -221,7 +221,7 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct
221221
offset_y + style->border_size / 2.0,
222222
notif_background_width,
223223
notif_height - style->border_size,
224-
scale, radius_top, radius_right, radius_bottom, radius_left);
224+
scale, radius_top_left, radius_top_right, radius_bottom_right, radius_bottom_left);
225225

226226
// Render background, keeping the path.
227227
set_source_u32(cairo, style->colors.background);

0 commit comments

Comments
 (0)