summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-21 23:02:28 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-21 23:02:28 -0300
commit82736b6fe91d8f721be7fed30ad2a17cacefc364 (patch)
treee4d2fa563d9c557a999d978ef68fe1a553b804bf /gui
parentc5d01642fa2ffc32c26434a1847b3e58aeea18d1 (diff)
downloadeeshow-82736b6fe91d8f721be7fed30ad2a17cacefc364.tar.gz
eeshow-82736b6fe91d8f721be7fed30ad2a17cacefc364.tar.bz2
eeshow-82736b6fe91d8f721be7fed30ad2a17cacefc364.zip
eeshow/gui/aoi.c (aoi_hover): also indicate from which direction we enter
Diffstat (limited to 'gui')
-rw-r--r--gui/aoi.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gui/aoi.c b/gui/aoi.c
index 1ec5818..daa65ee 100644
--- a/gui/aoi.c
+++ b/gui/aoi.c
@@ -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;
}