1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-17 20:04:05 +02:00

eeshow/gui/history.c: provide complete set of input functions

This commit is contained in:
Werner Almesberger 2016-08-18 04:10:35 -03:00
parent 9792a22799
commit 8d3b642fb2
3 changed files with 35 additions and 17 deletions

View File

@ -113,17 +113,12 @@ void add_glabel_aoi(struct gui_sheet *sheet, const struct sch_obj *obj);
/* sheet.c */ /* sheet.c */
bool sheet_click(void *user, int x, int y);
bool sheet_hover_update(void *user, int x, int y);
void sheet_key(void *user, int x, int y, int keyval);
void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet); void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet);
void do_revision_overlays(struct gui_ctx *ctx); void do_revision_overlays(struct gui_ctx *ctx);
void sheet_setup(struct gui_ctx *ctx); void sheet_setup(struct gui_ctx *ctx);
/* history */ /* history */
void hide_history(struct gui_ctx *ctx);
void show_history(struct gui_ctx *ctx, enum selecting sel); void show_history(struct gui_ctx *ctx, enum selecting sel);
/* gui.c */ /* gui.c */

View File

@ -26,7 +26,7 @@
#include "gui/common.h" #include "gui/common.h"
void hide_history(struct gui_ctx *ctx) static void hide_history(struct gui_ctx *ctx)
{ {
input_pop(); input_pop();
@ -217,6 +217,25 @@ void show_history(struct gui_ctx *ctx, enum selecting sel)
/* ----- Input ------------------------------------------------------------- */ /* ----- Input ------------------------------------------------------------- */
static bool history_click(void *user, int x, int y)
{
struct gui_ctx *ctx = user;
if (aoi_click(ctx->aois, x, y))
return 1;
hide_history(ctx);
return 1;
}
static bool history_hover_update(void *user, int x, int y)
{
struct gui_ctx *ctx = user;
return aoi_hover(ctx->aois, x, y);
}
static void history_drag_move(void *user, int dx, int dy) static void history_drag_move(void *user, int dx, int dy)
{ {
struct gui_ctx *ctx = user; struct gui_ctx *ctx = user;
@ -226,15 +245,21 @@ static void history_drag_move(void *user, int dx, int dy)
} }
/* @@@ under construction */ static void history_key(void *user, int x, int y, int keyval)
{
switch (keyval) {
case GDK_KEY_q:
gtk_main_quit();
}
}
static const struct input_ops history_input_ops = { static const struct input_ops history_input_ops = {
.click = sheet_click, .click = history_click,
.hover_begin = sheet_hover_update, .hover_begin = history_hover_update,
.hover_update = sheet_hover_update, .hover_update = history_hover_update,
.hover_click = sheet_click, .hover_click = history_click,
.drag_begin = input_accept, .drag_begin = input_accept,
.drag_move = history_drag_move, .drag_move = history_drag_move,
.key = sheet_key, .key = history_key,
}; };

View File

@ -308,7 +308,7 @@ static bool go_next_sheet(struct gui_ctx *ctx)
/* ----- Input ------------------------------------------------------------- */ /* ----- Input ------------------------------------------------------------- */
bool sheet_click(void *user, int x, int y) static bool sheet_click(void *user, int x, int y)
{ {
struct gui_ctx *ctx = user; struct gui_ctx *ctx = user;
const struct gui_sheet *curr_sheet = ctx->curr_sheet; const struct gui_sheet *curr_sheet = ctx->curr_sheet;
@ -322,15 +322,13 @@ bool sheet_click(void *user, int x, int y)
ex + curr_sheet->xmin, ey + curr_sheet->ymin)) ex + curr_sheet->xmin, ey + curr_sheet->ymin))
return 1; return 1;
if (ctx->showing_history)
hide_history(ctx);
overlay_remove_all(&ctx->pop_overlays); overlay_remove_all(&ctx->pop_overlays);
redraw(ctx); redraw(ctx);
return 1; return 1;
} }
bool sheet_hover_update(void *user, int x, int y) static bool sheet_hover_update(void *user, int x, int y)
{ {
struct gui_ctx *ctx = user; struct gui_ctx *ctx = user;
const struct gui_sheet *curr_sheet = ctx->curr_sheet; const struct gui_sheet *curr_sheet = ctx->curr_sheet;
@ -375,7 +373,7 @@ static void sheet_scroll(void *user, int x, int y, int dy)
} }
void sheet_key(void *user, int x, int y, int keyval) static void sheet_key(void *user, int x, int y, int keyval)
{ {
struct gui_ctx *ctx = user; struct gui_ctx *ctx = user;
struct gui_sheet *sheet = ctx->curr_sheet; struct gui_sheet *sheet = ctx->curr_sheet;