[gimp] app: fix cursor precision of source tools



commit ef2818231f43a39b0e2e118a71fa2645a773fa2f
Author: Ell <ell_se yahoo com>
Date:   Thu Jan 31 05:36:26 2019 -0500

    app: fix cursor precision of source tools
    
    In GimpCloneTool, set the cursor precision to PIXEL_CENTER while
    setting a source, and have GimpBrushTool snap the brush outline to
    pixel centers.

 app/tools/gimpbrushtool.c  |  9 +++++----
 app/tools/gimpsourcetool.c |  8 ++++++++
 app/tools/gimpsourcetool.h | 21 +++++++++++----------
 3 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c
index ddbe5c9a70..08c8ed964f 100644
--- a/app/tools/gimpbrushtool.c
+++ b/app/tools/gimpbrushtool.c
@@ -339,7 +339,7 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
                                 gdouble        x,
                                 gdouble        y)
 {
-  GimpPaintOptions     *options;
+  GimpTool             *tool;
   GimpDisplayShell     *shell;
   const GimpBezierDesc *boundary = NULL;
   gint                  width    = 0;
@@ -362,8 +362,8 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
   if (! boundary)
     return NULL;
 
-  options = GIMP_PAINT_TOOL_GET_OPTIONS (brush_tool);
-  shell   = gimp_display_get_shell (display);
+  tool  = GIMP_TOOL (brush_tool);
+  shell = gimp_display_get_shell (display);
 
   /*  don't draw the boundary if it becomes too small  */
   if (SCALEX (shell, width)  > 4 &&
@@ -372,7 +372,8 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
       x -= width  / 2.0;
       y -= height / 2.0;
 
-      if (gimp_paint_options_get_brush_mode (options) == GIMP_BRUSH_HARD)
+      if (gimp_tool_control_get_precision (tool->control) ==
+          GIMP_CURSOR_PRECISION_PIXEL_CENTER)
         {
 #define EPSILON 0.000001
           /*  Add EPSILON before rounding since e.g.
diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c
index 5ad8cc53f4..9293f500ee 100644
--- a/app/tools/gimpsourcetool.c
+++ b/app/tools/gimpsourcetool.c
@@ -249,12 +249,20 @@ gimp_source_tool_modifier_key (GimpTool        *tool,
           paint_tool->status = source_tool->status_set_source;
 
           source_tool->show_source_outline = FALSE;
+
+          source_tool->saved_precision =
+            gimp_tool_control_get_precision (tool->control);
+          gimp_tool_control_set_precision (tool->control,
+                                           GIMP_CURSOR_PRECISION_PIXEL_CENTER);
         }
       else
         {
           paint_tool->status = source_tool->status_paint;
 
           source_tool->show_source_outline = TRUE;
+
+          gimp_tool_control_set_precision (tool->control,
+                                           source_tool->saved_precision);
         }
 
       gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
diff --git a/app/tools/gimpsourcetool.h b/app/tools/gimpsourcetool.h
index d82eae3b82..c5737917aa 100644
--- a/app/tools/gimpsourcetool.h
+++ b/app/tools/gimpsourcetool.h
@@ -37,20 +37,21 @@ typedef struct _GimpSourceToolClass GimpSourceToolClass;
 
 struct _GimpSourceTool
 {
-  GimpBrushTool   parent_instance;
+  GimpBrushTool        parent_instance;
 
-  GimpDisplay    *src_display;
-  gint            src_x;
-  gint            src_y;
+  GimpDisplay         *src_display;
+  gint                 src_x;
+  gint                 src_y;
 
-  gboolean        show_source_outline;
+  gboolean             show_source_outline;
+  GimpCursorPrecision  saved_precision;
 
-  GimpCanvasItem *src_handle;
-  GimpCanvasItem *src_outline;
+  GimpCanvasItem      *src_handle;
+  GimpCanvasItem      *src_outline;
 
-  const gchar    *status_paint;
-  const gchar    *status_set_source;
-  const gchar    *status_set_source_ctrl;
+  const gchar         *status_paint;
+  const gchar         *status_set_source;
+  const gchar         *status_set_source_ctrl;
 };
 
 struct _GimpSourceToolClass


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