]> www.fi.muni.cz Git - evince.git/commitdiff
Add a EvTransitionAnimation to the struct.
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 4 Jan 2008 20:26:24 +0000 (20:26 +0000)
committerCarlos Garnacho <carlosg@src.gnome.org>
Fri, 4 Jan 2008 20:26:24 +0000 (20:26 +0000)
2008-01-04  Carlos Garnacho  <carlosg@gnome.org>

        * 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
shell/ev-view-private.h
shell/ev-view.c

index 33133b7d6830622ede36439780e995b62d87e1cf..c82fc3c0519fce4124e455dd1462e3429b70272e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-01-04  Carlos Garnacho  <carlosg@gnome.org>
+
+       * 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  <carlosg@gnome.org>
 
        * shell/ev-transition-animation.[ch]: Added, EvTransitionAnimation
index a2a2812541554d65c1f687ac2c47ee13213230f4..c36cd57bd421633fb1f2c3f0fd7e1f75c78f1bde 100644 (file)
@@ -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 {
index 5944e348305db28d0e60026f86090b3a48e4969f..0fd2834aeb6b03f89004eaf6d90259012be76709 100644 (file)
@@ -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);