Exact beat - provide audio->music mapping for region split.
[ardour.git] / libs / ardour / ardour / solo_isolate_control.h
1 /*
2     Copyright (C) 2016 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify it
5     under the terms of the GNU General Public License as published by the Free
6     Software Foundation; either version 2 of the License, or (at your option)
7     any later version.
8
9     This program is distributed in the hope that it will be useful, but WITHOUT
10     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12     for more details.
13
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_solo_isolate_control_h__
20 #define __ardour_solo_isolate_control_h__
21
22 #include <string>
23
24 #include <boost/shared_ptr.hpp>
25
26 #include "ardour/slavable_automation_control.h"
27 #include "ardour/libardour_visibility.h"
28
29 class XMLNode;
30
31 namespace ARDOUR {
32
33 class Session;
34 class Soloable;
35 class Muteable;
36
37 class LIBARDOUR_API SoloIsolateControl : public SlavableAutomationControl
38 {
39   public:
40         SoloIsolateControl (Session& session, std::string const & name, Soloable& soloable, Muteable& m);
41
42         double get_value () const;
43
44         /* Export additional API so that objects that only get access
45          * to a Controllable/AutomationControl can do more fine-grained
46          * operations with respect to solo isolate. Obviously, they would need
47          * to dynamic_cast<SoloControl> first.
48          *
49          * Solo Isolate state is not representable by a single scalar value,
50          * so set_value() and get_value() is not enough.
51          *
52          * This means that the Controllable is technically
53          * asymmetric. It is possible to call ::set_value (0.0) to
54          * disable (self)solo, and then call ::get_value() and get a
55          * return of 1.0 because the control is isolated by
56          * upstream/downstream or a master.
57          */
58
59         void mod_solo_isolated_by_upstream (int32_t delta);
60
61         /* API to check different aspects of solo isolate substate
62          */
63
64         uint32_t solo_isolated_by_upstream () const {
65                 return _solo_isolated_by_upstream;
66         }
67         bool self_solo_isolated () const {
68                 return _solo_isolated;
69         }
70         bool solo_isolated() const { return self_solo_isolated() || solo_isolated_by_upstream(); }
71
72         int set_state (XMLNode const&, int);
73         XMLNode& get_state ();
74
75   protected:
76         void master_changed (bool from_self, PBD::Controllable::GroupControlDisposition gcd, boost::shared_ptr<AutomationControl>);
77         void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override);
78
79   private:
80         Soloable&      _soloable;
81         Muteable&      _muteable;
82         bool           _solo_isolated;
83         uint32_t       _solo_isolated_by_upstream;
84
85         void set_solo_isolated (bool yn, Controllable::GroupControlDisposition group_override);
86
87 };
88
89 } /* namespace */
90
91 #endif /* __libardour_solo_isolate_control_h__ */