[gimp] Bug 796252 - Mouse wheel zooming should center on cursor...
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 796252 - Mouse wheel zooming should center on cursor...
- Date: Sat, 19 May 2018 13:32:30 +0000 (UTC)
commit ef2cf21f109007e722138feb2f945688c535085f
Author: Michael Natterer <mitch gimp org>
Date: Sat May 19 14:31:01 2018 +0200
Bug 796252 - Mouse wheel zooming should center on cursor...
... _even at low zoom levels_
Pass GIMP_ZOOM_FOCUS_POINTER to gimp_display_shell_scale() when
wheel-scrolling, and change the scaling code to really honor
GIMP_ZOOM_FOCUS_POINTER and not apply magic image centering.
This keep the same point centered under the mouse for wheel-scrolling
and the zoom tool (== when the zooming is really triggered at a
certain mouse position).
NEWS | 3 +
app/display/gimpdisplayshell-scale.c | 72 +++++++++++++++-------------
app/display/gimpdisplayshell-tool-events.c | 4 +-
3 files changed, 43 insertions(+), 36 deletions(-)
---
diff --git a/NEWS b/NEWS
index e0c4509..00cd086 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,9 @@ Usability:
- Mention pressing Enter to complete Foreground selection in the status bar.
- Make sure that clicking outside any selection prevents Rectangle Select
and Ellipse Select tools from creating empty selections.
+ - Improve mouse wheel zooming behavior to keep the same point
+ centered under the pointer even if the image is completely visible
+ in the canvas.
Translations:
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index 17eb0d4..ffbb83c 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -351,7 +351,9 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
gdouble new_scale,
GimpZoomFocus zoom_focus)
{
- gdouble current_scale;
+ GimpDisplayConfig *config;
+ gdouble current_scale;
+ gboolean resize_window;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (shell->canvas != NULL);
@@ -361,25 +363,44 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
if (zoom_type != GIMP_ZOOM_TO)
new_scale = gimp_zoom_model_zoom_step (zoom_type, current_scale);
- if (! SCALE_EQUALS (new_scale, current_scale))
- {
- GimpDisplayConfig *config = shell->display->config;
- gboolean resize_window;
+ if (SCALE_EQUALS (new_scale, current_scale))
+ return;
- /* Resize windows only in multi-window mode */
- resize_window = (config->resize_windows_on_zoom &&
- ! GIMP_GUI_CONFIG (config)->single_window_mode);
+ config = shell->display->config;
- if (resize_window)
- {
- /* If the window is resized on zoom, simply do the zoom and
- * get things rolling
- */
- gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, new_scale);
+ /* Resize windows only in multi-window mode */
+ resize_window = (config->resize_windows_on_zoom &&
+ ! GIMP_GUI_CONFIG (config)->single_window_mode);
- gimp_display_shell_scale_resize (shell, TRUE, FALSE);
- }
- else
+ if (resize_window)
+ {
+ /* If the window is resized on zoom, simply do the zoom and get
+ * things rolling
+ */
+ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, new_scale);
+
+ gimp_display_shell_scale_resize (shell, TRUE, FALSE);
+ }
+ else
+ {
+ gdouble x, y;
+ gint image_center_x;
+ gint image_center_y;
+
+ gimp_display_shell_scale_get_zoom_focus (shell,
+ new_scale,
+ current_scale,
+ &x,
+ &y,
+ zoom_focus);
+ gimp_display_shell_scale_get_image_center_viewport (shell,
+ &image_center_x,
+ &image_center_y);
+
+ gimp_display_shell_scale_to (shell, new_scale, x, y);
+
+ /* skip centering magic if pointer focus was requested */
+ if (zoom_focus != GIMP_ZOOM_FOCUS_POINTER)
{
gboolean starts_fitting_horiz;
gboolean starts_fitting_vert;
@@ -387,22 +408,6 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
gboolean zoom_focus_almost_centered_vert;
gboolean image_center_almost_centered_horiz;
gboolean image_center_almost_centered_vert;
- gdouble x, y;
- gint image_center_x;
- gint image_center_y;
-
- gimp_display_shell_scale_get_zoom_focus (shell,
- new_scale,
- current_scale,
- &x,
- &y,
- zoom_focus);
- gimp_display_shell_scale_get_image_center_viewport (shell,
- &image_center_x,
- &image_center_y);
-
- gimp_display_shell_scale_to (shell, new_scale, x, y);
-
/* If an image axis started to fit due to zooming out or if
* the focus point is as good as in the center, center on
@@ -1218,7 +1223,6 @@ gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
}
}
- /* Decide which one to use for each axis */
if (zoom_focus == GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS)
{
if (gimp_display_shell_scale_viewport_coord_almost_centered (shell,
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 73e612d..95b55f5 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -944,14 +944,14 @@ gimp_display_shell_canvas_tool_events_internal (GtkWidget *canvas,
gimp_display_shell_scale (shell,
GIMP_ZOOM_IN,
0.0,
- GIMP_ZOOM_FOCUS_BEST_GUESS);
+ GIMP_ZOOM_FOCUS_POINTER);
break;
case GDK_SCROLL_DOWN:
gimp_display_shell_scale (shell,
GIMP_ZOOM_OUT,
0.0,
- GIMP_ZOOM_FOCUS_BEST_GUESS);
+ GIMP_ZOOM_FOCUS_POINTER);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]