1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-18 00:00:38 +02:00

eeshow/gui/aoi.c (need_devover): also check the loction of the related AoI

This commit is contained in:
Werner Almesberger 2016-08-19 03:42:01 -03:00
parent bc0ae8ed67
commit bd8f6ab353

View File

@ -50,13 +50,19 @@ void aoi_update(struct aoi *aoi, const struct aoi *cfg)
} }
static bool in_aoi(const struct aoi *aoi, int x, int y)
{
return x >= aoi->x && x < aoi->x + aoi->w &&
y >= aoi->y && y < aoi->y + aoi->h;
}
static const struct aoi *find_aoi(const struct aoi *aois, int x, int y) static const struct aoi *find_aoi(const struct aoi *aois, int x, int y)
{ {
const struct aoi *aoi; const struct aoi *aoi;
for (aoi = aois; aoi; aoi = aoi->next) for (aoi = aois; aoi; aoi = aoi->next)
if (x >= aoi->x && x < aoi->x + aoi->w && if (in_aoi(aoi, x, y))
y >= aoi->y && y < aoi->y + aoi->h)
break; break;
return aoi; return aoi;
} }
@ -83,7 +89,7 @@ bool aoi_hover(const struct aoi *aois, int x, int y)
} }
static bool need_dehover(const struct aoi *aois) static bool need_dehover(const struct aoi *aois, int x, int y)
{ {
const struct aoi *aoi; const struct aoi *aoi;
@ -92,7 +98,7 @@ static bool need_dehover(const struct aoi *aois)
if (hovering->click) if (hovering->click)
return 0; return 0;
for (aoi = aois; aoi; aoi = aoi->next) for (aoi = aois; aoi; aoi = aoi->next)
if (aoi->related == hovering && aoi->click) if (aoi->related == hovering && aoi->click && in_aoi(aoi, x, y))
return 0; return 0;
return 1; return 1;
} }
@ -102,7 +108,7 @@ bool aoi_click(const struct aoi *aois, int x, int y)
{ {
const struct aoi *aoi; const struct aoi *aoi;
if (need_dehover(aois)) if (need_dehover(aois, x, y))
aoi_dehover(); aoi_dehover();
aoi = find_aoi(aois, x, y); aoi = find_aoi(aois, x, y);