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
Provenance
- Commit
71dc2bc- Tree
55e869e- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent
c95ddb9
3 files changed+20 added−10 removed
modified:main.c+2 added-3 removed
109 unmodified lines110 /* Window size */111 static const int width = 500;112 static const int height = 300;113 114-/* From render */115-//static const double x_margin = 20;114+static const double x_margin = 20;115 static const double y_margin = 4;116 static const double border_size = 1;117 118 static int max_matches;1116 unmodified lines1235 /* 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);1238 1240- c.render = render_init(font, width, height);1239+ c.render = render_init(font, width, height, x_margin, y_margin, border_size);1240 1241 refresh(&c);1242 1243 wl_display_dispatch_pending(c.wl.display);99 unmodified linesmodified:render.c+16 added-6 removed
9 unmodified lines10 11 struct 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 };19 17-static const double x_margin = 20;18-static const double y_margin = 4;19-static const double border_size = 1;20-20 void21 render_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;27+28 cairo_set_scaled_font(buf->cairo, render->regular_font);29 30 cairo_font_extents_t fextents;31 cairo_font_extents(buf->cairo, &fextents);165 unmodified lines197 render_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;204+205 assert(match_count == 0 || selected < match_count);206 200-207 cairo_set_scaled_font(buf->cairo, render->regular_font);208 209 cairo_font_extents_t fextents;210 cairo_font_extents(buf->cairo, &fextents);66 unmodified lines277 }278 }279 280 struct render *275-render_init(cairo_scaled_font_t *font, int width, int height)281+render_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 linesmodified:render.h+2 added-1 removed
10 unmodified lines11 size_t cursor;12 };13 14 struct render;15-struct render *render_init(cairo_scaled_font_t *font, int width, int height);15+struct render *render_init(cairo_scaled_font_t *font, int width, int height,16+ int x_margin, int y_margin, int border_size);17 void render_destroy(struct render *render);18 19 void render_prompt(20 const struct render *render, struct buffer *buf,5 unmodified lines