2 Copyright (C) 2000-2002 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.
24 #include <sigc++/bind.h>
26 #include <gtkmm2ext/gtk_ui.h>
27 #include <gtkmm2ext/utils.h>
28 #include <gtkmm2ext/choice.h>
29 #include <gtkmm2ext/slider_controller.h>
30 #include <gtkmm2ext/stop_signal.h>
31 #include <gtkmm2ext/bindable_button.h>
32 #include <gtkmm2ext/doi.h>
34 #include <ardour/ardour.h>
35 #include <ardour/session.h>
36 #include <ardour/audioengine.h>
37 #include <ardour/route.h>
38 #include <ardour/audio_track.h>
39 #include <ardour/diskstream.h>
40 #include <ardour/panner.h>
41 #include <ardour/send.h>
42 #include <ardour/insert.h>
43 #include <ardour/ladspa_plugin.h>
44 #include <ardour/connection.h>
45 #include <ardour/session_connection.h>
47 #include "ardour_ui.h"
48 #include "ardour_dialog.h"
49 #include "ardour_message.h"
50 #include "mixer_strip.h"
53 #include "plugin_selector.h"
54 #include "public_editor.h"
56 #include "plugin_ui.h"
58 #include "io_selector.h"
60 #include "gui_thread.h"
65 using namespace ARDOUR;
67 using namespace Gtkmm2ext;
70 static const gchar * small_x_xpm[] = {
87 static const gchar * lr_xpm[] = {
104 speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg)
106 float val = adj.get_value ();
111 snprintf (buf, 32, "%.3f", val);
115 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
117 RouteUI (rt, sess, _("mute"), _("solo"), _("RECORD")),
119 pre_redirect_box (PreFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
120 post_redirect_box (PostFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
122 panners (_route, sess),
124 gain_automation_style_button (""),
125 gain_automation_state_button (""),
126 pan_automation_style_button (""),
127 pan_automation_state_button (""),
128 polarity_button (_("polarity")),
129 comment_button (_("comments")),
130 speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
131 speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
134 if (set_color_from_route()) {
135 set_color (unique_random_color());
141 _marked_for_display = false;
143 ignore_comment_edit = false;
144 ignore_toggle = false;
145 ignore_speed_adjustment = false;
149 width_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(lr_xpm)))));
150 hide_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(small_x_xpm)))));
153 input_label.set_text (_("INPUT"));
154 input_button.add (input_label);
155 input_button.set_name ("MixerIOButton");
156 input_label.set_name ("MixerIOButtonLabel");
158 output_label.set_text (_("OUTPUT"));
159 output_button.add (output_label);
160 output_button.set_name ("MixerIOButton");
161 output_label.set_name ("MixerIOButtonLabel");
163 rec_enable_button->set_name ("MixerRecordEnableButton");
164 rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
166 solo_button->set_name ("MixerSoloButton");
167 mute_button->set_name ("MixerMuteButton");
168 gain_automation_style_button.set_name ("MixerAutomationModeButton");
169 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
170 pan_automation_style_button.set_name ("MixerAutomationModeButton");
171 pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
172 polarity_button.set_name ("MixerPhaseInvertButton");
174 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
175 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Gain automation mode"));
177 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
178 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Gain automation type"));
180 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
182 width_button.unset_flags (Gtk::CAN_FOCUS);
183 hide_button.unset_flags (Gtk::CAN_FOCUS);
184 input_button.unset_flags (Gtk::CAN_FOCUS);
185 output_button.unset_flags (Gtk::CAN_FOCUS);
186 solo_button->unset_flags (Gtk::CAN_FOCUS);
187 mute_button->unset_flags (Gtk::CAN_FOCUS);
188 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
189 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
190 pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
191 pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
192 polarity_button.unset_flags (Gtk::CAN_FOCUS);
194 button_table.set_homogeneous (true);
196 button_table.attach (name_button, 0, 2, 0, 1);
197 button_table.attach (group_button, 0, 2, 1, 2);
198 button_table.attach (input_button, 0, 2, 2, 3);
200 button_table.attach (polarity_button, 0, 2, 3, 4);
202 button_table.attach (*solo_button, 0, 1, 4, 5);
203 button_table.attach (*mute_button, 1, 2, 4, 5);
205 // button_table.attach (gain_automation_style_button, 0, 1, 5, 6);
206 button_table.attach (gain_automation_state_button, 0, 1, 5, 6);
207 // button_table.attach (pan_automation_style_button, 0, 1, 6, 7);
208 button_table.attach (pan_automation_state_button, 1, 2, 5, 6);
210 using namespace Menu_Helpers;
212 gain_astate_menu.items().push_back (MenuElem (_("off"),
213 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Off)));
214 gain_astate_menu.items().push_back (MenuElem (_("play"),
215 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Play)));
216 gain_astate_menu.items().push_back (MenuElem (_("write"),
217 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Write)));
218 gain_astate_menu.items().push_back (MenuElem (_("touch"),
219 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Touch)));
221 gain_astyle_menu.items().push_back (MenuElem (_("trim")));
222 gain_astyle_menu.items().push_back (MenuElem (_("abs")));
224 pan_astate_menu.items().push_back (MenuElem (_("off"),
225 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Off)));
226 pan_astate_menu.items().push_back (MenuElem (_("play"),
227 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Play)));
228 pan_astate_menu.items().push_back (MenuElem (_("write"),
229 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Write)));
230 pan_astate_menu.items().push_back (MenuElem (_("touch"),
231 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Touch)));
233 pan_astyle_menu.items().push_back (MenuElem (_("trim")));
234 pan_astyle_menu.items().push_back (MenuElem (_("abs")));
236 gain_astate_menu.set_name ("ArdourContextMenu");
237 gain_astyle_menu.set_name ("ArdourContextMenu");
238 pan_astate_menu.set_name ("ArdourContextMenu");
239 pan_astyle_menu.set_name ("ArdourContextMenu");
241 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("gain automation mode"));
242 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("pan automation mode"));
243 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("gain automation state"));
244 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("pan automation state"));
246 if (is_audio_track()) {
248 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
250 at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen));
252 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
254 speed_frame.set_name ("BaseFrame");
255 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
256 speed_frame.add (speed_spinner);
258 speed_spinner.set_print_func (speed_printer, 0);
260 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
262 button_table.attach (speed_frame, 0, 2, 6, 7);
263 button_table.attach (*rec_enable_button, 0, 2, 7, 8);
266 name_button.add (name_label);
267 name_button.set_name ("MixerNameButton");
268 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
270 name_label.set_name ("MixerNameButtonLabel");
271 name_label.set_text (_route.name());
273 group_button.add (group_label);
274 group_button.set_name ("MixerGroupButton");
275 group_label.set_name ("MixerGroupButtonLabel");
277 comment_button.set_name ("MixerCommentButton");
278 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ?
279 _("click to add/edit comments"):
281 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
283 global_vpacker.set_border_width (4);
284 global_vpacker.set_spacing (4);
286 Gtk::VBox *whvbox = manage (new Gtk::VBox);
288 width_button.set_name ("MixerWidthButton");
289 hide_button.set_name ("MixerHideButton");
291 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
292 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
294 width_hide_box.pack_start (width_button, false, true);
295 width_hide_box.pack_end (hide_button, false, true);
297 whvbox->pack_start (width_hide_box, true, true);
299 global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
300 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
301 global_vpacker.pack_start (pre_redirect_box, true, true);
302 global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK);
303 global_vpacker.pack_start (post_redirect_box, true, true);
304 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
305 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
306 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
308 global_frame.add (global_vpacker);
309 global_frame.set_shadow_type (Gtk::SHADOW_IN);
310 global_frame.set_name ("BaseFrame");
314 /* force setting of visible selected status */
317 set_selected (false);
322 _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed));
323 _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed));
324 _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
325 _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
326 _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
327 _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed));
328 _route.gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_state_changed));
329 _route.gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_style_changed));
330 _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan));
332 if (is_audio_track()) {
333 audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed));
334 get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed));
337 _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed));
338 _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
339 _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
341 input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
342 output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
344 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
345 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press));
346 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
347 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press));
348 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
350 gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
351 gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
352 pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
353 pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
355 gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
356 gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
357 pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
358 pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
360 polarity_button.signal_toggled().connect (mem_fun(*this, &MixerStrip::polarity_toggled));
362 name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release), false);
364 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
367 set_stuff_from_route ();
369 /* start off as a passthru strip. we'll correct this, if necessary,
370 in update_diskstream_display().
373 set_name ("AudioTrackStripBase");
375 /* now force an update of all the various elements */
377 pre_redirect_box.update();
378 post_redirect_box.update();
383 mix_group_changed (0);
384 gain_automation_state_changed ();
385 pan_automation_state_changed ();
388 panners.setup_pan ();
390 if (is_audio_track()) {
394 /* XXX hack: no phase invert changed signal */
396 polarity_button.set_active (_route.phase_invert());
398 update_diskstream_display ();
399 update_input_display ();
400 update_output_display ();
402 add_events (Gdk::BUTTON_RELEASE_MASK);
405 MixerStrip::~MixerStrip ()
407 GoingAway(); /* EMIT_SIGNAL */
409 if (input_selector) {
410 delete input_selector;
413 if (output_selector) {
414 delete output_selector;
419 MixerStrip::set_stuff_from_route ()
425 if ((prop = xml_node->property ("strip_width")) != 0) {
426 if (prop->value() == "wide") {
428 } else if (prop->value() == "narrow") {
432 error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg;
440 if ((prop = xml_node->property ("shown_mixer")) != 0) {
441 if (prop->value() == "no") {
442 _marked_for_display = false;
444 _marked_for_display = true;
448 /* backwards compatibility */
449 _marked_for_display = true;
454 MixerStrip::set_width (Width w)
456 /* always set the gpm width again, things may be hidden */
458 panners.set_width (w);
459 pre_redirect_box.set_width (w);
460 post_redirect_box.set_width (w);
472 set_size_request (-1, -1);
473 xml_node->add_property ("strip_width", "wide");
475 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("RECORD"));
476 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("mute"));
477 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("solo"));
478 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("comments"));
479 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
480 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
481 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
482 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
483 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("polarity"));
484 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
488 set_size_request (50, -1);
489 xml_node->add_property ("strip_width", "narrow");
491 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("REC"));
492 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("m"));
493 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("s"));
494 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("cmt"));
495 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
496 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
497 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
498 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
499 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("pol"));
500 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
504 update_input_display ();
505 update_output_display ();
506 mix_group_changed (0);
511 MixerStrip::set_packed (bool yn)
518 xml_node->add_property ("shown_mixer", "yes");
520 xml_node->add_property ("shown_mixer", "no");
526 MixerStrip::output_press (GdkEventButton *ev)
528 using namespace Menu_Helpers;
530 if (!_session.engine().connected()) {
531 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
535 MenuList& citems = output_menu.items();
536 output_menu.set_name ("ArdourContextMenu");
539 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
540 citems.push_back (SeparatorElem());
541 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
542 citems.push_back (SeparatorElem());
544 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
546 output_menu.popup (1, ev->time);
552 MixerStrip::edit_output_configuration ()
554 if (output_selector == 0) {
555 output_selector = new IOSelectorWindow (_session, _route, false);
558 if (output_selector->is_visible()) {
559 output_selector->get_toplevel()->get_window()->raise();
561 output_selector->show_all ();
566 MixerStrip::edit_input_configuration ()
568 if (input_selector == 0) {
569 input_selector = new IOSelectorWindow (_session, _route, true);
572 if (input_selector->is_visible()) {
573 input_selector->get_toplevel()->get_window()->raise();
575 input_selector->show_all ();
580 MixerStrip::input_press (GdkEventButton *ev)
582 using namespace Menu_Helpers;
584 MenuList& citems = input_menu.items();
585 input_menu.set_name ("ArdourContextMenu");
588 if (!_session.engine().connected()) {
589 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
593 #if ADVANCED_ROUTE_DISKSTREAM_CONNECTIVITY
594 if (is_audio_track()) {
595 citems.push_back (MenuElem (_("Track"), mem_fun(*this, &MixerStrip::select_stream_input)));
598 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
599 citems.push_back (SeparatorElem());
600 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
601 citems.push_back (SeparatorElem());
603 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
604 input_menu.popup (1, ev->time);
610 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
612 if (!ignore_toggle) {
615 _route.use_input_connection (*c, this);
618 catch (AudioEngine::PortRegistrationFailure& err) {
619 error << _("could not register new ports required for that connection")
626 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
628 if (!ignore_toggle) {
631 _route.use_output_connection (*c, this);
634 catch (AudioEngine::PortRegistrationFailure& err) {
635 error << _("could not register new ports required for that connection")
642 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
644 using namespace Menu_Helpers;
646 if (dynamic_cast<InputConnection *> (c) == 0) {
650 MenuList& citems = input_menu.items();
652 if (c->nports() == _route.n_inputs()) {
654 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
656 ARDOUR::Connection *current = _route.input_connection();
659 ignore_toggle = true;
660 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
661 ignore_toggle = false;
667 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
669 using namespace Menu_Helpers;
671 if (dynamic_cast<OutputConnection *> (c) == 0) {
675 if (c->nports() == _route.n_outputs()) {
677 MenuList& citems = output_menu.items();
678 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
680 ARDOUR::Connection *current = _route.output_connection();
683 ignore_toggle = true;
684 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
685 ignore_toggle = false;
691 MixerStrip::select_stream_input ()
693 using namespace Menu_Helpers;
695 Menu *stream_menu = manage (new Menu);
696 MenuList& items = stream_menu->items();
697 stream_menu->set_name ("ArdourContextMenu");
699 Session::DiskStreamList streams = _session.disk_streams();
701 for (Session::DiskStreamList::iterator i = streams.begin(); i != streams.end(); ++i) {
703 if (!(*i)->hidden()) {
705 items.push_back (CheckMenuElem ((*i)->name(), bind (mem_fun(*this, &MixerStrip::stream_input_chosen), *i)));
707 if (get_diskstream() == *i) {
708 ignore_toggle = true;
709 static_cast<CheckMenuItem *> (&items.back())->set_active (true);
710 ignore_toggle = false;
715 stream_menu->popup (1, 0);
719 MixerStrip::stream_input_chosen (DiskStream *stream)
721 if (is_audio_track()) {
722 audio_track()->set_diskstream (*stream, this);
727 MixerStrip::update_diskstream_display ()
729 if (is_audio_track()) {
733 update_input_display ();
735 if (input_selector) {
736 input_selector->hide_all ();
745 update_input_display ();
746 show_passthru_color ();
751 MixerStrip::connect_to_pan ()
753 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
755 panstate_connection.disconnect ();
756 panstyle_connection.disconnect ();
758 if (!_route.panner().empty()) {
759 StreamPanner* sp = _route.panner().front();
761 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_state_changed));
762 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_style_changed));
765 panners.pan_changed (this);
769 MixerStrip::update_input_display ()
771 ARDOUR::Connection *c;
773 if ((c = _route.input_connection()) != 0) {
774 input_label.set_text (c->name());
778 input_label.set_text (_("INPUT"));
781 input_label.set_text (_("IN"));
786 panners.setup_pan ();
790 MixerStrip::update_output_display ()
792 ARDOUR::Connection *c;
794 if ((c = _route.output_connection()) != 0) {
795 output_label.set_text (c->name());
799 output_label.set_text (_("OUTPUT"));
802 output_label.set_text (_("OUT"));
808 panners.setup_pan ();
812 MixerStrip::update ()
814 gpm.update_meters ();
818 MixerStrip::fast_update ()
820 if (_session.meter_falloff() > 0.0f) {
821 gpm.update_meters_falloff ();
826 MixerStrip::gain_automation_state_button_event (GdkEventButton *ev)
828 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
832 switch (ev->button) {
834 switch (ev->button) {
836 gain_astate_menu.popup (1, ev->time);
847 MixerStrip::gain_automation_style_button_event (GdkEventButton *ev)
849 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
853 switch (ev->button) {
855 gain_astyle_menu.popup (1, ev->time);
864 MixerStrip::pan_automation_state_button_event (GdkEventButton *ev)
866 using namespace Menu_Helpers;
868 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
872 switch (ev->button) {
874 pan_astate_menu.popup (1, ev->time);
884 MixerStrip::pan_automation_style_button_event (GdkEventButton *ev)
886 switch (ev->button) {
888 pan_astyle_menu.popup (1, ev->time);
897 MixerStrip::astate_string (AutoState state)
899 return _astate_string (state, false);
903 MixerStrip::short_astate_string (AutoState state)
905 return _astate_string (state, true);
909 MixerStrip::_astate_string (AutoState state, bool shrt)
915 sstr = (shrt ? "--" : _("off"));
918 sstr = (shrt ? "P" : _("aplay"));
921 sstr = (shrt ? "T" : _("touch"));
924 sstr = (shrt ? "W" : _("awrite"));
932 MixerStrip::astyle_string (AutoStyle style)
934 return _astyle_string (style, false);
938 MixerStrip::short_astyle_string (AutoStyle style)
940 return _astyle_string (style, true);
944 MixerStrip::_astyle_string (AutoStyle style, bool shrt)
949 /* XXX it might different in different languages */
951 return (shrt ? _("abs") : _("abs"));
956 MixerStrip::diskstream_changed (void *src)
958 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
962 MixerStrip::gain_automation_style_changed ()
966 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
969 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
975 MixerStrip::gain_automation_state_changed ()
977 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::gain_automation_state_changed));
983 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
986 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
990 x = (_route.gain_automation_state() != Off);
992 if (gain_automation_state_button.get_active() != x) {
993 ignore_toggle = true;
994 gain_automation_state_button.set_active (x);
995 ignore_toggle = false;
998 gpm.update_gain_sensitive ();
1000 /* start watching automation so that things move */
1002 gain_watching.disconnect();
1005 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (gpm, &GainMeter::effective_gain_display));
1010 MixerStrip::pan_automation_style_changed ()
1012 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_style_changed));
1016 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
1019 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
1025 MixerStrip::pan_automation_state_changed ()
1027 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_state_changed));
1033 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
1036 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
1040 /* when creating a new session, we get to create busses (and
1041 sometimes tracks) with no outputs by the time they get
1045 if (_route.panner().empty()) {
1049 x = (_route.panner().front()->automation().automation_state() != Off);
1051 if (pan_automation_state_button.get_active() != x) {
1052 ignore_toggle = true;
1053 pan_automation_state_button.set_active (x);
1054 ignore_toggle = false;
1057 panners.update_pan_sensitive ();
1059 /* start watching automation so that things move */
1061 pan_watching.disconnect();
1064 pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (panners, &PannerUI::effective_pan_display));
1069 MixerStrip::input_changed (IOChange change, void *src)
1071 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1075 MixerStrip::output_changed (IOChange change, void *src)
1077 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1081 MixerStrip::comment_button_clicked ()
1083 if (comment_window == 0) {
1084 setup_comment_editor ();
1087 if (comment_window->is_visible()) {
1088 comment_window->hide ();
1092 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1093 comment_window->show_all ();
1094 comment_window->present();
1096 ResponseType response = (ResponseType) comment_window->run();
1097 comment_window->hide ();
1100 case RESPONSE_ACCEPT:
1106 string str = comment_area->get_buffer()->get_text();
1107 _route.set_comment (str, this);
1108 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1109 str.empty() ? _("click to add/edit comments") : str);
1113 MixerStrip::setup_comment_editor ()
1116 title = _route.name();
1117 title += _(": comment editor");
1119 comment_window = new ArdourDialog (title, false);
1120 comment_area = manage (new TextView());
1122 comment_area->set_name ("MixerTrackCommentArea");
1123 comment_area->set_editable (true);
1124 comment_area->get_buffer()->set_text (_route.comment());
1125 comment_area->set_size_request (200,100);
1126 comment_area->show ();
1128 comment_window->get_vbox()->pack_start (*comment_area);
1129 comment_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1130 comment_window->add_button (Stock::OK, RESPONSE_ACCEPT);
1134 MixerStrip::comment_changed (void *src)
1136 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1139 ignore_comment_edit = true;
1141 comment_area->get_buffer()->set_text (_route.comment());
1143 ignore_comment_edit = false;
1148 MixerStrip::set_mix_group (RouteGroup *rg)
1151 _route.set_mix_group (rg, this);
1157 MixerStrip::add_mix_group_to_menu (RouteGroup *rg)
1159 using namespace Menu_Helpers;
1161 MenuList& items = group_menu->items();
1162 items.push_back (MenuElem (rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1166 MixerStrip::select_mix_group (GdkEventButton *ev)
1168 using namespace Menu_Helpers;
1170 group_menu = new Menu;
1171 group_menu->set_name ("ArdourContextMenu");
1172 MenuList& items = group_menu->items();
1174 items.push_back (MenuElem (_("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1175 _session.foreach_mix_group (this, &MixerStrip::add_mix_group_to_menu);
1177 group_menu->popup (ev->button, 0);
1178 return stop_signal (group_button, "button_press_event");
1182 MixerStrip::mix_group_changed (void *ignored)
1184 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1186 RouteGroup *rg = _route.mix_group();
1189 group_label.set_text (rg->name());
1193 group_label.set_text (_("no group"));
1196 group_label.set_text (_("~G"));
1203 MixerStrip::polarity_toggled ()
1207 if ((x = polarity_button.get_active()) != _route.phase_invert()) {
1208 _route.set_phase_invert (x, this);
1214 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1216 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1218 if (what_changed == "color") {
1219 if (set_color_from_route () == 0) {
1220 show_route_color ();
1226 MixerStrip::show_route_color ()
1228 name_button.ensure_style ();
1229 Glib::RefPtr<Gtk::Style> style = name_button.get_style()->copy();
1230 style->set_bg (Gtk::STATE_NORMAL, color());
1231 name_button.set_style (style);
1233 route_active_changed ();
1237 MixerStrip::show_passthru_color ()
1239 route_active_changed ();
1243 MixerStrip::build_route_ops_menu ()
1245 using namespace Menu_Helpers;
1247 route_ops_menu = manage (new Menu);
1248 route_ops_menu->set_name ("ArdourContextMenu");
1250 MenuList& items = route_ops_menu->items();
1252 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1253 items.push_back (SeparatorElem());
1254 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
1255 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1256 route_active_menu_item->set_active (_route.active());
1258 build_remote_control_menu ();
1260 items.push_back (SeparatorElem());
1261 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1263 items.push_back (SeparatorElem());
1264 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1268 MixerStrip::name_button_button_release (GdkEventButton* ev)
1270 if (ev->button == 3) {
1271 list_route_operations ();
1277 MixerStrip::list_route_operations ()
1279 if (route_ops_menu == 0) {
1280 build_route_ops_menu ();
1283 refresh_remote_control_menu();
1285 route_ops_menu->popup (1, 0);
1290 MixerStrip::speed_adjustment_changed ()
1292 /* since there is a usable speed adjustment, there has to be a diskstream */
1293 if (!ignore_speed_adjustment) {
1294 get_diskstream()->set_speed (speed_adjustment.get_value());
1299 MixerStrip::speed_changed ()
1301 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1305 MixerStrip::update_speed_display ()
1309 val = get_diskstream()->speed();
1312 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1314 speed_spinner.set_name ("MixerStripSpeedBase");
1317 if (speed_adjustment.get_value() != val) {
1318 ignore_speed_adjustment = true;
1319 speed_adjustment.set_value (val);
1320 ignore_speed_adjustment = false;
1326 MixerStrip::set_selected (bool yn)
1328 AxisView::set_selected (yn);
1330 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1331 global_frame.set_name ("MixerStripSelectedFrame");
1333 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1334 global_frame.set_name ("MixerStripFrame");
1336 global_frame.queue_draw ();
1340 MixerStrip::name_changed (void *src)
1344 RouteUI::name_changed (src);
1347 name_label.set_text (short_version (_route.name(), 5));
1353 MixerStrip::width_clicked ()
1366 MixerStrip::hide_clicked ()
1369 Hiding(); /* EMIT_SIGNAL */
1371 _mixer.unselect_strip_in_display (this);
1376 MixerStrip::set_embedded (bool yn)
1382 MixerStrip::map_frozen ()
1384 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1386 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
1389 switch (at->freeze_state()) {
1390 case AudioTrack::Frozen:
1391 pre_redirect_box.set_sensitive (false);
1392 post_redirect_box.set_sensitive (false);
1393 speed_spinner.set_sensitive (false);
1396 pre_redirect_box.set_sensitive (true);
1397 post_redirect_box.set_sensitive (true);
1398 speed_spinner.set_sensitive (true);
1402 _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1406 MixerStrip::hide_redirect_editor (Redirect* redirect)
1408 void* gui = redirect->get_gui ();
1411 static_cast<Gtk::Widget*>(gui)->hide ();
1416 MixerStrip::route_active_changed ()
1418 RouteUI::route_active_changed ();
1420 if (is_audio_track()) {
1421 if (_route.active()) {
1422 set_name ("AudioTrackStripBase");
1423 gpm.set_meter_strip_name ("AudioTrackStripBase");
1425 set_name ("AudioTrackStripBaseInactive");
1426 gpm.set_meter_strip_name ("AudioTrackStripBaseInactive");
1428 gpm.set_fader_name ("AudioTrackFader");
1430 if (_route.active()) {
1431 set_name ("AudioBusStripBase");
1432 gpm.set_meter_strip_name ("AudioBusStripBase");
1434 set_name ("AudioBusStripBaseInactive");
1435 gpm.set_meter_strip_name ("AudioBusStripBaseInactive");
1437 gpm.set_fader_name ("AudioBusFader");