make MIDI rubber band selects use the correct canvas item so that event processing...
[ardour.git] / gtk2_ardour / editor_drag.cc
index 701181d0095bc4ff622e36878b5f8a6210ce7c6b..2419169c7fb23f7d301ece441c762e7aaced59fc 100644 (file)
@@ -127,7 +127,7 @@ DragManager::start_grab (GdkEvent* e, Gdk::Cursor* c)
        _old_follow_playhead = _editor->follow_playhead ();
        _editor->set_follow_playhead (false);
 
-       _current_pointer_frame = _editor->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*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
                (*i)->start_grab (e, c);
@@ -165,7 +165,25 @@ DragManager::motion_handler (GdkEvent* e, bool from_autoscroll)
 {
        bool r = false;
 
-       _current_pointer_frame = _editor->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);
+               if (t) {
+                       r = true;
+               }
+
+       }
+
+       return r;
+}
+
+bool
+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);
 
        for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
                bool const t = (*i)->motion_handler (e, from_autoscroll);
@@ -232,7 +250,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
                _y_constrained = false;
        }
 
-       _raw_grab_frame = _editor->event_frame (event, &_grab_x, &_grab_y);
+       _raw_grab_frame = _editor->canvas_event_frame (event, &_grab_x, &_grab_y);
        setup_pointer_frame_offset ();
        _grab_frame = adjusted_frame (_raw_grab_frame, event);
        _last_pointer_frame = _grab_frame;
@@ -496,10 +514,9 @@ RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView
          _brushing (b),
          _total_x_delta (0)
 {
-
+       DEBUG_TRACE (DEBUG::Drags, "New RegionMotionDrag\n");
 }
 
