Commit 0b9737a3 authored by Ell's avatar Ell

app: in GimpCurveView, use relative motion when dragging point

In GimpCurveView, when dragging an existing curve point, don't
immediately move the point to the cursor position uppon button
press, but rather move it relative to its current position as the
cursor moves.  This allows selecting a point without moving it, and
adjusting its position more easily.

Additionally, when the cursor hovers above a point, or when
dargging a point, have the coordinate indicator show the point's
position, rather than the cursor's.
parent 62f7f277
......@@ -212,6 +212,8 @@ gimp_curve_view_init (GimpCurveView *view)
{
view->curve = NULL;
view->selected = 0;
view->offset_x = 0.0;
view->offset_y = 0.0;
view->last_x = 0.0;
view->last_y = 0.0;
view->cursor_type = -1;
......@@ -785,6 +787,8 @@ gimp_curve_view_button_press (GtkWidget *widget,
gint width, height;
gdouble x;
gdouble y;
gdouble point_x;
gdouble point_y;
gint closest_point;
gint i;
......@@ -816,8 +820,6 @@ gimp_curve_view_button_press (GtkWidget *widget,
view->leftmost = -1.0;
for (i = closest_point - 1; i >= 0; i--)
{
gdouble point_x;
gimp_curve_get_point (curve, i, &point_x, NULL);
if (point_x >= 0.0)
......@@ -830,8 +832,6 @@ gimp_curve_view_button_press (GtkWidget *widget,
view->rightmost = 2.0;
for (i = closest_point + 1; i < curve->n_points; i++)
{
gdouble point_x;
gimp_curve_get_point (curve, i, &point_x, NULL);
if (point_x >= 0.0)
......@@ -843,7 +843,17 @@ gimp_curve_view_button_press (GtkWidget *widget,
gimp_curve_view_set_selected (view, closest_point);
gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
gimp_curve_get_point (curve, view->selected, &point_x, &point_y);
if (point_x >= 0.0)
{
view->offset_x = point_x - x;
view->offset_y = (1.0 - point_y) - y;
}
else
{
gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
}
break;
case GIMP_CURVE_FREE:
......@@ -869,6 +879,9 @@ gimp_curve_view_button_release (GtkWidget *widget,
if (bevent->button != 1)
return TRUE;
view->offset_x = 0.0;
view->offset_y = 0.0;
view->grabbed = FALSE;
set_cursor (view, GDK_FLEUR);
......@@ -889,6 +902,7 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
gdouble x;
gdouble y;
gdouble point_x;
gdouble point_y;
gint closest_point;
if (! curve)
......@@ -903,6 +917,9 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
x = (gdouble) (mevent->x - border) / (gdouble) width;
y = (gdouble) (mevent->y - border) / (gdouble) height;
x += view->offset_x;
y += view->offset_y;
x = CLAMP (x, 0.0, 1.0);
y = CLAMP (y, 0.0, 1.0);
......@@ -913,12 +930,19 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
case GIMP_CURVE_SMOOTH:
if (! view->grabbed) /* If no point is grabbed... */
{
gimp_curve_get_point (curve, closest_point, &point_x, NULL);
gimp_curve_get_point (curve, closest_point, &point_x, &point_y);
if (point_x >= 0.0)
new_cursor = GDK_FLEUR;
{
new_cursor = GDK_FLEUR;
x = point_x;
y = 1.0 - point_y;
}
else
new_cursor = GDK_TCROSS;
{
new_cursor = GDK_TCROSS;
}
}
else /* Else, drag the grabbed point */
{
......
......@@ -48,6 +48,8 @@ struct _GimpCurveView
gint grid_columns;
gint selected;
gdouble offset_x;
gdouble offset_y;
gdouble last_x;
gdouble last_y;
gdouble leftmost;
......
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