diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 2 | ||||
-rw-r--r-- | src/objects.c | 22 | ||||
-rw-r--r-- | src/objects.h | 2 | ||||
-rw-r--r-- | src/slide_render.c | 16 | ||||
-rw-r--r-- | src/tool_image.c | 4 | ||||
-rw-r--r-- | src/tool_select.c | 4 | ||||
-rw-r--r-- | src/tool_text.c | 32 |
7 files changed, 69 insertions, 13 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index c5bece0..8af543d 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1130,7 +1130,7 @@ int open_mainwindow(struct presentation *p) p->slide_width + 20, p->slide_height + 20); - p->text_tool->realise(p->text_tool, p->drawingarea); + realise_everything(p); gtk_widget_set_can_focus(GTK_WIDGET(p->drawingarea), TRUE); gtk_widget_add_events(GTK_WIDGET(p->drawingarea), diff --git a/src/objects.c b/src/objects.c index 263c7b2..36e7419 100644 --- a/src/objects.c +++ b/src/objects.c @@ -173,7 +173,6 @@ void notify_style_update(struct presentation *p, struct style *sty) s->objects[j]->update_object(s->objects[j]); if ( p->cur_edit_slide == s ) changed = 1; - break; } @@ -192,6 +191,27 @@ void delete_object(struct object *o) } +void realise_everything(struct presentation *p) +{ + int i; + + p->text_tool->realise(p->text_tool, p->drawingarea); + + for ( i=0; i<p->num_slides; i++ ) { + + int j; + struct slide *s; + + s = p->slides[i]; + + for ( j=0; j<p->slides[i]->num_objects; j++ ) { + s->objects[j]->update_object(s->objects[j]); + } + + } +} + + enum corner which_corner(double xp, double yp, struct object *o) { double x, y; /* Relative to object position */ diff --git a/src/objects.h b/src/objects.h index 6fd3a42..9a2b35a 100644 --- a/src/objects.h +++ b/src/objects.h @@ -96,6 +96,8 @@ extern void notify_style_update(struct presentation *p, extern void delete_object(struct object *o); +extern void realise_everything(struct presentation *p); + extern enum corner which_corner(double xp, double yp, struct object *o); #endif /* OBJECTS_H */ diff --git a/src/slide_render.c b/src/slide_render.c index 07b57ec..d055c0a 100644 --- a/src/slide_render.c +++ b/src/slide_render.c @@ -81,6 +81,8 @@ void redraw_slide(struct slide *s) /* Is this slide currently open in the editor? */ if ( s == s->parent->cur_edit_slide ) { + GtkWidget *da; + if ( s->rendered_edit != NULL ) { cairo_surface_destroy(s->rendered_edit); } @@ -89,14 +91,18 @@ void redraw_slide(struct slide *s) h = (s->parent->slide_height/s->parent->slide_width) * w; s->rendered_edit = render_slide(s, w, h); - gdk_window_invalidate_rect(s->parent->drawingarea->window, - NULL, FALSE); + da = s->parent->drawingarea; + if ( da != NULL ) { + gdk_window_invalidate_rect(da->window, NULL, FALSE); + } } /* Is this slide currently being displayed on the projector? */ if ( s == s->parent->cur_proj_slide ) { + GtkWidget *da; + if ( s->rendered_proj != NULL ) { cairo_surface_destroy(s->rendered_proj); } @@ -105,8 +111,10 @@ void redraw_slide(struct slide *s) h = (s->parent->slide_height/s->parent->slide_width) * w; s->rendered_proj = render_slide(s, w, h); - gdk_window_invalidate_rect(s->parent->ss_drawingarea->window, - NULL, FALSE); + da = s->parent->drawingarea; + if ( da != NULL ) { + gdk_window_invalidate_rect(da->window, NULL, FALSE); + } } } diff --git a/src/tool_image.c b/src/tool_image.c index 16ebfa8..a9609ff 100644 --- a/src/tool_image.c +++ b/src/tool_image.c @@ -87,8 +87,6 @@ static void update_image(struct image_object *o) o->scaled_pb = gdk_pixbuf_scale_simple(i->pb, w, h, GDK_INTERP_BILINEAR); } /* else the size didn't change */ - - redraw_slide(((struct object *)o)->parent); } @@ -188,6 +186,7 @@ struct object *add_image_object(struct slide *s, double x, double y, } update_image(new); + redraw_slide(s); return (struct object *)new; } @@ -298,6 +297,7 @@ static void end_drag(struct toolinfo *tip, struct presentation *p, o->bb_width = ti->box_width; o->bb_height = ti->box_height; update_image((struct image_object *)o); + redraw_slide(o->parent); ti->drag_reason = IMAGE_DRAG_REASON_NONE; } diff --git a/src/tool_select.c b/src/tool_select.c index 55f8894..bf2393e 100644 --- a/src/tool_select.c +++ b/src/tool_select.c @@ -76,8 +76,8 @@ static void drag(struct toolinfo *tip, struct presentation *p, if ( o->x+o->bb_width > eright ) o->x = eright - o->bb_width; if ( o->y+o->bb_height > ebottom ) o->y = ebottom - o->bb_height; - o->update_object(o); /* Object method is responsible for requesting - * a redraw */ + o->update_object(o); + redraw_slide(o->parent); } diff --git a/src/tool_text.c b/src/tool_text.c index b22a466..7b9d377 100644 --- a/src/tool_text.c +++ b/src/tool_text.c @@ -73,6 +73,8 @@ struct text_object double offs_x; double offs_y; int furniture; + + PangoContext **pc; }; @@ -192,6 +194,15 @@ static void update_text(struct text_object *o) double mw = 0.0; double mh = 0.0; + if ( o->layout == NULL ) { + if ( *o->pc != NULL ) { + o->layout = pango_layout_new(*o->pc); + } else { + /* Can't render yet */ + return; + } + } + o->furniture = o->base.style != o->base.parent->parent->ss->styles[0]; pango_layout_set_text(o->layout, o->text, -1); @@ -223,8 +234,6 @@ static void update_text(struct text_object *o) if ( o->furniture ) { calculate_position_from_style(o, eright, ebottom, mw, mh); } - - redraw_slide(((struct object *)o)->parent); } @@ -270,6 +279,7 @@ void insert_text(struct object *op, char *t) free(tmp); update_text(o); + redraw_slide(op->parent); o->insertion_point += tlen; o->base.empty = 0; } @@ -324,6 +334,7 @@ void handle_text_backspace(struct object *op) if ( strlen(o->text) == 0 ) o->base.empty = 1; update_text(o); + redraw_slide(op->parent); } @@ -332,6 +343,10 @@ static void render_text_object(cairo_t *cr, struct object *op) struct text_object *o = (struct text_object *)op; GdkColor col; + if ( o->layout == NULL ) { + return; + } + cairo_move_to(cr, o->base.x - o->offs_x, o->base.y - o->offs_y); gdk_color_parse(o->base.style->colour, &col); gdk_cairo_set_source_color(cr, &col); /* FIXME: Honour alpha as well */ @@ -433,7 +448,13 @@ static struct object *new_text_object(double x, double y, struct style *sty, new->text_len = 1; new->insertion_point = 0; new->insertion_trail = 0; - new->layout = pango_layout_new(ti->pc); + if ( ti->pc != NULL ) { + new->layout = pango_layout_new(ti->pc); + new->pc = NULL; + } else { + new->layout = NULL; + new->pc = &ti->pc; + } new->fontdesc = NULL; /* Methods for this object */ @@ -584,6 +605,7 @@ static void end_drag(struct toolinfo *tip, struct presentation *p, o->bb_width = ti->box_width; o->bb_height = ti->box_height; update_text((struct text_object *)o); + redraw_slide(o->parent); ti->drag_reason = TEXT_DRAG_REASON_NONE; } @@ -600,6 +622,7 @@ static void create_default(struct presentation *p, struct style *sty, o = (struct text_object *)n; o->furniture = 1; update_text(o); + redraw_slide(((struct object *)o)->parent); p->editing_object = n; } @@ -621,6 +644,7 @@ static void create_region(struct toolinfo *tip, struct presentation *p, o->furniture = 0; update_text(o); + redraw_slide(((struct object *)o)->parent); p->editing_object = n; } @@ -818,6 +842,8 @@ struct toolinfo *initialise_text_tool(GtkWidget *w) ti->base.realise = realise; ti->base.deserialize = deserialize; + ti->pc = NULL; + ti->drag_reason = DRAG_REASON_NONE; return (struct toolinfo *)ti; |