Merge branch 'master' into cairocanvas
[ardour.git] / gtk2_ardour / editor_drag.cc
index 900424734fa2debee0badc24878bed85ff1c8e3f..1748c397365dcfef3499766b05f931cd285f775f 100644 (file)
@@ -191,7 +191,7 @@ DragManager::window_motion_handler (GdkEvent* e, bool from_autoscroll)
 {
        bool r = false;
 
-       _current_pointer_frame = _editor->window_event_frame (e, &_current_pointer_x, &_current_pointer_y);
+       _current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
 
        for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
                bool const t = (*i)->motion_handler (e, from_autoscroll);
@@ -450,7 +450,7 @@ struct EditorOrderTimeAxisViewSorter {
            RouteTimeAxisView* ra = dynamic_cast<RouteTimeAxisView*> (a);
            RouteTimeAxisView* rb = dynamic_cast<RouteTimeAxisView*> (b);
            assert (ra && rb);
-           return ra->route()->order_key (EditorSort) < rb->route()->order_key (EditorSort);
+           return ra->route()->order_key () < rb->route()->order_key ();
     }
 };
 
@@ -1498,7 +1498,7 @@ RegionCreateDrag::motion (GdkEvent* event, bool first_move)
                           place snapped notes at the start of the region.
                        */
 
-                       framecnt_t const len = (framecnt_t) fabs (f - grab_frame () - 1);
+                       framecnt_t const len = (framecnt_t) fabs ((double)(f - grab_frame () - 1));
                        _region->set_length (len < 1 ? 1 : len);
                }
        }
@@ -1687,7 +1687,7 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
        }
 
        framecnt_t dt = adjusted_current_frame (event) - raw_grab_frame() + _pointer_frame_offset;
-       dt = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(dt);
+       dt = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(_startdrag_video_offset+dt) - _startdrag_video_offset;
 
        if (_max_backwards_drag >= 0 && dt <= - _max_backwards_drag) {
                dt = - _max_backwards_drag;
@@ -2377,9 +2377,14 @@ CursorDrag::fake_locate (framepos_t t)
        Session* s = _editor->session ();
        if (s->timecode_transmission_suspended ()) {
                framepos_t const f = _editor->playhead_cursor->current_frame ();
+               /* This is asynchronous so it will be sent "now"
+                */
                s->send_mmc_locate (f);
-               s->send_full_time_code (f);
-               s->send_song_position_pointer (f);
+               /* These are synchronous and will be sent during the next
+                  process cycle
+               */
+               s->queue_full_time_code ();
+               s->queue_song_position_pointer ();
        }
 
        show_verbose_cursor_time (t);
@@ -3423,16 +3428,28 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
 
                double x1 = _editor->sample_to_pixel (start);
                double x2 = _editor->sample_to_pixel (end);
+               const double min_dimension = 2.0;
 
                _editor->rubberband_rect->set_x0 (x1);
                if (_vertical_only) {
                        /* fixed 10 pixel width */
                        _editor->rubberband_rect->set_x1 (x1 + 10);
                } else {
+                       if (x2 < x1) {
+                               x2 = min (x1 - min_dimension, x2);
+                       } else {
+                               x2 = max (x1 + min_dimension, x2);
+                       }
                        _editor->rubberband_rect->set_x1 (x2);
                } 
 
                _editor->rubberband_rect->set_y0 (y1);
+               if (y2 < y1) {
+                       y2 = min (y1 - min_dimension, y2);
+               } else {
+                       y2 = max (y1 + min_dimension, y2);
+               }
+
                _editor->rubberband_rect->set_y1 (y2);
                
                _editor->rubberband_rect->show();
@@ -4352,7 +4369,7 @@ NoteDrag::motion (GdkEvent *, bool)
                uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
                
                snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (new_note).c_str(),
-                         (int) floor (new_note));
+                         (int) floor ((double)new_note));
 
                show_verbose_cursor_text (buf);
        }
@@ -4856,7 +4873,7 @@ NoteCreateDrag::finished (GdkEvent*, bool had_movement)
        }
        
        framepos_t const start = min (_note[0], _note[1]);
-       framecnt_t length = (framecnt_t) fabs (_note[0] - _note[1]);
+       framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
 
        framecnt_t const g = grid_frames (start);
        double const one_tick = 1 / Timecode::BBT_Time::ticks_per_beat;