-
 void
 RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 {
@@ -552,7 +569,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_r
        if ((*pending_region_position != _last_frame_position) && x_move_allowed) {
 
                /* x movement since last time (in pixels) */
-               dx = (static_cast<double> (*pending_region_position) - _last_frame_position) / _editor->frames_per_pixel;
+               dx = (static_cast<double> (*pending_region_position) - _last_frame_position) / _editor->samples_per_pixel;
 
                /* total x movement */
                framecnt_t total_dx = *pending_region_position;
@@ -638,6 +655,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
        double const x_delta = compute_x_delta (event, &pending_region_position);
 
        /* Work out the change in y */
+
        int delta_time_axis_view = current_pointer_time_axis_view - _last_pointer_time_axis_view;
        double delta_layer = current_pointer_layer - _last_pointer_layer;
 
@@ -660,11 +678,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
 
                RegionView* rv = i->view;
 
-               if (rv->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || rv->region()->video_locked()
-#endif
-                               ) {
+               if (rv->region()->locked() || rv->region()->video_locked()) {
                        continue;
                }
 
@@ -672,20 +686,19 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
 
                        rv->drag_start (); 
 
-                       /* Absolutely no idea why this is necessary, but it is; without
-                          it, the region view disappears after the reparent.
-                       */
-                       _editor->update_canvas_now ();
-                       
                        /* Reparent to a non scrolling group so that we can keep the
                           region selection above all time axis views.
                           Reparenting means that we will have to move the region view
-                          later, as the two parent groups have different coordinates.
+                          within its new parent, as the two parent groups have different coordinates.
                        */
 
+                       ArdourCanvas::Group* rvg = rv->get_canvas_group();
+                       Duple rv_canvas_offset = rvg->item_to_canvas (Duple (0,0));
+
                        rv->get_canvas_group()->reparent (_editor->_region_motion_group);
-                       
+
                        rv->fake_set_opaque (true);
+                       rvg->set_position (rv_canvas_offset);
                }
 
                /* If we have moved tracks, we'll fudge the layer delta so that the
@@ -735,8 +748,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
 
                        /* Get the y coordinate of the top of the track that this region is now on */
                        tv->canvas_display()->item_to_canvas (x, y);
-                       y += _editor->get_trackview_group_vertical_offset();
-                       
+
                        /* And adjust for the layer that it should be on */
                        StreamView* cv = tv->view ();
                        switch (cv->layer_display ()) {
@@ -820,15 +832,6 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
                        _views = new_regionviews;
 
                        swap_grab (new_regionviews.front().view->get_canvas_group (), 0, event ? event->motion.time : 0);
-
-                       /*
-                         sync the canvas to what we think is its current state
-                         without it, the canvas seems to
-                         "forget" to update properly after the upcoming reparent()
-                         ..only if the mouse is in rapid motion at the time of the grab.
-                         something to do with regionview creation taking so long?
-                       */
-                       _editor->update_canvas_now();
                }
        }
 
@@ -881,8 +884,6 @@ RegionMoveDrag::finished (GdkEvent* ev, bool movement_occurred)
        bool const changed_tracks = (_time_axis_views[_views.front().time_axis_view] != &_views.front().view->get_time_axis_view());
        framecnt_t const drag_delta = _primary->region()->position() - _last_frame_position;
        
-       _editor->update_canvas_now ();
-
        if (_copy) {
 
                finished_copy (
@@ -931,11 +932,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const /*changed
        /* insert the regions into their new playlists */
        for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
 
-               if (i->view->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || i->view->region()->video_locked()
-#endif
-                               ) {
+               if (i->view->region()->locked() || i->view->region()->video_locked()) {
                        continue;
                }
 
@@ -1014,11 +1011,7 @@ RegionMoveDrag::finished_no_copy (
                RouteTimeAxisView* const dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[i->time_axis_view]);
                double const dest_layer = i->layer;
 
-               if (rv->region()->locked()
-#ifdef WITH_VIDEOTIMELINE
-                               || rv->region()->video_locked()
-#endif
-                               ) {
+               if (rv->region()->locked() || rv->region()->video_locked()) {
                        ++i;
                        continue;
                }
@@ -1291,8 +1284,6 @@ RegionMotionDrag::aborted (bool)
                rv->move (-_total_x_delta, 0);
                rv->set_height (rtv->view()->child_height ());
        }
-
-       _editor->update_canvas_now ();
 }
 
 /** @param b true to brush, otherwise false.
@@ -1341,8 +1332,6 @@ RegionInsertDrag::RegionInsertDrag (Editor* e, boost::shared_ptr<Region> r, Rout
 void
 RegionInsertDrag::finished (GdkEvent *, bool)
 {
-       _editor->update_canvas_now ();
-
        RouteTimeAxisView* dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[_views.front().time_axis_view]);
 
        _primary->get_canvas_group()->reparent (dest_rtv->view()->canvas_item());
@@ -1612,8 +1601,6 @@ NoteResizeDrag::aborted (bool)
        }
 }
 
-#ifdef WITH_VIDEOTIMELINE
-
 AVDraggingView::AVDraggingView (RegionView* v)
        : view (v)
 {
@@ -1625,16 +1612,12 @@ VideoTimeLineDrag::VideoTimeLineDrag (Editor* e, ArdourCanvas::Item* i)
 {
        DEBUG_TRACE (DEBUG::Drags, "New VideoTimeLineDrag\n");
 
-       /* create a list of regions to move along */
-#if 1 /* all reagions -- with video_locked() */
        RegionSelection rs;
        TrackViewList empty;
        empty.clear();
        _editor->get_regions_after(rs, (framepos_t) 0, empty);
        std::list<RegionView*> views = rs.by_layer();
-#else /* selected regions -- with video_locked() */
-       std::list<RegionView*> views = _editor->selection->regions.by_layer();
-#endif
+
        for (list<RegionView*>::iterator i = views.begin(); i != views.end(); ++i) {
                RegionView* rv = (*i);
                if (!rv->region()->video_locked()) {
@@ -1699,7 +1682,6 @@ VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
                DEBUG_TRACE (DEBUG::Drags, string_compose("SHIFT REGION at %1 by %2\n", i->initial_position, dt));
                if (first_move) {
                        rv->drag_start ();
-                       _editor->update_canvas_now ();
                        rv->fake_set_opaque (true);
                        rv->region()->clear_changes ();
                        rv->region()->suspend_property_changes();
@@ -1761,7 +1743,6 @@ VideoTimeLineDrag::finished (GdkEvent * /*event*/, bool movement_occurred)
 
 
        _editor->commit_reversible_command ();
-       _editor->update_canvas_now ();
 }
 
 void
@@ -1778,7 +1759,6 @@ VideoTimeLineDrag::aborted (bool)
                i->view->region()->set_position(i->initial_position);
        }
 }
-#endif
 
 TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool preserve_fade_anchor)
        : RegionDrag (e, i, p, v)
@@ -1850,6 +1830,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
        TimeAxisView* tvp = &_primary->get_time_axis_view ();
        RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
        pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
+       frameoffset_t frame_delta = 0;
 
        if (tv && tv->is_track()) {
                speed = tv->track()->speed();
@@ -1916,7 +1897,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
                                        boost::shared_ptr<AudioRegion> ar (arv->audio_region());
                                        distance = _drags->current_pointer_x() - grab_x();
                                        len = ar->fade_in()->back()->when;
-                                       new_length = len - _editor->unit_to_frame (distance);
+                                       new_length = len - _editor->pixel_to_sample (distance);
                                        new_length = ar->verify_xfade_bounds (new_length, true  /*START*/ );
                                        arv->reset_fade_in_shape_width (ar, new_length);  //the grey shape
                                }
@@ -1936,7 +1917,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
                                        boost::shared_ptr<AudioRegion> ar (arv->audio_region());
                                        distance = grab_x() - _drags->current_pointer_x();
                                        len = ar->fade_out()->back()->when;
-                                       new_length = len - _editor->unit_to_frame (distance);
+                                       new_length = len - _editor->pixel_to_sample (distance);
                                        new_length = ar->verify_xfade_bounds (new_length, false  /*END*/ );
                                        arv->reset_fade_out_shape_width (ar, new_length);  //the grey shape
                                }
@@ -1946,27 +1927,11 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
 
        case ContentsTrim:
                {
-                       bool swap_direction = false;
-
-                       if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
-                               swap_direction = true;
-                       }
-
-                       framecnt_t frame_delta = 0;
-
-                       bool left_direction = false;
-                       if (last_pointer_frame() > adjusted_current_frame(event)) {
-                               left_direction = true;
-                       }
-
-                       if (left_direction) {
-                               frame_delta = (last_pointer_frame() - adjusted_current_frame(event));
-                       } else {
-                               frame_delta = (adjusted_current_frame(event) - last_pointer_frame());
-                       }
+                       frame_delta = (adjusted_current_frame(event) - last_pointer_frame());
+                       // frame_delta = (last_pointer_frame() - adjusted_current_frame(event));
 
                        for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
-                               i->view->trim_contents (frame_delta, left_direction, swap_direction);
+                               i->view->move_contents (frame_delta);
                        }
                }
                break;
