aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-30 18:32:50 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-30 18:36:20 +0200
commitfcdd01f2c9e2664c3d82cd764064a1e6dea70674 (patch)
treef83a421305918174b7a484297a406be67544a472
parent8ccc8b247769d7c1dfd21d674b7e87a9370363e2 (diff)
Use GEOMETRY for slide size
-rw-r--r--data/demo.sc2
-rw-r--r--libstorycode/storycode.l1
-rw-r--r--libstorycode/storycode.y22
-rw-r--r--libstorycode/stylesheet.c19
-rw-r--r--libstorycode/stylesheet.h1
5 files changed, 8 insertions, 37 deletions
diff --git a/data/demo.sc b/data/demo.sc
index 8cbb3ef..96186f8 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -14,7 +14,7 @@ STYLES {
}
}
SLIDE {
- SIZE 1024u x 768u
+ GEOMETRY 1024u x 768u +0u +0u
BGCOL VERTICAL #333333 #000055
TEXT {
FONT Cantarell Regular 14
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 9a247cd..94901d5 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -65,7 +65,6 @@ BGCOL { BEGIN(col); return SC_BGCOL; }
<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; }
<align,sqb>(?i:right) { return SC_RIGHT; }
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index fce8d37..4c418eb 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -73,7 +73,7 @@
%token LEFT CENTER RIGHT
%token STRING
%token SQOPEN SQCLOSE
-%token UNIT VALUE SIZE HEXCOL
+%token UNIT VALUE HEXCOL
%type <n> narrative
%type <s> slide
@@ -364,28 +364,15 @@ 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, "SLIDE"); }
+| style_slide_def slide_geom { set_style(ctx, "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_slidesize:
- SIZE length 'x' length { if ( ($2.unit != LENGTH_UNIT)
- || ($4.unit != LENGTH_UNIT) )
- {
- fprintf(stderr, "Wrong slide size units\n");
- } else {
- stylesheet_set_slide_default_size(narrative_get_stylesheet(ctx->n),
- $2.len, $4.len);
- }
- }
-;
-
background:
BGCOL colour { copy_col(&ctx->bgcol, $2);
ctx->bggrad = GRAD_NONE;
@@ -396,6 +383,11 @@ background:
ctx->mask |= STYMASK_BGCOL; }
;
+slide_geom:
+ GEOMETRY geometry { ctx->geom = $2;
+ ctx->mask |= STYMASK_GEOM; }
+;
+
style_slide_prestitle:
PRESTITLE '{' styledefs '}' { set_style(ctx, "SLIDE.PRESTITLE"); }
;
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index 4248f52..896b2d3 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -237,18 +237,6 @@ int stylesheet_get_slide_default_size(Stylesheet *s, double *w, double *h)
}
-int stylesheet_set_slide_default_size(Stylesheet *s, double w, double h)
-{
- struct style *sty = lookup_style(&s->top, "SLIDE");
- if ( sty == NULL ) return 1;
- assert(sty->geom.w.unit == LENGTH_UNIT);
- assert(sty->geom.h.unit == LENGTH_UNIT);
- sty->geom.w.len = w;
- sty->geom.h.len = h;
- return 0;
-}
-
-
int stylesheet_set_geometry(Stylesheet *s, const char *stn, struct frame_geom geom)
{
struct style *sty = lookup_style(&s->top, stn);
@@ -518,13 +506,6 @@ static void add_style(char **text, size_t *len, size_t *lenmax, const char *pref
add_text(text, len, lenmax, prefix, "}\n");
}
free(prefix2);
-
- if ( strcmp(sty->name, "SLIDE") == 0 ) {
- char tmp[256];
- snprintf(tmp, 255, "SIZE %.4gu x %4gu\n",
- sty->geom.w.len, sty->geom.h.len);
- add_text(text, len, lenmax, prefix, tmp);
- }
}
diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h
index f7a3d21..0a38477 100644
--- a/libstorycode/stylesheet.h
+++ b/libstorycode/stylesheet.h
@@ -80,7 +80,6 @@ enum gradient
extern Stylesheet *stylesheet_new(void);
extern void stylesheet_free(Stylesheet *s);
-extern int stylesheet_set_slide_default_size(Stylesheet *s, double w, double h);
extern int stylesheet_get_slide_default_size(Stylesheet *s, double *w, double *h);
extern int stylesheet_set_geometry(Stylesheet *s, const char *stn, struct frame_geom geom);