aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-05-10 00:09:27 +0200
committerThomas White <taw@bitwiz.me.uk>2019-05-10 00:20:30 +0200
commitd321c825e10eaaec66f3584e2bdb8edda4e44e0e (patch)
tree21bce781b269344b4d757443173c6ead2244c1a0 /libstorycode
parentc3426c404324c2a629fe1403da548699abf9592d (diff)
Add end of presentation marker
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/narrative.c12
-rw-r--r--libstorycode/narrative.h1
-rw-r--r--libstorycode/narrative_priv.h1
-rw-r--r--libstorycode/narrative_render_cairo.c46
-rw-r--r--libstorycode/storycode.c4
-rw-r--r--libstorycode/storycode.l1
-rw-r--r--libstorycode/storycode.y2
7 files changed, 65 insertions, 2 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 6ed719a..38c7284 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -165,6 +165,7 @@ int narrative_get_unsaved(Narrative *n)
int narrative_item_is_text(Narrative *n, int item)
{
if ( n->items[item].type == NARRATIVE_ITEM_SLIDE ) return 0;
+ if ( n->items[item].type == NARRATIVE_ITEM_EOP ) return 0;
return 1;
}
@@ -284,6 +285,17 @@ void narrative_add_slide(Narrative *n, Slide *slide)
}
+void narrative_add_eop(Narrative *n)
+{
+ struct narrative_item *item;
+
+ item = add_item(n);
+ if ( item == NULL ) return;
+
+ item->type = NARRATIVE_ITEM_EOP;
+}
+
+
void narrative_insert_slide(Narrative *n, Slide *slide, int pos)
{
struct narrative_item *item = insert_item(n, pos-1);
diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h
index 7f9b491..c7666b7 100644
--- a/libstorycode/narrative.h
+++ b/libstorycode/narrative.h
@@ -55,6 +55,7 @@ extern void narrative_add_prestitle(Narrative *n, char *text);
extern void narrative_add_bp(Narrative *n, char *text);
extern void narrative_add_text(Narrative *n, char *text);
extern void narrative_add_slide(Narrative *n, Slide *slide);
+extern void narrative_add_eop(Narrative *n);
extern void narrative_insert_slide(Narrative *n, Slide *slide, int pos);
extern void narrative_delete_block(Narrative *n, int i1, size_t o1,
int i2, size_t o2);
diff --git a/libstorycode/narrative_priv.h b/libstorycode/narrative_priv.h
index cea2a53..9d6e294 100644
--- a/libstorycode/narrative_priv.h
+++ b/libstorycode/narrative_priv.h
@@ -38,6 +38,7 @@ enum narrative_item_type
NARRATIVE_ITEM_PRESTITLE,
NARRATIVE_ITEM_SLIDE,
NARRATIVE_ITEM_BP,
+ NARRATIVE_ITEM_EOP,
};
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c
index 160fc46..ad687ef 100644
--- a/libstorycode/narrative_render_cairo.c
+++ b/libstorycode/narrative_render_cairo.c
@@ -236,6 +236,15 @@ static void sort_positions(struct edit_pos *a, struct edit_pos *b)
}
+static void wrap_marker(struct narrative_item *item, PangoContext *pc, double w,
+ int sel_block)
+{
+ item->obj_w = w - item->space_l - item->space_r;
+ item->obj_h = 20.0;
+ item->selected = sel_block;
+}
+
+
int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *lang,
PangoContext *pc, double w, ImageStore *is,
int min, int max,
@@ -310,6 +319,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la
case NARRATIVE_ITEM_SLIDE :
stn = "NARRATIVE.SLIDE";
break;
+
+ case NARRATIVE_ITEM_EOP :
+ stn = "NARRATIVE.EOP";
+ break;
}
if ( stylesheet_get_paraspace(stylesheet, stn, paraspace) == 0 ) {
@@ -332,6 +345,8 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la
wrap_slide(&n->items[i], stylesheet, is, sel_block);
break;
+ case NARRATIVE_ITEM_EOP :
+ wrap_marker(&n->items[i], pc, w, sel_block);
break;
}
}
@@ -388,6 +403,32 @@ static void draw_slide(struct narrative_item *item, cairo_t *cr)
}
+static void draw_eop(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);
+
+ if ( item->selected ) {
+ cairo_rectangle(cr, x-5.0, y-5.0, item->obj_w+10.0, item->obj_h+10.0);
+ cairo_set_source_rgb(cr, 0.655, 0.899, 1.0);
+ cairo_fill(cr);
+ }
+
+ cairo_rectangle(cr, x, y, item->obj_w, item->obj_h);
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_fill(cr);
+
+ cairo_restore(cr);
+}
+
+
static void draw_text(struct narrative_item *item, cairo_t *cr)
{
if ( item->layout == NULL ) return;
@@ -423,8 +464,9 @@ int narrative_render_item_cairo(Narrative*n, cairo_t *cr, int i)
draw_slide(&n->items[i], cr);
break;
- default :
- return 1;
+ case NARRATIVE_ITEM_EOP :
+ draw_eop(&n->items[i], cr);
+ break;
}
diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c
index 5b4901d..ca0d2d0 100644
--- a/libstorycode/storycode.c
+++ b/libstorycode/storycode.c
@@ -219,6 +219,10 @@ static int write_item(GOutputStream *fh, struct narrative_item *item)
if ( write_string(fh, "}\n") ) return 1;
break;
+ case NARRATIVE_ITEM_EOP:
+ if ( write_string(fh, "ENDOFPRESENTATION\n") ) return 1;
+ break;
+
}
return 0;
}
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 94901d5..b1bd81a 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -50,6 +50,7 @@ PRESTITLE { return SC_PRESTITLE; }
SLIDETITLE { return SC_SLIDETITLE; }
NARRATIVE { return SC_NARRATIVE; }
SLIDE { return SC_SLIDE; }
+ENDOFPRESENTATION { return SC_EOP; }
BP { return SC_BP; }
GEOMETRY { BEGIN(geom); return SC_GEOMETRY; }
TEXT { return SC_TEXTFRAME; }
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index b32173e..b5ac68e 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -61,6 +61,7 @@
%token STYLES
%token SLIDE
+%token EOP
%token NARRATIVE
%token PRESTITLE
%token SLIDETITLE
@@ -206,6 +207,7 @@ narrative_el:
| narrative_bulletpoint { narrative_add_bp(ctx->n, $1); }
| slide { }
| STRING { narrative_add_text(ctx->n, $1); }
+| EOP { narrative_add_eop(ctx->n); }
;
narrative_prestitle: