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.pack1 (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);
137 //get_vbox()->pack_start (global_vpacker);
138 get_vbox()->pack_start (list_hpane);
141 set_name ("RouteParamsWindow");
142 set_default_size (620,370);
143 set_title (_("ardour: track/bus inspector"));
144 set_wmclass (_("ardour_route_parameters"), "Ardour");
147 route_display.get_selection()->signal_changed().connect(mem_fun(*this, &RouteParams_UI::route_selected));
148 route_display.get_column(0)->signal_clicked().connect(mem_fun(*this, &RouteParams_UI::show_track_menu));
150 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
152 _plugin_selector = new PluginSelector (PluginManager::the_manager());
153 _plugin_selector->signal_delete_event().connect (bind (ptr_fun (just_hide_it),
154 static_cast<Window *> (_plugin_selector)));
157 signal_delete_event().connect(bind(ptr_fun(just_hide_it), static_cast<Gtk::Window *>(this)));
160 RouteParams_UI::~RouteParams_UI ()
165 RouteParams_UI::add_route (Route* route)
167 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route));
169 if (route->hidden()) {
173 TreeModel::Row row = *(route_display_model->append());
174 row[route_display_columns.text] = route->name();
175 row[route_display_columns.route] = route;
177 //route_select_list.rows().back().select ();
179 route->name_changed.connect (bind (mem_fun(*this, &RouteParams_UI::route_name_changed), route));
180 route->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
185 RouteParams_UI::route_name_changed (void *src, Route *route)
187 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route));
190 TreeModel::Children rows = route_display_model->children();
191 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
192 if((*iter)[route_display_columns.route] == route) {
193 (*iter)[route_display_columns.text] = route->name() ;
201 error << _("route display list item for renamed route not found!") << endmsg;
204 if (route == _route) {
205 track_input_label.set_text (route->name());
211 RouteParams_UI::setup_redirect_boxes()
213 if (session && _route) {
215 // just in case... shouldn't need this
216 cleanup_redirect_boxes();
218 // construct new redirect boxes
219 pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection);
220 post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection);
222 pre_redir_hpane.pack1 (*pre_redirect_box);
223 post_redir_hpane.pack1 (*post_redirect_box);
225 pre_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
226 pre_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
227 post_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
228 post_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
230 pre_redir_hpane.show_all();
231 post_redir_hpane.show_all();
237 RouteParams_UI::cleanup_redirect_boxes()
239 if (pre_redirect_box) {
240 pre_redir_hpane.remove(*pre_redirect_box);
241 delete pre_redirect_box;
242 pre_redirect_box = 0;
245 if (post_redirect_box) {
246 post_redir_hpane.remove(*post_redirect_box);
247 delete post_redirect_box;
248 post_redirect_box = 0;
253 RouteParams_UI::setup_io_frames()
258 _input_iosel = new IOSelector (*session, *_route, true);
259 _input_iosel->redisplay ();
260 input_frame.add (*_input_iosel);
261 input_frame.show_all();
264 _output_iosel = new IOSelector (*session, *_route, false);
265 _output_iosel->redisplay ();
266 output_frame.add (*_output_iosel);
267 output_frame.show_all();
271 RouteParams_UI::cleanup_io_frames()
274 _input_iosel->Finished (IOSelector::Cancelled);
275 input_frame.remove();
281 _output_iosel->Finished (IOSelector::Cancelled);
283 output_frame.remove();
284 delete _output_iosel;
290 RouteParams_UI::cleanup_pre_view (bool stopupdate)
292 if (_active_pre_view) {
293 PluginUI * plugui = 0;
295 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_pre_view)) != 0) {
296 plugui->stop_updating (0);
299 _pre_plugin_conn.disconnect();
300 pre_redir_hpane.remove(*_active_pre_view);
301 delete _active_pre_view;
302 _active_pre_view = 0;
307 RouteParams_UI::cleanup_post_view (bool stopupdate)
309 if (_active_post_view) {
310 PluginUI * plugui = 0;
312 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_post_view)) != 0) {
313 plugui->stop_updating (0);
315 _post_plugin_conn.disconnect();
316 post_redir_hpane.remove(*_active_post_view);
317 delete _active_post_view;
318 _active_post_view = 0;
324 RouteParams_UI::route_removed (Route *route)
326 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
328 route_select_list.freeze ();
329 route_select_list.clear ();
330 session->foreach_route (this, &RouteParams_UI::add_route);
331 route_select_list.thaw ();
334 TreeModel::Children rows = route_display_model->children();
335 TreeModel::Children::iterator ri;
337 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
338 if((*iter)[route_display_columns.route] == route) {
339 route_display_model->erase(iter);
349 cleanup_redirect_boxes();
359 RouteParams_UI::set_session (Session *sess)
361 ArdourDialog::set_session (sess);
363 route_display_model->clear();
366 session->foreach_route (this, &RouteParams_UI::add_route);
367 session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
368 session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_route));
374 //route_select_list.thaw ();
376 _plugin_selector->set_session (session);
381 RouteParams_UI::session_gone ()
383 ENSURE_GUI_THREAD(mem_fun(*this, &RouteParams_UI::session_gone));
385 route_display_model->clear();
390 cleanup_redirect_boxes();
397 ArdourDialog::session_gone();
402 RouteParams_UI::route_selected()
404 Glib::RefPtr<TreeSelection> selection = route_display.get_selection();
405 TreeModel::iterator iter = selection->get_selected(); // only used with Gtk::SELECTION_SINGLE
407 //If anything is selected
408 Route* route = (*iter)[route_display_columns.route] ;
410 if (_route == route) {
415 // remove event binding from previously selected
417 _route_conn.disconnect();
418 _route_ds_conn.disconnect();
419 cleanup_redirect_boxes();
425 // update the other panes with the correct info
427 //update_routeinfo (route);
430 setup_redirect_boxes();
432 // bind to redirects changed event for this route
433 _route_conn = route->redirects_changed.connect (mem_fun(*this, &RouteParams_UI::redirects_changed));
435 track_input_label.set_text (_route->name());
441 _route_conn.disconnect();
447 cleanup_redirect_boxes();
452 track_input_label.set_text(_("NO TRACK"));
459 //RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
462 // _route_conn.disconnect();
465 // cleanup_io_frames();
466 // cleanup_pre_view();
467 // cleanup_post_view();
468 // cleanup_redirect_boxes();
471 // _pre_redirect = 0;
472 // _post_redirect = 0;
473 // track_input_label.set_text(_("NO TRACK"));
479 RouteParams_UI::redirects_changed (void *src)
482 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirects_changed), src));
484 // pre_redirect_list.freeze ();
485 // pre_redirect_list.clear ();
486 // post_redirect_list.freeze ();
487 // post_redirect_list.clear ();
489 // _route->foreach_redirect (this, &RouteParams_UI::add_redirect_to_display);
491 // pre_redirect_list.thaw ();
492 // post_redirect_list.thaw ();
505 RouteParams_UI::show_track_menu()
507 using namespace Menu_Helpers;
509 if (track_menu == 0) {
510 track_menu = new Menu;
511 track_menu->set_name ("ArdourContextMenu");
512 track_menu->items().push_back
513 (MenuElem (_("Add Track/Bus"),
514 mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
516 track_menu->popup (1, 0);
522 RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement place)
526 if ((place == PreFader && _pre_redirect == redirect)
527 || (place == PostFader && _post_redirect == redirect)){
531 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
535 if ((send = dynamic_cast<Send *> (redirect)) != 0) {
539 SendUI *send_ui = new SendUI (*send, *session);
541 if (place == PreFader) {
543 _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
544 _active_pre_view = send_ui;
546 pre_redir_hpane.add2 (*_active_pre_view);
547 pre_redir_hpane.show_all();
551 _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
552 _active_post_view = send_ui;
554 post_redir_hpane.add2 (*_active_post_view);
555 post_redir_hpane.show_all();
560 /* its an insert, though we don't know what kind yet. */
562 PluginInsert *plugin_insert;
563 PortInsert *port_insert;
565 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
567 PluginUI *plugin_ui = new PluginUI (session->engine(), *plugin_insert, true);
569 if (place == PreFader) {
571 _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader));
572 plugin_ui->start_updating (0);
573 _active_pre_view = plugin_ui;
574 pre_redir_hpane.pack2 (*_active_pre_view);
575 pre_redir_hpane.show_all();
579 _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader));
580 plugin_ui->start_updating (0);
581 _active_post_view = plugin_ui;
582 post_redir_hpane.pack2 (*_active_post_view);
583 post_redir_hpane.show_all();
586 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
588 PortInsertUI *portinsert_ui = new PortInsertUI (*session, *port_insert);
590 if (place == PreFader) {
592 _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
593 _active_pre_view = portinsert_ui;
594 pre_redir_hpane.pack2 (*_active_pre_view);
595 portinsert_ui->redisplay();
596 pre_redir_hpane.show_all();
600 _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
601 _active_post_view = portinsert_ui;
602 post_redir_hpane.pack2 (*_active_post_view);
603 portinsert_ui->redisplay();
604 post_redir_hpane.show_all();
610 if (place == PreFader) {
611 _pre_redirect = redirect;
614 _post_redirect = redirect;
622 RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect)
624 // not called anymore
626 if (redirect == _pre_redirect) {
630 else if (redirect == _post_redirect) {
639 RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
641 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
643 // delete the current view without calling finish
645 if (place == PreFader) {
646 cleanup_pre_view (false);
650 cleanup_post_view (false);
656 RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
659 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
661 printf ("redirect going away\n");
662 // delete the current view without calling finish
663 if (plugin == _pre_redirect) {
664 cleanup_pre_view (false);
667 else if (plugin == _post_redirect) {
668 cleanup_post_view (false);
675 RouteParams_UI::update_title ()
679 title += _route->name();
682 // if (_redirect && (_current_view == PLUGIN_CONFIG_VIEW || _current_view == SEND_CONFIG_VIEW)) {
683 // title += _redirect->name();
685 // else if (_current_view == INPUT_CONFIG_VIEW) {
686 // title += _("INPUT");
688 // else if (_current_view == OUTPUT_CONFIG_VIEW) {
689 // title += _("OUTPUT");
692 title_label.set_text(title);
694 title = _("ardour: track/bus inspector: ") + title;
698 title_label.set_text(_("No Route Selected"));
699 set_title(_("ardour: track/bus/inspector: no route selected"));
705 RouteParams_UI::start_updating ()
707 update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
708 (mem_fun(*this, &RouteParams_UI::update_views));
712 RouteParams_UI::stop_updating ()
714 update_connection.disconnect();
718 RouteParams_UI::update_views ()
721 // TODO: only do it if correct tab is showing
723 if ((sui = dynamic_cast<SendUI*> (_active_pre_view)) != 0) {
726 if ((sui = dynamic_cast<SendUI*> (_active_post_view)) != 0) {