From 90f95df20707995e267bd624b28980cfd9200bed Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 8 Dec 2009 01:52:49 +0000 Subject: [PATCH] closing in on a genuinely general scheme for handling route RT changes, now accomodating per-track, route-group override, natural route group and "all" rec-enable operations. still no sight of solo or mute ops git-svn-id: svn://localhost/ardour2/branches/3.0@6326 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/route_ui.cc | 72 +++++++++++++++++++++++++++++++---------- gtk2_ardour/route_ui.h | 6 +++- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index ba706242fa..9a849257a2 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -453,18 +453,49 @@ RouteUI::solo_release(GdkEventButton*) } void -RouteUI::post_rec_cleanup (SessionEvent* ev, UndoTransaction* undo, Session::GlobalRecordEnableStateCommand* cmd) +RouteUI::post_rtop_cleanup (SessionEvent* ev) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &RouteUI::post_rec_cleanup), ev, undo, cmd)); - + ENSURE_GUI_THREAD (bind (mem_fun (*this, &RouteUI::post_rtop_cleanup), ev)); delete ev; +} - check_rec_enable_sensitivity (); +void +RouteUI::post_group_rtop_cleanup (SessionEvent* ev, RouteGroup* rg, RouteGroup::Property prop) +{ + ENSURE_GUI_THREAD (bind (mem_fun (*this, &RouteUI::post_group_rtop_cleanup), ev, rg, prop)); + delete ev; + rg->set_property (prop, false); +} - cmd->mark(); - undo->add_command(cmd); +void +RouteUI::queue_route_group_op (RouteGroup::Property prop, void (Session::*session_method)(boost::shared_ptr, bool), bool yn) +{ + RouteGroup* rg = _route->route_group(); + bool prop_was_active; - _session.finish_reversible_command (*undo); + if (rg) { + prop_was_active = rg->active_property (prop); + rg->set_property (prop, true); + } else { + prop_was_active = false; + } + + /* we will queue the op for just this route, but because its route group now has the relevant property marked active, + the operation will apply to the whole group (if there is a group) + */ + + boost::shared_ptr rl (new RouteList); + rl->push_back (route()); + + SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); + ev->rt_slot = bind (sigc::mem_fun (_session, session_method), rl, yn); + if (rg && !prop_was_active) { + ev->rt_return = bind (sigc::mem_fun (*this, &RouteUI::post_group_rtop_cleanup), rg, prop); + } else { + ev->rt_return = sigc::mem_fun (*this, &RouteUI::post_rtop_cleanup); + } + + _session.queue_event (ev); } bool @@ -489,30 +520,35 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - UndoTransaction* undo = _session.start_reversible_command (_("rec-enable change")); - Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(_session, this); - SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); ev->rt_slot = bind (sigc::mem_fun (_session, &Session::set_all_record_enable), _session.get_routes(), !rec_enable_button->get_active()); - ev->rt_return = bind (sigc::mem_fun (*this, &RouteUI::post_rec_cleanup), undo, cmd); - + ev->rt_return = sigc::mem_fun (*this, &RouteUI::post_rtop_cleanup); + _session.queue_event (ev); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - /* Primary-button1 applies change to the mix group. + /* Primary-button1 applies change to the route group (even if it is not active) NOTE: Primary-button2 is MIDI learn. */ - - set_route_group_rec_enable (_route, !_route->record_enabled()); + + if (ev->button == 1) { + queue_route_group_op (RouteGroup::RecEnable, &Session::set_all_record_enable, !rec_enable_button->get_active()); + } } else if (Keyboard::is_context_menu_event (ev)) { /* do this on release */ } else { - reversibly_apply_track_boolean ("rec-enable change", &Track::set_record_enable, !track()->record_enabled(), this); - check_rec_enable_sensitivity (); + boost::shared_ptr rl (new RouteList); + rl->push_back (route()); + + SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); + ev->rt_slot = bind (sigc::mem_fun (_session, &Session::set_all_record_enable), rl, !rec_enable_button->get_active()); + ev->rt_return = sigc::mem_fun (*this, &RouteUI::post_rtop_cleanup); + + _session.queue_event (ev); } } @@ -827,6 +863,8 @@ RouteUI::update_rec_display () } else { rec_enable_button->set_visual_state (0); } + + check_rec_enable_sensitivity (); } void diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index e71864ab20..275366cbe6 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -28,6 +28,7 @@ #include "ardour/session_event.h" #include "ardour/session.h" #include "ardour/route.h" +#include "ardour/route_group.h" #include "ardour/track.h" #include "axis_view.h" @@ -207,12 +208,15 @@ class RouteUI : public virtual AxisView void init (); void reset (); + void queue_route_group_op (ARDOUR::RouteGroup::Property prop, void (ARDOUR::Session::*session_method)(boost::shared_ptr, bool), bool yn); + private: void check_rec_enable_sensitivity (); void parameter_changed (std::string const &); void relabel_solo_button (); - void post_rec_cleanup (ARDOUR::SessionEvent* ev, UndoTransaction* undo, ARDOUR::Session::GlobalRecordEnableStateCommand*); + void post_rtop_cleanup (ARDOUR::SessionEvent* ev); + void post_group_rtop_cleanup (ARDOUR::SessionEvent* ev, ARDOUR::RouteGroup*, ARDOUR::RouteGroup::Property); }; #endif /* __ardour_route_ui__ */