[gimp] app: change brush-hardness and brush-force range to [0.0..1.0]



commit 548df1fa32d24976249ad89131d116cff5a050b6
Author: Michael Natterer <mitch gimp org>
Date:   Mon Nov 17 23:17:13 2014 +0100

    app: change brush-hardness and brush-force range to [0.0..1.0]
    
    and set a factor of 100 on the GUI.

 app/paint/gimpbrushcore.c        |    3 +--
 app/paint/gimppaintbrush.c       |    3 ++-
 app/paint/gimppaintoptions.c     |   10 +++++-----
 app/tools/gimppaintoptions-gui.c |   22 ++++++++++++++--------
 4 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index def6239..1063445 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -1523,8 +1523,7 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore     *core,
 
   core->angle        = paint_options->brush_angle;
   core->aspect_ratio = paint_options->brush_aspect_ratio;
-
-  core->hardness     = paint_options->brush_hardness / 100.0;
+  core->hardness     = paint_options->brush_hardness;
 
   if (! GIMP_IS_DYNAMICS (core->dynamics))
     return;
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 43d45ae..4073e28 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -33,6 +33,7 @@
 #include "core/gimpbrush.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdynamics.h"
+#include "core/gimpdynamicsoutput.h"
 #include "core/gimpgradient.h"
 #include "core/gimpimage.h"
 #include "core/gimptempbuf.h"
@@ -209,7 +210,7 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
                                               paint_options,
                                               fade_point);
   force = 0.5;
-  option_force = paint_options->brush_force / 100.0;
+  option_force = paint_options->brush_force;
 
   if (gimp_dynamics_output_is_enabled (dyn_output))
     force = dyn_force;
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 77a085a..a834bf7 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -46,8 +46,8 @@
 #define DEFAULT_BRUSH_ANGLE            0.0
 #define DEFAULT_BRUSH_SPACING          10.0
 
-#define DEFAULT_BRUSH_HARDNESS         100.0 /* Generated brushes have their own */
-#define DEFAULT_BRUSH_FORCE            50.0
+#define DEFAULT_BRUSH_HARDNESS         1.0 /* Generated brushes have their own */
+#define DEFAULT_BRUSH_FORCE            0.5
 
 #define DEFAULT_APPLICATION_MODE       GIMP_PAINT_CONSTANT
 #define DEFAULT_HARD                   FALSE
@@ -189,12 +189,12 @@ gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
 
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_HARDNESS,
                                    "brush-hardness", _("Brush Hardness"),
-                                   0.0, 100.0, DEFAULT_BRUSH_HARDNESS,
+                                   0.0, 1.0, DEFAULT_BRUSH_HARDNESS,
                                    GIMP_PARAM_STATIC_STRINGS);
 
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_FORCE,
                                    "brush-force", _("Brush Force"),
-                                   0.0, 100.0, DEFAULT_BRUSH_FORCE,
+                                   0.0, 1.0, DEFAULT_BRUSH_FORCE,
                                    GIMP_PARAM_STATIC_STRINGS);
 
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_APPLICATION_MODE,
@@ -855,7 +855,7 @@ gimp_paint_options_set_default_brush_hardness (GimpPaintOptions *paint_options,
       GimpBrushGenerated *generated_brush = GIMP_BRUSH_GENERATED (brush);
 
       g_object_set (paint_options,
-                    "brush-hardness", (gdouble) gimp_brush_generated_get_hardness (generated_brush) * 100.0,
+                    "brush-hardness", (gdouble) gimp_brush_generated_get_hardness (generated_brush),
                     NULL);
     }
   else
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index 68aeffc..848c392 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -80,8 +80,10 @@ static GtkWidget * gimp_paint_options_gui_scale_with_reset_button
                                                 gchar     *reset_tooltip,
                                                 gdouble    step_increment,
                                                 gdouble    page_increment,
+                                                gint       digits,
                                                 gdouble    scale_min,
                                                 gdouble    scale_max,
+                                                gdouble    factor,
                                                 gdouble    gamma,
                                                 GCallback  reset_callback);
 
@@ -152,7 +154,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-size", _("Size"),
          _("Reset size to brush's native size"),
-         1.0, 10.0, 1.0, 1000.0, 1.7,
+         1.0, 10.0, 2, 1.0, 1000.0, 1.0, 1.7,
          G_CALLBACK (gimp_paint_options_gui_reset_size));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -160,7 +162,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-aspect-ratio", _("Aspect Ratio"),
          _("Reset aspect ratio to brush's native"),
-         0.1, 1.0, -20.0, 20.0, 1.0,
+         0.1, 1.0, 2, -20.0, 20.0, 1.0, 1.0,
          G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -168,7 +170,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-angle", _("Angle"),
          _("Reset angle to zero"),
-         0.1, 1.0, -180.0, 180.0, 1.0,
+         0.1, 1.0, 2, -180.0, 180.0, 1.0, 1.0,
          G_CALLBACK (gimp_paint_options_gui_reset_angle));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -176,7 +178,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-spacing", _("Spacing"),
          _("Reset spacing to brush's native spacing"),
-         0.1, 1.0, 1.0, 200.0, 1.7,
+         0.1, 1.0, 2, 1.0, 200.0, 1.0, 1.7,
          G_CALLBACK (gimp_paint_options_gui_reset_spacing));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -184,7 +186,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-hardness", _("Hardness"),
          _("Reset hardness to default"),
-         0.1, 1.0, 0.0, 100.0, 1.0,
+         0.001, 0.01, 3, 0.0, 100.0, 100.0, 1.0,
          G_CALLBACK (gimp_paint_options_gui_reset_hardness));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -192,7 +194,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       hbox = gimp_paint_options_gui_scale_with_reset_button
         (config, "brush-force", _("Force"),
          _("Reset force to default"),
-         0.1, 1.0, 0.0, 100.0, 1.0,
+         0.001, 0.01, 2, 0.0, 100.0, 100.0, 1.0,
          G_CALLBACK (gimp_paint_options_gui_reset_force));
       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
       gtk_widget_show (hbox);
@@ -460,7 +462,7 @@ gimp_paint_options_gui_reset_force (GtkWidget        *button,
                                     GimpPaintOptions *paint_options)
 {
   g_object_set (paint_options,
-                "brush-force", 50.0,
+                "brush-force", 0.5,
                 NULL);
 }
 
@@ -471,8 +473,10 @@ gimp_paint_options_gui_scale_with_reset_button (GObject   *config,
                                                 gchar     *reset_tooltip,
                                                 gdouble    step_increment,
                                                 gdouble    page_increment,
+                                                gint       digits,
                                                 gdouble    scale_min,
                                                 gdouble    scale_max,
+                                                gdouble    factor,
                                                 gdouble    gamma,
                                                 GCallback  reset_callback)
 {
@@ -484,7 +488,9 @@ gimp_paint_options_gui_scale_with_reset_button (GObject   *config,
 
   scale = gimp_prop_spin_scale_new (config, prop_name,
                                     prop_descr,
-                                    step_increment, page_increment, 2);
+                                    step_increment, page_increment, digits);
+  gimp_prop_widget_set_factor (scale, factor,
+                               step_increment, page_increment, digits);
   gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
                                     scale_min, scale_max);
   gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), gamma);


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