@@ -1980,7 +1945,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
                show_verbose_cursor_time ((framepos_t) (rv->region()->last_frame() / speed));
                break;
        case ContentsTrim:
-               show_verbose_cursor_time (adjusted_current_frame (event));
+               // show_verbose_cursor_time (frame_delta);
                break;
        }
 }
@@ -2010,7 +1975,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
                                                boost::shared_ptr<AudioRegion> ar (arv->audio_region());
                                                distance = _drags->current_pointer_x() - grab_x();
                                                len = ar->fade_in()->back()->when;
-                                               new_length = len - _editor->unit_to_frame (distance);
+                                               new_length = len - _editor->pixel_to_sample (distance);
                                                new_length = ar->verify_xfade_bounds (new_length, true  /*START*/ );
                                                ar->set_fade_in_length(new_length);
                                        }
@@ -2027,7 +1992,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
                                                boost::shared_ptr<AudioRegion> ar (arv->audio_region());
                                                distance = _drags->current_pointer_x() - grab_x();
                                                len = ar->fade_out()->back()->when;
-                                               new_length = len - _editor->unit_to_frame (distance);
+                                               new_length = len - _editor->pixel_to_sample (distance);
                                                new_length = ar->verify_xfade_bounds (new_length, false  /*END*/ );
                                                ar->set_fade_out_length(new_length);
                                        }
