2023-03-29 15:33:58 +02:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
|
2023-05-21 04:16:55 +02:00
|
|
|
#include <cairo/cairo.h>
|
|
|
|
#include <cairo/cairo-ft.h>
|
|
|
|
#include <cairo/cairo-xlib.h>
|
|
|
|
#include <pango/pango.h>
|
|
|
|
#include <pango/pangocairo.h>
|
|
|
|
|
2023-03-29 15:33:58 +02:00
|
|
|
typedef struct Fnt {
|
2023-05-08 23:00:45 +02:00
|
|
|
Display *dpy;
|
|
|
|
unsigned int h;
|
|
|
|
PangoLayout *layout;
|
2023-03-29 15:33:58 +02:00
|
|
|
} Fnt;
|
|
|
|
|
|
|
|
typedef struct {
|
2023-05-08 23:00:45 +02:00
|
|
|
unsigned int w, h;
|
2023-06-02 18:37:51 +02:00
|
|
|
int protocol;
|
2023-05-08 23:00:45 +02:00
|
|
|
Display *dpy;
|
|
|
|
int screen;
|
|
|
|
Window root;
|
|
|
|
Visual *visual;
|
|
|
|
unsigned int depth;
|
2023-06-08 19:40:30 +02:00
|
|
|
void *img_data;
|
2023-06-02 18:37:51 +02:00
|
|
|
void *data;
|
2023-05-08 23:00:45 +02:00
|
|
|
Colormap cmap;
|
|
|
|
Drawable drawable;
|
|
|
|
GC gc;
|
|
|
|
Fnt *font;
|
2023-05-21 04:16:55 +02:00
|
|
|
cairo_surface_t *surface;
|
2023-06-08 19:40:30 +02:00
|
|
|
cairo_surface_t *img_surface;
|
2023-05-21 04:16:55 +02:00
|
|
|
cairo_t *d;
|
2023-06-08 19:40:30 +02:00
|
|
|
cairo_t *img_d;
|
2023-06-23 03:49:23 +02:00
|
|
|
} Draw_t;
|
2023-03-29 15:33:58 +02:00
|
|
|
|
2023-06-02 18:37:51 +02:00
|
|
|
/* Cairo color convertion */
|
|
|
|
void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha);
|
|
|
|
|
2023-06-08 19:40:30 +02:00
|
|
|
/* Cairo image drawing */
|
2023-06-23 03:49:23 +02:00
|
|
|
void draw_img(Draw_t *draw, int x, int y);
|
|
|
|
void draw_set_img(Draw_t *draw, void *data, int w, int h);
|
2023-06-08 19:40:30 +02:00
|
|
|
|
2023-03-29 15:33:58 +02:00
|
|
|
/* Drawable abstraction */
|
2023-06-23 03:49:23 +02:00
|
|
|
Draw_t *draw_create_x11(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol);
|
|
|
|
Draw_t *draw_create_wl(int protocol);
|
|
|
|
void draw_create_surface_wl(Draw_t *draw, void *data, int32_t w, int32_t h);
|
2023-06-02 18:37:51 +02:00
|
|
|
|
2023-06-23 03:49:23 +02:00
|
|
|
void draw_resize(Draw_t *draw, unsigned int w, unsigned int h);
|
|
|
|
void draw_free(Draw_t *draw);
|
2023-03-29 15:33:58 +02:00
|
|
|
|
|
|
|
/* Fnt abstraction */
|
2023-06-23 03:49:23 +02:00
|
|
|
Fnt *draw_font_create(Draw_t* draw, char *font[], size_t fontcount);
|
|
|
|
void draw_font_free(Fnt* set);
|
|
|
|
unsigned int draw_fontset_getwidth_clamp(Draw_t *draw, const char *text, unsigned int n, Bool markup);
|
|
|
|
unsigned int draw_font_getwidth(Draw_t *draw, const char *text, Bool markup);
|
|
|
|
void draw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup);
|
2023-03-29 15:33:58 +02:00
|
|
|
|
|
|
|
/* Drawing functions */
|
2023-06-23 03:49:23 +02:00
|
|
|
void draw_rect(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha);
|
|
|
|
int draw_text(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup, char *fgcol, char *bgcol, int fgalpha, int bgalpha);
|
2023-03-29 15:33:58 +02:00
|
|
|
|
|
|
|
/* Map functions */
|
2023-06-23 03:49:23 +02:00
|
|
|
void draw_map(Draw_t *draw, Window win, int x, int y, unsigned int w, unsigned int h);
|
2023-03-29 15:33:58 +02:00
|
|
|
|
|
|
|
/* Powerline functions */
|
2023-06-23 03:49:23 +02:00
|
|
|
void draw_arrow(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha);
|
|
|
|
void draw_circle(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha);
|