diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2015-07-16 16:13:24 -0500 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2015-07-16 16:13:24 -0500 |
commit | 46c83693284ece4a732d26e62113ea4ac584d539 (patch) | |
tree | 6e191e809b84b1c4d2aa36af6e8878996a109332 /libs | |
parent | edce75973c076ab1fa66cc6d601a30fcbbcd5dd4 (diff) | |
parent | d9c0aa4236796d981a5d939bbc5d0d5a2e1910fe (diff) |
merge fix
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/automation_control.h | 1 | ||||
-rw-r--r-- | libs/ardour/automation_control.cc | 27 | ||||
-rw-r--r-- | libs/ardour/automation_list.cc | 6 | ||||
-rw-r--r-- | libs/ardour/automation_watch.cc | 2 | ||||
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 4 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 73 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/pixfader.h | 1 | ||||
-rw-r--r-- | libs/gtkmm2ext/pixfader.cc | 14 |
8 files changed, 101 insertions, 27 deletions
diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 24a9e0de3e..5d73e4aef9 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -101,6 +101,7 @@ protected: ARDOUR::Session& _session; const ParameterDescriptor _desc; + XMLNode* _before; //used for undo of touch start/stop pairs. }; diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index 21952038cf..bfb1046849 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -19,12 +19,15 @@ */ #include <iostream> - #include "ardour/automation_control.h" #include "ardour/automation_watch.h" #include "ardour/event_type_map.h" #include "ardour/session.h" +#include "pbd/memento_command.h" + +#include "i18n.h" + using namespace std; using namespace ARDOUR; using namespace PBD; @@ -85,6 +88,8 @@ AutomationControl::set_automation_state (AutoState as) } if (as == Write) { + /* get state for undo */ + _before = &alist ()->get_state (); AutomationWatch::instance().add_automation_watch (shared_from_this()); } else if (as == Touch) { if (!touching()) { @@ -113,9 +118,16 @@ AutomationControl::set_automation_style (AutoStyle as) void AutomationControl::start_touch(double when) { - if (!_list) return; + if (!_list) { + return; + } + if (!touching()) { + if (alist()->automation_state() == Touch) { + /* subtle. aligns the user value with the playback */ + set_value (get_value ()); + _before = &alist ()->get_state (); alist()->start_touch (when); if (!_desc.toggled) { AutomationWatch::instance().add_automation_watch (shared_from_this()); @@ -131,11 +143,22 @@ AutomationControl::stop_touch(bool mark, double when) if (!_list) return; if (touching()) { set_touching (false); + + if (alist()->automation_state() == Write) { + _session.begin_reversible_command (string_compose (_("write %1 automation"), name ())); + _session.add_command (new MementoCommand<AutomationList> (*alist ().get (), _before, &alist ()->get_state ())); + _session.commit_reversible_command (); + } + if (alist()->automation_state() == Touch) { alist()->stop_touch (mark, when); if (!_desc.toggled) { AutomationWatch::instance().remove_automation_watch (shared_from_this()); } + + _session.begin_reversible_command (string_compose (_("touch %1 automation"), name ())); + _session.add_command (new MementoCommand<AutomationList> (*alist ().get (), _before, &alist ()->get_state ())); + _session.commit_reversible_command (); } } } diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 7f7599f8ca..706a3330a7 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -276,7 +276,11 @@ AutomationList::state (bool full) if (_state != Write) { root->add_property ("state", auto_state_to_string (_state)); } else { - root->add_property ("state", auto_state_to_string (Off)); + if (_events.empty ()) { + root->add_property ("state", auto_state_to_string (Off)); + } else { + root->add_property ("state", auto_state_to_string (Touch)); + } } } else { /* never save anything but Off for automation state to a template */ diff --git a/libs/ardour/automation_watch.cc b/libs/ardour/automation_watch.cc index 4e833fceb5..3714f17502 100644 --- a/libs/ardour/automation_watch.cc +++ b/libs/ardour/automation_watch.cc @@ -128,7 +128,7 @@ AutomationWatch::timer () (*aw)->list()->add (time, (*aw)->user_double(), true); } } - } else { //transport stopped or reversed. stop the automation pass and start a new one (for bonus points, someday store the previous pass in an undo record) + } else if (time != _last_time) { //transport stopped or reversed. stop the automation pass and start a new one (for bonus points, someday store the previous pass in an undo record) for (AutomationWatches::iterator aw = automation_watches.begin(); aw != automation_watches.end(); ++aw) { DEBUG_TRACE (DEBUG::Automation, string_compose ("%1: transport in rewind, speed %2, in write pass ? %3 writing ? %4\n", (*aw)->name(), _session->transport_speed(), _session->transport_rolling(), diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 7a828264bd..82868cd24c 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -124,8 +124,8 @@ public: void slide (iterator before, double distance); void shift (double before, double distance); - virtual void add (double when, double value, bool with_guards=true, bool with_default=true); - virtual void editor_add (double when, double value); + virtual void add (double when, double value, bool with_guards=true, bool with_initial=true); + virtual void editor_add (double when, double value, bool with_guard); void fast_simple_add (double when, double value); diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index a2f3aa4f33..5118744c05 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -399,7 +399,7 @@ ControlList::add_guard_point (double when) most_recent_insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); double eval_value = unlocked_eval (insert_position); - + if (most_recent_insert_iterator == _events.end()) { DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert iterator at end, adding eval-value there %2\n", this, eval_value)); @@ -407,7 +407,7 @@ ControlList::add_guard_point (double when) /* leave insert iterator at the end */ } else if ((*most_recent_insert_iterator)->when == when) { - + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert iterator at existing point, setting eval-value there %2\n", this, eval_value)); /* most_recent_insert_iterator points to a control event @@ -415,15 +415,15 @@ ControlList::add_guard_point (double when) nothing to do. ... except ... - + advance most_recent_insert_iterator so that the "real" insert occurs in the right place, since it points to the control event just inserted. */ - + ++most_recent_insert_iterator; } else { - + /* insert a new control event at the right spot */ @@ -431,7 +431,7 @@ ControlList::add_guard_point (double when) this, eval_value, (*most_recent_insert_iterator)->when)); most_recent_insert_iterator = _events.insert (most_recent_insert_iterator, new ControlEvent (when, eval_value)); - + /* advance most_recent_insert_iterator so that the "real" * insert occurs in the right place, since it * points to the control event just inserted. @@ -452,7 +452,7 @@ ControlList::in_write_pass () const } void -ControlList::editor_add (double when, double value) +ControlList::editor_add (double when, double value, bool with_guard) { /* this is for making changes from a graphical line editor */ @@ -464,11 +464,19 @@ ControlList::editor_add (double when, double value) */ if (when >= 1) { - _events.insert (_events.end(), new ControlEvent (0, _default_value)); - DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _default_value)); + _events.insert (_events.end(), new ControlEvent (0, value)); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added value %2 at zero\n", this, value)); } } + insert_position = when; + if (with_guard) { + if (when > 64) { + add_guard_point (when - 64); + } + maybe_add_insert_guard (when); + } + ControlEvent cp (when, 0.0f); iterator i = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); DEBUG_TRACE (DEBUG::ControlList, string_compose ("editor_add: actually add when= %1 value= %2\n", when, value)); @@ -491,9 +499,9 @@ ControlList::maybe_add_insert_guard (double when) new control point so that our insert will happen correctly. */ most_recent_insert_iterator = _events.insert ( most_recent_insert_iterator, - new ControlEvent (when + 1, (*most_recent_insert_iterator)->value)); + new ControlEvent (when + 64, (*most_recent_insert_iterator)->value)); DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added insert guard point @ %2 = %3\n", - this, when+1, + this, when + 64, (*most_recent_insert_iterator)->value)); } } @@ -546,7 +554,7 @@ ControlList::erase_from_iterator_to (iterator iter, double when) } void -ControlList::add (double when, double value, bool with_guards, bool with_default) +ControlList::add (double when, double value, bool with_guards, bool with_initial) { /* this is for making changes from some kind of user interface or control surface (GUI, MIDI, OSC etc) @@ -561,12 +569,12 @@ ControlList::add (double when, double value, bool with_guards, bool with_default ControlEvent cp (when, 0.0f); iterator insertion_point; - if (_events.empty() && with_default) { + if (_events.empty() && with_initial) { /* empty: add an "anchor" point if the point we're adding past time 0 */ if (when >= 1) { - _events.insert (_events.end(), new ControlEvent (0, _default_value)); + _events.insert (_events.end(), new ControlEvent (0, value)); DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _default_value)); } } @@ -628,10 +636,10 @@ ControlList::add (double when, double value, bool with_guards, bool with_default if ((*most_recent_insert_iterator)->value != value) { DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 reset existing point to new value %2\n", this, value)); - /* only one point allowed per time point, so just - * reset the value here. + /* only one point allowed per time point, so add a guard point + * before it if needed then reset the value of the point. */ - + (*most_recent_insert_iterator)->value = value; /* if we modified the final value, then its as @@ -649,10 +657,35 @@ ControlList::add (double when, double value, bool with_guards, bool with_default } else { DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert new point at %2 at iterator at %3\n", this, when, (*most_recent_insert_iterator)->when)); - - const bool done = maybe_insert_straight_line (when, value); + bool done = false; + /* check for possible straight line here until maybe_insert_straight_line () handles the insert iterator properly*/ + if (most_recent_insert_iterator != _events.begin ()) { + bool have_point2 = false; + --most_recent_insert_iterator; + const bool have_point1 = (*most_recent_insert_iterator)->value == value; + + if (most_recent_insert_iterator != _events.begin ()) { + --most_recent_insert_iterator; + have_point2 = (*most_recent_insert_iterator)->value == value; + ++most_recent_insert_iterator; + } + + if (have_point1 && have_point2) { + (*most_recent_insert_iterator)->when = when; + done = true; + } else { + ++most_recent_insert_iterator; + } + } + //done = maybe_insert_straight_line (when, value) || done; + /* if the transport is stopped, add guard points (?) */ + if (!done && !_in_write_pass && when > 64) { + add_guard_point (when - 64); + maybe_add_insert_guard (when); + } + if (with_guards) { - maybe_add_insert_guard(when); + maybe_add_insert_guard (when); } if (!done) { diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index f137a4ed65..0a316340b4 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -58,6 +58,7 @@ class LIBGTKMM2EXT_API PixFader : public CairoWidget void on_size_allocate (Gtk::Allocation& alloc); void render (cairo_t *, cairo_rectangle_t*); + bool on_grab_broken_event (GdkEventGrabBroken*); bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); bool on_motion_notify_event (GdkEventMotion*); diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc index b140d7b56b..1e814fd147 100644 --- a/libs/gtkmm2ext/pixfader.cc +++ b/libs/gtkmm2ext/pixfader.cc @@ -71,7 +71,7 @@ PixFader::PixFader (Gtk::Adjustment& adj, int orientation, int fader_length, int _adjustment.signal_value_changed().connect (mem_fun (*this, &PixFader::adjustment_changed)); _adjustment.signal_changed().connect (mem_fun (*this, &PixFader::adjustment_changed)); - + signal_grab_broken_event ().connect (mem_fun (*this, &PixFader::on_grab_broken_event)); if (_orien == VERT) { CairoWidget::set_size_request(_girth, _span); } else { @@ -366,6 +366,18 @@ PixFader::on_size_allocate (Gtk::Allocation& alloc) } bool +PixFader::on_grab_broken_event (GdkEventGrabBroken* ev) +{ + if (_dragging) { + remove_modal_grab(); + _dragging = false; + gdk_pointer_ungrab (GDK_CURRENT_TIME); + StopGesture (); + } + return (_tweaks & NoButtonForward) ? true : false; +} + +bool PixFader::on_button_press_event (GdkEventButton* ev) { if (ev->type != GDK_BUTTON_PRESS) { |