closing in on a genuinely general scheme for handling route RT changes, now accomoda...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 8 Dec 2009 01:52:49 +0000 (01:52 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 8 Dec 2009 01:52:49 +0000 (01:52 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6326 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h

index ba706242fabef4946dd3697e83dd0b0370514328..9a849257a29503150e4078e8156514175dd6daed 100644 (file)
@@ -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;
+}
 
+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);
+}
 
-       check_rec_enable_sensitivity ();
+void
+RouteUI::queue_route_group_op (RouteGroup::Property prop, void (Session::*session_method)(boost::shared_ptr<RouteList>, bool), bool yn)
+{
+       RouteGroup* rg = _route->route_group();
+       bool prop_was_active;
 
-       cmd->mark();
-       undo->add_command(cmd);
+       if (rg) {
+               prop_was_active = rg->active_property (prop);
+               rg->set_property (prop, true);
+       } else {
+               prop_was_active = false;
+       }
 
-       _session.finish_reversible_command (*undo);
+       /* 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<RouteList> 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<RouteList> 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
index e71864ab2022ba8f277f17a740faba40862da9d8..275366cbe6804eff3346e211271eaca43848d063 100644 (file)
@@ -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<ARDOUR::RouteList>, 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__ */