app: some cleanup in the new brush size code

This commit is contained in:
Michael Natterer 2010-10-30 19:56:24 +02:00
parent 5bc3317b5a
commit ae742f0920
2 changed files with 42 additions and 39 deletions

View File

@ -367,12 +367,15 @@ gimp_brush_core_pre_paint (GimpPaintCore *paint_core,
paint_core->pixel_dist); paint_core->pixel_dist);
scale = paint_options->brush_size / 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, gimp_dynamics_output_get_linear_value (core->dynamics->size_output,
&current_coords, &current_coords,
paint_options, paint_options,
fade_point); 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); g_return_if_fail (core->brush_bound_segs == NULL);
scale = paint_options->brush_size / 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) if (scale > 0.0)
{ {
@ -1696,27 +1700,27 @@ gimp_brush_core_eval_transform_dynamics (GimpPaintCore *paint_core,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core); GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
GimpImage *image;
gdouble fade_point = 1.0; gdouble fade_point = 1.0;
if (core->main_brush) if (core->main_brush)
{
core->scale = paint_options->brush_size / 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 else
core->scale = -1; core->scale = -1;
core->angle = paint_options->brush_angle; core->angle = paint_options->brush_angle;
core->aspect_ratio = paint_options->brush_aspect_ratio; core->aspect_ratio = paint_options->brush_aspect_ratio;
if (!GIMP_IS_DYNAMICS (core->dynamics)) if (! GIMP_IS_DYNAMICS (core->dynamics))
return; return;
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush) if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_dynamic_transforming_brush)
{ {
if (drawable) 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, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
} }
@ -1745,7 +1749,6 @@ gimp_brush_core_eval_transform_dynamics (GimpPaintCore *paint_core,
paint_options, paint_options,
fade_point); fade_point);
} }
} }

View File

@ -120,7 +120,6 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
GtkObject *adj_angle; GtkObject *adj_angle;
GtkObject *adj_aspect_ratio; GtkObject *adj_aspect_ratio;
button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2, button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
"brush-view-type", "brush-view-size"); "brush-view-type", "brush-view-size");
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++, 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, "", 0.0, 0.5,
button, 2, FALSE); button, 2, FALSE);
gtk_widget_show (button); g_signal_connect (button, "clicked",
G_CALLBACK (gimp_paint_options_gui_reset_size),
g_signal_connect(button, "clicked", options);
G_CALLBACK(gimp_paint_options_gui_reset_size), options);
adj_aspect_ratio = gimp_prop_scale_entry_new (config, "brush-aspect-ratio", adj_aspect_ratio = gimp_prop_scale_entry_new (config, "brush-aspect-ratio",
GTK_TABLE (table), 0, table_row++, GTK_TABLE (table), 0, table_row++,
@ -344,11 +342,13 @@ static void
gimp_paint_options_gui_reset_size (GtkWidget *button, gimp_paint_options_gui_reset_size (GtkWidget *button,
GimpPaintOptions *paint_options) GimpPaintOptions *paint_options)
{ {
GimpContext *context = GIMP_CONTEXT(paint_options); GimpBrush *brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
GimpBrush *brush = gimp_context_get_brush (context);
if (brush) if (brush)
{ {
paint_options->brush_size = MAX(brush->mask->width, brush->mask->height); g_object_set (paint_options,
g_object_notify(G_OBJECT(paint_options), "brush-size"); "brush-size", (gdouble) MAX (brush->mask->width,
brush->mask->height),
NULL);
} }
} }