diff options
-rw-r--r-- | src/render.c | 42 | ||||
-rw-r--r-- | src/render.h | 2 | ||||
-rw-r--r-- | src/sc_editor.c | 38 | ||||
-rw-r--r-- | src/sc_editor.h | 1 | ||||
-rw-r--r-- | src/slideshow.c | 1 | ||||
-rw-r--r-- | tests/render_test.c | 22 | ||||
-rw-r--r-- | tests/render_test_sc1.c | 38 |
7 files changed, 29 insertions, 115 deletions
diff --git a/src/render.c b/src/render.c index 21a6973..719677a 100644 --- a/src/render.c +++ b/src/render.c @@ -345,7 +345,7 @@ static int recursive_wrap_and_draw(struct frame *fr, cairo_t *cr, static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, cairo_t *cr, double log_w, double log_h, - struct frame *top, SCBlock *stylesheet, + SCBlock *stylesheet, ImageStore *is, enum is_size isz, int slide_number) { @@ -353,6 +353,7 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, PangoContext *pc; SCInterpreter *scin; char snum[64]; + struct frame *top; cairo_rectangle(cr, 0.0, 0.0, log_w, log_h); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); @@ -370,6 +371,16 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, pc = pango_font_map_create_context(fontmap); pango_cairo_update_context(cr, pc); + top = sc_block_frame(scblocks); + if ( top == NULL ) { + top = frame_new(); + sc_block_set_frame(scblocks, top); + } + top->x = 0.0; + top->y = 0.0; + top->w = log_w; + top->h = log_h; + scin = sc_interp_new(pc, top); if ( scin == NULL ) { fprintf(stderr, "Failed to set up interpreter.\n"); @@ -402,7 +413,7 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, * Render the entire slide. */ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, - double log_w, double log_h, struct frame *top, + double log_w, double log_h, SCBlock *stylesheet, ImageStore *is, enum is_size isz, int slide_number) @@ -413,8 +424,8 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cr = cairo_create(surf); cairo_scale(cr, w/log_w, h/log_h); - render_sc_to_surface(scblocks, surf, cr, log_w, log_h, top, stylesheet, - is, isz,slide_number); + render_sc_to_surface(scblocks, surf, cr, log_w, log_h, + stylesheet, is, isz,slide_number); cairo_destroy(cr); return surf; } @@ -443,7 +454,6 @@ int export_pdf(struct presentation *p, const char *filename) for ( i=0; i<p->num_slides; i++ ) { struct slide *s; - struct frame top; s = p->slides[i]; @@ -455,28 +465,8 @@ int export_pdf(struct presentation *p, const char *filename) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); - top.x = 0.0; - top.y = 0.0; - top.children = NULL; - top.num_children = 0; - top.max_children = 0; - top.lines = NULL; - top.n_lines = 0; - top.max_lines = 0; - top.pad_l = 0; - top.pad_r = 0; - top.pad_t = 0; - top.pad_b = 0; - top.w = w; - top.h = w*r; - top.grad = GRAD_NONE; - top.bgcol[0] = 1.0; - top.bgcol[1] = 1.0; - top.bgcol[2] = 1.0; - top.bgcol[3] = 1.0; - render_sc_to_surface(s->scblocks, surf, cr, p->slide_width, - p->slide_height, &top, p->stylesheet, + p->slide_height, p->stylesheet, p->is, ISZ_SLIDESHOW, i); cairo_restore(cr); diff --git a/src/render.h b/src/render.h index 5354deb..37e66b2 100644 --- a/src/render.h +++ b/src/render.h @@ -31,7 +31,7 @@ #include "imagestore.h" extern cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, - double log_w, double log_h, struct frame *top, + double log_w, double log_h, SCBlock *stylesheet, ImageStore *is, enum is_size isz, int slide_number); diff --git a/src/sc_editor.c b/src/sc_editor.c index 91db62d..b1a01f2 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -67,8 +67,7 @@ static void rerender(SCEditor *e) /* FIXME: Slide number, if appropriate */ e->surface = render_sc(e->scblocks, e->w, e->h, e->log_w, e->log_h, - &e->top, e->stylesheet, e->is, ISZ_EDITOR, - 0); + e->stylesheet, e->is, ISZ_EDITOR, 0); } @@ -752,7 +751,8 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, if ( within_frame(e->selection, x, y) ) { clicked = e->selection; } else { - clicked = find_frame_at_position(&e->top, x, y); + clicked = find_frame_at_position(sc_block_frame(e->scblocks), + x, y); } /* If the user clicked the currently selected frame, position cursor @@ -795,8 +795,9 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, } - } else if ( (clicked == NULL) || (clicked == &e->top) ) { - + } else if ( (clicked == NULL) + || (clicked == sc_block_frame(e->scblocks)) ) + { /* Clicked no object. Deselect old object and set up for * (maybe) creating a new one. */ e->selection = NULL; @@ -878,7 +879,7 @@ static struct frame *create_frame(SCEditor *e, double x, double y, struct frame *parent; struct frame *fr; - parent = &e->top; + parent = sc_block_frame(e->scblocks); if ( w < 0.0 ) { x += w; @@ -1273,7 +1274,6 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, fr->is_image = 1; fr->empty = 0; sc_block_append_inside(fr->scblocks, "image", opts, ""); - show_hierarchy(&e->top, ""); rerender(e); e->selection = fr; redraw_editor(e); @@ -1344,6 +1344,8 @@ static void free_frame_contents(struct frame *fr) { int i; + if ( fr == NULL ) return; + for ( i=0; i<fr->n_lines; i++ ) { wrap_line_free(&fr->lines[i]); } @@ -1373,7 +1375,7 @@ void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks) e->scblocks = scblocks; /* Free all subframes */ - free_frame_contents(&e->top); + free_frame_contents(sc_block_frame(e->scblocks)); rerender(e); redraw_editor(e); @@ -1391,8 +1393,6 @@ void sc_editor_set_logical_size(SCEditor *e, double w, double h) { e->log_w = w; e->log_h = h; - e->top.w = w; - e->top.h = h; } @@ -1412,24 +1412,6 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock *stylesheet) sceditor->is = imagestore_new(); sceditor->stylesheet = stylesheet; - sceditor->top.children = NULL; - sceditor->top.num_children = 0; - sceditor->top.max_children = 0; - sceditor->top.lines = NULL; - sceditor->top.n_lines = 0; - sceditor->top.max_lines = 0; - sceditor->top.pad_l = 0; - sceditor->top.pad_r = 0; - sceditor->top.pad_t = 0; - sceditor->top.pad_b = 0; - sceditor->top.w = sceditor->log_w; - sceditor->top.h = sceditor->log_h; - sceditor->top.grad = GRAD_NONE; - sceditor->top.bgcol[0] = 1.0; - sceditor->top.bgcol[1] = 1.0; - sceditor->top.bgcol[2] = 1.0; - sceditor->top.bgcol[3] = 1.0; - rerender(sceditor); gtk_widget_set_size_request(GTK_WIDGET(sceditor), diff --git a/src/sc_editor.h b/src/sc_editor.h index 2617b1f..d10cbbd 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -92,7 +92,6 @@ struct _sceditor double log_h; SCBlock *scblocks; cairo_surface_t *surface; - struct frame top; SCBlock *stylesheet; ImageStore *is; diff --git a/src/slideshow.c b/src/slideshow.c index a2d1080..77f23cd 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -77,7 +77,6 @@ void slideshow_rerender(SlideShow *ss) ss->surface = render_sc(ss->cur_slide->scblocks, ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, - &ss->top, ss->p->stylesheet, ss->p->is, ISZ_SLIDESHOW, n); } diff --git a/tests/render_test.c b/tests/render_test.c index 456a6e1..62bab25 100644 --- a/tests/render_test.c +++ b/tests/render_test.c @@ -51,31 +51,11 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data) gint w, h; cairo_surface_t *surface; SCBlock *scblocks = data; - struct frame top; w = gtk_widget_get_allocated_width(da); h = gtk_widget_get_allocated_height(da); - top.pad_l = 20.0; - top.pad_r = 20.0; - top.pad_t = 20.0; - top.pad_b = 20.0; - top.w = w; - top.h = h; - top.grad = GRAD_NONE; - top.bgcol[0] = 1.0; - top.bgcol[1] = 1.0; - top.bgcol[2] = 0.6; - top.bgcol[3] = 1.0; - - top.lines = NULL; - top.n_lines = 0; - top.children = NULL; - top.num_children = 0; - top.max_children = 0; - top.boxes = NULL; - - surface = render_sc(scblocks, w, h, w, h, &top, NULL, NULL, + surface = render_sc(scblocks, w, h, w, h, NULL, NULL, ISZ_EDITOR, 1); cairo_rectangle(cr, 0.0, 0.0, w, h); cairo_set_source_surface(cr, surface, 0.0, 0.0); diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c index b1acbad..cf297e9 100644 --- a/tests/render_test_sc1.c +++ b/tests/render_test_sc1.c @@ -45,52 +45,16 @@ static gint mw_destroy(GtkWidget *w, void *p) } -static void unset_all_frames(SCBlock *bl) -{ - while ( bl != NULL ) { - sc_block_set_frame(bl, NULL); - if ( sc_block_child(bl) != NULL ) { - unset_all_frames(sc_block_child(bl)); - } - if ( sc_block_macro_child(bl) != NULL ) { - unset_all_frames(sc_block_macro_child(bl)); - } - bl = sc_block_next(bl); - } -} - - static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data) { gint w, h; cairo_surface_t *surface; SCBlock *scblocks = data; - struct frame top; w = gtk_widget_get_allocated_width(da); h = gtk_widget_get_allocated_height(da); - top.pad_l = 20.0; - top.pad_r = 20.0; - top.pad_t = 20.0; - top.pad_b = 20.0; - top.w = w; - top.h = h; - top.grad = GRAD_NONE; - top.bgcol[0] = 1.0; - top.bgcol[1] = 1.0; - top.bgcol[2] = 0.6; - top.bgcol[3] = 1.0; - - top.lines = NULL; - top.n_lines = 0; - top.children = NULL; - top.num_children = 0; - top.max_children = 0; - top.boxes = NULL; - unset_all_frames(scblocks); - - surface = render_sc(scblocks, w, h, w, h, &top, NULL, NULL, + surface = render_sc(scblocks, w, h, w, h, NULL, NULL, ISZ_EDITOR, 1); cairo_rectangle(cr, 0.0, 0.0, w, h); cairo_set_source_surface(cr, surface, 0.0, 0.0); |