mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 05:55:20 +02:00
eeshow/gui.c: delete/backspace return to previous sheet
This commit is contained in:
parent
2135f8ffc9
commit
7630325ae6
24
eeshow/gui.c
24
eeshow/gui.c
@ -50,6 +50,8 @@ struct gui_sheet {
|
|||||||
|
|
||||||
struct aoi *aois; /* areas of interest */
|
struct aoi *aois; /* areas of interest */
|
||||||
|
|
||||||
|
struct gui_sheet *prev; /* previous in stack */
|
||||||
|
|
||||||
struct gui_sheet *next;
|
struct gui_sheet *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ struct gui_ctx {
|
|||||||
|
|
||||||
const struct aoi *aoi_hovering; /* hovering over this aoi */
|
const struct aoi *aoi_hovering; /* hovering over this aoi */
|
||||||
|
|
||||||
const struct gui_sheet *curr_sheet;
|
struct gui_sheet *curr_sheet;
|
||||||
/* current sheet */
|
/* current sheet */
|
||||||
struct gui_sheet *sheets;
|
struct gui_sheet *sheets;
|
||||||
};
|
};
|
||||||
@ -273,7 +275,7 @@ static gboolean button_press_event(GtkWidget *widget, GdkEventButton *event,
|
|||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
canvas_coord(ctx, event->x, event->y, &x, &y);
|
canvas_coord(ctx, event->x, event->y, &x, &y);
|
||||||
fprintf(stderr, "button press\n");
|
|
||||||
switch (event->button) {
|
switch (event->button) {
|
||||||
case 1:
|
case 1:
|
||||||
aoi_click(ctx, x, y);
|
aoi_click(ctx, x, y);
|
||||||
@ -295,7 +297,7 @@ static gboolean button_release_event(GtkWidget *widget, GdkEventButton *event,
|
|||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
canvas_coord(ctx, event->x, event->y, &x, &y);
|
canvas_coord(ctx, event->x, event->y, &x, &y);
|
||||||
fprintf(stderr, "button release\n");
|
|
||||||
switch (event->button) {
|
switch (event->button) {
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
@ -313,9 +315,11 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
struct gui_ctx *ctx = data;
|
struct gui_ctx *ctx = data;
|
||||||
|
struct gui_sheet *sheet = ctx->curr_sheet;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
canvas_coord(ctx, ctx->curr_x, ctx->curr_y, &x, &y);
|
canvas_coord(ctx, ctx->curr_x, ctx->curr_y, &x, &y);
|
||||||
|
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case '+':
|
case '+':
|
||||||
case '=':
|
case '=':
|
||||||
@ -324,6 +328,14 @@ static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event,
|
|||||||
case '-':
|
case '-':
|
||||||
zoom_out(ctx, x, y);
|
zoom_out(ctx, x, y);
|
||||||
break;
|
break;
|
||||||
|
case GDK_KEY_BackSpace:
|
||||||
|
case GDK_KEY_Delete:
|
||||||
|
if (sheet->prev) {
|
||||||
|
ctx->curr_sheet = sheet->prev;
|
||||||
|
sheet->prev = NULL;
|
||||||
|
gtk_widget_queue_draw(ctx->da);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GDK_KEY_q:
|
case GDK_KEY_q:
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
@ -358,11 +370,12 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
|
|||||||
static void select_subsheet(struct gui_ctx *ctx, void *user)
|
static void select_subsheet(struct gui_ctx *ctx, void *user)
|
||||||
{
|
{
|
||||||
const struct sch_obj *obj = user;
|
const struct sch_obj *obj = user;
|
||||||
const struct gui_sheet *sheet;
|
struct gui_sheet *sheet;
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", obj->u.sheet.name);
|
fprintf(stderr, "%s\n", obj->u.sheet.name);
|
||||||
for (sheet = ctx->sheets; sheet; sheet = sheet->next)
|
for (sheet = ctx->sheets; sheet; sheet = sheet->next)
|
||||||
if (sheet->sch == obj->u.sheet.sheet) {
|
if (sheet->sch == obj->u.sheet.sheet) {
|
||||||
|
sheet->prev = ctx->curr_sheet;
|
||||||
ctx->curr_sheet = sheet;
|
ctx->curr_sheet = sheet;
|
||||||
gtk_widget_queue_draw(ctx->da);
|
gtk_widget_queue_draw(ctx->da);
|
||||||
return;
|
return;
|
||||||
@ -409,8 +422,9 @@ static void get_sheets(struct gui_ctx *ctx, const struct sheet *sheets)
|
|||||||
for (sheet = sheets; sheet; sheet = sheet->next) {
|
for (sheet = sheets; sheet; sheet = sheet->next) {
|
||||||
gui_sheet = alloc_type(struct gui_sheet);
|
gui_sheet = alloc_type(struct gui_sheet);
|
||||||
gui_sheet->sch = sheet;
|
gui_sheet->sch = sheet;
|
||||||
render(ctx, gui_sheet);
|
gui_sheet->prev = NULL;
|
||||||
|
|
||||||
|
render(ctx, gui_sheet);
|
||||||
mark_aois(gui_sheet);
|
mark_aois(gui_sheet);
|
||||||
|
|
||||||
*next = gui_sheet;
|
*next = gui_sheet;
|
||||||
|
Loading…
Reference in New Issue
Block a user