remove "Use OSC" from options menu; make OSC optional rather than a mandatory protocol
[ardour.git] / gtk2_ardour / port_group.h
1 /*
2     Copyright (C) 2002-2009 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef  __gtk_ardour_port_group_h__ 
21 #define  __gtk_ardour_port_group_h__ 
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/widget.h>
27 #include <gtkmm/checkbutton.h>
28
29 #include <ardour/data_type.h>
30
31 namespace ARDOUR {
32         class Session;
33         class IO;
34         class PortInsert;
35 }
36
37 class PortMatrix;
38
39 /// A list of port names, grouped by some aspect of their type e.g. busses, tracks, system
40 class PortGroup
41 {
42   public:
43         /** PortGroup constructor.
44          * @param n Name.
45          * @param p Port name prefix (including trailing :)
46          * @param v true if group should be visible in the UI, otherwise false.
47          */
48         PortGroup (std::string const & n, std::string const & p, bool v)
49                 : name (n), prefix (p), visible (v) {}
50
51         void add (std::string const & p);
52
53         std::string name; ///< name for the group
54         std::string prefix; ///< prefix e.g. "ardour:"
55         std::vector<std::string> ports; ///< port names
56         bool visible; ///< true if the group is visible in the UI
57 };
58
59 /// The UI for a PortGroup
60 class PortGroupUI
61 {
62   public:
63         PortGroupUI (PortMatrix&, PortGroup&);
64
65         Gtk::Widget& get_visibility_checkbutton ();
66         PortGroup& port_group () { return _port_group; }
67         void setup_visibility ();
68
69   private:
70         void port_checkbutton_toggled (Gtk::CheckButton*, int, int);
71         bool port_checkbutton_release (GdkEventButton* ev, Gtk::CheckButton* b, int r, int c);
72         void visibility_checkbutton_toggled ();
73
74         PortMatrix& _port_matrix; ///< the PortMatrix that we are working for
75         PortGroup& _port_group; ///< the PortGroup that we are representing
76         bool _ignore_check_button_toggle;
77         Gtk::CheckButton _visibility_checkbutton;
78 };
79
80 /// A list of PortGroups
81 class PortGroupList : public std::list<PortGroup*>
82 {
83   public:
84         enum Mask {
85                 BUSS = 0x1,
86                 TRACK = 0x2,
87                 SYSTEM = 0x4,
88                 OTHER = 0x8
89         };
90
91         PortGroupList (ARDOUR::Session &, ARDOUR::DataType, bool, Mask);
92
93         void refresh ();
94         int n_visible_ports () const;
95         std::string get_port_by_index (int, bool with_prefix = true) const;
96         void set_type (ARDOUR::DataType);
97         void set_offer_inputs (bool);
98         
99   private:
100         ARDOUR::Session& _session;
101         ARDOUR::DataType _type;
102         bool _offer_inputs;
103
104         PortGroup _buss;
105         PortGroup _track;
106         PortGroup _system;
107         PortGroup _other;
108 };
109
110 #endif /* __gtk_ardour_port_group_h__ */