Issue #1531 - Zooming with mouse movement should keep track of original point

When Control-Button2-Zooming, remember the start point, pass it to
gimp_display_shell_scale_drag() and force gimp_display_shell_scale()
to zoom around that point by passing GIMP_ZOOM_FOCUS_POINTER and
faking the point using gimp_display_shell_push_zoom_focus_pointer_pos().
This commit is contained in:
Michael Natterer 2018-06-04 11:42:02 +02:00
parent d1b9f74c6f
commit 792cd581a2
4 changed files with 16 additions and 2 deletions

View File

@ -639,6 +639,8 @@ gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
void
gimp_display_shell_scale_drag (GimpDisplayShell *shell,
gdouble start_x,
gdouble start_y,
gdouble delta_x,
gdouble delta_y)
{
@ -648,19 +650,21 @@ gimp_display_shell_scale_drag (GimpDisplayShell *shell,
scale = gimp_zoom_model_get_factor (shell->zoom);
gimp_display_shell_push_zoom_focus_pointer_pos (shell, start_x, start_y);
if (delta_y > 0)
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
scale * 1.1,
GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS);
GIMP_ZOOM_FOCUS_POINTER);
}
else if (delta_y < 0)
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
scale * 0.9,
GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS);
GIMP_ZOOM_FOCUS_POINTER);
}
}

View File

@ -61,6 +61,8 @@ void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
gboolean resize_window);
void gimp_display_shell_scale_drag (GimpDisplayShell *shell,
gdouble start_x,
gdouble start_y,
gdouble delta_x,
gdouble delta_y);

View File

@ -1493,6 +1493,8 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
GDK_BUTTON_RELEASE_MASK);
shell->scrolling = TRUE;
shell->scroll_start_x = x;
shell->scroll_start_y = y;
shell->scroll_last_x = x;
shell->scroll_last_y = y;
shell->rotating = (state & gimp_get_extend_selection_mask ()) ? TRUE : FALSE;
@ -1519,6 +1521,8 @@ 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->scroll_last_x = 0;
shell->scroll_last_y = 0;
shell->rotating = FALSE;
@ -1554,6 +1558,8 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
else if (shell->scaling)
{
gimp_display_shell_scale_drag (shell,
shell->scroll_start_x,
shell->scroll_start_y,
shell->scroll_last_x - x,
shell->scroll_last_y - y);
}

View File

@ -198,6 +198,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;
gboolean rotating;