From b6f290add261d99327f5dd56feec741c4be87725 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 16 Jul 2021 14:12:00 -0600 Subject: [PATCH] timeline type changes for new ripple code and post-conflict-resolution fixups --- gtk2_ardour/editor.h | 13 ++++++------ gtk2_ardour/editor_drag.cc | 36 ++++++++++++++++----------------- gtk2_ardour/editor_drag.h | 2 +- gtk2_ardour/editor_markers.cc | 9 ++++----- gtk2_ardour/editor_ops.cc | 20 +++++++++--------- gtk2_ardour/editor_selection.cc | 2 +- gtk2_ardour/midi_streamview.cc | 2 +- gtk2_ardour/route_time_axis.cc | 2 +- gtk2_ardour/route_time_axis.h | 2 +- gtk2_ardour/streamview.cc | 2 +- gtk2_ardour/streamview.h | 2 +- gtk2_ardour/time_axis_view.h | 2 +- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 6055d4da5d..3a63926c6f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -275,7 +275,7 @@ public: bool get_selection_extents (Temporal::timepos_t &start, Temporal::timepos_t &end) const; // the time extents of the current selection, whether Range, Region(s), Control Points, or Notes Selection& get_cut_buffer() const { return *cut_buffer; } - void get_regionviews_at_or_after (ARDOUR::samplepos_t, RegionSelection&); + void get_regionviews_at_or_after (Temporal::timepos_t const &, RegionSelection&); void set_selection (std::list, Selection::Operation); void set_selected_midi_region_view (MidiRegionView&); @@ -595,11 +595,11 @@ public: void edit_meter_section (Temporal::MeterPoint&); bool should_ripple () const; - void do_ripple (boost::shared_ptr, samplepos_t, samplecnt_t, ARDOUR::RegionList* exclude, bool add_to_command); - void do_ripple (boost::shared_ptr, samplepos_t, samplecnt_t, boost::shared_ptr exclude, bool add_to_command); - void ripple_marks (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance); - void get_markers_to_ripple (boost::shared_ptr target_playlist, samplepos_t pos, std::vector& markers); - samplepos_t effective_ripple_mark_start (boost::shared_ptr target_playlist, samplepos_t pos); + void do_ripple (boost::shared_ptr, Temporal::timepos_t const &, Temporal::timecnt_t const &, ARDOUR::RegionList* exclude, bool add_to_command); + void do_ripple (boost::shared_ptr, Temporal::timepos_t const &, Temporal::timecnt_t const &, boost::shared_ptr exclude, bool add_to_command); + void ripple_marks (boost::shared_ptr target_playlist, Temporal::timepos_t at, Temporal::timecnt_t const & distance); + void get_markers_to_ripple (boost::shared_ptr target_playlist, Temporal::timepos_t const & pos, std::vector& markers); + Temporal::timepos_t effective_ripple_mark_start (boost::shared_ptr target_playlist, Temporal::timepos_t pos); void add_region_marker (); void clear_region_markers (); @@ -2416,6 +2416,7 @@ private: friend class RegionCutDrag; friend class RegionDrag; friend class RegionMoveDrag; + friend class RegionRippleDrag; friend class TrimDrag; friend class BBTRulerDrag; friend class MeterMarkerDrag; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a714c94b80..b5041879cd 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -877,8 +877,8 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, Temporal::timepos_t & pending_region_position = _last_position; } - if (pending_region_position->sample <= _earliest_time_limit) { - pending_region_position->sample = _earliest_time_limit; + if (!_earliest_time_limit.zero() && pending_region_position <= _earliest_time_limit) { + pending_region_position = _earliest_time_limit; return 0.0; } @@ -1708,7 +1708,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t PlaylistSet modified_playlists; RouteTimeAxisView* new_time_axis_view = 0; - timecnt_t const drag_delta = _last_position.distance (_primary->region()->nt_position()); + timecnt_t const drag_delta = _last_position.distance (_primary->region()->position()); RegionList ripple_exclude; /*x_contrained on the same track: this will just make a duplicate region in the same place: abort the operation */ @@ -1722,8 +1722,8 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t PlaylistMapping playlist_mapping; /* determine boundaries of dragged regions, across all playlists */ - samplepos_t extent_min = max_samplepos; - samplepos_t extent_max = 0; + timepos_t extent_min = timepos_t::max(_primary->region()->position().time_domain()); + timepos_t extent_max; /* insert the regions into their (potentially) new (or existing) playlists */ for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { @@ -1744,12 +1744,12 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t /* compute full extent of regions that we're going to insert */ - if (where.sample < extent_min) { - extent_min = where.sample; + if (where < extent_min) { + extent_min = where; } - if (where.sample + i->view->region()->length() > extent_max) { - extent_max = where.sample + i->view->region()->length(); + if (where + i->view->region()->length() > extent_max) { + extent_max = where + i->view->region()->length(); } if (i->time_axis_view < 0 || i->time_axis_view >= (int)_time_axis_views.size()) { @@ -1802,7 +1802,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t for (PlaylistSet::iterator p = modified_playlists.begin(); p != modified_playlists.end(); ++p) { if (_editor->should_ripple()) { - (*p)->ripple (extent_min, extent_max - extent_min, &ripple_exclude); + (*p)->ripple (extent_min, extent_min.distance (extent_max), &ripple_exclude); } (*p)->rdiff_and_add_command (_editor->session()); } @@ -1810,7 +1810,7 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const changed_t /* Ripple marks & ranges if appropriate */ if (Config->get_edit_mode() == RippleAll) { - _editor->ripple_marks (_primary->region()->playlist(), extent_min, extent_max - extent_min); + _editor->ripple_marks (_primary->region()->playlist(), extent_min, extent_min.distance (extent_max)); } /* If we've created new regions either by copying or moving @@ -1838,7 +1838,7 @@ RegionMoveDrag::finished_no_copy ( set views_to_update; RouteTimeAxisView* new_time_axis_view = 0; - timecnt_t const drag_delta = last_position.distance (_primary->region()->nt_position()); + timecnt_t const drag_delta = last_position.distance (_primary->region()->position()); RegionList ripple_exclude; typedef map, RouteTimeAxisView*> PlaylistMapping; @@ -2236,7 +2236,7 @@ RegionInsertDrag::finished (GdkEvent * event, bool) playlist->add_region (_primary->region (), _last_position, 1.0, false); if (_editor->should_ripple()) { - playlist->ripple (_last_position, _primary->region()->nt_length(), _primary->region()); + playlist->ripple (_last_position, _primary->region()->length(), _primary->region()); } else { playlist->rdiff_and_add_command (_editor->session()); } @@ -2286,8 +2286,8 @@ RegionRippleDrag::add_all_after_to_views(TimeAxisView *tav, timepos_t const & wh (*i)->drag_start(); ArdourCanvas::Item* rvg = (*i)->get_canvas_group(); Duple rv_canvas_offset = rvg->item_to_canvas (Duple (0,0)); - Duple dmg_canvas_offset = _editor->_drag_motion_group->canvas_origin (); - rvg->reparent (_editor->_drag_motion_group); + Duple dmg_canvas_offset = _editor->get_drag_motion_group()->canvas_origin (); + rvg->reparent (_editor->get_drag_motion_group()); // we only need to move in the y direction Duple fudge = rv_canvas_offset - dmg_canvas_offset; @@ -2309,7 +2309,7 @@ RegionRippleDrag::remove_unselected_from_views(timecnt_t const & amount, bool mo // we added all the regions after the selection std::list::iterator to_erase = i++; - if (!_editor->selection->regions.contains (to_erase->view)) { + if (!_editor->get_selection().regions.contains (to_erase->view)) { // restore the non-selected regions to their original playlist & positions, // and then ripple them back by the length of the regions that were dragged away // do the same things as RegionMotionDrag::aborted @@ -2359,7 +2359,7 @@ RegionRippleDrag::RegionRippleDrag (Editor* e, ArdourCanvas::Item* i, RegionView { DEBUG_TRACE (DEBUG::Drags, "New RegionRippleDrag\n"); // compute length of selection - RegionSelection selected_regions = _editor->selection->regions; + RegionSelection selected_regions = _editor->get_selection().regions; selection_length = selected_regions.start_time().distance (selected_regions.end_time()); // Rippling accross tracks disabled. Rippling on all tracks is the way to go in the future. @@ -2468,7 +2468,7 @@ RegionRippleDrag::motion (GdkEvent* event, bool first_move) tv->playlist()->ripple (where, amount+adjust, exclude); // add regions after point where drag entered this track to subsequent ripples - add_all_after_to_views (tv, where, _editor->selection->regions, true); + add_all_after_to_views (tv, where, _editor->get_selection().regions, true); } else { // motion on same track diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index c751590901..51290b1e69 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -302,7 +302,7 @@ protected: bool _x_constrained; ///< true if x motion is constrained, otherwise false bool _y_constrained; ///< true if y motion is constrained, otherwise false bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false - ARDOUR::samplepos_t _earliest_time_limit; ///< time we cannot drag before (defaults to 0, indicating no such limit) + ARDOUR::timepos_t _earliest_time_limit; ///< time we cannot drag before (defaults to 0, indicating no such limit) private: bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 529ded4c92..65a46f6b98 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -471,17 +471,16 @@ Editor::LocationMarkers::~LocationMarkers () } void -Editor::get_markers_to_ripple (boost::shared_ptr target_playlist, samplepos_t pos, std::vector& markers) +Editor::get_markers_to_ripple (boost::shared_ptr target_playlist, timepos_t const & pos, std::vector& markers) { - - pos = effective_ripple_mark_start (target_playlist, pos); + const timepos_t ripple_start = effective_ripple_mark_start (target_playlist, pos); for (LocationMarkerMap::const_iterator i = location_markers.begin(); i != location_markers.end(); ++i) { - if (i->first->start() >= pos) { + if (i->first->start() >= ripple_start) { cerr << "Add markers for " << i->first->name() << endl; markers.push_back (i->second->start); } - if (i->first->end() >= pos && i->second->end) { + if (i->first->end() >= ripple_start && i->second->end) { markers.push_back (i->second->end); } } diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 2fb22bc926..67289569c8 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -2253,7 +2253,7 @@ Editor::add_location_from_selection () void Editor::add_location_mark (timepos_t const & where) { - if (_session->locations()->mark_at (where, 1)) { + if (_session->locations()->mark_at (where, timecnt_t (1))) { return; } @@ -4822,7 +4822,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) case Cut: _xx = RegionFactory::create (r, false); - npl->add_region (_xx, r->position() - first_position); + npl->add_region (_xx, timepos_t (first_position.distance (r->position()))); pl->remove_region (r); if (should_ripple()) { do_ripple (pl, r->position(), -r->length(), boost::shared_ptr(), false); @@ -9216,7 +9216,7 @@ Editor::should_ripple () const } void -Editor::do_ripple (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance, boost::shared_ptr exclude, bool add_to_command) +Editor::do_ripple (boost::shared_ptr target_playlist, timepos_t const & at, timecnt_t const & distance, boost::shared_ptr exclude, bool add_to_command) { RegionList el; if (exclude) { @@ -9226,7 +9226,7 @@ Editor::do_ripple (boost::shared_ptr target_playlist, samplepo } void -Editor::do_ripple (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance, RegionList* exclude, bool add_to_command) +Editor::do_ripple (boost::shared_ptr target_playlist, timepos_t const & at, timecnt_t const & distance, RegionList* exclude, bool add_to_command) { typedef std::set > UniquePlaylists; UniquePlaylists playlists; @@ -9301,8 +9301,8 @@ Editor::do_ripple (boost::shared_ptr target_playlist, samplepos_t at, ripple_marks (target_playlist, at, distance); } -samplepos_t -Editor::effective_ripple_mark_start (boost::shared_ptr target_playlist, samplepos_t pos) +timepos_t +Editor::effective_ripple_mark_start (boost::shared_ptr target_playlist, timepos_t pos) { /* in the target playlist, find the region before the target * (implicitly given by @param at. Allow all markers that occur between @@ -9311,24 +9311,24 @@ Editor::effective_ripple_mark_start (boost::shared_ptr target_playlist */ boost::shared_ptr rl = target_playlist->region_list(); - samplepos_t last_region_end_before_at = 0; + timepos_t last_region_end_before_at (pos.time_domain()); for (RegionList::const_iterator r = rl->begin(); r != rl->end(); ++r) { - samplepos_t region_end = (*r)->position() + (*r)->length(); + timepos_t region_end = (*r)->end(); if (region_end > last_region_end_before_at && region_end < pos) { last_region_end_before_at = region_end; } } if (last_region_end_before_at < pos) { - pos = last_region_end_before_at + 1; + pos = last_region_end_before_at.increment(); } return pos; } void -Editor::ripple_marks (boost::shared_ptr target_playlist, samplepos_t at, samplecnt_t distance) +Editor::ripple_marks (boost::shared_ptr target_playlist, timepos_t at, timecnt_t const & distance) { at = effective_ripple_mark_start (target_playlist, at); diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 299d271b0d..bee6852635 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -2261,7 +2261,7 @@ Editor::select_all_selectables_between (bool within) } void -Editor::get_regionviews_at_or_after (samplepos_t pos, RegionSelection& regions) +Editor::get_regionviews_at_or_after (timepos_t const & pos, RegionSelection& regions) { for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) { (*iter)->get_regionviews_at_or_after (pos, regions); diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index a0159c7828..003ba8d719 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -507,7 +507,7 @@ MidiStreamView::setup_rec_box () */ region->set_start (timepos_t (_trackview.track()->current_capture_start() - _trackview.track()->get_capture_start_sample (0))); - region->set_position (_trackview.track()->current_capture_start ()); + region->set_position (timepos_t (_trackview.track()->current_capture_start ())); RegionView* rv = add_region_view_internal (region, false, true); MidiRegionView* mrv = dynamic_cast (rv); diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index d809b60bbd..bd6ab9e728 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1176,7 +1176,7 @@ RouteTimeAxisView::get_inverted_selectables (Selection& sel, list& } void -RouteTimeAxisView::get_regionviews_at_or_after (samplepos_t pos, RegionSelection& regions) +RouteTimeAxisView::get_regionviews_at_or_after (timepos_t const & pos, RegionSelection& regions) { if (!_view) { return; diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 5a253c86fc..f973b9ac24 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -102,7 +102,7 @@ public: void set_selected_regionviews (RegionSelection&); void get_selectables (Temporal::timepos_t const &, Temporal::timepos_t const &, double top, double bot, std::list&, bool within = false); void get_inverted_selectables (Selection&, std::list&); - void get_regionviews_at_or_after (ARDOUR::samplepos_t, RegionSelection&); + void get_regionviews_at_or_after (Temporal::timepos_t const &, RegionSelection&); void set_layer_display (LayerDisplay d); void toggle_layer_display (); LayerDisplay layer_display () const; diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index b87b141260..d1ddc02a07 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -602,7 +602,7 @@ StreamView::get_inverted_selectables (Selection& sel, list& results } void -StreamView::get_regionviews_at_or_after (samplepos_t pos, RegionSelection& regions) +StreamView::get_regionviews_at_or_after (timepos_t const & pos, RegionSelection& regions) { for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { if ((*i)->region()->position() >= pos) { diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 4308825b43..2a9020e563 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -106,7 +106,7 @@ public: void set_selected_regionviews (RegionSelection&); void get_selectables (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list&, bool within = false); void get_inverted_selectables (Selection&, std::list& results); - void get_regionviews_at_or_after (ARDOUR::samplepos_t, RegionSelection&); + void get_regionviews_at_or_after (Temporal::timepos_t const &, RegionSelection&); virtual void update_contents_metrics(boost::shared_ptr) {} diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index 729a72ca83..51e4a8843c 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -211,7 +211,7 @@ public: virtual void get_selectables (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list&, bool within = false); virtual void get_inverted_selectables (Selection&, std::list& results); - virtual void get_regionviews_at_or_after (ARDOUR::samplepos_t, RegionSelection&) {} + virtual void get_regionviews_at_or_after (Temporal::timepos_t const &, RegionSelection&) {} void add_ghost (RegionView*); void remove_ghost (RegionView*);