diff options
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 41 |
1 files changed, 20 insertions, 21 deletions
@@ -36,6 +36,7 @@ Drawer *draw_create(const char *font, int height, int left_pad, int right_pad, i return draw; } +// TODO: Remove this static void compute_width(Drawer *draw, Window *win, int *width, int *height) { int screen_width = win->con->screen_size->width; @@ -71,27 +72,27 @@ void draw_paint(Drawer *draw, Window *win) cairo_push_group(cr); - int radius = layout->height / 2; + int radius = (layout->height - 2 * layout->y_pad) / 2; Color color = btn->color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_new_sub_path(cr); - cairo_arc(cr, layout->x + radius, layout->y + radius, radius, 90 * degree, 270 * degree); - cairo_arc(cr, layout->x + layout->width - radius, layout->y + radius, radius, 270 * degree, 450 * degree); + cairo_arc(cr, layout->x + layout->x_pad + radius, layout->y + layout->y_pad + radius, radius, 90 * degree, 270 * degree); + cairo_arc(cr, layout->x + layout->width - layout->x_pad - radius, layout->y + layout->y_pad + radius, radius, 270 * degree, 450 * degree); cairo_close_path(cr); cairo_fill(cr); color = btn->line_color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_new_sub_path(cr); - cairo_arc(cr, layout->x + radius, layout->y + radius, radius - line_w , 90 * degree, 270 * degree); - cairo_arc(cr, layout->x + layout->width - radius, layout->y + radius, radius - line_w, 270 * degree, 450 * degree); + cairo_arc(cr, layout->x + layout->x_pad + radius, layout->y + layout->y_pad + radius, radius - line_w, 90 * degree, 270 * degree); + cairo_arc(cr, layout->x + layout->width - layout->x_pad - radius, layout->y + layout->y_pad + radius, radius - line_w, 270 * degree, 450 * degree); cairo_close_path(cr); cairo_stroke(cr); if (btn->simple) { - int text_x = layout->x + (layout->width / 2) - (layout->text_w / 2); - int text_y = layout->y + (layout->height / 2) - (layout->text_h / 2); + int text_x = layout->x + layout->width / 2 - layout->text_w / 2; + int text_y = layout->y + layout->y_pad + radius - layout->text_h / 2; color = CAST(btn, ButtonSimple)->text_color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); @@ -155,7 +156,6 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) g_list_free_full(draw->layouts, (GDestroyNotify)layout_destroy); draw->layouts = NULL; - // Remove this... int width, height; compute_width(draw, win, &width, &height); @@ -178,8 +178,11 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) if (prev != NULL && prev->align == btn->align) x += sep; - layout->x = x + btn->padding; - layout->y = btn->padding; + layout->x_pad = btn->x_pad; + layout->y_pad = btn->y_pad; + + layout->x = x; + layout->y = 0; draw->layouts = g_list_prepend(draw->layouts, layout); @@ -205,8 +208,11 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) Layout *child = g_malloc(sizeof(Layout)); child->btn = btn; - child->x = x + btn->padding; - child->y = btn->padding; + child->x_pad = btn->x_pad; + child->y_pad = btn->y_pad; + + child->x = x; + child->y = 0; child->pl = pango_cairo_create_layout(window_get_context(win)); layout_text(child, draw->desc, height, radius); @@ -214,10 +220,6 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) draw->layouts = g_list_prepend(draw->layouts, child); x += child->width + line_w * 2; - - child->width -= 2 * btn->padding; - child->height -= 2 * btn->padding; - if (it->next != NULL) x += sep; } @@ -227,8 +229,8 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) // FIXME: Temporary solution to make the antialiasing (or the circles not overlapping correctly) problem less noticeable - 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; + bool fix_left = CAST(g_list_first(group->children)->data, Button)->x_pad == 0; + bool fix_right = CAST(g_list_last(group->children)->data, Button)->x_pad == 0; if (fix_left) { layout->x += 1; @@ -255,9 +257,6 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns) } x += layout->width + line_w * 2; - - layout->width -= 2 * btn->padding; - layout->height -= 2 * btn->padding; } prev = btn; |
