From 57510a5330b09cd701bb0bb4cbbeca1d6d096737 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 30 Mar 2018 23:57:15 +0200 Subject: Do all rendering one level higher All rendering functions now render the contents of the given block, not the block itself. This makes everything consistent again with respect to where the frame SCBlock pointers point, even for the top frame. --- src/narrative_window.c | 7 ++----- src/print.c | 7 ++++--- src/render.c | 8 ++++---- src/sc_editor.c | 4 ++-- src/slideshow.c | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/narrative_window.c b/src/narrative_window.c index 312763d..913d8da 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -159,8 +159,7 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter, sc_block_delete(&nw->dummy_top, ns); /* Full rerender */ - sc_editor_set_scblock(nw->sceditor, - sc_editor_get_scblock(nw->sceditor)); + sc_editor_set_scblock(nw->sceditor, nw->dummy_top); nw->p->saved = 0; update_titlebar(nw); } @@ -339,8 +338,7 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter, fprintf(stderr, "Failed to split paragraph\n"); } - sc_editor_set_scblock(nw->sceditor, - sc_editor_get_scblock(nw->sceditor)); + sc_editor_set_scblock(nw->sceditor, nw->dummy_top); nw->p->saved = 0; update_titlebar(nw); } @@ -681,7 +679,6 @@ static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp) struct frame *top; int sn = slide_number(p, scblocks); - scblocks = sc_block_child(scblocks); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; diff --git a/src/print.c b/src/print.c index 8275f23..b54d8e7 100644 --- a/src/print.c +++ b/src/print.c @@ -135,7 +135,7 @@ static void print_slide_only(GtkPrintOperation *op, GtkPrintContext *ctx, printf("%f x %f ---> %f x %f\n", w, h, slide_width, slide_height); - top = interp_and_shape(sc_block_child(ps->slide), stylesheets, NULL, + top = interp_and_shape(ps->slide, stylesheets, NULL, ps->p->is, page+1, pc, sw, sh, ps->p->lang); recursive_wrap(top, pc); @@ -175,7 +175,6 @@ static cairo_surface_t *print_render_thumbnail(int w, int h, void *bvp, void *vp SCBlock *stylesheets[2]; struct frame *top; - scblocks = sc_block_child(scblocks); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; surf = render_sc(scblocks, w, h, p->slide_width, p->slide_height, stylesheets, NULL, @@ -194,6 +193,7 @@ static void begin_narrative_print(GtkPrintOperation *op, GtkPrintContext *ctx, PangoContext *pc; int i, n_pages; double h, page_height; + SCBlock *dummy_top; cbl = sc_callback_list_new(); ps->slide_number = 1; @@ -211,7 +211,8 @@ static void begin_narrative_print(GtkPrintOperation *op, GtkPrintContext *ctx, pc = gtk_print_context_create_pango_context(ctx); - ps->top = interp_and_shape(ps->p->scblocks, stylesheets, cbl, + dummy_top = sc_block_new_parent(ps->p->scblocks, "presentation"); + ps->top = interp_and_shape(dummy_top, stylesheets, cbl, ps->is, 0, pc, gtk_print_context_get_width(ctx), gtk_print_context_get_height(ctx), diff --git a/src/render.c b/src/render.c index f1ff019..103194e 100644 --- a/src/render.c +++ b/src/render.c @@ -215,7 +215,7 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, top->col[2] = sc_interp_get_fgcol(scin)[2]; top->col[3] = sc_interp_get_fgcol(scin)[3]; - sc_interp_add_blocks(scin, scblocks); + sc_interp_add_blocks(scin, sc_block_child(scblocks)); sc_interp_destroy(scin); @@ -320,9 +320,9 @@ int export_pdf(struct presentation *p, const char *filename) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); - render_sc_with_context(sc_block_child(bl), cr, p->slide_width, - p->slide_height, stylesheets, NULL, - p->is, i, p->lang, pc); + render_sc_with_context(bl, cr, p->slide_width, + p->slide_height, stylesheets, NULL, + p->is, i, p->lang, pc); cairo_restore(cr); diff --git a/src/sc_editor.c b/src/sc_editor.c index 5fdcc07..e0fc64c 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -195,7 +195,7 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event, w = e->log_w; h = e->log_h; } - e->top = interp_and_shape(sc_block_child(e->scblocks), + e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl, e->is, e->slidenum, pc, w, h, e->lang); @@ -396,7 +396,7 @@ static void full_rerender(SCEditor *e) pc = gdk_pango_context_get(); - e->top = interp_and_shape(sc_block_child(e->scblocks), + e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl, e->is, e->slidenum, pc, e->log_w, 0.0, e->lang); diff --git a/src/slideshow.c b/src/slideshow.c index 3e33c3d..194befd 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -66,7 +66,7 @@ static void slideshow_rerender(SCSlideshow *ss) stylesheets[1] = NULL; n = slide_number(ss->p, ss->cur_slide); - ss->surface = render_sc(sc_block_child(ss->cur_slide), + ss->surface = render_sc(ss->cur_slide, ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, stylesheets, NULL, ss->p->is, n, -- cgit v1.2.3