[gimp] app: add "Snap brush outline to stroke" option to the preferences



commit 499834a1cb28d691605f4c13db8549b0e09b925e
Author: Ell <ell_se yahoo com>
Date:   Wed Feb 5 18:30:31 2020 +0200

    app: add "Snap brush outline to stroke" option to the preferences
    
    Add a new "Snap brush outline to stroke" toggle to the "Image
    Windows" preferences page.  When enabled, the brush outline in
    paint tools snaps to the individual dabs while painting, instead of
    following the cursor precisely (this is the existing behavior).
    When disabled, the brush outline follows the cursor while painting
    in the same way it does while not painting.
    
    Disable the option by default.  This seems to be what most other
    programs are doing, and it does give paitning a smoother feel.

 app/config/gimpdisplayconfig.c   | 14 ++++++++++++++
 app/config/gimpdisplayconfig.h   |  1 +
 app/config/gimprc-blurbs.h       |  4 ++++
 app/dialogs/preferences-dialog.c | 15 ++++++++++++---
 app/tools/gimppainttool-paint.c  |  6 ++++--
 app/tools/gimppainttool.c        | 14 +++++++++++++-
 app/tools/gimppainttool.h        |  1 +
 7 files changed, 49 insertions(+), 6 deletions(-)
---
diff --git a/app/config/gimpdisplayconfig.c b/app/config/gimpdisplayconfig.c
index 3c55522020..d38a6a18aa 100644
--- a/app/config/gimpdisplayconfig.c
+++ b/app/config/gimpdisplayconfig.c
@@ -57,6 +57,7 @@ enum
   PROP_CURSOR_MODE,
   PROP_CURSOR_UPDATING,
   PROP_SHOW_BRUSH_OUTLINE,
+  PROP_SNAP_BRUSH_OUTLINE,
   PROP_SHOW_PAINT_TOOL_CURSOR,
   PROP_IMAGE_TITLE_FORMAT,
   PROP_IMAGE_STATUS_FORMAT,
@@ -202,6 +203,13 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
                             TRUE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SNAP_BRUSH_OUTLINE,
+                            "snap-brush-outline",
+                            "Snap brush outline",
+                            SNAP_BRUSH_OUTLINE_BLURB,
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SHOW_PAINT_TOOL_CURSOR,
                             "show-paint-tool-cursor",
                             "Show paint tool cursor",
