2 Copyright (C) 2017 Paul Davis
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.
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.
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.
20 #ifndef __ardour_selection_h__
21 #define __ardour_selection_h__
26 #include <boost/weak_ptr.hpp>
27 #include <boost/shared_ptr.hpp>
29 #include "pbd/stateful.h"
31 #include "ardour/presentation_info.h"
32 #include "ardour/types.h"
36 class AutomationControl;
41 class PresentationInfo;
43 class LIBARDOUR_API CoreSelection : public PBD::Stateful {
45 CoreSelection (Session& s);
48 void toggle (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
49 void add (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
50 void remove (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
51 void set (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
52 void set (StripableList&);
54 void select_next_stripable (bool mixer_order, bool routes_only);
55 void select_prev_stripable (bool mixer_order, bool routes_only);
56 bool select_stripable_and_maybe_group (boost::shared_ptr<Stripable> s, bool with_group, bool routes_only, RouteGroup*);
58 void clear_stripables();
60 bool selected (boost::shared_ptr<const Stripable>) const;
61 bool selected (boost::shared_ptr<const AutomationControl>) const;
62 uint32_t selected() const;
64 struct StripableAutomationControl {
65 boost::shared_ptr<Stripable> stripable;
66 boost::shared_ptr<AutomationControl> controllable;
69 StripableAutomationControl (boost::shared_ptr<Stripable> s, boost::shared_ptr<AutomationControl> c, int o)
70 : stripable (s), controllable (c), order (o) {}
73 typedef std::vector<StripableAutomationControl> StripableAutomationControls;
75 void get_stripables (StripableAutomationControls&) const;
77 XMLNode& get_state (void);
78 int set_state (const XMLNode&, int version);
81 friend class AutomationControl;
82 void remove_control_by_id (PBD::ID const &);
85 friend class Stripable;
87 friend class VCAManager;
88 void remove_stripable_by_id (PBD::ID const &);
91 mutable Glib::Threads::RWLock _lock;
95 struct SelectedStripable {
96 SelectedStripable (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>, int);
97 SelectedStripable (PBD::ID const & s, PBD::ID const & c, int o)
98 : stripable (s), controllable (c), order (o) {}
101 PBD::ID controllable;
104 bool operator< (SelectedStripable const & other) const {
105 if (stripable == other.stripable) {
106 return controllable < other.controllable;
108 return stripable < other.stripable;
112 typedef std::set<SelectedStripable> SelectedStripables;
114 SelectedStripables _stripables;
116 void send_selection_change ();
118 template<typename IterTypeCore>
119 void select_adjacent_stripable (bool mixer_order, bool routes_only,
120 IterTypeCore (StripableList::*begin_method)(),
121 IterTypeCore (StripableList::*end_method)());
124 } // namespace ARDOUR
126 #endif /* __ardour_selection_h__ */