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"
32 #include "ardour/presentation_info.h"
36 class AutomationControl;
39 class PresentationInfo;
41 class LIBARDOUR_API CoreSelection : public PBD::Stateful {
43 CoreSelection (Session& s);
46 void toggle (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
47 void add (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
48 void remove (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
49 void set (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>);
50 void clear_stripables();
52 bool selected (boost::shared_ptr<const Stripable>) const;
53 bool selected (boost::shared_ptr<const AutomationControl>) const;
54 uint32_t selected() const;
56 struct StripableAutomationControl {
57 boost::shared_ptr<Stripable> stripable;
58 boost::shared_ptr<AutomationControl> controllable;
61 StripableAutomationControl (boost::shared_ptr<Stripable> s, boost::shared_ptr<AutomationControl> c, int o)
62 : stripable (s), controllable (c), order (o) {}
65 typedef std::vector<StripableAutomationControl> StripableAutomationControls;
67 void get_stripables (StripableAutomationControls&) const;
69 XMLNode& get_state (void);
70 int set_state (const XMLNode&, int version);
73 friend class AutomationControl;
74 void remove_control_by_id (PBD::ID const &);
77 friend class Stripable;
78 void remove_stripable_by_id (PBD::ID const &);
81 mutable Glib::Threads::RWLock _lock;
85 struct SelectedStripable {
86 SelectedStripable (boost::shared_ptr<Stripable>, boost::shared_ptr<AutomationControl>, int);
87 SelectedStripable (PBD::ID const & s, PBD::ID const & c, int o)
88 : stripable (s), controllable (c), order (o) {}
94 bool operator< (SelectedStripable const & other) const {
95 if (stripable == other.stripable) {
96 return controllable < other.controllable;
98 return stripable < other.stripable;
102 typedef std::set<SelectedStripable> SelectedStripables;
104 SelectedStripables _stripables;
106 void send_selection_change ();
109 } // namespace ARDOUR
111 #endif /* __ardour_selection_h__ */