[Xfce4-commits] <ristretto:master> Takee the image-offset into account when using box-zoom.

Stephan Arts noreply at xfce.org
Mon Aug 8 15:04:26 CEST 2011


Updating branch refs/heads/master
         to 174be852ac13380735f4cd2cadbb9457c93ee224 (commit)
       from 6c5ff39c0777f5bc6cc3d3c603679966c1e42fd5 (commit)

commit 174be852ac13380735f4cd2cadbb9457c93ee224
Author: Stephan Arts <stephan at xfce.org>
Date:   Fri Aug 5 21:52:48 2011 +0200

    Takee the image-offset into account when using box-zoom.

 src/image_viewer.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/image_viewer.c b/src/image_viewer.c
index 2c08972..8c01693 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -1467,25 +1467,11 @@ cb_rstto_image_viewer_scroll_event (RsttoImageViewer *viewer, GdkEventScroll *ev
     gdouble scale;
     GtkWidget *widget = GTK_WIDGET(viewer);
 
-    gint pixbuf_width;
-    gint pixbuf_height;
-    gint pixbuf_x_offset;
-    gint pixbuf_y_offset;
-
-
-    if (viewer->priv->dst_pixbuf)
-    {
-        pixbuf_width = gdk_pixbuf_get_width(viewer->priv->dst_pixbuf);
-        pixbuf_height = gdk_pixbuf_get_height(viewer->priv->dst_pixbuf);
-        pixbuf_x_offset = ((widget->allocation.width - pixbuf_width)/2);
-        pixbuf_y_offset = ((widget->allocation.height - pixbuf_height)/2);
-    }
-
     if ((event->state & (GDK_CONTROL_MASK)))
     {
             viewer->priv->auto_scale = FALSE;
-            tmp_x = (gtk_adjustment_get_value(viewer->hadjustment) + event->x) / viewer->priv->scale + pixbuf_x_offset;
-            tmp_y = (gtk_adjustment_get_value(viewer->vadjustment) + event->y) / viewer->priv->scale + pixbuf_y_offset;
+            tmp_x = (gtk_adjustment_get_value(viewer->hadjustment) + event->x) / viewer->priv->scale;
+            tmp_y = (gtk_adjustment_get_value(viewer->vadjustment) + event->y) / viewer->priv->scale;
 
             switch(event->direction)
             {
@@ -1771,9 +1757,9 @@ cb_rstto_image_viewer_button_release_event (RsttoImageViewer *viewer, GdkEventBu
                          * Calculate the center of the selection-box.
                          */
 
-                        gdouble tmp_y = (gtk_adjustment_get_value(viewer->vadjustment) + (gdouble)box_y + ((gdouble)box_height/ 2)) / viewer->priv->scale + pixbuf_y_offset;
+                        gdouble tmp_y = (gtk_adjustment_get_value(viewer->vadjustment) + (gdouble)box_y + ((gdouble)box_height/ 2) - pixbuf_y_offset) / viewer->priv->scale;
 
-                        gdouble tmp_x = (gtk_adjustment_get_value(viewer->hadjustment) + (gdouble)box_x + ((gdouble)box_width / 2)) / viewer->priv->scale + pixbuf_x_offset;
+                        gdouble tmp_x = (gtk_adjustment_get_value(viewer->hadjustment) + (gdouble)box_x + ((gdouble)box_width / 2) - pixbuf_x_offset) / viewer->priv->scale;
 
                         /*
                          * Calculate the new scale


More information about the Xfce4-commits mailing list