diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-04-14 17:01:44 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-04-14 17:01:44 +0200 |
commit | 9944d103205725fc66459b525d18564d780029c1 (patch) | |
tree | 856c0b2c7aae15386be3ff2b75306b1f06c19629 | |
parent | a52d8c455caafff5bf4ae6f0b15219d3f0d38119 (diff) |
Keep paragraph centered in narrative during slideshow
-rw-r--r-- | libstorycode/gtk/gtknarrativeview.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c index 2e50065..675ea09 100644 --- a/libstorycode/gtk/gtknarrativeview.c +++ b/libstorycode/gtk/gtknarrativeview.c @@ -1181,9 +1181,21 @@ int gtk_narrative_view_get_cursor_para(GtkNarrativeView *e) void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos) { + double h; + int i; + e->cpos.para = pos; e->cpos.pos = 0; e->cpos.trail = 0; + + h = 0; + for ( i=0; i<e->cpos.para; i++ ) { + h += narrative_item_get_height(e->n, i); + } + h += narrative_item_get_height(e->n, e->cpos.para)/2; + e->scroll_pos = h - (e->visible_height/2); + set_vertical_params(e); + redraw(e); } |