From 3b5daecbd6b2d64d603a0173e7e2f490d6707bb9 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 6 Aug 2016 10:19:16 -0300 Subject: [PATCH] eeshow/gui.c (go_to_sheet): don't "render" (record) sheets before shown --- eeshow/gui.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/eeshow/gui.c b/eeshow/gui.c index c6dfde7..5fc51a2 100644 --- a/eeshow/gui.c +++ b/eeshow/gui.c @@ -46,6 +46,8 @@ struct gui_sheet { int w, h; int xmin, ymin; + bool rendered; /* 0 if still have to render it */ + struct aoi *aois; /* areas of interest; in schematics coord */ struct gui_sheet *next; @@ -128,7 +130,7 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, } -static void render(struct gui_ctx *ctx, struct gui_sheet *sheet) +static void render_sheet(struct gui_sheet *sheet) { char *argv[] = { "gui", NULL }; @@ -137,9 +139,7 @@ static void render(struct gui_ctx *ctx, struct gui_sheet *sheet) cro_canvas_end(gfx_ctx, &sheet->w, &sheet->h, &sheet->xmin, &sheet->ymin); sheet->gfx_ctx = gfx_ctx; - - ctx->x = sheet->w >> 1; - ctx->y = sheet->h >> 1; + sheet->rendered = 1; // gfx_end(); } @@ -327,6 +327,10 @@ static void show_history_cb(void *user) /* ----- Navigate sheets --------------------------------------------------- */ +/* @@@ find a better place for this forward declaration */ +static void mark_aois(struct gui_ctx *ctx, struct gui_sheet *sheet); + + static void close_subsheet(void *user) { struct gui_ctx *ctx = user; @@ -337,6 +341,10 @@ static void close_subsheet(void *user) static void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet) { + if (!sheet->rendered) { + render_sheet(sheet); + mark_aois(ctx, sheet); + } ctx->curr_sheet = sheet; overlay_remove_all(&ctx->sheet_overlays); if (ctx->hist) { @@ -616,9 +624,7 @@ static struct gui_sheet *get_sheets(struct gui_ctx *ctx, for (sheet = sheets; sheet; sheet = sheet->next) { new = alloc_type(struct gui_sheet); new->sch = sheet; - - render(ctx, new); - mark_aois(ctx, new); + new->rendered = 0; *next = new; next = &new->next;