add gimp_curve_get_point().
2008-02-11 Michael Natterer <mitch@gimp.org> * app/core/gimpcurve.[ch]: add gimp_curve_get_point(). * app/gegl/gimpcurvesconfig.c * app/widgets/gimpcurveview.c: use it instead of accessing the points array directly. svn path=/trunk/; revision=24857
This commit is contained in:

committed by
Michael Natterer

parent
dc9ad3ee3d
commit
168566ad3e
@ -1,3 +1,11 @@
|
||||
2008-02-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpcurve.[ch]: add gimp_curve_get_point().
|
||||
|
||||
* app/gegl/gimpcurvesconfig.c
|
||||
* app/widgets/gimpcurveview.c: use it instead of accessing the
|
||||
points array directly.
|
||||
|
||||
2008-02-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpthumb/Makefile.am (libgimpthumb_2_0_la_LIBADD):
|
||||
|
@ -475,6 +475,21 @@ gimp_curve_move_point (GimpCurve *curve,
|
||||
gimp_data_dirty (GIMP_DATA (curve));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_curve_get_point (GimpCurve *curve,
|
||||
gint point,
|
||||
gdouble *x,
|
||||
gdouble *y)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CURVE (curve));
|
||||
|
||||
if (curve->curve_type == GIMP_CURVE_FREE)
|
||||
return;
|
||||
|
||||
if (x) *x = curve->points[point].x;
|
||||
if (y) *y = curve->points[point].y;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_curve_set_curve (GimpCurve *curve,
|
||||
gdouble x,
|
||||
|
@ -67,6 +67,7 @@ GimpCurveType gimp_curve_get_curve_type (GimpCurve *curve);
|
||||
|
||||
gint gimp_curve_get_closest_point (GimpCurve *curve,
|
||||
gdouble x);
|
||||
|
||||
void gimp_curve_set_point (GimpCurve *curve,
|
||||
gint point,
|
||||
gdouble x,
|
||||
@ -74,6 +75,10 @@ void gimp_curve_set_point (GimpCurve *curve,
|
||||
void gimp_curve_move_point (GimpCurve *curve,
|
||||
gint point,
|
||||
gdouble y);
|
||||
void gimp_curve_get_point (GimpCurve *curve,
|
||||
gint point,
|
||||
gdouble *x,
|
||||
gdouble *y);
|
||||
|
||||
void gimp_curve_set_curve (GimpCurve *curve,
|
||||
gdouble x,
|
||||
|
@ -417,9 +417,15 @@ gimp_curves_config_save_cruft (GimpCurvesConfig *config,
|
||||
}
|
||||
|
||||
for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
|
||||
fprintf (file, "%d %d ",
|
||||
(gint) (curve->points[j].x * 255.999),
|
||||
(gint) (curve->points[j].y * 255.999));
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
gimp_curve_get_point (curve, j, &x, &y);
|
||||
|
||||
fprintf (file, "%d %d ",
|
||||
(gint) (x * 255.999),
|
||||
(gint) (y * 255.999));
|
||||
}
|
||||
|
||||
fprintf (file, "\n");
|
||||
}
|
||||
|
@ -315,12 +315,13 @@ gimp_curve_view_draw_point (GimpCurveView *view,
|
||||
{
|
||||
gdouble x, y;
|
||||
|
||||
x = view->curve->points[i].x;
|
||||
y = 1.0 - view->curve->points[i].y;
|
||||
gimp_curve_get_point (view->curve, i, &x, &y);
|
||||
|
||||
if (x < 0.0)
|
||||
return;
|
||||
|
||||
y = 1.0 - y;
|
||||
|
||||
#define RADIUS 3
|
||||
|
||||
cairo_move_to (cr,
|
||||
@ -553,19 +554,31 @@ gimp_curve_view_button_press (GtkWidget *widget,
|
||||
/* determine the leftmost and rightmost points */
|
||||
view->leftmost = -1.0;
|
||||
for (i = closest_point - 1; i >= 0; i--)
|
||||
if (curve->points[i].x >= 0.0)
|
||||
{
|
||||
view->leftmost = curve->points[i].x;
|
||||
break;
|
||||
}
|
||||
{
|
||||
gdouble point_x;
|
||||
|
||||
gimp_curve_get_point (curve, i, &point_x, NULL);
|
||||
|
||||
if (point_x >= 0.0)
|
||||
{
|
||||
view->leftmost = point_x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
view->rightmost = 2.0;
|
||||
for (i = closest_point + 1; i < GIMP_CURVE_NUM_POINTS; i++)
|
||||
if (curve->points[i].x >= 0.0)
|
||||
{
|
||||
view->rightmost = curve->points[i].x;
|
||||
break;
|
||||
}
|
||||
{
|
||||
gdouble point_x;
|
||||
|
||||
gimp_curve_get_point (curve, i, &point_x, NULL);
|
||||
|
||||
if (point_x >= 0.0)
|
||||
{
|
||||
view->rightmost = point_x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_curve_view_set_selected (view, closest_point);
|
||||
|
||||
@ -632,10 +645,14 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
||||
|
||||
switch (gimp_curve_get_curve_type (curve))
|
||||
{
|
||||
gdouble point_x;
|
||||
|
||||
case GIMP_CURVE_SMOOTH:
|
||||
if (! view->grabbed) /* If no point is grabbed... */
|
||||
{
|
||||
if (curve->points[closest_point].x >= 0.0)
|
||||
gimp_curve_get_point (curve, closest_point, &x, NULL);
|
||||
|
||||
if (point_x >= 0.0)
|
||||
new_cursor = GDK_FLEUR;
|
||||
else
|
||||
new_cursor = GDK_TCROSS;
|
||||
@ -651,7 +668,10 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
||||
if (x > view->leftmost && x < view->rightmost)
|
||||
{
|
||||
closest_point = ((gint) (x * 255.999) + 8) / 16;
|
||||
if (curve->points[closest_point].x < 0.0)
|
||||
|
||||
gimp_curve_get_point (curve, closest_point, &point_x, NULL);
|
||||
|
||||
if (point_x < 0.0)
|
||||
gimp_curve_view_set_selected (view, closest_point);
|
||||
|
||||
gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
|
||||
@ -737,19 +757,23 @@ gimp_curve_view_key_press (GtkWidget *widget,
|
||||
GimpCurveView *view = GIMP_CURVE_VIEW (widget);
|
||||
GimpCurve *curve = view->curve;
|
||||
gint i = view->selected;
|
||||
gdouble y = curve->points[i].y;
|
||||
gdouble x, y;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (view->grabbed || ! curve ||
|
||||
gimp_curve_get_curve_type (curve) == GIMP_CURVE_FREE)
|
||||
return FALSE;
|
||||
|
||||
gimp_curve_get_point (curve, i, NULL, &y);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Left:
|
||||
for (i = i - 1; i >= 0 && ! retval; i--)
|
||||
{
|
||||
if (curve->points[i].x >= 0.0)
|
||||
gimp_curve_get_point (curve, i, &x, NULL);
|
||||
|
||||
if (x >= 0.0)
|
||||
{
|
||||
gimp_curve_view_set_selected (view, i);
|
||||
|
||||
@ -761,7 +785,9 @@ gimp_curve_view_key_press (GtkWidget *widget,
|
||||
case GDK_Right:
|
||||
for (i = i + 1; i < GIMP_CURVE_NUM_POINTS && ! retval; i++)
|
||||
{
|
||||
if (curve->points[i].x >= 0.0)
|
||||
gimp_curve_get_point (curve, i, &x, NULL);
|
||||
|
||||
if (x >= 0.0)
|
||||
{
|
||||
gimp_curve_view_set_selected (view, i);
|
||||
|
||||
|
Reference in New Issue
Block a user