mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-29 14:17:30 +02:00
eeshow/gui-over.c: make list doubly-linked; reverse when dy < 0
This commit is contained in:
parent
375efa6476
commit
b67f6b9a96
@ -49,7 +49,7 @@ struct overlay {
|
|||||||
|
|
||||||
struct aoi *aoi;
|
struct aoi *aoi;
|
||||||
|
|
||||||
struct overlay *next;
|
struct overlay *next, *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -171,12 +171,20 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
|
|||||||
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
||||||
unsigned x, unsigned y, int dx, int dy)
|
unsigned x, unsigned y, int dx, int dy)
|
||||||
{
|
{
|
||||||
struct overlay *over;
|
struct overlay *over = overlays;
|
||||||
unsigned h;
|
unsigned h;
|
||||||
|
|
||||||
for (over = overlays; over; over = over->next) {
|
if (dy < 0)
|
||||||
|
while (over && over->next)
|
||||||
|
over = over->next;
|
||||||
|
while (over) {
|
||||||
h = overlay_draw(over, cr, x, y, dx, dy);
|
h = overlay_draw(over, cr, x, y, dx, dy);
|
||||||
y += dy * (h + over->style.skip);
|
y += dy * (h + over->style.skip);
|
||||||
|
if (dy >= 0)
|
||||||
|
over = over->next;
|
||||||
|
else
|
||||||
|
over = over->prev;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +218,7 @@ void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y)
|
|||||||
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
||||||
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user)
|
bool (*hover)(void *user, bool on), void (*click)(void *user), void *user)
|
||||||
{
|
{
|
||||||
struct overlay *over;
|
struct overlay *over, *prev;
|
||||||
struct overlay **anchor;
|
struct overlay **anchor;
|
||||||
|
|
||||||
over = alloc_type(struct overlay);
|
over = alloc_type(struct overlay);
|
||||||
@ -223,8 +231,11 @@ struct overlay *overlay_add(struct overlay **overlays, struct aoi **aois,
|
|||||||
over->user = user;
|
over->user = user;
|
||||||
over->aoi = NULL;
|
over->aoi = NULL;
|
||||||
|
|
||||||
for (anchor = overlays; *anchor; anchor = &(*anchor)->next);
|
prev = NULL;
|
||||||
|
for (anchor = overlays; *anchor; anchor = &(*anchor)->next)
|
||||||
|
prev = *anchor;
|
||||||
over->next = NULL;
|
over->next = NULL;
|
||||||
|
over->prev = prev;
|
||||||
*anchor = over;
|
*anchor = over;
|
||||||
|
|
||||||
return over;
|
return over;
|
||||||
@ -272,15 +283,13 @@ static void overlay_free(struct overlay *over)
|
|||||||
|
|
||||||
void overlay_remove(struct overlay **overlays, struct overlay *over)
|
void overlay_remove(struct overlay **overlays, struct overlay *over)
|
||||||
{
|
{
|
||||||
struct overlay **anchor;
|
if (over->next)
|
||||||
|
over->next->prev = over->prev;
|
||||||
for (anchor = overlays; *anchor; anchor = &(*anchor)->next)
|
if (over->prev)
|
||||||
if (*anchor == over) {
|
over->prev->next = over->next;
|
||||||
*anchor = over->next;
|
else
|
||||||
overlay_free(over);
|
*overlays = over->next;
|
||||||
return;
|
overlay_free(over);
|
||||||
}
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user