1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#ifndef COMET_DRAW_H
#define COMET_DRAW_H
#include <glib.h>
#include <pango/pango-font.h>
#include <pango/pangocairo.h>
#include "window.h"
typedef struct {
double r, g, b, a;
} Color;
// The one who draws ('o')7
typedef struct {
PangoFontDescription *desc;
PangoContext *context;
int height;
int width;
int left_pad;
int right_pad;
int top_pad;
int sep;
Color background;
GList *layouts;
// Calculated by draw_compute_layout
GList *layout_end[3];
int layout_bx[3];
int layout_width[3];
} Drawer;
typedef struct {
struct Button *btn;
int x, y;
int width, height;
int text_w, text_h;
int x_pad, y_pad;
int line_w;
PangoLayout *pl;
GList *children;
} Layout;
Drawer *draw_create();
void draw_paint(Drawer *draw, Window *win);
// TODO: Rework the api so that we don't need to pass the window
void draw_compute_layout(Drawer *draw, Window *win, GList *btns);
void draw_compute_text_size(Drawer *draw, const char *text, int *text_w, int *text_h);
void draw_set_background(Drawer *draw, Color background);
void draw_set_separator(Drawer *draw, int sep);
void draw_set_font(Drawer *draw, const char *font);
void draw_set_context(Drawer *draw, PangoContext *context);
void draw_set_size(Drawer *draw, int height, int left_pad, int right_pad, int top_pad);
void draw_destroy(Drawer *draw);
#endif
// vim: ts=4 sw=4 et
|