aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-26 19:57:41 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-26 19:57:41 +0100
commit36a4bd7229a562d414513073d1123080b9615cd9 (patch)
treec473b435ca1165b69519f02ad9a5b8eafe693ef7 /libstorycode
parentfd60b77df51cb24c33440ab7d9afe8043f9e43db (diff)
Use slide size from stylesheet when appropriate
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/slide.c13
-rw-r--r--libstorycode/slide.h2
-rw-r--r--libstorycode/slide_render_cairo.c3
-rw-r--r--libstorycode/stylesheet.c9
-rw-r--r--libstorycode/stylesheet.h1
5 files changed, 24 insertions, 4 deletions
diff --git a/libstorycode/slide.c b/libstorycode/slide.c
index 809f2cb..9db5995 100644
--- a/libstorycode/slide.c
+++ b/libstorycode/slide.c
@@ -40,8 +40,8 @@ Slide *slide_new()
if ( s == NULL ) return NULL;
s->n_items = 0;
s->items = NULL;
- s->logical_w = 1024.0;
- s->logical_h = 768.0;
+ s->logical_w = -1.0;
+ s->logical_h = -1.0;
return s;
}
@@ -198,9 +198,16 @@ int slide_set_logical_size(Slide *s, double w, double h)
}
-int slide_get_logical_size(Slide *s, double *w, double *h)
+int slide_get_logical_size(Slide *s, Stylesheet *ss, double *w, double *h)
{
if ( s == NULL ) return 1;
+
+ if ( s->logical_w < 0.0 ) {
+ /* Slide-specific value not set, use stylesheet */
+ stylesheet_get_slide_default_size(ss, w, h);
+ return 0;
+ }
+
*w = s->logical_w;
*h = s->logical_h;
return 0;
diff --git a/libstorycode/slide.h b/libstorycode/slide.h
index a91e578..e9e5875 100644
--- a/libstorycode/slide.h
+++ b/libstorycode/slide.h
@@ -43,7 +43,7 @@ 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);
+extern int slide_get_logical_size(Slide *s, Stylesheet *ss, double *w, double *h);
/* For debugging, not really part of API */
extern void describe_slide(Slide *s);
diff --git a/libstorycode/slide_render_cairo.c b/libstorycode/slide_render_cairo.c
index 307b4d4..ed9b948 100644
--- a/libstorycode/slide_render_cairo.c
+++ b/libstorycode/slide_render_cairo.c
@@ -192,10 +192,13 @@ int slide_render_cairo(Slide *s, cairo_t *cr, ImageStore *is, Stylesheet *styles
double bgcol[4];
double bgcol2[4];
cairo_pattern_t *patt = NULL;
+ double w, h;
r = stylesheet_get_background(stylesheet, STYEL_SLIDE, &bg, bgcol, bgcol2);
if ( r ) return 1;
+ slide_get_logical_size(s, stylesheet, &w, &h);
+
/* Overall background */
cairo_rectangle(cr, 0.0, 0.0, s->logical_w, s->logical_h);
switch ( bg ) {
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index 5d40f4b..0002859 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -144,6 +144,15 @@ 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;
+ return 0;
+}
+
+
int stylesheet_set_slide_default_size(Stylesheet *s, double w, double h)
{
if ( s == NULL ) return 1;
diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h
index f050303..5bd1695 100644
--- a/libstorycode/stylesheet.h
+++ b/libstorycode/stylesheet.h
@@ -83,6 +83,7 @@ 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, enum style_element el, struct frame_geom geom);
extern int stylesheet_set_font(Stylesheet *s, enum style_element el, char *font);