universal change in the design of the way Route/Track controls are designed and used...
[ardour.git] / libs / ardour / session_rtevents.cc
1 /*
2     Copyright (C) 1999-2009 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include <boost/bind.hpp>
20
21 #include "pbd/error.h"
22 #include "pbd/compose.h"
23
24 #include "ardour/monitor_control.h"
25 #include "ardour/route.h"
26 #include "ardour/session.h"
27 #include "ardour/track.h"
28
29 #include "i18n.h"
30
31 using namespace std;
32 using namespace PBD;
33 using namespace ARDOUR;
34 using namespace Glib;
35
36 void
37 Session::set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
38 {
39         std::cerr << "Session::set_controls called on " << cl->size() << " controls, group = " << enum_2_string (gcd) << std::endl;
40         queue_event (get_rt_event (cl, val, gcd));
41 }
42
43 void
44 Session::set_control (boost::shared_ptr<AutomationControl> ac, double val, Controllable::GroupControlDisposition gcd)
45 {
46         boost::shared_ptr<ControlList> cl (new ControlList);
47         cl->push_back (ac);
48         set_controls (cl, val, gcd);
49 }
50
51 void
52 Session::rt_set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
53 {
54         for (ControlList::iterator c = cl->begin(); c != cl->end(); ++c) {
55                 (*c)->set_value (val, gcd);
56         }
57 }
58
59 void
60 Session::clear_all_solo_state (boost::shared_ptr<RouteList> rl)
61 {
62         queue_event (get_rt_event (rl, false, rt_cleanup, Controllable::NoGroup, &Session::rt_clear_all_solo_state));
63 }
64
65 void
66 Session::rt_clear_all_solo_state (boost::shared_ptr<RouteList> rl, bool /* yn */, Controllable::GroupControlDisposition /* group_override */)
67 {
68         for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
69                 if ((*i)->is_auditioner()) {
70                         continue;
71                 }
72                 (*i)->clear_all_solo_state();
73         }
74         set_dirty();
75 }
76
77 void
78 Session::process_rtop (SessionEvent* ev)
79 {
80         ev->rt_slot ();
81
82         if (ev->event_loop) {
83                 ev->event_loop->call_slot (MISSING_INVALIDATOR, boost::bind (ev->rt_return, ev));
84         } else {
85                 warning << string_compose ("programming error: %1", X_("Session RT event queued from thread without a UI - cleanup in RT thread!")) << endmsg;
86                 ev->rt_return (ev);
87         }
88 }