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.
This commit is contained in:
@ -243,6 +243,8 @@ gimp_curve_view_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
GimpCurveView *view = GIMP_CURVE_VIEW (object);
|
GimpCurveView *view = GIMP_CURVE_VIEW (object);
|
||||||
|
|
||||||
|
g_clear_object (&view->orig_curve);
|
||||||
|
|
||||||
g_clear_object (&view->layout);
|
g_clear_object (&view->layout);
|
||||||
g_clear_object (&view->cursor_layout);
|
g_clear_object (&view->cursor_layout);
|
||||||
|
|
||||||
@ -811,6 +813,8 @@ gimp_curve_view_button_press (GtkWidget *widget,
|
|||||||
|
|
||||||
view->grabbed = TRUE;
|
view->grabbed = TRUE;
|
||||||
|
|
||||||
|
view->orig_curve = GIMP_CURVE (gimp_data_duplicate (GIMP_DATA (curve)));
|
||||||
|
|
||||||
set_cursor (view, GDK_TCROSS);
|
set_cursor (view, GDK_TCROSS);
|
||||||
|
|
||||||
switch (gimp_curve_get_curve_type (curve))
|
switch (gimp_curve_get_curve_type (curve))
|
||||||
@ -852,6 +856,9 @@ gimp_curve_view_button_press (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
else
|
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);
|
gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -879,6 +886,8 @@ gimp_curve_view_button_release (GtkWidget *widget,
|
|||||||
if (bevent->button != 1)
|
if (bevent->button != 1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
g_clear_object (&view->orig_curve);
|
||||||
|
|
||||||
view->offset_x = 0.0;
|
view->offset_x = 0.0;
|
||||||
view->offset_y = 0.0;
|
view->offset_y = 0.0;
|
||||||
|
|
||||||
@ -942,12 +951,18 @@ gimp_curve_view_motion_notify (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_cursor = GDK_TCROSS;
|
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 */
|
else /* Else, drag the grabbed point */
|
||||||
{
|
{
|
||||||
new_cursor = GDK_TCROSS;
|
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_data_freeze (GIMP_DATA (curve));
|
||||||
|
|
||||||
gimp_curve_set_point (curve, view->selected, -1.0, -1.0);
|
gimp_curve_set_point (curve, view->selected, -1.0, -1.0);
|
||||||
|
@ -55,6 +55,7 @@ struct _GimpCurveView
|
|||||||
gdouble leftmost;
|
gdouble leftmost;
|
||||||
gdouble rightmost;
|
gdouble rightmost;
|
||||||
gboolean grabbed;
|
gboolean grabbed;
|
||||||
|
GimpCurve *orig_curve;
|
||||||
|
|
||||||
GdkCursorType cursor_type;
|
GdkCursorType cursor_type;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user