allow user tweaking of everything that might have inherent latency; add GUI for track...
[ardour.git] / gtk2_ardour / route_params_ui.h
1 /*
2     Copyright (C) 2000 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 __ardour_route_params_ui_h__
21 #define __ardour_route_params_ui_h__
22
23 #include <list>
24
25 #include <gtkmm/box.h>
26 #include <gtkmm/button.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/label.h>
30 #include <gtkmm/paned.h>
31 #include <gtkmm/scrolledwindow.h>
32 #include <gtkmm/togglebutton.h>
33 #include <gtkmm/treeview.h>
34
35 #include <pbd/stateful.h>
36
37 #include <ardour/ardour.h>
38 #include <ardour/io.h>
39 #include <ardour/io_processor.h>
40
41 #include "io_selector.h"
42 #include "ardour_dialog.h"
43 #include "processor_box.h"
44 #include "route_processor_selection.h"
45 #include "latency_gui.h"
46
47 namespace ARDOUR {
48         class Route;
49         class Send;
50         class Processor;
51         class Session;
52         class PortInsert;
53         class Connection;
54         class Plugin;
55 }
56
57 class PluginSelector;
58
59 class RouteParams_UI : public ArdourDialog
60 {
61   public:
62         RouteParams_UI ();
63         ~RouteParams_UI();
64
65         void set_session (ARDOUR::Session *);
66         void session_gone ();
67         PluginSelector&  plugin_selector() { return *_plugin_selector; }
68
69   private:
70         Gtk::HBox                global_hpacker;
71         Gtk::VBox                global_vpacker;
72         Gtk::ScrolledWindow      scroller;
73         Gtk::EventBox            scroller_base;
74         Gtk::HBox                scroller_hpacker;
75         Gtk::VBox                mixer_scroller_vpacker;
76
77         Gtk::VBox                list_vpacker;
78         Gtk::Label               route_list_button_label;
79         Gtk::Button              route_list_button;
80         Gtk::ScrolledWindow      route_select_scroller;
81
82         Gtk::Notebook            notebook;
83         Gtk::Frame               input_frame;
84         Gtk::Frame               output_frame;
85         Gtk::HPaned              pre_redir_hpane;
86         Gtk::HPaned              post_redir_hpane;
87
88         Gtk::Frame               route_select_frame;
89
90         Gtk::HBox                route_hpacker;
91         Gtk::VBox                route_vpacker;
92
93         ProcessorBox              * pre_insert_box;
94         ProcessorBox              * post_insert_box;
95         
96         Gtk::HPaned              list_hpane;
97
98         Gtk::HPaned              right_hpane;
99         
100         Gtk::Frame               route_choice_frame;
101
102         Gtk::Frame               route_param_frame;
103
104         Gtk::VBox                choice_vpacker;
105         
106         Gtk::Frame               latency_frame;
107         Gtk::VBox                latency_packer;
108         Gtk::HButtonBox          latency_button_box;
109         Gtk::Button              latency_apply_button;
110         LatencyGUI*              latency_widget;
111         Gtk::Label               delay_label;
112         sigc::connection         latency_conn;
113         sigc::connection         delay_conn;
114         sigc::connection         latency_apply_conn;
115
116         void refresh_latency ();
117         
118         Gtk::ToggleButton input_button;
119         Gtk::ToggleButton output_button;
120         Gtk::Label  track_input_label;
121         
122         Gtk::Label  title_label;
123         
124         Gtk::Container * _active_pre_view;
125         Gtk::Container * _active_post_view;
126         IOSelector     * _input_iosel;
127         IOSelector     * _output_iosel;
128         
129         PluginSelector    *_plugin_selector;
130         RouteRedirectSelection  _rr_selection;
131
132         boost::shared_ptr<ARDOUR::Route> _route;
133         sigc::connection            _route_conn;
134         sigc::connection            _route_ds_conn;
135
136         boost::shared_ptr<ARDOUR::Processor> _pre_processor;
137         sigc::connection                    _pre_plugin_conn;
138
139         boost::shared_ptr<ARDOUR::Processor> _post_processor;
140         sigc::connection                     _post_plugin_conn;
141         
142         
143         enum ConfigView {
144                 NO_CONFIG_VIEW = 0,
145                 INPUT_CONFIG_VIEW,
146                 OUTPUT_CONFIG_VIEW,
147                 PLUGIN_CONFIG_VIEW,             
148                 PORTINSERT_CONFIG_VIEW,
149                 SEND_CONFIG_VIEW
150         };
151         
152         ConfigView _current_view;
153
154
155         /* treeview */
156         struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
157                 RouteDisplayModelColumns() {
158                         add(text);
159                         add(route);
160                 }
161                 Gtk::TreeModelColumn<Glib::ustring> text;
162                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
163         };
164
165         RouteDisplayModelColumns route_display_columns ;
166         Gtk::TreeView route_display;
167         Glib::RefPtr<Gtk::ListStore> route_display_model;
168
169         
170         void add_routes (ARDOUR::Session::RouteList&);
171
172         void route_name_changed (boost::shared_ptr<ARDOUR::Route> route);
173         void route_removed (boost::shared_ptr<ARDOUR::Route> route);
174
175
176         void route_selected();
177         //void route_unselected (gint row, gint col, GdkEvent *ev);
178
179         void setup_io_frames();
180         void cleanup_io_frames();
181         void cleanup_pre_view(bool stopupdate = true);
182         void cleanup_post_view(bool stopupdate = true);
183         void cleanup_latency_frame ();
184         void setup_latency_frame ();
185         
186         void processors_changed ();
187         
188         void setup_processor_boxes();
189         void cleanup_processor_boxes();
190
191         void redirect_selected (boost::shared_ptr<ARDOUR::Processor>, ARDOUR::Placement);
192         
193         void plugin_going_away (ARDOUR::Placement);
194         void redirect_going_away (boost::shared_ptr<ARDOUR::Processor>);
195
196         gint edit_input_configuration (GdkEventButton *ev);
197         gint edit_output_configuration (GdkEventButton *ev);
198         
199         void update_routeinfo (ARDOUR::Route * route);
200         
201         Gtk::Menu *track_menu;
202         void show_track_menu();
203         
204         void update_title ();
205         //void unselect_all_redirects ();
206
207         sigc::connection update_connection;
208         void update_views ();
209
210         void start_updating ();
211         void stop_updating ();
212 };
213
214
215 #endif /* __ardour_route_params_ui_h__ */