spmenu/libs/draw/draw.h

70 lines
2.5 KiB
C
Raw Normal View History

2023-03-29 15:33:58 +02:00
/* See LICENSE file for copyright and license details. */
#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;
int protocol;
2023-05-08 23:00:45 +02:00
Display *dpy;
int screen;
Window root;
Visual *visual;
unsigned int depth;
void *img_data;
void *data;
2023-05-08 23:00:45 +02:00
Colormap cmap;
Drawable drawable;
GC gc;
Fnt *font;
cairo_surface_t *surface;
cairo_surface_t *img_surface;
cairo_t *d;
cairo_t *img_d;
} Draw_t;
2023-03-29 15:33:58 +02:00
/* Cairo color convertion */
void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha);
/* Cairo image drawing */
void draw_img(Draw_t *draw, int x, int y);
void draw_set_img(Draw_t *draw, void *data, int w, int h);
2023-03-29 15:33:58 +02:00
/* Drawable abstraction */
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);
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 */
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 */
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 */
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 */
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);
/* Screenshot functions */
void draw_save_screen(Draw_t *draw, const char *file);