From 0687c3317d02cae553fa4cd37f032089467bafc7 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 10 Aug 2008 13:06:06 +0000 Subject: [PATCH] Move the zoom-revert updating logic into this new helper function so that 2008-08-10 Martin Nordholts * app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale_handle_zoom_revert): Move the zoom-revert updating logic into this new helper function so that we can update zoom-revert from other places. svn path=/trunk/; revision=26485 --- ChangeLog | 7 +++++ app/display/gimpdisplayshell-scale.c | 42 ++++++++++++++++++---------- app/display/gimpdisplayshell-scale.h | 1 + 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dba140a89..37e9ae8dd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-08-10 Martin Nordholts + + * app/display/gimpdisplayshell-scale.c + (gimp_display_shell_scale_handle_zoom_revert): Move the + zoom-revert updating logic into this new helper function so that + we can update zoom-revert from other places. + 2008-08-10 Martin Nordholts * app/display/gimpdisplayshell-scale.[ch]: diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 42f90b6cf4..3feae2d4eb 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -45,7 +45,7 @@ #include "gimp-intl.h" -#define SCALE_TIMEOUT 1 +#define SCALE_TIMEOUT 2 #define SCALE_EPSILON 0.0001 @@ -484,6 +484,31 @@ gimp_display_shell_scale_fill (GimpDisplayShell *shell) gimp_display_shell_scroll_center_image (shell, TRUE, TRUE); } +/** + * gimp_display_shell_scale_handle_zoom_revert: + * @shell: + * + * Handle the updating of the Revert Zoom variables. + **/ +void +gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell) +{ + guint now; + + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + now = time (NULL); + + if (now - shell->last_scale_time >= SCALE_TIMEOUT) + { + shell->last_scale = gimp_zoom_model_get_factor (shell->zoom); + shell->last_offset_x = shell->offset_x; + shell->last_offset_y = shell->offset_y; + } + + shell->last_scale_time = now; +} + /** * gimp_display_shell_scale_by_values: * @shell: the #GimpDisplayShell @@ -503,8 +528,6 @@ gimp_display_shell_scale_by_values (GimpDisplayShell *shell, gint offset_y, gboolean resize_window) { - guint now; - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); /* Abort early if the values are all setup already. We don't @@ -515,18 +538,7 @@ gimp_display_shell_scale_by_values (GimpDisplayShell *shell, shell->offset_y == offset_y) return; - /* remember the current scale and offsets to allow reverting the scaling */ - - now = time (NULL); - - if (now - shell->last_scale_time > SCALE_TIMEOUT) - { - shell->last_scale = gimp_zoom_model_get_factor (shell->zoom); - shell->last_offset_x = shell->offset_x; - shell->last_offset_y = shell->offset_y; - } - - shell->last_scale_time = now; + gimp_display_shell_scale_handle_zoom_revert (shell); /* freeze the active tool */ gimp_display_shell_pause (shell); diff --git a/app/display/gimpdisplayshell-scale.h b/app/display/gimpdisplayshell-scale.h index 77f48b7bb9..db6b604fea 100644 --- a/app/display/gimpdisplayshell-scale.h +++ b/app/display/gimpdisplayshell-scale.h @@ -38,6 +38,7 @@ void gimp_display_shell_scale_to (GimpDisplayShell *shel gdouble y); void gimp_display_shell_scale_fit_in (GimpDisplayShell *shell); void gimp_display_shell_scale_fill (GimpDisplayShell *shell); +void gimp_display_shell_scale_handle_zoom_revert (GimpDisplayShell *shell); void gimp_display_shell_scale_by_values (GimpDisplayShell *shell, gdouble scale, gint offset_x,