@@ -2181,7 +2146,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
                _marker = new MeterMarker (
                        *_editor,
                        *_editor->meter_group,
-                       ARDOUR_UI::config()->canvasvar_MeterMarker.get(),
+                       ARDOUR_UI::config()->get_canvasvar_MeterMarker(),
                        name,
                        *new MeterSection (_marker->meter())
                );
@@ -2300,7 +2265,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
                _marker = new TempoMarker (
                        *_editor,
                        *_editor->tempo_group,
-                       ARDOUR_UI::config()->canvasvar_TempoMarker.get(),
+                       ARDOUR_UI::config()->get_canvasvar_TempoMarker(),
                        name,
                        *new TempoSection (_marker->tempo())
                        );
@@ -2373,9 +2338,10 @@ TempoMarkerDrag::aborted (bool moved)
        }
 }
 
-CursorDrag::CursorDrag (Editor* e, ArdourCanvas::Item* i, bool s)
-       : Drag (e, i),
-         _stop (s)
+CursorDrag::CursorDrag (Editor* e, EditorCursor& c, bool s)
+       : Drag (e, &c.time_bar_canvas_item())
+       , _cursor (c)
+       , _stop (s)
 {
        DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n");
 }
@@ -2405,15 +2371,20 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
 {
        Drag::start_grab (event, c);
 
-       _grab_zoom = _editor->frames_per_pixel;
+       _grab_zoom = _editor->samples_per_pixel;
+
+       framepos_t where = _editor->canvas_event_frame (event, 0, 0);
 
-       framepos_t where = _editor->event_frame (event, 0, 0);
        _editor->snap_to_with_modifier (where, event);
 
        _editor->_dragging_playhead = true;
 
        Session* s = _editor->session ();
 
+       /* grab the track canvas item as well */
+
+       _cursor.track_canvas_item().grab();
+
        if (s) {
                if (_was_rolling && _stop) {
                        s->request_stop ();
@@ -2449,9 +2420,6 @@ CursorDrag::motion (GdkEvent* event, bool)
        framepos_t const adjusted_frame = adjusted_current_frame (event);
        if (adjusted_frame != last_pointer_frame()) {
                fake_locate (adjusted_frame);
-#ifdef GTKOSX
-               _editor->update_canvas_now ();
-#endif
        }
 }
 
@@ -2460,6 +2428,8 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
 {
        _editor->_dragging_playhead = false;
 
+       _cursor.track_canvas_item().ungrab();
+
        if (!movement_occurred && _stop) {
                return;
        }
@@ -2477,6 +2447,8 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
 void
 CursorDrag::aborted (bool)
 {
+       _cursor.track_canvas_item().ungrab();
+
        if (_editor->_dragging_playhead) {
                _editor->session()->request_resume_timecode_transmission ();
                _editor->_dragging_playhead = false;
@@ -2996,10 +2968,6 @@ MarkerDrag::motion (GdkEvent* event, bool)
        assert (!_copied_locations.empty());
 
        show_verbose_cursor_time (newframe);
-
-#ifdef GTKOSX
-       _editor->update_canvas_now ();
-#endif
 }
 
 void
@@ -3160,7 +3128,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
        cy = max (0.0, cy);
        cy = min ((double) _point->line().height(), cy);
 
-       framepos_t cx_frames = _editor->unit_to_frame (cx);
+       framepos_t cx_frames = _editor->pixel_to_sample (cx);
 
        if (!_x_constrained) {
                _editor->snap_to_with_modifier (cx_frames, event);
@@ -3170,7 +3138,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
 
        float const fraction = 1.0 - (cy / _point->line().height());
 
-       _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, _pushing, _final_index);
+       _point->line().drag_motion (_editor->sample_to_pixel_unrounded (cx_frames), fraction, false, _pushing, _final_index);
 
        _editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
 }
@@ -3237,7 +3205,7 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
 
        _line->parent_group().canvas_to_item (cx, cy);
 
-       framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->frames_per_pixel);
+       framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->samples_per_pixel);
 
        uint32_t before;
        uint32_t after;
@@ -3333,7 +3301,7 @@ FeatureLineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
 
        _arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview"));
 
-       _max_x = _editor->frame_to_pixel(_arv->get_duration());
+       _max_x = _editor->sample_to_pixel(_arv->get_duration());
 }
 
 void
