diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-02-22 22:03:22 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-02-22 22:03:22 +0100 |
commit | 3ff425d840876c0db965b23826998161ee87c1fd (patch) | |
tree | 982ff6ad78cee6dbbac278df4b67f8642d1b11f5 /libstorycode | |
parent | cce16c01a4ef4280b260b72e9bbf9cb4a400d122 (diff) |
Rendering stuff
Diffstat (limited to 'libstorycode')
-rw-r--r-- | libstorycode/cairo/render.c | 15 | ||||
-rw-r--r-- | libstorycode/cairo/render.h | 11 | ||||
-rw-r--r-- | libstorycode/presentation.c | 7 | ||||
-rw-r--r-- | libstorycode/presentation.h | 1 | ||||
-rw-r--r-- | libstorycode/slide.c | 22 | ||||
-rw-r--r-- | libstorycode/slide.h | 3 | ||||
-rw-r--r-- | libstorycode/storycode.l | 1 | ||||
-rw-r--r-- | libstorycode/storycode.y | 8 |
8 files changed, 54 insertions, 14 deletions
diff --git a/libstorycode/cairo/render.c b/libstorycode/cairo/render.c index 32b9596..0d3fd6f 100644 --- a/libstorycode/cairo/render.c +++ b/libstorycode/cairo/render.c @@ -1,7 +1,7 @@ /* * render.c * - * Copyright © 2013-2018 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2019 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -38,13 +38,16 @@ #include "stylesheet.h" -int slide_render(Slide *s, cairo_t *cr, double log_w, double log_h, - Stylesheet *stylesheet, int slide_number, PangoLanguage *lang, - PangoContext *pc) +int cairo_render_slide(Slide *s, cairo_t *cr, Stylesheet *stylesheet, + int slide_number, PangoLanguage *lang, PangoContext *pc) { - cairo_scale(cr, 1.0/log_w, 1.0/log_h); + double w, h; + int i; - cairo_rectangle(cr, 0.0, 0.0, log_w, log_h); + slide_get_logical_size(s, &w, &h); + + /* Overall default background */ + cairo_rectangle(cr, 0.0, 0.0, w, h); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); diff --git a/libstorycode/cairo/render.h b/libstorycode/cairo/render.h index 6e5f4ad..15fcc0c 100644 --- a/libstorycode/cairo/render.h +++ b/libstorycode/cairo/render.h @@ -1,7 +1,7 @@ /* * render.h * - * Copyright © 2013-2018 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2019 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -28,12 +28,9 @@ #endif #include "presentation.h" -#include "imagestore.h" -#include "sc_interp.h" -#include "frame.h" -extern int render_cairo_slide(Slide *s, cairo_t *cr, double log_w, double log_h, - Stylesheet *stylesheet, int slide_number, - PangoLanguage *lang, PangoContext *pc); +extern int cairo_render_slide(Slide *s, cairo_t *cr, Stylesheet *stylesheet, + int slide_number, PangoLanguage *lang, + PangoContext *pc); #endif /* RENDER_H */ diff --git a/libstorycode/presentation.c b/libstorycode/presentation.c index cafb368..6a4d019 100644 --- a/libstorycode/presentation.c +++ b/libstorycode/presentation.c @@ -109,3 +109,10 @@ Slide *presentation_slide(Presentation *p, int i) if ( i < 0 ) return NULL; return p->slides[i]; } + + +Stylesheet *presentation_get_stylesheet(Presentation *p) +{ + if ( p == NULL ) return NULL; + return p->stylesheet; +} diff --git a/libstorycode/presentation.h b/libstorycode/presentation.h index 24e5e92..80c6186 100644 --- a/libstorycode/presentation.h +++ b/libstorycode/presentation.h @@ -41,5 +41,6 @@ extern void presentation_add_slide(Presentation *p, Slide *s); extern int presentation_num_slides(Presentation *p); extern Slide *presentation_slide(Presentation *p, int i); +extern Stylesheet *presentation_get_stylesheet(Presentation *p); #endif /* PRESENTATION_H */ diff --git a/libstorycode/slide.c b/libstorycode/slide.c index 3f65ca8..400b614 100644 --- a/libstorycode/slide.c +++ b/libstorycode/slide.c @@ -62,6 +62,8 @@ struct slide_item struct _slide { + double logical_w; + double logical_h; int n_items; struct slide_item *items; }; @@ -74,6 +76,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; return s; } @@ -184,3 +188,21 @@ void describe_slide(Slide *s) printf("item %i: %i\n", i, s->items[i].type); } } + + +int slide_set_logical_size(Slide *s, double w, double h) +{ + if ( s == NULL ) return 1; + s->logical_w = w; + s->logical_h = h; + return 0; +} + + +int slide_get_logical_size(Slide *s, double *w, double *h) +{ + if ( s == NULL ) return 1; + *w = s->logical_w; + *h = s->logical_h; + return 0; +} diff --git a/libstorycode/slide.h b/libstorycode/slide.h index f42562b..a7574e1 100644 --- a/libstorycode/slide.h +++ b/libstorycode/slide.h @@ -61,6 +61,9 @@ extern int slide_add_image(Slide *s, char *filename, struct frame_geom geom); extern int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom); extern int slide_add_footer(Slide *s); extern int slide_add_slidetitle(Slide *s, char *slidetitle); +extern int slide_set_logical_size(Slide *s, double w, double h); + +extern int slide_get_logical_size(Slide *s, double *w, double *h); /* For debugging, not really part of API */ extern void describe_slide(Slide *s); diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l index f68026d..46237e5 100644 --- a/libstorycode/storycode.l +++ b/libstorycode/storycode.l @@ -52,6 +52,7 @@ PAD { return SC_PAD; } ALIGN { return SC_ALIGN; } FGCOL { return SC_FGCOL; } BGCOL { return SC_BGCOL; } +SIZE { return SC_SIZE; } (?i:left) { return SC_LEFT; } (?i:center) { return SC_CENTER; } (?i:right) { return SC_RIGHT; } diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index 1f163f3..b04acf4 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -72,7 +72,7 @@ %token OPENBRACE CLOSEBRACE %token SQOPEN SQCLOSE %token PLUS TIMES -%token UNIT VALUE +%token UNIT VALUE SIZE %type <p> presentation %type <n> narrative @@ -84,6 +84,7 @@ %type <str> bulletpoint %type <str> frameopt %type <geom> geometry +%type <geom> style_slidesize %type <len> length %type <str> slidetitle %type <character> UNIT @@ -276,9 +277,14 @@ style_slide: style_slide_def: %empty | style_slide_def style_prestitle +| style_slide_def style_slidesize | style_slide_def styledef ; +style_slidesize: + SIZE length TIMES length { $$.w = $2; $$.h = $4; $$.x.len = 0.0; $$.y.len = 0.0; } +; + style_prestitle: PRESTITLE OPENBRACE styledefs CLOSEBRACE { printf("prestitle style\n"); } ; |