aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/stylesheet.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-07 00:12:50 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-07 00:12:50 +0200
commit9506063ff3d800ca7cafc3e9147ed1df50028be3 (patch)
tree45dffe56e96b1bde4eba84807ace9f32fb3af594 /libstorycode/stylesheet.c
parentf06c80cda67ad053d0561e19fa95881f545a0e6d (diff)
Save default slide size in stylesheet
Also gets rid of the nasty special variables for the default slide size, using the geometry property of the "SLIDE" style instead.
Diffstat (limited to 'libstorycode/stylesheet.c')
-rw-r--r--libstorycode/stylesheet.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index cde2216..51ae67c 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -68,8 +68,6 @@ struct style
struct _stylesheet
{
struct style top;
- double default_slide_w;
- double default_slide_h;
};
@@ -199,12 +197,11 @@ static struct style *create_style(Stylesheet *ss, const char *path, const char *
Stylesheet *stylesheet_new()
{
Stylesheet *ss;
+ struct style *sty;
+
ss = malloc(sizeof(*ss));
if ( ss == NULL ) return NULL;
- ss->default_slide_w = 1024.0;
- ss->default_slide_h = 768.0;
-
ss->top.n_substyles = 0;
ss->top.substyles = NULL;
ss->top.name = strdup("");
@@ -214,7 +211,11 @@ Stylesheet *stylesheet_new()
create_style(ss, "", "NARRATIVE");
create_style(ss, "NARRATIVE", "BP");
create_style(ss, "NARRATIVE", "PRESTITLE");
- create_style(ss, "", "SLIDE");
+ sty = create_style(ss, "", "SLIDE");
+ sty->geom.w.unit = LENGTH_UNIT;
+ sty->geom.w.len = 1024.0;
+ sty->geom.h.unit = LENGTH_UNIT;
+ sty->geom.h.len = 768.0;
create_style(ss, "SLIDE", "TEXT");
create_style(ss, "SLIDE", "PRESTITLE");
create_style(ss, "SLIDE", "SLIDETITLE");
@@ -241,18 +242,24 @@ static struct style *get_style(Stylesheet *s, enum style_element el)
int stylesheet_get_slide_default_size(Stylesheet *s, double *w, double *h)
{
- if ( s == NULL ) return 1;
- *w = s->default_slide_w;
- *h = s->default_slide_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);
+ *w = sty->geom.w.len;
+ *h = sty->geom.h.len;
return 0;
}
int stylesheet_set_slide_default_size(Stylesheet *s, double w, double h)
{
- if ( s == NULL ) return 1;
- s->default_slide_w = w;
- s->default_slide_h = 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;
}
@@ -527,7 +534,12 @@ static void add_style(char **text, size_t *len, size_t *lenmax, const char *pref
}
free(prefix2);
- /* FIXME: add default slide size */
+ 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);
+ }
}