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"
39 PortGroup (std::string const & n, std::string const & p) : name (n), prefix (p) {}
41 void add (std::string const & p);
45 std::vector<std::string> ports;
48 class GroupedPortList : public std::list<PortGroup>
51 GroupedPortList (ARDOUR::Session &, boost::shared_ptr<ARDOUR::IO>, bool);
55 std::string get_port_by_index (int, bool with_prefix = true) const;
58 ARDOUR::Session& _session;
59 boost::shared_ptr<ARDOUR::IO> _io;
64 /// A widget which provides a set of rotated text labels
65 class RotatedLabelSet : public Gtk::Widget {
67 RotatedLabelSet (GroupedPortList&);
68 virtual ~RotatedLabelSet ();
71 void set_base_dimensions (int, int);
74 virtual void on_size_request (Gtk::Requisition*);
75 virtual void on_size_allocate (Gtk::Allocation&);
76 virtual void on_realize ();
77 virtual void on_unrealize ();
78 virtual bool on_expose_event (GdkEventExpose*);
80 Glib::RefPtr<Gdk::Window> _gdk_window;
83 std::pair<int, int> setup_layout (std::string const &);
85 GroupedPortList& _port_list; ///< list of ports to display
86 int _angle_degrees; ///< label rotation angle in degrees
87 double _angle_radians; ///< label rotation angle in radians
88 int _base_start; ///< offset to start of labels; see set_base_dimensions() for more details
89 int _base_width; ///< width of labels; see set_base_dimensions() for more details
90 Glib::RefPtr<Pango::Context> _pango_context;
91 Glib::RefPtr<Pango::Layout> _pango_layout;
92 Glib::RefPtr<Gdk::GC> _gc;
93 Gdk::Color _fg_colour;
94 Gdk::Color _bg_colour;
99 /// Widget for selecting what an IO is connected to
100 class IOSelector : public Gtk::VBox {
102 IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool);
112 sigc::signal<void, Result> Finished;
115 ARDOUR::Session& _session;
119 void setup_row_labels ();
120 void setup_check_button_states ();
121 void check_button_toggled (int, int);
122 void add_port_button_clicked ();
123 void remove_port_button_clicked ();
124 void set_button_sensitivity ();
125 void ports_changed (ARDOUR::IOChange, void *);
126 void update_column_label_dimensions ();
128 GroupedPortList _port_list;
129 boost::shared_ptr<ARDOUR::IO> _io;
133 std::vector<Gtk::Label*> _row_labels;
134 std::vector<Gtk::EventBox*> _group_labels;
135 RotatedLabelSet _column_labels;
136 std::vector<std::vector<Gtk::CheckButton*> > _check_buttons;
137 bool _ignore_check_button_toggle; ///< check button toggle events are ignored when this is true
138 Gtk::Button _add_port_button;
139 Gtk::Button _remove_port_button;
140 Gtk::VBox _add_remove_box;
141 Gtk::HBox _table_hbox;
143 bool _add_remove_box_added;
148 class IOSelectorWindow : public ArdourDialog
151 IOSelectorWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool for_input, bool can_cancel = false);
152 ~IOSelectorWindow ();
154 IOSelector& selector() { return _selector; }
160 IOSelector _selector;
162 /* overall operation buttons */
164 Gtk::Button ok_button;
165 Gtk::Button cancel_button;
166 Gtk::Button rescan_button;
174 class PortInsertUI : public Gtk::VBox
177 PortInsertUI (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>);
180 void finished (IOSelector::Result);
184 IOSelector input_selector;
185 IOSelector output_selector;
188 class PortInsertWindow : public ArdourDialog
191 PortInsertWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>, bool can_cancel = false);
197 PortInsertUI _portinsertui;
200 Gtk::Button ok_button;
201 Gtk::Button cancel_button;
202 Gtk::Button rescan_button;
203 Gtk::Frame button_frame;
209 void plugin_going_away ();
210 sigc::connection going_away_connection;