mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 16:01:31 +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,10 +83,26 @@ 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)
|
bool aoi_click(const struct aoi *aois, int x, int y)
|
||||||
{
|
{
|
||||||
const struct aoi *aoi;
|
const struct aoi *aoi;
|
||||||
|
|
||||||
|
if (need_dehover(aois))
|
||||||
aoi_dehover();
|
aoi_dehover();
|
||||||
|
|
||||||
aoi = find_aoi(aois, x, y);
|
aoi = find_aoi(aois, x, y);
|
||||||
@ -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)
|
void aoi_remove(struct aoi **aois, const struct aoi *aoi)
|
||||||
{
|
{
|
||||||
if (hovering == aoi) {
|
if (hovering == aoi) {
|
||||||
|
@ -24,6 +24,8 @@ struct aoi {
|
|||||||
void (*click)(void *user);
|
void (*click)(void *user);
|
||||||
void *user;
|
void *user;
|
||||||
|
|
||||||
|
const struct aoi *related; /* considered equal for clicks */
|
||||||
|
|
||||||
struct aoi *next;
|
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);
|
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_remove(struct aoi **aois, const struct aoi *aoi);
|
||||||
void aoi_dehover(void);
|
void aoi_dehover(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user