diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-05-22 22:35:10 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-05-22 22:35:10 +0200 |
commit | 13248acdefcaa88d88cb9ef493ab3e9602abc658 (patch) | |
tree | 595b7b05e0692464e00b3299931a2d4dc1f05f2a /src/slide_render.c | |
parent | 18285193ab891014089227a459cfab7c2560af02 (diff) |
Editing and input plumbing
Diffstat (limited to 'src/slide_render.c')
-rw-r--r-- | src/slide_render.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/slide_render.c b/src/slide_render.c index 1966fe7..33eee36 100644 --- a/src/slide_render.c +++ b/src/slide_render.c @@ -26,15 +26,40 @@ #endif #include <cairo.h> +#include <pango/pangocairo.h> #include "slide_render.h" #include "presentation.h" +#include "objects.h" + + +static void render_text_object(cairo_t *cr, struct object *o) +{ + PangoLayout *l; + PangoFontDescription *d; + int width, height; + + l = pango_cairo_create_layout(cr); + pango_layout_set_text(l, o->text, -1); + d = pango_font_description_from_string("Sans 30"); + pango_layout_set_font_description(l, d); + pango_font_description_free(d); + + pango_cairo_update_layout(cr, l); + pango_layout_get_size(l, &width, &height); + cairo_move_to(cr, o->x - (width/PANGO_SCALE)/2.0, + o->y - (height/PANGO_SCALE)/2.0); + + cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + pango_cairo_show_layout(cr, l); +} int render_slide(struct slide *s) { cairo_surface_t *surf; cairo_t *cr; + int i; surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, s->slide_width, s->slide_height); @@ -45,10 +70,23 @@ int render_slide(struct slide *s) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); + for ( i=0; i<s->num_objects; i++ ) { + + struct object *o = s->objects[i]; + + switch ( o->type ) { + case TEXT : + render_text_object(cr, o); + break; + } + + } + cairo_destroy(cr); if ( s->render_cache != NULL ) cairo_surface_destroy(s->render_cache); s->render_cache = surf; + s->render_cache_seq = s->object_seq; return 0; } |