aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-05-10 23:32:22 +0200
committerThomas White <taw@bitwiz.me.uk>2019-08-13 21:30:56 +0200
commitd1089423bd69517513913e0d7d38acf30c44b757 (patch)
treec16ea0c45c806a2c8ce2b6c05999aeddaca720e6
parente3ee9aa8ffa5f75707316627940c3dfe96c94ece (diff)
Implement end of presentation marker
-rw-r--r--libstorycode/narrative.c10
-rw-r--r--libstorycode/narrative.h1
-rw-r--r--libstorycode/narrative_render_cairo.c31
-rw-r--r--src/narrative_window.c26
4 files changed, 52 insertions, 16 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 2a8f0f3..4d088e4 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -409,6 +409,16 @@ int narrative_get_num_items(Narrative *n)
}
+int narrative_get_num_items_to_eop(Narrative *n)
+{
+ int i;
+ for ( i=0; i<n->n_items; i++ ) {
+ if ( n->items[i].type == NARRATIVE_ITEM_EOP ) return i;
+ }
+ return n->n_items;
+}
+
+
int narrative_get_num_slides(Narrative *n)
{
int i;
diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h
index c7666b7..3e21ca1 100644
--- a/libstorycode/narrative.h
+++ b/libstorycode/narrative.h
@@ -61,6 +61,7 @@ extern void narrative_delete_block(Narrative *n, int i1, size_t o1,
int i2, size_t o2);
extern void narrative_split_item(Narrative *n, int i1, size_t o1);
extern int narrative_get_num_items(Narrative *n);
+extern int narrative_get_num_items_to_eop(Narrative *n);
extern int narrative_get_num_slides(Narrative *n);
extern Slide *narrative_get_slide(Narrative *n, int para);
extern Slide *narrative_get_slide_by_number(Narrative *n, int pos);
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c
index ad687ef..c22b7ce 100644
--- a/libstorycode/narrative_render_cairo.c
+++ b/libstorycode/narrative_render_cairo.c
@@ -33,6 +33,9 @@
#include <stdlib.h>
#include <math.h>
+#include <libintl.h>
+#define _(x) gettext(x)
+
#include "slide.h"
#include "narrative.h"
#include "stylesheet.h"
@@ -403,9 +406,11 @@ static void draw_slide(struct narrative_item *item, cairo_t *cr)
}
-static void draw_eop(struct narrative_item *item, cairo_t *cr)
+static void draw_marker(struct narrative_item *item, cairo_t *cr)
{
double x, y;
+ PangoLayout *layout;
+ PangoFontDescription *fontdesc;
cairo_save(cr);
cairo_translate(cr, item->space_l, item->space_t);
@@ -422,9 +427,29 @@ static void draw_eop(struct narrative_item *item, cairo_t *cr)
}
cairo_rectangle(cr, x, y, item->obj_w, item->obj_h);
- cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+ cairo_set_source_rgb(cr, 0.8, 0.0, 0.0);
cairo_fill(cr);
+ layout = pango_cairo_create_layout(cr);
+ pango_layout_set_text(layout, _("End of presentation"), -1);
+
+ fontdesc = pango_font_description_new();
+ pango_font_description_set_family_static(fontdesc, "Sans");
+ pango_font_description_set_style(fontdesc, PANGO_STYLE_ITALIC);
+ pango_font_description_set_absolute_size(fontdesc, 0.9*item->obj_h*PANGO_SCALE);
+ pango_layout_set_font_description(layout, fontdesc);
+ pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
+ pango_layout_set_width(layout, item->obj_w*PANGO_SCALE);
+
+ cairo_move_to(cr, 0.0, 0.0);
+ cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+ pango_cairo_update_layout(cr, layout);
+ pango_cairo_show_layout(cr, layout);
+ cairo_fill(cr);
+
+ g_object_unref(layout);
+ pango_font_description_free(fontdesc);
+
cairo_restore(cr);
}
@@ -465,7 +490,7 @@ int narrative_render_item_cairo(Narrative*n, cairo_t *cr, int i)
break;
case NARRATIVE_ITEM_EOP :
- draw_eop(&n->items[i], cr);
+ draw_marker(&n->items[i], cr);
break;
}
diff --git a/src/narrative_window.c b/src/narrative_window.c
index d90913b..7eed8ca 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -327,15 +327,21 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter,
}
+static void set_clock_pos(NarrativeWindow *nw)
+{
+ int pos = gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv));
+ int end = narrative_get_num_items_to_eop(nw->n);
+ if ( pos >= end ) pos = end-1;
+ pr_clock_set_pos(nw->pr_clock, pos, end);
+}
+
+
static void first_para_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(nw->n);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), 0);
- pr_clock_set_pos(nw->pr_clock,
- gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)),
- n_paras);
+ set_clock_pos(nw);
update_toolbar(nw);
}
@@ -343,13 +349,10 @@ static void first_para_sig(GSimpleAction *action, GVariant *parameter,
static void ss_prev_para(SCSlideshow *ss, void *vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(nw->n);
if ( gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)) == 0 ) return;
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv),
gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv))-1);
- pr_clock_set_pos(nw->pr_clock,
- gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)),
- n_paras);
+ set_clock_pos(nw);
update_toolbar(nw);
}
@@ -387,7 +390,7 @@ static void ss_next_para(SCSlideshow *ss, void *vp)
}
}
- pr_clock_set_pos(nw->pr_clock, gtk_narrative_view_get_cursor_para(nv), n_paras);
+ set_clock_pos(nw);
ns = narrative_get_slide(nw->n, gtk_narrative_view_get_cursor_para(nv));
if ( nw->show != NULL && ns != NULL ) {
sc_slideshow_set_slide(nw->show, ns);
@@ -408,11 +411,8 @@ static void last_para_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(nw->n);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), -1);
- pr_clock_set_pos(nw->pr_clock,
- gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)),
- n_paras);
+ set_clock_pos(nw);
update_toolbar(nw);
}