mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 21:05:40 +02:00
particle: add utility function to render a particle's decoration
This commit is contained in:
parent
6f5572ff6b
commit
22507ae26c
8 changed files with 21 additions and 20 deletions
10
particle.c
10
particle.c
|
@ -40,6 +40,16 @@ exposable_default_destroy(struct exposable *exposable)
|
||||||
free(exposable);
|
free(exposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
exposable_render_deco(const struct exposable *exposable,
|
||||||
|
cairo_t *cr, int x, int y, int height)
|
||||||
|
{
|
||||||
|
const struct deco *deco = exposable->particle->deco;
|
||||||
|
if (deco != NULL)
|
||||||
|
deco->expose(deco, cr, x, y, exposable->width, height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
exposable_default_on_mouse(struct exposable *exposable, struct bar *bar,
|
exposable_default_on_mouse(struct exposable *exposable, struct bar *bar,
|
||||||
enum mouse_event event, int x, int y)
|
enum mouse_event event, int x, int y)
|
||||||
|
|
|
@ -50,6 +50,9 @@ void particle_default_destroy(struct particle *particle);
|
||||||
struct exposable *exposable_common_new(
|
struct exposable *exposable_common_new(
|
||||||
const struct particle *particle, const char *on_click);
|
const struct particle *particle, const char *on_click);
|
||||||
void exposable_default_destroy(struct exposable *exposable);
|
void exposable_default_destroy(struct exposable *exposable);
|
||||||
|
void exposable_render_deco(
|
||||||
|
const struct exposable *exposable, cairo_t *cr, int x, int y, int height);
|
||||||
|
|
||||||
void exposable_default_on_mouse(
|
void exposable_default_on_mouse(
|
||||||
struct exposable *exposable, struct bar *bar,
|
struct exposable *exposable, struct bar *bar,
|
||||||
enum mouse_event event, int x, int y);
|
enum mouse_event event, int x, int y);
|
||||||
|
|
|
@ -13,9 +13,7 @@ begin_expose(struct exposable *exposable, cairo_t *cr)
|
||||||
static void
|
static void
|
||||||
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
{
|
{
|
||||||
const struct deco *deco = exposable->particle->deco;
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
|
|
|
@ -56,9 +56,7 @@ expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
{
|
{
|
||||||
const struct eprivate *e = exposable->private;
|
const struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
const struct deco *deco = exposable->particle->deco;
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
|
|
||||||
int left_margin = exposable->particle->left_margin;
|
int left_margin = exposable->particle->left_margin;
|
||||||
int left_spacing = e->left_spacing;
|
int left_spacing = e->left_spacing;
|
||||||
|
|
|
@ -41,11 +41,9 @@ begin_expose(struct exposable *exposable, cairo_t *cr)
|
||||||
static void
|
static void
|
||||||
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
{
|
{
|
||||||
const struct deco *deco = exposable->particle->deco;
|
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
|
|
||||||
struct eprivate *e = exposable->private;
|
struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
e->exposable->expose(
|
e->exposable->expose(
|
||||||
e->exposable, cr, x + exposable->particle->left_margin, y, height);
|
e->exposable, cr, x + exposable->particle->left_margin, y, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,7 @@ expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
{
|
{
|
||||||
const struct eprivate *e = exposable->private;
|
const struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
const struct deco *deco = exposable->particle->deco;
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
|
|
||||||
x += exposable->particle->left_margin;
|
x += exposable->particle->left_margin;
|
||||||
for (size_t i = 0; i < e->count; i++) {
|
for (size_t i = 0; i < e->count; i++) {
|
||||||
|
|
|
@ -42,11 +42,9 @@ begin_expose(struct exposable *exposable, cairo_t *cr)
|
||||||
static void
|
static void
|
||||||
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
{
|
{
|
||||||
const struct deco *deco = exposable->particle->deco;
|
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
|
|
||||||
struct eprivate *e = exposable->private;
|
struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
e->exposable->expose(
|
e->exposable->expose(
|
||||||
e->exposable, cr, x + exposable->particle->left_margin, y, height);
|
e->exposable, cr, x + exposable->particle->left_margin, y, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,7 @@ expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
|
||||||
e->text, strlen(e->text), &glyphs, &num_glyphs,
|
e->text, strlen(e->text), &glyphs, &num_glyphs,
|
||||||
&clusters, &num_clusters, &cluster_flags);
|
&clusters, &num_clusters, &cluster_flags);
|
||||||
|
|
||||||
const struct deco *deco = exposable->particle->deco;
|
exposable_render_deco(exposable, cr, x, y, height);
|
||||||
if (deco != NULL)
|
|
||||||
deco->expose(deco, cr, x, y, exposable->width, height);
|
|
||||||
|
|
||||||
cairo_set_source_rgba(cr,
|
cairo_set_source_rgba(cr,
|
||||||
e->foreground.red,
|
e->foreground.red,
|
||||||
|
|
Loading…
Add table
Reference in a new issue