@@ -3354,7 +3322,7 @@ FeatureLineDrag::motion (GdkEvent*, bool)
                cx = 0;
        }
 
-       boost::optional<Rect> bbox = _line->bounding_box ();
+       boost::optional<ArdourCanvas::Rect> bbox = _line->bounding_box ();
        assert (bbox);
        _line->set (ArdourCanvas::Duple (cx, 2.0), ArdourCanvas::Duple (cx, bbox.get().height ()));
 
@@ -3429,8 +3397,8 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
 
        if (start != end || y1 != y2) {
 
-               double x1 = _editor->frame_to_pixel (start);
-               double x2 = _editor->frame_to_pixel (end);
+               double x1 = _editor->sample_to_pixel (start);
+               double x2 = _editor->sample_to_pixel (end);
 
                _editor->rubberband_rect->set_x0 (x1);
                if (_vertical_only) {
@@ -3442,7 +3410,7 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
 
                _editor->rubberband_rect->set_y0 (y1);
                _editor->rubberband_rect->set_y1 (y2);
-
+               
                _editor->rubberband_rect->show();
                _editor->rubberband_rect->raise_to_top();
 
@@ -3968,8 +3936,8 @@ RangeMarkerBarDrag::RangeMarkerBarDrag (Editor* e, ArdourCanvas::Item* i, Operat
                                                                      physical_screen_height (_editor->get_window())));
        _drag_rect->hide ();
 
-       _drag_rect->set_fill_color (ARDOUR_UI::config()->canvasvar_RangeDragRect.get());
-       _drag_rect->set_outline_color (ARDOUR_UI::config()->canvasvar_RangeDragRect.get());
+       _drag_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
+       _drag_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
 }
 
 void
@@ -4065,8 +4033,8 @@ RangeMarkerBarDrag::motion (GdkEvent* event, bool first_move)
        if (start != end) {
                _editor->temp_location->set (start, end);
 
-               double x1 = _editor->frame_to_pixel (start);
-               double x2 = _editor->frame_to_pixel (end);
+               double x1 = _editor->sample_to_pixel (start);
+               double x2 = _editor->sample_to_pixel (end);
                crect->set_x0 (x1);
                crect->set_x1 (x2);
 
@@ -4166,8 +4134,8 @@ RangeMarkerBarDrag::aborted (bool)
 void
 RangeMarkerBarDrag::update_item (Location* location)
 {
-       double const x1 = _editor->frame_to_pixel (location->start());
-       double const x2 = _editor->frame_to_pixel (location->end());
+       double const x1 = _editor->sample_to_pixel (location->start());
+       double const x2 = _editor->sample_to_pixel (location->end());
 
        _drag_rect->set_x0 (x1);
        _drag_rect->set_x1 (x2);
@@ -4299,7 +4267,7 @@ frameoffset_t
 NoteDrag::total_dx () const
 {
        /* dx in frames */
-       frameoffset_t const dx = _editor->unit_to_frame (_drags->current_pointer_x() - grab_x());
+       frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x());
 
        /* primary note time */
        frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ());
@@ -4339,7 +4307,7 @@ NoteDrag::motion (GdkEvent *, bool)
        int8_t const dy = total_dy ();
 
        /* Now work out what we have to do to the note canvas items to set this new drag delta */
-       double const tdx = _editor->frame_to_unit (dx) - _cumulative_dx;
+       double const tdx = _editor->sample_to_pixel (dx) - _cumulative_dx;
        double const tdy = -dy * _note_height - _cumulative_dy;
 
        if (tdx || tdy) {
@@ -4661,7 +4629,7 @@ PatchChangeDrag::motion (GdkEvent* ev, bool)
        f = min (f, r->last_frame ());
 
        framecnt_t const dxf = f - grab_frame(); // permitted dx in frames
-       double const dxu = _editor->frame_to_unit (dxf); // permitted fx in units
+       double const dxu = _editor->sample_to_pixel (dxf); // permitted fx in units
        _patch_change->move (ArdourCanvas::Duple (dxu - _cumulative_dx, 0));
        _cumulative_dx = dxu;
 }
@@ -4698,7 +4666,7 @@ PatchChangeDrag::setup_pointer_frame_offset ()
 }
 
 MidiRubberbandSelectDrag::MidiRubberbandSelectDrag (Editor* e, MidiRegionView* rv)
