2 Copyright (C) 2000-2006 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 <sigc++/bind.h>
25 #include <gtkmm/messagedialog.h>
27 #include "pbd/convert.h"
28 #include "pbd/enumwriter.h"
29 #include "pbd/replace_all.h"
30 #include "pbd/stacktrace.h"
32 #include "ardour/amp.h"
33 #include "ardour/audioengine.h"
34 #include "ardour/internal_send.h"
35 #include "ardour/io.h"
36 #include "ardour/pannable.h"
37 #include "ardour/panner.h"
38 #include "ardour/panner_shell.h"
39 #include "ardour/panner_manager.h"
40 #include "ardour/port.h"
41 #include "ardour/profile.h"
42 #include "ardour/route.h"
43 #include "ardour/send.h"
44 #include "ardour/session.h"
45 #include "ardour/types.h"
46 #include "ardour/user_bundle.h"
48 #include "gtkmm2ext/gtk_ui.h"
49 #include "gtkmm2ext/menu_elems.h"
50 #include "gtkmm2ext/utils.h"
51 #include "gtkmm2ext/doi.h"
53 #include "widgets/tooltips.h"
55 #include "ardour_window.h"
56 #include "enums_convert.h"
57 #include "foldback_strip.h"
60 #include "public_editor.h"
62 #include "io_selector.h"
64 #include "gui_thread.h"
65 #include "ui_config.h"
69 using namespace ARDOUR;
70 using namespace ArdourWidgets;
73 using namespace Gtkmm2ext;
76 FoldbackStrip* FoldbackStrip::_entered_foldback_strip;
77 PBD::Signal1<void,FoldbackStrip*> FoldbackStrip::CatchDeletion;
79 FoldbackStrip::FoldbackStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt)
80 : SessionHandlePtr (sess)
86 , button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL))
87 , mute_solo_table (1, 2)
88 , bottom_button_table (1, 1)
89 , _plugin_insert_cnt (0)
90 , _comment_button (_("Comments"))
91 , fb_level_control (0)
92 // , _visibility (X_("mixer-element-visibility"))
100 FoldbackStrip::init ()
102 _entered_foldback_strip= 0;
104 route_select_menu = 0;
105 ignore_comment_edit = false;
106 ignore_toggle = false;
110 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
111 longest_label = "longest label";
114 output_button.set_text (_("Output"));
115 output_button.set_name ("mixer strip button");
116 // send_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
117 // send_scroller.add (send_display);
119 send_display.set_flags (CAN_FOCUS);
120 send_display.set_name ("ProcessorList");
121 send_display.set_data ("sendbox", this);
122 send_display.set_size_request (48, -1);
123 send_display.set_spacing (0);
125 insert_box = new ProcessorBox (0, boost::bind (&FoldbackStrip::plugin_selector, this), _pr_selection, 0);
126 insert_box->set_no_show_all ();
128 insert_box->set_session (_session);
130 // send_scroller.show ();
131 send_display.show ();
133 // TODO implement ArdourKnob::on_size_request properly
134 fb_level_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent);
136 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
137 fb_level_control->set_size_request (PX_SCALE(65), PX_SCALE(65));
139 fb_level_control->set_tooltip_prefix (_("Level: "));
140 fb_level_control->set_name ("monitor section knob");
141 fb_level_control->set_no_show_all (true);
143 bottom_button_table.attach (*fb_level_control, 0, 1, 0, 1,FILL,FILL,20,20); //EXPAND
146 mute_solo_table.set_homogeneous (true);
147 mute_solo_table.set_spacings (2);
149 show_sends_button->set_text (_("Show Sends"));
151 show_sends_box.pack_start (*show_sends_button, true, true);
152 show_sends_button->show();
154 bottom_button_table.set_spacings (20);
155 bottom_button_table.set_row_spacings (20);
156 bottom_button_table.set_homogeneous (true);
158 name_button.set_name ("monitor section button");
159 name_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
161 _select_button.set_name ("monitor section button");
162 _select_button.set_text (_("Select Foldback Bus"));
164 _comment_button.set_name (X_("mixer strip button"));
165 _comment_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
166 _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor));
168 global_vpacker.set_border_width (1);
170 global_vpacker.set_spacing (4);
171 global_vpacker.pack_start (_select_button, Gtk::PACK_SHRINK);
172 global_vpacker.pack_start (name_button, Gtk::PACK_SHRINK);
173 global_vpacker.pack_start (_invert_button_box, Gtk::PACK_SHRINK);
174 global_vpacker.pack_start (show_sends_box, Gtk::PACK_SHRINK);
177 //add a spacer underneath the foldback bus;
178 //this fills the area that is taken up by the scrollbar on the tracks;
179 //and therefore keeps the strip boxes "even" across the bottom
180 int scrollbar_height = 0;
182 Gtk::Window window (WINDOW_TOPLEVEL);
183 HScrollbar scrollbar;
184 window.add (scrollbar);
185 scrollbar.set_name ("MixerWindow");
186 scrollbar.ensure_style();
187 Gtk::Requisition requisition(scrollbar.size_request ());
188 scrollbar_height = requisition.height;
190 spacer.set_size_request (-1, scrollbar_height);
191 global_vpacker.pack_end (spacer, false, false);
193 global_vpacker.pack_end (_comment_button, Gtk::PACK_SHRINK);
194 global_vpacker.pack_end (output_button, Gtk::PACK_SHRINK);
195 global_vpacker.pack_end (mute_solo_table, Gtk::PACK_SHRINK);
196 global_vpacker.pack_end (panners, Gtk::PACK_SHRINK);
197 global_vpacker.pack_end (bottom_button_table, Gtk::PACK_SHRINK);
198 // global_vpacker.pack_end (*insert_box, true, true);
199 global_vpacker.pack_end (*insert_box, Gtk::PACK_SHRINK);
201 global_frame.add (global_vpacker);
202 global_frame.set_shadow_type (Gtk::SHADOW_IN);
203 global_frame.set_name ("BaseFrame");
207 /* force setting of visible selected status */
210 set_selected (false);
215 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::engine_stopped, this), gui_context());
216 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::engine_running, this), gui_context());
218 output_button.set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
220 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::output_press), false);
221 output_button.signal_button_release_event().connect (sigc::mem_fun(*this, &FoldbackStrip::output_release), false);
224 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::name_button_button_press), false);
225 _select_button.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackStrip::select_button_button_press), false);
230 /* start off as a passthru strip. we'll correct this, if necessary,
231 in update_diskstream_display().
236 add_events (Gdk::BUTTON_RELEASE_MASK|
237 Gdk::ENTER_NOTIFY_MASK|
238 Gdk::LEAVE_NOTIFY_MASK|
240 Gdk::KEY_RELEASE_MASK);
242 set_flags (get_flags() | Gtk::CAN_FOCUS);
244 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
245 *this, invalidator (*this), boost::bind (&FoldbackStrip::port_connected_or_disconnected, this, _1, _3), gui_context ()
248 /* Add the widgets under visibility control to the VisibilityGroup; the names used here
249 must be the same as those used in RCOptionEditor so that the configuration changes
250 are recognised when they occur.
252 /* _visibility.add (&_invert_button_box, X_("PhaseInvert"), _("Phase Invert"), false);
253 _visibility.add (&output_button, X_("Output"), _("Output"), false);
254 _visibility.add (&_comment_button, X_("Comments"), _("Comments"), false);
256 parameter_changed (X_("mixer-element-visibility"));
257 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &FoldbackStrip::parameter_changed));
258 Config->ParameterChanged.connect (_config_connection, MISSING_INVALIDATOR, boost::bind (&FoldbackStrip::parameter_changed, this, _1), gui_context());
259 _session->config.ParameterChanged.connect (_config_connection, MISSING_INVALIDATOR, boost::bind (&FoldbackStrip::parameter_changed, this, _1), gui_context());
261 //watch for mouse enter/exit so we can do some stuff
262 signal_enter_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_enter_event ));
263 signal_leave_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_leave_event ));
267 FoldbackStrip::~FoldbackStrip ()
269 CatchDeletion (this);
270 delete fb_level_control;
271 fb_level_control = 0;
273 if (this ==_entered_foldback_strip)
274 _entered_foldback_strip = NULL;
278 FoldbackStrip::mixer_strip_enter_event (GdkEventCrossing* /*ev*/)
280 _entered_foldback_strip = this;
282 //although we are triggering on the "enter", to the user it will appear that it is happenin on the "leave"
283 //because the FoldbackStrip control is a parent that encompasses the strip
284 deselect_all_processors();
290 FoldbackStrip::mixer_strip_leave_event (GdkEventCrossing *ev)
292 //if we have moved outside our strip, but not into a child view, then deselect ourselves
293 if ( !(ev->detail == GDK_NOTIFY_INFERIOR) ) {
294 _entered_foldback_strip= 0;
302 FoldbackStrip::name() const
305 return _route->name();
311 FoldbackStrip::update_fb_level_control ()
313 fb_level_control->show ();
314 fb_level_control->set_controllable (_route->gain_control());
318 FoldbackStrip::set_route (boost::shared_ptr<Route> rt)
322 RouteUI::self_delete ();
326 if (show_sends_button->get_parent()) {
327 show_sends_box.remove (*show_sends_button);
330 RouteUI::set_route (rt);
332 /* ProcessorBox needs access to _route so that it can read
335 // processor_box.set_route (rt);
336 insert_box->set_route (rt);
338 revert_to_default_display ();
341 // mute_solo_table.attach (gpm.gain_display,0,1,1,2, EXPAND|FILL, EXPAND);
342 // mute_solo_table.attach (gpm.peak_display,1,2,1,2, EXPAND|FILL, EXPAND);
344 if (solo_button->get_parent()) {
345 mute_solo_table.remove (*solo_button);
348 if (mute_button->get_parent()) {
349 mute_solo_table.remove (*mute_button);
352 mute_solo_table.attach (*mute_button, 0, 1, 0, 1);
353 mute_solo_table.attach (*solo_button, 1, 2, 0, 1);
354 mute_button->show ();
355 solo_button->show ();
356 show_sends_box.show ();
360 update_fb_level_control();
362 show_sends_box.pack_start (*show_sends_button, true, true);
363 show_sends_button->show();
366 delete route_ops_menu;
369 delete route_select_menu;
370 route_select_menu = 0;
372 _route->output()->changed.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::update_output_display, this), gui_context());
374 _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::io_changed_proxy, this), gui_context ());
376 if (_route->panner_shell()) {
377 update_panner_choices();
378 _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::connect_to_pan, this), gui_context());
381 _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::setup_comment_button, this), gui_context());
383 set_stuff_from_route ();
385 /* now force an update of all the various elements */
387 update_mute_display ();
388 update_solo_display ();
393 panners.setup_pan ();
396 update_output_display ();
398 add_events (Gdk::BUTTON_RELEASE_MASK);
402 Route::FedBy fed_by = _route->fed_by();
403 for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) {
405 boost::shared_ptr<Route> s_rt (i->r.lock());
406 boost::shared_ptr<Send> snd = s_rt->internal_send_for (_route);
407 //s_rt->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&FoldbackStrip::fill_sendbox, this), this);
408 boost::shared_ptr<Processor> processor (snd);
409 //boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
410 // Ok we have the info... now we need widgets to put it in... I suspect I need a class or three
411 // this doesn't work... and I need to clear it out and rebuild each time.
412 ArdourWidgets::ArdourButton _button;
413 _button.set_distinct_led_click (true);
414 _button.set_fallthrough_to_parent(true);
415 _button.set_led_left (true);
416 // _button.signal_led_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::led_clicked));
417 _button.set_text (s_rt->name ());
419 //Gtk::VBox snd_entry = NULL;
421 snd_entry.set_border_width (1);
422 snd_entry.set_spacing (4);
423 snd_entry.pack_start (_button, true, true);
424 send_display.pack_start (snd_entry, true, true);
435 global_vpacker.show();
436 mute_solo_table.show();
437 bottom_button_table.show();
438 show_sends_box.show_all();
439 //send_scroller.show ();
440 send_display.show ();
441 output_button.show();
443 _select_button.show();
444 _comment_button.show();
452 FoldbackStrip::set_stuff_from_route ()
454 /* if width is not set, it will be set by the MixerUI or editor */
457 if (get_gui_property ("strip-width", width)) {
458 // set_width_enum (width, this);
463 FoldbackStrip::set_packed (bool yn)
466 set_gui_property ("visible", _packed);
470 struct RouteCompareByName {
471 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
472 return a->name().compare (b->name()) < 0;
477 FoldbackStrip::output_release (GdkEventButton *ev)
479 switch (ev->button) {
481 edit_output_configuration ();
489 FoldbackStrip::output_press (GdkEventButton *ev)
491 using namespace Menu_Helpers;
492 if (!ARDOUR_UI_UTILS::engine_is_running ()) {
496 MenuList& citems = output_menu.items();
497 switch (ev->button) {
500 return false; //wait for the mouse-up to pop the dialog
504 output_menu.set_name ("ArdourContextMenu");
506 output_menu_bundles.clear ();
508 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
510 citems.push_back (SeparatorElem());
511 uint32_t const n_with_separator = citems.size ();
513 ARDOUR::BundleList current = _route->output()->bundles_connected ();
515 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
517 /* guess the user-intended main type of the route output */
518 DataType intended_type = guess_main_type(false);
520 /* try adding the master bus first */
521 boost::shared_ptr<Route> master = _session->master_out();
523 maybe_add_bundle_to_output_menu (master->input()->bundle(), current, intended_type);
526 /* then other routes inputs */
527 RouteList copy = _session->get_routelist ();
528 copy.sort (RouteCompareByName ());
529 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
530 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current, intended_type);
533 /* then try adding user bundles, often labeled/grouped physical inputs */
534 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
535 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
536 maybe_add_bundle_to_output_menu (*i, current, intended_type);
540 /* then all other bundles, including physical outs or other sofware */
541 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
542 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
543 maybe_add_bundle_to_output_menu (*i, current, intended_type);
547 if (citems.size() == n_with_separator) {
548 /* no routes added; remove the separator */
552 if (!ARDOUR::Profile->get_mixbus()) {
553 citems.push_back (SeparatorElem());
555 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
558 string_compose (_("Add %1 port"), (*i).to_i18n_string()),
559 sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::add_output_port), *i)
565 citems.push_back (SeparatorElem());
566 citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));
568 Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "",
581 FoldbackStrip::bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle> c)
587 _route->output()->connect_ports_to_bundle (c, true, true, this);
591 FoldbackStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const& /*current*/,
594 using namespace Menu_Helpers;
596 /* The bundle should be an input one, but not ours */
597 if (b->ports_are_inputs() == false || *b == *_route->input()->bundle()) {
601 /* Don't add the monitor input unless we are Master */
602 boost::shared_ptr<Route> monitor = _session->monitor_out();
603 if ((!_route->is_master()) && monitor && b->has_same_ports (monitor->input()->bundle()))
606 /* It should either match exactly our outputs (if |type| is DataType::NIL)
607 * or have the same number of |type| channels than our outputs. */
608 if (type == DataType::NIL) {
609 if(b->nchannels() != _route->n_outputs())
612 if (b->nchannels().n(type) != _route->n_outputs().n(type))
616 /* Avoid adding duplicates */
617 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
618 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
621 if (i != output_menu_bundles.end()) {
625 /* Now add the bundle to the menu */
626 output_menu_bundles.push_back (b);
628 MenuList& citems = output_menu.items();
629 citems.push_back (MenuElemNoMnemonic (b->name (), sigc::bind (sigc::mem_fun(*this, &FoldbackStrip::bundle_output_chosen), b)));
633 FoldbackStrip::connect_to_pan ()
635 ENSURE_GUI_THREAD (*this, &FoldbackStrip::connect_to_pan)
637 panstate_connection.disconnect ();
638 panstyle_connection.disconnect ();
640 if (!_route->panner()) {
644 boost::shared_ptr<Pannable> p = _route->pannable ();
646 //p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
648 /* This call reduncant, PannerUI::set_panner() connects to _panshell->Changed itself
649 * However, that only works a panner was previously set.
651 * PannerUI must remain subscribed to _panshell->Changed() in case
652 * we switch the panner eg. AUX-Send and back
653 * _route->panner_shell()->Changed() vs _panshell->Changed
655 /*if (panners._panner == 0) {
656 panners.panshell_changed ();
658 update_panner_choices();
662 FoldbackStrip::update_panner_choices ()
664 ENSURE_GUI_THREAD (*this, &FoldbackStrip::update_panner_choices)
665 if (!_route->panner_shell()) { return; }
667 uint32_t in = _route->output()->n_ports().n_audio();
669 if (_route->panner()) {
670 in = _route->panner()->in().n_audio();
673 panners.set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
677 FoldbackStrip::guess_main_type(bool for_input, bool favor_connected) const
679 /* The heuristic follows these principles:
680 * A) If all ports that the user connected are of the same type, then he
681 * very probably intends to use the IO with that type. A common subcase
682 * is when the IO has only ports of the same type (connected or not).
683 * B) If several types of ports are connected, then we should guess based
684 * on the likeliness of the user wanting to use a given type.
685 * We assume that the DataTypes are ordered from the most likely to the
686 * least likely when iterating or comparing them with "<".
687 * C) If no port is connected, the same logic can be applied with all ports
688 * instead of connected ones. TODO: Try other ideas, for instance look at
689 * the last plugin output when |for_input| is false (note: when StrictIO
690 * the outs of the last plugin should be the same as the outs of the route
691 * modulo the panner which forwards non-audio anyway).
692 * All of these constraints are respected by the following algorithm that
693 * just returns the most likely datatype found in connected ports if any, or
694 * available ports if any (since if all ports are of the same type, the most
695 * likely found will be that one obviously). */
697 boost::shared_ptr<IO> io = for_input ? _route->input() : _route->output();
699 /* Find most likely type among connected ports */
700 if (favor_connected) {
701 DataType type = DataType::NIL; /* NIL is always last so least likely */
702 for (PortSet::iterator p = io->ports().begin(); p != io->ports().end(); ++p) {
703 if (p->connected() && p->type() < type)
706 if (type != DataType::NIL) {
707 /* There has been a connected port (necessarily non-NIL) */
712 /* Find most likely type among available ports.
713 * The iterator stops before NIL. */
714 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
715 if (io->n_ports().n(*t) > 0)
719 /* No port at all, return the most likely datatype by default */
720 return DataType::front();
724 * Output port labelling
726 * Case 1: Each output has one connection, all connections are to system:playback_%i
727 * out 1 -> system:playback_1
728 * out 2 -> system:playback_2
729 * out 3 -> system:playback_3
732 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
733 * out 1 -> ardour:track_x/in 1
734 * out 2 -> ardour:track_x/in 2
735 * Display as: track_x
737 * Case 3: Each output has one connection, all connections are to Jack client "program x"
738 * out 1 -> program x:foo
739 * out 2 -> program x:foo
740 * Display as: program x
742 * Case 4: No connections (Disconnected)
745 * Default case (unusual routing):
746 * Display as: *number of connections*
751 * .-----------------------------------------------.
753 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
754 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
755 * '-----------------------------------------------'
756 * .-----------------------------------------------.
759 * '-----------------------------------------------'
763 FoldbackStrip::update_io_button ()
765 ostringstream tooltip;
767 bool have_label = false;
769 uint32_t total_connection_count = 0;
770 uint32_t typed_connection_count = 0;
771 bool each_typed_port_has_one_connection = true;
773 DataType dt = guess_main_type(false);
774 boost::shared_ptr<IO> io = _route->output();
776 /* Fill in the tooltip. Also count:
777 * - The total number of connections.
778 * - The number of main-typed connections.
779 * - Whether each main-typed port has exactly one connection. */
781 tooltip << string_compose (_("<b>OUTPUT</b> from %1"),
782 Gtkmm2ext::markup_escape_text (_route->name()));
784 string arrow = Gtkmm2ext::markup_escape_text(" -> ");
785 vector<string> port_connections;
786 for (PortSet::iterator port = io->ports().begin();
787 port != io->ports().end();
789 port_connections.clear();
790 port->get_connections(port_connections);
792 uint32_t port_connection_count = 0;
794 for (vector<string>::iterator i = port_connections.begin();
795 i != port_connections.end();
797 ++port_connection_count;
799 if (port_connection_count == 1) {
800 tooltip << endl << Gtkmm2ext::markup_escape_text (
801 port->name().substr(port->name().find("/") + 1));
807 tooltip << Gtkmm2ext::markup_escape_text(*i);
810 total_connection_count += port_connection_count;
811 if (port->type() == dt) {
812 typed_connection_count += port_connection_count;
813 each_typed_port_has_one_connection &= (port_connection_count == 1);
818 if (total_connection_count == 0) {
819 tooltip << endl << _("Disconnected");
822 if (typed_connection_count == 0) {
827 /* Are all main-typed channels connected to the same route ? */
829 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
830 for (ARDOUR::RouteList::const_iterator route = routes->begin();
831 route != routes->end();
833 boost::shared_ptr<IO> dest_io = (*route)->output();
834 if (io->bundle()->connected_to(dest_io->bundle(),
837 label << Gtkmm2ext::markup_escape_text ((*route)->name());
844 /* Are all main-typed channels connected to the same (user) bundle ? */
846 boost::shared_ptr<ARDOUR::BundleList> bundles = _session->bundles ();
847 for (ARDOUR::BundleList::iterator bundle = bundles->begin();
848 bundle != bundles->end();
850 if (boost::dynamic_pointer_cast<UserBundle> (*bundle) == 0)
852 if (io->bundle()->connected_to(*bundle, _session->engine(),
854 label << Gtkmm2ext::markup_escape_text ((*bundle)->name());
861 /* Is each main-typed channel only connected to a physical output ? */
862 if (!have_label && each_typed_port_has_one_connection) {
863 ostringstream temp_label;
865 string playorcapture;
867 _session->engine().get_physical_outputs(dt, phys);
868 playorcapture = "playback_";
869 for (PortSet::iterator port = io->ports().begin(dt);
870 port != io->ports().end(dt);
873 for (vector<string>::iterator s = phys.begin();
876 if (!port->connected_to(*s))
878 pn = AudioEngine::instance()->get_pretty_name_by_name(*s);
880 string::size_type start = (*s).find(playorcapture);
881 if (start != string::npos) {
882 pn = (*s).substr(start + playorcapture.size());
888 temp_label.str(""); /* erase the failed attempt */
891 if (port != io->ports().begin(dt))
896 if (!temp_label.str().empty()) {
897 label << temp_label.str();
902 /* Is each main-typed channel connected to a single and different port with
903 * the same client name (e.g. another JACK client) ? */
904 if (!have_label && each_typed_port_has_one_connection) {
905 string maybe_client = "";
906 vector<string> connections;
907 for (PortSet::iterator port = io->ports().begin(dt);
908 port != io->ports().end(dt);
910 port_connections.clear();
911 port->get_connections(port_connections);
912 string connection = port_connections.front();
914 vector<string>::iterator i = connections.begin();
915 while (i != connections.end() && *i != connection) {
918 if (i != connections.end())
919 break; /* duplicate connection */
920 connections.push_back(connection);
922 connection = connection.substr(0, connection.find(":"));
923 if (maybe_client.empty())
924 maybe_client = connection;
925 if (maybe_client != connection)
928 if (connections.size() == io->n_ports().n(dt)) {
929 label << maybe_client;
934 /* Odd configuration */
936 label << "*" << total_connection_count << "*";
939 if (total_connection_count > typed_connection_count) {
940 label << "\u2295"; /* circled plus */
943 /* Actually set the properties of the button */
944 char * cstr = new char[tooltip.str().size() + 1];
945 strcpy(cstr, tooltip.str().c_str());
947 output_button.set_text (label.str());
948 set_tooltip (&output_button, cstr);
954 FoldbackStrip::update_output_display ()
957 panners.setup_pan ();
959 if (has_audio_outputs ()) {
967 FoldbackStrip::io_changed_proxy ()
969 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &FoldbackStrip::update_panner_choices));
973 FoldbackStrip::port_connected_or_disconnected (boost::weak_ptr<Port> wa, boost::weak_ptr<Port> wb)
975 boost::shared_ptr<Port> a = wa.lock ();
976 boost::shared_ptr<Port> b = wb.lock ();
978 if ((a && _route->output()->has_port (a)) || (b && _route->output()->has_port (b))) {
979 update_output_display ();
984 FoldbackStrip::setup_comment_button ()
986 std::string comment = _route->comment();
988 set_tooltip (_comment_button, comment.empty() ? _("Click to add/edit comments") : _route->comment());
990 if (comment.empty ()) {
991 _comment_button.set_name ("generic button");
992 _comment_button.set_text (_("Comments"));
996 _comment_button.set_name ("comment button");
998 string::size_type pos = comment.find_first_of (" \t\n");
999 if (pos != string::npos) {
1000 comment = comment.substr (0, pos);
1002 if (comment.empty()) {
1003 _comment_button.set_text (_("Comments"));
1005 _comment_button.set_text (comment);
1010 FoldbackStrip::show_passthru_color ()
1012 //reset_strip_style ();
1017 FoldbackStrip::help_count_plugins (boost::weak_ptr<Processor> p)
1019 boost::shared_ptr<Processor> processor (p.lock ());
1020 if (!processor || !processor->display_to_user()) {
1023 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
1025 if (pi && pi->is_channelstrip ()) {
1030 ++_plugin_insert_cnt;
1034 FoldbackStrip::build_route_ops_menu ()
1036 using namespace Menu_Helpers;
1037 route_ops_menu = new Menu;
1038 route_ops_menu->set_name ("ArdourContextMenu");
1040 MenuList& items = route_ops_menu->items();
1042 items.push_back (MenuElem (_("Comments..."), sigc::mem_fun (*this, &RouteUI::open_comment_editor)));
1044 items.push_back (MenuElem (_("Outputs..."), sigc::mem_fun (*this, &RouteUI::edit_output_configuration)));
1046 items.push_back (SeparatorElem());
1048 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1050 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1052 items.push_back (SeparatorElem());
1053 items.push_back (CheckMenuElem (_("Active")));
1054 Gtk::CheckMenuItem* i = dynamic_cast<Gtk::CheckMenuItem *> (&items.back());
1055 i->set_active (_route->active());
1056 i->set_sensitive(! _session->transport_rolling());
1057 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
1059 items.push_back (SeparatorElem());
1060 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1061 denormal_menu_item = dynamic_cast<Gtk::CheckMenuItem *> (&items.back());
1062 denormal_menu_item->set_active (_route->denormal_protection());
1064 items.push_back (SeparatorElem());
1065 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &FoldbackStrip::remove_current_fb)));
1069 FoldbackStrip::build_route_select_menu ()
1071 using namespace Menu_Helpers;
1072 route_select_menu = new Menu;
1073 route_select_menu->set_name ("ArdourContextMenu");
1075 MenuList& items = route_select_menu->items();
1076 StripableList fb_list;
1077 _session->get_stripables (fb_list, PresentationInfo::FoldbackBus);
1078 for (StripableList::iterator s = fb_list.begin(); s != fb_list.end(); ++s) {
1080 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> ((*s));
1081 if (route == _route) {
1084 items.push_back (MenuElem (route->name (), sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::set_route), route)));
1091 FoldbackStrip::name_button_button_press (GdkEventButton* ev)
1093 if (ev->button == 1 || ev->button == 3) {
1094 list_route_operations ();
1096 if (ev->button == 1) {
1097 Gtkmm2ext::anchored_menu_popup(route_ops_menu, &name_button, "",
1100 route_ops_menu->popup (3, ev->time);
1110 FoldbackStrip::select_button_button_press (GdkEventButton* ev)
1112 if (ev->button == 1 || ev->button == 3) {
1115 if (ev->button == 1) {
1116 Gtkmm2ext::anchored_menu_popup(route_select_menu, &_select_button, "",
1119 route_select_menu->popup (3, ev->time);
1129 FoldbackStrip::list_route_operations ()
1131 delete route_ops_menu;
1132 build_route_ops_menu ();
1136 FoldbackStrip::list_fb_routes ()
1138 delete route_select_menu;
1139 build_route_select_menu ();
1143 FoldbackStrip::set_selected (bool yn)
1145 AxisView::set_selected (yn);
1148 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1149 global_frame.set_name ("MixerStripSelectedFrame");
1151 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1152 global_frame.set_name ("MixerStripFrame");
1155 global_frame.queue_draw ();
1158 // processor_box.deselect_all_processors();
1162 FoldbackStrip::route_property_changed (const PropertyChange& what_changed)
1164 if (what_changed.contains (ARDOUR::Properties::name)) {
1170 FoldbackStrip::name_changed ()
1173 name_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
1174 name_button.set_text (_route->name());
1176 set_tooltip (name_button, Gtkmm2ext::markup_escape_text(_route->name()));
1181 FoldbackStrip::output_button_resized (Gtk::Allocation& alloc)
1183 //output_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE);
1187 FoldbackStrip::name_button_resized (Gtk::Allocation& alloc)
1189 //name_button.set_layout_ellipsize_width (20);
1193 FoldbackStrip::comment_button_resized (Gtk::Allocation& alloc)
1195 //_comment_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE);
1199 FoldbackStrip::set_embedded (bool yn)
1205 FoldbackStrip::map_frozen ()
1207 ENSURE_GUI_THREAD (*this, &FoldbackStrip::map_frozen)
1210 RouteUI::map_frozen ();
1214 FoldbackStrip::hide_redirect_editors ()
1216 _route->foreach_processor (sigc::mem_fun (*this, &FoldbackStrip::hide_processor_editor));
1220 FoldbackStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1222 boost::shared_ptr<Processor> processor (p.lock ());
1227 // Gtk::Window* w = processor_box.get_processor_ui (processor);
1228 Gtk::Window* w = insert_box->get_processor_ui (processor);
1236 FoldbackStrip::reset_strip_style ()
1238 if (_route->active()) {
1239 set_name ("AudioBusStripBase");
1241 set_name ("AudioBusStripBaseInactive");
1247 FoldbackStrip::engine_stopped ()
1252 FoldbackStrip::engine_running ()
1257 FoldbackStrip::drop_send ()
1259 boost::shared_ptr<Send> current_send;
1261 if (_current_delivery && ((current_send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0)) {
1262 current_send->set_metering (false);
1265 send_gone_connection.disconnect ();
1266 output_button.set_sensitive (true);
1267 set_invert_sensitive (true);
1268 mute_button->set_sensitive (true);
1269 solo_button->set_sensitive (true);
1270 _comment_button.set_sensitive (true);
1271 fb_level_control->set_sensitive (true);
1272 set_button_names (); // update solo button visual state
1276 FoldbackStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1278 _current_delivery = d;
1279 DeliveryChanged (_current_delivery);
1283 FoldbackStrip::revert_to_default_display ()
1287 set_current_delivery (_route->main_outs ());
1289 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1290 update_panner_choices();
1291 panner_ui().setup_pan ();
1292 panner_ui().set_send_drawing_mode (false);
1294 if (has_audio_outputs ()) {
1295 panners.show_all ();
1297 panners.hide_all ();
1300 reset_strip_style ();
1304 FoldbackStrip::set_button_names ()
1307 mute_button->set_text (_("Mute"));
1309 if (_route && _route->solo_safe_control()->solo_safe()) {
1310 solo_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() | Gtkmm2ext::Insensitive));
1312 solo_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() & ~Gtkmm2ext::Insensitive));
1314 if (!Config->get_solo_control_is_listen_control()) {
1315 solo_button->set_text (_("Solo"));
1317 switch (Config->get_listen_position()) {
1318 case AfterFaderListen:
1319 solo_button->set_text (_("AFL"));
1321 case PreFaderListen:
1322 solo_button->set_text (_("PFL"));
1329 FoldbackStrip::plugin_selector()
1331 return _mixer.plugin_selector();
1335 FoldbackStrip::state_id () const
1337 return string_compose ("strip %1", _route->id().to_s());
1341 FoldbackStrip::add_output_port (DataType t)
1343 _route->output()->add_port ("", this, t);
1347 FoldbackStrip::route_active_changed ()
1349 reset_strip_style ();
1353 FoldbackStrip::copy_processors ()
1355 // processor_box.processor_operation (ProcessorBox::ProcessorsCopy);
1356 insert_box->processor_operation (ProcessorBox::ProcessorsCopy);
1360 FoldbackStrip::cut_processors ()
1362 // processor_box.processor_operation (ProcessorBox::ProcessorsCut);
1363 insert_box->processor_operation (ProcessorBox::ProcessorsCut);
1367 FoldbackStrip::paste_processors ()
1369 insert_box->processor_operation (ProcessorBox::ProcessorsPaste);
1373 FoldbackStrip::select_all_processors ()
1375 insert_box->processor_operation (ProcessorBox::ProcessorsSelectAll);
1379 FoldbackStrip::deselect_all_processors ()
1381 // processor_box.processor_operation (ProcessorBox::ProcessorsSelectNone);
1382 insert_box->processor_operation (ProcessorBox::ProcessorsSelectNone);
1386 FoldbackStrip::delete_processors ()
1388 return insert_box->processor_operation (ProcessorBox::ProcessorsDelete);
1392 FoldbackStrip::toggle_processors ()
1394 insert_box->processor_operation (ProcessorBox::ProcessorsToggleActive);
1398 FoldbackStrip::ab_plugins ()
1400 insert_box->processor_operation (ProcessorBox::ProcessorsAB);
1404 FoldbackStrip::build_sends_menu ()
1406 using namespace Menu_Helpers;
1408 sends_menu = new Menu;
1409 sends_menu->set_name ("ArdourContextMenu");
1410 MenuList& items = sends_menu->items();
1413 MenuElem(_("Assign all tracks"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, false))
1417 MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true))
1421 MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, false))
1425 MenuElem(_("Assign selected tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true)));
1427 items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track)));
1428 items.push_back (MenuElem(_("Set sends gain to -inf"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_zero)));
1429 items.push_back (MenuElem(_("Set sends gain to 0dB"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_unity)));
1434 FoldbackStrip::color () const
1436 return route_color ();
1440 FoldbackStrip::marked_for_display () const
1442 return !_route->presentation_info().hidden();
1446 FoldbackStrip::remove_current_fb ()
1448 StripableList slist;
1449 boost::shared_ptr<Route> next = boost::shared_ptr<Route> ();
1450 boost::shared_ptr<Route> old_route = _route;
1451 _session->get_stripables (slist, PresentationInfo::FoldbackBus);
1452 if (slist.size ()) {
1453 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
1454 if ((*s) != _route) {
1455 next = boost::dynamic_pointer_cast<Route> (*s);
1463 _session->remove_route (old_route);