From a779b9a9095cfceaa4a0a8da5b4faaaa98287078 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 25 Feb 2019 21:03:27 +0100 Subject: Parse gradients --- libstorycode/storycode.y | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'libstorycode/storycode.y') diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index 724a779..38a0750 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -47,6 +47,7 @@ double val; double rgba[4]; enum alignment align; + enum gradient grad; } %{ @@ -70,6 +71,7 @@ %token IMAGEFRAME %token BP %token FONT GEOMETRY PAD ALIGN FGCOL BGCOL PARASPACE +%token VERT HORIZ %token LEFT CENTER RIGHT %token STRING %token SQOPEN SQCLOSE @@ -95,6 +97,7 @@ %type slidetitle %type UNIT %type VALUE +%type gradtype %parse-param { struct scpctx *ctx }; %initial-action @@ -302,6 +305,11 @@ length: if ( $UNIT == 'f' ) $$.unit = LENGTH_FRAC; } ; +gradtype: + VERT { $$ = GRAD_VERT; } +| HORIZ { $$ = GRAD_HORIZ; } +; + /* ------ Stylesheet ------ */ @@ -332,10 +340,14 @@ style_slide: style_slide_def: %empty + /* Doesn't need set_style() */ +| style_slide_def style_slidesize { } + /* Call set_style() immediately */ +| style_slide_def background { set_style(ctx, STYEL_SLIDE); } + /* The ones below will call set_style() themselves */ | style_slide_def style_slide_prestitle { } | style_slide_def style_slide_text { } | style_slide_def style_slide_title { } -| style_slide_def style_slidesize { } ; style_slidesize: @@ -349,6 +361,16 @@ style_slidesize: } ; +background: + BGCOL colour { for ( int i=0; i<4; i++ ) ctx->bgcol[i] = $2[i]; + ctx->bggrad = GRAD_NONE; + ctx->mask |= STYMASK_BGCOL; } +| BGCOL gradtype colour colour { for ( int i=0; i<4; i++ ) ctx->bgcol[i] = $3[i]; + for ( int i=0; i<4; i++ ) ctx->bgcol2[i] = $4[i]; + ctx->bggrad = $2; + ctx->mask |= STYMASK_BGCOL; } +; + style_slide_prestitle: PRESTITLE '{' styledefs '}' { set_style(ctx, STYEL_SLIDE_PRESTITLE); } ; @@ -377,8 +399,7 @@ styledef: ctx->mask |= STYMASK_PARASPACE; } | FGCOL colour { for ( int i=0; i<4; i++ ) ctx->fgcol[i] = $2[i]; ctx->mask |= STYMASK_FGCOL; } -| BGCOL colour { for ( int i=0; i<4; i++ ) ctx->bgcol[i] = $2[i]; - ctx->mask |= STYMASK_BGCOL; } +| background { /* Handled in rule 'background' */ } | ALIGN alignment { ctx->alignment = $2; ctx->mask |= STYMASK_ALIGNMENT; } ; -- cgit v1.2.3