[gimp/gimp-2-10] app: in GimpCurveView, use relative motion when dragging point
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in GimpCurveView, use relative motion when dragging point
- Date: Wed, 17 Apr 2019 22:02:31 +0000 (UTC)
commit 1ecb868821da0f3d3499591df4d159e169a93d6a
Author: Ell <ell_se yahoo com>
Date: Wed Apr 17 17:33:24 2019 -0400
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.
(cherry picked from commit 0b9737a3ed8cac8b49c18c9c6fa7bd8bd3343c8b)
app/widgets/gimpcurveview.c | 40 ++++++++++++++++++++++++++++++++--------
app/widgets/gimpcurveview.h | 2 ++
2 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index e723dd61ff..1a0fa09240 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -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;
@@ -781,6 +783,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;
@@ -812,8 +816,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)
@@ -826,8 +828,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)
@@ -839,7 +839,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:
@@ -865,6 +875,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);
@@ -885,6 +898,7 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
gdouble x;
gdouble y;
gdouble point_x;
+ gdouble point_y;
gint closest_point;
if (! curve)
@@ -899,6 +913,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);
@@ -909,12 +926,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 */
{
diff --git a/app/widgets/gimpcurveview.h b/app/widgets/gimpcurveview.h
index 25a056ca2f..49b43ebba6 100644
--- a/app/widgets/gimpcurveview.h
+++ b/app/widgets/gimpcurveview.h
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]