+
+CrossfadeEdgeDrag::CrossfadeEdgeDrag (Editor* e, AudioRegionView* rv, ArdourCanvas::Item* i, bool start_yn)
+ : Drag (e, i)
+ , arv (rv)
+ , start (start_yn)
+{
+ std::cout << ("CrossfadeEdgeDrag is DEPRECATED. See TrimDrag::preserve_fade_anchor") << endl;
+}
+
+void
+CrossfadeEdgeDrag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
+{
+ Drag::start_grab (event, cursor);
+}
+
+void
+CrossfadeEdgeDrag::motion (GdkEvent*, bool)
+{
+ double distance;
+ double new_length;
+ framecnt_t len;
+
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+
+ if (start) {
+ distance = _drags->current_pointer_x() - grab_x();
+ len = ar->fade_in()->back()->when;
+ } else {
+ distance = grab_x() - _drags->current_pointer_x();
+ len = ar->fade_out()->back()->when;
+ }
+
+ /* how long should it be ? */
+
+ new_length = len + _editor->unit_to_frame (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);
+ } else {
+ arv->redraw_end_xfade_to (ar, new_length);
+ }
+}
+
+void
+CrossfadeEdgeDrag::finished (GdkEvent*, bool)
+{
+ double distance;
+ double new_length;
+ framecnt_t len;
+
+ boost::shared_ptr<AudioRegion> ar (arv->audio_region());
+
+ if (start) {
+ distance = _drags->current_pointer_x() - grab_x();
+ len = ar->fade_in()->back()->when;
+ } else {
+ distance = grab_x() - _drags->current_pointer_x();
+ len = ar->fade_out()->back()->when;
+ }
+
+ new_length = ar->verify_xfade_bounds (len + _editor->unit_to_frame (distance), start);
+
+ _editor->begin_reversible_command ("xfade trim");
+ ar->playlist()->clear_owned_changes ();
+
+ if (start) {
+ ar->set_fade_in_length (new_length);
+ } else {
+ ar->set_fade_out_length (new_length);
+ }
+
+ /* Adjusting the xfade may affect other regions in the playlist, so we need
+ to get undo Commands from the whole playlist rather than just the
+ region.
+ */
+
+ vector<Command*> cmds;
+ ar->playlist()->rdiff (cmds);
+ _editor->session()->add_commands (cmds);
+ _editor->commit_reversible_command ();
+
+}
+
+void
+CrossfadeEdgeDrag::aborted (bool)
+{
+ if (start) {
+ arv->redraw_start_xfade ();
+ } else {
+ arv->redraw_end_xfade ();
+ }
+}
+