[gimp] app: simplify scroll offset calculation for middle-mouse scrolling



commit 6b8426874d962074dd04e9e0b407ee22f6afd011
Author: Michael Natterer <mitch gimp org>
Date:   Sat Apr 20 08:37:15 2013 +0200

    app: simplify scroll offset calculation for middle-mouse scrolling

 app/display/gimpdisplayshell-tool-events.c | 21 +++++++++++----------
 app/display/gimpdisplayshell.h             |  4 ++--
 2 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index d639e8a..733c972 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -842,10 +842,11 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
                             : mevent->y);
 
             gimp_display_shell_scroll (shell,
-                                       (shell->scroll_start_x - x -
-                                        shell->offset_x),
-                                       (shell->scroll_start_y - y -
-                                        shell->offset_y));
+                                       shell->scroll_last_x - x,
+                                       shell->scroll_last_y - y);
+
+            shell->scroll_last_x = x;
+            shell->scroll_last_y = y;
           }
         else if (state & GDK_BUTTON1_MASK)
           {
@@ -1412,9 +1413,9 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
 
   gimp_display_shell_pointer_grab (shell, event, GDK_POINTER_MOTION_MASK);
 
-  shell->scrolling      = TRUE;
-  shell->scroll_start_x = x + shell->offset_x;
-  shell->scroll_start_y = y + shell->offset_y;
+  shell->scrolling     = TRUE;
+  shell->scroll_last_x = x;
+  shell->scroll_last_y = y;
 
   gimp_display_shell_set_override_cursor (shell, GDK_FLEUR);
 }
@@ -1427,9 +1428,9 @@ gimp_display_shell_stop_scrolling (GimpDisplayShell *shell,
 
   gimp_display_shell_unset_override_cursor (shell);
 
-  shell->scrolling      = FALSE;
-  shell->scroll_start_x = 0;
-  shell->scroll_start_y = 0;
+  shell->scrolling     = FALSE;
+  shell->scroll_last_x = 0;
+  shell->scroll_last_y = 0;
 
   gimp_display_shell_pointer_ungrab (shell, event);
 }
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 2204d2d..08ef099 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -174,8 +174,8 @@ struct _GimpDisplayShell
   const gchar       *space_shaded_tool;
 
   gboolean           scrolling;
-  gint               scroll_start_x;
-  gint               scroll_start_y;
+  gint               scroll_last_x;
+  gint               scroll_last_y;
   gpointer           scroll_info;
 
   GimpDrawable      *mask;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]