step editing now accessed via a context menu on MIDI track rec-enable buttons. along...
[ardour.git] / libs / evoral / src / ControlList.cpp
index fb8f88ecba8ca10cdf3a69cb3ac7eee1cfed2e59..4a710cfbb063221af71d9a76c40d4d9b54f60c61 100644 (file)
@@ -167,8 +167,9 @@ ControlList::maybe_signal_changed ()
 {
        mark_dirty ();
 
-       if (_frozen)
+       if (_frozen) {
                _changed_when_thawed = true;
+       }
 }
 
 void
@@ -557,8 +558,12 @@ ControlList::mark_dirty () const
 {
        _lookup_cache.left = -1;
        _search_cache.left = -1;
-       if (_curve)
+
+       if (_curve) {
                _curve->mark_dirty();
+       }
+
+       Dirty (); /* EMIT SIGNAL */
 }
 
 void
@@ -949,10 +954,11 @@ ControlList::rt_safe_earliest_event(double start, double end, double& x, double&
 bool
 ControlList::rt_safe_earliest_event_unlocked(double start, double end, double& x, double& y, bool inclusive) const
 {
-       if (_interpolation == Discrete)
+       if (_interpolation == Discrete) {
                return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
-       else
+       } else {
                return rt_safe_earliest_event_linear_unlocked(start, end, x, y, inclusive);
+       }
 }
 
 
@@ -1014,10 +1020,11 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
        //<< ", x: " << x << ", y: " << y << ", inclusive: " << inclusive <<  ")" << endl;
 
        const_iterator length_check_iter = _events.begin();
-       if (_events.empty()) // 0 events
+       if (_events.empty()) // 0 events
                return false;
-       else if (_events.end() == ++length_check_iter) // 1 event
+        } else if (_events.end() == ++length_check_iter) { // 1 event
                return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
+        }
 
        // Hack to avoid infinitely repeating the same event
        build_search_cache_if_necessary(start, end);
@@ -1096,9 +1103,9 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
                        x = first->when + (y - first->value) / (double)slope;
                }
 
-               cerr << first->value << " @ " << first->when << " ... "
+               /*cerr << first->value << " @ " << first->when << " ... "
                                << next->value << " @ " << next->when
-                               << " = " << y << " @ " << x << endl;
+                               << " = " << y << " @ " << x << endl;*/
 
                assert(    (y >= first->value && y <= next->value)
                                || (y <= first->value && y >= next->value) );
@@ -1151,21 +1158,25 @@ ControlList::cut (iterator start, iterator end)
        return nal;
 }
 
+/** @param op 0 = cut, 1 = copy, 2 = clear */
 boost::shared_ptr<ControlList>
 ControlList::cut_copy_clear (double start, double end, int op)
 {
        boost::shared_ptr<ControlList> nal = create (_parameter);
+       
        iterator s, e;
-       ControlEvent cp (start, 0.0);
        bool changed = false;
 
        {
                Glib::Mutex::Lock lm (_lock);
 
+               /* find the first event in our list that is at or before `start' in time */
+               ControlEvent cp (start, 0.0);
                if ((s = lower_bound (_events.begin(), _events.end(), &cp, time_comparator)) == _events.end()) {
                        return nal;
                }
 
+               /* and the last that is at or after `end' */
                cp.when = end;
                e = upper_bound (_events.begin(), _events.end(), &cp, time_comparator);
 
@@ -1174,9 +1185,7 @@ ControlList::cut_copy_clear (double start, double end, int op)
                }
 
                for (iterator x = s; x != e; ) {
-                       iterator tmp;
-
-                       tmp = x;
+                       iterator tmp = x;
                        ++tmp;
 
                        changed = true;
@@ -1349,5 +1358,16 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements)
        maybe_signal_changed ();
 }
 
+void
+ControlList::set_interpolation (InterpolationStyle s)
+{
+       if (_interpolation == s) {
+               return;
+       }
+
+       _interpolation = s;
+       InterpolationChanged (s); /* EMIT SIGNAL */
+}
+
 } // namespace Evoral