[gimp/gimp-2-10] app: improve brush outline position when not snapping to stroke



commit 522bc531f4f52323725a21e7708b2463194991cd
Author: Ell <ell_se yahoo com>
Date:   Sat Feb 8 11:48:50 2020 +0200

    app: improve brush outline position when not snapping to stroke
    
    In GimpPaintTool, track the cursor position separately from the
    current paint core position, so that the brush outline doesn't lag
    behind the cursor while painting.
    
    (cherry picked from commit d244a079ca76f66bffc13ff8ed782f5d5dae9010)

 app/tools/gimppainttool-paint.c | 3 +++
 app/tools/gimppainttool.c       | 7 +++++--
 app/tools/gimppainttool.h       | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimppainttool-paint.c b/app/tools/gimppainttool-paint.c
index c2132d87cf..81eb892ee4 100644
--- a/app/tools/gimppainttool-paint.c
+++ b/app/tools/gimppainttool-paint.c
@@ -518,6 +518,9 @@ gimp_paint_tool_paint_motion (GimpPaintTool    *paint_tool,
   data->coords.x -= off_x;
   data->coords.y -= off_y;
 
+  paint_tool->cursor_x = data->coords.x;
+  paint_tool->cursor_y = data->coords.y;
+
   gimp_paint_core_smooth_coords (core, paint_options, &data->coords);
 
   /*  Don't paint while the Shift key is pressed for line drawing  */
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 90b375ed58..e6ffc3bcf9 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -604,6 +604,9 @@ gimp_paint_tool_oper_update (GimpTool         *tool,
       core->cur_coords.x -= off_x;
       core->cur_coords.y -= off_y;
 
+      paint_tool->cursor_x = core->cur_coords.x;
+      paint_tool->cursor_y = core->cur_coords.y;
+
       if (display == tool->display && (state & GIMP_PAINT_TOOL_LINE_MASK))
         {
           /*  If shift is down and this is not the first paint stroke,
@@ -704,8 +707,8 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
         }
       else
         {
-          cur_x = core->cur_coords.x + off_x;
-          cur_y = core->cur_coords.y + off_y;
+          cur_x = paint_tool->cursor_x + off_x;
+          cur_y = paint_tool->cursor_y + off_y;
 
           if (paint_tool->draw_line &&
               ! gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control))
diff --git a/app/tools/gimppainttool.h b/app/tools/gimppainttool.h
index 44f3e47dd3..faaf9c738a 100644
--- a/app/tools/gimppainttool.h
+++ b/app/tools/gimppainttool.h
@@ -62,6 +62,9 @@ struct _GimpPaintTool
   GimpDisplay   *display;
   GimpDrawable  *drawable;
 
+  gdouble        cursor_x;
+  gdouble        cursor_y;
+
   gdouble        paint_x;
   gdouble        paint_y;
 };


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