diff options
-rw-r--r-- | libstorycode/slide.c | 64 | ||||
-rw-r--r-- | libstorycode/slide.h | 4 | ||||
-rw-r--r-- | libstorycode/slide_priv.h | 5 | ||||
-rw-r--r-- | libstorycode/slide_render_cairo.c | 17 | ||||
-rw-r--r-- | libstorycode/storycode.y | 18 | ||||
-rw-r--r-- | libstorycode/stylesheet.c | 2 |
6 files changed, 71 insertions, 39 deletions
diff --git a/libstorycode/slide.c b/libstorycode/slide.c index 4ee02c9..809f2cb 100644 --- a/libstorycode/slide.c +++ b/libstorycode/slide.c @@ -62,18 +62,6 @@ static struct slide_item *add_item(Slide *s) } -int slide_add_prestitle(Slide *s, char *prestitle) -{ - struct slide_item *item; - - item = add_item(s); - if ( item == NULL ) return 1; - - item->type = SLIDE_ITEM_PRESTITLE; - return 0; -} - - int slide_add_image(Slide *s, char *filename, struct frame_geom geom) { struct slide_item *item; @@ -89,8 +77,8 @@ int slide_add_image(Slide *s, char *filename, struct frame_geom geom) } -int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom, - enum alignment alignment) +int add_text_item(Slide *s, char **text, int n_text, struct frame_geom geom, + enum alignment alignment, enum slide_item_type slide_item) { int i; struct slide_item *item; @@ -98,7 +86,7 @@ int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom, item = add_item(s); if ( item == NULL ) return 1; - item->type = SLIDE_ITEM_TEXT; + item->type = slide_item; item->paragraphs = malloc(n_text*sizeof(char *)); if ( item->paragraphs == NULL ) { s->n_items--; @@ -131,17 +119,49 @@ int slide_add_footer(Slide *s) } -int slide_add_slidetitle(Slide *s, char *slidetitle) +int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom, + enum alignment alignment) { - struct slide_item *item; + return add_text_item(s, text, n_text, geom, alignment, + SLIDE_ITEM_TEXT); +} - item = add_item(s); - if ( item == NULL ) return 1; - item->type = SLIDE_ITEM_SLIDETITLE; - item->text = slidetitle; +int slide_add_slidetitle(Slide *s, char **text, int n_text) +{ + struct frame_geom geom; + + /* This geometry should never get used by the renderer */ + geom.x.len = 0.0; + geom.x.unit = LENGTH_FRAC; + geom.y.len = 0.0; + geom.y.unit = LENGTH_FRAC; + geom.w.len = 1.0; + geom.w.unit = LENGTH_FRAC; + geom.h.len = 1.0; + geom.h.unit = LENGTH_FRAC; + + return add_text_item(s, text, n_text, geom, ALIGN_INHERIT, + SLIDE_ITEM_SLIDETITLE); +} - return 0; + +int slide_add_prestitle(Slide *s, char **text, int n_text) +{ + struct frame_geom geom; + + /* This geometry should never get used by the renderer */ + geom.x.len = 0.0; + geom.x.unit = LENGTH_FRAC; + geom.y.len = 0.0; + geom.y.unit = LENGTH_FRAC; + geom.w.len = 1.0; + geom.w.unit = LENGTH_FRAC; + geom.h.len = 1.0; + geom.h.unit = LENGTH_FRAC; + + return add_text_item(s, text, n_text, geom, ALIGN_INHERIT, + SLIDE_ITEM_PRESTITLE); } diff --git a/libstorycode/slide.h b/libstorycode/slide.h index f4a5542..a91e578 100644 --- a/libstorycode/slide.h +++ b/libstorycode/slide.h @@ -35,12 +35,12 @@ typedef struct _slideitem SlideItem; extern Slide *slide_new(void); extern void slide_free(Slide *s); -extern int slide_add_prestitle(Slide *s, char *prestitle); extern int slide_add_image(Slide *s, char *filename, struct frame_geom geom); extern int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom, enum alignment alignment); extern int slide_add_footer(Slide *s); -extern int slide_add_slidetitle(Slide *s, char *slidetitle); +extern int slide_add_slidetitle(Slide *s, char **text, int n_text); +extern int slide_add_prestitle(Slide *s, char **text, int n_text); extern int slide_set_logical_size(Slide *s, double w, double h); extern int slide_get_logical_size(Slide *s, double *w, double *h); diff --git a/libstorycode/slide_priv.h b/libstorycode/slide_priv.h index fb535ba..0d39d8a 100644 --- a/libstorycode/slide_priv.h +++ b/libstorycode/slide_priv.h @@ -43,7 +43,7 @@ struct slide_item { enum slide_item_type type; - /* For TEXT */ + /* For TEXT, SLIDETITLE, PRESTITLE */ char **paragraphs; int n_paras; enum alignment align; @@ -54,9 +54,6 @@ struct slide_item /* For IMAGE */ char *filename; - /* For SLIDETITLE */ - char *text; - /* For TEXT and IMAGE */ struct frame_geom geom; }; diff --git a/libstorycode/slide_render_cairo.c b/libstorycode/slide_render_cairo.c index 7942d27..81b78ef 100644 --- a/libstorycode/slide_render_cairo.c +++ b/libstorycode/slide_render_cairo.c @@ -64,7 +64,8 @@ static PangoAlignment to_pangoalignment(enum alignment align) static void render_text(struct slide_item *item, cairo_t *cr, PangoContext *pc, - Stylesheet *ss, double parent_w, double parent_h) + Stylesheet *ss, enum style_element el, + double parent_w, double parent_h) { int i; double x, y, w, h; @@ -80,7 +81,7 @@ static void render_text(struct slide_item *item, cairo_t *cr, PangoContext *pc, w = lcalc(item->geom.w, parent_w); h = lcalc(item->geom.h, parent_h); - font = stylesheet_get_font(ss, STYEL_SLIDE_TEXT, fgcol, &align); + font = stylesheet_get_font(ss, el, fgcol, &align); if ( font == NULL ) return; fontdesc = pango_font_description_from_string(font); @@ -212,7 +213,7 @@ int slide_render_cairo(Slide *s, cairo_t *cr, ImageStore *is, Stylesheet *styles switch ( s->items[i].type ) { case SLIDE_ITEM_TEXT : - render_text(&s->items[i], cr, pc, stylesheet, + render_text(&s->items[i], cr, pc, stylesheet, STYEL_SLIDE_TEXT, s->logical_w, s->logical_h); break; @@ -221,6 +222,16 @@ int slide_render_cairo(Slide *s, cairo_t *cr, ImageStore *is, Stylesheet *styles s->logical_w, s->logical_h); break; + case SLIDE_ITEM_SLIDETITLE : + render_text(&s->items[i], cr, pc, stylesheet, STYEL_SLIDE_SLIDETITLE, + s->logical_w, s->logical_h); + break; + + case SLIDE_ITEM_PRESTITLE : + render_text(&s->items[i], cr, pc, stylesheet, STYEL_SLIDE_PRESTITLE, + s->logical_w, s->logical_h); + break; + default : break; diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index d476acc..5b7279f 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -223,18 +223,26 @@ slide_parts: ; slide_part: - slide_prestitle { slide_add_prestitle(ctx->s, $1); str_reset(ctx); } + slide_prestitle { slide_add_prestitle(ctx->s, ctx->str, ctx->n_str); + str_reset(ctx); } | imageframe { slide_add_image(ctx->s, $1, ctx->geom); str_reset(ctx); } | textframe { slide_add_text(ctx->s, ctx->str, ctx->n_str, ctx->geom, ctx->alignment); str_reset(ctx); } | FOOTER { slide_add_footer(ctx->s); } -| slidetitle { slide_add_slidetitle(ctx->s, $1); str_reset(ctx); } +| slidetitle { slide_add_slidetitle(ctx->s, ctx->str, ctx->n_str); + str_reset(ctx); } ; slide_prestitle: - PRESTITLE STRING { $$ = $2; } + PRESTITLE frame_options multi_line_string { } +| PRESTITLE frame_options '{' multi_line_string '}' { } +; + +slidetitle: + SLIDETITLE frame_options multi_line_string { } +| SLIDETITLE frame_options '{' multi_line_string '}' { } ; imageframe: @@ -257,10 +265,6 @@ slide_bulletpoint: BP STRING { $$ = $2; } ; -slidetitle: - SLIDETITLE STRING { $$ = $2; } -; - /* There can be any number of options */ frame_options: %empty diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c index 4d650c1..7054a09 100644 --- a/libstorycode/stylesheet.c +++ b/libstorycode/stylesheet.c @@ -244,7 +244,7 @@ const char *stylesheet_get_font(Stylesheet *s, enum style_element el, *alignment = sty->alignment; for ( i=0; i<4; i++ ) fgcol[i] = sty->fgcol[i]; - return s->slide_text.font; + return sty->font; } |