Region::_start should be a timepos_t not a timecnt_t (GUI edition)

This commit is contained in:
Paul Davis 2021-03-03 10:04:33 -07:00
parent 56cde042cd
commit 49424ab0e3
5 changed files with 20 additions and 11 deletions

View file

@ -1397,7 +1397,7 @@ AutomationLine::session_position (AutomationList::const_iterator p) const
} }
void void
AutomationLine::set_offset (timecnt_t const & off) AutomationLine::set_offset (timepos_t const & off)
{ {
if (_offset == off) { if (_offset == off) {
return; return;

View file

@ -157,8 +157,8 @@ public:
return _maximum_time; return _maximum_time;
} }
void set_offset (Temporal::timecnt_t const &); void set_offset (Temporal::timepos_t const &);
Temporal::timecnt_t offset () { return _offset; } Temporal::timepos_t offset () { return _offset; }
void set_width (Temporal::timecnt_t const &); void set_width (Temporal::timecnt_t const &);
samplepos_t session_sample_position (ARDOUR::AutomationList::const_iterator) const; samplepos_t session_sample_position (ARDOUR::AutomationList::const_iterator) const;
@ -224,7 +224,7 @@ private:
/** offset from the start of the automation list to the start of the line, so that /** offset from the start of the automation list to the start of the line, so that
* a +ve offset means that the 0 on the line is at _offset in the list * a +ve offset means that the 0 on the line is at _offset in the list
*/ */
Temporal::timecnt_t _offset; Temporal::timepos_t _offset;
bool is_stepped() const; bool is_stepped() const;
void update_visibility (); void update_visibility ();

View file

@ -6344,16 +6344,25 @@ NoteDrag::total_dx (GdkEvent * event) const
/* primary note time in quarter notes */ /* primary note time in quarter notes */
timepos_t const n_qn = _region->region()->source_beats_to_absolute_time (_primary->note()->time()); timepos_t const n_qn = _region->region()->source_beats_to_absolute_time (_primary->note()->time());
/* new session relative time of the primary note (will be in beats) */ /* new session relative time of the primary note (will be in beats)
* start from the note position, add the distance the drag has covered,
* and then the required (if any) snap distance
*/
timepos_t snap = n_qn + dx + snap_delta (event->button.state); timepos_t snap = n_qn + dx + snap_delta (event->button.state);
/* possibly snap and return corresponding delta (will be in beats) */ /* possibly snap and return corresponding delta (will be in beats) */
_editor->snap_to_with_modifier (snap, event); _editor->snap_to_with_modifier (snap, event);
timecnt_t ret = timecnt_t (snap.earlier (n_qn).earlier (snap_delta (event->button.state))); /* we are trying to return the delta on the x-axis (almost certain in
* beats), So now, having snapped etc., subtract the original note
* position and the snap delta, and we'll know the current dx.
*/
timecnt_t ret (snap.earlier (n_qn).earlier (snap_delta (event->button.state)), n_qn);
/* prevent the earliest note being dragged earlier than the region's start position */ /* prevent the earliest note being dragged earlier than the region's start position */
if (ret + _earliest < _region->region()->start()) { if (_earliest + ret < _region->region()->start()) {
ret -= (ret + _earliest) - _region->region()->start(); ret -= (ret + _earliest) - _region->region()->start();
} }

View file

@ -7286,7 +7286,7 @@ Editor::split_region_at_points (boost::shared_ptr<Region> r, AnalysisFeatureList
/* file start = original start + how far we from the initial position ? */ /* file start = original start + how far we from the initial position ? */
timecnt_t file_start = r->start() + pos; timepos_t file_start = r->start() + pos;
/* length = next position - current position */ /* length = next position - current position */
@ -8765,7 +8765,7 @@ Editor::launch_playlist_selector ()
vector<MidiRegionView*> vector<MidiRegionView*>
Editor::filter_to_unique_midi_region_views (RegionSelection const & ms) const Editor::filter_to_unique_midi_region_views (RegionSelection const & ms) const
{ {
typedef std::pair<boost::shared_ptr<MidiSource>,timecnt_t> MapEntry; typedef std::pair<boost::shared_ptr<MidiSource>,timepos_t> MapEntry;
std::set<MapEntry> single_region_set; std::set<MapEntry> single_region_set;
vector<MidiRegionView*> views; vector<MidiRegionView*> views;

View file

@ -505,8 +505,8 @@ MidiStreamView::setup_rec_box ()
/* MIDI regions should likely not be positioned using audio time, but this is /* MIDI regions should likely not be positioned using audio time, but this is
* just a rec-region, so we don't really care * just a rec-region, so we don't really care
*/ */
region->set_start (timecnt_t (_trackview.track()->current_capture_start()
- _trackview.track()->get_capture_start_sample (0))); 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 (_trackview.track()->current_capture_start ());
RegionView* rv = add_region_view_internal (region, false, true); RegionView* rv = add_region_view_internal (region, false, true);