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_io_selector_h__
21 #define __ardour_ui_io_selector_h__
23 #include <gtkmm/box.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/table.h>
26 #include <gtkmm/frame.h>
28 #include "ardour_dialog.h"
36 /// A group of port names
40 PortGroup (std::string const & n, std::string const & p) : name (n), prefix (p), visible (true) {}
42 void add (std::string const & p);
45 std::string prefix; ///< prefix (before colon) e.g. "ardour:"
46 std::vector<std::string> ports; ///< port names
50 /// A table of checkbuttons to provide the GUI for connecting to a PortGroup
54 PortGroupTable (PortGroup&, boost::shared_ptr<ARDOUR::IO>, bool);
56 Gtk::Widget& get_widget ();
57 std::pair<int, int> unit_size () const;
58 PortGroup& port_group () { return _port_group; }
61 void check_button_toggled (Gtk::CheckButton*, int, std::string const &);
65 PortGroup& _port_group;
66 std::vector<std::vector<Gtk::CheckButton* > > _check_buttons;
67 bool _ignore_check_button_toggle;
68 boost::shared_ptr<ARDOUR::IO> _io;
72 /// A list of PortGroups
73 class PortGroupList : public std::list<PortGroup>
76 PortGroupList (ARDOUR::Session &, boost::shared_ptr<ARDOUR::IO>, bool);
79 int n_visible_ports () const;
80 std::string get_port_by_index (int, bool with_prefix = true) const;
83 ARDOUR::Session& _session;
84 boost::shared_ptr<ARDOUR::IO> _io;
89 /// A widget which provides a set of rotated text labels
90 class RotatedLabelSet : public Gtk::Widget {
92 RotatedLabelSet (PortGroupList&);
93 virtual ~RotatedLabelSet ();
96 void set_base_width (int);
97 void update_visibility ();
100 virtual void on_size_request (Gtk::Requisition*);
101 virtual void on_size_allocate (Gtk::Allocation&);
102 virtual void on_realize ();
103 virtual void on_unrealize ();
104 virtual bool on_expose_event (GdkEventExpose*);
106 Glib::RefPtr<Gdk::Window> _gdk_window;
109 std::pair<int, int> setup_layout (std::string const &);
111 PortGroupList& _port_group_list; ///< list of ports to display
112 int _angle_degrees; ///< label rotation angle in degrees
113 double _angle_radians; ///< label rotation angle in radians
114 int _base_width; ///< width of labels; see set_base_width() for more details
115 Glib::RefPtr<Pango::Context> _pango_context;
116 Glib::RefPtr<Pango::Layout> _pango_layout;
117 Glib::RefPtr<Gdk::GC> _gc;
118 Gdk::Color _fg_colour;
119 Gdk::Color _bg_colour;
124 /// Widget for selecting what an IO is connected to
125 class IOSelector : public Gtk::VBox {
127 IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool);
137 sigc::signal<void, Result> Finished;
142 void setup_dimensions ();
143 void ports_changed (ARDOUR::IOChange, void*);
144 bool row_label_button_pressed (GdkEventButton*, int);
146 void remove_port (int);
147 void group_visible_toggled (Gtk::CheckButton*, std::string const &);
149 PortGroupList _port_group_list;
150 boost::shared_ptr<ARDOUR::IO> _io;
152 std::vector<PortGroupTable*> _port_group_tables;
153 std::vector<Gtk::EventBox*> _row_labels[2];
154 Gtk::VBox* _row_labels_vbox[2];
155 RotatedLabelSet _column_labels;
156 Gtk::HBox _overall_hbox;
157 Gtk::VBox _side_vbox[2];
158 Gtk::HBox _port_group_hbox;
159 Gtk::ScrolledWindow _scrolled_window;
160 Gtk::Label* _side_vbox_pad[2];
164 class IOSelectorWindow : public ArdourDialog
167 IOSelectorWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool for_input, bool can_cancel = false);
168 ~IOSelectorWindow ();
170 IOSelector& selector() { return _selector; }
176 IOSelector _selector;
178 /* overall operation buttons */
180 Gtk::Button ok_button;
181 Gtk::Button cancel_button;
182 Gtk::Button rescan_button;
190 class PortInsertUI : public Gtk::VBox
193 PortInsertUI (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>);
196 void finished (IOSelector::Result);
200 IOSelector input_selector;
201 IOSelector output_selector;
204 class PortInsertWindow : public ArdourDialog
207 PortInsertWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>, bool can_cancel = false);
213 PortInsertUI _portinsertui;
216 Gtk::Button ok_button;
217 Gtk::Button cancel_button;
218 Gtk::Button rescan_button;
219 Gtk::Frame button_frame;
225 void plugin_going_away ();
226 sigc::connection going_away_connection;