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 constructor.
47 * @param v true if group should be visible in the UI, otherwise false.
49 PortGroup (std::string const & n, bool v)
50 : name (n), _visible (v) {}
52 void add_bundle (boost::shared_ptr<ARDOUR::Bundle>);
53 boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
54 void add_port (std::string const &);
57 std::string name; ///< name for the group
58 std::vector<std::string> ports;
60 ARDOUR::BundleList const & bundles () const {
64 bool visible () const {
68 void set_visible (bool v) {
73 bool has_port (std::string const &) const;
75 sigc::signal<void> VisibilityChanged;
78 ARDOUR::BundleList _bundles;
79 bool _visible; ///< true if the group is visible in the UI
82 /// The UI for a PortGroup
86 PortGroupUI (PortMatrix*, PortGroup*);
88 Gtk::Widget& visibility_checkbutton () {
89 return _visibility_checkbutton;
93 void visibility_checkbutton_toggled ();
94 void setup_visibility_checkbutton ();
96 PortMatrix* _port_matrix; ///< the PortMatrix that we are working for
97 PortGroup* _port_group; ///< the PortGroup that we are representing
98 Gtk::CheckButton _visibility_checkbutton;
101 /// A list of PortGroups
102 class PortGroupList : public std::list<PortGroup*>, public sigc::trackable
105 PortGroupList (ARDOUR::DataType, bool);
107 void gather (ARDOUR::Session &);
108 void set_type (ARDOUR::DataType);
109 void set_offer_inputs (bool);
110 ARDOUR::BundleList const & bundles () const;
111 void take_visibility_from (PortGroupList const &);
114 sigc::signal<void> VisibilityChanged;
117 bool port_has_prefix (std::string const &, std::string const &) const;
118 std::string common_prefix (std::vector<std::string> const &) const;
119 void visibility_changed ();
120 void update_bundles () const;
122 ARDOUR::DataType _type;
124 mutable ARDOUR::BundleList _bundles;
125 mutable bool _bundles_dirty;
132 std::vector<sigc::connection> _visibility_connections;
135 #endif /* __gtk_ardour_port_group_h__ */