diff --git a/eeshow/gui/aoi.c b/eeshow/gui/aoi.c index 3b762e3..19eccaf 100644 --- a/eeshow/gui/aoi.c +++ b/eeshow/gui/aoi.c @@ -83,11 +83,27 @@ bool aoi_hover(const struct aoi *aois, int x, int y) } +static bool need_dehover(const struct aoi *aois) +{ + const struct aoi *aoi; + + if (!hovering) + return 0; + if (hovering->click) + return 0; + for (aoi = aois; aoi; aoi = aoi->next) + if (aoi->related == hovering && aoi->click) + return 0; + return 1; +} + + bool aoi_click(const struct aoi *aois, int x, int y) { const struct aoi *aoi; - aoi_dehover(); + if (need_dehover(aois)) + aoi_dehover(); aoi = find_aoi(aois, x, y); if (!aoi || !aoi->click) @@ -97,6 +113,12 @@ bool aoi_click(const struct aoi *aois, int x, int y) } +void aoi_set_related(struct aoi *aoi, const struct aoi *related) +{ + assert(!aoi->related); + aoi->related = related; +} + void aoi_remove(struct aoi **aois, const struct aoi *aoi) { if (hovering == aoi) { diff --git a/eeshow/gui/aoi.h b/eeshow/gui/aoi.h index 959762f..935f526 100644 --- a/eeshow/gui/aoi.h +++ b/eeshow/gui/aoi.h @@ -24,6 +24,8 @@ struct aoi { void (*click)(void *user); void *user; + const struct aoi *related; /* considered equal for clicks */ + struct aoi *next; }; @@ -34,6 +36,8 @@ bool aoi_hover(const struct aoi *aois, int x, int y); bool aoi_click(const struct aoi *aois, int x, int y); +void aoi_set_related(struct aoi *aoi, const struct aoi *related); + void aoi_remove(struct aoi **aois, const struct aoi *aoi); void aoi_dehover(void);