aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-25 21:03:27 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-25 21:03:27 +0100
commita779b9a9095cfceaa4a0a8da5b4faaaa98287078 (patch)
tree5cc65c14e82c22e78836f91c4cd34179c04892f1
parent0a146090aa9dc02f5568e9c314e11ab69b40d225 (diff)
Parse gradients
-rw-r--r--data/demo.sc1
-rw-r--r--libstorycode/scparse_priv.h2
-rw-r--r--libstorycode/storycode.l4
-rw-r--r--libstorycode/storycode.y27
-rw-r--r--libstorycode/stylesheet.h9
5 files changed, 40 insertions, 3 deletions
diff --git a/data/demo.sc b/data/demo.sc
index 65c3a1f..8890774 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -11,6 +11,7 @@ STYLES {
}
SLIDE {
SIZE 1024u x 768u
+ BGCOL VERTICAL #333333 #000055
TEXT {
FONT Cantarell Regular 14
PAD 0u,0u,0u,0u
diff --git a/libstorycode/scparse_priv.h b/libstorycode/scparse_priv.h
index 0ddfe1c..47edbf8 100644
--- a/libstorycode/scparse_priv.h
+++ b/libstorycode/scparse_priv.h
@@ -59,7 +59,9 @@ struct scpctx
struct length padding[4];
struct length paraspace[4];
double fgcol[4];
+ enum gradient bggrad;
double bgcol[4];
+ double bgcol2[4];
};
#endif /* SCPARSE_PRIV_H */
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 3a7704f..d64b8c0 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -62,6 +62,10 @@ PARASPACE { BEGIN(paraspace); return SC_PARASPACE; }
ALIGN { BEGIN(align); return SC_ALIGN; }
FGCOL { BEGIN(col); return SC_FGCOL; }
BGCOL { BEGIN(col); return SC_BGCOL; }
+<col>VERT { return SC_VERT; }
+<col>VERTICAL { return SC_VERT; }
+<col>HORIZ { return SC_HORIZ; }
+<col>HORIZONTAL { return SC_HORIZ; }
SIZE { return SC_SIZE; }
<align,sqb>(?i:left) { return SC_LEFT; }
<align,sqb>(?i:center) { return SC_CENTER; }
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 <str> slidetitle
%type <character> UNIT
%type <val> VALUE
+%type <grad> 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; }
;
diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h
index dd2b470..b4d3f00 100644
--- a/libstorycode/stylesheet.h
+++ b/libstorycode/stylesheet.h
@@ -60,9 +60,18 @@ struct frame_geom
};
+enum gradient
+{
+ GRAD_NONE,
+ GRAD_HORIZ,
+ GRAD_VERT
+};
+
+
enum style_element
{
STYEL_NARRATIVE,
+ STYEL_SLIDE,
STYEL_SLIDE_TEXT,
STYEL_SLIDE_PRESTITLE,
STYEL_SLIDE_SLIDETITLE,