mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 20:43:07 +02:00
eeshow/gui-over.c: more fine-grained control over stacking direction
This commit is contained in:
parent
a3301f95ae
commit
d8f3319264
@ -66,7 +66,8 @@ static void rrect(cairo_t *cr, int x, int y, int w, int h, int r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y)
|
static unsigned overlay_draw(struct overlay *over, cairo_t *cr,
|
||||||
|
unsigned x, unsigned y, int dx, int dy)
|
||||||
{
|
{
|
||||||
const struct overlay_style *style = &over->style;
|
const struct overlay_style *style = &over->style;
|
||||||
const struct color *fg = &style->fg;
|
const struct color *fg = &style->fg;
|
||||||
@ -101,18 +102,18 @@ fprintf(stderr, "%d + %d %d + %d\n",
|
|||||||
w = ink_w + 2 * style->pad;
|
w = ink_w + 2 * style->pad;
|
||||||
h = ink_h + 2 * style->pad;
|
h = ink_h + 2 * style->pad;
|
||||||
|
|
||||||
sx = *x;
|
sx = x;
|
||||||
sy = *y;
|
sy = y;
|
||||||
if (sx < 0 || sy < 0) {
|
if (dx < 0 || dy < 0) {
|
||||||
double x1, y1, x2, y2;
|
double x1, y1, x2, y2;
|
||||||
int sw, sh;
|
int sw, sh;
|
||||||
|
|
||||||
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
|
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
|
||||||
sw = x2 - x1;
|
sw = x2 - x1;
|
||||||
sh = y2 - y1;
|
sh = y2 - y1;
|
||||||
if (sx < 0)
|
if (dx < 0)
|
||||||
sx = sw + sx - w;
|
sx = sw + sx - w;
|
||||||
if (sy < 0)
|
if (dy < 0)
|
||||||
sy = sh + sy - h;
|
sy = sh + sy - h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
|
|||||||
cairo_reset_clip(cr);
|
cairo_reset_clip(cr);
|
||||||
g_object_unref(layout);
|
g_object_unref(layout);
|
||||||
|
|
||||||
if (over->hover || over->click) {
|
if (over->hover || over->click || over->drag) {
|
||||||
struct aoi aoi_cfg = {
|
struct aoi aoi_cfg = {
|
||||||
.x = sx,
|
.x = sx,
|
||||||
.y = sy,
|
.y = sy,
|
||||||
@ -174,21 +175,37 @@ fprintf(stderr, "%u(%d) %u %.60s\n", ty, ink_rect.y / PANGO_SCALE, ink_h, over->
|
|||||||
over->aoi = aoi_add(over->aois, &aoi_cfg);
|
over->aoi = aoi_add(over->aois, &aoi_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*y >= 0)
|
return h;
|
||||||
*y += h + style->skip;
|
}
|
||||||
else
|
|
||||||
*y -= h + style->skip;
|
|
||||||
|
|
||||||
return over->next;
|
|
||||||
|
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
||||||
|
unsigned x, unsigned y, int dx, int dy)
|
||||||
|
{
|
||||||
|
struct overlay *over;
|
||||||
|
unsigned h;
|
||||||
|
|
||||||
|
for (over = overlays; over; over = over->next) {
|
||||||
|
h = overlay_draw(over, cr, x, y, dx, dy);
|
||||||
|
y += dy * (h + over->style.skip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y)
|
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y)
|
||||||
{
|
{
|
||||||
struct overlay *over;
|
int dx = 1;
|
||||||
|
int dy = 1;
|
||||||
|
|
||||||
for (over = overlays; over; over = over->next)
|
if (x < 0) {
|
||||||
overlay_draw(over, cr, &x, &y);
|
x = -x;
|
||||||
|
dx = -1;
|
||||||
|
}
|
||||||
|
if (y < 0) {
|
||||||
|
y = -y;
|
||||||
|
dy = -1;
|
||||||
|
}
|
||||||
|
overlay_draw_all_d(overlays, cr, x, y, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,8 +41,10 @@ struct overlay_style {
|
|||||||
struct overlay;
|
struct overlay;
|
||||||
|
|
||||||
|
|
||||||
struct overlay *overlay_draw(struct overlay *over, cairo_t *cr, int *x, int *y);
|
void overlay_draw_all_d(struct overlay *overlays, cairo_t *cr,
|
||||||
|
unsigned x, unsigned y, int dx, int dy);
|
||||||
void overlay_draw_all(struct overlay *overlays, cairo_t *cr, int x, int y);
|
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);
|
||||||
void overlay_text_raw(struct overlay *over, const char *s);
|
void overlay_text_raw(struct overlay *over, const char *s);
|
||||||
|
Loading…
Reference in New Issue
Block a user