[gimp] app: some cleanup in the new brush size code



commit ae742f09200cb04d99e5d7a482dd941fb67233f2
Author: Michael Natterer <mitch gimp org>
Date:   Sat Oct 30 19:56:24 2010 +0200

    app: some cleanup in the new brush size code

 app/paint/gimpbrushcore.c        |   59 ++++++++++++++++++++------------------
 app/tools/gimppaintoptions-gui.c |   22 +++++++-------
 2 files changed, 42 insertions(+), 39 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 0463d0f..71f5f13 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -367,12 +367,15 @@ gimp_brush_core_pre_paint (GimpPaintCore    *paint_core,
                                                         paint_core->pixel_dist);
 
               scale = paint_options->brush_size /
-                      MAX (core->main_brush->mask->width, core->main_brush->mask->height) *
+                      MAX (core->main_brush->mask->width,
+                           core->main_brush->mask->height) *
                       gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
                                                              &current_coords,
                                                              paint_options,
                                                              fade_point);
-              if (scale < 0.0001) return FALSE;
+
+              if (scale < 0.0001)
+                return FALSE;
             }
         }
 
@@ -948,7 +951,8 @@ gimp_brush_core_create_boundary (GimpBrushCore    *core,
   g_return_if_fail (core->brush_bound_segs == NULL);
 
   scale = paint_options->brush_size /
-          MAX (core->main_brush->mask->width, core->main_brush->mask->height);
+          MAX (core->main_brush->mask->width,
+               core->main_brush->mask->height);
 
   if (scale > 0.0)
     {
@@ -1696,56 +1700,55 @@ gimp_brush_core_eval_transform_dynamics (GimpPaintCore     *paint_core,
                                          const GimpCoords  *coords)
 {
   GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
-  GimpImage *image;
   gdouble    fade_point = 1.0;
 
   if (core->main_brush)
-   {
     core->scale = paint_options->brush_size /
-                  MAX (core->main_brush->mask->width, core->main_brush->mask->height);
-   }
+                  MAX (core->main_brush->mask->width,
+                       core->main_brush->mask->height);
   else
-   core->scale = -1;
-  core->angle = paint_options->brush_angle;
+    core->scale = -1;
+
+  core->angle        = paint_options->brush_angle;
   core->aspect_ratio = paint_options->brush_aspect_ratio;
 
-  if (!GIMP_IS_DYNAMICS (core->dynamics))
+  if (! GIMP_IS_DYNAMICS (core->dynamics))
     return;
 
   if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
     {
       if (drawable)
         {
-          image = gimp_item_get_image (GIMP_ITEM (drawable));
+          GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+
           fade_point = gimp_paint_options_get_fade (paint_options, image,
                                                     paint_core->pixel_dist);
         }
 
       core->scale *=
-            gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
-                                                   coords,
-                                                   paint_options,
-                                                   fade_point);
+        gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
+                                               coords,
+                                               paint_options,
+                                               fade_point);
 
       core->angle +=
-            gimp_dynamics_output_get_angular_value (core->dynamics->angle_output,
-                                                    coords,
-                                                    paint_options,
-                                                    fade_point);
+        gimp_dynamics_output_get_angular_value (core->dynamics->angle_output,
+                                                coords,
+                                                paint_options,
+                                                fade_point);
 
       core->hardness =
-            gimp_dynamics_output_get_linear_value (core->dynamics->hardness_output,
-                                                   coords,
-                                                   paint_options,
-                                                   fade_point);
+        gimp_dynamics_output_get_linear_value (core->dynamics->hardness_output,
+                                               coords,
+                                               paint_options,
+                                               fade_point);
 
       core->aspect_ratio *=
-            gimp_dynamics_output_get_aspect_value (core->dynamics->aspect_ratio_output,
-                                                   coords,
-                                                   paint_options,
-                                                   fade_point);
+        gimp_dynamics_output_get_aspect_value (core->dynamics->aspect_ratio_output,
+                                               coords,
+                                               paint_options,
+                                               fade_point);
     }
-
 }
 
 
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index 9ccf71f..2a5139c 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -120,7 +120,6 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
       GtkObject *adj_angle;
       GtkObject *adj_aspect_ratio;
 
-
       button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
                                         "brush-view-type", "brush-view-size");
       gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
@@ -147,10 +146,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
                                  "", 0.0, 0.5,
                                  button, 2, FALSE);
 
-      gtk_widget_show (button);
-
-      g_signal_connect(button, "clicked",
-                       G_CALLBACK(gimp_paint_options_gui_reset_size), options);
+      g_signal_connect (button, "clicked",
+                        G_CALLBACK (gimp_paint_options_gui_reset_size),
+                        options);
 
       adj_aspect_ratio = gimp_prop_scale_entry_new (config, "brush-aspect-ratio",
                                                     GTK_TABLE (table), 0, table_row++,
@@ -344,11 +342,13 @@ static void
 gimp_paint_options_gui_reset_size (GtkWidget        *button,
                                    GimpPaintOptions *paint_options)
 {
- GimpContext *context = GIMP_CONTEXT(paint_options);
- GimpBrush *brush = gimp_context_get_brush (context);
+ GimpBrush *brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
+
  if (brush)
-  {
-    paint_options->brush_size = MAX(brush->mask->width, brush->mask->height);
-    g_object_notify(G_OBJECT(paint_options), "brush-size");
-  }
+   {
+     g_object_set (paint_options,
+                   "brush-size", (gdouble) MAX (brush->mask->width,
+                                                brush->mask->height),
+                   NULL);
+   }
 }



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