Skip to content
Myr

refactor: DRY repetive code to calculate row_bg_x()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Adds new documented function and updates callers to use it.

authored by Mark Stosberg · committed by Daniel Eklöf · parent 1656dfb · Browse files · 1 file+22 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−14 removed

  • other:+22 added−14 removed

1 file+22 added−14 removed

modified:render.c+22 added-14 removed
621 unmodified lines
622 }623624}625626/*627 * Returns the x-coordinate of the left edge of the row background area.628 * The background extends slightly past the text content edge (border + x_margin)629 * by sel_margin (= x_margin / 3) on each side, so the selection highlight630 * has a small gap from the window border while bleeding into the margin.631 */632static int633row_bg_x(const struct render *render)634{635 const int sel_margin = render->x_margin / 3;636 return render->border_size + render->x_margin - sel_margin;637}638639void640render_message(struct render *render, struct buffer *buf)641{642 if (!render->conf->message) return;
18 unmodified lines
661 //pixman_color_t bg = (pixman_color_t){0xffff, 0, 0, 0xffff};662 pixman_image_fill_rectangles(663 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,664 &(pixman_rectangle16_t){652 render->border_size + render->x_margin - render->x_margin / 3,665 row_bg_x(render),666 render->border_size + render->y_margin,654 buf->width - 2 * (render->border_size + render->x_margin - render->x_margin / 3),667 buf->width - 2 * row_bg_x(render),668 render->message_height});669670 struct fcft_text_run *message_run = render->message_text_run;671
122 unmodified lines
794 //pixman_color_t bg = (pixman_color_t){0xffff, 0, 0, 0xffff};795 pixman_image_fill_rectangles(796 PIXMAN_OP_SRC, buf->pix[0], &bg, 1,797 &(pixman_rectangle16_t){785 render->border_size + render->x_margin - render->x_margin / 3,798 row_bg_x(render),799 render->border_size + render->y_margin + render->message_height,787 buf->width - 2 * (render->border_size + render->x_margin - render->x_margin / 3),800 buf->width - 2 * row_bg_x(render),801 render->row_height});802803#if 0804 bg = (pixman_color_t){0, 0xffff, 0, 0xffff};
796 unmodified lines
1601 pixman_image_t *pix, int width)1602{1603 pixman_color_t bg = render->pix_background_color;16041592 const int sel_margin = render->x_margin / 3;15931594 const int x = render->border_size + render->x_margin - sel_margin;1605 const int x = row_bg_x(render);1606 const int y = first_row_y(render) + idx * render->row_height;1596 const int w = width - 2 * (render->border_size + render->x_margin - sel_margin);1607 const int w = width - 2 * row_bg_x(render);1608 const int h = row_count * render->row_height;16091610 pixman_image_fill_rectangles(1611 PIXMAN_OP_SRC, pix, &bg, 1, &(pixman_rectangle16_t){x, y, w, h});
4 unmodified lines
1616 int idx, pixman_image_t *pix, int width)1617{1618 pixman_color_t bg = render->pix_selection_color;16191609 const int sel_margin = render->x_margin / 3;16101611 const int x = render->border_size + render->x_margin - sel_margin;1620 const int x = row_bg_x(render);1621 const int y = first_row_y(render) + idx * render->row_height;1613 const int w = width - 2 * (render->border_size + render->x_margin - sel_margin);1622 const int w = width - 2 * row_bg_x(render);1623 const int h = 1 * render->row_height;16241625 // limit radius to half of height, any larger and it causes weird shapes1626 // also limit it when horizontal padding is small, to prevent icon pop out
532 unmodified lines
2159ssize_t2160render_get_row_num(const struct render *render, int width, int x, int y,2161 const struct matches *matches)2162{2154 const int border_size = render->border_size;2163 const int row_height = render->row_height;21642157 const int min_x = border_size + render->x_margin - render->x_margin / 3;2165 const int min_x = row_bg_x(render);2166 const int max_x = width - (min_x);21672168 const int first_row = first_row_y(render);2169
21 unmodified lines