From 1624d8ca4f26f53dcae3e2f122285d75fa003384 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 4 Jan 2008 20:26:24 +0000 Subject: [PATCH] Add a EvTransitionAnimation to the struct. 2008-01-04 Carlos Garnacho * shell/ev-view-private.h: Add a EvTransitionAnimation to the struct. * shell/ev-view.c (ev_view_expose_event) (ev_view_change_page) (ev_view_transition_animation_start) (ev_view_transition_animation_finish) (ev_transition_animation_frame) (job_finished_cb) (page_changed_cb) (ev_view_set_presentation) (ev_view_next_page) (ev_view_previous_page): Use EvTransitionAnimation to drive page changes in the presentation mode, the animation will wait to start until both the origin and destination page surfaces are available. Fixes #458460. (draw_loading_text): Remove workaround for bug #320352, it's now fixed properly. svn path=/trunk/; revision=2800 --- ChangeLog | 18 ++++++ shell/ev-view-private.h | 3 + shell/ev-view.c | 126 +++++++++++++++++++++++++++++++++------- 3 files changed, 127 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33133b7d..c82fc3c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2008-01-04 Carlos Garnacho + + * shell/ev-view-private.h: Add a EvTransitionAnimation to the struct. + * shell/ev-view.c (ev_view_expose_event) (ev_view_change_page) + (ev_view_transition_animation_start) + (ev_view_transition_animation_finish) (ev_transition_animation_frame) + (job_finished_cb) (page_changed_cb) (ev_view_set_presentation) + (ev_view_next_page) (ev_view_previous_page): + + Use EvTransitionAnimation to drive page changes in the presentation + mode, the animation will wait to start until both the origin and + destination page surfaces are available. Fixes #458460. + + (draw_loading_text): + + Remove workaround for bug #320352, it's now fixed properly. + + 2008-01-04 Carlos Garnacho * shell/ev-transition-animation.[ch]: Added, EvTransitionAnimation diff --git a/shell/ev-view-private.h b/shell/ev-view-private.h index a2a28125..c36cd57b 100644 --- a/shell/ev-view-private.h +++ b/shell/ev-view-private.h @@ -27,6 +27,7 @@ #include "ev-image.h" #include "ev-form-field.h" #include "ev-selection.h" +#include "ev-transition-animation.h" #define DRAG_HISTORY 10 @@ -172,6 +173,8 @@ struct _EvView { /* Goto Popup */ GtkWidget *goto_window; GtkWidget *goto_entry; + + EvTransitionAnimation *animation; }; struct _EvViewClass { diff --git a/shell/ev-view.c b/shell/ev-view.c index 5944e348..0fd2834a 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -42,6 +42,7 @@ #include "ev-job-queue.h" #include "ev-page-cache.h" #include "ev-pixbuf-cache.h" +#include "ev-transition-animation.h" #if !GTK_CHECK_VERSION (2, 11, 7) #include "ev-tooltip.h" #endif @@ -2479,6 +2480,24 @@ ev_view_expose_event (GtkWidget *widget, cairo_t *cr; gint i; + if (view->animation) { + GdkRectangle page_area; + GtkBorder border; + + if (get_page_extents (view, view->current_page, &page_area, &border)) { + cr = gdk_cairo_create (view->layout.bin_window); + + /* normalize to x=0, y=0 */ + cairo_translate (cr, page_area.x, page_area.y); + page_area.x = page_area.y = 0; + + ev_transition_animation_paint (view->animation, cr, page_area); + cairo_destroy (cr); + } + + return TRUE; + } + if (view->presentation) { switch (view->presentation_state) { case EV_PRESENTATION_END: { @@ -3601,12 +3620,6 @@ draw_loading_text (EvView *view, cairo_t *cr; gint width, height; - /* Don't annoy users with loading messages during presentations. - * FIXME: Temporary "workaround" for - * http://bugzilla.gnome.org/show_bug.cgi?id=320352 */ - if (view->presentation) - return; - if (!view->loading_text) { const gchar *loading_text = _("Loading..."); PangoLayout *layout; @@ -3725,7 +3738,7 @@ draw_one_page (EvView *view, cairo_save (cr); cairo_translate (cr, overlap.x, overlap.y); - + if (width != page_width || height != page_height) { cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST); @@ -4204,11 +4217,76 @@ find_changed_cb (EvDocument *document, int page, EvView *view) gtk_widget_queue_draw (GTK_WIDGET (view)); } +static void +ev_view_change_page (EvView *view, + gint new_page) +{ + gint x, y; + + view->current_page = new_page; + view->pending_scroll = SCROLL_TO_PAGE_POSITION; + + if (view->presentation) + ev_view_presentation_transition_start (view); + + gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); + ev_view_handle_cursor_over_xy (view, x, y); + + gtk_widget_queue_resize (GTK_WIDGET (view)); +} + +static void +ev_view_transition_animation_finish (EvTransitionAnimation *animation, + EvView *view) +{ + g_object_unref (view->animation); + view->animation = NULL; + ev_view_change_page (view, view->current_page); +} + +static void +ev_view_transition_animation_frame (EvTransitionAnimation *animation, + gdouble progress, + EvView *view) +{ + gtk_widget_queue_draw (GTK_WIDGET (view)); +} + +static void +ev_view_presentation_animation_start (EvView *view, + int new_page) +{ + EvTransitionEffect *effect = NULL; + cairo_surface_t *surface; + + if (EV_IS_DOCUMENT_TRANSITION (view->document)) + effect = ev_document_transition_get_effect (EV_DOCUMENT_TRANSITION (view->document), + view->current_page); + if (!effect) + return; + + surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, view->current_page); + view->animation = ev_transition_animation_new (effect); + ev_transition_animation_set_origin_surface (view->animation, surface); + + g_signal_connect (view->animation, "frame", + G_CALLBACK (ev_view_transition_animation_frame), view); + g_signal_connect (view->animation, "finished", + G_CALLBACK (ev_view_transition_animation_finish), view); +} + static void job_finished_cb (EvPixbufCache *pixbuf_cache, GdkRegion *region, EvView *view) { + if (view->animation) { + cairo_surface_t *surface; + + surface = ev_pixbuf_cache_get_surface (pixbuf_cache, view->current_page); + ev_transition_animation_set_dest_surface (view->animation, surface); + } + if (region) { gdk_window_invalidate_region (view->layout.bin_window, region, TRUE); @@ -4223,18 +4301,10 @@ page_changed_cb (EvPageCache *page_cache, EvView *view) { if (view->current_page != new_page) { - gint x, y; - - view->current_page = new_page; - view->pending_scroll = SCROLL_TO_PAGE_POSITION; - if (view->presentation) - ev_view_presentation_transition_start (view); - - gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); - ev_view_handle_cursor_over_xy (view, x, y); - - gtk_widget_queue_resize (GTK_WIDGET (view)); + ev_view_presentation_animation_start (view, new_page); + + ev_view_change_page (view, new_page); } else { gtk_widget_queue_draw (GTK_WIDGET (view)); } @@ -4579,9 +4649,15 @@ ev_view_set_presentation (EvView *view, if (presentation) ev_view_presentation_transition_start (view); - else + else { ev_view_presentation_transition_stop (view); + if (view->animation) { + /* stop any running animation */ + ev_view_transition_animation_finish (view->animation, view); + } + } + if (GTK_WIDGET_REALIZED (view)) { if (view->presentation) gdk_window_set_background (view->layout.bin_window, @@ -5771,7 +5847,12 @@ ev_view_next_page (EvView *view) view->presentation_state == EV_PRESENTATION_WHITE)) { ev_view_reset_presentation_state (view); return FALSE; - } + } + + if (view->animation) { + ev_view_transition_animation_finish (view->animation, view); + return TRUE; + } ev_view_presentation_transition_stop (view); ev_view_reset_presentation_state (view); @@ -5822,6 +5903,11 @@ ev_view_previous_page (EvView *view) return FALSE; } + if (view->animation) { + ev_view_transition_animation_finish (view->animation, view); + return TRUE; + } + ev_view_reset_presentation_state (view); page = ev_page_cache_get_current_page (view->page_cache); -- 2.43.5