Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
21 
22 #include <memory>
23 #include <set>
24 #include <vector>
25 
26 #include "pbd/stateful.h"
27 
29 #include "ardour/types.h"
30 
31 namespace ARDOUR {
32 
33 class AutomationControl;
34 class RouteGroup;
35 class Session;
36 class Stripable;
37 class VCAManager;
38 class PresentationInfo;
39 
41  public:
44 
45  bool select_stripable_and_maybe_group (std::shared_ptr<Stripable> s, SelectionOperation op, bool with_group = true, bool routes_only = true, RouteGroup* = nullptr);
46  void select_stripable_with_control (std::shared_ptr<Stripable> s, std::shared_ptr<AutomationControl>, SelectionOperation);
47 
48  void select_next_stripable (bool mixer_order, bool routes_only);
49  void select_prev_stripable (bool mixer_order, bool routes_only);
50 
52 
53  std::shared_ptr<Stripable> first_selected_stripable () const;
54 
55  bool selected (std::shared_ptr<const Stripable>) const;
56  bool selected (std::shared_ptr<const AutomationControl>) const;
57  uint32_t selected() const;
58 
60  std::shared_ptr<Stripable> stripable;
61  std::shared_ptr<AutomationControl> controllable;
62  int order;
63 
64  StripableAutomationControl (std::shared_ptr<Stripable> s, std::shared_ptr<AutomationControl> c, int o)
65  : stripable (s), controllable (c), order (o) {}
66  };
67 
68  typedef std::vector<StripableAutomationControl> StripableAutomationControls;
69 
71  void get_stripables_for_op (StripableList&, std::shared_ptr<Stripable> base, bool (RouteGroup::*group_predicate)() const) const;
72  void get_stripables_for_op (std::shared_ptr<StripableList>, std::shared_ptr<Stripable> base, bool (RouteGroup::*group_predicate)() const) const;
73 
74  XMLNode& get_state () const;
75  int set_state (const XMLNode&, int version);
76 
77  protected:
78  friend class AutomationControl;
79  void remove_control_by_id (PBD::ID const &);
80 
81  protected:
82  friend class Stripable;
83  friend class Session;
84  friend class VCAManager;
86 
87  private:
88  mutable Glib::Threads::RWLock _lock;
89  std::atomic<int> _selection_order;
90 
92 
94  SelectedStripable (std::shared_ptr<Stripable>, std::shared_ptr<AutomationControl>, int);
95  SelectedStripable (PBD::ID const & s, PBD::ID const & c, int o)
96  : stripable (s), controllable (c), order (o) {}
97 
100  int order;
101 
102  bool operator< (SelectedStripable const & other) const {
103  if (stripable == other.stripable) {
104  return controllable < other.controllable;
105  }
106  return stripable < other.stripable;
107  }
108  };
109 
110  typedef std::set<SelectedStripable> SelectedStripables;
111 
112  std::weak_ptr<ARDOUR::Stripable> _first_selected_stripable;
113 
115 
117 
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)());
122 
123  bool toggle (StripableList&, std::shared_ptr<AutomationControl>);
124  bool add (StripableList&, std::shared_ptr<AutomationControl>);
125  bool remove (StripableList&, std::shared_ptr<AutomationControl>);
126  bool set (StripableList&, std::shared_ptr<AutomationControl>, std::vector<std::shared_ptr<Stripable> > &);
127 
128  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);
129 };
130 
131 } // namespace ARDOUR
132 
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:34
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)