-       : RubberbandSelectDrag (e, rv->get_canvas_frame ())
+       : RubberbandSelectDrag (e, rv->get_canvas_group ())
        , _region_view (rv)
 {
 
@@ -4716,8 +4684,8 @@ MidiRubberbandSelectDrag::select_things (int button_state, framepos_t x1, framep
        y2 = max (0.0, y2 - y);
        
        _region_view->update_drag_selection (
-               _editor->frame_to_pixel (x1),
-               _editor->frame_to_pixel (x2),
+               _editor->sample_to_pixel (x1),
+               _editor->sample_to_pixel (x2),
                y1,
                y2,
                Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier)
@@ -4731,7 +4699,7 @@ MidiRubberbandSelectDrag::deselect_things ()
 }
 
 MidiVerticalSelectDrag::MidiVerticalSelectDrag (Editor* e, MidiRegionView* rv)
-       : RubberbandSelectDrag (e, rv->get_canvas_frame ())
+       : RubberbandSelectDrag (e, rv->get_canvas_group ())
        , _region_view (rv)
 {
        _vertical_only = true;
@@ -4835,7 +4803,7 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
        _note[0] = adjusted_frame (pf, event) - _region_view->region()->position ();
 
        MidiStreamView* sv = _region_view->midi_stream_view ();
-       double const x = _editor->frame_to_pixel (_note[0]);
+       double const x = _editor->sample_to_pixel (_note[0]);
        double const y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
 
        _drag_rect->set (ArdourCanvas::Rect (x, y, x, y + floor (_region_view->midi_stream_view()->note_height ())));
@@ -4848,7 +4816,7 @@ void
 NoteCreateDrag::motion (GdkEvent* event, bool)
 {
        _note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
-       double const x = _editor->frame_to_pixel (_note[1]);
+       double const x = _editor->sample_to_pixel (_note[1]);
        if (_note[1] > _note[0]) {
                _drag_rect->set_x1 (x);
        } else {
@@ -4925,16 +4893,16 @@ CrossfadeEdgeDrag::motion (GdkEvent*, bool)
 
        /* how long should it be ? */
 
-       new_length = len + _editor->unit_to_frame (distance);
+       new_length = len + _editor->pixel_to_sample (distance);
 
        /* now check with the region that this is legal */
 
        new_length = ar->verify_xfade_bounds (new_length, start);
 
        if (start) {
-               arv->redraw_start_xfade_to (ar, new_length);
+               arv->reset_fade_in_shape_width (ar, new_length);
        } else {
-               arv->redraw_end_xfade_to (ar, new_length);
+               arv->reset_fade_out_shape_width (ar, new_length);
        }
 }
 
@@ -4955,7 +4923,7 @@ CrossfadeEdgeDrag::finished (GdkEvent*, bool)
                len = ar->fade_out()->back()->when;
        }
 
-       new_length = ar->verify_xfade_bounds (len + _editor->unit_to_frame (distance), start);
+       new_length = ar->verify_xfade_bounds (len + _editor->pixel_to_sample (distance), start);
        
        _editor->begin_reversible_command ("xfade trim");
        ar->playlist()->clear_owned_changes ();