mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-17 20:04:05 +02:00
eeshow/gui/: hover callback now indicates in which direction we left
This commit is contained in:
parent
3e5c229291
commit
c6498a8cc1
@ -72,13 +72,16 @@ bool aoi_hover(struct aoi *const *aois, int x, int y)
|
|||||||
if (hovering) {
|
if (hovering) {
|
||||||
if (in_aoi(hovering, x, y))
|
if (in_aoi(hovering, x, y))
|
||||||
return 1;
|
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;
|
hovering = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (aoi = *aois; aoi; aoi = aoi->next)
|
for (aoi = *aois; aoi; aoi = aoi->next)
|
||||||
if (aoi->hover && in_aoi(aoi, x, y) &&
|
if (aoi->hover && in_aoi(aoi, x, y) &&
|
||||||
aoi->hover(aoi->user, 1)) {
|
aoi->hover(aoi->user, 1, 0, 0)) {
|
||||||
hovering = aoi;
|
hovering = aoi;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -130,7 +133,7 @@ void aoi_remove(struct aoi **aois, const struct aoi *aoi)
|
|||||||
{
|
{
|
||||||
assert(aoi);
|
assert(aoi);
|
||||||
if (hovering == aoi) {
|
if (hovering == aoi) {
|
||||||
aoi->hover(aoi->user, 0);
|
aoi->hover(aoi->user, 0, 0, 0);
|
||||||
hovering = NULL;
|
hovering = NULL;
|
||||||
}
|
}
|
||||||
while (*aois && *aois != aoi)
|
while (*aois && *aois != aoi)
|
||||||
@ -144,6 +147,6 @@ void aoi_remove(struct aoi **aois, const struct aoi *aoi)
|
|||||||
void aoi_dehover(void)
|
void aoi_dehover(void)
|
||||||
{
|
{
|
||||||
if (hovering)
|
if (hovering)
|
||||||
hovering->hover(hovering->user, 0);
|
hovering->hover(hovering->user, 0, 0, 0);
|
||||||
hovering = NULL;
|
hovering = NULL;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ struct aoi {
|
|||||||
int x, y, w, h; /* activation box, eeschema coordinates */
|
int x, y, w, h; /* activation box, eeschema coordinates */
|
||||||
/* points to hovered aoi, or NULL */
|
/* 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 (*click)(void *user);
|
||||||
void *user;
|
void *user;
|
||||||
|
|
||||||
|
@ -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;
|
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 glabel_aoi_ctx *aoi_ctx = user;
|
||||||
struct gui_ctx *ctx = aoi_ctx->sheet->ctx;
|
struct gui_ctx *ctx = aoi_ctx->sheet->ctx;
|
||||||
|
@ -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_hist *h = user;
|
||||||
struct gui_ctx *ctx = h->ctx;
|
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 = skip_history(ctx, h);
|
||||||
h->over = overlay_add(&ctx->hist_overlays, &ctx->aois,
|
h->over = overlay_add(&ctx->hist_overlays, &ctx->aois,
|
||||||
hover_history, click_history, h);
|
hover_history, click_history, h);
|
||||||
hover_history(h, 0);
|
hover_history(h, 0, 0, 0);
|
||||||
set_history_style(h, 0);
|
set_history_style(h, 0);
|
||||||
}
|
}
|
||||||
redraw(ctx);
|
redraw(ctx);
|
||||||
|
@ -45,7 +45,7 @@ struct overlay {
|
|||||||
struct overlay_style style;
|
struct overlay_style style;
|
||||||
|
|
||||||
struct aoi **aois;
|
struct aoi **aois;
|
||||||
bool (*hover)(void *user, bool on);
|
bool (*hover)(void *user, bool on, int dx, int dy);
|
||||||
void (*click)(void *user);
|
void (*click)(void *user);
|
||||||
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,
|
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 *over, *prev;
|
||||||
struct overlay **anchor;
|
struct overlay **anchor;
|
||||||
|
@ -54,7 +54,8 @@ void overlay_size_all(const struct overlay *overlays,
|
|||||||
PangoContext *pango_context, bool dx, bool dy, int *w, int *h);
|
PangoContext *pango_context, bool dx, bool dy, int *w, int *h);
|
||||||
|
|
||||||
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, int dx, int dy),
|
||||||
|
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);
|
||||||
void overlay_text(struct overlay *over, const char *fmt, ...);
|
void overlay_text(struct overlay *over, const char *fmt, ...);
|
||||||
|
@ -123,7 +123,7 @@ static void zoom_to_extents(struct gui_ctx *ctx)
|
|||||||
/* ----- Revision selection overlays --------------------------------------- */
|
/* ----- 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_hist *h = user;
|
||||||
struct gui_ctx *ctx = h->ctx;
|
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)
|
if (ctx->diff_mode == diff_new)
|
||||||
style.frame = RGBA(0, 0, 0, 1);
|
style.frame = RGBA(0, 0, 0, 1);
|
||||||
overlay_style(new->over, &style);
|
overlay_style(new->over, &style);
|
||||||
show_history_details(new, 0);
|
show_history_details(new, 0, 0, 0);
|
||||||
|
|
||||||
add_delta(ctx);
|
add_delta(ctx);
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ static void revision_overlays_diff(struct gui_ctx *ctx)
|
|||||||
if (ctx->diff_mode == diff_old)
|
if (ctx->diff_mode == diff_old)
|
||||||
style.frame = RGBA(0, 0, 0, 1);
|
style.frame = RGBA(0, 0, 0, 1);
|
||||||
overlay_style(old->over, &style);
|
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->aois, show_history_details, show_history_cb,
|
||||||
ctx->new_hist);
|
ctx->new_hist);
|
||||||
overlay_style(ctx->new_hist->over, &overlay_style_default);
|
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);
|
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_sheet *sheet = user;
|
||||||
struct gui_ctx *ctx = sheet->ctx;
|
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_selector_recurse(ctx, parent);
|
||||||
sheet->over = overlay_add(&ctx->sheet_overlays, &ctx->aois,
|
sheet->over = overlay_add(&ctx->sheet_overlays, &ctx->aois,
|
||||||
hover_sheet, close_subsheet, sheet);
|
hover_sheet, close_subsheet, sheet);
|
||||||
hover_sheet(sheet, 0);
|
hover_sheet(sheet, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user