|
|
|
@ -51,7 +51,8 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color, double x, double y
|
|
|
|
|
|
|
|
|
|
static void render_block(struct window *window, struct config *config, struct status_block *block, double *x, bool edge) {
|
|
|
|
|
int width, height, sep_width;
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height, block->markup, "%s", block->full_text);
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height,
|
|
|
|
|
window->scale, block->markup, "%s", block->full_text);
|
|
|
|
|
|
|
|
|
|
int textwidth = width;
|
|
|
|
|
double block_width = width;
|
|
|
|
@ -75,7 +76,8 @@ static void render_block(struct window *window, struct config *config, struct st
|
|
|
|
|
// Add separator
|
|
|
|
|
if (!edge) {
|
|
|
|
|
if (config->sep_symbol) {
|
|
|
|
|
get_text_size(window->cairo, window->font, &sep_width, &height, false, "%s", config->sep_symbol);
|
|
|
|
|
get_text_size(window->cairo, window->font, &sep_width, &height,
|
|
|
|
|
window->scale, false, "%s", config->sep_symbol);
|
|
|
|
|
if (sep_width > block->separator_block_width) {
|
|
|
|
|
block->separator_block_width = sep_width + margin * 2;
|
|
|
|
|
}
|
|
|
|
@ -137,7 +139,8 @@ static void render_block(struct window *window, struct config *config, struct st
|
|
|
|
|
|
|
|
|
|
cairo_move_to(window->cairo, offset, margin);
|
|
|
|
|
cairo_set_source_u32(window->cairo, block->color);
|
|
|
|
|
pango_printf(window->cairo, window->font, block->markup, "%s", block->full_text);
|
|
|
|
|
pango_printf(window->cairo, window->font, window->scale,
|
|
|
|
|
block->markup, "%s", block->full_text);
|
|
|
|
|
|
|
|
|
|
pos += width;
|
|
|
|
|
|
|
|
|
@ -160,7 +163,8 @@ static void render_block(struct window *window, struct config *config, struct st
|
|
|
|
|
if (config->sep_symbol) {
|
|
|
|
|
offset = pos + (block->separator_block_width - sep_width) / 2;
|
|
|
|
|
cairo_move_to(window->cairo, offset, margin);
|
|
|
|
|
pango_printf(window->cairo, window->font, false, "%s", config->sep_symbol);
|
|
|
|
|
pango_printf(window->cairo, window->font, window->scale,
|
|
|
|
|
false, "%s", config->sep_symbol);
|
|
|
|
|
} else {
|
|
|
|
|
cairo_set_line_width(window->cairo, 1);
|
|
|
|
|
cairo_move_to(window->cairo, pos + block->separator_block_width/2,
|
|
|
|
@ -200,7 +204,8 @@ static const char *strip_workspace_name(bool strip_num, const char *ws_name) {
|
|
|
|
|
void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height) {
|
|
|
|
|
const char *stripped_name = strip_workspace_name(swaybar.config->strip_workspace_numbers, workspace_name);
|
|
|
|
|
|
|
|
|
|
get_text_size(window->cairo, window->font, width, height, false, "%s", stripped_name);
|
|
|
|
|
get_text_size(window->cairo, window->font, width, height,
|
|
|
|
|
window->scale, false, "%s", stripped_name);
|
|
|
|
|
*width += 2 * ws_horizontal_padding;
|
|
|
|
|
*height += 2 * ws_vertical_padding;
|
|
|
|
|
}
|
|
|
|
@ -235,14 +240,16 @@ static void render_workspace_button(struct window *window, struct config *config
|
|
|
|
|
// text
|
|
|
|
|
cairo_set_source_u32(window->cairo, box_colors.text);
|
|
|
|
|
cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin);
|
|
|
|
|
pango_printf(window->cairo, window->font, false, "%s", stripped_name);
|
|
|
|
|
pango_printf(window->cairo, window->font, window->scale,
|
|
|
|
|
false, "%s", stripped_name);
|
|
|
|
|
|
|
|
|
|
*x += width + ws_spacing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void render_binding_mode_indicator(struct window *window, struct config *config, double pos) {
|
|
|
|
|
int width, height;
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height, false, "%s", config->mode);
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height,
|
|
|
|
|
window->scale, false, "%s", config->mode);
|
|
|
|
|
|
|
|
|
|
// background
|
|
|
|
|
cairo_set_source_u32(window->cairo, config->colors.binding_mode.background);
|
|
|
|
@ -259,7 +266,8 @@ static void render_binding_mode_indicator(struct window *window, struct config *
|
|
|
|
|
// text
|
|
|
|
|
cairo_set_source_u32(window->cairo, config->colors.binding_mode.text);
|
|
|
|
|
cairo_move_to(window->cairo, (int)pos + ws_horizontal_padding, margin);
|
|
|
|
|
pango_printf(window->cairo, window->font, false, "%s", config->mode);
|
|
|
|
|
pango_printf(window->cairo, window->font, window->scale,
|
|
|
|
|
false, "%s", config->mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render(struct output *output, struct config *config, struct status_line *line) {
|
|
|
|
@ -283,10 +291,12 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
if (line->protocol == TEXT) {
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height, config->pango_markup, "%s", line->text_line);
|
|
|
|
|
get_text_size(window->cairo, window->font, &width, &height,
|
|
|
|
|
window->scale, config->pango_markup, "%s", line->text_line);
|
|
|
|
|
cairo_move_to(cairo, (window->width * window->scale)
|
|
|
|
|
- margin - width, margin);
|
|
|
|
|
pango_printf(window->cairo, window->font, config->pango_markup, "%s", line->text_line);
|
|
|
|
|
pango_printf(window->cairo, window->font, window->scale,
|
|
|
|
|
config->pango_markup, "%s", line->text_line);
|
|
|
|
|
} else if (line->protocol == I3BAR && line->block_line) {
|
|
|
|
|
double pos = window->width - 0.5;
|
|
|
|
|
bool edge = true;
|
|
|
|
@ -319,7 +329,7 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|
|
|
|
void set_window_height(struct window *window, int height) {
|
|
|
|
|
int text_width, text_height;
|
|
|
|
|
get_text_size(window->cairo, window->font,
|
|
|
|
|
&text_width, &text_height, false,
|
|
|
|
|
&text_width, &text_height, window->scale, false,
|
|
|
|
|
"Test string for measuring purposes");
|
|
|
|
|
if (height > 0) {
|
|
|
|
|
margin = (height - text_height) / 2;
|
|
|
|
|