aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-28 18:07:50 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-28 18:07:50 +0200
commit06ec128632d51750bd0ea36436145759eda4765a (patch)
tree95efd25e4a21f136febb68ccbd8ebac86e7dcdd6
parent691f647afa414f2ea98b236b6ea7aa909be7042f (diff)
Defer re-wrapping until redraw
This avoids repeatedly re-wrapping.
-rw-r--r--libstorycode/gtk/gtknarrativeview.c9
-rw-r--r--libstorycode/gtk/gtknarrativeview.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 427b637..d45ae5d 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -606,6 +606,11 @@ static void draw_overlay(cairo_t *cr, GtkNarrativeView *e)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
{
+ if ( e->rewrap_needed ) {
+ rewrap_range(e, 0, e->n->n_items);
+ e->rewrap_needed = 0;
+ }
+
/* Ultimate background */
cairo_set_source_rgba(cr, 0.8, 0.8, 1.0, 1.0);
cairo_paint(cr);
@@ -1120,7 +1125,7 @@ GtkWidget *gtk_narrative_view_new(Narrative *n)
nview->h = 100;
nview->scroll_pos = 0;
nview->n = n;
-
+ nview->rewrap_needed = 0;
nview->para_highlight = 0;
gtk_widget_set_size_request(GTK_WIDGET(nview),
@@ -1228,7 +1233,7 @@ void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
extern void gtk_narrative_view_redraw(GtkNarrativeView *e)
{
- rewrap_range(e, 0, e->n->n_items);
+ e->rewrap_needed = 1;
emit_change_sig(e);
redraw(e);
}
diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h
index fd589c5..910c60f 100644
--- a/libstorycode/gtk/gtknarrativeview.h
+++ b/libstorycode/gtk/gtknarrativeview.h
@@ -81,6 +81,7 @@ struct _gtknarrativeview
double h_scroll_pos;
int visible_height;
int visible_width;
+ int rewrap_needed;
/* Location of the cursor */
struct edit_pos cpos;