Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
draw.h File Reference

Layout and render notifications. More...

#include <stdbool.h>
#include <cairo.h>
#include "output.h"
+ Include dependency graph for draw.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  color
 
struct  gradient
 

Macros

#define COLOR_UNINIT   { -1, -1, -1, -1 }
 
#define COLOR_VALID(c)
 
#define COLOR_SAME(c1, c2)
 
#define GRADIENT_VALID(g)
 

Enumerations

enum  corner_pos {
  C_NONE = 0 , C_TOP_LEFT = 1 << 0 , C_TOP_RIGHT = 1 << 1 , C_BOT_LEFT = 1 << 2 ,
  C_BOT_RIGHT = 1 << 3 , C_TOP = C_TOP_LEFT | C_TOP_RIGHT , C_BOT = C_BOT_LEFT | C_BOT_RIGHT , C_LEFT = C_TOP_LEFT | C_BOT_LEFT ,
  C_RIGHT = C_TOP_RIGHT | C_BOT_RIGHT , C_ALL = C_TOP | C_BOT , _C_FIRST = 1 << 4 , _C_LAST = 1 << 5
}
 Specify which corner to draw in draw_rouned_rect. More...
 

Functions

char * color_to_string (struct color c, char buf[10])
 Stringify a color struct to a RRGGBBAA string.
 
struct gradientgradient_alloc (size_t length)
 
struct gradientgradient_acquire (struct gradient *grad)
 
void gradient_release (struct gradient *grad)
 
void gradient_pattern (struct gradient *grad)
 
char * gradient_to_string (const struct gradient *grad)
 
void draw_setup (void)
 
void draw (void)
 
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.
 
double draw_get_scale (void)
 
void draw_deinit (void)
 
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 ret_x and ret_y.
 

Variables

window win
 
const struct output * output
 

Detailed Description

Layout and render notifications.

License
BSD-3-Clause

Definition in file draw.h.

Macro Definition Documentation

◆ COLOR_SAME

#define COLOR_SAME ( c1,
c2 )
Value:
((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)

Definition at line 57 of file draw.h.

◆ COLOR_UNINIT

#define COLOR_UNINIT   { -1, -1, -1, -1 }

Definition at line 55 of file draw.h.

◆ COLOR_VALID

#define COLOR_VALID ( c)
Value:
((c).r >= 0 && (c).g >= 0 && (c).b >= 0 && (c).a >= 0 && (c).r <= 1 && (c).g <= 1 && (c).b <= 1 && (c).a <= 1)

Definition at line 56 of file draw.h.

◆ GRADIENT_VALID

#define GRADIENT_VALID ( g)
Value:
((g) != NULL && (g)->length != 0)

Definition at line 71 of file draw.h.

Enumeration Type Documentation

◆ corner_pos

enum corner_pos

Specify which corner to draw in draw_rouned_rect.

C_TOP_LEFT 0001 C_TOP_RIGHT 0010 C_BOT_LEFT 0100 C_BOT_RIGHT 1000

Definition at line 28 of file draw.h.

Function Documentation

◆ calc_window_pos()

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 ret_x and ret_y.

Definition at line 975 of file draw.c.

◆ color_to_string()

char * color_to_string ( struct color c,
char buf[10] )

Stringify a color struct to a RRGGBBAA string.

Returns the buffer on success and NULL if the struct is invalid.

Definition at line 68 of file draw.c.

◆ draw()

void draw ( void )

Definition at line 1021 of file draw.c.

◆ draw_deinit()

void draw_deinit ( void )

Definition at line 1062 of file draw.c.

◆ draw_get_scale()

double draw_get_scale ( void )

Definition at line 1071 of file draw.c.

◆ draw_rounded_rect()

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.

The top corners will get rounded by corner_radius, if first is set. Respectably the same for last with the bottom corners.

TODO: Pass additional frame width information to fix blurry lines due to fractional scaling X and Y can then be calculated as: x = round(x*scale) + half_frame_width

Definition at line 556 of file draw.c.

◆ draw_setup()

void draw_setup ( void )

Definition at line 153 of file draw.c.

◆ gradient_acquire()

struct gradient * gradient_acquire ( struct gradient * grad)

Definition at line 93 of file draw.c.

◆ gradient_alloc()

struct gradient * gradient_alloc ( size_t length)

Definition at line 80 of file draw.c.

◆ gradient_pattern()

void gradient_pattern ( struct gradient * grad)

Definition at line 110 of file draw.c.

◆ gradient_release()

void gradient_release ( struct gradient * grad)

Definition at line 104 of file draw.c.

◆ gradient_to_string()

char * gradient_to_string ( const struct gradient * grad)

Definition at line 131 of file draw.c.

Variable Documentation

◆ output

const struct output* output
extern

Definition at line 40 of file draw.c.

◆ win

window win
extern

Definition at line 41 of file draw.c.