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 "mixer_strip.h"
52 #include "plugin_selector.h"
53 #include "public_editor.h"
55 #include "plugin_ui.h"
57 #include "io_selector.h"
59 #include "gui_thread.h"
64 using namespace ARDOUR;
66 using namespace Gtkmm2ext;
68 #ifdef VARISPEED_IN_MIXER_STRIP
70 speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg)
72 float val = adj.get_value ();
77 snprintf (buf, 32, "%.3f", val);
82 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
84 RouteUI (rt, sess, _("mute"), _("solo"), _("RECORD")),
86 pre_redirect_box (PreFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
87 post_redirect_box (PostFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
89 panners (_route, sess),
91 gain_automation_style_button (""),
92 gain_automation_state_button (""),
93 pan_automation_style_button (""),
94 pan_automation_state_button (""),
95 polarity_button (_("polarity")),
96 comment_button (_("comments")),
97 speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
98 speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
101 if (set_color_from_route()) {
102 set_color (unique_random_color());
108 _marked_for_display = false;
110 ignore_comment_edit = false;
111 ignore_toggle = false;
112 ignore_speed_adjustment = false;
116 width_button.add (*(manage (new Gtk::Image (get_xpm("lr.xpm")))));
117 hide_button.add (*(manage (new Gtk::Image (get_xpm("small_x.xpm")))));
120 input_label.set_text (_("INPUT"));
121 input_button.add (input_label);
122 input_button.set_name ("MixerIOButton");
123 input_label.set_name ("MixerIOButtonLabel");
125 output_label.set_text (_("OUTPUT"));
126 output_button.add (output_label);
127 output_button.set_name ("MixerIOButton");
128 output_label.set_name ("MixerIOButtonLabel");
130 rec_enable_button->set_name ("MixerRecordEnableButton");
131 rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
133 solo_button->set_name ("MixerSoloButton");
134 mute_button->set_name ("MixerMuteButton");
135 gain_automation_style_button.set_name ("MixerAutomationModeButton");
136 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
137 pan_automation_style_button.set_name ("MixerAutomationModeButton");
138 pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
139 polarity_button.set_name ("MixerPhaseInvertButton");
141 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
142 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Gain automation mode"));
144 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
145 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Gain automation type"));
147 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
149 width_button.unset_flags (Gtk::CAN_FOCUS);
150 hide_button.unset_flags (Gtk::CAN_FOCUS);
151 input_button.unset_flags (Gtk::CAN_FOCUS);
152 output_button.unset_flags (Gtk::CAN_FOCUS);
153 solo_button->unset_flags (Gtk::CAN_FOCUS);
154 mute_button->unset_flags (Gtk::CAN_FOCUS);
155 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
156 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
157 pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
158 pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
159 polarity_button.unset_flags (Gtk::CAN_FOCUS);
161 button_table.set_homogeneous (true);
162 button_table.set_spacings (0);
164 button_table.attach (name_button, 0, 2, 0, 1);
165 button_table.attach (group_button, 0, 2, 1, 2);
166 button_table.attach (input_button, 0, 2, 2, 3);
168 button_table.attach (polarity_button, 0, 2, 3, 4);
170 button_table.attach (*solo_button, 0, 1, 4, 5);
171 button_table.attach (*mute_button, 1, 2, 4, 5);
173 // button_table.attach (gain_automation_style_button, 0, 1, 5, 6);
174 button_table.attach (gain_automation_state_button, 0, 1, 5, 6);
175 // button_table.attach (pan_automation_style_button, 0, 1, 6, 7);
176 button_table.attach (pan_automation_state_button, 1, 2, 5, 6);
178 using namespace Menu_Helpers;
180 gain_astate_menu.items().push_back (MenuElem (_("off"),
181 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Off)));
182 gain_astate_menu.items().push_back (MenuElem (_("play"),
183 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Play)));
184 gain_astate_menu.items().push_back (MenuElem (_("write"),
185 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Write)));
186 gain_astate_menu.items().push_back (MenuElem (_("touch"),
187 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Touch)));
189 gain_astyle_menu.items().push_back (MenuElem (_("trim")));
190 gain_astyle_menu.items().push_back (MenuElem (_("abs")));
192 pan_astate_menu.items().push_back (MenuElem (_("off"),
193 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Off)));
194 pan_astate_menu.items().push_back (MenuElem (_("play"),
195 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Play)));
196 pan_astate_menu.items().push_back (MenuElem (_("write"),
197 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Write)));
198 pan_astate_menu.items().push_back (MenuElem (_("touch"),
199 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Touch)));
201 pan_astyle_menu.items().push_back (MenuElem (_("trim")));
202 pan_astyle_menu.items().push_back (MenuElem (_("abs")));
204 gain_astate_menu.set_name ("ArdourContextMenu");
205 gain_astyle_menu.set_name ("ArdourContextMenu");
206 pan_astate_menu.set_name ("ArdourContextMenu");
207 pan_astyle_menu.set_name ("ArdourContextMenu");
209 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("gain automation mode"));
210 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("pan automation mode"));
211 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("gain automation state"));
212 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("pan automation state"));
214 if (is_audio_track()) {
216 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
218 at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen));
220 #ifdef VARISPEED_IN_MIXER_STRIP
221 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
223 speed_frame.set_name ("BaseFrame");
224 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
225 speed_frame.add (speed_spinner);
227 speed_spinner.set_print_func (speed_printer, 0);
229 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
231 button_table.attach (speed_frame, 0, 2, 6, 7);
232 #endif /* VARISPEED_IN_MIXER_STRIP */
234 button_table.attach (*rec_enable_button, 0, 2, 6, 7);
237 name_button.add (name_label);
238 name_button.set_name ("MixerNameButton");
239 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
241 name_label.set_name ("MixerNameButtonLabel");
242 name_label.set_text (_route.name());
244 group_button.add (group_label);
245 group_button.set_name ("MixerGroupButton");
246 group_label.set_name ("MixerGroupButtonLabel");
248 comment_button.set_name ("MixerCommentButton");
249 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ?
250 _("click to add/edit comments"):
252 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
254 global_vpacker.set_border_width (0);
255 global_vpacker.set_spacing (0);
257 Gtk::VBox *whvbox = manage (new Gtk::VBox);
259 width_button.set_name ("MixerWidthButton");
260 hide_button.set_name ("MixerHideButton");
262 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
263 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
265 width_hide_box.pack_start (width_button, false, true);
266 width_hide_box.pack_end (hide_button, false, true);
268 whvbox->pack_start (width_hide_box, true, true);
270 global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
271 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
272 global_vpacker.pack_start (pre_redirect_box, true, true);
273 global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK, 4);
274 global_vpacker.pack_start (post_redirect_box, true, true);
275 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
277 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
279 global_frame.add (global_vpacker);
280 global_frame.set_shadow_type (Gtk::SHADOW_IN);
281 global_frame.set_name ("BaseFrame");
285 /* force setting of visible selected status */
288 set_selected (false);
293 _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed));
294 _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed));
295 _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
296 _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
297 _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
298 _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed));
299 _route.gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_state_changed));
300 _route.gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_style_changed));
301 _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan));
303 if (is_audio_track()) {
304 audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed));
305 get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed));
308 _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed));
309 _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
310 _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
312 input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
313 output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
315 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
316 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
317 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
318 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
319 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
321 gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
322 gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
323 pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
324 pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
326 gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
327 gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
328 pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
329 pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
331 polarity_button.signal_toggled().connect (mem_fun(*this, &MixerStrip::polarity_toggled));
333 name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release), false);
335 group_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
338 set_stuff_from_route ();
340 /* start off as a passthru strip. we'll correct this, if necessary,
341 in update_diskstream_display().
344 set_name ("AudioTrackStripBase");
346 /* now force an update of all the various elements */
348 pre_redirect_box.update();
349 post_redirect_box.update();
354 mix_group_changed (0);
355 gain_automation_state_changed ();
356 pan_automation_state_changed ();
359 panners.setup_pan ();
361 if (is_audio_track()) {
365 /* XXX hack: no phase invert changed signal */
367 polarity_button.set_active (_route.phase_invert());
369 update_diskstream_display ();
370 update_input_display ();
371 update_output_display ();
373 add_events (Gdk::BUTTON_RELEASE_MASK);
376 MixerStrip::~MixerStrip ()
378 GoingAway(); /* EMIT_SIGNAL */
380 if (input_selector) {
381 delete input_selector;
384 if (output_selector) {
385 delete output_selector;
390 MixerStrip::set_stuff_from_route ()
396 if ((prop = xml_node->property ("strip_width")) != 0) {
397 if (prop->value() == "wide") {
399 } else if (prop->value() == "narrow") {
403 error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg;
411 if ((prop = xml_node->property ("shown_mixer")) != 0) {
412 if (prop->value() == "no") {
413 _marked_for_display = false;
415 _marked_for_display = true;
419 /* backwards compatibility */
420 _marked_for_display = true;
425 MixerStrip::set_width (Width w)
427 /* always set the gpm width again, things may be hidden */
429 panners.set_width (w);
430 pre_redirect_box.set_width (w);
431 post_redirect_box.set_width (w);
443 set_size_request (-1, -1);
444 xml_node->add_property ("strip_width", "wide");
446 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("RECORD"));
447 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("mute"));
448 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("solo"));
449 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("comments"));
450 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
451 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
452 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
453 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
454 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("polarity"));
455 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
459 set_size_request (50, -1);
460 xml_node->add_property ("strip_width", "narrow");
462 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("REC"));
463 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("m"));
464 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("s"));
465 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("cmt"));
466 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
467 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
468 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
469 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
470 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("pol"));
471 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
475 update_input_display ();
476 update_output_display ();
477 mix_group_changed (0);
482 MixerStrip::set_packed (bool yn)
489 xml_node->add_property ("shown_mixer", "yes");
491 xml_node->add_property ("shown_mixer", "no");
497 MixerStrip::output_press (GdkEventButton *ev)
499 using namespace Menu_Helpers;
501 if (!_session.engine().connected()) {
502 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
507 MenuList& citems = output_menu.items();
508 output_menu.set_name ("ArdourContextMenu");
511 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
512 citems.push_back (SeparatorElem());
513 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
514 citems.push_back (SeparatorElem());
516 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
518 output_menu.popup (1, ev->time);
524 MixerStrip::edit_output_configuration ()
526 if (output_selector == 0) {
527 output_selector = new IOSelectorWindow (_session, _route, false);
530 if (output_selector->is_visible()) {
531 output_selector->get_toplevel()->get_window()->raise();
533 output_selector->show_all ();
538 MixerStrip::edit_input_configuration ()
540 if (input_selector == 0) {
541 input_selector = new IOSelectorWindow (_session, _route, true);
544 if (input_selector->is_visible()) {
545 input_selector->get_toplevel()->get_window()->raise();
547 input_selector->show_all ();
552 MixerStrip::input_press (GdkEventButton *ev)
554 using namespace Menu_Helpers;
556 MenuList& citems = input_menu.items();
557 input_menu.set_name ("ArdourContextMenu");
560 if (!_session.engine().connected()) {
561 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
566 #if ADVANCED_ROUTE_DISKSTREAM_CONNECTIVITY
567 if (is_audio_track()) {
568 citems.push_back (MenuElem (_("Track"), mem_fun(*this, &MixerStrip::select_stream_input)));
571 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
572 citems.push_back (SeparatorElem());
573 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
574 citems.push_back (SeparatorElem());
576 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
577 input_menu.popup (1, ev->time);
583 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
585 if (!ignore_toggle) {
588 _route.use_input_connection (*c, this);
591 catch (AudioEngine::PortRegistrationFailure& err) {
592 error << _("could not register new ports required for that connection")
599 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
601 if (!ignore_toggle) {
604 _route.use_output_connection (*c, this);
607 catch (AudioEngine::PortRegistrationFailure& err) {
608 error << _("could not register new ports required for that connection")
615 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
617 using namespace Menu_Helpers;
619 if (dynamic_cast<InputConnection *> (c) == 0) {
623 MenuList& citems = input_menu.items();
625 if (c->nports() == _route.n_inputs()) {
627 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
629 ARDOUR::Connection *current = _route.input_connection();
632 ignore_toggle = true;
633 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
634 ignore_toggle = false;
640 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
642 using namespace Menu_Helpers;
644 if (dynamic_cast<OutputConnection *> (c) == 0) {
648 if (c->nports() == _route.n_outputs()) {
650 MenuList& citems = output_menu.items();
651 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
653 ARDOUR::Connection *current = _route.output_connection();
656 ignore_toggle = true;
657 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
658 ignore_toggle = false;
664 MixerStrip::select_stream_input ()
666 using namespace Menu_Helpers;
668 Menu *stream_menu = manage (new Menu);
669 MenuList& items = stream_menu->items();
670 stream_menu->set_name ("ArdourContextMenu");
672 Session::DiskStreamList streams = _session.disk_streams();
674 for (Session::DiskStreamList::iterator i = streams.begin(); i != streams.end(); ++i) {
676 if (!(*i)->hidden()) {
678 items.push_back (CheckMenuElem ((*i)->name(), bind (mem_fun(*this, &MixerStrip::stream_input_chosen), *i)));
680 if (get_diskstream() == *i) {
681 ignore_toggle = true;
682 static_cast<CheckMenuItem *> (&items.back())->set_active (true);
683 ignore_toggle = false;
688 stream_menu->popup (1, 0);
692 MixerStrip::stream_input_chosen (DiskStream *stream)
694 if (is_audio_track()) {
695 audio_track()->set_diskstream (*stream, this);
700 MixerStrip::update_diskstream_display ()
702 if (is_audio_track()) {
706 update_input_display ();
708 if (input_selector) {
709 input_selector->hide_all ();
718 update_input_display ();
719 show_passthru_color ();
724 MixerStrip::connect_to_pan ()
726 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
728 panstate_connection.disconnect ();
729 panstyle_connection.disconnect ();
731 if (!_route.panner().empty()) {
732 StreamPanner* sp = _route.panner().front();
734 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_state_changed));
735 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_style_changed));
738 panners.pan_changed (this);
742 MixerStrip::update_input_display ()
744 ARDOUR::Connection *c;
746 if ((c = _route.input_connection()) != 0) {
747 input_label.set_text (c->name());
751 input_label.set_text (_("INPUT"));
754 input_label.set_text (_("IN"));
759 panners.setup_pan ();
763 MixerStrip::update_output_display ()
765 ARDOUR::Connection *c;
767 if ((c = _route.output_connection()) != 0) {
768 output_label.set_text (c->name());
772 output_label.set_text (_("OUTPUT"));
775 output_label.set_text (_("OUT"));
781 panners.setup_pan ();
785 MixerStrip::update ()
787 gpm.update_meters ();
791 MixerStrip::fast_update ()
793 if (_session.meter_falloff() > 0.0f) {
794 gpm.update_meters_falloff ();
799 MixerStrip::gain_automation_state_button_event (GdkEventButton *ev)
801 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
805 switch (ev->button) {
807 switch (ev->button) {
809 gain_astate_menu.popup (1, ev->time);
820 MixerStrip::gain_automation_style_button_event (GdkEventButton *ev)
822 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
826 switch (ev->button) {
828 gain_astyle_menu.popup (1, ev->time);
837 MixerStrip::pan_automation_state_button_event (GdkEventButton *ev)
839 using namespace Menu_Helpers;
841 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
845 switch (ev->button) {
847 pan_astate_menu.popup (1, ev->time);
857 MixerStrip::pan_automation_style_button_event (GdkEventButton *ev)
859 switch (ev->button) {
861 pan_astyle_menu.popup (1, ev->time);
870 MixerStrip::astate_string (AutoState state)
872 return _astate_string (state, false);
876 MixerStrip::short_astate_string (AutoState state)
878 return _astate_string (state, true);
882 MixerStrip::_astate_string (AutoState state, bool shrt)
888 sstr = (shrt ? "--" : _("off"));
891 sstr = (shrt ? "P" : _("aplay"));
894 sstr = (shrt ? "T" : _("touch"));
897 sstr = (shrt ? "W" : _("awrite"));
905 MixerStrip::astyle_string (AutoStyle style)
907 return _astyle_string (style, false);
911 MixerStrip::short_astyle_string (AutoStyle style)
913 return _astyle_string (style, true);
917 MixerStrip::_astyle_string (AutoStyle style, bool shrt)
922 /* XXX it might different in different languages */
924 return (shrt ? _("abs") : _("abs"));
929 MixerStrip::diskstream_changed (void *src)
931 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
935 MixerStrip::gain_automation_style_changed ()
939 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
942 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
948 MixerStrip::gain_automation_state_changed ()
950 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::gain_automation_state_changed));
956 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
959 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
963 x = (_route.gain_automation_state() != Off);
965 if (gain_automation_state_button.get_active() != x) {
966 ignore_toggle = true;
967 gain_automation_state_button.set_active (x);
968 ignore_toggle = false;
971 gpm.update_gain_sensitive ();
973 /* start watching automation so that things move */
975 gain_watching.disconnect();
978 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (gpm, &GainMeter::effective_gain_display));
983 MixerStrip::pan_automation_style_changed ()
985 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_style_changed));
989 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
992 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
998 MixerStrip::pan_automation_state_changed ()
1000 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_state_changed));
1006 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
1009 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
1013 /* when creating a new session, we get to create busses (and
1014 sometimes tracks) with no outputs by the time they get
1018 if (_route.panner().empty()) {
1022 x = (_route.panner().front()->automation().automation_state() != Off);
1024 if (pan_automation_state_button.get_active() != x) {
1025 ignore_toggle = true;
1026 pan_automation_state_button.set_active (x);
1027 ignore_toggle = false;
1030 panners.update_pan_sensitive ();
1032 /* start watching automation so that things move */
1034 pan_watching.disconnect();
1037 pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (panners, &PannerUI::effective_pan_display));
1042 MixerStrip::input_changed (IOChange change, void *src)
1044 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1048 MixerStrip::output_changed (IOChange change, void *src)
1050 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1054 MixerStrip::comment_button_clicked ()
1056 if (comment_window == 0) {
1057 setup_comment_editor ();
1060 if (comment_window->is_visible()) {
1061 comment_window->hide ();
1065 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1066 comment_window->show_all ();
1067 comment_window->present();
1069 ResponseType response = (ResponseType) comment_window->run();
1070 comment_window->hide ();
1073 case RESPONSE_ACCEPT:
1079 string str = comment_area->get_buffer()->get_text();
1080 _route.set_comment (str, this);
1081 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1082 str.empty() ? _("click to add/edit comments") : str);
1086 MixerStrip::setup_comment_editor ()
1089 title = _route.name();
1090 title += _(": comment editor");
1092 comment_window = new ArdourDialog (title, false);
1093 comment_area = manage (new TextView());
1095 comment_area->set_name ("MixerTrackCommentArea");
1096 comment_area->set_editable (true);
1097 comment_area->get_buffer()->set_text (_route.comment());
1098 comment_area->set_size_request (200,100);
1099 comment_area->show ();
1101 comment_window->get_vbox()->pack_start (*comment_area);
1102 comment_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1103 comment_window->add_button (Stock::OK, RESPONSE_ACCEPT);
1107 MixerStrip::comment_changed (void *src)
1109 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1112 ignore_comment_edit = true;
1114 comment_area->get_buffer()->set_text (_route.comment());
1116 ignore_comment_edit = false;
1121 MixerStrip::set_mix_group (RouteGroup *rg)
1123 _route.set_mix_group (rg, this);
1127 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1129 using namespace Menu_Helpers;
1131 MenuList& items = group_menu->items();
1133 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1135 if (_route.mix_group() == rg) {
1136 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1141 MixerStrip::select_mix_group (GdkEventButton *ev)
1143 using namespace Menu_Helpers;
1145 if (group_menu == 0) {
1146 group_menu = new Menu;
1148 group_menu->set_name ("ArdourContextMenu");
1149 MenuList& items = group_menu->items();
1150 RadioMenuItem::Group group;
1153 items.push_back (RadioMenuElem (group, _("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1155 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
1157 group_menu->popup (1, 0);
1163 MixerStrip::mix_group_changed (void *ignored)
1165 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1167 RouteGroup *rg = _route.mix_group();
1170 group_label.set_text (rg->name());
1174 group_label.set_text (_("no group"));
1177 group_label.set_text (_("~G"));
1184 MixerStrip::polarity_toggled ()
1188 if ((x = polarity_button.get_active()) != _route.phase_invert()) {
1189 _route.set_phase_invert (x, this);
1195 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1197 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1199 if (what_changed == "color") {
1200 if (set_color_from_route () == 0) {
1201 show_route_color ();
1207 MixerStrip::show_route_color ()
1209 name_button.modify_bg (STATE_NORMAL, color());
1210 route_active_changed ();
1214 MixerStrip::show_passthru_color ()
1216 route_active_changed ();
1220 MixerStrip::build_route_ops_menu ()
1222 using namespace Menu_Helpers;
1224 route_ops_menu = manage (new Menu);
1225 route_ops_menu->set_name ("ArdourContextMenu");
1227 MenuList& items = route_ops_menu->items();
1229 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1230 items.push_back (SeparatorElem());
1231 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
1232 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1233 route_active_menu_item->set_active (_route.active());
1235 build_remote_control_menu ();
1237 items.push_back (SeparatorElem());
1238 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1240 items.push_back (SeparatorElem());
1241 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1245 MixerStrip::name_button_button_release (GdkEventButton* ev)
1247 if (ev->button == 3) {
1248 list_route_operations ();
1254 MixerStrip::list_route_operations ()
1256 if (route_ops_menu == 0) {
1257 build_route_ops_menu ();
1260 refresh_remote_control_menu();
1262 route_ops_menu->popup (1, 0);
1267 MixerStrip::speed_adjustment_changed ()
1269 /* since there is a usable speed adjustment, there has to be a diskstream */
1270 if (!ignore_speed_adjustment) {
1271 get_diskstream()->set_speed (speed_adjustment.get_value());
1276 MixerStrip::speed_changed ()
1278 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1282 MixerStrip::update_speed_display ()
1286 val = get_diskstream()->speed();
1289 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1291 speed_spinner.set_name ("MixerStripSpeedBase");
1294 if (speed_adjustment.get_value() != val) {
1295 ignore_speed_adjustment = true;
1296 speed_adjustment.set_value (val);
1297 ignore_speed_adjustment = false;
1303 MixerStrip::set_selected (bool yn)
1305 AxisView::set_selected (yn);
1307 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1308 global_frame.set_name ("MixerStripSelectedFrame");
1310 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1311 global_frame.set_name ("MixerStripFrame");
1313 global_frame.queue_draw ();
1317 MixerStrip::name_changed (void *src)
1321 RouteUI::name_changed (src);
1324 name_label.set_text (short_version (_route.name(), 5));
1330 MixerStrip::width_clicked ()
1343 MixerStrip::hide_clicked ()
1346 Hiding(); /* EMIT_SIGNAL */
1348 _mixer.hide_strip (this);
1353 MixerStrip::set_embedded (bool yn)
1359 MixerStrip::map_frozen ()
1361 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1363 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
1366 switch (at->freeze_state()) {
1367 case AudioTrack::Frozen:
1368 pre_redirect_box.set_sensitive (false);
1369 post_redirect_box.set_sensitive (false);
1370 speed_spinner.set_sensitive (false);
1373 pre_redirect_box.set_sensitive (true);
1374 post_redirect_box.set_sensitive (true);
1375 speed_spinner.set_sensitive (true);
1379 _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1383 MixerStrip::hide_redirect_editor (Redirect* redirect)
1385 void* gui = redirect->get_gui ();
1388 static_cast<Gtk::Widget*>(gui)->hide ();
1393 MixerStrip::route_active_changed ()
1395 RouteUI::route_active_changed ();
1397 if (is_audio_track()) {
1398 if (_route.active()) {
1399 set_name ("AudioTrackStripBase");
1400 gpm.set_meter_strip_name ("AudioTrackStripBase");
1402 set_name ("AudioTrackStripBaseInactive");
1403 gpm.set_meter_strip_name ("AudioTrackStripBaseInactive");
1405 gpm.set_fader_name ("AudioTrackFader");
1407 if (_route.active()) {
1408 set_name ("AudioBusStripBase");
1409 gpm.set_meter_strip_name ("AudioBusStripBase");
1411 set_name ("AudioBusStripBaseInactive");
1412 gpm.set_meter_strip_name ("AudioBusStripBaseInactive");
1414 gpm.set_fader_name ("AudioBusFader");
1419 MixerStrip::mix_group() const
1421 return _route.mix_group();