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.
22 #include <sigc++/bind.h>
24 #include "pbd/convert.h"
25 #include "pbd/enumwriter.h"
26 #include "pbd/replace_all.h"
28 #include <gtkmm2ext/gtk_ui.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/choice.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/doi.h>
33 #include <gtkmm2ext/slider_controller.h>
34 #include <gtkmm2ext/bindable_button.h>
36 #include "ardour/ardour.h"
37 #include "ardour/session.h"
38 #include "ardour/audioengine.h"
39 #include "ardour/route.h"
40 #include "ardour/route_group.h"
41 #include "ardour/audio_track.h"
42 #include "ardour/audio_diskstream.h"
43 #include "ardour/panner.h"
44 #include "ardour/send.h"
45 #include "ardour/processor.h"
46 #include "ardour/profile.h"
47 #include "ardour/ladspa_plugin.h"
48 #include "ardour/user_bundle.h"
50 #include "ardour_ui.h"
51 #include "ardour_dialog.h"
52 #include "mixer_strip.h"
55 #include "public_editor.h"
57 #include "io_selector.h"
59 #include "gui_thread.h"
64 using namespace ARDOUR;
67 using namespace Gtkmm2ext;
70 int MixerStrip::scrollbar_height = 0;
72 #ifdef VARISPEED_IN_MIXER_STRIP
74 speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg)
76 float val = adj.get_value ();
81 snprintf (buf, 32, "%.3f", val);
86 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
88 , RouteUI (sess, _("Mute"), _("Solo"), _("Record"))
90 , _mixer_owned (in_mixer)
91 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), in_mixer)
92 , post_processor_box (PostFader, sess, mx.plugin_selector(), mx.selection(), in_mixer)
96 , middle_button_table (1, 2)
97 , bottom_button_table (1, 2)
98 , meter_point_label (_("pre"))
99 , comment_button (_("Comments"))
100 , speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1)
101 , speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
107 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer)
109 , RouteUI (sess, _("Mute"), _("Solo"), _("Record"))
111 , _mixer_owned (in_mixer)
112 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), in_mixer)
113 , post_processor_box (PostFader, sess, mx.plugin_selector(), mx.selection(), in_mixer)
116 , button_table (3, 2)
117 , middle_button_table (1, 2)
118 , bottom_button_table (1, 2)
119 , meter_point_label (_("pre"))
120 , comment_button (_("Comments"))
121 , speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1)
122 , speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
135 _marked_for_display = false;
137 ignore_comment_edit = false;
138 ignore_toggle = false;
139 ignore_speed_adjustment = false;
147 img = manage (new Gtk::Image (::get_icon("strip_width")));
150 width_button.add (*img);
152 img = manage (new Gtk::Image (::get_icon("hide")));
155 hide_button.add (*img);
157 input_label.set_text (_("Input"));
158 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
159 input_button.add (input_label);
160 input_button.set_name ("MixerIOButton");
161 input_label.set_name ("MixerIOButtonLabel");
162 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
164 output_label.set_text (_("Output"));
165 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
166 output_button.add (output_label);
167 output_button.set_name ("MixerIOButton");
168 output_label.set_name ("MixerIOButtonLabel");
169 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
171 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
172 meter_point_button.add (meter_point_label);
173 meter_point_button.set_name ("MixerStripMeterPreButton");
174 meter_point_label.set_name ("MixerStripMeterPreButton");
176 /* TRANSLATORS: this string should be longest of the strings
177 used to describe meter points. In english, it's "input".
179 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
181 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
183 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
184 /* XXX what is this meant to do? */
185 //meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
187 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
189 mute_button->set_name ("MixerMuteButton");
190 solo_button->set_name ("MixerSoloButton");
192 button_table.set_homogeneous (true);
193 button_table.set_spacings (0);
195 button_table.attach (name_button, 0, 2, 0, 1);
196 button_table.attach (input_button, 0, 2, 1, 2);
198 middle_button_table.set_homogeneous (true);
199 middle_button_table.set_spacings (0);
200 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
201 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
203 bottom_button_table.set_col_spacings (0);
204 bottom_button_table.set_homogeneous (true);
205 bottom_button_table.attach (group_button, 0, 1, 0, 1);
207 name_button.add (name_label);
208 name_button.set_name ("MixerNameButton");
209 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
211 name_label.set_name ("MixerNameButtonLabel");
212 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
213 group_button.add (group_label);
214 group_button.set_name ("MixerGroupButton");
215 group_label.set_name ("MixerGroupButtonLabel");
217 comment_button.set_name ("MixerCommentButton");
219 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
221 global_vpacker.set_border_width (0);
222 global_vpacker.set_spacing (0);
224 width_button.set_name ("MixerWidthButton");
225 hide_button.set_name ("MixerHideButton");
226 top_event_box.set_name ("MixerTopEventBox");
228 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
229 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
231 width_hide_box.pack_start (width_button, false, true);
232 width_hide_box.pack_start (top_event_box, true, true);
233 width_hide_box.pack_end (hide_button, false, true);
234 gain_meter_alignment.set_padding(0, 4, 0, 0);
235 gain_meter_alignment.add(gpm);
237 whvbox.pack_start (width_hide_box, true, true);
239 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
241 global_vpacker.pack_start (pre_processor_box, true, true);
242 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
243 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
244 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
245 global_vpacker.pack_start (post_processor_box, true, true);
246 if (!is_midi_track()) {
247 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
249 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
250 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
252 global_frame.add (global_vpacker);
253 global_frame.set_shadow_type (Gtk::SHADOW_IN);
254 global_frame.set_name ("BaseFrame");
258 /* force setting of visible selected status */
261 set_selected (false);
266 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
267 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
269 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
270 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
272 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
273 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
274 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
275 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
277 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
281 rec_enable_button->set_name ("MixerRecordEnableButton");
282 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
283 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
285 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
286 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
290 /* start off as a passthru strip. we'll correct this, if necessary,
291 in update_diskstream_display().
294 /* start off as a passthru strip. we'll correct this, if necessary,
295 in update_diskstream_display().
299 set_name ("MidiTrackStripBase");
301 set_name ("AudioTrackStripBase");
303 add_events (Gdk::BUTTON_RELEASE_MASK);
306 MixerStrip::~MixerStrip ()
308 GoingAway(); /* EMIT_SIGNAL */
310 delete input_selector;
311 delete output_selector;
315 MixerStrip::set_route (boost::shared_ptr<Route> rt)
317 if (rec_enable_button->get_parent()) {
318 button_table.remove (*rec_enable_button);
321 #ifdef VARISPEED_IN_MIXER_STRIP
322 if (speed_frame->get_parent()) {
323 button_table.remove (*speed_frame);
327 RouteUI::set_route (rt);
329 delete input_selector;
332 delete output_selector;
337 pre_processor_box.set_route (rt);
338 post_processor_box.set_route (rt);
340 if (set_color_from_route()) {
341 set_color (unique_random_color());
344 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
346 if (scrollbar_height == 0) {
347 HScrollbar scrollbar;
348 Gtk::Requisition requisition(scrollbar.size_request ());
349 scrollbar_height = requisition.height;
352 spacer = manage (new EventBox);
353 spacer->set_size_request (-1, scrollbar_height);
354 global_vpacker.pack_start (*spacer, false, false);
357 if (is_audio_track()) {
359 boost::shared_ptr<AudioTrack> at = audio_track();
361 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
363 #ifdef VARISPEED_IN_MIXER_STRIP
364 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
366 speed_frame.set_name ("BaseFrame");
367 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
368 speed_frame.add (speed_spinner);
370 speed_spinner.set_print_func (speed_printer, 0);
372 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("Varispeed"));
374 button_table.attach (speed_frame, 0, 2, 5, 6);
375 #endif /* VARISPEED_IN_MIXER_STRIP */
377 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
378 rec_enable_button->show();
381 if (_route->phase_invert()) {
382 name_label.set_text (X_("Ø ") + name_label.get_text());
384 name_label.set_text (_route->name());
387 switch (_route->meter_point()) {
389 meter_point_label.set_text (_("input"));
393 meter_point_label.set_text (_("pre"));
397 meter_point_label.set_text (_("post"));
401 delete route_ops_menu;
404 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
405 _("Click to Add/Edit Comments"):
408 connections.push_back (_route->meter_change.connect (mem_fun(*this, &MixerStrip::meter_changed)));
409 connections.push_back (_route->input_changed.connect (mem_fun(*this, &MixerStrip::input_changed)));
410 connections.push_back (_route->output_changed.connect (mem_fun(*this, &MixerStrip::output_changed)));
411 connections.push_back (_route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)));
412 connections.push_back (_route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)));
413 connections.push_back (_route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)));
414 connections.push_back (_route->mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed)));
415 connections.push_back (_route->panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan)));
417 if (is_audio_track()) {
418 connections.push_back (audio_track()->DiskstreamChanged.connect (mem_fun(*this, &MixerStrip::diskstream_changed)));
419 connections.push_back (get_diskstream()->SpeedChanged.connect (mem_fun(*this, &MixerStrip::speed_changed)));
422 connections.push_back (_route->NameChanged.connect (mem_fun(*this, &RouteUI::name_changed)));
423 connections.push_back (_route->comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed)));
424 connections.push_back (_route->gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed)));
426 set_stuff_from_route ();
428 /* now force an update of all the various elements */
430 pre_processor_box.update();
431 post_processor_box.update();
436 mix_group_changed (0);
440 panners.setup_pan ();
442 if (is_audio_track()) {
446 update_diskstream_display ();
447 update_input_display ();
448 update_output_display ();
450 add_events (Gdk::BUTTON_RELEASE_MASK);
452 pre_processor_box.show();
454 if (!route()->is_master() && !route()->is_control()) {
455 /* we don't allow master or control routes to be hidden */
460 width_hide_box.show();
463 global_vpacker.show();
465 middle_button_table.show();
466 bottom_button_table.show();
467 pre_processor_box.show_all ();
470 gain_meter_alignment.show ();
471 post_processor_box.show_all ();
472 gain_unit_button.show();
473 gain_unit_label.show();
474 meter_point_button.show();
475 meter_point_label.show();
476 diskstream_button.show();
477 diskstream_label.show();
480 output_button.show();
484 comment_button.show();
487 speed_spinner.show();
495 MixerStrip::set_stuff_from_route ()
501 /* if width is not set, it will be set by the MixerUI or editor */
503 if ((prop = xml_node->property ("strip-width")) != 0) {
504 set_width (Width (string_2_enum (prop->value(), _width)), this);
507 if ((prop = xml_node->property ("shown-mixer")) != 0) {
508 if (prop->value() == "no") {
509 _marked_for_display = false;
511 _marked_for_display = true;
514 /* backwards compatibility */
515 _marked_for_display = true;
520 MixerStrip::set_width (Width w, void* owner)
522 /* always set the gpm width again, things may be hidden */
525 panners.set_width (w);
526 pre_processor_box.set_width (w);
527 post_processor_box.set_width (w);
529 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
531 _width_owner = owner;
537 if (_width_owner == this) {
538 xml_node->add_property ("strip-width", enum_2_string (_width));
544 if (rec_enable_button) {
545 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Record"));
547 ((Gtk::Label*)mute_button->get_child())->set_text (_("Mute"));
548 ((Gtk::Label*)solo_button->get_child())->set_text (_("Solo"));
550 if (_route->comment() == "") {
551 comment_button.unset_bg (STATE_NORMAL);
552 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
554 comment_button.modify_bg (STATE_NORMAL, color());
555 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
558 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.astyle_string(gain_automation->automation_style()));
559 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.astate_string(gain_automation->automation_state()));
560 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.astyle_string(_route->panner().automation_style()));
561 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.astate_string(_route->panner().automation_state()));
562 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
563 set_size_request (-1, -1);
567 if (rec_enable_button) {
568 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec"));
570 ((Gtk::Label*)mute_button->get_child())->set_text (_("M"));
571 ((Gtk::Label*)solo_button->get_child())->set_text (_("S"));
573 if (_route->comment() == "") {
574 comment_button.unset_bg (STATE_NORMAL);
575 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
577 comment_button.modify_bg (STATE_NORMAL, color());
578 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
581 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.short_astyle_string(gain_automation->automation_style()));
582 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.short_astate_string(gain_automation->automation_state()));
583 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.short_astyle_string(_route->panner().automation_style()));
584 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.short_astate_string(_route->panner().automation_state()));
585 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
586 set_size_request (max (50, gpm.get_gm_width()), -1);
589 update_input_display ();
590 update_output_display ();
591 mix_group_changed (0);
599 MixerStrip::set_packed (bool yn)
606 xml_node->add_property ("shown-mixer", "yes");
608 xml_node->add_property ("shown-mixer", "no");
614 MixerStrip::output_press (GdkEventButton *ev)
616 using namespace Menu_Helpers;
617 if (!_session.engine().connected()) {
618 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
623 MenuList& citems = output_menu.items();
624 switch (ev->button) {
627 edit_output_configuration ();
632 output_menu.set_name ("ArdourContextMenu");
635 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
636 citems.push_back (SeparatorElem());
638 ARDOUR::BundleList current = _route->bundles_connected_to_outputs ();
640 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
641 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
642 maybe_add_bundle_to_output_menu (*i, current);
645 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
646 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
647 maybe_add_bundle_to_output_menu ((*i)->bundle_for_inputs(), current);
650 if (citems.size() == 2) {
651 /* no routes added; remove the separator */
655 output_menu.popup (1, ev->time);
666 MixerStrip::edit_output_configuration ()
668 if (output_selector == 0) {
669 output_selector = new IOSelectorWindow (_session, _route, false);
672 if (output_selector->is_visible()) {
673 output_selector->get_toplevel()->get_window()->raise();
675 output_selector->present ();
680 MixerStrip::edit_input_configuration ()
682 if (input_selector == 0) {
683 input_selector = new IOSelectorWindow (_session, _route, true);
686 if (input_selector->is_visible()) {
687 input_selector->get_toplevel()->get_window()->raise();
689 input_selector->present ();
694 MixerStrip::input_press (GdkEventButton *ev)
696 using namespace Menu_Helpers;
698 MenuList& citems = input_menu.items();
699 input_menu.set_name ("ArdourContextMenu");
702 if (!_session.engine().connected()) {
703 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
708 switch (ev->button) {
711 edit_input_configuration ();
716 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
717 citems.push_back (SeparatorElem());
719 ARDOUR::BundleList current = _route->bundles_connected_to_inputs ();
721 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
722 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
723 maybe_add_bundle_to_input_menu (*i, current);
726 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
727 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
728 maybe_add_bundle_to_input_menu ((*i)->bundle_for_outputs(), current);
731 if (citems.size() == 2) {
732 /* no routes added; remove the separator */
736 input_menu.popup (1, ev->time);
746 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
752 ARDOUR::BundleList current = _route->bundles_connected_to_inputs ();
754 if (std::find (current.begin(), current.end(), c) == current.end()) {
755 _route->connect_input_ports_to_bundle (c, this);
757 _route->disconnect_input_ports_from_bundle (c, this);
762 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
768 ARDOUR::BundleList current = _route->bundles_connected_to_outputs ();
770 if (std::find (current.begin(), current.end(), c) == current.end()) {
771 _route->connect_output_ports_to_bundle (c, this);
773 _route->disconnect_output_ports_from_bundle (c, this);
778 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
780 using namespace Menu_Helpers;
782 if (b->ports_are_outputs() == false ||
783 route()->default_type() != b->type() ||
784 b->nchannels() != _route->n_inputs().get (b->type ())) {
789 MenuList& citems = input_menu.items();
791 std::string n = b->name ();
792 replace_all (n, "_", " ");
794 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
796 if (std::find (current.begin(), current.end(), b) != current.end()) {
797 ignore_toggle = true;
798 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
799 ignore_toggle = false;
804 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
806 using namespace Menu_Helpers;
808 if (b->ports_are_inputs() == false ||
809 route()->default_type() != b->type() ||
810 b->nchannels() != _route->n_outputs().get (b->type ())) {
815 MenuList& citems = output_menu.items();
817 std::string n = b->name ();
818 replace_all (n, "_", " ");
820 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
822 if (std::find (current.begin(), current.end(), b) != current.end()) {
823 ignore_toggle = true;
824 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
825 ignore_toggle = false;
830 MixerStrip::update_diskstream_display ()
834 if (input_selector) {
835 input_selector->hide_all ();
842 show_passthru_color ();
847 MixerStrip::connect_to_pan ()
849 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
851 panstate_connection.disconnect ();
852 panstyle_connection.disconnect ();
854 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
855 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
856 _route->panner().data().control(Evoral::Parameter( PanAutomation ) ));
859 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
860 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
863 panners.pan_changed (this);
867 MixerStrip::update_input_display ()
869 ARDOUR::BundleList const c = _route->bundles_connected_to_inputs ();
872 input_label.set_text (_("Inputs"));
873 } else if (c.size() == 1) {
874 input_label.set_text (c[0]->name ());
878 input_label.set_text (_(" Input"));
881 input_label.set_text (_("I"));
885 panners.setup_pan ();
889 MixerStrip::update_output_display ()
891 ARDOUR::BundleList const c = _route->bundles_connected_to_outputs ();
893 /* XXX: how do we represent >1 connected bundle? */
895 output_label.set_text (_("Outputs"));
896 } else if (c.size() == 1) {
897 output_label.set_text (c[0]->name());
901 output_label.set_text (_("Output"));
904 output_label.set_text (_("O"));
910 panners.setup_pan ();
914 MixerStrip::fast_update ()
916 gpm.update_meters ();
920 MixerStrip::diskstream_changed ()
922 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
926 MixerStrip::input_changed (IOChange change, void *src)
928 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
929 set_width(_width, this);
933 MixerStrip::output_changed (IOChange change, void *src)
935 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
936 set_width(_width, this);
941 MixerStrip::comment_editor_done_editing()
943 string str = comment_area->get_buffer()->get_text();
944 if (_route->comment() != str) {
945 _route->set_comment (str, this);
951 comment_button.modify_bg (STATE_NORMAL, color());
952 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
954 comment_button.unset_bg (STATE_NORMAL);
955 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
961 comment_button.modify_bg (STATE_NORMAL, color());
962 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
964 comment_button.unset_bg (STATE_NORMAL);
965 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
970 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
971 str.empty() ? _("Click to Add/Edit Comments") : str);
977 MixerStrip::comment_button_clicked ()
979 if (comment_window == 0) {
980 setup_comment_editor ();
983 int x, y, cw_width, cw_height;
985 if (comment_window->is_visible()) {
986 comment_window->hide ();
990 comment_window->get_size (cw_width, cw_height);
991 comment_window->get_position(x, y);
992 comment_window->move(x, y - (cw_height / 2) - 45);
994 half the dialog height minus the comments button height
995 with some window decoration fudge thrown in.
998 comment_window->show();
999 comment_window->present();
1003 MixerStrip::setup_comment_editor ()
1006 title = _route->name();
1007 title += _(": comment editor");
1009 comment_window = new ArdourDialog (title, false);
1010 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1011 comment_window->set_skip_taskbar_hint (true);
1012 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1014 comment_area = manage (new TextView());
1015 comment_area->set_name ("MixerTrackCommentArea");
1016 comment_area->set_size_request (110, 178);
1017 comment_area->set_wrap_mode (WRAP_WORD);
1018 comment_area->set_editable (true);
1019 comment_area->get_buffer()->set_text (_route->comment());
1020 comment_area->show ();
1022 comment_window->get_vbox()->pack_start (*comment_area);
1023 comment_window->get_action_area()->hide();
1027 MixerStrip::comment_changed (void *src)
1029 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1032 ignore_comment_edit = true;
1034 comment_area->get_buffer()->set_text (_route->comment());
1036 ignore_comment_edit = false;
1041 MixerStrip::set_mix_group (RouteGroup *rg)
1043 _route->set_mix_group (rg, this);
1047 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1049 using namespace Menu_Helpers;
1051 MenuList& items = group_menu->items();
1053 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1055 if (_route->mix_group() == rg) {
1056 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1061 MixerStrip::select_mix_group (GdkEventButton *ev)
1063 using namespace Menu_Helpers;
1065 if (group_menu == 0) {
1066 group_menu = new Menu;
1068 group_menu->set_name ("ArdourContextMenu");
1069 MenuList& items = group_menu->items();
1070 RadioMenuItem::Group group;
1072 switch (ev->button) {
1076 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1078 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
1080 group_menu->popup (1, ev->time);
1091 MixerStrip::mix_group_changed (void *ignored)
1093 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1095 RouteGroup *rg = _route->mix_group();
1098 group_label.set_text (rg->name());
1102 group_label.set_text (_("Grp"));
1105 group_label.set_text (_("~G"));
1113 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1115 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1117 if (what_changed == "color") {
1118 if (set_color_from_route () == 0) {
1119 show_route_color ();
1125 MixerStrip::show_route_color ()
1127 name_button.modify_bg (STATE_NORMAL, color());
1128 top_event_box.modify_bg (STATE_NORMAL, color());
1129 route_active_changed ();
1133 MixerStrip::show_passthru_color ()
1135 route_active_changed ();
1139 MixerStrip::build_route_ops_menu ()
1141 using namespace Menu_Helpers;
1142 route_ops_menu = new Menu;
1143 route_ops_menu->set_name ("ArdourContextMenu");
1145 MenuList& items = route_ops_menu->items();
1147 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1148 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1149 items.push_back (SeparatorElem());
1150 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1151 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1152 route_active_menu_item->set_active (_route->active());
1154 items.push_back (SeparatorElem());
1156 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1158 items.push_back (SeparatorElem());
1159 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1160 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1161 polarity_menu_item->set_active (_route->phase_invert());
1162 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1163 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1164 denormal_menu_item->set_active (_route->denormal_protection());
1166 if (!Profile->get_sae()) {
1167 build_remote_control_menu ();
1168 items.push_back (SeparatorElem());
1169 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1172 items.push_back (SeparatorElem());
1173 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1177 MixerStrip::name_button_button_press (GdkEventButton* ev)
1179 if (ev->button == 1 || ev->button == 3) {
1180 list_route_operations ();
1182 Menu_Helpers::MenuList& items = route_ops_menu->items();
1183 /* do not allow rename if the track is record-enabled */
1184 static_cast<MenuItem*> (&items.front())->set_sensitive (!_route->record_enabled());
1186 route_ops_menu->popup (1, ev->time);
1192 MixerStrip::list_route_operations ()
1194 if (route_ops_menu == 0) {
1195 build_route_ops_menu ();
1198 refresh_remote_control_menu();
1203 MixerStrip::speed_adjustment_changed ()
1205 /* since there is a usable speed adjustment, there has to be a diskstream */
1206 if (!ignore_speed_adjustment) {
1207 get_diskstream()->set_speed (speed_adjustment.get_value());
1212 MixerStrip::speed_changed ()
1214 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1218 MixerStrip::update_speed_display ()
1222 val = get_diskstream()->speed();
1225 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1227 speed_spinner.set_name ("MixerStripSpeedBase");
1230 if (speed_adjustment.get_value() != val) {
1231 ignore_speed_adjustment = true;
1232 speed_adjustment.set_value (val);
1233 ignore_speed_adjustment = false;
1239 MixerStrip::set_selected (bool yn)
1241 AxisView::set_selected (yn);
1243 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1244 global_frame.set_name ("MixerStripSelectedFrame");
1246 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1247 global_frame.set_name ("MixerStripFrame");
1249 global_frame.queue_draw ();
1253 MixerStrip::name_changed ()
1257 RouteUI::name_changed ();
1260 name_label.set_text (PBD::short_version (_route->name(), 5));
1263 if (_route->phase_invert()) {
1264 name_label.set_text (X_("Ø ") + name_label.get_text());
1269 MixerStrip::width_clicked ()
1273 set_width (Narrow, this);
1276 set_width (Wide, this);
1282 MixerStrip::hide_clicked ()
1284 // LAME fix to reset the button status for when it is redisplayed (part 1)
1285 hide_button.set_sensitive(false);
1288 Hiding(); /* EMIT_SIGNAL */
1290 _mixer.hide_strip (this);
1294 hide_button.set_sensitive(true);
1298 MixerStrip::set_embedded (bool yn)
1304 MixerStrip::map_frozen ()
1306 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1308 boost::shared_ptr<AudioTrack> at = audio_track();
1311 switch (at->freeze_state()) {
1312 case AudioTrack::Frozen:
1313 pre_processor_box.set_sensitive (false);
1314 post_processor_box.set_sensitive (false);
1315 speed_spinner.set_sensitive (false);
1318 pre_processor_box.set_sensitive (true);
1319 post_processor_box.set_sensitive (true);
1320 speed_spinner.set_sensitive (true);
1321 // XXX need some way, maybe, to retoggle redirect editors
1326 hide_redirect_editors ();
1330 MixerStrip::hide_redirect_editors ()
1332 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1336 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1338 boost::shared_ptr<Processor> processor (p.lock ());
1343 void* gui = processor->get_gui ();
1346 static_cast<Gtk::Widget*>(gui)->hide ();
1351 MixerStrip::route_active_changed ()
1353 RouteUI::route_active_changed ();
1355 if (is_midi_track()) {
1356 if (_route->active()) {
1357 set_name ("MidiTrackStripBase");
1358 gpm.set_meter_strip_name ("MidiTrackStripBase");
1360 set_name ("MidiTrackStripBaseInactive");
1361 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1363 gpm.set_fader_name ("MidiTrackFader");
1364 } else if (is_audio_track()) {
1365 if (_route->active()) {
1366 set_name ("AudioTrackStripBase");
1367 gpm.set_meter_strip_name ("AudioTrackMetrics");
1369 set_name ("AudioTrackStripBaseInactive");
1370 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1372 gpm.set_fader_name ("AudioTrackFader");
1374 if (_route->active()) {
1375 set_name ("AudioBusStripBase");
1376 gpm.set_meter_strip_name ("AudioBusMetrics");
1378 set_name ("AudioBusStripBaseInactive");
1379 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1381 gpm.set_fader_name ("AudioBusFader");
1383 /* (no MIDI busses yet) */
1388 MixerStrip::mix_group() const
1390 return _route->mix_group();
1394 MixerStrip::engine_stopped ()
1399 MixerStrip::engine_running ()
1404 MixerStrip::meter_changed (void *src)
1407 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1409 switch (_route->meter_point()) {
1411 meter_point_label.set_text (_("input"));
1415 meter_point_label.set_text (_("pre"));
1418 case MeterPostFader:
1419 meter_point_label.set_text (_("post"));
1423 gpm.setup_meters ();
1424 // reset peak when meter point changes
1425 gpm.reset_peak_display();
1426 set_width(_width, this);