[gimp/wip/Jehan/issue-498-quick-brush-edit] app: display the brush outline (or fallback or circle) when resizing.



commit 3d8a49101ff5cb76faf418359a7a00f8ba98614b
Author: Jehan <jehan girinstud io>
Date:   Mon Mar 14 19:15:43 2022 +0100

    app: display the brush outline (or fallback or circle) when resizing.
    
    Bypass temporarily the "Show brush outline" settings when resizing
    on-canvas.

 app/display/gimpdisplayshell-tool-events.c | 22 +++++++++++++++++++---
 app/tools/gimppainttool.c                  | 28 ++++++++++++++++++++++++++++
 app/tools/gimppainttool.h                  |  3 +++
 3 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index c9d65d9ce8..62d43c4cfe 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -53,6 +53,7 @@
 
 #include "tools/gimpguidetool.h"
 #include "tools/gimpmovetool.h"
+#include "tools/gimppainttool.h"
 #include "tools/gimpsamplepointtool.h"
 #include "tools/gimptoolcontrol.h"
 #include "tools/tool_manager.h"
@@ -1626,11 +1627,17 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
     }
   else if (shell->mod1_settings == TRUE)
     {
-      /* no-op. */
+      Gimp     *gimp       = gimp_display_get_gimp (shell->display);
+      GimpTool *active_tool = tool_manager_get_active (gimp);
+
+      if (GIMP_IS_PAINT_TOOL (active_tool))
+        gimp_paint_tool_force_draw (GIMP_PAINT_TOOL (active_tool), TRUE);
     }
   else
-    gimp_display_shell_set_override_cursor (shell,
-                                            (GimpCursorType) GDK_FLEUR);
+    {
+      gimp_display_shell_set_override_cursor (shell,
+                                              (GimpCursorType) GDK_FLEUR);
+    }
 }
 
 static void
@@ -1641,6 +1648,15 @@ gimp_display_shell_stop_scrolling (GimpDisplayShell *shell,
 
   gimp_display_shell_unset_override_cursor (shell);
 
+  if (shell->mod1_settings == TRUE)
+    {
+      Gimp     *gimp       = gimp_display_get_gimp (shell->display);
+      GimpTool *active_tool = tool_manager_get_active (gimp);
+
+      if (GIMP_IS_PAINT_TOOL (active_tool))
+        gimp_paint_tool_force_draw (GIMP_PAINT_TOOL (active_tool), FALSE);
+    }
+
   shell->scrolling         = FALSE;
   shell->scroll_start_x    = 0;
   shell->scroll_start_y    = 0;
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 9f7bbba312..404e67786a 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -798,6 +798,7 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
         }
 
       gimp_paint_tool_set_draw_fallback (paint_tool, FALSE, 0.0);
+      gimp_paint_tool_set_draw_circle (paint_tool, FALSE, 0.0);
 
       if (paint_tool->draw_brush)
         outline = gimp_paint_tool_get_outline (paint_tool,
@@ -1068,3 +1069,30 @@ gimp_paint_tool_set_draw_circle (GimpPaintTool *tool,
   tool->draw_circle = draw_circle;
   tool->circle_size = circle_size;
 }
+
+
+/**
+ * gimp_paint_tool_force_draw:
+ * @tool:
+ * @force:
+ *
+ * If @force is %TRUE, the brush, or a fallback, or circle will be
+ * drawn, regardless of the Preferences settings. This can be used for
+ * code such as when modifying brush size or shape on-canvas with a
+ * visual feedback, temporarily bypassing the user setting.
+ */
+void
+gimp_paint_tool_force_draw (GimpPaintTool *tool,
+                            gboolean       force)
+{
+  GimpDisplayConfig *display_config;
+
+  g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
+
+  display_config = GIMP_DISPLAY_CONFIG (GIMP_TOOL (tool)->tool_info->gimp->config);
+
+  if (force)
+    tool->draw_brush = TRUE;
+  else
+    tool->draw_brush  = display_config->show_brush_outline;
+}
diff --git a/app/tools/gimppainttool.h b/app/tools/gimppainttool.h
index 4f1375221e..0941ffbaeb 100644
--- a/app/tools/gimppainttool.h
+++ b/app/tools/gimppainttool.h
@@ -108,5 +108,8 @@ void    gimp_paint_tool_set_draw_circle     (GimpPaintTool       *tool,
                                              gboolean             draw_circle,
                                              gint                 circle_size);
 
+void    gimp_paint_tool_force_draw          (GimpPaintTool       *tool,
+                                             gboolean             force);
+
 
 #endif  /*  __GIMP_PAINT_TOOL_H__  */


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