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

app: allow to zoom with middle mouse button + control + drag up/down

parent 014fdb87
......@@ -628,6 +628,33 @@ gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
gimp_display_shell_resume (shell);
}
void
gimp_display_shell_scale_drag (GimpDisplayShell *shell,
gdouble delta_x,
gdouble delta_y)
{
gdouble scale;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
scale = gimp_zoom_model_get_factor (shell->zoom);
if (delta_y > 0)
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
scale * 1.1,
GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS);
}
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_display_shell_scale_shrink_wrap:
* @shell: the #GimpDisplayShell
......
......@@ -60,6 +60,10 @@ void gimp_display_shell_scale_by_values (GimpDisplayShell *shell,
gint offset_y,
gboolean resize_window);
void gimp_display_shell_scale_drag (GimpDisplayShell *shell,
gdouble delta_x,
gdouble delta_y);
void gimp_display_shell_scale_shrink_wrap (GimpDisplayShell *shell,
gboolean grow_only);
void gimp_display_shell_scale_resize (GimpDisplayShell *shell,
......
......@@ -888,6 +888,12 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
y,
constrain);
}
else if (shell->scaling)
{
gimp_display_shell_scale_drag (shell,
shell->scroll_last_x - x,
shell->scroll_last_y - y);
}
else
{
gimp_display_shell_scroll (shell,
......@@ -1502,12 +1508,16 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
shell->scrolling = TRUE;
shell->scroll_last_x = x;
shell->scroll_last_y = y;
shell->rotating = (state & GDK_SHIFT_MASK) ? TRUE : FALSE;
shell->rotating = (state & gimp_get_extend_selection_mask ()) ? TRUE : FALSE;
shell->rotate_drag_angle = shell->rotate_angle;
shell->scaling = (state & gimp_get_toggle_behavior_mask ()) ? TRUE : FALSE;
if (shell->rotating)
gimp_display_shell_set_override_cursor (shell,
(GimpCursorType) GDK_EXCHANGE);
if (shell->scaling)
gimp_display_shell_set_override_cursor (shell,
(GimpCursorType) GIMP_CURSOR_ZOOM);
else
gimp_display_shell_set_override_cursor (shell,
(GimpCursorType) GDK_FLEUR);
......@@ -1526,6 +1536,7 @@ gimp_display_shell_stop_scrolling (GimpDisplayShell *shell,
shell->scroll_last_y = 0;
shell->rotating = FALSE;
shell->rotate_drag_angle = 0.0;
shell->scaling = FALSE;
gimp_display_shell_pointer_ungrab (shell, event);
}
......
......@@ -197,6 +197,7 @@ struct _GimpDisplayShell
gint scroll_last_y;
gboolean rotating;
gdouble rotate_drag_angle;
gboolean scaling;
gpointer scroll_info;
GeglBuffer *mask;
......
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