2 Copyright (C) 2000 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.
23 #include <pbd/lockmonitor.h>
24 #include <gtkmm2ext/utils.h>
25 #include <gtkmm2ext/stop_signal.h>
27 #include <ardour/session.h>
28 #include <ardour/session_route.h>
29 #include <ardour/diskstream.h>
30 #include <ardour/plugin.h>
31 #include <ardour/plugin_manager.h>
32 #include <ardour/ardour.h>
33 #include <ardour/session.h>
34 #include <ardour/route.h>
35 #include <ardour/audio_track.h>
36 #include <ardour/send.h>
37 #include <ardour/insert.h>
38 #include <ardour/connection.h>
39 #include <ardour/session_connection.h>
41 #include "route_params_ui.h"
43 #include "mixer_strip.h"
44 #include "plugin_selector.h"
45 #include "ardour_ui.h"
46 #include "plugin_ui.h"
47 #include "io_selector.h"
50 #include "gui_thread.h"
54 using namespace ARDOUR;
58 static const gchar *route_display_titles[] = { N_("Tracks/Buses"), 0 };
59 static const gchar *pre_display_titles[] = { N_("Pre Redirects"), 0 };
60 static const gchar *post_display_titles[] = { N_("Post Redirects"), 0 };
62 RouteParams_UI::RouteParams_UI (AudioEngine& eng)
63 : ArdourDialog ("track/bus inspector"),
65 route_select_list (internationalize(route_display_titles)),
70 post_redirect_box = 0;
77 _active_post_view = 0;
79 using namespace Notebook_Helpers;
81 input_frame.set_shadow_type(GTK_SHADOW_NONE);
82 output_frame.set_shadow_type(GTK_SHADOW_NONE);
84 notebook.set_show_tabs (true);
85 notebook.set_show_border (true);
86 notebook.set_name ("RouteParamNotebook");
88 route_select_list.column_titles_active();
89 route_select_list.set_name ("RouteParamsListDisplay");
90 route_select_list.set_shadow_type (Gtk::SHADOW_IN);
91 route_select_list.set_selection_mode (GTK_SELECTION_SINGLE);
92 route_select_list.set_reorderable (false);
93 route_select_list.set_size_request (75, -1);
94 route_select_scroller.add (route_select_list);
95 route_select_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
97 route_select_frame.set_name("RouteSelectBaseFrame");
98 route_select_frame.set_shadow_type (Gtk::SHADOW_IN);
99 route_select_frame.add(route_select_scroller);
101 list_vpacker.pack_start (route_select_frame, true, true);
103 notebook.pages().push_back (TabElem (input_frame, _("Inputs")));
104 notebook.pages().push_back (TabElem (output_frame, _("Outputs")));
105 notebook.pages().push_back (TabElem (pre_redir_hpane, _("Pre-fader Redirects")));
106 notebook.pages().push_back (TabElem (post_redir_hpane, _("Post-fader Redirects")));
108 notebook.set_name ("InspectorNotebook");
110 title_label.set_name ("RouteParamsTitleLabel");
114 route_param_frame.set_name("RouteParamsBaseFrame");
115 route_param_frame.set_shadow_type (Gtk::SHADOW_IN);
118 route_hpacker.pack_start (notebook, true, true);
121 route_vpacker.pack_start (title_label, false, false);
122 route_vpacker.pack_start (route_hpacker, true, true);
125 list_hpane.add1 (list_vpacker);
126 list_hpane.add2 (route_vpacker);
128 list_hpane.set_position(110);
130 pre_redir_hpane.set_position(110);
131 post_redir_hpane.set_position(110);
133 global_vpacker.pack_start (list_hpane, true, true);
135 add (global_vpacker);
136 set_name ("RouteParamsWindow");
137 set_default_size (620,370);
138 set_title (_("ardour: track/bus inspector"));
139 set_wmclass (_("ardour_route_parameters"), "Ardour");
142 route_select_list.select_row.connect (mem_fun(*this, &RouteParams_UI::route_selected));
143 route_select_list.unselect_row.connect (mem_fun(*this, &RouteParams_UI::route_unselected));
144 route_select_list.click_column.connect (mem_fun(*this, &RouteParams_UI::show_track_menu));
147 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
149 _plugin_selector = new PluginSelector (PluginManager::the_manager());
150 _plugin_selector->signal_delete_event.connect (bind (ptr_fun (just_hide_it),
151 static_cast<Window *> (_plugin_selector)));
154 delete_event.connect (bind (ptr_fun (just_hide_it), static_cast<Gtk::Window*> (this)));
157 RouteParams_UI::~RouteParams_UI ()
162 RouteParams_UI::add_route (Route* route)
164 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route));
166 if (route->hidden()) {
170 const gchar *rowdata[1];
171 rowdata[0] = route->name().c_str();
172 route_select_list.rows().push_back (rowdata);
173 route_select_list.rows().back().set_data (route);
174 //route_select_list.rows().back().select ();
176 route->name_changed.connect (bind (mem_fun(*this, &RouteParams_UI::route_name_changed), route));
177 route->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
182 RouteParams_UI::route_name_changed (void *src, Route *route)
184 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route));
186 CList_Helpers::RowList::iterator i;
188 if ((i = route_select_list.rows().find_data (route)) == route_select_list.rows().end()) {
189 error << _("route display list item for renamed route not found!") << endmsg;
193 route_select_list.cell ((*i)->get_row_num(), 0).set_text (route->name());
195 if (route == _route) {
196 track_input_label.set_text (route->name());
202 RouteParams_UI::setup_redirect_boxes()
204 if (session && _route) {
206 // just in case... shouldn't need this
207 cleanup_redirect_boxes();
209 // construct new redirect boxes
210 pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection);
211 post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection);
213 pre_redirect_box->set_title (pre_display_titles[0]);
214 pre_redirect_box->set_title_shown (true);
215 post_redirect_box->set_title (post_display_titles[0]);
216 post_redirect_box->set_title_shown (true);
218 pre_redir_hpane.add1 (*pre_redirect_box);
219 post_redir_hpane.add1 (*post_redirect_box);
221 pre_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
222 pre_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
223 post_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
224 post_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
231 RouteParams_UI::cleanup_redirect_boxes()
233 if (pre_redirect_box) {
234 pre_redir_hpane.remove(*pre_redirect_box);
235 delete pre_redirect_box;
236 pre_redirect_box = 0;
239 if (post_redirect_box) {
240 post_redir_hpane.remove(*post_redirect_box);
241 delete post_redirect_box;
242 post_redirect_box = 0;
247 RouteParams_UI::setup_io_frames()
252 _input_iosel = new IOSelector (*session, *_route, true);
253 _input_iosel->redisplay ();
254 input_frame.add (*_input_iosel);
255 input_frame.show_all();
258 _output_iosel = new IOSelector (*session, *_route, false);
259 _output_iosel->redisplay ();
260 output_frame.add (*_output_iosel);
261 output_frame.show_all();
265 RouteParams_UI::cleanup_io_frames()
268 _input_iosel->Finished (IOSelector::Cancelled);
269 input_frame.remove();
275 _output_iosel->Finished (IOSelector::Cancelled);
277 output_frame.remove();
278 delete _output_iosel;
284 RouteParams_UI::cleanup_pre_view (bool stopupdate)
286 if (_active_pre_view) {
287 PluginUI * plugui = 0;
289 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_pre_view)) != 0) {
290 plugui->stop_updating (0);
293 _pre_plugin_conn.disconnect();
294 pre_redir_hpane.remove(*_active_pre_view);
295 delete _active_pre_view;
296 _active_pre_view = 0;
301 RouteParams_UI::cleanup_post_view (bool stopupdate)
303 if (_active_post_view) {
304 PluginUI * plugui = 0;
306 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_post_view)) != 0) {
307 plugui->stop_updating (0);
309 _post_plugin_conn.disconnect();
310 post_redir_hpane.remove(*_active_post_view);
311 delete _active_post_view;
312 _active_post_view = 0;
318 RouteParams_UI::route_removed (Route *route)
320 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
322 route_select_list.freeze ();
323 route_select_list.clear ();
324 session->foreach_route (this, &RouteParams_UI::add_route);
325 route_select_list.thaw ();
328 CList_Helpers::RowList::iterator i;
330 if ((i = route_select_list.rows().find_data (route)) == route_select_list.rows().end()) {
331 // couldn't find route to be deleted
340 cleanup_redirect_boxes();
348 route_select_list.rows().erase(i);
353 RouteParams_UI::set_session (Session *sess)
355 ArdourDialog::set_session (sess);
357 route_select_list.freeze ();
358 route_select_list.clear ();
361 session->foreach_route (this, &RouteParams_UI::add_route);
362 session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
363 session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_route));
369 route_select_list.thaw ();
371 _plugin_selector->set_session (session);
376 RouteParams_UI::session_gone ()
379 route_select_list.clear ();
384 cleanup_redirect_boxes();
391 ArdourDialog::session_gone();
396 RouteParams_UI::route_selected (gint row, gint col, GdkEvent *ev)
400 if ((route = (Route *) route_select_list.get_row_data (row)) != 0) {
402 if (_route == route) {
407 // remove event binding from previously selected
409 _route_conn.disconnect();
410 _route_ds_conn.disconnect();
411 cleanup_redirect_boxes();
417 // update the other panes with the correct info
419 //update_routeinfo (route);
422 setup_redirect_boxes();
424 // bind to redirects changed event for this route
425 _route_conn = route->redirects_changed.connect (mem_fun(*this, &RouteParams_UI::redirects_changed));
427 track_input_label.set_text (_route->name());
434 RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
437 _route_conn.disconnect();
443 cleanup_redirect_boxes();
448 track_input_label.set_text(_("NO TRACK"));
454 RouteParams_UI::redirects_changed (void *src)
457 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirects_changed), src));
459 // pre_redirect_list.freeze ();
460 // pre_redirect_list.clear ();
461 // post_redirect_list.freeze ();
462 // post_redirect_list.clear ();
464 // _route->foreach_redirect (this, &RouteParams_UI::add_redirect_to_display);
466 // pre_redirect_list.thaw ();
467 // post_redirect_list.thaw ();
480 RouteParams_UI::show_track_menu (gint arg)
482 using namespace Menu_Helpers;
484 if (track_menu == 0) {
485 track_menu = new Menu;
486 track_menu->set_name ("ArdourContextMenu");
487 track_menu->items().push_back
488 (MenuElem (_("Add Track/Bus"),
489 mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
491 track_menu->popup (1, 0);
497 RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement place)
501 if ((place == PreFader && _pre_redirect == redirect)
502 || (place == PostFader && _post_redirect == redirect)){
506 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
510 if ((send = dynamic_cast<Send *> (redirect)) != 0) {
514 SendUI *send_ui = new SendUI (*send, *session);
516 if (place == PreFader) {
518 _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
519 _active_pre_view = send_ui;
521 pre_redir_hpane.add2 (*_active_pre_view);
522 pre_redir_hpane.show_all();
526 _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
527 _active_post_view = send_ui;
529 post_redir_hpane.add2 (*_active_post_view);
530 post_redir_hpane.show_all();
535 /* its an insert, though we don't know what kind yet. */
537 PluginInsert *plugin_insert;
538 PortInsert *port_insert;
540 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
542 PluginUI *plugin_ui = new PluginUI (session->engine(), *plugin_insert, true);
544 if (place == PreFader) {
546 _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader));
547 plugin_ui->start_updating (0);
548 _active_pre_view = plugin_ui;
549 pre_redir_hpane.add2 (*_active_pre_view);
550 pre_redir_hpane.show_all();
554 _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader));
555 plugin_ui->start_updating (0);
556 _active_post_view = plugin_ui;
557 post_redir_hpane.add2 (*_active_post_view);
558 post_redir_hpane.show_all();
561 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
563 PortInsertUI *portinsert_ui = new PortInsertUI (*session, *port_insert);
565 if (place == PreFader) {
567 _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
568 _active_pre_view = portinsert_ui;
569 pre_redir_hpane.add2 (*_active_pre_view);
570 portinsert_ui->redisplay();
571 pre_redir_hpane.show_all();
575 _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
576 _active_post_view = portinsert_ui;
577 post_redir_hpane.add2 (*_active_post_view);
578 portinsert_ui->redisplay();
579 post_redir_hpane.show_all();
585 if (place == PreFader) {
586 _pre_redirect = redirect;
589 _post_redirect = redirect;
597 RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect)
599 // not called anymore
601 if (redirect == _pre_redirect) {
605 else if (redirect == _post_redirect) {
614 RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
616 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
618 // delete the current view without calling finish
620 if (place == PreFader) {
621 cleanup_pre_view (false);
625 cleanup_post_view (false);
631 RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
634 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
636 printf ("redirect going away\n");
637 // delete the current view without calling finish
638 if (plugin == _pre_redirect) {
639 cleanup_pre_view (false);
642 else if (plugin == _post_redirect) {
643 cleanup_post_view (false);
650 RouteParams_UI::update_title ()
654 title += _route->name();
657 // if (_redirect && (_current_view == PLUGIN_CONFIG_VIEW || _current_view == SEND_CONFIG_VIEW)) {
658 // title += _redirect->name();
660 // else if (_current_view == INPUT_CONFIG_VIEW) {
661 // title += _("INPUT");
663 // else if (_current_view == OUTPUT_CONFIG_VIEW) {
664 // title += _("OUTPUT");
667 title_label.set_text(title);
669 title = _("ardour: track/bus inspector: ") + title;
673 title_label.set_text(_("No Route Selected"));
674 set_title(_("ardour: track/bus/inspector: no route selected"));
680 RouteParams_UI::start_updating ()
682 update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
683 (mem_fun(*this, &RouteParams_UI::update_views));
687 RouteParams_UI::stop_updating ()
689 update_connection.disconnect();
693 RouteParams_UI::update_views ()
696 // TODO: only do it if correct tab is showing
698 if ((sui = dynamic_cast<SendUI*> (_active_pre_view)) != 0) {
701 if ((sui = dynamic_cast<SendUI*> (_active_post_view)) != 0) {