introduce the notion that note additions and property changes can cause the removal...
[ardour.git] / gtk2_ardour / editor_ops.cc
index 8aa9489497d376d4f29f5405810b55bfe405d1f6..9206f1516bfc1a2581d69237d028a346e5ec58d3 100644 (file)
@@ -1736,7 +1736,7 @@ Editor::temporal_zoom_region (bool both_axes)
 
                for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                        if (find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) {
-                               hide_track_in_display (**i, true);
+                               hide_track_in_display (*i, true);
                        }
                }
 
@@ -1776,7 +1776,13 @@ Editor::temporal_zoom_session ()
        ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_session)
 
        if (_session) {
-               temporal_zoom_by_frame (_session->current_start_frame(), _session->current_end_frame(), "zoom to _session");
+               nframes_t const l = _session->current_end_frame() - _session->current_start_frame();
+               double s = _session->current_start_frame() - l * 0.01;
+               if (s < 0) {
+                       s = 0;
+               }
+               nframes_t const e = _session->current_end_frame() + l * 0.01;
+               temporal_zoom_by_frame (nframes_t (s), e, "zoom to _session");
        }
 }
 
@@ -2191,8 +2197,6 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
        boost::shared_ptr<Playlist> playlist;
 
        track_canvas->window_to_world (x, y, wx, wy);
-       //wx += horizontal_adjustment.get_value();
-       //wy += vertical_adjustment.get_value();
 
        GdkEvent event;
        event.type = GDK_BUTTON_RELEASE;
@@ -2229,7 +2233,8 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
 }
 
 void
-Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y) {
+Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y)
+{
        double wx, wy;
        double cx, cy;
        nframes_t where;
@@ -2237,7 +2242,7 @@ Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y) {
        RouteTimeAxisView *source_rtv = 0;
 
        track_canvas->window_to_world (x, y, wx, wy);
-       wx += horizontal_adjustment.get_value();
+       wx += horizontal_position ();
        wy += vertical_adjustment.get_value();
 
        GdkEvent event;
@@ -3657,6 +3662,8 @@ Editor::bounce_range_selection (bool replace, bool enable_processing)
                InterThreadInfo itt;
 
                 playlist->clear_history ();
+               playlist->clear_owned_history ();
+               
                boost::shared_ptr<Region> r = rtv->track()->bounce_range (start, start+cnt, itt, enable_processing);
 
                if (replace) {
@@ -3666,7 +3673,13 @@ Editor::bounce_range_selection (bool replace, bool enable_processing)
                        playlist->add_region (r, start);
                }
 
-               _session->add_command (new StatefulDiffCommand (playlist));
+               vector<StatefulDiffCommand*> cmds;
+               playlist->rdiff (cmds);
+               for (vector<StatefulDiffCommand*>::iterator j = cmds.begin(); j != cmds.end(); ++j) {
+                       _session->add_command (*j);
+               }
+
+                _session->add_command (new StatefulDiffCommand (playlist));
        }
 
        commit_reversible_command ();
@@ -3760,7 +3773,7 @@ Editor::cut_copy (CutCopyOp op)
                        Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
                }
 
-               _drags->break_drag ();
+               _drags->abort ();
                return;
        }
 
@@ -3841,7 +3854,7 @@ Editor::cut_copy (CutCopyOp op)
        }
 
        if (op == Cut || op == Clear) {
-               _drags->break_drag ();
+               _drags->abort ();
        }
 }
 
@@ -4600,7 +4613,7 @@ Command*
 Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv)
 {
        Evoral::Sequence<Evoral::MusicalTime>::Notes selected;
-       mrv.selection_as_notelist (selected);
+       mrv.selection_as_notelist (selected, true);
 
        vector<Evoral::Sequence<Evoral::MusicalTime>::Notes> v;
        v.push_back (selected);
@@ -4643,6 +4656,47 @@ Editor::apply_midi_note_edit_op (MidiOperator& op)
        rs.clear ();
 }
 
+void
+Editor::fork_region ()
+{
+       RegionSelection rs;
+
+       get_regions_for_action (rs);
+
+       if (rs.empty()) {
+               return;
+       }
+
+       begin_reversible_command (_("Fork Region(s)"));
+
+       track_canvas->get_window()->set_cursor (*wait_cursor);
+       gdk_flush ();
+
+       for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ) {
+               RegionSelection::iterator tmp = r;
+               ++tmp;
+
+               MidiRegionView* const mrv = dynamic_cast<MidiRegionView*>(*r);
+
+               if (mrv) {
+                       boost::shared_ptr<Playlist> playlist = mrv->region()->playlist();
+                        boost::shared_ptr<MidiRegion> newregion = mrv->midi_region()->clone ();
+                        
+                        playlist->clear_history ();
+                        cerr << "Replace region with " << newregion->name() << endl;
+                        playlist->replace_region (mrv->region(), newregion, mrv->region()->position());
+                        _session->add_command(new StatefulDiffCommand (playlist));
+               }
+
+               r = tmp;
+       }
+
+       commit_reversible_command ();
+       rs.clear ();
+
+       track_canvas->get_window()->set_cursor (*current_canvas_cursor);
+}
+
 void
 Editor::quantize_region ()
 {
@@ -4976,7 +5030,7 @@ Editor::set_fade_length (bool in)
 
        nframes64_t pos = get_preferred_edit_position();
        nframes64_t len;
-       char* cmd;
+       char const * cmd;
 
        if (pos > rv->region()->last_frame() || pos < rv->region()->first_frame()) {
                /* edit point is outside the relevant region */
@@ -6011,7 +6065,7 @@ Editor::playhead_backward_to_grid ()
 }
 
 void
-Editor::set_track_height (uint32_t h)
+Editor::set_track_height (Height h)
 {
        TrackSelection& ts (selection->tracks);
 
@@ -6192,7 +6246,8 @@ Editor::do_insert_time ()
                return;
        }
 
-       InsertTimeOption opt;
+       /* only setting this to keep GCC quiet */
+       InsertTimeOption opt = LeaveIntersected;
 
        switch (intersected_combo.get_active_row_number ()) {
        case 0:
@@ -6319,7 +6374,7 @@ Editor::fit_tracks (TrackViewList & tracks)
        uint32_t h = (uint32_t) floor ((_canvas_height - child_heights - canvas_timebars_vsize) / tracks.size());
        double first_y_pos = DBL_MAX;
 
-       if (h < TimeAxisView::hSmall) {
+       if (h < TimeAxisView::preset_height (HeightSmall)) {
                MessageDialog msg (*this, _("There are too many tracks to fit in the current window"));
                /* too small to be displayed */
                return;
@@ -6351,7 +6406,7 @@ Editor::fit_tracks (TrackViewList & tracks)
                        first_y_pos = std::min ((*t)->y_position (), first_y_pos);
                } else {
                        if (prev_was_selected && next_is_selected) {
-                               hide_track_in_display (**t);
+                               hide_track_in_display (*t);
                        }
                }