diff options
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/automation_line.cc | 36 | ||||
-rw-r--r-- | gtk2_ardour/automation_line.h | 10 | ||||
-rw-r--r-- | gtk2_ardour/automation_region_view.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/automation_streamview.cc | 22 | ||||
-rw-r--r-- | gtk2_ardour/automation_streamview.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/automation_time_axis.cc | 50 | ||||
-rw-r--r-- | gtk2_ardour/automation_time_axis.h | 7 |
7 files changed, 75 insertions, 52 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 82372f39e9..ed94b03355 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -67,7 +67,6 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv , _parent_group (parent) , _time_converter (converter ? (*converter) : default_converter) { - _interpolation = al->interpolation(); points_visible = false; update_pending = false; _uses_gain_mapping = false; @@ -86,7 +85,7 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv line->signal_event().connect (sigc::mem_fun (*this, &AutomationLine::event_handler)); - alist->StateChanged.connect (_state_connection, invalidator (*this), boost::bind (&AutomationLine::list_changed, this), gui_context()); + connect_to_list (); trackview.session()->register_with_memento_command_factory(alist->id(), this); @@ -95,7 +94,9 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv set_uses_gain_mapping (true); } - set_interpolation(alist->interpolation()); + interpolation_changed (alist->interpolation ()); + + connect_to_list (); } AutomationLine::~AutomationLine () @@ -122,7 +123,7 @@ AutomationLine::queue_reset () void AutomationLine::show () { - if (_interpolation != AutomationList::Discrete) { + if (alist->interpolation() != AutomationList::Discrete) { line->show(); } @@ -148,7 +149,7 @@ AutomationLine::hide () double AutomationLine::control_point_box_size () { - if (_interpolation == AutomationList::Discrete) { + if (alist->interpolation() == AutomationList::Discrete) { return max((_height*4.0) / (double)(alist->parameter().max() - alist->parameter().min()), 4.0); } @@ -470,7 +471,7 @@ AutomationLine::determine_visible_control_points (ALPoints& points) line->property_points() = line_points; - if (_visible && _interpolation != AutomationList::Discrete) { + if (_visible && alist->interpolation() != AutomationList::Discrete) { line->show(); } @@ -1117,10 +1118,11 @@ AutomationLine::change_model (AutomationList::iterator /*i*/, double /*x*/, doub } void -AutomationLine::set_list(boost::shared_ptr<ARDOUR::AutomationList> list) +AutomationLine::set_list (boost::shared_ptr<ARDOUR::AutomationList> list) { alist = list; - queue_reset(); + queue_reset (); + connect_to_list (); } void @@ -1222,13 +1224,10 @@ AutomationLine::model_to_view_coord (double& x, double& y) const x = _time_converter.to(x); } - +/** Called when our list has announced that its interpolation style has changed */ void -AutomationLine::set_interpolation(AutomationList::InterpolationStyle style) +AutomationLine::interpolation_changed (AutomationList::InterpolationStyle style) { - _interpolation = style; - alist->set_interpolation (_interpolation); - if (style == AutomationList::Discrete) { show_all_control_points(); line->hide(); @@ -1301,3 +1300,14 @@ AutomationLine::clear_always_in_view () alist->apply_to_points (*this, &AutomationLine::reset_callback); } +void +AutomationLine::connect_to_list () +{ + _list_connections.drop_connections (); + + alist->StateChanged.connect (_list_connections, invalidator (*this), boost::bind (&AutomationLine::list_changed, this), gui_context()); + + alist->InterpolationChanged.connect ( + _list_connections, invalidator (*this), boost::bind (&AutomationLine::interpolation_changed, this, _1), gui_context() + ); +} diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h index 3e0f0f4bb3..161d33a80b 100644 --- a/gtk2_ardour/automation_line.h +++ b/gtk2_ardour/automation_line.h @@ -52,6 +52,7 @@ namespace Gnome { } } +/** A GUI representation of an ARDOUR::AutomationList */ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible { public: @@ -91,8 +92,6 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible void set_line_color (uint32_t); uint32_t get_line_color() const { return _line_color; } - void set_interpolation(ARDOUR::AutomationList::InterpolationStyle style); - void show (); void hide (); void set_height (guint32); @@ -174,7 +173,6 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible void reset_callback (const Evoral::ControlList&); void list_changed (); - PBD::ScopedConnection _state_connection; virtual bool event_handler (GdkEvent*); virtual void add_model_point (ALPoints& tmp_points, double frame, double yfract); @@ -189,12 +187,12 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible std::list<double> _always_in_view; const Evoral::TimeConverter<double, ARDOUR::sframes_t>& _time_converter; - ARDOUR::AutomationList::InterpolationStyle _interpolation; void reset_line_coords (ControlPoint&); void add_visible_control_point (uint32_t, uint32_t, double, double, ARDOUR::AutomationList::iterator, uint32_t); - double control_point_box_size (); + void connect_to_list (); + void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle); struct ModelRepresentation { ARDOUR::AutomationList::iterator start; @@ -211,6 +209,8 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible void model_representation (ControlPoint&, ModelRepresentation&); + PBD::ScopedConnectionList _list_connections; + friend class AudioRegionGainLine; }; diff --git a/gtk2_ardour/automation_region_view.cc b/gtk2_ardour/automation_region_view.cc index 45bd5d770b..9f3d169dde 100644 --- a/gtk2_ardour/automation_region_view.cc +++ b/gtk2_ardour/automation_region_view.cc @@ -75,7 +75,6 @@ AutomationRegionView::create_line (boost::shared_ptr<ARDOUR::AutomationList> lis ARDOUR::EventTypeMap::instance().to_symbol(list->parameter()), trackview, *get_canvas_group(), list, &_time_converter)); _line->set_colors(); - _line->set_interpolation(list->interpolation()); _line->set_height ((uint32_t)rint(trackview.current_height() - NAME_HIGHLIGHT_SIZE)); _line->show(); _line->show_all_control_points(); diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index 006834c59d..146cdc7b89 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -237,14 +237,28 @@ AutomationStreamView::has_automation () const return false; } +/** Our parent AutomationTimeAxisView calls this when the user requests a particular + * InterpolationStyle; tell the AutomationLists in our regions. + */ void AutomationStreamView::set_interpolation (AutomationList::InterpolationStyle s) { - for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) { + for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) { AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*i); assert (arv); - if (arv->line()) { - arv->line()->set_interpolation (s); - } + arv->line()->the_list()->set_interpolation (s); + } +} + +AutomationList::InterpolationStyle +AutomationStreamView::interpolation () const +{ + if (region_views.empty()) { + return AutomationList::Linear; } + + AutomationRegionView* v = dynamic_cast<AutomationRegionView*> (region_views.front()); + assert (v); + + return v->line()->the_list()->interpolation (); } diff --git a/gtk2_ardour/automation_streamview.h b/gtk2_ardour/automation_streamview.h index 01d3435714..335d63ca7a 100644 --- a/gtk2_ardour/automation_streamview.h +++ b/gtk2_ardour/automation_streamview.h @@ -57,6 +57,7 @@ class AutomationStreamView : public StreamView bool has_automation () const; void set_interpolation (ARDOUR::AutomationList::InterpolationStyle); + ARDOUR::AutomationList::InterpolationStyle interpolation () const; private: void setup_rec_box (); diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 841ec65fb9..a7114f8ff0 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -270,7 +270,6 @@ AutomationTimeAxisView::set_automation_state (AutoState state) #endif } - cout << "_view = " << _view << "\n"; if (_view) { _view->set_automation_state (state); @@ -347,13 +346,12 @@ AutomationTimeAxisView::automation_state_changed () } } +/** The interpolation style of our AutomationList has changed, so update */ void -AutomationTimeAxisView::interpolation_changed () +AutomationTimeAxisView::interpolation_changed (AutomationList::InterpolationStyle s) { - AutomationList::InterpolationStyle style = _control->list()->interpolation(); - if (mode_line_item && mode_discrete_item) { - if (style == AutomationList::Discrete) { + if (s == AutomationList::Discrete) { mode_discrete_item->set_active(true); mode_line_item->set_active(false); } else { @@ -361,25 +359,20 @@ AutomationTimeAxisView::interpolation_changed () mode_discrete_item->set_active(false); } } - - if (_line) { - _line->set_interpolation(style); - } - - if (_view) { - _view->set_interpolation (style); - } } +/** A menu item has been selected to change our interpolation mode */ void AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style) { - _control->list()->set_interpolation(style); - if (_line) { - _line->set_interpolation(style); - } + /* Tell our view's list, if we have one, otherwise tell our own. + * Everything else will be signalled back from that. + */ + if (_view) { _view->set_interpolation (style); + } else { + _control->list()->set_interpolation (style); } } @@ -546,6 +539,9 @@ AutomationTimeAxisView::build_display_menu () /* mode menu */ + /* current interpolation state */ + AutomationList::InterpolationStyle const s = _view ? _view->interpolation() : _control->list()->interpolation (); + if (EventTypeMap::instance().is_midi_parameter(_control->parameter())) { Menu* auto_mode_menu = manage (new Menu); @@ -558,17 +554,13 @@ AutomationTimeAxisView::build_display_menu () sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation), AutomationList::Discrete))); mode_discrete_item = dynamic_cast<CheckMenuItem*>(&am_items.back()); - mode_discrete_item->set_active(_control->list()->interpolation() == AutomationList::Discrete); + mode_discrete_item->set_active (s == AutomationList::Discrete); am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind ( sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation), AutomationList::Linear))); mode_line_item = dynamic_cast<CheckMenuItem*>(&am_items.back()); - - // Set default interpolation type to linear if this isn't a (usually) discrete controller - if (EventTypeMap::instance().interpolation_of(_control->parameter()) == Evoral::ControlList::Linear) { - mode_line_item->set_active(_control->list()->interpolation() == AutomationList::Linear); - } + mode_line_item->set_active (s == AutomationList::Linear); items.push_back (MenuElem (_("Mode"), *auto_mode_menu)); } @@ -576,7 +568,7 @@ AutomationTimeAxisView::build_display_menu () /* make sure the automation menu state is correct */ automation_state_changed (); - interpolation_changed (); + interpolation_changed (s); } void @@ -834,7 +826,7 @@ void AutomationTimeAxisView::clear_lines () { _line.reset(); - automation_connection.disconnect (); + _list_connections.drop_connections (); } void @@ -844,7 +836,13 @@ AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line) assert(!_line); assert(line->the_list() == _control->list()); - _control->alist()->automation_state_changed.connect (automation_connection, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context()); + _control->alist()->automation_state_changed.connect ( + _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::automation_state_changed, this), gui_context() + ); + + _control->alist()->InterpolationChanged.connect ( + _list_connections, invalidator (*this), boost::bind (&AutomationTimeAxisView::interpolation_changed, this, _1), gui_context() + ); _line = line; //_controller = AutomationController::create(_session, line->the_list(), _control); diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 9d4802f6fc..4b21ec8533 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -116,7 +116,8 @@ class AutomationTimeAxisView : public TimeAxisView { ArdourCanvas::SimpleRect* _base_rect; boost::shared_ptr<AutomationLine> _line; - AutomationStreamView* _view; + /** AutomationStreamView if we are editing region-based automation (for MIDI), otherwise 0 */ + AutomationStreamView* _view; std::string _name; bool ignore_toggle; @@ -156,9 +157,9 @@ class AutomationTimeAxisView : public TimeAxisView { void automation_state_changed (); void set_interpolation (ARDOUR::AutomationList::InterpolationStyle); - void interpolation_changed (); + void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle); - PBD::ScopedConnection automation_connection; + PBD::ScopedConnectionList _list_connections; void update_extra_xml_shown (bool editor_shown); |