aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-03-04 08:57:16 +0100
committerThomas White <taw@bitwiz.me.uk>2019-03-04 08:57:16 +0100
commit9c4fa38c4b301645439a6718ef42aa597a97de9b (patch)
tree188c08b19fdc7af014449dd0c560b062e650418c
parent60d5817656bd7c2a9f07a83be612a28c9041ab12 (diff)
Placeholder boxes for slides in narrative
-rw-r--r--libstorycode/narrative.c7
-rw-r--r--libstorycode/narrative_priv.h6
-rw-r--r--libstorycode/narrative_render_cairo.c27
-rw-r--r--libstorycode/storycode.y2
4 files changed, 40 insertions, 2 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 97d4353..91c87c5 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -102,4 +102,11 @@ void narrative_add_text(Narrative *n, char *text)
void narrative_add_slide(Narrative *n, Slide *slide)
{
+ struct narrative_item *item;
+
+ item = add_item(n);
+ if ( item == NULL ) return;
+
+ item->type = NARRATIVE_ITEM_SLIDE;
+ item->slide = slide;
}
diff --git a/libstorycode/narrative_priv.h b/libstorycode/narrative_priv.h
index a661e97..9076def 100644
--- a/libstorycode/narrative_priv.h
+++ b/libstorycode/narrative_priv.h
@@ -28,6 +28,7 @@
#endif
#include "storycode.h"
+#include "slide.h"
enum narrative_item_type
@@ -48,7 +49,7 @@ struct narrative_item
double space_t; /* Already included in "h" */
double space_b; /* Already included in "h" */
- /* For TEXT, SLIDETITLE, PRESTITLE */
+ /* For TEXT, BP, PRESTITLE */
char *text;
enum alignment align;
#ifdef HAVE_PANGO
@@ -56,6 +57,9 @@ struct narrative_item
#else
void *layout;
#endif
+
+ /* For SLIDE */
+ Slide *slide;
};
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c
index b50944a..0cc9c4d 100644
--- a/libstorycode/narrative_render_cairo.c
+++ b/libstorycode/narrative_render_cairo.c
@@ -148,6 +148,11 @@ int narrative_wrap(Narrative *n, Stylesheet *stylesheet, PangoLanguage *lang,
break;
case NARRATIVE_ITEM_SLIDE :
+ n->items[i].space_l = 0.0;
+ n->items[i].space_r = 0.0;
+ n->items[i].space_t = 0.0;
+ n->items[i].space_b = 0.0;
+ n->items[i].h = 256.0;
break;
default :
@@ -171,6 +176,27 @@ double narrative_get_height(Narrative *n)
}
+static void draw_slide(struct narrative_item *item, cairo_t *cr)
+{
+ double x, y;
+
+ cairo_save(cr);
+ cairo_translate(cr, item->space_l, item->space_t);
+
+ x = 0.0; y = 0.0;
+ cairo_user_to_device(cr, &x, &y);
+ x = rint(x); y = rint(y);
+ cairo_device_to_user(cr, &x, &y);
+ cairo_rectangle(cr, x+0.5, y+0.5, 320.0, 256.0);
+
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_set_line_width(cr, 1.0);
+ cairo_stroke(cr);
+
+ cairo_restore(cr);
+}
+
+
static void draw_text(struct narrative_item *item, cairo_t *cr)
{
cairo_save(cr);
@@ -241,6 +267,7 @@ int narrative_render_cairo(Narrative *n, cairo_t *cr, Stylesheet *stylesheet)
break;
case NARRATIVE_ITEM_SLIDE :
+ draw_slide(&n->items[i], cr);
break;
default :
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index f400bec..f549525 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -195,7 +195,7 @@ narrative:
narrative_el:
narrative_prestitle { narrative_add_prestitle(ctx->n, $1); }
| narrative_bulletpoint { narrative_add_bp(ctx->n, $1); }
-| slide { narrative_add_slide(ctx->n, $1); }
+| slide { }
| STRING { narrative_add_text(ctx->n, $1); }
;