particle/ramp: fix on_mouse() regression

Now that we have a wrapper exposable, we need to implement
on_mouse(). In it, we need to check if we have our own on-click
handler, or else, check if mouse is inside the sub-exposable, or in
the left- or right margin.
This commit is contained in:
Daniel Eklöf 2018-12-29 21:18:07 +01:00
parent e4fab9a20b
commit 3eebdbb5b0

View file

@ -49,6 +49,30 @@ expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
e->exposable, cr, x + exposable->particle->left_margin, y, height);
}
static void
on_mouse(struct exposable *exposable, struct bar *bar, enum mouse_event event,
int x, int y)
{
const struct particle *p = exposable->particle;
const struct eprivate *e = exposable->private;
if (exposable->on_click != NULL) {
/* We have our own handler */
exposable_default_on_mouse(exposable, bar, event, x, y);
return;
}
int px = p->left_margin;
if (x >= px && x < px + e->exposable->width) {
if (e->exposable->on_mouse != NULL)
e->exposable->on_mouse(e->exposable, bar, event, x - px, y);
return;
}
/* In the left- or right margin */
exposable_default_on_mouse(exposable, bar, event, x, y);
}
static void
particle_destroy(struct particle *particle)
{
@ -102,6 +126,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
exposable->destroy = &exposable_destroy;
exposable->begin_expose = &begin_expose;
exposable->expose = &expose;
exposable->on_mouse = &on_mouse;
free(on_click);
return exposable;