mirror of https://github.com/GNOME/gimp.git
don't recalculate the curve if the data object is frozen. Recalculate on
2007-11-05 Michael Natterer <mitch@gimp.org> * app/core/gimpcurve.[ch]: don't recalculate the curve if the data object is frozen. Recalculate on thaw instead. Made gimp_curve_calculate() private and emit some GimpData::dirty signals where appropriate. * app/tools/gimpcurvestool.c * app/widgets/gimpcurveview.c * tools/pdbgen/pdb/color.pdb: changed accodingly (connect to "dirty" instead of "notify" and added some freeze/thaw where approproate). * app/pdb/color_cmds.c: regenerated. svn path=/trunk/; revision=24063
This commit is contained in:
parent
2f77a15f39
commit
21b3675ea8
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2007-11-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpcurve.[ch]: don't recalculate the curve if the data
|
||||
object is frozen. Recalculate on thaw instead. Made
|
||||
gimp_curve_calculate() private and emit some GimpData::dirty
|
||||
signals where appropriate.
|
||||
|
||||
* app/tools/gimpcurvestool.c
|
||||
* app/widgets/gimpcurveview.c
|
||||
* tools/pdbgen/pdb/color.pdb: changed accodingly (connect to "dirty"
|
||||
instead of "notify" and added some freeze/thaw where approproate).
|
||||
|
||||
* app/pdb/color_cmds.c: regenerated.
|
||||
|
||||
2007-11-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpimagemap.c (gimp_image_map_clear): update the
|
||||
|
|
|
@ -76,9 +76,12 @@ static TempBuf * gimp_curve_get_new_preview (GimpViewable *viewable,
|
|||
gint height);
|
||||
static gchar * gimp_curve_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
static void gimp_curve_dirty (GimpData *data);
|
||||
static gchar * gimp_curve_get_extension (GimpData *data);
|
||||
static GimpData * gimp_curve_duplicate (GimpData *data);
|
||||
|
||||
static void gimp_curve_calculate (GimpCurve *curve);
|
||||
static void gimp_curve_plot (GimpCurve *curve,
|
||||
gint p1,
|
||||
gint p2,
|
||||
|
@ -111,6 +114,7 @@ gimp_curve_class_init (GimpCurveClass *klass)
|
|||
viewable_class->get_new_preview = gimp_curve_get_new_preview;
|
||||
viewable_class->get_description = gimp_curve_get_description;
|
||||
|
||||
data_class->dirty = gimp_curve_dirty;
|
||||
data_class->save = gimp_curve_save;
|
||||
data_class->get_extension = gimp_curve_get_extension;
|
||||
data_class->duplicate = gimp_curve_duplicate;
|
||||
|
@ -256,6 +260,13 @@ gimp_curve_get_description (GimpViewable *viewable,
|
|||
return g_strdup_printf ("%s", GIMP_OBJECT (curve)->name);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_curve_dirty (GimpData *data)
|
||||
{
|
||||
gimp_curve_calculate (GIMP_CURVE (data));
|
||||
|
||||
GIMP_DATA_CLASS (parent_class)->dirty (data);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_curve_get_extension (GimpData *data)
|
||||
|
@ -342,6 +353,8 @@ gimp_curve_reset (GimpCurve *curve,
|
|||
g_object_notify (G_OBJECT (curve), "curve-type");
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (curve));
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -371,9 +384,9 @@ gimp_curve_set_curve_type (GimpCurve *curve,
|
|||
curve->points[i * 2][0] = index;
|
||||
curve->points[i * 2][1] = curve->curve[index];
|
||||
}
|
||||
}
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
g_object_notify (G_OBJECT (curve), "points");
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (curve), "curve-type");
|
||||
|
||||
|
@ -437,9 +450,9 @@ gimp_curve_set_point (GimpCurve *curve,
|
|||
|
||||
g_object_notify (G_OBJECT (curve), "points");
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (curve));
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -458,9 +471,9 @@ gimp_curve_move_point (GimpCurve *curve,
|
|||
|
||||
g_object_notify (G_OBJECT (curve), "points");
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (curve));
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -480,6 +493,8 @@ gimp_curve_set_curve (GimpCurve *curve,
|
|||
g_object_notify (G_OBJECT (curve), "curve");
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (curve));
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -495,7 +510,7 @@ gimp_curve_get_uchar (GimpCurve *curve,
|
|||
|
||||
/* private functions */
|
||||
|
||||
void
|
||||
static void
|
||||
gimp_curve_calculate (GimpCurve *curve)
|
||||
{
|
||||
gint i;
|
||||
|
@ -503,6 +518,9 @@ gimp_curve_calculate (GimpCurve *curve)
|
|||
gint num_pts;
|
||||
gint p1, p2, p3, p4;
|
||||
|
||||
if (GIMP_DATA (curve)->freeze_count > 0)
|
||||
return;
|
||||
|
||||
switch (curve->curve_type)
|
||||
{
|
||||
case GIMP_CURVE_SMOOTH:
|
||||
|
|
|
@ -44,7 +44,6 @@ struct _GimpCurve
|
|||
|
||||
gint points[GIMP_CURVE_NUM_POINTS][2];
|
||||
guchar curve[256];
|
||||
|
||||
};
|
||||
|
||||
struct _GimpCurveClass
|
||||
|
@ -82,8 +81,5 @@ void gimp_curve_set_curve (GimpCurve *curve,
|
|||
void gimp_curve_get_uchar (GimpCurve *curve,
|
||||
guchar *dest_array);
|
||||
|
||||
/* FIXME: make private */
|
||||
void gimp_curve_calculate (GimpCurve *curve);
|
||||
|
||||
|
||||
#endif /* __GIMP_CURVE_H__ */
|
||||
|
|
|
@ -412,17 +412,17 @@ curves_spline_invoker (GimpProcedure *procedure,
|
|||
|
||||
curve = GIMP_CURVE (gimp_curve_new ("curves_spline"));
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
/* unset the last point */
|
||||
curve->points[GIMP_CURVE_NUM_POINTS - 1][0] = -1;
|
||||
curve->points[GIMP_CURVE_NUM_POINTS - 1][1] = -1;
|
||||
gimp_curve_set_point (curve, GIMP_CURVE_NUM_POINTS - 1, -1, -1);
|
||||
|
||||
for (j = 0; j < num_points / 2; j++)
|
||||
{
|
||||
curve->points[j][0] = control_pts[j * 2];
|
||||
curve->points[j][1] = control_pts[j * 2 + 1];
|
||||
}
|
||||
gimp_curve_set_point (curve, j,
|
||||
control_pts[j * 2],
|
||||
control_pts[j * 2 + 1]);
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
gimp_curve_get_uchar (curve, c.curve[channel]);
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@ static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map
|
|||
gpointer fp);
|
||||
|
||||
static void curves_curve_callback (GimpCurve *curve,
|
||||
const GParamSpec *pspec,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_channel_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
|
@ -177,7 +176,7 @@ gimp_curves_tool_init (GimpCurvesTool *tool)
|
|||
{
|
||||
tool->curve[i] = GIMP_CURVE (gimp_curve_new ("curves tool"));
|
||||
|
||||
g_signal_connect_object (tool->curve[i], "notify::curve",
|
||||
g_signal_connect_object (tool->curve[i], "dirty",
|
||||
G_CALLBACK (curves_curve_callback),
|
||||
tool, 0);
|
||||
}
|
||||
|
@ -652,15 +651,14 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
|
|||
{
|
||||
GimpCurve *curve = tool->curve[i];
|
||||
|
||||
curve->curve_type = GIMP_CURVE_SMOOTH;
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
gimp_curve_set_curve_type (curve, GIMP_CURVE_SMOOTH);
|
||||
|
||||
for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
|
||||
{
|
||||
curve->points[j][0] = index[i][j];
|
||||
curve->points[j][1] = value[i][j];
|
||||
}
|
||||
gimp_curve_set_point (curve, j, index[i][j], value[i][j]);
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
|
||||
|
@ -710,9 +708,8 @@ gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
|
|||
}
|
||||
|
||||
static void
|
||||
curves_curve_callback (GimpCurve *curve,
|
||||
const GParamSpec *pspec,
|
||||
GimpCurvesTool *tool)
|
||||
curves_curve_callback (GimpCurve *curve,
|
||||
GimpCurvesTool *tool)
|
||||
{
|
||||
if (curve != tool->curve[tool->channel])
|
||||
return;
|
||||
|
@ -779,7 +776,7 @@ curves_channel_callback (GtkWidget *widget,
|
|||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
|
||||
tool->curve[tool->channel]->curve_type);
|
||||
|
||||
curves_curve_callback (tool->curve[tool->channel], NULL, tool);
|
||||
curves_curve_callback (tool->curve[tool->channel], tool);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -428,6 +428,8 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
|||
{
|
||||
new_cursor = GDK_TCROSS;
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
gimp_curve_set_point (curve, view->selected, -1, -1);
|
||||
|
||||
if (x > view->leftmost && x < view->rightmost)
|
||||
|
@ -438,6 +440,8 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
|||
|
||||
gimp_curve_set_point (curve, view->selected, x, 255 - y);
|
||||
}
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -463,9 +467,13 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
|||
|
||||
if (x2 != x1)
|
||||
{
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
for (i = x1; i <= x2; i++)
|
||||
gimp_curve_set_curve (curve, i,
|
||||
255 - (y1 + ((y2 - y1) * (i - x1)) / (x2 - x1)));
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -587,16 +595,10 @@ gimp_curve_view_new (void)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_curve_view_curve_notify (GimpCurve *curve,
|
||||
const GParamSpec *pspec,
|
||||
GimpCurveView *view)
|
||||
gimp_curve_view_curve_dirty (GimpCurve *curve,
|
||||
GimpCurveView *view)
|
||||
{
|
||||
if (! strcmp (pspec->name, "curve-type") ||
|
||||
! strcmp (pspec->name, "points") ||
|
||||
! strcmp (pspec->name, "curve"))
|
||||
{
|
||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||
}
|
||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -612,7 +614,7 @@ gimp_curve_view_set_curve (GimpCurveView *view,
|
|||
if (view->curve)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (view->curve,
|
||||
gimp_curve_view_curve_notify,
|
||||
gimp_curve_view_curve_dirty,
|
||||
view);
|
||||
g_object_unref (view->curve);
|
||||
}
|
||||
|
@ -622,8 +624,8 @@ gimp_curve_view_set_curve (GimpCurveView *view,
|
|||
if (view->curve)
|
||||
{
|
||||
g_object_ref (view->curve);
|
||||
g_signal_connect (view->curve, "notify",
|
||||
G_CALLBACK (gimp_curve_view_curve_notify),
|
||||
g_signal_connect (view->curve, "dirty",
|
||||
G_CALLBACK (gimp_curve_view_curve_dirty),
|
||||
view);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,17 +457,17 @@ HELP
|
|||
|
||||
curve = GIMP_CURVE (gimp_curve_new ("curves_spline"));
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (curve));
|
||||
|
||||
/* unset the last point */
|
||||
curve->points[GIMP_CURVE_NUM_POINTS - 1][0] = -1;
|
||||
curve->points[GIMP_CURVE_NUM_POINTS - 1][1] = -1;
|
||||
gimp_curve_set_point (curve, GIMP_CURVE_NUM_POINTS - 1, -1, -1);
|
||||
|
||||
for (j = 0; j < num_points / 2; j++)
|
||||
{
|
||||
curve->points[j][0] = control_pts[j * 2];
|
||||
curve->points[j][1] = control_pts[j * 2 + 1];
|
||||
}
|
||||
gimp_curve_set_point (curve, j,
|
||||
control_pts[j * 2],
|
||||
control_pts[j * 2 + 1]);
|
||||
|
||||
gimp_curve_calculate (curve);
|
||||
gimp_data_thaw (GIMP_DATA (curve));
|
||||
|
||||
gimp_curve_get_uchar (curve, c.curve[channel]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue