forked from external/yambar
decoration: configurable graphical effects, added to a particle
This commit is contained in:
parent
052513c736
commit
0284f5ac85
4 changed files with 58 additions and 0 deletions
|
@ -25,6 +25,7 @@ pkg_check_modules(UDEV REQUIRED libudev) # Module/battery
|
|||
add_executable(f00bar
|
||||
bar.c bar.h
|
||||
config.c config.h
|
||||
decoration.h
|
||||
font.c font.h
|
||||
log.c log.h
|
||||
main.c
|
||||
|
@ -34,6 +35,8 @@ add_executable(f00bar
|
|||
xcb.c xcb.h
|
||||
yml.c yml.h
|
||||
|
||||
decorations/background.c decorations/background.h
|
||||
|
||||
particles/list.c particles/list.h
|
||||
particles/map.c particles/map.h
|
||||
particles/ramp.c particles/ramp.h
|
||||
|
|
10
decoration.h
Normal file
10
decoration.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
struct deco {
|
||||
void *private;
|
||||
void (*expose)(const struct deco *deco, cairo_t *cr,
|
||||
int x, int y, int width, int height);
|
||||
void (*destroy)(struct deco *deco);
|
||||
};
|
39
decorations/background.c
Normal file
39
decorations/background.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "background.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct private {
|
||||
struct rgba color;
|
||||
};
|
||||
|
||||
static void
|
||||
destroy(struct deco *deco)
|
||||
{
|
||||
struct private *d = deco->private;
|
||||
free(d);
|
||||
free(deco);
|
||||
}
|
||||
|
||||
static void
|
||||
expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height)
|
||||
{
|
||||
const struct private *d = deco->private;
|
||||
cairo_set_source_rgba(
|
||||
cr, d->color.red, d->color.green, d->color.blue, d->color.alpha);
|
||||
cairo_rectangle(cr, x, y, width, height);
|
||||
cairo_fill(cr);
|
||||
}
|
||||
|
||||
struct deco *
|
||||
deco_background(struct rgba color)
|
||||
{
|
||||
struct private *priv = malloc(sizeof(*priv));
|
||||
priv->color = color;
|
||||
|
||||
struct deco *deco = malloc(sizeof(*deco));
|
||||
deco->private = priv;
|
||||
deco->expose = &expose;
|
||||
deco->destroy = &destroy;
|
||||
|
||||
return deco;
|
||||
}
|
6
decorations/background.h
Normal file
6
decorations/background.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "../color.h"
|
||||
#include "../decoration.h"
|
||||
|
||||
struct deco *deco_background(struct rgba color);
|
Loading…
Add table
Reference in a new issue