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)
85 , button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL))
86 , mute_solo_table (1, 2)
87 , bottom_button_table (1, 1)
88 , _comment_button (_("Comments"))
89 , fb_level_control (0)
96 FoldbackStrip::init ()
98 _entered_foldback_strip= 0;
100 route_select_menu = 0;
101 ignore_comment_edit = false;
102 ignore_toggle = false;
106 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
107 longest_label = "longest label";
109 //input_button_box.set_spacing(2);
112 output_button.set_text (_("Output"));
113 output_button.set_name ("foldback strip button");
114 // send_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
115 // send_scroller.add (send_display);
117 send_display.set_flags (CAN_FOCUS);
118 send_display.set_name ("ProcessorList");
119 send_display.set_data ("sendbox", this);
120 send_display.set_size_request (48, -1);
121 send_display.set_spacing (0);
124 // send_scroller.show ();
125 send_display.show ();
127 // TODO implement ArdourKnob::on_size_request properly
128 fb_level_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent);
130 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
131 fb_level_control->set_size_request (PX_SCALE(65), PX_SCALE(65));
133 fb_level_control->set_tooltip_prefix (_("Level: "));
134 fb_level_control->set_name ("monitor section knob");
135 fb_level_control->set_no_show_all (true);
137 bottom_button_table.attach (*fb_level_control, 0, 1, 0, 1,FILL,FILL,20,20); //EXPAND
140 mute_solo_table.set_homogeneous (true);
141 mute_solo_table.set_spacings (2);
143 show_sends_button->set_text (_("Show Sends"));
145 show_sends_box.pack_start (*show_sends_button, true, true);
146 show_sends_button->show();
148 bottom_button_table.set_spacings (20);
149 bottom_button_table.set_row_spacings (20);
150 bottom_button_table.set_homogeneous (true);
152 name_button.set_name ("monitor section button");
153 name_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
154 name_button.signal_size_allocate().connect (sigc::mem_fun (*this, &FoldbackStrip::name_button_resized));
156 _select_button.set_name ("monitor section button");
157 _select_button.set_text (_("Select Foldback Bus"));
160 _comment_button.set_name (X_("foldback strip button"));
161 _comment_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
162 _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor));
163 _comment_button.signal_size_allocate().connect (sigc::mem_fun (*this, &FoldbackStrip::comment_button_resized));
165 global_vpacker.set_border_width (1);
167 global_vpacker.set_spacing (4);
168 global_vpacker.pack_start (_select_button, Gtk::PACK_SHRINK);
169 global_vpacker.pack_start (name_button, Gtk::PACK_SHRINK);
170 global_vpacker.pack_start (_invert_button_box, Gtk::PACK_SHRINK);
171 global_vpacker.pack_start (show_sends_box, Gtk::PACK_SHRINK);
174 //add a spacer underneath the master bus;
175 //this fills the area that is taken up by the scrollbar on the tracks;
176 //and therefore keeps the faders "even" across the bottom
177 int scrollbar_height = 0;
179 Gtk::Window window (WINDOW_TOPLEVEL);
180 HScrollbar scrollbar;
181 window.add (scrollbar);
182 scrollbar.set_name ("MixerWindow");
183 scrollbar.ensure_style();
184 Gtk::Requisition requisition(scrollbar.size_request ());
185 scrollbar_height = requisition.height;
187 spacer.set_size_request (-1, scrollbar_height);
188 global_vpacker.pack_end (spacer, false, false);
190 global_vpacker.pack_end (_comment_button, Gtk::PACK_SHRINK);
191 global_vpacker.pack_end (output_button, Gtk::PACK_SHRINK);
192 global_vpacker.pack_end (mute_solo_table, Gtk::PACK_SHRINK);
193 global_vpacker.pack_end (panners, Gtk::PACK_SHRINK);
194 global_vpacker.pack_end (bottom_button_table, Gtk::PACK_SHRINK);
196 global_frame.add (global_vpacker);
197 global_frame.set_shadow_type (Gtk::SHADOW_IN);
198 global_frame.set_name ("BaseFrame");
202 /* force setting of visible selected status */
205 set_selected (false);
210 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::engine_stopped, this), gui_context());
211 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::engine_running, this), gui_context());
213 output_button.set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
215 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::output_press), false);
216 output_button.signal_button_release_event().connect (sigc::mem_fun(*this, &FoldbackStrip::output_release), false);
217 output_button.signal_size_allocate().connect (sigc::mem_fun (*this, &FoldbackStrip::output_button_resized));
220 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &FoldbackStrip::name_button_button_press), false);
221 _select_button.signal_button_press_event().connect (sigc::mem_fun (*this, &FoldbackStrip::select_button_button_press), false);
226 /* start off as a passthru strip. we'll correct this, if necessary,
227 in update_diskstream_display().
232 add_events (Gdk::BUTTON_RELEASE_MASK|
233 Gdk::ENTER_NOTIFY_MASK|
234 Gdk::LEAVE_NOTIFY_MASK|
236 Gdk::KEY_RELEASE_MASK);
238 set_flags (get_flags() | Gtk::CAN_FOCUS);
240 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
241 *this, invalidator (*this), boost::bind (&FoldbackStrip::port_connected_or_disconnected, this, _1, _3), gui_context ()
245 //watch for mouse enter/exit so we can do some stuff
246 signal_enter_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_enter_event ));
247 signal_leave_notify_event().connect (sigc::mem_fun(*this, &FoldbackStrip::mixer_strip_leave_event ));
251 FoldbackStrip::~FoldbackStrip ()
253 CatchDeletion (this);
254 delete fb_level_control;
255 fb_level_control = 0;
257 if (this ==_entered_foldback_strip)
258 _entered_foldback_strip = NULL;
262 FoldbackStrip::mixer_strip_enter_event (GdkEventCrossing* /*ev*/)
264 _entered_foldback_strip = this;
266 //although we are triggering on the "enter", to the user it will appear that it is happenin on the "leave"
267 //because the FoldbackStrip control is a parent that encompasses the strip
268 //deselect_all_processors();
274 FoldbackStrip::mixer_strip_leave_event (GdkEventCrossing *ev)
276 //if we have moved outside our strip, but not into a child view, then deselect ourselves
277 if ( !(ev->detail == GDK_NOTIFY_INFERIOR) ) {
278 _entered_foldback_strip= 0;
286 FoldbackStrip::name() const
289 return _route->name();
295 FoldbackStrip::update_fb_level_control ()
297 fb_level_control->show ();
298 fb_level_control->set_controllable (_route->gain_control());
302 FoldbackStrip::set_route (boost::shared_ptr<Route> rt)
306 RouteUI::self_delete ();
307 /* _route.reset (); // drop reference to route, so that it can be cleaned up
308 route_connections.drop_connections ();
314 delete comment_window;
315 delete input_selector;
316 delete output_selector;
317 delete monitor_input_button;
318 delete monitor_disk_button;
321 send_blink_connection.disconnect ();
322 rec_blink_connection.disconnect ();*/
325 //the rec/monitor stuff only shows up for tracks.
326 //the show_sends only shows up for buses.
327 //remove them all here, and we may add them back later
328 if (show_sends_button->get_parent()) {
329 show_sends_box.remove (*show_sends_button);
332 RouteUI::set_route (rt);
334 revert_to_default_display ();
336 if (solo_button->get_parent()) {
337 mute_solo_table.remove (*solo_button);
340 if (mute_button->get_parent()) {
341 mute_solo_table.remove (*mute_button);
344 mute_solo_table.attach (*mute_button, 0, 1, 0, 1);
345 mute_solo_table.attach (*solo_button, 1, 2, 0, 1);
346 mute_button->show ();
347 solo_button->show ();
348 show_sends_box.show ();
352 update_fb_level_control();
354 show_sends_box.pack_start (*show_sends_button, true, true);
355 show_sends_button->show();
358 delete route_ops_menu;
361 delete route_select_menu;
362 route_select_menu = 0;
364 _route->output()->changed.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::update_output_display, this), gui_context());
366 _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::io_changed_proxy, this), gui_context ());
368 if (_route->panner_shell()) {
369 update_panner_choices();
370 _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::connect_to_pan, this), gui_context());
373 _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::setup_comment_button, this), gui_context());
375 set_stuff_from_route ();
377 /* now force an update of all the various elements */
379 update_mute_display ();
380 update_solo_display ();
385 panners.setup_pan ();
388 update_output_display ();
390 add_events (Gdk::BUTTON_RELEASE_MASK);
392 Route::FedBy fed_by = _route->fed_by();
393 for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) {
395 boost::shared_ptr<Route> s_rt (i->r.lock());
396 boost::shared_ptr<Send> snd = s_rt->internal_send_for (_route);
397 //s_rt->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&FoldbackStrip::fill_sendbox, this), this);
398 boost::shared_ptr<Processor> processor (snd);
399 //boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
400 // Ok we have the info... now we need widgets to put it in... I suspect I need a class or three
401 // this doesn't work... and I need to clear it out and rebuild each time.
402 ArdourWidgets::ArdourButton _button;
403 _button.set_distinct_led_click (true);
404 _button.set_fallthrough_to_parent(true);
405 _button.set_led_left (true);
406 // _button.signal_led_clicked.connect (sigc::mem_fun (*this, &FoldbackStrip::led_clicked));
407 _button.set_text (s_rt->name ());
409 //Gtk::VBox snd_entry = NULL;
411 snd_entry.set_border_width (1);
412 snd_entry.set_spacing (4);
413 snd_entry.pack_start (_button, true, true);
414 send_display.pack_start (snd_entry, true, true);
425 global_vpacker.show();
426 mute_solo_table.show();
427 bottom_button_table.show();
428 show_sends_box.show_all();
429 //send_scroller.show ();
430 send_display.show ();
431 output_button.show();
433 _select_button.show();
434 _comment_button.show();
442 FoldbackStrip::set_stuff_from_route ()
444 /* if width is not set, it will be set by the MixerUI or editor */
447 if (get_gui_property ("strip-width", width)) {
452 FoldbackStrip::set_packed (bool yn)
455 set_gui_property ("visible", _packed);
459 struct RouteCompareByName {
460 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
461 return a->name().compare (b->name()) < 0;
466 FoldbackStrip::output_release (GdkEventButton *ev)
468 switch (ev->button) {
470 edit_output_configuration ();
478 FoldbackStrip::output_press (GdkEventButton *ev)
480 using namespace Menu_Helpers;
481 if (!_session->engine().connected()) {
482 MessageDialog msg (_("Not connected to audio engine - no I/O changes are possible"));
487 MenuList& citems = output_menu.items();
488 switch (ev->button) {
491 return false; //wait for the mouse-up to pop the dialog
495 output_menu.set_name ("ArdourContextMenu");
497 output_menu_bundles.clear ();
499 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
501 citems.push_back (SeparatorElem());
502 uint32_t const n_with_separator = citems.size ();
504 ARDOUR::BundleList current = _route->output()->bundles_connected ();
506 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
508 /* guess the user-intended main type of the route output */
509 DataType intended_type = guess_main_type(false);
511 /* try adding the master bus first */
512 boost::shared_ptr<Route> master = _session->master_out();
514 maybe_add_bundle_to_output_menu (master->input()->bundle(), current, intended_type);
517 /* then other routes inputs */
518 RouteList copy = _session->get_routelist ();
519 copy.sort (RouteCompareByName ());
520 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
521 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current, intended_type);
524 /* then try adding user bundles, often labeled/grouped physical inputs */
525 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
526 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
527 maybe_add_bundle_to_output_menu (*i, current, intended_type);
531 /* then all other bundles, including physical outs or other sofware */
532 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
533 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
534 maybe_add_bundle_to_output_menu (*i, current, intended_type);
538 if (citems.size() == n_with_separator) {
539 /* no routes added; remove the separator */
543 if (!ARDOUR::Profile->get_mixbus()) {
544 citems.push_back (SeparatorElem());
546 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
549 string_compose (_("Add %1 port"), (*i).to_i18n_string()),
550 sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::add_output_port), *i)
556 citems.push_back (SeparatorElem());
557 citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));
559 Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "",
572 FoldbackStrip::bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle> c)
578 _route->output()->connect_ports_to_bundle (c, true, true, this);
582 FoldbackStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const& /*current*/,
585 using namespace Menu_Helpers;
587 /* The bundle should be an input one, but not ours */
588 if (b->ports_are_inputs() == false || *b == *_route->input()->bundle()) {
592 /* Don't add the monitor input unless we are Master */
593 boost::shared_ptr<Route> monitor = _session->monitor_out();
594 if ((!_route->is_master()) && monitor && b->has_same_ports (monitor->input()->bundle()))
597 /* It should either match exactly our outputs (if |type| is DataType::NIL)
598 * or have the same number of |type| channels than our outputs. */
599 if (type == DataType::NIL) {
600 if(b->nchannels() != _route->n_outputs())
603 if (b->nchannels().n(type) != _route->n_outputs().n(type))
607 /* Avoid adding duplicates */
608 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
609 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
612 if (i != output_menu_bundles.end()) {
616 /* Now add the bundle to the menu */
617 output_menu_bundles.push_back (b);
619 MenuList& citems = output_menu.items();
620 citems.push_back (MenuElemNoMnemonic (b->name (), sigc::bind (sigc::mem_fun(*this, &FoldbackStrip::bundle_output_chosen), b)));
624 FoldbackStrip::connect_to_pan ()
626 ENSURE_GUI_THREAD (*this, &FoldbackStrip::connect_to_pan)
628 panstate_connection.disconnect ();
629 panstyle_connection.disconnect ();
631 if (!_route->panner()) {
635 boost::shared_ptr<Pannable> p = _route->pannable ();
637 //p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
639 /* This call reduncant, PannerUI::set_panner() connects to _panshell->Changed itself
640 * However, that only works a panner was previously set.
642 * PannerUI must remain subscribed to _panshell->Changed() in case
643 * we switch the panner eg. AUX-Send and back
644 * _route->panner_shell()->Changed() vs _panshell->Changed
646 /* if (panners._panner == 0) {
647 panners.panshell_changed ();
649 */ update_panner_choices();
653 FoldbackStrip::update_panner_choices ()
655 ENSURE_GUI_THREAD (*this, &FoldbackStrip::update_panner_choices)
656 if (!_route->panner_shell()) { return; }
658 uint32_t in = _route->output()->n_ports().n_audio();
660 if (_route->panner()) {
661 in = _route->panner()->in().n_audio();
664 panners.set_available_panners(PannerManager::instance().PannerManager::get_available_panners(in, out));
668 FoldbackStrip::guess_main_type(bool for_input, bool favor_connected) const
670 /* The heuristic follows these principles:
671 * A) If all ports that the user connected are of the same type, then he
672 * very probably intends to use the IO with that type. A common subcase
673 * is when the IO has only ports of the same type (connected or not).
674 * B) If several types of ports are connected, then we should guess based
675 * on the likeliness of the user wanting to use a given type.
676 * We assume that the DataTypes are ordered from the most likely to the
677 * least likely when iterating or comparing them with "<".
678 * C) If no port is connected, the same logic can be applied with all ports
679 * instead of connected ones. TODO: Try other ideas, for instance look at
680 * the last plugin output when |for_input| is false (note: when StrictIO
681 * the outs of the last plugin should be the same as the outs of the route
682 * modulo the panner which forwards non-audio anyway).
683 * All of these constraints are respected by the following algorithm that
684 * just returns the most likely datatype found in connected ports if any, or
685 * available ports if any (since if all ports are of the same type, the most
686 * likely found will be that one obviously). */
688 boost::shared_ptr<IO> io = for_input ? _route->input() : _route->output();
690 /* Find most likely type among connected ports */
691 if (favor_connected) {
692 DataType type = DataType::NIL; /* NIL is always last so least likely */
693 for (PortSet::iterator p = io->ports().begin(); p != io->ports().end(); ++p) {
694 if (p->connected() && p->type() < type)
697 if (type != DataType::NIL) {
698 /* There has been a connected port (necessarily non-NIL) */
703 /* Find most likely type among available ports.
704 * The iterator stops before NIL. */
705 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
706 if (io->n_ports().n(*t) > 0)
710 /* No port at all, return the most likely datatype by default */
711 return DataType::front();
715 * Output port labelling
717 * Case 1: Each output has one connection, all connections are to system:playback_%i
718 * out 1 -> system:playback_1
719 * out 2 -> system:playback_2
720 * out 3 -> system:playback_3
723 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
724 * out 1 -> ardour:track_x/in 1
725 * out 2 -> ardour:track_x/in 2
726 * Display as: track_x
728 * Case 3: Each output has one connection, all connections are to Jack client "program x"
729 * out 1 -> program x:foo
730 * out 2 -> program x:foo
731 * Display as: program x
733 * Case 4: No connections (Disconnected)
736 * Default case (unusual routing):
737 * Display as: *number of connections*
742 * .-----------------------------------------------.
744 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
745 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
746 * '-----------------------------------------------'
747 * .-----------------------------------------------.
750 * '-----------------------------------------------'
754 FoldbackStrip::update_io_button ()
756 ostringstream tooltip;
758 bool have_label = false;
760 uint32_t total_connection_count = 0;
761 uint32_t typed_connection_count = 0;
762 bool each_typed_port_has_one_connection = true;
764 DataType dt = guess_main_type(false);
765 boost::shared_ptr<IO> io = _route->output();
767 /* Fill in the tooltip. Also count:
768 * - The total number of connections.
769 * - The number of main-typed connections.
770 * - Whether each main-typed port has exactly one connection. */
772 tooltip << string_compose (_("<b>OUTPUT</b> from %1"),
773 Gtkmm2ext::markup_escape_text (_route->name()));
775 string arrow = Gtkmm2ext::markup_escape_text(" -> ");
776 vector<string> port_connections;
777 for (PortSet::iterator port = io->ports().begin();
778 port != io->ports().end();
780 port_connections.clear();
781 port->get_connections(port_connections);
783 uint32_t port_connection_count = 0;
785 for (vector<string>::iterator i = port_connections.begin();
786 i != port_connections.end();
788 ++port_connection_count;
790 if (port_connection_count == 1) {
791 tooltip << endl << Gtkmm2ext::markup_escape_text (
792 port->name().substr(port->name().find("/") + 1));
798 tooltip << Gtkmm2ext::markup_escape_text(*i);
801 total_connection_count += port_connection_count;
802 if (port->type() == dt) {
803 typed_connection_count += port_connection_count;
804 each_typed_port_has_one_connection &= (port_connection_count == 1);
809 if (total_connection_count == 0) {
810 tooltip << endl << _("Disconnected");
813 if (typed_connection_count == 0) {
818 /* Are all main-typed channels connected to the same route ? */
820 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
821 for (ARDOUR::RouteList::const_iterator route = routes->begin();
822 route != routes->end();
824 boost::shared_ptr<IO> dest_io = (*route)->output();
825 if (io->bundle()->connected_to(dest_io->bundle(),
828 label << Gtkmm2ext::markup_escape_text ((*route)->name());
835 /* Are all main-typed channels connected to the same (user) bundle ? */
837 boost::shared_ptr<ARDOUR::BundleList> bundles = _session->bundles ();
838 for (ARDOUR::BundleList::iterator bundle = bundles->begin();
839 bundle != bundles->end();
841 if (boost::dynamic_pointer_cast<UserBundle> (*bundle) == 0)
843 if (io->bundle()->connected_to(*bundle, _session->engine(),
845 label << Gtkmm2ext::markup_escape_text ((*bundle)->name());
852 /* Is each main-typed channel only connected to a physical output ? */
853 if (!have_label && each_typed_port_has_one_connection) {
854 ostringstream temp_label;
856 string playorcapture;
858 _session->engine().get_physical_outputs(dt, phys);
859 playorcapture = "playback_";
860 for (PortSet::iterator port = io->ports().begin(dt);
861 port != io->ports().end(dt);
864 for (vector<string>::iterator s = phys.begin();
867 if (!port->connected_to(*s))
869 pn = AudioEngine::instance()->get_pretty_name_by_name(*s);
871 string::size_type start = (*s).find(playorcapture);
872 if (start != string::npos) {
873 pn = (*s).substr(start + playorcapture.size());
879 temp_label.str(""); /* erase the failed attempt */
882 if (port != io->ports().begin(dt))
887 if (!temp_label.str().empty()) {
888 label << temp_label.str();
893 /* Is each main-typed channel connected to a single and different port with
894 * the same client name (e.g. another JACK client) ? */
895 if (!have_label && each_typed_port_has_one_connection) {
896 string maybe_client = "";
897 vector<string> connections;
898 for (PortSet::iterator port = io->ports().begin(dt);
899 port != io->ports().end(dt);
901 port_connections.clear();
902 port->get_connections(port_connections);
903 string connection = port_connections.front();
905 vector<string>::iterator i = connections.begin();
906 while (i != connections.end() && *i != connection) {
909 if (i != connections.end())
910 break; /* duplicate connection */
911 connections.push_back(connection);
913 connection = connection.substr(0, connection.find(":"));
914 if (maybe_client.empty())
915 maybe_client = connection;
916 if (maybe_client != connection)
919 if (connections.size() == io->n_ports().n(dt)) {
920 label << maybe_client;
925 /* Odd configuration */
927 label << "*" << total_connection_count << "*";
930 if (total_connection_count > typed_connection_count) {
931 label << "\u2295"; /* circled plus */
934 /* Actually set the properties of the button */
935 char * cstr = new char[tooltip.str().size() + 1];
936 strcpy(cstr, tooltip.str().c_str());
939 output_button.set_text (label.str());
940 set_tooltip (&output_button, cstr);
946 FoldbackStrip::update_output_display ()
949 panners.setup_pan ();
951 if (has_audio_outputs ()) {
959 FoldbackStrip::io_changed_proxy ()
961 Glib::signal_idle().connect_once (sigc::mem_fun (*this, &FoldbackStrip::update_panner_choices));
965 FoldbackStrip::port_connected_or_disconnected (boost::weak_ptr<Port> wa, boost::weak_ptr<Port> wb)
967 boost::shared_ptr<Port> a = wa.lock ();
968 boost::shared_ptr<Port> b = wb.lock ();
970 if ((a && _route->output()->has_port (a)) || (b && _route->output()->has_port (b))) {
971 update_output_display ();
976 FoldbackStrip::setup_comment_button ()
978 std::string comment = _route->comment();
980 set_tooltip (_comment_button, comment.empty() ? _("Click to add/edit comments") : _route->comment());
982 if (comment.empty ()) {
983 _comment_button.set_name ("generic button");
984 _comment_button.set_text (_("Comments"));
988 _comment_button.set_name ("comment button");
990 string::size_type pos = comment.find_first_of (" \t\n");
991 if (pos != string::npos) {
992 comment = comment.substr (0, pos);
994 if (comment.empty()) {
995 _comment_button.set_text (_("Comments"));
997 _comment_button.set_text (comment);
1002 FoldbackStrip::show_passthru_color ()
1004 //reset_strip_style ();
1008 FoldbackStrip::build_route_ops_menu ()
1010 using namespace Menu_Helpers;
1011 route_ops_menu = new Menu;
1012 route_ops_menu->set_name ("ArdourContextMenu");
1014 MenuList& items = route_ops_menu->items();
1016 items.push_back (MenuElem (_("Comments..."), sigc::mem_fun (*this, &RouteUI::open_comment_editor)));
1018 items.push_back (MenuElem (_("Outputs..."), sigc::mem_fun (*this, &RouteUI::edit_output_configuration)));
1020 items.push_back (SeparatorElem());
1022 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1024 items.push_back (SeparatorElem());
1025 items.push_back (CheckMenuElem (_("Active")));
1026 Gtk::CheckMenuItem* i = dynamic_cast<Gtk::CheckMenuItem *> (&items.back());
1027 i->set_active (_route->active());
1028 i->set_sensitive(! _session->transport_rolling());
1029 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
1031 items.push_back (SeparatorElem());
1032 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1033 denormal_menu_item = dynamic_cast<Gtk::CheckMenuItem *> (&items.back());
1034 denormal_menu_item->set_active (_route->denormal_protection());
1036 items.push_back (SeparatorElem());
1037 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &FoldbackStrip::remove_current_fb)));
1041 FoldbackStrip::build_route_select_menu ()
1043 using namespace Menu_Helpers;
1044 route_select_menu = new Menu;
1045 route_select_menu->set_name ("ArdourContextMenu");
1047 MenuList& items = route_select_menu->items();
1048 StripableList fb_list;
1049 _session->get_stripables (fb_list, PresentationInfo::FoldbackBus);
1050 for (StripableList::iterator s = fb_list.begin(); s != fb_list.end(); ++s) {
1052 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> ((*s));
1053 if (route == _route) {
1056 items.push_back (MenuElem (route->name (), sigc::bind (sigc::mem_fun (*this, &FoldbackStrip::set_route), route)));
1063 FoldbackStrip::name_button_button_press (GdkEventButton* ev)
1065 if (ev->button == 1 || ev->button == 3) {
1066 list_route_operations ();
1068 if (ev->button == 1) {
1069 Gtkmm2ext::anchored_menu_popup(route_ops_menu, &name_button, "",
1072 route_ops_menu->popup (3, ev->time);
1082 FoldbackStrip::select_button_button_press (GdkEventButton* ev)
1084 if (ev->button == 1 || ev->button == 3) {
1087 if (ev->button == 1) {
1088 Gtkmm2ext::anchored_menu_popup(route_select_menu, &_select_button, "",
1091 route_select_menu->popup (3, ev->time);
1101 FoldbackStrip::list_route_operations ()
1103 delete route_ops_menu;
1104 build_route_ops_menu ();
1108 FoldbackStrip::list_fb_routes ()
1110 delete route_select_menu;
1111 build_route_select_menu ();
1115 FoldbackStrip::route_property_changed (const PropertyChange& what_changed)
1117 if (what_changed.contains (ARDOUR::Properties::name)) {
1123 FoldbackStrip::name_changed ()
1126 name_button.set_text_ellipsize (Pango::ELLIPSIZE_END);
1127 name_button.set_text (_route->name());
1129 set_tooltip (name_button, Gtkmm2ext::markup_escape_text(_route->name()));
1134 FoldbackStrip::output_button_resized (Gtk::Allocation& alloc)
1136 output_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE);
1140 FoldbackStrip::name_button_resized (Gtk::Allocation& alloc)
1142 name_button.set_layout_ellipsize_width (20);
1146 FoldbackStrip::comment_button_resized (Gtk::Allocation& alloc)
1148 _comment_button.set_layout_ellipsize_width (alloc.get_width() * PANGO_SCALE);
1152 FoldbackStrip::set_embedded (bool yn)
1158 FoldbackStrip::map_frozen ()
1160 ENSURE_GUI_THREAD (*this, &FoldbackStrip::map_frozen)
1163 RouteUI::map_frozen ();
1167 FoldbackStrip::hide_redirect_editors ()
1172 FoldbackStrip::reset_strip_style ()
1174 set_name ("AudioBusStripBase");
1178 FoldbackStrip::engine_stopped ()
1183 FoldbackStrip::engine_running ()
1188 FoldbackStrip::drop_send ()
1190 boost::shared_ptr<Send> current_send;
1192 if (_current_delivery && ((current_send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0)) {
1193 current_send->set_metering (false);
1196 send_gone_connection.disconnect ();
1197 output_button.set_sensitive (true);
1198 set_invert_sensitive (true);
1199 mute_button->set_sensitive (true);
1200 solo_button->set_sensitive (true);
1201 _comment_button.set_sensitive (true);
1202 fb_level_control->set_sensitive (true);
1203 set_button_names (); // update solo button visual state
1207 FoldbackStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1209 _current_delivery = d;
1210 DeliveryChanged (_current_delivery);
1214 FoldbackStrip::revert_to_default_display ()
1218 set_current_delivery (_route->main_outs ());
1220 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1221 update_panner_choices();
1222 panner_ui().setup_pan ();
1223 panner_ui().set_send_drawing_mode (false);
1225 if (has_audio_outputs ()) {
1226 panners.show_all ();
1228 panners.hide_all ();
1231 reset_strip_style ();
1235 FoldbackStrip::set_button_names ()
1238 mute_button->set_text (_("Mute"));
1241 if (_route && _route->solo_safe_control()->solo_safe()) {
1242 solo_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() | Gtkmm2ext::Insensitive));
1244 solo_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() & ~Gtkmm2ext::Insensitive));
1246 if (!Config->get_solo_control_is_listen_control()) {
1247 solo_button->set_text (_("Solo"));
1249 switch (Config->get_listen_position()) {
1250 case AfterFaderListen:
1251 solo_button->set_text (_("AFL"));
1253 case PreFaderListen:
1254 solo_button->set_text (_("PFL"));
1263 FoldbackStrip::state_id () const
1265 return string_compose ("strip %1", _route->id().to_s());
1269 FoldbackStrip::add_output_port (DataType t)
1271 _route->output()->add_port ("", this, t);
1275 FoldbackStrip::route_active_changed ()
1277 reset_strip_style ();
1281 FoldbackStrip::build_sends_menu ()
1283 using namespace Menu_Helpers;
1285 sends_menu = new Menu;
1286 sends_menu->set_name ("ArdourContextMenu");
1287 MenuList& items = sends_menu->items();
1290 MenuElem(_("Assign all tracks"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, false))
1294 MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true))
1298 MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, false))
1302 MenuElem(_("Assign selected tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true)));
1304 items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track)));
1305 items.push_back (MenuElem(_("Set sends gain to -inf"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_zero)));
1306 items.push_back (MenuElem(_("Set sends gain to 0dB"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_unity)));
1311 FoldbackStrip::color () const
1313 return route_color ();
1317 FoldbackStrip::marked_for_display () const
1319 return !_route->presentation_info().hidden();
1323 FoldbackStrip::remove_current_fb ()
1325 StripableList slist;
1326 boost::shared_ptr<Route> next = boost::shared_ptr<Route> ();
1327 boost::shared_ptr<Route> old_route = _route;
1328 _session->get_stripables (slist, PresentationInfo::FoldbackBus);
1329 if (slist.size ()) {
1330 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
1331 if ((*s) != _route) {
1332 next = boost::dynamic_pointer_cast<Route> (*s);
1340 _session->remove_route (old_route);