particle/progress-bar: allow user to configure an on-click handler

Since we're typically interrested in *where* (on the progress-bar) the
user clicked, we need a way to pass the clicked position to the
handler.

Normally, the on-click handler is expanded when a particle
instantiates its exposable. At this point, we (obviously) don't have
the click position.

This is solved by expanding the handler a second time, when the bar is
clicked.

Thus, the user can use the "{where}" tag in the click handler. "where"
will be expanded to a percentage value (0-100).
This commit is contained in:
Daniel Eklöf 2018-12-29 17:36:34 +01:00
parent bd365405d7
commit 1f182b862e
3 changed files with 60 additions and 5 deletions

View file

@ -5,4 +5,4 @@ struct particle * particle_progress_bar_new(
const char *tag, int width,
struct particle *start_marker, struct particle *end_marker,
struct particle *fill, struct particle *empty, struct particle *indicator,
int left_margin, int right_margin);
int left_margin, int right_margin, const char *on_click_template);