Skip to content
Myr

render: render_init(): margins and border size are now required arguments

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

authored by Daniel Eklöf · committed by Daniel Eklöf · parent c95ddb9 · Browse files · 3 files+20 added−10 removed
This commit

State

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

Diff stats

3 files+20 added−10 removed

  • other:+20 added−10 removed

3 files+20 added−10 removed

modified:main.c+2 added-3 removed
109 unmodified lines
110/* Window size */111static const int width = 500;112static const int height = 300;113114/* From render */115//static const double x_margin = 20;114static const double x_margin = 20;115static const double y_margin = 4;116static const double border_size = 1;117118static int max_matches;
1116 unmodified lines
1235 /* Trigger a 'configure' event, after which we'll have the width */1236 wl_surface_commit(c.wl.surface);1237 wl_display_roundtrip(c.wl.display);12381240 c.render = render_init(font, width, height);1239 c.render = render_init(font, width, height, x_margin, y_margin, border_size);12401241 refresh(&c);12421243 wl_display_dispatch_pending(c.wl.display);
99 unmodified lines
modified:render.c+16 added-6 removed
9 unmodified lines
1011struct render {12 int width;13 int height;14 int x_margin;15 int y_margin;16 int border_size;17 cairo_scaled_font_t *regular_font;18};1917static const double x_margin = 20;18static const double y_margin = 4;19static const double border_size = 1;2020void21render_prompt(const struct render *render, struct buffer *buf,22 const struct prompt *prompt)23{24 const double x_margin = render->x_margin;25 const double y_margin = render->y_margin;26 const double border_size = render->border_size;2728 cairo_set_scaled_font(buf->cairo, render->regular_font);2930 cairo_font_extents_t fextents;31 cairo_font_extents(buf->cairo, &fextents);
165 unmodified lines
197render_match_list(const struct render *render, struct buffer *buf,198 const struct match matches[], size_t match_count,199 size_t match_length, size_t selected)200{201 const double x_margin = render->x_margin;202 const double y_margin = render->y_margin;203 const double border_size = render->border_size;204205 assert(match_count == 0 || selected < match_count);206200207 cairo_set_scaled_font(buf->cairo, render->regular_font);208209 cairo_font_extents_t fextents;210 cairo_font_extents(buf->cairo, &fextents);
66 unmodified lines
277 }278}279280struct render *275render_init(cairo_scaled_font_t *font, int width, int height)281render_init(cairo_scaled_font_t *font, int width, int height,282 int x_margin, int y_margin, int border_size)283{284 struct render *render = calloc(1, sizeof(*render));285 render->width = width;286 render->height = height;287 render->x_margin = x_margin;288 render->y_margin = y_margin;289 render->border_size = border_size;290 render->regular_font = font;291 return render;292}293
9 unmodified lines
modified:render.h+2 added-1 removed
10 unmodified lines
11 size_t cursor;12};1314struct render;15struct render *render_init(cairo_scaled_font_t *font, int width, int height);15struct render *render_init(cairo_scaled_font_t *font, int width, int height,16 int x_margin, int y_margin, int border_size);17void render_destroy(struct render *render);1819void render_prompt(20 const struct render *render, struct buffer *buf,
5 unmodified lines