13
0

fix selectability of region-associated automation (i.e. MIDI)

The fix here is really just dropping the use of _offset when computing the session position
of a control point. This was just an arithmetical error.

However, session_sample_position() was redundant and just caused more work, so this
method was removed, and only ::session_position() is now used.

In addition, several closely related places now use C++11 (or later) "auto"
syntax for iterating over containers, for cleaner looking code
This commit is contained in:
Paul Davis 2022-08-11 13:36:46 -06:00
parent 9327027d98
commit 373a73cb51
3 changed files with 14 additions and 19 deletions

View File

@ -910,12 +910,12 @@ AutomationLine::get_selectables (timepos_t const & start, timepos_t const & end,
double const bot_track = (1 - topfrac) * trackview.current_height ();
double const top_track = (1 - botfrac) * trackview.current_height ();
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
for (auto const & cp : control_points) {
timepos_t const session_samples_when = timepos_t (session_sample_position ((*i)->model()));
const timepos_t w = session_position ((*cp->model())->when);
if (session_samples_when >= start && session_samples_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) {
results.push_back (*i);
if (w >= start && w <= end && cp->get_y() >= bot_track && cp->get_y() <= top_track) {
results.push_back (cp);
}
}
}
@ -1024,6 +1024,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events)
ty = _height - (ty * _height);
add_visible_control_point (vp, pi, px, ty, ai, np);
vp++;
}
@ -1353,24 +1354,19 @@ AutomationLine::get_point_x_range () const
{
pair<timepos_t, timepos_t> r (timepos_t::max (the_list()->time_domain()), timepos_t::zero (the_list()->time_domain()));
for (AutomationList::const_iterator i = the_list()->begin(); i != the_list()->end(); ++i) {
r.first = min (r.first, session_position (i));
r.second = max (r.second, session_position (i));
for (auto const & cp : *the_list()) {
const timepos_t w (session_position (cp->when));
r.first = min (r.first, w);
r.second = max (r.second, w);
}
return r;
}
samplepos_t
AutomationLine::session_sample_position (AutomationList::const_iterator p) const
{
return (*p)->when.samples() + _offset.samples() + get_origin().samples();
}
timepos_t
AutomationLine::session_position (AutomationList::const_iterator p) const
AutomationLine::session_position (timepos_t const & when) const
{
return (*p)->when + _offset + get_origin();
return when + get_origin();
}
void

View File

@ -161,8 +161,7 @@ public:
Temporal::timepos_t offset () { return _offset; }
void set_width (Temporal::timecnt_t const &);
samplepos_t session_sample_position (ARDOUR::AutomationList::const_iterator) const;
Temporal::timepos_t session_position (ARDOUR::AutomationList::const_iterator) const;
Temporal::timepos_t session_position (Temporal::timepos_t const &) const;
protected:

View File

@ -284,8 +284,8 @@ TimeInfoBox::selection_changed ()
} else {
s = timepos_t::max (selection.points.front()->line().the_list()->time_domain());
e = timepos_t::zero (s.time_domain());
for (PointSelection::iterator i = selection.points.begin(); i != selection.points.end(); ++i) {
timepos_t const p = (*i)->line().session_position ((*i)->model ());
for (auto const & pt : selection.points) {
const timepos_t p = pt->line().session_position ((*pt->model ())->when);
s = min (s, p);
e = max (e, p);
}