@@ -427,6 +435,9 @@ gimp_display_config_set_property (GObject      *object,
     case PROP_SHOW_BRUSH_OUTLINE:
       display_config->show_brush_outline = g_value_get_boolean (value);
       break;
+    case PROP_SNAP_BRUSH_OUTLINE:
+      display_config->snap_brush_outline = g_value_get_boolean (value);
+      break;
     case PROP_SHOW_PAINT_TOOL_CURSOR:
       display_config->show_paint_tool_cursor = g_value_get_boolean (value);
       break;
@@ -536,6 +547,9 @@ gimp_display_config_get_property (GObject    *object,
     case PROP_SHOW_BRUSH_OUTLINE:
       g_value_set_boolean (value, display_config->show_brush_outline);
       break;
+    case PROP_SNAP_BRUSH_OUTLINE:
+      g_value_set_boolean (value, display_config->snap_brush_outline);
+      break;
     case PROP_SHOW_PAINT_TOOL_CURSOR:
       g_value_set_boolean (value, display_config->show_paint_tool_cursor);
       break;
diff --git a/app/config/gimpdisplayconfig.h b/app/config/gimpdisplayconfig.h
index 3fe2050047..e4c2a72962 100644
--- a/app/config/gimpdisplayconfig.h
+++ b/app/config/gimpdisplayconfig.h
@@ -53,6 +53,7 @@ struct _GimpDisplayConfig
   GimpCursorMode      cursor_mode;
   gboolean            cursor_updating;
   gboolean            show_brush_outline;
+  gboolean            snap_brush_outline;
   gboolean            show_paint_tool_cursor;
   gchar              *image_title_format;
   gchar              *image_status_format;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index b0cdd19719..85c52e0d9a 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -392,6 +392,10 @@ _("Save the tool options when GIMP exits.")
 _("When enabled, all paint tools will show a preview of the current " \
   "brush's outline.")
 
+#define SNAP_BRUSH_OUTLINE_BLURB \
+_("When enabled, the brush outline will snap to individual dabs while " \
+  "painting.")
+
 #define SHOW_HELP_BUTTON_BLURB \
 _("When enabled, dialogs will show a help button that gives access to " \
   "the related help page.  Without this button, the help page can still " \
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 3c09257728..c22dad364e 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2889,9 +2889,18 @@ prefs_dialog_new (Gimp       *gimp,
   vbox2 = prefs_frame_new (_("Mouse Pointers"),
                            GTK_CONTAINER (vbox), FALSE);
 
-  prefs_check_button_add (object, "show-brush-outline",
-                          _("Show _brush outline"),
-                          GTK_BOX (vbox2));
+  button = prefs_check_button_add (object, "show-brush-outline",
+                                   _("Show _brush outline"),
+                                   GTK_BOX (vbox2));
+
+  vbox3 = prefs_frame_new (NULL, GTK_CONTAINER (vbox2), FALSE);
+  g_object_bind_property (button, "active",
+                          vbox3,  "sensitive",
+                          G_BINDING_SYNC_CREATE);
+  prefs_check_button_add (object, "snap-brush-outline",
+                          _("S_nap brush outline to stroke"),
+                          GTK_BOX (vbox3));
+
   prefs_check_button_add (object, "show-paint-tool-cursor",
                           _("Show pointer for paint _tools"),
                           GTK_BOX (vbox2));
diff --git a/app/tools/gimppainttool-paint.c b/app/tools/gimppainttool-paint.c
index 905f80360b..c2132d87cf 100644
--- a/app/tools/gimppainttool-paint.c
+++ b/app/tools/gimppainttool-paint.c
@@ -186,12 +186,14 @@ gimp_paint_tool_paint_timeout (GimpPaintTool *paint_tool)
       GimpDisplay  *display   = paint_tool->display;
       GimpImage    *image     = gimp_display_get_image (display);
 
-      gimp_draw_tool_pause (draw_tool);
+      if (paint_tool->snap_brush)
+        gimp_draw_tool_pause (draw_tool);
 
       gimp_projection_flush_now (gimp_image_get_projection (image), TRUE);
       gimp_display_flush_now (display);
 
-      gimp_draw_tool_resume (draw_tool);
+      if (paint_tool->snap_brush)
+        gimp_draw_tool_resume (draw_tool);
     }
 
   return G_SOURCE_CONTINUE;
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index ad8e1765a6..521688dea0 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -210,6 +210,7 @@ gimp_paint_tool_constructed (GObject *object)
 
   paint_tool->show_cursor = display_config->show_paint_tool_cursor;
   paint_tool->draw_brush  = display_config->show_brush_outline;
+  paint_tool->snap_brush  = display_config->snap_brush_outline;
 
   g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
                            G_CALLBACK (gimp_paint_tool_cursor_notify),
@@ -217,6 +218,9 @@ gimp_paint_tool_constructed (GObject *object)
   g_signal_connect_object (display_config, "notify::show-brush-outline",
                            G_CALLBACK (gimp_paint_tool_cursor_notify),
                            paint_tool, 0);
+  g_signal_connect_object (display_config, "notify::snap-brush-outline",
+                           G_CALLBACK (gimp_paint_tool_cursor_notify),
+                           paint_tool, 0);
 }
 
 static void
@@ -413,7 +417,13 @@ gimp_paint_tool_motion (GimpTool         *tool,
   if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
     return;
 
+  if (! paint_tool->snap_brush)
+    gimp_draw_tool_pause  (GIMP_DRAW_TOOL (tool));
+
   gimp_paint_tool_paint_motion (paint_tool, coords, time);
+
+  if (! paint_tool->snap_brush)
+    gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
 }
 
 static void
@@ -685,7 +695,8 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
 
       gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
-      if (gimp_paint_tool_paint_is_active (paint_tool))
+      if (gimp_paint_tool_paint_is_active (paint_tool) &&
+          paint_tool->snap_brush)
         {
           cur_x = paint_tool->paint_x + off_x;
           cur_y = paint_tool->paint_y + off_y;
@@ -906,6 +917,7 @@ gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
 
   paint_tool->show_cursor = config->show_paint_tool_cursor;
   paint_tool->draw_brush  = config->show_brush_outline;
+  paint_tool->snap_brush  = config->snap_brush_outline;
 
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
 }
diff --git a/app/tools/gimppainttool.h b/app/tools/gimppainttool.h
index 18e48f72ce..44f3e47dd3 100644
--- a/app/tools/gimppainttool.h
+++ b/app/tools/gimppainttool.h
@@ -47,6 +47,7 @@ struct _GimpPaintTool
 
   gboolean       show_cursor;
   gboolean       draw_brush;
+  gboolean       snap_brush;
   gboolean       draw_fallback;
   gint           fallback_size;
   gboolean       draw_circle;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]