summaryrefslogtreecommitdiff
path: root/gui/aoi.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-18 02:13:55 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-18 02:13:55 -0300
commitd4cf39e51eccf03a4deabe3a11fa4f5cbf573189 (patch)
tree0a1d7d932df060036fd9194ab228ef8524b56537 /gui/aoi.c
parent70e965bcd24eec04d798f896ae13218f2d39a38a (diff)
downloadeeshow-d4cf39e51eccf03a4deabe3a11fa4f5cbf573189.tar.gz
eeshow-d4cf39e51eccf03a4deabe3a11fa4f5cbf573189.tar.bz2
eeshow-d4cf39e51eccf03a4deabe3a11fa4f5cbf573189.zip
eeshow/aoi.c, aoi.h: remove dragging support (now in input.c)
The crazy detour through aoi.c and over.c is no longer needed.
Diffstat (limited to 'gui/aoi.c')
-rw-r--r--gui/aoi.c98
1 files changed, 5 insertions, 93 deletions
diff --git a/gui/aoi.c b/gui/aoi.c
index 5349613..3b762e3 100644
--- a/gui/aoi.c
+++ b/gui/aoi.c
@@ -25,13 +25,7 @@
#include "gui/aoi.h"
-#define DRAG_RADIUS 5
-
-
static const struct aoi *hovering = NULL;
-static const struct aoi *clicked = NULL;
-static const struct aoi *dragging = NULL;
-static int clicked_x, clicked_y;
struct aoi *aoi_add(struct aoi **aois, const struct aoi *cfg)
@@ -68,23 +62,10 @@ static const struct aoi *find_aoi(const struct aoi *aois, int x, int y)
}
-static bool aoi_on_list(const struct aoi *aois, const struct aoi *ref)
-{
- const struct aoi *aoi;
-
- for (aoi = aois; aoi; aoi = aoi->next)
- if (aoi == ref)
- return 1;
- return 0;
-}
-
-
bool aoi_hover(const struct aoi *aois, int x, int y)
{
const struct aoi *aoi;
- if (dragging)
- return 0;
if (hovering) {
if (x >= hovering->x && x < hovering->x + hovering->w &&
y >= hovering->y && y < hovering->y + hovering->h)
@@ -102,85 +83,16 @@ bool aoi_hover(const struct aoi *aois, int x, int y)
}
-bool aoi_move(const struct aoi *aois, int x, int y)
-{
- if (dragging) {
- if (aoi_on_list(aois, dragging)) {
- dragging->drag(dragging->user,
- x - clicked_x, y - clicked_y);
- clicked_x = x;
- clicked_y = y;
- }
- return 1;
- }
- if (!clicked)
- return 0;
-
- /*
- * Ensure we're on the right list and are using the same coordinate
- * system.
- */
- if (!aoi_on_list(aois, clicked))
- return 0;
-
- if (hypot(x - clicked_x, y - clicked_y) > DRAG_RADIUS) {
- if (clicked && clicked->drag) {
- dragging = clicked;
- dragging->drag(dragging->user,
- x - clicked_x, y - clicked_y);
- clicked_x = x;
- clicked_y = y;
- }
- clicked = NULL;
- }
- return 1;
-}
-
-
-bool aoi_down(const struct aoi *aois, int x, int y)
-{
- assert(!clicked);
-
- aoi_dehover();
-
- clicked = find_aoi(aois, x, y);
- if (!clicked)
- return 0;
- if (!clicked->click) {
- clicked = NULL;
- return 0;
- }
-
- clicked_x = x;
- clicked_y = y;
-
- return 1;
-}
-
-
-bool aoi_up(const struct aoi *aois, int x, int y)
+bool aoi_click(const struct aoi *aois, int x, int y)
{
const struct aoi *aoi;
- if (!aoi_move(aois, x, y))
- return 0;
+ aoi_dehover();
- /*
- * Ensure we're on the right list and are using the same coordinate
- * system.
- */
- for (aoi = aois; aoi; aoi = aoi->next)
- if (aoi == clicked || aoi == dragging)
- break;
- if (!aoi)
+ aoi = find_aoi(aois, x, y);
+ if (!aoi || !aoi->click)
return 0;
- if (dragging) {
- dragging = NULL;
- return 1;
- }
-
- clicked->click(clicked->user);
- clicked = NULL;
+ aoi->click(aoi->user);
return 1;
}