aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/draw.c b/src/draw.c
index 4d983d6..16a5669 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -64,7 +64,6 @@ void draw_paint(Drawable *draw, Window *win)
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- int radius = height / 2;
double degree = M_PI / 180.0;
cairo_set_source_rgba(cr, draw->background.r, draw->background.g, draw->background.b, draw->background.a);
@@ -75,6 +74,7 @@ void draw_paint(Drawable *draw, Window *win)
// This is caused by some difference between the two shapes (that should technically be the same)
// which causes a mismatch between the two layers and leaves some black pixels visible
+ //int radius = height / 2;
//cairo_arc(cr, radius, radius, radius, 90.0 * degree, 270 * degree);
//cairo_arc(cr, width - radius, radius, radius, 270 * degree, 450 * degree);
//cairo_fill(cr);
@@ -87,6 +87,8 @@ void draw_paint(Drawable *draw, Window *win)
for (GList *it = draw->layouts; it; it = it->next) {
Layout *layout = it->data;
+ int radius = layout->height / 2;
+
Color color = layout->btn->color;
cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
cairo_new_sub_path(cr);
@@ -192,8 +194,8 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
if (prev != NULL && prev->align == btn->align) x += sep;
- layout->x = x;
- layout->y = 0;
+ layout->x = x + btn->padding;
+ layout->y = btn->padding;
draw->layouts = g_list_prepend(draw->layouts, layout);
@@ -215,8 +217,8 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
Layout *child = g_malloc(sizeof(Layout));
child->btn = btn;
- child->x = x;
- child->y = 0;
+ child->x = x + btn->padding;
+ child->y = btn->padding;;
child->pl = pango_cairo_create_layout(window_get_context(win));
layout_text(child, draw->desc, scale, height, radius);
@@ -225,6 +227,9 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
x += child->width + line_w * 2;
+ child->width -= 2 * btn->padding;
+ child->height -= 2 * btn->padding;
+
if (it->next != NULL) x += sep;
}
@@ -233,8 +238,15 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
layout->height = height;
// FIXME: Temporary solution to make the antialiasing (or the circles not overlapping correctly) problem less noticeable
- layout->x += 1;
- layout->width -= 2;
+
+ bool fix_left = CAST(g_list_first(group->children)->data, Button)->padding == 0;
+ bool fix_right = CAST(g_list_last(group->children)->data, Button)->padding == 0;
+
+ if (fix_left) {
+ layout->x += 1;
+ layout->width -= 1;
+ }
+ if (fix_right) layout->width -= 1;
goto end;
}
}
@@ -243,6 +255,9 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
layout_text(layout, draw->desc, scale, height, radius);
x += layout->width + line_w * 2;
+ layout->width -= 2 * btn->padding;
+ layout->height -= 2 * btn->padding;
+
end:
if (prev != NULL && prev->align != btn->align) {
if (btn->align == PANGO_ALIGN_CENTER) adjust_center = draw->layouts;