Commit c3ef34b4 authored by Jehan's avatar Jehan
Browse files

Revert "app: "distance-metric" is now a property of GimpContext."

This reverts commit 2c799d4a.
Ok. I misunderstood Mitch. This belongs in GimpPDBContext.
parent 2c799d4a
......@@ -565,30 +565,29 @@ typedef enum /*< pdb-skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_CONTEXT_PROP_FIRST = 2,
GIMP_CONTEXT_PROP_IMAGE = GIMP_CONTEXT_PROP_FIRST,
GIMP_CONTEXT_PROP_DISPLAY = 3,
GIMP_CONTEXT_PROP_TOOL = 4,
GIMP_CONTEXT_PROP_PAINT_INFO = 5,
GIMP_CONTEXT_PROP_FOREGROUND = 6,
GIMP_CONTEXT_PROP_BACKGROUND = 7,
GIMP_CONTEXT_PROP_OPACITY = 8,
GIMP_CONTEXT_PROP_PAINT_MODE = 9,
GIMP_CONTEXT_PROP_BRUSH = 10,
GIMP_CONTEXT_PROP_DYNAMICS = 11,
GIMP_CONTEXT_PROP_MYBRUSH = 12,
GIMP_CONTEXT_PROP_PATTERN = 13,
GIMP_CONTEXT_PROP_GRADIENT = 14,
GIMP_CONTEXT_PROP_PALETTE = 15,
GIMP_CONTEXT_PROP_TOOL_PRESET = 16,
GIMP_CONTEXT_PROP_FONT = 17,
GIMP_CONTEXT_PROP_BUFFER = 18,
GIMP_CONTEXT_PROP_IMAGEFILE = 19,
GIMP_CONTEXT_PROP_TEMPLATE = 20,
GIMP_CONTEXT_PROP_DISTANCE_METRIC = 21,
GIMP_CONTEXT_PROP_LAST = GIMP_CONTEXT_PROP_DISTANCE_METRIC
GIMP_CONTEXT_PROP_FIRST = 2,
GIMP_CONTEXT_PROP_IMAGE = GIMP_CONTEXT_PROP_FIRST,
GIMP_CONTEXT_PROP_DISPLAY = 3,
GIMP_CONTEXT_PROP_TOOL = 4,
GIMP_CONTEXT_PROP_PAINT_INFO = 5,
GIMP_CONTEXT_PROP_FOREGROUND = 6,
GIMP_CONTEXT_PROP_BACKGROUND = 7,
GIMP_CONTEXT_PROP_OPACITY = 8,
GIMP_CONTEXT_PROP_PAINT_MODE = 9,
GIMP_CONTEXT_PROP_BRUSH = 10,
GIMP_CONTEXT_PROP_DYNAMICS = 11,
GIMP_CONTEXT_PROP_MYBRUSH = 12,
GIMP_CONTEXT_PROP_PATTERN = 13,
GIMP_CONTEXT_PROP_GRADIENT = 14,
GIMP_CONTEXT_PROP_PALETTE = 15,
GIMP_CONTEXT_PROP_TOOL_PRESET = 16,
GIMP_CONTEXT_PROP_FONT = 17,
GIMP_CONTEXT_PROP_BUFFER = 18,
GIMP_CONTEXT_PROP_IMAGEFILE = 19,
GIMP_CONTEXT_PROP_TEMPLATE = 20,
GIMP_CONTEXT_PROP_LAST = GIMP_CONTEXT_PROP_TEMPLATE
} GimpContextPropType;
......
......@@ -277,10 +277,6 @@ static void gimp_context_template_list_thaw (GimpContainer *container,
static void gimp_context_real_set_template (GimpContext *context,
GimpTemplate *template);
/* distance metric */
static void gimp_context_distance_metric_changed (GimpContext *context);
static void gimp_context_real_set_distance_metric (GimpContext *context,
GeglDistanceMetric metric);
/* utilities */
static gpointer gimp_context_find_object (GimpContext *context,
......@@ -322,7 +318,6 @@ enum
BUFFER_CHANGED,
IMAGEFILE_CHANGED,
TEMPLATE_CHANGED,
DISTANCE_METRIC_CHANGED,
PROP_NAME_CHANGED,
LAST_SIGNAL
};
......@@ -349,8 +344,7 @@ static const gchar * const gimp_context_prop_names[] =
"font",
"buffer",
"imagefile",
"template",
"distance-metric"
"template"
};
static GType gimp_context_prop_types[] =
......@@ -375,7 +369,6 @@ static GType gimp_context_prop_types[] =
0,
0,
0,
0,
0
};
......@@ -590,16 +583,6 @@ gimp_context_class_init (GimpContextClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_TEMPLATE);
gimp_context_signals[DISTANCE_METRIC_CHANGED] =
g_signal_new ("distance-metric-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpContextClass, distance_metric_changed),
NULL, NULL,
gimp_marshal_VOID__DOUBLE,
G_TYPE_NONE, 1,
GEGL_TYPE_DISTANCE_METRIC);
gimp_context_signals[PROP_NAME_CHANGED] =
g_signal_new ("prop-name-changed",
G_TYPE_FROM_CLASS (klass),
......@@ -639,21 +622,20 @@ gimp_context_class_init (GimpContextClass *klass)
klass->template_changed = NULL;
klass->prop_name_changed = NULL;
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE] = GIMP_TYPE_IMAGE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PAINT_INFO] = GIMP_TYPE_PAINT_INFO;
gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH] = GIMP_TYPE_BRUSH;
gimp_context_prop_types[GIMP_CONTEXT_PROP_DYNAMICS] = GIMP_TYPE_DYNAMICS;
gimp_context_prop_types[GIMP_CONTEXT_PROP_MYBRUSH] = GIMP_TYPE_MYBRUSH;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN] = GIMP_TYPE_PATTERN;
gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT] = GIMP_TYPE_GRADIENT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE] = GIMP_TYPE_PALETTE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL_PRESET] = GIMP_TYPE_TOOL_PRESET;
gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT] = GIMP_TYPE_FONT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER;
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE] = GIMP_TYPE_TEMPLATE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_DISTANCE_METRIC] = GEGL_TYPE_DISTANCE_METRIC;
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE] = GIMP_TYPE_IMAGE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL] = GIMP_TYPE_TOOL_INFO;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PAINT_INFO] = GIMP_TYPE_PAINT_INFO;
gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH] = GIMP_TYPE_BRUSH;
gimp_context_prop_types[GIMP_CONTEXT_PROP_DYNAMICS] = GIMP_TYPE_DYNAMICS;
gimp_context_prop_types[GIMP_CONTEXT_PROP_MYBRUSH] = GIMP_TYPE_MYBRUSH;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN] = GIMP_TYPE_PATTERN;
gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT] = GIMP_TYPE_GRADIENT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE] = GIMP_TYPE_PALETTE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL_PRESET] = GIMP_TYPE_TOOL_PRESET;
gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT] = GIMP_TYPE_FONT;
gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER;
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE;
gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE] = GIMP_TYPE_TEMPLATE;
g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_GIMP,
g_param_spec_object ("gimp",
......@@ -790,13 +772,6 @@ gimp_context_class_init (GimpContextClass *klass)
NULL, NULL,
GIMP_TYPE_TEMPLATE,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_DISTANCE_METRIC,
g_param_spec_enum (gimp_context_prop_names[GIMP_CONTEXT_PROP_DISTANCE_METRIC],
NULL, NULL,
GEGL_TYPE_DISTANCE_METRIC,
GEGL_DISTANCE_METRIC_EUCLIDEAN,
GIMP_PARAM_READWRITE));
}
static void
......@@ -1106,9 +1081,6 @@ gimp_context_set_property (GObject *object,
case GIMP_CONTEXT_PROP_TEMPLATE:
gimp_context_set_template (context, g_value_get_object (value));
break;
case GIMP_CONTEXT_PROP_DISTANCE_METRIC:
gimp_context_set_distance_metric (context, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -1195,9 +1167,6 @@ gimp_context_get_property (GObject *object,
case GIMP_CONTEXT_PROP_TEMPLATE:
g_value_set_object (value, gimp_context_get_template (context));
break;
case GIMP_CONTEXT_PROP_DISTANCE_METRIC:
g_value_set_enum (value, gimp_context_get_distance_metric (context));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -1738,10 +1707,6 @@ gimp_context_copy_property (GimpContext *src,
gimp_context_real_set_template (dest, src->template);
break;
case GIMP_CONTEXT_PROP_DISTANCE_METRIC:
gimp_context_real_set_distance_metric (dest, src->distance_metric);
break;
default:
break;
}
......@@ -3922,49 +3887,6 @@ gimp_context_real_set_template (GimpContext *context,
gimp_context_template_changed (context);
}
/*****************************************************************************/
/* distance metric **********************************************************/
GeglDistanceMetric
gimp_context_get_distance_metric (GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_CONTEXT (context), GEGL_DISTANCE_METRIC_EUCLIDEAN);
return context->distance_metric;
}
void
gimp_context_set_distance_metric (GimpContext *context,
GeglDistanceMetric metric)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
context_find_defined (context, GIMP_CONTEXT_PROP_DISTANCE_METRIC);
gimp_context_real_set_distance_metric (context, metric);
}
static void
gimp_context_distance_metric_changed (GimpContext *context)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_signal_emit (context,
gimp_context_signals[DISTANCE_METRIC_CHANGED], 0,
context->distance_metric);
}
static void
gimp_context_real_set_distance_metric (GimpContext *context,
GeglDistanceMetric metric)
{
if (context->distance_metric == metric)
return;
context->distance_metric = metric;
g_object_notify (G_OBJECT (context), "distance-metric");
gimp_context_distance_metric_changed (context);
}
/*****************************************************************************/
/* utility functions *******************************************************/
......
......@@ -102,56 +102,52 @@ struct _GimpContext
GimpTemplate *template;
gchar *template_name;
GeglDistanceMetric distance_metric;
};
struct _GimpContextClass
{
GimpViewableClass parent_class;
void (* image_changed) (GimpContext *context,
GimpImage *image);
void (* display_changed) (GimpContext *context,
gpointer display);
void (* tool_changed) (GimpContext *context,
GimpToolInfo *tool_info);
void (* paint_info_changed) (GimpContext *context,
GimpPaintInfo *paint_info);
void (* foreground_changed) (GimpContext *context,
GimpRGB *color);
void (* background_changed) (GimpContext *context,
GimpRGB *color);
void (* opacity_changed) (GimpContext *context,
gdouble opacity);
void (* paint_mode_changed) (GimpContext *context,
GimpLayerMode paint_mode);
void (* brush_changed) (GimpContext *context,
GimpBrush *brush);
void (* dynamics_changed) (GimpContext *context,
GimpDynamics *dynamics);
void (* mybrush_changed) (GimpContext *context,
GimpMybrush *brush);
void (* pattern_changed) (GimpContext *context,
GimpPattern *pattern);
void (* gradient_changed) (GimpContext *context,
GimpGradient *gradient);
void (* palette_changed) (GimpContext *context,
GimpPalette *palette);
void (* tool_preset_changed) (GimpContext *context,
GimpToolPreset *tool_preset);
void (* font_changed) (GimpContext *context,
GimpFont *font);
void (* buffer_changed) (GimpContext *context,
GimpBuffer *buffer);
void (* imagefile_changed) (GimpContext *context,
GimpImagefile *imagefile);
void (* template_changed) (GimpContext *context,
GimpTemplate *template);
void (* distance_metric_changed) (GimpContext *context,
GeglDistanceMetric metric);
void (* image_changed) (GimpContext *context,
GimpImage *image);
void (* display_changed) (GimpContext *context,
gpointer display);
void (* tool_changed) (GimpContext *context,
GimpToolInfo *tool_info);
void (* paint_info_changed) (GimpContext *context,
GimpPaintInfo *paint_info);
void (* foreground_changed) (GimpContext *context,
GimpRGB *color);
void (* background_changed) (GimpContext *context,
GimpRGB *color);
void (* opacity_changed) (GimpContext *context,
gdouble opacity);
void (* paint_mode_changed) (GimpContext *context,
GimpLayerMode paint_mode);
void (* brush_changed) (GimpContext *context,
GimpBrush *brush);
void (* dynamics_changed) (GimpContext *context,
GimpDynamics *dynamics);
void (* mybrush_changed) (GimpContext *context,
GimpMybrush *brush);
void (* pattern_changed) (GimpContext *context,
GimpPattern *pattern);
void (* gradient_changed) (GimpContext *context,
GimpGradient *gradient);
void (* palette_changed) (GimpContext *context,
GimpPalette *palette);
void (* tool_preset_changed)(GimpContext *context,
GimpToolPreset *tool_preset);
void (* font_changed) (GimpContext *context,
GimpFont *font);
void (* buffer_changed) (GimpContext *context,
GimpBuffer *buffer);
void (* imagefile_changed) (GimpContext *context,
GimpImagefile *imagefile);
void (* template_changed) (GimpContext *context,
GimpTemplate *template);
void (* prop_name_changed) (GimpContext *context,
GimpContextPropType prop);
......@@ -360,10 +356,5 @@ void gimp_context_set_template (GimpContext *context,
GimpTemplate *template);
void gimp_context_template_changed (GimpContext *context);
/* distance metric */
GeglDistanceMetric
gimp_context_get_distance_metric (GimpContext *context);
void gimp_context_set_distance_metric (GimpContext *context,
GeglDistanceMetric metric);
#endif /* __GIMP_CONTEXT_H__ */
......@@ -44,6 +44,7 @@ enum
PROP_0,
PROP_OFFSET,
PROP_GRADIENT_TYPE,
PROP_DISTANCE_METRIC,
PROP_GRADIENT_REPEAT, /* overrides a GimpPaintOptions property */
PROP_SUPERSAMPLE,
PROP_SUPERSAMPLE_DEPTH,
......@@ -95,6 +96,13 @@ gimp_blend_options_class_init (GimpBlendOptionsClass *klass)
GIMP_TYPE_GRADIENT_TYPE,
GIMP_GRADIENT_LINEAR,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_DISTANCE_METRIC,
"distance-metric",
_("Metric"),
_("Metric to use for the distance calculation"),
GEGL_TYPE_DISTANCE_METRIC,
GEGL_DISTANCE_METRIC_EUCLIDEAN,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_GRADIENT_REPEAT,
"gradient-repeat",
_("Repeat"),
......@@ -165,6 +173,9 @@ gimp_blend_options_set_property (GObject *object,
case PROP_GRADIENT_TYPE:
options->gradient_type = g_value_get_enum (value);
break;
case PROP_DISTANCE_METRIC:
options->distance_metric = g_value_get_enum (value);
break;
case PROP_GRADIENT_REPEAT:
GIMP_PAINT_OPTIONS (options)->gradient_options->gradient_repeat =
g_value_get_enum (value);
......@@ -213,6 +224,9 @@ gimp_blend_options_get_property (GObject *object,
case PROP_GRADIENT_TYPE:
g_value_set_enum (value, options->gradient_type);
break;
case PROP_DISTANCE_METRIC:
g_value_set_enum (value, options->distance_metric);
break;
case PROP_GRADIENT_REPEAT:
g_value_set_enum (value,
GIMP_PAINT_OPTIONS (options)->gradient_options->gradient_repeat);
......@@ -285,8 +299,7 @@ gimp_blend_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (combo);
/* the distance metric menu */
combo = gimp_prop_enum_combo_box_new (G_OBJECT (context),
"distance-metric", 0, 0);
combo = gimp_prop_enum_combo_box_new (config, "distance-metric", 0, 0);
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Metric"));
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
......
......@@ -39,6 +39,7 @@ struct _GimpBlendOptions
gdouble offset;
GimpGradientType gradient_type;
GeglDistanceMetric distance_metric;
gboolean supersample;
gint supersample_depth;
......
......@@ -792,7 +792,6 @@ static void
gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_tool)
{
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
GimpContext *context = GIMP_CONTEXT (options);
GimpTool *tool = GIMP_TOOL (blend_tool);
gint x, y, width, height;
......@@ -804,7 +803,7 @@ gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_tool)
return;
blend_tool->dist_buffer =
gimp_drawable_blend_shapeburst_distmap (tool->drawable, context->distance_metric,
gimp_drawable_blend_shapeburst_distmap (tool->drawable, options->distance_metric,
GEGL_RECTANGLE (x, y, width, height),
GIMP_PROGRESS (blend_tool));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment