aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-08 16:19:31 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-08 16:25:07 +1000
commit9215ca0f01f7d155191d11fd9caa2574387c6f84 (patch)
treea1defcadae4b1d07388fd9e6bfe2a09051aec777 /swaybar/render.c
parentFix gaps in title textures and vertically center them (diff)
downloadsway-9215ca0f01f7d155191d11fd9caa2574387c6f84.tar.gz
sway-9215ca0f01f7d155191d11fd9caa2574387c6f84.tar.zst
sway-9215ca0f01f7d155191d11fd9caa2574387c6f84.zip
Align titles to baseline
This does the following: * Adds a baseline argument to get_text_size (the baseline is the distance from the top of the texture to the baseline). * Stores the baseline in the container when calculating the title height. * Takes the baseline into account when calculating the config's max font height. * When rendering, pads the textures according to the baseline so they line up.
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 702e863c..7303e70f 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -33,8 +33,8 @@ static uint32_t render_status_line_error(cairo_t *cairo,
33 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 33 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
34 34
35 int text_width, text_height; 35 int text_width, text_height;
36 get_text_size(cairo, config->font, 36 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
37 &text_width, &text_height, output->scale, false, "%s", error); 37 output->scale, false, "%s", error);
38 38
39 uint32_t ideal_height = text_height + ws_vertical_padding * 2; 39 uint32_t ideal_height = text_height + ws_vertical_padding * 2;
40 uint32_t ideal_surface_height = ideal_height / output->scale; 40 uint32_t ideal_surface_height = ideal_height / output->scale;
@@ -63,7 +63,7 @@ static uint32_t render_status_line_text(cairo_t *cairo,
63 config->colors.focused_statusline : config->colors.statusline); 63 config->colors.focused_statusline : config->colors.statusline);
64 64
65 int text_width, text_height; 65 int text_width, text_height;
66 get_text_size(cairo, config->font, &text_width, &text_height, 66 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
67 output->scale, config->pango_markup, "%s", text); 67 output->scale, config->pango_markup, "%s", text);
68 68
69 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 69 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
@@ -126,7 +126,7 @@ static uint32_t render_status_block(cairo_t *cairo,
126 uint32_t height = surface_height * output->scale; 126 uint32_t height = surface_height * output->scale;
127 127
128 int text_width, text_height; 128 int text_width, text_height;
129 get_text_size(cairo, config->font, &text_width, &text_height, 129 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
130 output->scale, block->markup, "%s", block->full_text); 130 output->scale, block->markup, "%s", block->full_text);
131 131
132 int margin = 3 * output->scale; 132 int margin = 3 * output->scale;
@@ -157,7 +157,7 @@ static uint32_t render_status_block(cairo_t *cairo,
157 int sep_width, sep_height; 157 int sep_width, sep_height;
158 if (!edge) { 158 if (!edge) {
159 if (config->sep_symbol) { 159 if (config->sep_symbol) {
160 get_text_size(cairo, config->font, &sep_width, &sep_height, 160 get_text_size(cairo, config->font, &sep_width, &sep_height, NULL,
161 output->scale, false, "%s", config->sep_symbol); 161 output->scale, false, "%s", config->sep_symbol);
162 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; 162 uint32_t _ideal_height = sep_height + ws_vertical_padding * 2;
163 uint32_t _ideal_surface_height = _ideal_height / output->scale; 163 uint32_t _ideal_surface_height = _ideal_height / output->scale;
@@ -297,7 +297,7 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
297 uint32_t height = surface_height * output->scale; 297 uint32_t height = surface_height * output->scale;
298 298
299 int text_width, text_height; 299 int text_width, text_height;
300 get_text_size(cairo, config->font, &text_width, &text_height, 300 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
301 output->scale, config->mode_pango_markup, 301 output->scale, config->mode_pango_markup,
302 "%s", mode); 302 "%s", mode);
303 303
@@ -379,7 +379,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
379 uint32_t height = surface_height * output->scale; 379 uint32_t height = surface_height * output->scale;
380 380
381 int text_width, text_height; 381 int text_width, text_height;
382 get_text_size(cairo, config->font, &text_width, &text_height, 382 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
383 output->scale, config->pango_markup, "%s", name); 383 output->scale, config->pango_markup, "%s", name);
384 384
385 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 385 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;