Commit ef2cf21f authored by Michael Natterer's avatar Michael Natterer 😴

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).
parent fcfb1263
......@@ -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:
......
......@@ -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,
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment