Merge with 2.0-ongoing R2988
[ardour.git] / gtk2_ardour / editor_mouse.cc
index 35f410eb25590bcba6af10f67b4ff2fbd38be966..4234368acdc6c67a992097039fd2152f8d3cd379 100644 (file)
@@ -967,24 +967,23 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                        case FadeOutHandleItem:
                                popup_fade_context_menu (1, event->button.time, item, item_type);
                                break;
-
+                       
                        case StreamItem:
-                               popup_track_context_menu (1, event->button.time, where);
+                               popup_track_context_menu (1, event->button.time, item_type, false, where);
                                break;
                                
                        case RegionItem:
                        case RegionViewNameHighlight:
                        case RegionViewName:
-                               popup_track_context_menu (1, event->button.time, where);
+                               popup_track_context_menu (1, event->button.time, item_type, false, where);
                                break;
                                
                        case SelectionItem:
-                               popup_track_context_menu (1, event->button.time, where);
+                               popup_track_context_menu (1, event->button.time, item_type, true, where);
                                break;
 
                        case AutomationTrackItem:
-                       case CrossfadeViewItem:
-                               popup_track_context_menu (1, event->button.time, where);
+                               popup_track_context_menu (1, event->button.time, item_type, false, where);
                                break;
 
                        case MarkerBarItem: 
@@ -1007,6 +1006,10 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                        case MeterMarkerItem:
                                tm_marker_context_menu (&event->button, item);
                                break;
+                       
+                       case CrossfadeViewItem:
+                               popup_track_context_menu (1, event->button.time, item_type, false, where);
+                               break;
 
 #ifdef WITH_CMT
                        case ImageFrameItem:
@@ -3069,7 +3072,7 @@ Editor::possibly_copy_regions_during_grab (GdkEvent* event)
                /* reset selection to new regionviews */
 
                selection->set (new_regionviews);
-               
+
                /* reset drag_info data to reflect the fact that we are dragging the copies */
                
                drag_info.data = new_regionviews.front();
@@ -3379,7 +3382,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
                        }
            
                        if (sync_frame - sync_offset <= sync_frame) {
-                               pending_region_position = sync_frame + (sync_dir*sync_offset);
+                               pending_region_position = sync_frame - (sync_dir*sync_offset);
                        } else {
                                pending_region_position = 0;
                        }
@@ -3468,7 +3471,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
 
                pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
                const list<RegionView*>& layered_regions = selection->regions.by_layer();
-
+               
                for (list<RegionView*>::const_iterator i = layered_regions.begin(); i != layered_regions.end(); ++i) {
            
                        RegionView* rv = (*i);
@@ -3680,7 +3683,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
 
        if (regionview_y_movement) {
 
-               /* moved to a different audio track. */
+               /* moved to a different track. */
                
                vector<RegionView*> new_selection;
                
@@ -3695,7 +3698,11 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
 
                        RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(trackview_by_y_position (iy1));
 
+                       boost::shared_ptr<Playlist> from_playlist = rv->region()->playlist();
                        boost::shared_ptr<Playlist> to_playlist = rtv2->playlist();
+                       
+                       where = (nframes_t) (unit_to_frame (ix1) * speed);
+                       boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region()));
 
                        if (! to_playlist->frozen()) {
                                /* 
@@ -3720,35 +3727,26 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
                                to_playlist->freeze();
                        }
                        
-                       where = (nframes_t) (unit_to_frame (ix1) * speed);
-                       boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region()));
-
-                       if (!drag_info.copy) {
+                       /* undo the previous hide_dependent_views so that xfades don't
+                          disappear on copying regions 
+                       */
 
+                       rv->get_time_axis_view().reveal_dependent_views (*rv);
 
+                       if (!drag_info.copy) {
+                               
                                /* the region that used to be in the old playlist is not
                                   moved to the new one - we make a copy of it. as a result,
                                   any existing editor for the region should no longer be
                                   visible.
                                */ 
-
-                               RouteTimeAxisView* from_playlist_rtv = dynamic_cast<RouteTimeAxisView*>(&(*i)->get_trackview());
-                               boost::shared_ptr<Playlist> from_playlist = from_playlist_rtv->playlist();
-
-                               if (! from_playlist->frozen()) {
-                                       from_playlist->freeze();
-                                       used_playlists.push_back(from_playlist);
-
-                                       sigc::connection c = rtv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_and_select_new_region_view));
-                                       used_connections.push_back (c);
-
-                                       session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));    
-                               }
-
+           
                                rv->hide_region_editor();
                                rv->fake_set_opaque (false);
 
+                               session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));    
                                from_playlist->remove_region ((rv->region()));
+                               session->add_command (new MementoCommand<Playlist>(*from_playlist, 0, &from_playlist->get_state()));    
 
                        } else {
 
@@ -3868,7 +3866,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
                                sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
                                to_playlist->add_region (newregion, (nframes_t) (where * rtv->get_diskstream()->speed()));
                                c.disconnect ();
-                               
+
                                if (!latest_regionviews.empty()) {
                                        // XXX why just the first one ? we only expect one
                                        rtv->reveal_dependent_views (*latest_regionviews.front());
@@ -5333,11 +5331,15 @@ Editor::end_time_fx (ArdourCanvas::Item* item, GdkEvent* event)
        }
        
        nframes_t newlen = drag_info.last_pointer_frame - clicked_regionview->region()->position();
-#ifdef USE_RUBBERBAND
-       float percentage = (float) ((double) newlen / (double) clicked_regionview->region()->length());
-#else
-       float percentage = (float) ((double) newlen - (double) clicked_regionview->region()->length()) / ((double) newlen) * 100.0f;
+
+       float percentage = (double) newlen / (double) clicked_regionview->region()->length();
+
+#ifndef USE_RUBBERBAND
+       // Soundtouch uses percentage / 100 instead of normal (/ 1) 
+       if (clicked_regionview->region()->data_type() == DataType::AUDIO) {
+               percentage = (float) ((double) newlen - (double) clicked_regionview->region()->length()) / ((double) newlen) * 100.0f;
 #endif 
+       }
 
        begin_reversible_command (_("timestretch"));