--- gimp-painter--20080205/app/core/gimptooloptions.c Tue Nov 20 18:30:56 2007 +++ gimp-painter--20080504/app/core/gimptooloptions.c Sun May 18 03:47:57 2008 @@ -45,7 +45,8 @@ enum { PROP_0, - PROP_TOOL_INFO + PROP_TOOL_INFO, + PROP_MAX_COORD_SMOOTH }; @@ -80,6 +81,10 @@ GIMP_TYPE_TOOL_INFO, GIMP_PARAM_READWRITE)); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MAX_COORD_SMOOTH, + "max-coord-smooth", NULL, + 0.0, 1.0, 0.0, + GIMP_PARAM_STATIC_STRINGS); } static void @@ -110,6 +115,10 @@ } break; + case PROP_MAX_COORD_SMOOTH: + options->max_coord_smooth = g_value_get_double (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -128,6 +137,11 @@ { case PROP_TOOL_INFO: g_value_set_object (value, options->tool_info); + break; + + + case PROP_MAX_COORD_SMOOTH: + g_value_set_double (value, options->max_coord_smooth); break; default: --- gimp-painter--20080205/app/core/gimptooloptions.h Tue Nov 20 18:30:56 2007 +++ gimp-painter--20080504/app/core/gimptooloptions.h Sun May 18 03:47:57 2008 @@ -38,6 +38,8 @@ GimpContext parent_instance; GimpToolInfo *tool_info; + + gdouble max_coord_smooth; }; struct _GimpToolOptionsClass --- gimp-painter--20080205/app/display/gimpdisplayshell-callbacks.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/display/gimpdisplayshell-callbacks.c Sun May 18 03:47:57 2008 @@ -40,6 +40,7 @@ #include "core/gimpimage-quick-mask.h" #include "core/gimplayer.h" #include "core/gimptoolinfo.h" +#include "core/gimptooloptions.h" #include "tools/gimpimagemaptool.h" #include "tools/gimpmovetool.h" @@ -88,9 +89,6 @@ #endif -#define DEFAULT_EVENT_SMOOTHING 0.7 -#define DEFAULT_EVENT_FILTER 0.5 - /* local function prototypes */ static void gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment, @@ -618,6 +616,7 @@ Gimp *gimp; GdkDisplay *gdk_display; GimpTool *active_tool; + GimpToolOptions *active_tool_options; GimpCoords display_coords; GimpCoords image_coords; GdkModifierType state; @@ -663,6 +662,7 @@ &image_coords); active_tool = tool_manager_get_active (gimp); + active_tool_options = gimp_tool_get_options (active_tool); if (active_tool && gimp_tool_control_get_snap_to (active_tool->control)) { @@ -1256,8 +1256,7 @@ */ if (gimp_display_shell_eval_event (shell, &image_coords, - DEFAULT_EVENT_SMOOTHING, - DEFAULT_EVENT_FILTER, + active_tool_options->max_coord_smooth, history_events[i]->time)) { tool_manager_motion_active (gimp, @@ -1278,8 +1277,7 @@ */ if (gimp_display_shell_eval_event (shell, &image_coords, - DEFAULT_EVENT_SMOOTHING, - DEFAULT_EVENT_FILTER, + active_tool_options->max_coord_smooth, time)) { tool_manager_motion_active (gimp, @@ -1300,10 +1298,10 @@ /* Early removal of useless events saves CPU time. * Smoothing is 0.0 here for coasting. */ + if (gimp_display_shell_eval_event (shell, &image_coords, 0.0, - DEFAULT_EVENT_FILTER, time)) { tool_manager_oper_update_active (gimp, --- gimp-painter--20080205/app/display/gimpdisplayshell-coords.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/display/gimpdisplayshell-coords.c Sun May 18 03:47:57 2008 @@ -190,9 +190,8 @@ * * This function evaluates the event to decide if the change is * big enough to need handling and returns FALSE, if change is less - * than one image pixel or when smoothed event distance covers less - * than one pixel taking a whole lot of load off any draw tools that - * have no use for these sub-pixel events anyway. If the event is + * than set filter level taking a whole lot of load off any draw tools + * that have no use for these events anyway. If the event is * seen fit at first look, it is evaluated for speed and smoothed. * Due to lousy time resolution of events pretty strong smoothing is * applied to timestamps for sensible speed result. This function is @@ -210,12 +209,15 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell, GimpCoords *coords, gdouble inertia_factor, - gdouble filter_treshhold, guint32 time) { - const gdouble smooth_factor = 0.3; - guint32 thistime = time; - gdouble dist; + /* Smoothing causes problems with cursor tracking + * when zoomed above screen resolution so we need to supress it. + */ + if (shell->scale_x > 1.0 || shell->scale_y > 1.0) + { + inertia_factor = 0.0; + } if (shell->last_disp_motion_time == 0) { @@ -230,16 +232,22 @@ { gdouble dx = coords->delta_x = shell->last_coords.x - coords->x; gdouble dy = coords->delta_y = shell->last_coords.y - coords->y; + gdouble filter; + gdouble dist; - /* Events with distances less than the filter_threshold are not - worth handling. +#define SMOOTH_FACTOR 0.3 + + /* Events with distances less than the screen resolution are not + * worth handling. */ - if (fabs (dx) < filter_treshhold && fabs (dy) < filter_treshhold) + filter = MIN (1 / shell->scale_x, 1 / shell->scale_y) / 2.0; + + if (fabs (dx) < filter && fabs (dy) < filter) return FALSE; - coords->delta_time = thistime - shell->last_disp_motion_time; - coords->delta_time = (shell->last_coords.delta_time * (1 - smooth_factor) - + coords->delta_time * smooth_factor); + coords->delta_time = time - shell->last_disp_motion_time; + coords->delta_time = (shell->last_coords.delta_time * (1 - SMOOTH_FACTOR) + + coords->delta_time * SMOOTH_FACTOR); coords->distance = dist = sqrt (SQR (dx) + SQR (dy)); /* If even smoothed time resolution does not allow to guess for speed, @@ -255,8 +263,8 @@ (coords->distance / (gdouble) coords->delta_time) / 10; /* A little smooth on this too, feels better in tools this way. */ - coords->velocity = (shell->last_coords.velocity * (1 - smooth_factor) - + coords->velocity * smooth_factor); + coords->velocity = (shell->last_coords.velocity * (1 - SMOOTH_FACTOR) + + coords->velocity * SMOOTH_FACTOR); /* Speed needs upper limit */ coords->velocity = MIN (coords->velocity, 1.0); } @@ -290,8 +298,10 @@ coords->delta_x = sin_avg * coords->distance; coords->delta_y = cos_avg * coords->distance; - new_x = (shell->last_coords.x - coords->delta_x) * 0.5 + coords->x * 0.5; - new_y = (shell->last_coords.y - coords->delta_y) * 0.5 + coords->y * 0.5; + new_x = + (shell->last_coords.x - coords->delta_x) * 0.5 + coords->x * 0.5; + new_y = + (shell->last_coords.y - coords->delta_y) * 0.5 + coords->y * 0.5; cur_deviation = SQR (coords->x - new_x) + SQR (coords->y - new_y); @@ -326,7 +336,7 @@ #endif } - shell->last_coords = *coords; + shell->last_coords = *coords; shell->last_disp_motion_time = time; return TRUE; --- gimp-painter--20080205/app/display/gimpdisplayshell-coords.h Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/display/gimpdisplayshell-coords.h Sun May 18 03:47:57 2008 @@ -41,7 +41,6 @@ gboolean gimp_display_shell_eval_event (GimpDisplayShell *shell, GimpCoords *coords, gdouble inertia_factor, - gdouble filter_threshhold, guint32 time); --- gimp-painter--20080205/app/paint/gimpink2options.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/paint/gimpink2options.c Sun May 18 03:48:00 2008 @@ -48,7 +48,9 @@ PROP_BLOB_ANGLE, PROP_COMPENSATION_HIST_SIZE, PROP_COMPENSATE_AT_LAST, - PROP_COMPENSATION_RATE_TEMPERATURE + PROP_COMPENSATION_RATE_TEMPERATURE, + + PROP_MAX_COORD_SMOOTH }; @@ -119,6 +121,14 @@ "compensation-rate-temperature", NULL, 0.0, 1000, 25, 0); + + /* G-Pen uses the own smoothing routin, so disable the GimpDisplayShell's one */ + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MAX_COORD_SMOOTH, + "ink2-max-coord-smooth", NULL, + 0.0, 0.0, 0.0, + GIMP_PARAM_STATIC_STRINGS); + + g_object_class_override_property (object_class, PROP_MAX_COORD_SMOOTH, "paint-max-coord-smooth"); } static void @@ -169,6 +179,11 @@ case PROP_COMPENSATION_RATE_TEMPERATURE: options->compensation_rate_temperature = g_value_get_double (value); break; + + case PROP_MAX_COORD_SMOOTH: + GIMP_TOOL_OPTIONS (options)->max_coord_smooth = g_value_get_double (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -218,6 +233,11 @@ case PROP_COMPENSATION_RATE_TEMPERATURE: g_value_set_double (value, options->compensation_rate_temperature); break; + + case PROP_MAX_COORD_SMOOTH: + g_value_set_double (value, GIMP_TOOL_OPTIONS (options)->max_coord_smooth); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; --- gimp-painter--20080205/app/paint/gimppaintoptions.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/paint/gimppaintoptions.c Sun May 18 03:48:00 2008 @@ -34,31 +34,31 @@ #include "gimppaintoptions.h" -#define DEFAULT_BRUSH_SCALE 1.0 -#define DEFAULT_APPLICATION_MODE GIMP_PAINT_CONSTANT -#define DEFAULT_HARD FALSE - -#define DEFAULT_PRESSURE_EXPANDED FALSE -#define DEFAULT_PRESSURE_OPACITY TRUE -#define DEFAULT_PRESSURE_HARDNESS FALSE -#define DEFAULT_PRESSURE_RATE FALSE -#define DEFAULT_PRESSURE_SIZE FALSE -#define DEFAULT_PRESSURE_INVERSE_SIZE FALSE -#define DEFAULT_PRESSURE_COLOR FALSE -#define DEFAULT_PRESSURE_MIN_SCALE 0 - -#define DEFAULT_USE_FADE FALSE -#define DEFAULT_FADE_LENGTH 100.0 -#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL - -#define DEFAULT_USE_JITTER FALSE -#define DEFAULT_JITTER_AMOUNT 0.2 - -#define DEFAULT_USE_GRADIENT FALSE -#define DEFAULT_GRADIENT_REVERSE FALSE -#define DEFAULT_GRADIENT_REPEAT GIMP_REPEAT_TRIANGULAR -#define DEFAULT_GRADIENT_LENGTH 100.0 -#define DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL +#define DEFAULT_BRUSH_SCALE 1.0 +#define DEFAULT_APPLICATION_MODE GIMP_PAINT_CONSTANT +#define DEFAULT_HARD FALSE + +#define DEFAULT_PRESSURE_EXPANDED FALSE +#define DEFAULT_PRESSURE_OPACITY TRUE +#define DEFAULT_PRESSURE_HARDNESS FALSE +#define DEFAULT_PRESSURE_RATE FALSE +#define DEFAULT_PRESSURE_SIZE FALSE +#define DEFAULT_PRESSURE_INVERSE_SIZE FALSE +#define DEFAULT_PRESSURE_COLOR FALSE +#define DEFAULT_PRESSURE_MIN_SCALE 0 + +#define DEFAULT_USE_FADE FALSE +#define DEFAULT_FADE_LENGTH 100.0 +#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL + +#define DEFAULT_USE_JITTER FALSE +#define DEFAULT_JITTER_AMOUNT 0.2 + +#define DEFAULT_USE_GRADIENT FALSE +#define DEFAULT_GRADIENT_REVERSE FALSE +#define DEFAULT_GRADIENT_REPEAT GIMP_REPEAT_TRIANGULAR +#define DEFAULT_GRADIENT_LENGTH 100.0 +#define DEFAULT_GRADIENT_UNIT GIMP_UNIT_PIXEL #define DEFAULT_REDUCE_UPDATE_FREQ FALSE #define DEFAULT_UPDATE_FREQ_S_THRESHOLD 30.0 @@ -66,6 +66,8 @@ #define DEFAULT_UPDATE_FREQ_GAMMA 1.35 #define DEFAULT_UPDATE_FREQ_MAX_N_DABS 18 +#define DEFAULT_MAX_COORD_SMOOTH 0.98 + enum { @@ -104,7 +106,9 @@ PROP_UPDATE_FREQ_S_THRESHOLD, PROP_UPDATE_FREQ_V_THRESHOLD, PROP_UPDATE_FREQ_GAMMA, - PROP_UPDATE_FREQ_MAX_N_DABS + PROP_UPDATE_FREQ_MAX_N_DABS, + + PROP_MAX_COORD_SMOOTH }; @@ -290,6 +294,13 @@ "update-freq-max-n-dabs", NULL, 5, 40, DEFAULT_UPDATE_FREQ_MAX_N_DABS, GIMP_PARAM_STATIC_STRINGS); + + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MAX_COORD_SMOOTH, + "paint-max-coord-smooth", NULL, + 0.0, 1.0, DEFAULT_MAX_COORD_SMOOTH, + GIMP_PARAM_STATIC_STRINGS); + + g_object_class_override_property (object_class, PROP_MAX_COORD_SMOOTH, "max-coord-smooth"); } static void @@ -451,6 +462,10 @@ update_freq_options->max_n_dabs = g_value_get_int (value); break; + case PROP_MAX_COORD_SMOOTH: + GIMP_TOOL_OPTIONS (options)->max_coord_smooth = g_value_get_double (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -585,6 +600,10 @@ break; case PROP_UPDATE_FREQ_MAX_N_DABS: g_value_set_int (value, update_freq_options->max_n_dabs); + break; + + case PROP_MAX_COORD_SMOOTH: + g_value_set_double (value, GIMP_TOOL_OPTIONS (options)->max_coord_smooth); break; default: --- gimp-painter--20080205/app/tools/gimpinktool2.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/tools/gimpinktool2.c Sun May 18 03:48:00 2008 @@ -80,4 +80,7 @@ gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (ink_tool), GIMP_COLOR_PICK_MODE_FOREGROUND); + + /* G-Pen uses the own smoothing routin, so disable the GimpDisplayShell's one */ + tool->max_coord_smooth = 0.0; } --- gimp-painter--20080205/app/tools/gimppaintoptions-gui.c Mon May 19 20:13:03 2008 +++ gimp-painter--20080504/app/tools/gimppaintoptions-gui.c Sun May 18 03:48:01 2008 @@ -46,6 +46,7 @@ #include "gimppenciltool.h" #include "gimpperspectiveclonetool.h" #include "gimpsmudgetool.h" +#include "gimpinktool2.h" #include "gimpmixbrushtool.h" #include "gimptooloptions-gui.h" @@ -140,6 +141,18 @@ } } + /* coords smoothing */ + if (tool_type != GIMP_TYPE_INK2_TOOL && + tool_type != GIMP_TYPE_BLEND_TOOL && + tool_type != GIMP_TYPE_BUCKET_FILL_TOOL) + { + gimp_prop_scale_entry_new (config, "max-coord-smooth", + GTK_TABLE (table), 0, table_row++, + _("Smoothing:"), + 0.01, 0.1, 2, + FALSE, 0.0, 1.0); + } + /* the gradient */ if (tool_type == GIMP_TYPE_BLEND_TOOL) { @@ -501,7 +514,9 @@ GObject *config = G_OBJECT (paint_options); GtkWidget *frame = NULL; - if (!g_type_is_a (tool_type, GIMP_TYPE_PERSPECTIVE_CLONE_TOOL)) + if (tool_type != GIMP_TYPE_PERSPECTIVE_CLONE_TOOL && + tool_type != GIMP_TYPE_BLEND_TOOL && + tool_type != GIMP_TYPE_BUCKET_FILL_TOOL) { GtkWidget *table; --- gimp-painter--20080205/app/tools/gimppainttool.c Tue Nov 20 18:31:00 2007 +++ gimp-painter--20080504/app/tools/gimppainttool.c Sun May 18 03:48:01 2008 @@ -133,6 +133,9 @@ paint_tool->status_line = _("Click to draw the line"); paint_tool->status_ctrl = _("%s to pick a color"); + /* Paint tools benefit most from strong smoothing on coordinates */ + tool->max_coord_smooth = 0.98; + paint_tool->core = NULL; } --- gimp-painter--20080205/app/tools/gimptool.c Tue Nov 20 18:31:00 2007 +++ gimp-painter--20080504/app/tools/gimptool.c Sun May 18 03:48:01 2008 @@ -156,6 +156,7 @@ tool->modifier_state = 0; tool->active_modifier_state = 0; tool->button_press_state = 0; + tool->max_coord_smooth = 0.0; } static void --- gimp-painter--20080205/app/tools/gimptool.h Tue Nov 20 18:31:00 2007 +++ gimp-painter--20080504/app/tools/gimptool.h Sun May 18 03:48:01 2008 @@ -48,6 +48,8 @@ GimpDisplay *display; /* pointer to currently active display */ GimpDrawable *drawable; /* pointer to the tool's current drawable */ + gdouble max_coord_smooth; + /* private state of gimp_tool_set_focus_display() and * gimp_tool_set_[active_]modifier_state() */