From 51d1ab9bce70eccd0210c8040a7d8787e76474cb Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 26 Jan 2021 22:14:44 +0200 Subject: [PATCH] libgimpwidgets: Introduce GIMP_ZOOM_PINCH This zoom mode is handled pretty much the same as GIMP_ZOOM_SMOOTH except that we do not apply adjustments for the scaling delta. Pinch zooming is ultimately a different physical activity than smooth scrolling and users likely expect different sensitivity. --- libgimpwidgets/gimpwidgetsenums.h | 4 +++- libgimpwidgets/gimpzoommodel.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libgimpwidgets/gimpwidgetsenums.h b/libgimpwidgets/gimpwidgetsenums.h index 3544afc6a3..ef6d935607 100644 --- a/libgimpwidgets/gimpwidgetsenums.h +++ b/libgimpwidgets/gimpwidgetsenums.h @@ -216,6 +216,7 @@ typedef enum * @GIMP_ZOOM_OUT_MAX: zoom out as far as possible * @GIMP_ZOOM_TO: zoom to a specific zoom factor * @GIMP_ZOOM_SMOOTH: zoom smoothly from a smooth scroll event + * @GIMP_ZOOM_PINCH: zoom smoothly from a touchpad pinch gesture * * the zoom types for #GimpZoomModel. **/ @@ -232,7 +233,8 @@ typedef enum GIMP_ZOOM_IN_MAX, /*< skip >*/ GIMP_ZOOM_OUT_MAX, /*< skip >*/ GIMP_ZOOM_TO, /*< skip >*/ - GIMP_ZOOM_SMOOTH /*< skip >*/ + GIMP_ZOOM_SMOOTH, /*< skip >*/ + GIMP_ZOOM_PINCH, /*< skip >*/ } GimpZoomType; diff --git a/libgimpwidgets/gimpzoommodel.c b/libgimpwidgets/gimpzoommodel.c index 6d12aba7c0..e4b772eacc 100644 --- a/libgimpwidgets/gimpzoommodel.c +++ b/libgimpwidgets/gimpzoommodel.c @@ -705,6 +705,14 @@ gimp_zoom_model_zoom_step (GimpZoomType zoom_type, new_scale = scale; break; + case GIMP_ZOOM_PINCH: + if (delta > 0.0) + new_scale = scale * (1.0 + delta); + else if (delta < 0.0) + new_scale = scale / (1.0 + -delta); + else + new_scale = scale; + break; } return CLAMP (new_scale, ZOOM_MIN, ZOOM_MAX);