From 9215ca0f01f7d155191d11fd9caa2574387c6f84 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 8 Sep 2018 16:19:31 +1000 Subject: 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. --- swaybar/render.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'swaybar') 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, int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; int text_width, text_height; - get_text_size(cairo, config->font, - &text_width, &text_height, output->scale, false, "%s", error); + get_text_size(cairo, config->font, &text_width, &text_height, NULL, + output->scale, false, "%s", error); uint32_t ideal_height = text_height + ws_vertical_padding * 2; uint32_t ideal_surface_height = ideal_height / output->scale; @@ -63,7 +63,7 @@ static uint32_t render_status_line_text(cairo_t *cairo, config->colors.focused_statusline : config->colors.statusline); int text_width, text_height; - get_text_size(cairo, config->font, &text_width, &text_height, + get_text_size(cairo, config->font, &text_width, &text_height, NULL, output->scale, config->pango_markup, "%s", text); int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; @@ -126,7 +126,7 @@ static uint32_t render_status_block(cairo_t *cairo, uint32_t height = surface_height * output->scale; int text_width, text_height; - get_text_size(cairo, config->font, &text_width, &text_height, + get_text_size(cairo, config->font, &text_width, &text_height, NULL, output->scale, block->markup, "%s", block->full_text); int margin = 3 * output->scale; @@ -157,7 +157,7 @@ static uint32_t render_status_block(cairo_t *cairo, int sep_width, sep_height; if (!edge) { if (config->sep_symbol) { - get_text_size(cairo, config->font, &sep_width, &sep_height, + get_text_size(cairo, config->font, &sep_width, &sep_height, NULL, output->scale, false, "%s", config->sep_symbol); uint32_t _ideal_height = sep_height + ws_vertical_padding * 2; uint32_t _ideal_surface_height = _ideal_height / output->scale; @@ -297,7 +297,7 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo, uint32_t height = surface_height * output->scale; int text_width, text_height; - get_text_size(cairo, config->font, &text_width, &text_height, + get_text_size(cairo, config->font, &text_width, &text_height, NULL, output->scale, config->mode_pango_markup, "%s", mode); @@ -379,7 +379,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, uint32_t height = surface_height * output->scale; int text_width, text_height; - get_text_size(cairo, config->font, &text_width, &text_height, + get_text_size(cairo, config->font, &text_width, &text_height, NULL, output->scale, config->pango_markup, "%s", name); int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; -- cgit v1.2.3