2 Copyright (C) 2002-2007 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 __ardour_ui_port_matrix_h__
21 #define __ardour_ui_port_matrix_h__
23 #include <gtkmm/box.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/table.h>
26 #include <gtkmm/frame.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/scrolledwindow.h>
30 #include "ardour_dialog.h"
40 /// A list of port names, grouped by some aspect of their type e.g. busses, tracks, system
44 /** PortGroup constructor.
46 * @param p Port name prefix.
47 * @param v true if group should be visible in the UI, otherwise false.
49 PortGroup (std::string const & n, std::string const & p, bool v) : name (n), prefix (p), visible (v) {}
51 void add (std::string const & p);
53 std::string name; ///< name for the group
54 std::string prefix; ///< prefix (before colon) e.g. "ardour:"
55 std::vector<std::string> ports; ///< port names
56 bool visible; ///< true if the group is visible in the UI
59 /// The UI for a PortGroup
63 PortGroupUI (PortMatrix&, PortGroup&);
65 Gtk::Widget& get_table ();
66 Gtk::Widget& get_visibility_checkbutton ();
67 std::pair<int, int> unit_size () const;
68 PortGroup& port_group () { return _port_group; }
69 void setup_visibility ();
72 void port_checkbutton_toggled (Gtk::CheckButton*, int, int);
73 void visibility_checkbutton_toggled ();
75 PortMatrix& _port_matrix; ///< the PortMatrix that we are working for
76 PortGroup& _port_group; ///< the PortGroup that we are representing
77 bool _ignore_check_button_toggle;
79 Gtk::EventBox _table_box;
80 std::vector<std::vector<Gtk::CheckButton* > > _port_checkbuttons;
81 Gtk::CheckButton _visibility_checkbutton;
84 /// A list of PortGroups
85 class PortGroupList : public std::list<PortGroup*>
95 PortGroupList (ARDOUR::Session &, ARDOUR::DataType, bool, Mask);
98 int n_visible_ports () const;
99 std::string get_port_by_index (int, bool with_prefix = true) const;
100 void set_type (ARDOUR::DataType);
101 void set_offer_inputs (bool);
104 ARDOUR::Session& _session;
105 ARDOUR::DataType _type;
115 /// A widget which provides a set of rotated text labels
116 class RotatedLabelSet : public Gtk::Widget {
118 RotatedLabelSet (PortGroupList&);
119 virtual ~RotatedLabelSet ();
121 void set_angle (int);
122 void set_base_width (int);
123 void update_visibility ();
126 virtual void on_size_request (Gtk::Requisition*);
127 virtual void on_size_allocate (Gtk::Allocation&);
128 virtual void on_realize ();
129 virtual void on_unrealize ();
130 virtual bool on_expose_event (GdkEventExpose*);
132 Glib::RefPtr<Gdk::Window> _gdk_window;
135 std::pair<int, int> setup_layout (std::string const &);
137 PortGroupList& _port_group_list; ///< list of ports to display
138 int _angle_degrees; ///< label rotation angle in degrees
139 double _angle_radians; ///< label rotation angle in radians
140 int _base_width; ///< width of labels; see set_base_width() for more details
141 Glib::RefPtr<Pango::Context> _pango_context;
142 Glib::RefPtr<Pango::Layout> _pango_layout;
143 Glib::RefPtr<Gdk::GC> _gc;
144 Gdk::Color _fg_colour;
145 Gdk::Color _bg_colour;
149 class PortMatrix : public Gtk::VBox {
151 PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool, PortGroupList::Mask);
161 sigc::signal<void, Result> Finished;
163 void set_type (ARDOUR::DataType);
164 void set_offer_inputs (bool);
166 virtual void set_state (int, std::string const &, bool) = 0;
167 virtual bool get_state (int, std::string const &) const = 0;
168 virtual uint32_t n_rows () const = 0;
169 virtual uint32_t maximum_rows () const = 0;
170 virtual uint32_t minimum_rows () const = 0;
171 virtual std::string row_name (int) const = 0;
172 virtual void add_row () = 0;
173 virtual void remove_row (int) = 0;
174 virtual std::string row_descriptor () const = 0;
183 void setup_dimensions ();
184 bool row_label_button_pressed (GdkEventButton*, int);
186 PortGroupList _port_group_list;
187 ARDOUR::DataType _type;
188 std::vector<PortGroupUI*> _port_group_ui;
189 std::vector<Gtk::EventBox*> _row_labels[2];
190 Gtk::VBox* _row_labels_vbox[2];
191 RotatedLabelSet _column_labels;
192 Gtk::HBox _overall_hbox;
193 Gtk::VBox _side_vbox[2];
194 Gtk::HBox _port_group_hbox;
195 Gtk::ScrolledWindow _scrolled_window;
196 Gtk::Label* _side_vbox_pad[2];
197 Gtk::HBox _visibility_checkbutton_box;