changes required by fixing ambiguities in timepos_t/timecnt_t API (GUI edition)

This commit is contained in:
Paul Davis 2020-12-03 21:34:48 -07:00
parent 65aa619e58
commit cce695d33a
8 changed files with 30 additions and 28 deletions

View File

@ -355,7 +355,7 @@ Editor::do_import (vector<string> paths,
boost::shared_ptr<Track> track;
vector<string> to_import;
int nth = 0;
bool use_timestamp = (pos == -1);
bool use_timestamp = (pos == timepos_t::max (pos.time_domain()));
std::string const& pgroup_id = Playlist::generate_pgroup_id ();
/* XXX nutempo2: we will import markers using music (beat) time, which
@ -455,7 +455,7 @@ Editor::do_import (vector<string> paths,
/* have to reset this for every file we handle */
if (use_timestamp) {
pos = -1;
pos = timepos_t::max (pos.time_domain());
}
ipw.show ();
@ -510,7 +510,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
vector<string> to_embed;
bool multi = paths.size() > 1;
int nth = 0;
bool use_timestamp = (pos == -1);
bool use_timestamp = (pos == timepos_t::max (pos.time_domain()));
std::string const& pgroup_id = Playlist::generate_pgroup_id ();
switch (import_as) {
@ -519,7 +519,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
/* have to reset this for every file we handle */
if (use_timestamp) {
pos = -1;
pos = timepos_t::max (pos.time_domain());
}
to_embed.clear ();
@ -541,7 +541,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
/* have to reset this for every file we handle */
if (use_timestamp) {
pos = -1;
pos = timepos_t::max (pos.time_domain());
}
to_embed.clear ();
@ -566,7 +566,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
/* have to reset this for every file we handle */
if (use_timestamp) {
pos = -1;
pos = timepos_t::max (pos.time_domain());
}
to_embed.clear ();
@ -806,7 +806,7 @@ Editor::add_sources (vector<string> paths,
bool use_timestamp;
vector<string> track_names;
use_timestamp = (pos == -1);
use_timestamp = (pos == timepos_t::max (pos.time_domain()));
// kludge (for MIDI we're abusing "channel" for "track" here)
if (SMFSource::safe_midi_file_extension (paths.front())) {

View File

@ -607,7 +607,7 @@ std::pair <timepos_t,timepos_t>
Editor::session_gui_extents (bool use_extra) const
{
if (!_session) {
return std::make_pair (timepos_t::max (Temporal::AudioTime), timepos_t (0));
return std::make_pair (timepos_t::max (Temporal::AudioTime), timepos_t (Temporal::AudioTime));
}
timepos_t session_extent_start (_session->current_start_sample());

View File

@ -5419,7 +5419,8 @@ RubberbandSelectDrag::do_select_things (GdkEvent* event, bool drag_in_progress)
if (!UIConfiguration::instance().get_rubberbanding_snaps_to_grid ()) {
grab = raw_grab_time ();
lpf = _editor->pixel_to_sample_from_event (last_pointer_x());
#warning NUTEMPO how can this ever use BeatTime
lpf = timepos_t (_editor->pixel_to_sample_from_event (last_pointer_x()));
}
if (grab < lpf) {
@ -6512,8 +6513,8 @@ AutomationRangeDrag::setup (list<boost::shared_ptr<AutomationLine> > const & lin
AudioRegionGainLine *argl = dynamic_cast<AudioRegionGainLine*> ((*i).get());
if (!argl) {
//in automation lanes, the EFFECTIVE range should be considered 0->max_samplepos (even if there is no line)
r.first = 0;
r.second = max_samplepos;
r.first = Temporal::timepos_t ((*i)->the_list()->time_domain());
r.second = Temporal::timepos_t::max ((*i)->the_list()->time_domain());
}
/* check this range against all the TimelineRanges that we are using */
@ -6896,7 +6897,7 @@ NoteCreateDrag::NoteCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView
, _region_view (rv)
, _drag_rect (0)
{
_note[0] = _note[1] = 0;
_note[0] = _note[1] = timepos_t (Temporal::BeatTime);
}
NoteCreateDrag::~NoteCreateDrag ()
@ -6954,9 +6955,9 @@ NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
}
}
_note[0] = grid_beats;
_note[0] = timepos_t (grid_beats);
/* minimum initial length is grid beats */
_note[1] = grid_beats + grid_beats;
_note[1] = timepos_t (grid_beats + grid_beats);
double const x0 = _editor->time_to_pixel (_note[0]);
double const x1 = _editor->time_to_pixel (_note[1]);
@ -6993,7 +6994,7 @@ NoteCreateDrag::motion (GdkEvent* event, bool)
aligned_beats += grid_beats;
}
_note[1] = max (Temporal::Beats(), aligned_beats - _region_view->region()->position ().beats());
_note[1] = timepos_t (max (Temporal::Beats(), aligned_beats - _region_view->region()->position ().beats()));
double const x0 = _editor->time_to_pixel (_note[0]);
double const x1 = _editor->time_to_pixel (_note[1]);

View File

@ -53,7 +53,7 @@ Editor::keyboard_selection_finish (bool /*add*/, Editing::EditIgnoreOption ign)
timepos_t start = selection->time.start_time();
timepos_t end;
if ((_edit_point == EditAtPlayhead) && _session->transport_rolling()) {
end = _session->audible_sample();
end = timepos_t (_session->audible_sample());
} else {
end = get_preferred_edit_position(ign);
}
@ -82,7 +82,7 @@ Editor::keyboard_selection_begin (Editing::EditIgnoreOption ign)
timepos_t start;
timepos_t end (selection->time.end_time());
if ((_edit_point == EditAtPlayhead) && _session->transport_rolling()) {
start = _session->audible_sample();
start = timepos_t (_session->audible_sample());
} else {
start = get_preferred_edit_position(ign);
}

View File

@ -1219,11 +1219,11 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir)
switch (point) {
case Start:
pos = r->first_sample ();
pos = timepos_t (r->first_sample ());
break;
case End:
pos = r->last_sample ();
pos = timepos_t (r->last_sample ());
break;
case SyncPoint:
@ -4471,7 +4471,7 @@ Editor::cut_copy_points (Editing::CutCopyOp op, timepos_t const & earliest_time)
if (earliest != timepos_t::max (earliest.time_domain())) {
if (earliest.time_domain() == Temporal::BeatTime) {
/* always just round down to beat */
earliest = earliest.beats().round_down_to_beat();
earliest = timepos_t (earliest.beats().round_down_to_beat());
} else {
/* do actual snap */
snap_to (earliest, Temporal::RoundDownMaybe);
@ -6863,7 +6863,7 @@ Editor::set_auto_punch_range ()
set_punch_range (begin, end, _("Auto Punch In/Out"));
} else {
// normal case for 2nd press - set the punch out
end = _playhead_cursor->current_sample ();
end = timepos_t (playhead_cursor->current_sample ());
set_punch_range (tpl->start(), now, _("Auto Punch In/Out"));
_session->config.set_punch_out(true);
}

View File

@ -760,8 +760,9 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
/* 1. find the last selected regionview in the track that was clicked in */
last_pos = 0;
first_pos = timepos_t::max (selection->regions.empty() ? Temporal::AudioTime : selection->regions.front()->region()->position().time_domain());
const Temporal::TimeDomain time_domain = (selection->regions.empty() ? Temporal::AudioTime : selection->regions.front()->region()->position().time_domain());
last_pos = timepos_t (time_domain);
first_pos = timepos_t::max (time_domain);
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {

View File

@ -2536,7 +2536,7 @@ MidiRegionView::move_selection(timecnt_t const & dx_qn, double dy, double cumula
/* update length */
if (midi_view()->note_mode() == Sustained) {
Note* sus = dynamic_cast<Note*> (*i);
double const len_dx = editor->time_to_pixel_unrounded (timepos_t (note_time_qn) + dx_qn + n->note()->length());
double const len_dx = editor->time_to_pixel_unrounded (timepos_t (note_time_qn) + dx_qn + timecnt_t (n->note()->length()));
sus->set_x1 (n->item()->canvas_to_item (ArdourCanvas::Duple (len_dx, 0)).x);
}
@ -2631,7 +2631,7 @@ MidiRegionView::move_copies (timecnt_t const & dx_qn, double dy, double cumulati
if (midi_view()->note_mode() == Sustained) {
Note* sus = dynamic_cast<Note*> (*i);
double const len_dx = editor->time_to_pixel_unrounded (timepos_t (note_time_qn) + dx_qn + n->note()->length());
double const len_dx = editor->time_to_pixel_unrounded (timepos_t (note_time_qn) + dx_qn + timecnt_t (n->note()->length()));
sus->set_x1 (n->item()->canvas_to_item (ArdourCanvas::Duple (len_dx, 0)).x);
}
@ -2928,7 +2928,7 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
if (with_snap) {
snapped_x = snap_pixel_to_time (current_x, ensure_snap); /* units depend on snap settings */
} else {
snapped_x = trackview.editor ().pixel_to_sample (current_x); /* samples */
snapped_x = timepos_t (trackview.editor ().pixel_to_sample (current_x)); /* probably samples */
}
Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use());
@ -3023,7 +3023,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
if (with_snap) {
current_time = snap_pixel_to_time (current_x, ensure_snap);
} else {
current_time = trackview.editor().pixel_to_sample (current_x);
current_time = timepos_t (trackview.editor().pixel_to_sample (current_x));
}
/* and then to beats */

View File

@ -41,7 +41,7 @@ StepEditor::StepEditor (PublicEditor& e, boost::shared_ptr<MidiTrack> t, MidiTim
, _track (t)
, _mtv (mtv)
{
step_edit_insert_position = 0;
step_edit_insert_position = timepos_t (Temporal::BeatTime);
_step_edit_triplet_countdown = 0;
_step_edit_within_chord = 0;
_step_edit_chord_duration = Temporal::Beats();