Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
draw.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
9
10#ifndef DUNST_DRAW_H
11#define DUNST_DRAW_H
12
13#include <stdbool.h>
14#include <cairo.h>
15#include "output.h"
16
17extern window win; // Temporary
18extern const struct output *output;
19
29 C_NONE = 0,
30 C_TOP_LEFT = 1 << 0,
31 C_TOP_RIGHT = 1 << 1,
32 C_BOT_LEFT = 1 << 2,
33 C_BOT_RIGHT = 1 << 3,
34
35 // Handy combinations of the corners
36 C_TOP = C_TOP_LEFT | C_TOP_RIGHT,
37 C_BOT = C_BOT_LEFT | C_BOT_RIGHT,
38 C_LEFT = C_TOP_LEFT | C_BOT_LEFT,
39 C_RIGHT = C_TOP_RIGHT | C_BOT_RIGHT,
40 C_ALL = C_TOP | C_BOT,
41
42 // These two values are internal only and
43 // should not be used outside of draw.c !
44 _C_FIRST = 1 << 4,
45 _C_LAST = 1 << 5,
46};
47
48struct color {
49 double r;
50 double g;
51 double b;
52 double a;
53};
54
55#define COLOR_UNINIT { -1, -1, -1, -1 }
56#define COLOR_VALID(c) ((c).r >= 0 && (c).g >= 0 && (c).b >= 0 && (c).a >= 0 && (c).r <= 1 && (c).g <= 1 && (c).b <= 1 && (c).a <= 1)
57#define COLOR_SAME(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
58
63char *color_to_string(struct color c, char buf[10]);
64
65struct gradient {
66 cairo_pattern_t *pattern;
67 size_t length;
68 struct color colors[];
69};
70
71#define GRADIENT_VALID(g) ((g) != NULL && (g)->length != 0)
72
73struct gradient *gradient_alloc(size_t length);
74
75struct gradient *gradient_acquire(struct gradient *grad);
76
77void gradient_release(struct gradient *grad);
78
79void gradient_pattern(struct gradient *grad);
80
81char *gradient_to_string(const struct gradient *grad);
82
83
84void draw_setup(void);
85
86void draw(void);
87
88void draw_rounded_rect(cairo_t *c, float x, float y, int width, int height, int corner_radius, double scale, enum corner_pos corners);
89
90// TODO get rid of this function by passing scale to everything that needs it.
91double draw_get_scale(void);
92
93void draw_deinit(void);
94
95void calc_window_pos(const struct screen_info *scr, int width, int height, int *ret_x, int *ret_y);
96
97#endif
char * color_to_string(struct color c, char buf[10])
Stringify a color struct to a RRGGBBAA string.
Definition draw.c:68
corner_pos
Specify which corner to draw in draw_rouned_rect.
Definition draw.h:28
void calc_window_pos(const struct screen_info *scr, int width, int height, int *ret_x, int *ret_y)
Calculates the position the window should be placed at given its width and height and stores them in ...
Definition draw.c:975
void draw_rounded_rect(cairo_t *c, float x, float y, int width, int height, int corner_radius, double scale, enum corner_pos corners)
Create a path on the given cairo context to draw the background of a notification.
Definition draw.c:556
Generic graphics backend wrapper.
Definition draw.h:48