aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/draw.c b/src/draw.c
index 131b944..69de9fd 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -40,23 +40,15 @@ Drawable *draw_create(const char *font, int height, int left_pad, int right_pad,
static void compute_width(Drawable *draw, Window *win, int *width, int *height)
{
- // FIXME: Does not work for scale != 1
- //double scale = window_get_scale(win);
- double scale = 1;
-
int screen_width = win->con->screen_size->width;
int screen_height = win->con->screen_size->height;
- *width = round(screen_width - draw->right_pad - draw->left_pad * scale);
- *height = round(draw->height * scale);
+ *width = round(screen_width - draw->right_pad - draw->left_pad);
+ *height = round(draw->height);
}
void draw_paint(Drawable *draw, Window *win)
{
- // FIXME: Does not work for scale != 1
- //double scale = window_get_scale(win);
- double scale = 1;
-
int width, height;
compute_width(draw, win, &width, &height);
@@ -72,7 +64,7 @@ void draw_paint(Drawable *draw, Window *win)
cairo_set_source_rgba(cr, draw->background.r, draw->background.g, draw->background.b, draw->background.a);
cairo_paint(cr);
- int line_w = draw->line_w * scale;
+ int line_w = draw->line_w;
cairo_set_line_width(cr, line_w);
for (GList *it = draw->layouts; it; it = it->next) {
@@ -121,18 +113,8 @@ void draw_paint(Drawable *draw, Window *win)
cairo_surface_destroy(surface);
}
-static gint align_compare(gconstpointer a, gconstpointer b)
-{
- PangoAlignment a_align = ((Button *)a)->align;
- PangoAlignment b_align = ((Button *)b)->align;
-
- if (a_align < b_align) return -1;
- if (a_align > b_align) return 1;
- return 0;
-}
-
// Works only for simple buttons
-static void layout_text(Layout *layout, PangoFontDescription *desc, double scale, int height, int radius)
+static void layout_text(Layout *layout, PangoFontDescription *desc, int height, int radius)
{
const char *text = CAST(layout->btn, ButtonSimple)->text;
@@ -143,8 +125,8 @@ static void layout_text(Layout *layout, PangoFontDescription *desc, double scale
int text_w, text_h;
pango_layout_get_pixel_size(layout->pl, &text_w, &text_h);
- layout->text_w = ceil(text_w / scale);
- layout->text_h = ceil(text_h / scale);
+ layout->text_w = ceil(text_w);
+ layout->text_h = ceil(text_h);
// If there is only one glyph the button should be round
size_t text_l = g_utf8_strlen(text, -1);
@@ -158,23 +140,17 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
g_list_free_full(draw->layouts, (GDestroyNotify)layout_destroy);
draw->layouts = NULL;
- // FIXME: Does not work for scale != 1
- //double scale = window_get_scale(win);
- double scale = 1;
-
// Remove this...
int width, height;
compute_width(draw, win, &width, &height);
- // Order by alignment
- btns = g_list_sort(btns, align_compare);
Button *prev = NULL;
int x = 0;
int radius = height / 2;
- int sep = 10 * scale;
- int line_w = draw->line_w * scale;
+ int sep = 10;
+ int line_w = draw->line_w;
GList *layout_start[3] = { NULL };
int layout_end[3] = { 0 };
@@ -218,7 +194,7 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
child->y = btn->padding;
child->pl = pango_cairo_create_layout(window_get_context(win));
- layout_text(child, draw->desc, scale, height, radius);
+ layout_text(child, draw->desc, height, radius);
draw->layouts = g_list_prepend(draw->layouts, child);
@@ -249,7 +225,7 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns)
if (layout->btn->simple) {
layout->pl = pango_cairo_create_layout(window_get_context(win));
- layout_text(layout, draw->desc, scale, height, radius);
+ layout_text(layout, draw->desc, height, radius);
x += layout->width + line_w * 2;
layout->width -= 2 * btn->padding;