mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-17 21:16:15 +02:00
eeshow/gui/aoi.c (aoi_set_related): AoIs can now share clicks
If A is related to B, then A can receive clicks while B is hovering, without getting B de-hovered. Note that in aoi_set_related(A, B), more than one A can share one B, but an A can't have more than one B.
This commit is contained in:
parent
fe5bc4a55a
commit
49fe8518a5
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user