2 * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef __gtk_ardour_port_group_h__
22 #define __gtk_ardour_port_group_h__
27 #include <boost/shared_ptr.hpp>
28 #include "pbd/signals.h"
30 #include <gtkmm/widget.h>
31 #include <gtkmm/checkbutton.h>
33 #include "ardour/data_type.h"
34 #include "ardour/types.h"
46 /** A list of bundles grouped by some aspect of their type e.g. busses, tracks, system.
47 * A group has 0 or more bundles.
49 class PortGroup : public sigc::trackable
52 PortGroup (std::string const & n);
55 void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, bool allow_dups = false);
56 void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO> io);
57 void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO>, Gdk::Color);
58 void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
59 boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
61 ARDOUR::ChanCount total_channels () const;
62 boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
63 void remove_duplicates ();
65 std::string name; ///< name for the group
67 bool has_port (std::string const &) const;
69 /** The bundle list has changed in some way; a bundle has been added or removed, or the list cleared etc. */
70 PBD::Signal0<void> Changed;
72 /** An individual bundle on our list has changed in some way */
73 PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
76 boost::shared_ptr<ARDOUR::Bundle> bundle;
77 /** IO whose ports are in the bundle, or 0. This is so that we can do things like adding
78 ports to the IO from matrix editor menus. */
79 boost::weak_ptr<ARDOUR::IO> io;
82 PBD::ScopedConnection changed_connection;
84 BundleRecord (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO>, Gdk::Color, bool has_colour);
87 typedef std::list<BundleRecord*> BundleList;
89 BundleList const & bundles () const {
94 void bundle_changed (ARDOUR::Bundle::Change);
95 void add_bundle_internal (boost::shared_ptr<ARDOUR::Bundle>, boost::shared_ptr<ARDOUR::IO>, bool, Gdk::Color, bool);
100 /// A list of PortGroups
101 class PortGroupList : public sigc::trackable
107 typedef std::vector<boost::shared_ptr<PortGroup> > List;
109 void add_group (boost::shared_ptr<PortGroup>);
110 void add_group_if_not_empty (boost::shared_ptr<PortGroup>);
111 void gather (ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool);
112 PortGroup::BundleList const & bundles () const;
114 void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
115 ARDOUR::ChanCount total_channels () const;
116 uint32_t size () const {
117 return _groups.size();
119 boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
121 void suspend_signals ();
122 void resume_signals ();
124 List::const_iterator begin () const {
125 return _groups.begin ();
128 List::const_iterator end () const {
129 return _groups.end ();
134 /** The group list has changed in some way; a group has been added or removed, or the list cleared etc. */
135 PBD::Signal0<void> Changed;
137 /** A bundle in one of our groups has changed */
138 PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
141 bool port_has_prefix (std::string const &, std::string const &) const;
142 std::string common_prefix (std::vector<std::string> const &) const;
143 std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
144 void emit_changed ();
145 void emit_bundle_changed (ARDOUR::Bundle::Change);
146 boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, ARDOUR::DataType, bool, std::string const& bundle_name = std::string()) const;
147 void maybe_add_processor_to_list (boost::weak_ptr<ARDOUR::Processor>, std::list<boost::shared_ptr<ARDOUR::IO> > *, bool, std::set<boost::shared_ptr<ARDOUR::IO> > &);
149 mutable PortGroup::BundleList _bundles;
151 PBD::ScopedConnectionList _bundle_changed_connections;
152 PBD::ScopedConnectionList _changed_connections;
153 bool _signals_suspended;
154 bool _pending_change;
155 ARDOUR::Bundle::Change _pending_bundle_change;
158 #endif /* __gtk_ardour_port_group_h__ */