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 RouteParams_UI::RouteParams_UI (AudioEngine& eng)
59 : ArdourDialog ("track/bus inspector"),
65 post_redirect_box = 0;
72 _active_post_view = 0;
74 using namespace Notebook_Helpers;
76 input_frame.set_shadow_type(Gtk::SHADOW_NONE);
77 output_frame.set_shadow_type(Gtk::SHADOW_NONE);
79 notebook.set_show_tabs (true);
80 notebook.set_show_border (true);
81 notebook.set_name ("RouteParamNotebook");
83 // create the tree model
84 route_display_model = ListStore::create(route_display_columns);
87 route_display.set_model(route_display_model);
88 route_display.append_column(_("Tracks/Buses"), route_display_columns.text);
89 route_display.set_name(X_("RouteParamsListDisplay"));
90 route_display.get_selection()->set_mode(Gtk::SELECTION_SINGLE); // default
91 route_display.set_reorderable(false);
92 route_display.set_size_request(75, -1);
93 route_display.set_headers_visible(true);
94 route_display.set_headers_clickable(true);
96 route_select_scroller.add(route_display);
97 route_select_scroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
100 route_select_frame.set_name("RouteSelectBaseFrame");
101 route_select_frame.set_shadow_type (Gtk::SHADOW_IN);
102 route_select_frame.add(route_select_scroller);
104 list_vpacker.pack_start (route_select_frame, true, true);
106 notebook.pages().push_back (TabElem (input_frame, _("Inputs")));
107 notebook.pages().push_back (TabElem (output_frame, _("Outputs")));
108 notebook.pages().push_back (TabElem (pre_redir_hpane, _("Pre-fader Redirects")));
109 notebook.pages().push_back (TabElem (post_redir_hpane, _("Post-fader Redirects")));
111 notebook.set_name ("InspectorNotebook");
113 title_label.set_name ("RouteParamsTitleLabel");
117 route_param_frame.set_name("RouteParamsBaseFrame");
118 route_param_frame.set_shadow_type (Gtk::SHADOW_IN);
121 route_hpacker.pack_start (notebook, true, true);
124 route_vpacker.pack_start (title_label, false, false);
125 route_vpacker.pack_start (route_hpacker, true, true);
128 list_hpane.add1 (list_vpacker);
129 list_hpane.add2 (route_vpacker);
131 list_hpane.set_position(110);
133 pre_redir_hpane.set_position(110);
134 post_redir_hpane.set_position(110);
136 global_vpacker.pack_start (list_hpane, true, true);
138 add (global_vpacker);
139 set_name ("RouteParamsWindow");
140 set_default_size (620,370);
141 set_title (_("ardour: track/bus inspector"));
142 set_wmclass (_("ardour_route_parameters"), "Ardour");
145 route_display.get_selection()->signal_changed().connect(mem_fun(*this, &RouteParams_UI::route_selected));
146 route_display.get_column(0)->signal_clicked().connect(mem_fun(*this, &RouteParams_UI::show_track_menu));
148 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
150 _plugin_selector = new PluginSelector (PluginManager::the_manager());
151 _plugin_selector->signal_delete_event().connect (bind (ptr_fun (just_hide_it),
152 static_cast<Window *> (_plugin_selector)));
155 signal_delete_event().connect(bind(ptr_fun(just_hide_it), static_cast<Gtk::Window *>(this)));
158 RouteParams_UI::~RouteParams_UI ()
163 RouteParams_UI::add_route (Route* route)
165 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route));
167 if (route->hidden()) {
171 TreeModel::Row row = *(route_display_model->append());
172 row[route_display_columns.text] = route->name();
173 row[route_display_columns.route] = route;
175 //route_select_list.rows().back().select ();
177 route->name_changed.connect (bind (mem_fun(*this, &RouteParams_UI::route_name_changed), route));
178 route->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
183 RouteParams_UI::route_name_changed (void *src, Route *route)
185 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route));
188 TreeModel::Children rows = route_display_model->children();
189 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
190 if((*iter)[route_display_columns.route] == route) {
191 (*iter)[route_display_columns.text] = route->name() ;
199 error << _("route display list item for renamed route not found!") << endmsg;
202 if (route == _route) {
203 track_input_label.set_text (route->name());
209 RouteParams_UI::setup_redirect_boxes()
211 if (session && _route) {
213 // just in case... shouldn't need this
214 cleanup_redirect_boxes();
216 // construct new redirect boxes
217 pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection);
218 post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection);
220 pre_redir_hpane.add1 (*pre_redirect_box);
221 post_redir_hpane.add1 (*post_redirect_box);
223 pre_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
224 pre_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
225 post_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
226 post_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
233 RouteParams_UI::cleanup_redirect_boxes()
235 if (pre_redirect_box) {
236 pre_redir_hpane.remove(*pre_redirect_box);
237 delete pre_redirect_box;
238 pre_redirect_box = 0;
241 if (post_redirect_box) {
242 post_redir_hpane.remove(*post_redirect_box);
243 delete post_redirect_box;
244 post_redirect_box = 0;
249 RouteParams_UI::setup_io_frames()
254 _input_iosel = new IOSelector (*session, *_route, true);
255 _input_iosel->redisplay ();
256 input_frame.add (*_input_iosel);
257 input_frame.show_all();
260 _output_iosel = new IOSelector (*session, *_route, false);
261 _output_iosel->redisplay ();
262 output_frame.add (*_output_iosel);
263 output_frame.show_all();
267 RouteParams_UI::cleanup_io_frames()
270 _input_iosel->Finished (IOSelector::Cancelled);
271 input_frame.remove();
277 _output_iosel->Finished (IOSelector::Cancelled);
279 output_frame.remove();
280 delete _output_iosel;
286 RouteParams_UI::cleanup_pre_view (bool stopupdate)
288 if (_active_pre_view) {
289 PluginUI * plugui = 0;
291 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_pre_view)) != 0) {
292 plugui->stop_updating (0);
295 _pre_plugin_conn.disconnect();
296 pre_redir_hpane.remove(*_active_pre_view);
297 delete _active_pre_view;
298 _active_pre_view = 0;
303 RouteParams_UI::cleanup_post_view (bool stopupdate)
305 if (_active_post_view) {
306 PluginUI * plugui = 0;
308 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_post_view)) != 0) {
309 plugui->stop_updating (0);
311 _post_plugin_conn.disconnect();
312 post_redir_hpane.remove(*_active_post_view);
313 delete _active_post_view;
314 _active_post_view = 0;
320 RouteParams_UI::route_removed (Route *route)
322 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
324 route_select_list.freeze ();
325 route_select_list.clear ();
326 session->foreach_route (this, &RouteParams_UI::add_route);
327 route_select_list.thaw ();
330 TreeModel::Children rows = route_display_model->children();
331 TreeModel::Children::iterator ri;
333 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
334 if((*iter)[route_display_columns.route] == route) {
335 route_display_model->erase(iter);
345 cleanup_redirect_boxes();
355 RouteParams_UI::set_session (Session *sess)
357 ArdourDialog::set_session (sess);
360 // route_select_list.freeze ();
362 route_display_model->clear();
365 session->foreach_route (this, &RouteParams_UI::add_route);
366 session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
367 session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_route));
373 //route_select_list.thaw ();
375 _plugin_selector->set_session (session);
380 RouteParams_UI::session_gone ()
382 ENSURE_GUI_THREAD(mem_fun(*this, &RouteParams_UI::session_gone));
384 route_display_model->clear();
389 cleanup_redirect_boxes();
396 ArdourDialog::session_gone();
401 RouteParams_UI::route_selected()
403 Glib::RefPtr<TreeSelection> selection = route_display.get_selection();
404 TreeModel::iterator iter = selection->get_selected(); // only used with Gtk::SELECTION_SINGLE
406 //If anything is selected
407 Route* route = (*iter)[route_display_columns.route] ;
409 if (_route == route) {
414 // remove event binding from previously selected
416 _route_conn.disconnect();
417 _route_ds_conn.disconnect();
418 cleanup_redirect_boxes();
424 // update the other panes with the correct info
426 //update_routeinfo (route);
429 setup_redirect_boxes();
431 // bind to redirects changed event for this route
432 _route_conn = route->redirects_changed.connect (mem_fun(*this, &RouteParams_UI::redirects_changed));
434 track_input_label.set_text (_route->name());
440 _route_conn.disconnect();
446 cleanup_redirect_boxes();
451 track_input_label.set_text(_("NO TRACK"));
458 //RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
461 // _route_conn.disconnect();
464 // cleanup_io_frames();
465 // cleanup_pre_view();
466 // cleanup_post_view();
467 // cleanup_redirect_boxes();
470 // _pre_redirect = 0;
471 // _post_redirect = 0;
472 // track_input_label.set_text(_("NO TRACK"));
478 RouteParams_UI::redirects_changed (void *src)
481 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirects_changed), src));
483 // pre_redirect_list.freeze ();
484 // pre_redirect_list.clear ();
485 // post_redirect_list.freeze ();
486 // post_redirect_list.clear ();
488 // _route->foreach_redirect (this, &RouteParams_UI::add_redirect_to_display);
490 // pre_redirect_list.thaw ();
491 // post_redirect_list.thaw ();
504 RouteParams_UI::show_track_menu()
506 using namespace Menu_Helpers;
508 if (track_menu == 0) {
509 track_menu = new Menu;
510 track_menu->set_name ("ArdourContextMenu");
511 track_menu->items().push_back
512 (MenuElem (_("Add Track/Bus"),
513 mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
515 track_menu->popup (1, 0);
521 RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement place)
525 if ((place == PreFader && _pre_redirect == redirect)
526 || (place == PostFader && _post_redirect == redirect)){
530 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
534 if ((send = dynamic_cast<Send *> (redirect)) != 0) {
538 SendUI *send_ui = new SendUI (*send, *session);
540 if (place == PreFader) {
542 _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
543 _active_pre_view = send_ui;
545 pre_redir_hpane.add2 (*_active_pre_view);
546 pre_redir_hpane.show_all();
550 _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
551 _active_post_view = send_ui;
553 post_redir_hpane.add2 (*_active_post_view);
554 post_redir_hpane.show_all();
559 /* its an insert, though we don't know what kind yet. */
561 PluginInsert *plugin_insert;
562 PortInsert *port_insert;
564 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
566 PluginUI *plugin_ui = new PluginUI (session->engine(), *plugin_insert, true);
568 if (place == PreFader) {
570 _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader));
571 plugin_ui->start_updating (0);
572 _active_pre_view = plugin_ui;
573 pre_redir_hpane.add2 (*_active_pre_view);
574 pre_redir_hpane.show_all();
578 _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader));
579 plugin_ui->start_updating (0);
580 _active_post_view = plugin_ui;
581 post_redir_hpane.add2 (*_active_post_view);
582 post_redir_hpane.show_all();
585 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
587 PortInsertUI *portinsert_ui = new PortInsertUI (*session, *port_insert);
589 if (place == PreFader) {
591 _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
592 _active_pre_view = portinsert_ui;
593 pre_redir_hpane.add2 (*_active_pre_view);
594 portinsert_ui->redisplay();
595 pre_redir_hpane.show_all();
599 _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
600 _active_post_view = portinsert_ui;
601 post_redir_hpane.add2 (*_active_post_view);
602 portinsert_ui->redisplay();
603 post_redir_hpane.show_all();
609 if (place == PreFader) {
610 _pre_redirect = redirect;
613 _post_redirect = redirect;
621 RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect)
623 // not called anymore
625 if (redirect == _pre_redirect) {
629 else if (redirect == _post_redirect) {
638 RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
640 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
642 // delete the current view without calling finish
644 if (place == PreFader) {
645 cleanup_pre_view (false);
649 cleanup_post_view (false);
655 RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
658 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
660 printf ("redirect going away\n");
661 // delete the current view without calling finish
662 if (plugin == _pre_redirect) {
663 cleanup_pre_view (false);
666 else if (plugin == _post_redirect) {
667 cleanup_post_view (false);
674 RouteParams_UI::update_title ()
678 title += _route->name();
681 // if (_redirect && (_current_view == PLUGIN_CONFIG_VIEW || _current_view == SEND_CONFIG_VIEW)) {
682 // title += _redirect->name();
684 // else if (_current_view == INPUT_CONFIG_VIEW) {
685 // title += _("INPUT");
687 // else if (_current_view == OUTPUT_CONFIG_VIEW) {
688 // title += _("OUTPUT");
691 title_label.set_text(title);
693 title = _("ardour: track/bus inspector: ") + title;
697 title_label.set_text(_("No Route Selected"));
698 set_title(_("ardour: track/bus/inspector: no route selected"));
704 RouteParams_UI::start_updating ()
706 update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
707 (mem_fun(*this, &RouteParams_UI::update_views));
711 RouteParams_UI::stop_updating ()
713 update_connection.disconnect();
717 RouteParams_UI::update_views ()
720 // TODO: only do it if correct tab is showing
722 if ((sui = dynamic_cast<SendUI*> (_active_pre_view)) != 0) {
725 if ((sui = dynamic_cast<SendUI*> (_active_post_view)) != 0) {