summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2007-11-06 13:33:39 +0000
committerCarl Hetherington <carl@carlh.net>2007-11-06 13:33:39 +0000
commit3069423106e9901ccad74624ad30756dd8338a36 (patch)
tree66323ee7db06033162f0adad194d71500e9478ba /gtk2_ardour
parent3594c3d80cd8b14a8d31901dc2171d5b31271a7c (diff)
Patch from jdavisp3 to further improve region gain line behaviour, as discussed in bug #1841
git-svn-id: svn://localhost/ardour2/trunk@2599 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_mouse.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index ad4dfad009..dc961f51ea 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -74,6 +74,8 @@ using namespace sigc;
using namespace Gtk;
using namespace Editing;
+const static double ZERO_GAIN_FRACTION = gain_to_slider_position(dB_to_coefficient(0.0));
+
nframes_t
Editor::event_frame (GdkEvent* event, double* pcx, double* pcy)
{
@@ -2599,6 +2601,16 @@ Editor::start_control_point_grab (ArdourCanvas::Item* item, GdkEvent* event)
start_grab (event, fader_cursor);
+ // start the grab at the center of the control point so
+ // the point doesn't 'jump' to the mouse after the first drag
+ drag_info.grab_x = control_point->get_x();
+ drag_info.grab_y = control_point->get_y();
+ control_point->line().parent_group().i2w(drag_info.grab_x, drag_info.grab_y);
+ track_canvas.w2c(drag_info.grab_x, drag_info.grab_y,
+ drag_info.grab_x, drag_info.grab_y);
+
+ drag_info.grab_frame = pixel_to_frame(drag_info.grab_x);
+
control_point->line().start_drag (control_point, drag_info.grab_frame, 0);
double fraction = 1.0 - ((control_point->get_y() - control_point->line().y_position()) / (double)control_point->line().height());
@@ -2624,6 +2636,18 @@ Editor::control_point_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent*
double cx = drag_info.grab_x + drag_info.cumulative_x_drag + dx;
double cy = drag_info.grab_y + drag_info.cumulative_y_drag + dy;
+ // calculate zero crossing point. back off by .01 to stay on the
+ // positive side of zero
+ double _unused = 0;
+ double zero_gain_y = (1.0 - ZERO_GAIN_FRACTION) * cp->line().height() - .01;
+ cp->line().parent_group().i2w(_unused, zero_gain_y);
+
+ // make sure we hit zero when passing through
+ if ((cy < zero_gain_y and (cy - dy) > zero_gain_y)
+ or (cy > zero_gain_y and (cy - dy) < zero_gain_y)) {
+ cy = zero_gain_y;
+ }
+
if (drag_info.x_constrained) {
cx = drag_info.grab_x;
}
@@ -2761,6 +2785,18 @@ Editor::line_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
double cx = drag_info.current_pointer_x;
double cy = drag_info.grab_y + drag_info.cumulative_y_drag + dy;
+ // calculate zero crossing point. back off by .01 to stay on the
+ // positive side of zero
+ double _unused = 0;
+ double zero_gain_y = (1.0 - ZERO_GAIN_FRACTION) * line->height() - .01;
+ line->parent_group().i2w(_unused, zero_gain_y);
+
+ // make sure we hit zero when passing through
+ if ((cy < zero_gain_y and (cy - dy) > zero_gain_y)
+ or (cy > zero_gain_y and (cy - dy) < zero_gain_y)) {
+ cy = zero_gain_y;
+ }
+
drag_info.cumulative_y_drag = cy - drag_info.grab_y;
line->parent_group().w2i (cx, cy);