aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-03-28 15:05:10 +0100
committerThomas White <taw@bitwiz.me.uk>2019-03-28 15:05:10 +0100
commit6b60cafe0c2689531459f1cffd704da16ed2aec3 (patch)
treee41af753bb798e8b955434696c843c04dccf6bc5 /libstorycode
parent47764e46296e8c6921bbc00b95c05ff153699dc2 (diff)
Restore slideshow and clock
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/gtk/gtknarrativeview.c47
-rw-r--r--libstorycode/gtk/gtknarrativeview.h1
-rw-r--r--libstorycode/narrative.c14
-rw-r--r--libstorycode/narrative.h2
4 files changed, 60 insertions, 4 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 5bf45dd..1d0a1c2 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -487,11 +487,28 @@ static double para_top(Narrative *n, int pnum)
static void draw_para_highlight(cairo_t *cr, Narrative *n, int cursor_para)
{
double cx, cy, cw, ch;
+ struct narrative_item *item;
+
+ cx = 0.0;
+ cy = para_top(n, cursor_para);
- cx = n->space_l;
- cy = n->space_t + para_top(n, cursor_para);
- cw = n->items[cursor_para].slide_w;
- ch = n->items[cursor_para].slide_h;
+ item = &n->items[cursor_para];
+
+ if ( item->type == NARRATIVE_ITEM_SLIDE ) {
+ cw = item->slide_w;
+ ch = item->slide_h;
+ } else {
+ if ( item->layout != NULL ) {
+ PangoRectangle rect;
+ pango_layout_get_extents(item->layout, NULL, &rect);
+ cw = pango_units_to_double(rect.width) + item->space_r + item->space_l;
+ ch = pango_units_to_double(rect.height) + item->space_b + item->space_t;
+ } else {
+ cw = 0.0;
+ ch = 0.0;
+ fprintf(stderr, "No layout when drawing highlight box\n");
+ }
+ }
cairo_new_path(cr);
cairo_rectangle(cr, cx, cy, cw, ch);
@@ -1176,3 +1193,25 @@ GtkWidget *gtk_narrative_view_new(Presentation *p)
return GTK_WIDGET(nview);
}
+
+
+void gtk_narrative_view_set_para_highlight(GtkNarrativeView *e, int para_highlight)
+{
+ e->para_highlight = para_highlight;
+ redraw(e);
+}
+
+
+int gtk_narrative_view_get_cursor_para(GtkNarrativeView *e)
+{
+ return e->cpos.para;
+}
+
+
+void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos)
+{
+ e->cpos.para = pos;
+ e->cpos.pos = 0;
+ e->cpos.trail = 0;
+ redraw(e);
+}
diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h
index fdcfed6..9cbdcbd 100644
--- a/libstorycode/gtk/gtknarrativeview.h
+++ b/libstorycode/gtk/gtknarrativeview.h
@@ -100,6 +100,7 @@ struct _gtknarrativeviewclass
typedef struct _gtknarrativeview GtkNarrativeView;
typedef struct _gtknarrativeviewclass GtkNarrativeViewClass;
+extern GType gtk_narrative_view_get_type(void);
extern GtkWidget *gtk_narrative_view_new(Presentation *p);
extern void gtk_narrative_view_set_logical_size(GtkNarrativeView *e, double w, double h);
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 81b55f0..c0ae0d7 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -248,3 +248,17 @@ void narrative_split_item(Narrative *n, int i1, size_t o1)
item2->type = NARRATIVE_ITEM_TEXT;
}
+
+
+int narrative_get_num_items(Narrative *n)
+{
+ return n->n_items;
+}
+
+
+Slide *narrative_get_slide(Narrative *n, int para)
+{
+ if ( para >= n->n_items ) return NULL;
+ if ( n->items[para].type != NARRATIVE_ITEM_SLIDE ) return NULL;
+ return n->items[para].slide;
+}
diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h
index 5b8af4a..3ee215f 100644
--- a/libstorycode/narrative.h
+++ b/libstorycode/narrative.h
@@ -41,6 +41,8 @@ extern void narrative_add_slide(Narrative *n, Slide *slide);
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 Slide *narrative_get_slide(Narrative *n, int para);
#endif /* NARRATIVE_H */