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 bool port_checkbutton_release (GdkEventButton* ev, Gtk::CheckButton* b, int r, int c);
74 void visibility_checkbutton_toggled ();
76 PortMatrix& _port_matrix; ///< the PortMatrix that we are working for
77 PortGroup& _port_group; ///< the PortGroup that we are representing
78 bool _ignore_check_button_toggle;
80 Gtk::EventBox _table_box;
81 std::vector<std::vector<Gtk::CheckButton* > > _port_checkbuttons;
82 Gtk::CheckButton _visibility_checkbutton;
85 /// A list of PortGroups
86 class PortGroupList : public std::list<PortGroup*>
96 PortGroupList (ARDOUR::Session &, ARDOUR::DataType, bool, Mask);
99 int n_visible_ports () const;
100 std::string get_port_by_index (int, bool with_prefix = true) const;
101 void set_type (ARDOUR::DataType);
102 void set_offer_inputs (bool);
105 ARDOUR::Session& _session;
106 ARDOUR::DataType _type;
116 /// A widget which provides a set of rotated text labels
117 class RotatedLabelSet : public Gtk::Widget {
119 RotatedLabelSet (PortGroupList&);
120 virtual ~RotatedLabelSet ();
122 void set_angle (int);
123 void set_base_width (int);
124 void update_visibility ();
127 virtual void on_size_request (Gtk::Requisition*);
128 virtual void on_size_allocate (Gtk::Allocation&);
129 virtual void on_realize ();
130 virtual void on_unrealize ();
131 virtual bool on_expose_event (GdkEventExpose*);
133 Glib::RefPtr<Gdk::Window> _gdk_window;
136 std::pair<int, int> setup_layout (std::string const &);
138 PortGroupList& _port_group_list; ///< list of ports to display
139 int _angle_degrees; ///< label rotation angle in degrees
140 double _angle_radians; ///< label rotation angle in radians
141 int _base_width; ///< width of labels; see set_base_width() for more details
142 Glib::RefPtr<Pango::Context> _pango_context;
143 Glib::RefPtr<Pango::Layout> _pango_layout;
144 Glib::RefPtr<Gdk::GC> _gc;
145 Gdk::Color _fg_colour;
146 Gdk::Color _bg_colour;
150 class PortMatrix : public Gtk::VBox {
152 PortMatrix (ARDOUR::Session&, ARDOUR::DataType, bool, PortGroupList::Mask);
162 sigc::signal<void, Result> Finished;
164 void set_type (ARDOUR::DataType);
165 void set_offer_inputs (bool);
166 bool offering_input() const { return _offer_inputs; }
168 virtual void set_state (int, std::string const &, bool, uint32_t) = 0;
169 virtual bool get_state (int, std::string const &) const = 0;
170 virtual uint32_t n_rows () const = 0;
171 virtual uint32_t maximum_rows () const = 0;
172 virtual uint32_t minimum_rows () const = 0;
173 virtual std::string row_name (int) const = 0;
174 virtual void add_row () = 0;
175 virtual void remove_row (int) = 0;
176 virtual std::string row_descriptor () const = 0;
178 Gtk::Widget& scrolled_window() { return _scrolled_window; }
185 PortGroupList _port_group_list;
186 ARDOUR::DataType _type;
187 std::vector<PortGroupUI*> _port_group_ui;
188 std::vector<Gtk::EventBox*> _row_labels;
189 Gtk::VBox* _row_labels_vbox;
190 RotatedLabelSet _column_labels;
191 Gtk::HBox _overall_hbox;
192 Gtk::VBox _side_vbox;
193 Gtk::HBox _port_group_hbox;
194 Gtk::ScrolledWindow _scrolled_window;
195 Gtk::Label* _side_vbox_pad;
196 Gtk::HBox _visibility_checkbutton_box;
200 void setup_dimensions ();
201 bool row_label_button_pressed (GdkEventButton*, int);
202 void reset_visibility ();