mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 20:45:55 +02:00
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.
This commit is contained in:
parent
d78caddaf9
commit
6847165604
@ -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;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ struct aoi {
|
||||
|
||||
bool (*hover)(void *user, bool on);
|
||||
void (*click)(void *user);
|
||||
void (*drag)(void *user, int dx, int dy);
|
||||
void *user;
|
||||
|
||||
struct aoi *next;
|
||||
@ -33,9 +32,7 @@ struct aoi *aoi_add(struct aoi **aois, const struct aoi *cfg);
|
||||
void aoi_update(struct aoi *aoi, const struct aoi *cfg);
|
||||
bool aoi_hover(const struct aoi *aois, int x, int y);
|
||||
|
||||
bool aoi_move(const struct aoi *aois, int x, int y);
|
||||
bool aoi_down(const struct aoi *aois, int x, int y);
|
||||
bool aoi_up(const struct aoi *aois, int x, int y);
|
||||
bool aoi_click(const struct aoi *aois, int x, int y);
|
||||
|
||||
void aoi_remove(struct aoi **aois, const struct aoi *aoi);
|
||||
void aoi_dehover(void);
|
||||
|
@ -780,12 +780,11 @@ static bool sheet_click(void *user, int x, int y)
|
||||
|
||||
canvas_coord(ctx, x, y, &ex, &ey);
|
||||
|
||||
if (aoi_down(ctx->aois, x, y))
|
||||
return aoi_up(ctx->aois, x, y);
|
||||
if (aoi_down(curr_sheet->aois,
|
||||
if (aoi_click(ctx->aois, x, y))
|
||||
return 1;
|
||||
if (aoi_click(curr_sheet->aois,
|
||||
ex + curr_sheet->xmin, ey + curr_sheet->ymin))
|
||||
return aoi_up(curr_sheet->aois,
|
||||
ex + curr_sheet->xmin, ey + curr_sheet->ymin);
|
||||
return 1;
|
||||
|
||||
if (ctx->showing_history)
|
||||
hide_history(ctx);
|
||||
@ -803,11 +802,6 @@ static bool sheet_hover_update(void *user, int x, int y)
|
||||
|
||||
canvas_coord(ctx, x, y, &ex, &ey);
|
||||
|
||||
if (aoi_move(ctx->aois, x, y))
|
||||
return 1;
|
||||
if (aoi_move(curr_sheet->aois,
|
||||
ex + curr_sheet->xmin, ey + curr_sheet->ymin))
|
||||
return 1;
|
||||
if (aoi_hover(ctx->aois, x, y))
|
||||
return 1;
|
||||
return aoi_hover(curr_sheet->aois,
|
||||
|
Loading…
Reference in New Issue
Block a user