[gimp] app: Add drag-to-zoom speed preference
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add drag-to-zoom speed preference
- Date: Tue, 5 Apr 2022 13:08:18 +0000 (UTC)
commit eb58b277d22e0d02fd0c43db0dfccdc73b1fa16b
Author: woob <thetoastcaper gmail com>
Date: Tue Mar 1 20:08:42 2022 -0500
app: Add drag-to-zoom speed preference
Adds the new configuration option "drag-zoom-speed" to adjust the rate
at which mouse movement can zoom the canvas, ranging from 25% to 300%
of the base rate and applying to both drag-to-zoom modes.
This option can be found in the preferences dialog as:
Image Windows -> Zoom & Resize Behavior -> Drag-to-zoom speed
app/config/gimpdisplayconfig.c | 14 ++++++++++++++
app/config/gimpdisplayconfig.h | 1 +
app/config/gimprc-blurbs.h | 4 ++++
app/dialogs/preferences-dialog.c | 6 ++++++
app/display/gimpdisplayshell-scale.c | 7 ++++---
5 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/app/config/gimpdisplayconfig.c b/app/config/gimpdisplayconfig.c
index e2c51d0ecc..d77f021335 100644
--- a/app/config/gimpdisplayconfig.c
+++ b/app/config/gimpdisplayconfig.c
@@ -55,6 +55,7 @@ enum
PROP_DEFAULT_DOT_FOR_DOT,
PROP_INITIAL_ZOOM_TO_FIT,
PROP_DRAG_ZOOM_MODE,
+ PROP_DRAG_ZOOM_SPEED,
PROP_CURSOR_MODE,
PROP_CURSOR_UPDATING,
PROP_SHOW_BRUSH_OUTLINE,
@@ -190,6 +191,13 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
PROP_DRAG_ZOOM_MODE_DISTANCE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_DOUBLE(object_class, PROP_DRAG_ZOOM_SPEED,
+ "drag-zoom-speed",
+ "Drag-to-zoom speed",
+ DRAG_ZOOM_SPEED_BLURB,
+ 25.0, 300.0, 100.0,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CURSOR_MODE,
"cursor-mode",
"Cursor mode",
@@ -438,6 +446,9 @@ gimp_display_config_set_property (GObject *object,
case PROP_DRAG_ZOOM_MODE:
display_config->drag_zoom_mode = g_value_get_enum (value);
break;
+ case PROP_DRAG_ZOOM_SPEED:
+ display_config->drag_zoom_speed = g_value_get_double (value);
+ break;
case PROP_CURSOR_MODE:
display_config->cursor_mode = g_value_get_enum (value);
break;
@@ -553,6 +564,9 @@ gimp_display_config_get_property (GObject *object,
case PROP_DRAG_ZOOM_MODE:
g_value_set_enum (value, display_config->drag_zoom_mode);
break;
+ case PROP_DRAG_ZOOM_SPEED:
+ g_value_set_double (value, display_config->drag_zoom_speed);
+ break;
case PROP_CURSOR_MODE:
g_value_set_enum (value, display_config->cursor_mode);
break;
diff --git a/app/config/gimpdisplayconfig.h b/app/config/gimpdisplayconfig.h
index 1de8bffe89..0deab5f08b 100644
--- a/app/config/gimpdisplayconfig.h
+++ b/app/config/gimpdisplayconfig.h
@@ -51,6 +51,7 @@ struct _GimpDisplayConfig
gboolean default_dot_for_dot;
gboolean initial_zoom_to_fit;
GimpDragZoomMode drag_zoom_mode;
+ gboolean drag_zoom_speed;
GimpCursorMode cursor_mode;
gboolean cursor_updating;
gboolean show_brush_outline;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 00726264df..73487fa0d7 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -261,6 +261,10 @@ _("When enabled, this will ensure that the full image is visible after a " \
_("Whether to zoom based on distance moved or time spent moving, when " \
"zooming via dragging the mouse.")
+#define DRAG_ZOOM_SPEED_BLURB \
+_("Adjusts the rate at which dragging the mouse will zoom the canvas, " \
+ "in percentage.")
+
#define INTERPOLATION_TYPE_BLURB \
_("Sets the level of interpolation used for scaling and other " \
"transformations.")
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 6d50f1aba3..a9a418c18c 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2939,6 +2939,12 @@ prefs_dialog_new (Gimp *gimp,
_("Dra_g-to-zoom behavior:"),
GTK_GRID (grid), 0, size_group);
+ grid = prefs_grid_new (GTK_CONTAINER (vbox2));
+
+ prefs_spin_button_add (object, "drag-zoom-speed", 5.0, 25.0, 0,
+ _("Drag-to-zoom spe_ed:"),
+ GTK_GRID (grid), 0, size_group);
+
/* Space Bar */
vbox2 = prefs_frame_new (_("Space Bar"),
GTK_CONTAINER (vbox), FALSE);
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index c840f962f9..a3875aa437 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -812,6 +812,7 @@ gimp_display_shell_scale_drag (GimpDisplayShell *shell,
if (delta_y != 0.0)
{
GimpDisplayConfig *config = shell->display->config;
+ gdouble speed = config->drag_zoom_speed * 0.01;
gimp_display_shell_push_zoom_focus_pointer_pos (shell, start_x, start_y);
@@ -819,21 +820,21 @@ gimp_display_shell_scale_drag (GimpDisplayShell *shell,
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
- scale * exp (0.005 * delta_y),
+ scale * exp (0.005 * speed * delta_y),
GIMP_ZOOM_FOCUS_POINTER);
}
else if (delta_y > 0.0) /* drag_zoom_mode == PROP_DRAG_ZOOM_MODE_DURATION */
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
- scale * 1.1,
+ scale * (1 + 0.1 * speed),
GIMP_ZOOM_FOCUS_POINTER);
}
else /* delta_y < 0.0 */
{
gimp_display_shell_scale (shell,
GIMP_ZOOM_TO,
- scale * 0.9,
+ scale * (1 - 0.1 * speed),
GIMP_ZOOM_FOCUS_POINTER);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]