Fix wonky note length when create-dragging notes backwards.
authorDavid Robillard <d@drobilla.net>
Fri, 14 Nov 2014 05:33:05 +0000 (00:33 -0500)
committerDavid Robillard <d@drobilla.net>
Fri, 14 Nov 2014 05:33:05 +0000 (00:33 -0500)
Specifically, when pivoting from forwards to backwards (around the drag start
point), the note length was too long.  Setting both the start and end x
coordinates of the rect every time to the right value does the right thing.

gtk2_ardour/editor_drag.cc

index 1f400310ae87de8e40c4d0f6cf6a6331c2b639e7..0aaec8d24d5e4e8129b1f919fd2b5bf45d668696 100644 (file)
@@ -5280,12 +5280,10 @@ void
 NoteCreateDrag::motion (GdkEvent* event, bool)
 {
        _note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
-       double const x = _editor->sample_to_pixel (_note[1]);
-       if (_note[1] > _note[0]) {
-               _drag_rect->set_x1 (x);
-       } else {
-               _drag_rect->set_x0 (x);
-       }
+       double const x0 = _editor->sample_to_pixel (_note[0]);
+       double const x1 = _editor->sample_to_pixel (_note[1]);
+       _drag_rect->set_x0 (std::min(x0, x1));
+       _drag_rect->set_x1 (std::max(x0, x1));
 }
 
 void