Ardour  8.12
libs/ardour/ardour/selection.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017-2018 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_selection_h__
21 #define __ardour_selection_h__
22 
23 #include <memory>
24 #include <set>
25 #include <vector>
26 
27 #include "pbd/stateful.h"
28 
30 #include "ardour/types.h"
31 
32 namespace ARDOUR {
33 
34 class AutomationControl;
35 class RouteGroup;
36 class Session;
37 class Stripable;
38 class VCAManager;
39 class PresentationInfo;
40 
42  public:
45 
46  bool select_stripable_and_maybe_group (std::shared_ptr<Stripable> s, SelectionOperation op, bool with_group = true, bool routes_only = true, RouteGroup* = nullptr);
47  void select_stripable_with_control (std::shared_ptr<Stripable> s, std::shared_ptr<AutomationControl>, SelectionOperation);
48 
49  void select_next_stripable (bool mixer_order, bool routes_only);
50  void select_prev_stripable (bool mixer_order, bool routes_only);
51 
53 
54  std::shared_ptr<Stripable> first_selected_stripable () const;
55 
56  bool selected (std::shared_ptr<const Stripable>) const;
57  bool selected (std::shared_ptr<const AutomationControl>) const;
58  uint32_t selected() const;
59 
61  std::shared_ptr<Stripable> stripable;
62  std::shared_ptr<AutomationControl> controllable;
63  int order;
64 
65  StripableAutomationControl (std::shared_ptr<Stripable> s, std::shared_ptr<AutomationControl> c, int o)
66  : stripable (s), controllable (c), order (o) {}
67  };
68 
69  typedef std::vector<StripableAutomationControl> StripableAutomationControls;
70 
72  void get_stripables_for_op (StripableList&, std::shared_ptr<Stripable> base, bool (RouteGroup::*group_predicate)() const) const;
73  void get_stripables_for_op (std::shared_ptr<StripableList>, std::shared_ptr<Stripable> base, bool (RouteGroup::*group_predicate)() const) const;
74 
75  XMLNode& get_state () const;
76  int set_state (const XMLNode&, int version);
77 
78  protected:
79  friend class AutomationControl;
80  void remove_control_by_id (PBD::ID const &);
81 
82  protected:
83  friend class Stripable;
84  friend class Session;
85  friend class VCAManager;
87 
88  private:
89  mutable Glib::Threads::RWLock _lock;
90  std::atomic<int> _selection_order;
91 
93 
95  SelectedStripable (std::shared_ptr<Stripable>, std::shared_ptr<AutomationControl>, int);
96  SelectedStripable (PBD::ID const & s, PBD::ID const & c, int o)
97  : stripable (s), controllable (c), order (o) {}
98 
101  int order;
102 
103  bool operator< (SelectedStripable const & other) const {
104  if (stripable == other.stripable) {
105  return controllable < other.controllable;
106  }
107  return stripable < other.stripable;
108  }
109  };
110 
111  typedef std::set<SelectedStripable> SelectedStripables;
112 
113  std::weak_ptr<ARDOUR::Stripable> _first_selected_stripable;
114 
116 
118 
119  template<typename IterTypeCore>
120  void select_adjacent_stripable (bool mixer_order, bool routes_only,
121  IterTypeCore (StripableList::*begin_method)(),
122  IterTypeCore (StripableList::*end_method)());
123 
124  bool toggle (StripableList&, std::shared_ptr<AutomationControl>);
125  bool add (StripableList&, std::shared_ptr<AutomationControl>);
126  bool remove (StripableList&, std::shared_ptr<AutomationControl>);
127  bool set (StripableList&, std::shared_ptr<AutomationControl>, std::vector<std::shared_ptr<Stripable> > &);
128 
129  bool do_select (std::shared_ptr<Stripable> s, std::shared_ptr<AutomationControl> c, SelectionOperation op, bool with_group, bool routes_only, RouteGroup* not_allowed_in_group);
130 };
131 
132 } // namespace ARDOUR
133 
134 #endif /* __ardour_selection_h__ */
std::set< SelectedStripable > SelectedStripables
bool select_stripable_and_maybe_group(std::shared_ptr< Stripable > s, SelectionOperation op, bool with_group=true, bool routes_only=true, RouteGroup *=nullptr)
bool toggle(StripableList &, std::shared_ptr< AutomationControl >)
void select_stripable_with_control(std::shared_ptr< Stripable > s, std::shared_ptr< AutomationControl >, SelectionOperation)
void select_next_stripable(bool mixer_order, bool routes_only)
void get_stripables_for_op(std::shared_ptr< StripableList >, std::shared_ptr< Stripable > base, bool(RouteGroup::*group_predicate)() const) const
void select_adjacent_stripable(bool mixer_order, bool routes_only, IterTypeCore(StripableList::*begin_method)(), IterTypeCore(StripableList::*end_method)())
bool set(StripableList &, std::shared_ptr< AutomationControl >, std::vector< std::shared_ptr< Stripable > > &)
std::vector< StripableAutomationControl > StripableAutomationControls
XMLNode & get_state() const
void get_stripables_for_op(StripableList &, std::shared_ptr< Stripable > base, bool(RouteGroup::*group_predicate)() const) const
bool add(StripableList &, std::shared_ptr< AutomationControl >)
bool remove(StripableList &, std::shared_ptr< AutomationControl >)
int set_state(const XMLNode &, int version)
void remove_control_by_id(PBD::ID const &)
void select_prev_stripable(bool mixer_order, bool routes_only)
void remove_stripable_by_id(PBD::ID const &)
uint32_t selected() const
bool selected(std::shared_ptr< const Stripable >) const
bool do_select(std::shared_ptr< Stripable > s, std::shared_ptr< AutomationControl > c, SelectionOperation op, bool with_group, bool routes_only, RouteGroup *not_allowed_in_group)
std::weak_ptr< ARDOUR::Stripable > _first_selected_stripable
bool selected(std::shared_ptr< const AutomationControl >) const
CoreSelection(Session &s)
void get_stripables(StripableAutomationControls &) const
std::shared_ptr< Stripable > first_selected_stripable() const
Definition: id.h:35
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< uint32_t > order
std::list< std::shared_ptr< Stripable > > StripableList
SelectedStripable(std::shared_ptr< Stripable >, std::shared_ptr< AutomationControl >, int)
SelectedStripable(PBD::ID const &s, PBD::ID const &c, int o)
StripableAutomationControl(std::shared_ptr< Stripable > s, std::shared_ptr< AutomationControl > c, int o)