[gimp] app: in GimpCurveView, snap to curve when holding Ctrl
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in GimpCurveView, snap to curve when holding Ctrl
- Date: Wed, 17 Apr 2019 22:02:47 +0000 (UTC)
commit 8357c9ad645b6ecff6882b39b828440ccfe004e6
Author: Ell <ell_se yahoo com>
Date: Wed Apr 17 17:48:49 2019 -0400
app: in GimpCurveView, snap to curve when holding Ctrl
In GimpCurveView, when holding down Ctrl while adding/dragging a
point, snap the y-coordinate to the original curve (at the start of
the drag). This is particularly useful for adding points along the
curve, without changing their y-coordinate.
Likewise, have the coordinate indicator show the snapped
coordinate.
app/widgets/gimpcurveview.c | 15 +++++++++++++++
app/widgets/gimpcurveview.h | 1 +
2 files changed, 16 insertions(+)
---
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index dae61ef934..ec42ebee21 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -243,6 +243,8 @@ gimp_curve_view_finalize (GObject *object)
{
GimpCurveView *view = GIMP_CURVE_VIEW (object);
+ g_clear_object (&view->orig_curve);
+
g_clear_object (&view->layout);
g_clear_object (&view->cursor_layout);
@@ -811,6 +813,8 @@ gimp_curve_view_button_press (GtkWidget *widget,
view->grabbed = TRUE;
+ view->orig_curve = GIMP_CURVE (gimp_data_duplicate (GIMP_DATA (curve)));
+
set_cursor (view, GDK_TCROSS);
switch (gimp_curve_get_curve_type (curve))
@@ -852,6 +856,9 @@ gimp_curve_view_button_press (GtkWidget *widget,
}
else
{
+ if (bevent->state & gimp_get_constrain_behavior_mask ())
+ y = 1.0 - gimp_curve_map_value (view->orig_curve, x);
+
gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
}
break;
@@ -879,6 +886,8 @@ gimp_curve_view_button_release (GtkWidget *widget,
if (bevent->button != 1)
return TRUE;
+ g_clear_object (&view->orig_curve);
+
view->offset_x = 0.0;
view->offset_y = 0.0;
@@ -942,12 +951,18 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
else
{
new_cursor = GDK_TCROSS;
+
+ if (mevent->state & gimp_get_constrain_behavior_mask ())
+ y = 1.0 - gimp_curve_map_value (view->curve, x);
}
}
else /* Else, drag the grabbed point */
{
new_cursor = GDK_TCROSS;
+ if (mevent->state & gimp_get_constrain_behavior_mask ())
+ y = 1.0 - gimp_curve_map_value (view->orig_curve, x);
+
gimp_data_freeze (GIMP_DATA (curve));
gimp_curve_set_point (curve, view->selected, -1.0, -1.0);
diff --git a/app/widgets/gimpcurveview.h b/app/widgets/gimpcurveview.h
index 49b43ebba6..b41358441e 100644
--- a/app/widgets/gimpcurveview.h
+++ b/app/widgets/gimpcurveview.h
@@ -55,6 +55,7 @@ struct _GimpCurveView
gdouble leftmost;
gdouble rightmost;
gboolean grabbed;
+ GimpCurve *orig_curve;
GdkCursorType cursor_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]