mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-25 21:13:45 +02:00
eeshow/gui/aoi.c (aoi_hover): also indicate from which direction we enter
This commit is contained in:
parent
c6498a8cc1
commit
b844bbfed2
@ -57,6 +57,14 @@ static bool in_aoi(const struct aoi *aoi, int x, int y)
|
||||
}
|
||||
|
||||
|
||||
static bool hover_d(const struct aoi *aoi, bool on,int x, int y)
|
||||
{
|
||||
return aoi->hover(aoi->user, on,
|
||||
x < aoi->x ? -1 : x >= aoi->x + aoi->w ? 1 : 0,
|
||||
y < aoi->y ? -1 : y >= aoi->y + aoi->h ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We need a pointer to the anchor of the AoI list here because dehovering may
|
||||
* delete the AoI *aois points to.
|
||||
@ -67,25 +75,26 @@ static bool in_aoi(const struct aoi *aoi, int x, int y)
|
||||
|
||||
bool aoi_hover(struct aoi *const *aois, int x, int y)
|
||||
{
|
||||
static int last_x = 0;
|
||||
static int last_y = 0;
|
||||
const struct aoi *aoi;
|
||||
|
||||
if (hovering) {
|
||||
if (in_aoi(hovering, x, y))
|
||||
return 1;
|
||||
aoi = hovering;
|
||||
aoi->hover(aoi->user, 0,
|
||||
x < aoi->x ? -1 : x >= aoi->x + aoi->w ? 1 : 0,
|
||||
y < aoi->y ? -1 : y >= aoi->y + aoi->h ? 1 : 0);
|
||||
hover_d(hovering, 0, x, y);
|
||||
hovering = NULL;
|
||||
}
|
||||
|
||||
for (aoi = *aois; aoi; aoi = aoi->next)
|
||||
if (aoi->hover && in_aoi(aoi, x, y) &&
|
||||
aoi->hover(aoi->user, 1, 0, 0)) {
|
||||
hover_d(aoi, 1, last_x, last_y)) {
|
||||
hovering = aoi;
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
return aoi;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user