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 <glibmm/thread.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/audio_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;
59 RouteParams_UI::RouteParams_UI (AudioEngine& eng)
60 : ArdourDialog ("track/bus inspector"),
66 post_redirect_box = 0;
73 _active_post_view = 0;
75 using namespace Notebook_Helpers;
77 input_frame.set_shadow_type(Gtk::SHADOW_NONE);
78 output_frame.set_shadow_type(Gtk::SHADOW_NONE);
80 notebook.set_show_tabs (true);
81 notebook.set_show_border (true);
82 notebook.set_name ("RouteParamNotebook");
84 // create the tree model
85 route_display_model = ListStore::create(route_display_columns);
88 route_display.set_model(route_display_model);
89 route_display.append_column(_("Tracks/Buses"), route_display_columns.text);
90 route_display.set_name(X_("RouteParamsListDisplay"));
91 route_display.get_selection()->set_mode(Gtk::SELECTION_SINGLE); // default
92 route_display.set_reorderable(false);
93 route_display.set_size_request(75, -1);
94 route_display.set_headers_visible(true);
95 route_display.set_headers_clickable(true);
97 route_select_scroller.add(route_display);
98 route_select_scroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
101 route_select_frame.set_name("RouteSelectBaseFrame");
102 route_select_frame.set_shadow_type (Gtk::SHADOW_IN);
103 route_select_frame.add(route_select_scroller);
105 list_vpacker.pack_start (route_select_frame, true, true);
107 notebook.pages().push_back (TabElem (input_frame, _("Inputs")));
108 notebook.pages().push_back (TabElem (output_frame, _("Outputs")));
109 notebook.pages().push_back (TabElem (pre_redir_hpane, _("Pre-fader Redirects")));
110 notebook.pages().push_back (TabElem (post_redir_hpane, _("Post-fader Redirects")));
112 notebook.set_name ("InspectorNotebook");
114 title_label.set_name ("RouteParamsTitleLabel");
118 route_param_frame.set_name("RouteParamsBaseFrame");
119 route_param_frame.set_shadow_type (Gtk::SHADOW_IN);
122 route_hpacker.pack_start (notebook, true, true);
125 route_vpacker.pack_start (title_label, false, false);
126 route_vpacker.pack_start (route_hpacker, true, true);
129 list_hpane.pack1 (list_vpacker);
130 list_hpane.add2 (route_vpacker);
132 list_hpane.set_position(110);
134 pre_redir_hpane.set_position(110);
135 post_redir_hpane.set_position(110);
137 //global_vpacker.pack_start (list_hpane, true, true);
138 //get_vbox()->pack_start (global_vpacker);
139 get_vbox()->pack_start (list_hpane);
142 set_name ("RouteParamsWindow");
143 set_default_size (620,370);
144 set_title (_("ardour: track/bus inspector"));
145 set_wmclass (_("ardour_route_parameters"), "Ardour");
148 route_display.get_selection()->signal_changed().connect(mem_fun(*this, &RouteParams_UI::route_selected));
149 route_display.get_column(0)->signal_clicked().connect(mem_fun(*this, &RouteParams_UI::show_track_menu));
151 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
153 _plugin_selector = new PluginSelector (PluginManager::the_manager());
154 _plugin_selector->signal_delete_event().connect (bind (ptr_fun (just_hide_it),
155 static_cast<Window *> (_plugin_selector)));
158 signal_delete_event().connect(bind(ptr_fun(just_hide_it), static_cast<Gtk::Window *>(this)));
161 RouteParams_UI::~RouteParams_UI ()
166 RouteParams_UI::add_route (Route* route)
168 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route));
170 if (route->hidden()) {
174 TreeModel::Row row = *(route_display_model->append());
175 row[route_display_columns.text] = route->name();
176 row[route_display_columns.route] = route;
178 //route_select_list.rows().back().select ();
180 route->name_changed.connect (bind (mem_fun(*this, &RouteParams_UI::route_name_changed), route));
181 route->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
186 RouteParams_UI::route_name_changed (void *src, Route *route)
188 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route));
191 TreeModel::Children rows = route_display_model->children();
192 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
193 if((*iter)[route_display_columns.route] == route) {
194 (*iter)[route_display_columns.text] = route->name() ;
202 error << _("route display list item for renamed route not found!") << endmsg;
205 if (route == _route) {
206 track_input_label.set_text (route->name());
212 RouteParams_UI::setup_redirect_boxes()
214 if (session && _route) {
216 // just in case... shouldn't need this
217 cleanup_redirect_boxes();
219 // construct new redirect boxes
220 pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection);
221 post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection);
223 pre_redir_hpane.pack1 (*pre_redirect_box);
224 post_redir_hpane.pack1 (*post_redirect_box);
226 pre_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
227 pre_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
228 post_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
229 post_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
231 pre_redir_hpane.show_all();
232 post_redir_hpane.show_all();
238 RouteParams_UI::cleanup_redirect_boxes()
240 if (pre_redirect_box) {
241 pre_redir_hpane.remove(*pre_redirect_box);
242 delete pre_redirect_box;
243 pre_redirect_box = 0;
246 if (post_redirect_box) {
247 post_redir_hpane.remove(*post_redirect_box);
248 delete post_redirect_box;
249 post_redirect_box = 0;
254 RouteParams_UI::setup_io_frames()
259 _input_iosel = new IOSelector (*session, *_route, true);
260 _input_iosel->redisplay ();
261 input_frame.add (*_input_iosel);
262 input_frame.show_all();
265 _output_iosel = new IOSelector (*session, *_route, false);
266 _output_iosel->redisplay ();
267 output_frame.add (*_output_iosel);
268 output_frame.show_all();
272 RouteParams_UI::cleanup_io_frames()
275 _input_iosel->Finished (IOSelector::Cancelled);
276 input_frame.remove();
282 _output_iosel->Finished (IOSelector::Cancelled);
284 output_frame.remove();
285 delete _output_iosel;
291 RouteParams_UI::cleanup_pre_view (bool stopupdate)
293 if (_active_pre_view) {
294 PluginUI * plugui = 0;
296 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_pre_view)) != 0) {
297 plugui->stop_updating (0);
300 _pre_plugin_conn.disconnect();
301 pre_redir_hpane.remove(*_active_pre_view);
302 delete _active_pre_view;
303 _active_pre_view = 0;
308 RouteParams_UI::cleanup_post_view (bool stopupdate)
310 if (_active_post_view) {
311 PluginUI * plugui = 0;
313 if (stopupdate && (plugui = dynamic_cast<PluginUI*>(_active_post_view)) != 0) {
314 plugui->stop_updating (0);
316 _post_plugin_conn.disconnect();
317 post_redir_hpane.remove(*_active_post_view);
318 delete _active_post_view;
319 _active_post_view = 0;
325 RouteParams_UI::route_removed (Route *route)
327 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
329 route_select_list.freeze ();
330 route_select_list.clear ();
331 session->foreach_route (this, &RouteParams_UI::add_route);
332 route_select_list.thaw ();
335 TreeModel::Children rows = route_display_model->children();
336 TreeModel::Children::iterator ri;
338 for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
339 if((*iter)[route_display_columns.route] == route) {
340 route_display_model->erase(iter);
350 cleanup_redirect_boxes();
360 RouteParams_UI::set_session (Session *sess)
362 ArdourDialog::set_session (sess);
364 route_display_model->clear();
367 session->foreach_route (this, &RouteParams_UI::add_route);
368 session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
369 session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_route));
375 //route_select_list.thaw ();
377 _plugin_selector->set_session (session);
382 RouteParams_UI::session_gone ()
384 ENSURE_GUI_THREAD(mem_fun(*this, &RouteParams_UI::session_gone));
386 route_display_model->clear();
391 cleanup_redirect_boxes();
398 ArdourDialog::session_gone();
403 RouteParams_UI::route_selected()
405 Glib::RefPtr<TreeSelection> selection = route_display.get_selection();
406 TreeModel::iterator iter = selection->get_selected(); // only used with Gtk::SELECTION_SINGLE
408 //If anything is selected
409 Route* route = (*iter)[route_display_columns.route] ;
411 if (_route == route) {
416 // remove event binding from previously selected
418 _route_conn.disconnect();
419 _route_ds_conn.disconnect();
420 cleanup_redirect_boxes();
426 // update the other panes with the correct info
428 //update_routeinfo (route);
431 setup_redirect_boxes();
433 // bind to redirects changed event for this route
434 _route_conn = route->redirects_changed.connect (mem_fun(*this, &RouteParams_UI::redirects_changed));
436 track_input_label.set_text (_route->name());
442 _route_conn.disconnect();
448 cleanup_redirect_boxes();
453 track_input_label.set_text(_("NO TRACK"));
460 //RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
463 // _route_conn.disconnect();
466 // cleanup_io_frames();
467 // cleanup_pre_view();
468 // cleanup_post_view();
469 // cleanup_redirect_boxes();
472 // _pre_redirect = 0;
473 // _post_redirect = 0;
474 // track_input_label.set_text(_("NO TRACK"));
480 RouteParams_UI::redirects_changed (void *src)
483 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirects_changed), src));
485 // pre_redirect_list.freeze ();
486 // pre_redirect_list.clear ();
487 // post_redirect_list.freeze ();
488 // post_redirect_list.clear ();
490 // _route->foreach_redirect (this, &RouteParams_UI::add_redirect_to_display);
492 // pre_redirect_list.thaw ();
493 // post_redirect_list.thaw ();
506 RouteParams_UI::show_track_menu()
508 using namespace Menu_Helpers;
510 if (track_menu == 0) {
511 track_menu = new Menu;
512 track_menu->set_name ("ArdourContextMenu");
513 track_menu->items().push_back
514 (MenuElem (_("Add Track/Bus"),
515 mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
517 track_menu->popup (1, 0);
523 RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement place)
527 if ((place == PreFader && _pre_redirect == redirect)
528 || (place == PostFader && _post_redirect == redirect)){
532 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
536 if ((send = dynamic_cast<Send *> (redirect)) != 0) {
540 SendUI *send_ui = new SendUI (*send, *session);
542 if (place == PreFader) {
544 _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
545 _active_pre_view = send_ui;
547 pre_redir_hpane.add2 (*_active_pre_view);
548 pre_redir_hpane.show_all();
552 _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
553 _active_post_view = send_ui;
555 post_redir_hpane.add2 (*_active_post_view);
556 post_redir_hpane.show_all();
561 /* its an insert, though we don't know what kind yet. */
563 PluginInsert *plugin_insert;
564 PortInsert *port_insert;
566 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
568 PluginUI *plugin_ui = new PluginUI (session->engine(), *plugin_insert, true);
570 if (place == PreFader) {
572 _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader));
573 plugin_ui->start_updating (0);
574 _active_pre_view = plugin_ui;
575 pre_redir_hpane.pack2 (*_active_pre_view);
576 pre_redir_hpane.show_all();
580 _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader));
581 plugin_ui->start_updating (0);
582 _active_post_view = plugin_ui;
583 post_redir_hpane.pack2 (*_active_post_view);
584 post_redir_hpane.show_all();
587 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
589 PortInsertUI *portinsert_ui = new PortInsertUI (*session, *port_insert);
591 if (place == PreFader) {
593 _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
594 _active_pre_view = portinsert_ui;
595 pre_redir_hpane.pack2 (*_active_pre_view);
596 portinsert_ui->redisplay();
597 pre_redir_hpane.show_all();
601 _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
602 _active_post_view = portinsert_ui;
603 post_redir_hpane.pack2 (*_active_post_view);
604 portinsert_ui->redisplay();
605 post_redir_hpane.show_all();
611 if (place == PreFader) {
612 _pre_redirect = redirect;
615 _post_redirect = redirect;
623 RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect)
625 // not called anymore
627 if (redirect == _pre_redirect) {
631 else if (redirect == _post_redirect) {
640 RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
642 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
644 // delete the current view without calling finish
646 if (place == PreFader) {
647 cleanup_pre_view (false);
651 cleanup_post_view (false);
657 RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
660 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
662 printf ("redirect going away\n");
663 // delete the current view without calling finish
664 if (plugin == _pre_redirect) {
665 cleanup_pre_view (false);
668 else if (plugin == _post_redirect) {
669 cleanup_post_view (false);
676 RouteParams_UI::update_title ()
680 title += _route->name();
683 // if (_redirect && (_current_view == PLUGIN_CONFIG_VIEW || _current_view == SEND_CONFIG_VIEW)) {
684 // title += _redirect->name();
686 // else if (_current_view == INPUT_CONFIG_VIEW) {
687 // title += _("INPUT");
689 // else if (_current_view == OUTPUT_CONFIG_VIEW) {
690 // title += _("OUTPUT");
693 title_label.set_text(title);
695 title = _("ardour: track/bus inspector: ") + title;
699 title_label.set_text(_("No Route Selected"));
700 set_title(_("ardour: track/bus/inspector: no route selected"));
706 RouteParams_UI::start_updating ()
708 update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
709 (mem_fun(*this, &RouteParams_UI::update_views));
713 RouteParams_UI::stop_updating ()
715 update_connection.disconnect();
719 RouteParams_UI::update_views ()
722 // TODO: only do it if correct tab is showing
724 if ((sui = dynamic_cast<SendUI*> (_active_pre_view)) != 0) {
727 if ((sui = dynamic_cast<SendUI*> (_active_post_view)) != 0) {