2 Copyright (C) 2002-2009 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 __gtk_ardour_port_group_h__
21 #define __gtk_ardour_port_group_h__
25 #include <gtkmm/widget.h>
26 #include <gtkmm/checkbutton.h>
27 #include <boost/shared_ptr.hpp>
28 #include <ardour/data_type.h>
29 #include <ardour/types.h>
38 /** A list of bundles and ports, grouped by some aspect of their
39 * type e.g. busses, tracks, system. Each group has 0 or more bundles
40 * and 0 or more ports, where the ports are not in the bundles.
42 class PortGroup : public sigc::trackable
45 PortGroup (std::string const & n);
47 void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
48 void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
49 boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
51 uint32_t total_channels () const;
53 std::string name; ///< name for the group
55 ARDOUR::BundleList const & bundles () const {
59 bool visible () const {
63 void set_visible (bool v) {
68 bool has_port (std::string const &) const;
70 sigc::signal<void> Modified;
71 sigc::signal<void, ARDOUR::Bundle::Change> BundleChanged;
74 void bundle_changed (ARDOUR::Bundle::Change);
76 ARDOUR::BundleList _bundles;
78 typedef std::map<boost::shared_ptr<ARDOUR::Bundle>, sigc::connection> ConnectionList;
79 ConnectionList _bundle_changed_connections;
81 bool _visible; ///< true if the group is visible in the UI
84 /// A list of PortGroups
85 class PortGroupList : public sigc::trackable
90 typedef std::vector<boost::shared_ptr<PortGroup> > List;
92 void add_group (boost::shared_ptr<PortGroup>);
93 void set_type (ARDOUR::DataType);
94 void gather (ARDOUR::Session &, bool);
95 ARDOUR::BundleList const & bundles () const;
97 void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
98 uint32_t total_visible_channels () const;
99 uint32_t size () const {
100 return _groups.size();
103 void suspend_signals ();
104 void resume_signals ();
106 List::const_iterator begin () const {
107 return _groups.begin();
110 List::const_iterator end () const {
111 return _groups.end();
114 sigc::signal<void> Changed;
117 bool port_has_prefix (std::string const &, std::string const &) const;
118 std::string common_prefix (std::vector<std::string> const &) const;
119 std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
120 void emit_changed ();
121 boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, bool) const;
123 ARDOUR::DataType _type;
124 mutable ARDOUR::BundleList _bundles;
126 std::vector<sigc::connection> _bundle_changed_connections;
127 bool _signals_suspended;
128 bool _pending_change;
132 class RouteBundle : public ARDOUR::Bundle
135 RouteBundle (boost::shared_ptr<ARDOUR::Bundle>);
137 void add_processor_bundle (boost::shared_ptr<ARDOUR::Bundle>);
140 void reread_component_bundles ();
142 boost::shared_ptr<ARDOUR::Bundle> _route;
143 std::vector<boost::shared_ptr<ARDOUR::Bundle> > _processor;
146 #endif /* __gtk_ardour_port_group_h__ */