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 <boost/shared_ptr.hpp>
27 #include "pbd/signals.h"
29 #include <gtkmm/widget.h>
30 #include <gtkmm/checkbutton.h>
32 #include "ardour/data_type.h"
33 #include "ardour/types.h"
45 /** A list of bundles grouped by some aspect of their type e.g. busses, tracks, system.
46 * A group has 0 or more bundles.
48 class PortGroup
: public sigc::trackable
51 PortGroup (std::string
const & n
);
54 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>, bool allow_dups
= false);
55 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
> io
);
56 void add_bundle (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
>, Gdk::Color
);
57 void remove_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
58 boost::shared_ptr
<ARDOUR::Bundle
> only_bundle ();
60 ARDOUR::ChanCount
total_channels () const;
61 boost::shared_ptr
<ARDOUR::IO
> io_from_bundle (boost::shared_ptr
<ARDOUR::Bundle
>) const;
62 void remove_duplicates ();
64 std::string name
; ///< name for the group
66 bool has_port (std::string
const &) const;
68 /** The bundle list has changed in some way; a bundle has been added or removed, or the list cleared etc. */
69 PBD::Signal0
<void> Changed
;
71 /** An individual bundle on our list has changed in some way */
72 PBD::Signal1
<void,ARDOUR::Bundle::Change
> BundleChanged
;
75 boost::shared_ptr
<ARDOUR::Bundle
> bundle
;
76 /** IO whose ports are in the bundle, or 0. This is so that we can do things like adding
77 ports to the IO from matrix editor menus. */
78 boost::weak_ptr
<ARDOUR::IO
> io
;
81 PBD::ScopedConnection changed_connection
;
83 BundleRecord (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
>, Gdk::Color
, bool has_colour
);
86 typedef std::list
<BundleRecord
*> BundleList
;
88 BundleList
const & bundles () const {
93 void bundle_changed (ARDOUR::Bundle::Change
);
94 void add_bundle_internal (boost::shared_ptr
<ARDOUR::Bundle
>, boost::shared_ptr
<ARDOUR::IO
>, bool, Gdk::Color
, bool);
99 /// A list of PortGroups
100 class PortGroupList
: public sigc::trackable
106 typedef std::vector
<boost::shared_ptr
<PortGroup
> > List
;
108 void add_group (boost::shared_ptr
<PortGroup
>);
109 void add_group_if_not_empty (boost::shared_ptr
<PortGroup
>);
110 void gather (ARDOUR::Session
*, ARDOUR::DataType
, bool, bool);
111 PortGroup::BundleList
const & bundles () const;
113 void remove_bundle (boost::shared_ptr
<ARDOUR::Bundle
>);
114 ARDOUR::ChanCount
total_channels () const;
115 uint32_t size () const {
116 return _groups
.size();
118 boost::shared_ptr
<ARDOUR::IO
> io_from_bundle (boost::shared_ptr
<ARDOUR::Bundle
>) const;
120 void suspend_signals ();
121 void resume_signals ();
123 List::const_iterator
begin () const {
124 return _groups
.begin ();
127 List::const_iterator
end () const {
128 return _groups
.end ();
133 /** The group list has changed in some way; a group has been added or removed, or the list cleared etc. */
134 PBD::Signal0
<void> Changed
;
136 /** A bundle in one of our groups has changed */
137 PBD::Signal1
<void,ARDOUR::Bundle::Change
> BundleChanged
;
140 bool port_has_prefix (std::string
const &, std::string
const &) const;
141 std::string
common_prefix (std::vector
<std::string
> const &) const;
142 std::string
common_prefix_before (std::vector
<std::string
> const &, std::string
const &) const;
143 void emit_changed ();
144 void emit_bundle_changed (ARDOUR::Bundle::Change
);
145 boost::shared_ptr
<ARDOUR::Bundle
> make_bundle_from_ports (std::vector
<std::string
> const &, ARDOUR::DataType
, bool) const;
146 void maybe_add_processor_to_list (
147 boost::weak_ptr
<ARDOUR::Processor
>, std::list
<boost::shared_ptr
<ARDOUR::IO
> > *, bool, std::set
<boost::shared_ptr
<ARDOUR::IO
> > &
149 boost::shared_ptr
<ARDOUR::Bundle
> bundle_for_type (boost::shared_ptr
<ARDOUR::Bundle
>, ARDOUR::DataType
) const;
151 mutable PortGroup::BundleList _bundles
;
153 PBD::ScopedConnectionList _bundle_changed_connections
;
154 PBD::ScopedConnectionList _changed_connections
;
155 bool _signals_suspended
;
156 bool _pending_change
;
157 ARDOUR::Bundle::Change _pending_bundle_change
;
160 #endif /* __gtk_ardour_port_group_h__ */