]> mj.ucw.cz Git - osdd.git/blob - display.h
48ffb0be3783377ea26828d11e7d92bae0dd2d3f
[osdd.git] / display.h
1 /*
2  *      On-screen Display
3  *
4  *      (c) 2013 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <stdbool.h>
8 #include <X11/Xlib.h>
9
10 struct osd_state;
11
12 #define OSD_MAX_LINE_LEN 256
13
14 enum osd_line_type {
15   OSD_TYPE_TEXT,
16   OSD_TYPE_PERCENTAGE,
17   OSD_TYPE_SLIDER,
18 };
19
20 struct osd_line {
21   enum osd_line_type type;
22   char *fg_color;
23   char *outline_color;
24   int outline_width;
25   union {                                       // Data dependent on type
26     char text[OSD_MAX_LINE_LEN];                // in UTF-8
27   } u;
28
29   // Used internally
30   int width;
31   int height;
32   int x_pos;
33   int y_pos;
34 };
35
36 struct osd_state *osd_new(Display *dpy);
37 void osd_free(struct osd_state *osd);
38 void osd_set_font(struct osd_state *osd, char *font_name, double line_spacing);
39 struct osd_line *osd_add_line(struct osd_state *osd, enum osd_line_type type);
40 void osd_show(struct osd_state *osd);
41 void osd_hide(struct osd_state *osd);
42 void osd_clear(struct osd_state *osd);
43 bool osd_handle_event(struct osd_state *osd, XEvent *ev);