1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 13:48:08 +02:00

eeshow/gui.c: add zoom in/out with + (or =) and -

This commit is contained in:
Werner Almesberger 2016-08-03 10:05:01 -03:00
parent c8b8dbd174
commit 2775b5cb8d

View File

@ -35,6 +35,9 @@ struct gui_ctx {
int w, h; int w, h;
int xmin, ymin; int xmin, ymin;
int curr_x; /* last on-screen mouse position */
int curr_y;
unsigned zoom; /* scale by 1.0 / (1 << zoom) */ unsigned zoom; /* scale by 1.0 / (1 << zoom) */
int x, y; /* center, in eeschema coordinates */ int x, y; /* center, in eeschema coordinates */
@ -167,6 +170,9 @@ static gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event,
struct gui_ctx *ctx = data; struct gui_ctx *ctx = data;
int x, y; int x, y;
ctx->curr_x = event->x;
ctx->curr_y = event->y;
canvas_coord(ctx, event->x, event->y, &x, &y); canvas_coord(ctx, event->x, event->y, &x, &y);
// fprintf(stderr, "motion\n"); // fprintf(stderr, "motion\n");
pan_update(ctx, event->x, event->y); pan_update(ctx, event->x, event->y);
@ -219,8 +225,18 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event, static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
gpointer data) gpointer data)
{ {
fprintf(stderr, "key %d\n", event->keyval); struct gui_ctx *ctx = data;
int x, y;
canvas_coord(ctx, ctx->curr_x, ctx->curr_y, &x, &y);
switch (event->keyval) { switch (event->keyval) {
case '+':
case '=':
zoom_in(ctx, x, y);
break;
case '-':
zoom_out(ctx, x, y);
break;
case GDK_KEY_q: case GDK_KEY_q:
gtk_main_quit(); gtk_main_quit();
} }