summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-21 22:31:52 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-21 22:31:52 -0300
commitc5d01642fa2ffc32c26434a1847b3e58aeea18d1 (patch)
tree54e38d2101631a5e2b331fd895603d3dd8b80006 /gui
parent513813be0325b7e29231c6a1e8c74758d1287eea (diff)
downloadeeshow-c5d01642fa2ffc32c26434a1847b3e58aeea18d1.tar.gz
eeshow-c5d01642fa2ffc32c26434a1847b3e58aeea18d1.tar.bz2
eeshow-c5d01642fa2ffc32c26434a1847b3e58aeea18d1.zip
eeshow/gui/: hover callback now indicates in which direction we left
Diffstat (limited to 'gui')
-rw-r--r--gui/aoi.c11
-rw-r--r--gui/aoi.h2
-rw-r--r--gui/glabel.c4
-rw-r--r--gui/history.c4
-rw-r--r--gui/over.c5
-rw-r--r--gui/over.h3
-rw-r--r--gui/sheet.c12
7 files changed, 23 insertions, 18 deletions
diff --git a/gui/aoi.c b/gui/aoi.c
index 45e3012..1ec5818 100644
--- a/gui/aoi.c
+++ b/gui/aoi.c
@@ -72,13 +72,16 @@ bool aoi_hover(struct aoi *const *aois, int x, int y)
if (hovering) {
if (in_aoi(hovering, x, y))
return 1;
- hovering->hover(hovering->user, 0);
+ aoi = hovering;
+ aoi->hover(aoi->user, 0,
+ x < aoi->x ? -1 : x >= aoi->x + aoi->w ? 1 : 0,
+ y < aoi->y ? -1 : y >= aoi->y + aoi->h ? 1 : 0);
hovering = NULL;
}
for (aoi = *aois; aoi; aoi = aoi->next)
if (aoi->hover && in_aoi(aoi, x, y) &&
- aoi->hover(aoi->user, 1)) {
+ aoi->hover(aoi->user, 1, 0, 0)) {
hovering = aoi;
return 1;
}
@@ -130,7 +133,7 @@ void aoi_remove(struct aoi **aois, const struct aoi *aoi)
{
assert(aoi);
if (hovering == aoi) {
- aoi->hover(aoi->user, 0);
+ aoi->hover(aoi->user, 0, 0, 0);
hovering = NULL;
}
while (*aois && *aois != aoi)
@@ -144,6 +147,6 @@ void aoi_remove(struct aoi **aois, const struct aoi *aoi)
void aoi_dehover(void)
{
if (hovering)
- hovering->hover(hovering->user, 0);
+ hovering->hover(hovering->user, 0, 0, 0);
hovering = NULL;
}
diff --git a/gui/aoi.h b/gui/aoi.h
index 6ac9889..fb3a833 100644
--- a/gui/aoi.h
+++ b/gui/aoi.h
@@ -20,7 +20,7 @@ struct aoi {
int x, y, w, h; /* activation box, eeschema coordinates */
/* points to hovered aoi, or NULL */
- bool (*hover)(void *user, bool on);
+ bool (*hover)(void *user, bool on, int dx, int dy);
void (*click)(void *user);
void *user;
diff --git a/gui/glabel.c b/gui/glabel.c
index 83936da..8d7586b 100644
--- a/gui/glabel.c
+++ b/gui/glabel.c
@@ -132,7 +132,7 @@ static void add_dest_overlay(struct gui_ctx *ctx, const char *label,
}
-static bool pop_hover(void *user, bool on)
+static bool pop_hover(void *user, bool on, int dx, int dy)
{
struct gui_ctx *ctx = user;
@@ -184,7 +184,7 @@ static void add_dest_frame(struct gui_ctx *ctx)
}
-static bool hover_glabel(void *user, bool on)
+static bool hover_glabel(void *user, bool on, int dx, int dy)
{
struct glabel_aoi_ctx *aoi_ctx = user;
struct gui_ctx *ctx = aoi_ctx->sheet->ctx;
diff --git a/gui/history.c b/gui/history.c
index e17b8c3..4deef17 100644
--- a/gui/history.c
+++ b/gui/history.c
@@ -82,7 +82,7 @@ static void set_history_style(struct gui_hist *h, bool current)
}
-static bool hover_history(void *user, bool on)
+static bool hover_history(void *user, bool on, int dx, int dy)
{
struct gui_hist *h = user;
struct gui_ctx *ctx = h->ctx;
@@ -274,7 +274,7 @@ void show_history(struct gui_ctx *ctx, enum selecting sel)
h = skip_history(ctx, h);
h->over = overlay_add(&ctx->hist_overlays, &ctx->aois,
hover_history, click_history, h);
- hover_history(h, 0);
+ hover_history(h, 0, 0, 0);
set_history_style(h, 0);
}
redraw(ctx);
diff --git a/gui/over.c b/gui/over.c
index 9bdec04..aede7c5 100644
--- a/gui/over.c
+++ b/gui/over.c
@@ -45,7 +45,7 @@ struct overlay {
struct overlay_style style;
struct aoi **aois;
- bool (*hover)(void *user, bool on);
+ bool (*hover)(void *user, bool on, int dx, int dy);
void (*click)(void *user);
void *user;
@@ -420,7 +420,8 @@ void overlay_size_all(const struct overlay *overlays,
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, int dx, int dy),
+ void (*click)(void *user), void *user)
{
struct overlay *over, *prev;
struct overlay **anchor;
diff --git a/gui/over.h b/gui/over.h
index e77793c..f80e1f8 100644
--- a/gui/over.h
+++ b/gui/over.h
@@ -54,7 +54,8 @@ void overlay_size_all(const struct overlay *overlays,
PangoContext *pango_context, bool dx, bool dy, int *w, int *h);
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, int dx, int dy),
+ void (*click)(void *user), void *user);
void overlay_text_raw(struct overlay *over, const char *s);
void overlay_text(struct overlay *over, const char *fmt, ...);
diff --git a/gui/sheet.c b/gui/sheet.c
index 841363e..a3687ac 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -123,7 +123,7 @@ static void zoom_to_extents(struct gui_ctx *ctx)
/* ----- Revision selection overlays --------------------------------------- */
-static bool show_history_details(void *user, bool on)
+static bool show_history_details(void *user, bool on, int dx, int dy)
{
struct gui_hist *h = user;
struct gui_ctx *ctx = h->ctx;
@@ -219,7 +219,7 @@ static void revision_overlays_diff(struct gui_ctx *ctx)
if (ctx->diff_mode == diff_new)
style.frame = RGBA(0, 0, 0, 1);
overlay_style(new->over, &style);
- show_history_details(new, 0);
+ show_history_details(new, 0, 0, 0);
add_delta(ctx);
@@ -229,7 +229,7 @@ static void revision_overlays_diff(struct gui_ctx *ctx)
if (ctx->diff_mode == diff_old)
style.frame = RGBA(0, 0, 0, 1);
overlay_style(old->over, &style);
- show_history_details(old, 0);
+ show_history_details(old, 0, 0, 0);
}
@@ -244,7 +244,7 @@ void do_revision_overlays(struct gui_ctx *ctx)
&ctx->aois, show_history_details, show_history_cb,
ctx->new_hist);
overlay_style(ctx->new_hist->over, &overlay_style_default);
- show_history_details(ctx->new_hist, 0);
+ show_history_details(ctx->new_hist, 0, 0, 0);
add_delta(ctx);
}
@@ -263,7 +263,7 @@ static void close_subsheet(void *user)
}
-static bool hover_sheet(void *user, bool on)
+static bool hover_sheet(void *user, bool on, int dx, int dy)
{
struct gui_sheet *sheet = user;
struct gui_ctx *ctx = sheet->ctx;
@@ -314,7 +314,7 @@ static void sheet_selector_recurse(struct gui_ctx *ctx, struct gui_sheet *sheet)
sheet_selector_recurse(ctx, parent);
sheet->over = overlay_add(&ctx->sheet_overlays, &ctx->aois,
hover_sheet, close_subsheet, sheet);
- hover_sheet(sheet, 0);
+ hover_sheet(sheet, 0, 0, 0);
}