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__
26 #include <gtkmm/widget.h>
27 #include <gtkmm/checkbutton.h>
28 #include <boost/shared_ptr.hpp>
29 #include "ardour/data_type.h"
30 #include "ardour/types.h"
43 /** A list of bundles and ports, grouped by some aspect of their
44 * type e.g. busses, tracks, system. Each group has 0 or more bundles
45 * and 0 or more ports, where the ports are not in the bundles.
47 class PortGroup
: public sigc::trackable
50 PortGroup (std::string
const & n
);
52 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
53 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
> io
);
54 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
>, Gdk::Color
);
55 void remove_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
56 boost::shared_ptr
<ARDOUR::Bundle
> only_bundle ();
58 uint32_t total_channels () const;
59 boost::shared_ptr
<ARDOUR::IO
> io_from_bundle (boost::shared_ptr
<ARDOUR::Bundle
>) const;
61 std::string name
; ///< name for the group
63 bool visible () const {
67 void set_visible (bool v
) {
72 bool has_port (std::string
const &) const;
74 sigc::signal
<void> Changed
;
75 sigc::signal
<void, ARDOUR::Bundle::Change
> BundleChanged
;
78 boost::shared_ptr
<ARDOUR::Bundle
> bundle
;
79 boost::shared_ptr
<ARDOUR::IO
> io
;
82 sigc::connection changed_connection
;
85 typedef std::list
<BundleRecord
> BundleList
;
87 BundleList
const & bundles () const {
92 void bundle_changed (ARDOUR::Bundle::Change
);
95 bool _visible
; ///< true if the group is visible in the UI
98 /// A list of PortGroups
99 class PortGroupList
: public sigc::trackable
104 typedef std::vector
<boost::shared_ptr
<PortGroup
> > List
;
106 void add_group (boost::shared_ptr
<PortGroup
>);
107 void set_type (ARDOUR::DataType
);
108 void gather (ARDOUR::Session
&, bool);
109 PortGroup::BundleList
const & bundles () const;
111 void remove_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
112 uint32_t total_visible_channels () const;
113 uint32_t size () const {
114 return _groups
.size();
116 boost::shared_ptr
<ARDOUR::IO
> io_from_bundle (boost::shared_ptr
<ARDOUR::Bundle
>) const;
118 void suspend_signals ();
119 void resume_signals ();
121 List::const_iterator
begin () const {
122 return _groups
.begin();
125 List::const_iterator
end () const {
126 return _groups
.end();
129 sigc::signal
<void> Changed
;
132 bool port_has_prefix (std::string
const &, std::string
const &) const;
133 std::string
common_prefix (std::vector
<std::string
> const &) const;
134 std::string
common_prefix_before (std::vector
<std::string
> const &, std::string
const &) const;
135 void emit_changed ();
136 boost::shared_ptr
<ARDOUR::Bundle
> make_bundle_from_ports (std::vector
<std::string
> const &, bool) const;
137 void maybe_add_processor_to_bundle (boost::weak_ptr
<ARDOUR::Processor
>, boost::shared_ptr
<RouteBundle
>, bool, std::set
<boost::shared_ptr
<ARDOUR::IO
> > &);
139 ARDOUR::DataType _type
;
140 mutable PortGroup::BundleList _bundles
;
142 std::vector
<sigc::connection
> _bundle_changed_connections
;
143 bool _signals_suspended
;
144 bool _pending_change
;
148 class RouteBundle
: public ARDOUR::Bundle
151 RouteBundle (boost::shared_ptr
<ARDOUR::Bundle
>);
153 void add_processor_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
156 void reread_component_bundles ();
158 boost::shared_ptr
<ARDOUR::Bundle
> _route
;
159 std::vector
<boost::shared_ptr
<ARDOUR::Bundle
> > _processor
;
162 #endif /* __gtk_ardour_port_group_h__ */