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 comment_button (_("comments")),
96 speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
97 speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
100 if (set_color_from_route()) {
101 set_color (unique_random_color());
107 _marked_for_display = false;
109 ignore_comment_edit = false;
110 ignore_toggle = false;
111 ignore_speed_adjustment = false;
115 width_button.add (*(manage (new Gtk::Image (get_xpm("lr.xpm")))));
116 hide_button.add (*(manage (new Gtk::Image (get_xpm("small_x.xpm")))));
119 input_label.set_text (_("INPUT"));
120 input_button.add (input_label);
121 input_button.set_name ("MixerIOButton");
122 input_label.set_name ("MixerIOButtonLabel");
124 output_label.set_text (_("OUTPUT"));
125 output_button.add (output_label);
126 output_button.set_name ("MixerIOButton");
127 output_label.set_name ("MixerIOButtonLabel");
129 rec_enable_button->set_name ("MixerRecordEnableButton");
130 rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
132 solo_button->set_name ("MixerSoloButton");
133 mute_button->set_name ("MixerMuteButton");
134 gain_automation_style_button.set_name ("MixerAutomationModeButton");
135 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
136 pan_automation_style_button.set_name ("MixerAutomationModeButton");
137 pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
139 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
140 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Gain automation mode"));
142 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
143 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Gain automation type"));
145 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
147 width_button.unset_flags (Gtk::CAN_FOCUS);
148 hide_button.unset_flags (Gtk::CAN_FOCUS);
149 input_button.unset_flags (Gtk::CAN_FOCUS);
150 output_button.unset_flags (Gtk::CAN_FOCUS);
151 solo_button->unset_flags (Gtk::CAN_FOCUS);
152 mute_button->unset_flags (Gtk::CAN_FOCUS);
153 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
154 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
155 pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
156 pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
158 button_table.set_homogeneous (true);
159 button_table.set_spacings (0);
161 button_table.attach (name_button, 0, 2, 0, 1);
162 button_table.attach (group_button, 0, 2, 1, 2);
163 button_table.attach (input_button, 0, 2, 2, 3);
165 button_table.attach (*solo_button, 0, 1, 3, 4);
166 button_table.attach (*mute_button, 1, 2, 3, 4);
168 button_table.attach (gain_automation_state_button, 0, 1, 4, 5);
169 button_table.attach (pan_automation_state_button, 1, 2, 4, 5);
171 using namespace Menu_Helpers;
173 gain_astate_menu.items().push_back (MenuElem (_("off"),
174 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Off)));
175 gain_astate_menu.items().push_back (MenuElem (_("play"),
176 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Play)));
177 gain_astate_menu.items().push_back (MenuElem (_("write"),
178 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Write)));
179 gain_astate_menu.items().push_back (MenuElem (_("touch"),
180 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Touch)));
182 gain_astyle_menu.items().push_back (MenuElem (_("trim")));
183 gain_astyle_menu.items().push_back (MenuElem (_("abs")));
185 pan_astate_menu.items().push_back (MenuElem (_("off"),
186 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Off)));
187 pan_astate_menu.items().push_back (MenuElem (_("play"),
188 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Play)));
189 pan_astate_menu.items().push_back (MenuElem (_("write"),
190 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Write)));
191 pan_astate_menu.items().push_back (MenuElem (_("touch"),
192 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Touch)));
194 pan_astyle_menu.items().push_back (MenuElem (_("trim")));
195 pan_astyle_menu.items().push_back (MenuElem (_("abs")));
197 gain_astate_menu.set_name ("ArdourContextMenu");
198 gain_astyle_menu.set_name ("ArdourContextMenu");
199 pan_astate_menu.set_name ("ArdourContextMenu");
200 pan_astyle_menu.set_name ("ArdourContextMenu");
202 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("gain automation mode"));
203 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("pan automation mode"));
204 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("gain automation state"));
205 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("pan automation state"));
207 if (is_audio_track()) {
209 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
211 at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen));
213 #ifdef VARISPEED_IN_MIXER_STRIP
214 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
216 speed_frame.set_name ("BaseFrame");
217 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
218 speed_frame.add (speed_spinner);
220 speed_spinner.set_print_func (speed_printer, 0);
222 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
224 button_table.attach (speed_frame, 0, 2, 5, 6);
225 #endif /* VARISPEED_IN_MIXER_STRIP */
227 button_table.attach (*rec_enable_button, 0, 2, 5, 6);
230 name_button.add (name_label);
231 name_button.set_name ("MixerNameButton");
232 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
234 name_label.set_name ("MixerNameButtonLabel");
235 name_label.set_text (_route.name());
237 group_button.add (group_label);
238 group_button.set_name ("MixerGroupButton");
239 group_label.set_name ("MixerGroupButtonLabel");
241 comment_button.set_name ("MixerCommentButton");
242 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ?
243 _("click to add/edit comments"):
245 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
247 global_vpacker.set_border_width (0);
248 global_vpacker.set_spacing (0);
250 Gtk::VBox *whvbox = manage (new Gtk::VBox);
252 width_button.set_name ("MixerWidthButton");
253 hide_button.set_name ("MixerHideButton");
255 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
256 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
258 width_hide_box.pack_start (width_button, false, true);
259 width_hide_box.pack_end (hide_button, false, true);
261 whvbox->pack_start (width_hide_box, true, true);
263 global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
264 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
265 global_vpacker.pack_start (pre_redirect_box, true, true);
266 global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK, 4);
267 global_vpacker.pack_start (post_redirect_box, true, true);
268 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
269 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
270 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
272 global_frame.add (global_vpacker);
273 global_frame.set_shadow_type (Gtk::SHADOW_IN);
274 global_frame.set_name ("BaseFrame");
278 /* force setting of visible selected status */
281 set_selected (false);
286 _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed));
287 _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed));
288 _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
289 _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
290 _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
291 _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed));
292 _route.gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_state_changed));
293 _route.gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_style_changed));
294 _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan));
296 if (is_audio_track()) {
297 audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed));
298 get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed));
301 _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed));
302 _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
303 _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
305 input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
306 output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
308 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
309 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
310 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
311 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
312 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
314 gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
315 gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
316 pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
317 pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
319 gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
320 gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
321 pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
322 pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
324 name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release), false);
326 group_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
329 set_stuff_from_route ();
331 /* start off as a passthru strip. we'll correct this, if necessary,
332 in update_diskstream_display().
335 set_name ("AudioTrackStripBase");
337 /* now force an update of all the various elements */
339 pre_redirect_box.update();
340 post_redirect_box.update();
345 mix_group_changed (0);
346 gain_automation_state_changed ();
347 pan_automation_state_changed ();
350 panners.setup_pan ();
352 if (is_audio_track()) {
356 update_diskstream_display ();
357 update_input_display ();
358 update_output_display ();
360 add_events (Gdk::BUTTON_RELEASE_MASK);
363 MixerStrip::~MixerStrip ()
365 GoingAway(); /* EMIT_SIGNAL */
367 if (input_selector) {
368 delete input_selector;
371 if (output_selector) {
372 delete output_selector;
377 MixerStrip::set_stuff_from_route ()
383 if ((prop = xml_node->property ("strip_width")) != 0) {
384 if (prop->value() == "wide") {
386 } else if (prop->value() == "narrow") {
390 error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg;
398 if ((prop = xml_node->property ("shown_mixer")) != 0) {
399 if (prop->value() == "no") {
400 _marked_for_display = false;
402 _marked_for_display = true;
406 /* backwards compatibility */
407 _marked_for_display = true;
412 MixerStrip::set_width (Width w)
414 /* always set the gpm width again, things may be hidden */
416 panners.set_width (w);
417 pre_redirect_box.set_width (w);
418 post_redirect_box.set_width (w);
430 set_size_request (-1, -1);
431 xml_node->add_property ("strip_width", "wide");
433 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("RECORD"));
434 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("mute"));
435 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("solo"));
436 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("comments"));
437 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
438 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
439 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
440 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
441 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
445 set_size_request (50, -1);
446 xml_node->add_property ("strip_width", "narrow");
448 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("REC"));
449 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("m"));
450 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("s"));
451 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("cmt"));
452 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
453 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
454 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
455 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
456 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
460 update_input_display ();
461 update_output_display ();
462 mix_group_changed (0);
467 MixerStrip::set_packed (bool yn)
474 xml_node->add_property ("shown_mixer", "yes");
476 xml_node->add_property ("shown_mixer", "no");
482 MixerStrip::output_press (GdkEventButton *ev)
484 using namespace Menu_Helpers;
486 if (!_session.engine().connected()) {
487 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
492 MenuList& citems = output_menu.items();
493 output_menu.set_name ("ArdourContextMenu");
496 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
497 citems.push_back (SeparatorElem());
498 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
499 citems.push_back (SeparatorElem());
501 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
503 output_menu.popup (1, ev->time);
509 MixerStrip::edit_output_configuration ()
511 if (output_selector == 0) {
512 output_selector = new IOSelectorWindow (_session, _route, false);
515 if (output_selector->is_visible()) {
516 output_selector->get_toplevel()->get_window()->raise();
518 output_selector->show_all ();
523 MixerStrip::edit_input_configuration ()
525 if (input_selector == 0) {
526 input_selector = new IOSelectorWindow (_session, _route, true);
529 if (input_selector->is_visible()) {
530 input_selector->get_toplevel()->get_window()->raise();
532 input_selector->show_all ();
537 MixerStrip::input_press (GdkEventButton *ev)
539 using namespace Menu_Helpers;
541 MenuList& citems = input_menu.items();
542 input_menu.set_name ("ArdourContextMenu");
545 if (!_session.engine().connected()) {
546 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
551 #if ADVANCED_ROUTE_DISKSTREAM_CONNECTIVITY
552 if (is_audio_track()) {
553 citems.push_back (MenuElem (_("Track"), mem_fun(*this, &MixerStrip::select_stream_input)));
556 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
557 citems.push_back (SeparatorElem());
558 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
559 citems.push_back (SeparatorElem());
561 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
562 input_menu.popup (1, ev->time);
568 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
570 if (!ignore_toggle) {
573 _route.use_input_connection (*c, this);
576 catch (AudioEngine::PortRegistrationFailure& err) {
577 error << _("could not register new ports required for that connection")
584 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
586 if (!ignore_toggle) {
589 _route.use_output_connection (*c, this);
592 catch (AudioEngine::PortRegistrationFailure& err) {
593 error << _("could not register new ports required for that connection")
600 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
602 using namespace Menu_Helpers;
604 if (dynamic_cast<InputConnection *> (c) == 0) {
608 MenuList& citems = input_menu.items();
610 if (c->nports() == _route.n_inputs()) {
612 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
614 ARDOUR::Connection *current = _route.input_connection();
617 ignore_toggle = true;
618 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
619 ignore_toggle = false;
625 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
627 using namespace Menu_Helpers;
629 if (dynamic_cast<OutputConnection *> (c) == 0) {
633 if (c->nports() == _route.n_outputs()) {
635 MenuList& citems = output_menu.items();
636 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
638 ARDOUR::Connection *current = _route.output_connection();
641 ignore_toggle = true;
642 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
643 ignore_toggle = false;
649 MixerStrip::select_stream_input ()
651 using namespace Menu_Helpers;
653 Menu *stream_menu = manage (new Menu);
654 MenuList& items = stream_menu->items();
655 stream_menu->set_name ("ArdourContextMenu");
657 Session::DiskStreamList streams = _session.disk_streams();
659 for (Session::DiskStreamList::iterator i = streams.begin(); i != streams.end(); ++i) {
661 if (!(*i)->hidden()) {
663 items.push_back (CheckMenuElem ((*i)->name(), bind (mem_fun(*this, &MixerStrip::stream_input_chosen), *i)));
665 if (get_diskstream() == *i) {
666 ignore_toggle = true;
667 static_cast<CheckMenuItem *> (&items.back())->set_active (true);
668 ignore_toggle = false;
673 stream_menu->popup (1, 0);
677 MixerStrip::stream_input_chosen (DiskStream *stream)
679 if (is_audio_track()) {
680 audio_track()->set_diskstream (*stream, this);
685 MixerStrip::update_diskstream_display ()
687 if (is_audio_track()) {
691 update_input_display ();
693 if (input_selector) {
694 input_selector->hide_all ();
703 update_input_display ();
704 show_passthru_color ();
709 MixerStrip::connect_to_pan ()
711 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
713 panstate_connection.disconnect ();
714 panstyle_connection.disconnect ();
716 if (!_route.panner().empty()) {
717 StreamPanner* sp = _route.panner().front();
719 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_state_changed));
720 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_style_changed));
723 panners.pan_changed (this);
727 MixerStrip::update_input_display ()
729 ARDOUR::Connection *c;
731 if ((c = _route.input_connection()) != 0) {
732 input_label.set_text (c->name());
736 input_label.set_text (_("INPUT"));
739 input_label.set_text (_("IN"));
744 panners.setup_pan ();
748 MixerStrip::update_output_display ()
750 ARDOUR::Connection *c;
752 if ((c = _route.output_connection()) != 0) {
753 output_label.set_text (c->name());
757 output_label.set_text (_("OUTPUT"));
760 output_label.set_text (_("OUT"));
766 panners.setup_pan ();
770 MixerStrip::fast_update ()
772 gpm.update_meters ();
776 MixerStrip::gain_automation_state_button_event (GdkEventButton *ev)
778 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
782 switch (ev->button) {
784 switch (ev->button) {
786 gain_astate_menu.popup (1, ev->time);
797 MixerStrip::gain_automation_style_button_event (GdkEventButton *ev)
799 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
803 switch (ev->button) {
805 gain_astyle_menu.popup (1, ev->time);
814 MixerStrip::pan_automation_state_button_event (GdkEventButton *ev)
816 using namespace Menu_Helpers;
818 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
822 switch (ev->button) {
824 pan_astate_menu.popup (1, ev->time);
834 MixerStrip::pan_automation_style_button_event (GdkEventButton *ev)
836 switch (ev->button) {
838 pan_astyle_menu.popup (1, ev->time);
847 MixerStrip::astate_string (AutoState state)
849 return _astate_string (state, false);
853 MixerStrip::short_astate_string (AutoState state)
855 return _astate_string (state, true);
859 MixerStrip::_astate_string (AutoState state, bool shrt)
865 sstr = (shrt ? "--" : _("off"));
868 sstr = (shrt ? "P" : _("aplay"));
871 sstr = (shrt ? "T" : _("touch"));
874 sstr = (shrt ? "W" : _("awrite"));
882 MixerStrip::astyle_string (AutoStyle style)
884 return _astyle_string (style, false);
888 MixerStrip::short_astyle_string (AutoStyle style)
890 return _astyle_string (style, true);
894 MixerStrip::_astyle_string (AutoStyle style, bool shrt)
899 /* XXX it might different in different languages */
901 return (shrt ? _("abs") : _("abs"));
906 MixerStrip::diskstream_changed (void *src)
908 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
912 MixerStrip::gain_automation_style_changed ()
916 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
919 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
925 MixerStrip::gain_automation_state_changed ()
927 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::gain_automation_state_changed));
933 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
936 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
940 x = (_route.gain_automation_state() != Off);
942 if (gain_automation_state_button.get_active() != x) {
943 ignore_toggle = true;
944 gain_automation_state_button.set_active (x);
945 ignore_toggle = false;
948 gpm.update_gain_sensitive ();
950 /* start watching automation so that things move */
952 gain_watching.disconnect();
955 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (gpm, &GainMeter::effective_gain_display));
960 MixerStrip::pan_automation_style_changed ()
962 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_style_changed));
966 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
969 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
975 MixerStrip::pan_automation_state_changed ()
977 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_state_changed));
983 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
986 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
990 /* when creating a new session, we get to create busses (and
991 sometimes tracks) with no outputs by the time they get
995 if (_route.panner().empty()) {
999 x = (_route.panner().front()->automation().automation_state() != Off);
1001 if (pan_automation_state_button.get_active() != x) {
1002 ignore_toggle = true;
1003 pan_automation_state_button.set_active (x);
1004 ignore_toggle = false;
1007 panners.update_pan_sensitive ();
1009 /* start watching automation so that things move */
1011 pan_watching.disconnect();
1014 pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (panners, &PannerUI::effective_pan_display));
1019 MixerStrip::input_changed (IOChange change, void *src)
1021 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1025 MixerStrip::output_changed (IOChange change, void *src)
1027 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1031 MixerStrip::comment_button_clicked ()
1033 if (comment_window == 0) {
1034 setup_comment_editor ();
1037 if (comment_window->is_visible()) {
1038 comment_window->hide ();
1042 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1043 comment_window->show_all ();
1044 comment_window->present();
1046 ResponseType response = (ResponseType) comment_window->run();
1047 comment_window->hide ();
1050 case RESPONSE_ACCEPT:
1056 string str = comment_area->get_buffer()->get_text();
1057 _route.set_comment (str, this);
1058 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1059 str.empty() ? _("click to add/edit comments") : str);
1063 MixerStrip::setup_comment_editor ()
1066 title = _route.name();
1067 title += _(": comment editor");
1069 comment_window = new ArdourDialog (title, false);
1070 comment_area = manage (new TextView());
1072 comment_area->set_name ("MixerTrackCommentArea");
1073 comment_area->set_editable (true);
1074 comment_area->get_buffer()->set_text (_route.comment());
1075 comment_area->set_size_request (200,100);
1076 comment_area->show ();
1078 comment_window->get_vbox()->pack_start (*comment_area);
1079 comment_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1080 comment_window->add_button (Stock::OK, RESPONSE_ACCEPT);
1084 MixerStrip::comment_changed (void *src)
1086 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1089 ignore_comment_edit = true;
1091 comment_area->get_buffer()->set_text (_route.comment());
1093 ignore_comment_edit = false;
1098 MixerStrip::set_mix_group (RouteGroup *rg)
1100 _route.set_mix_group (rg, this);
1104 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1106 using namespace Menu_Helpers;
1108 MenuList& items = group_menu->items();
1110 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1112 if (_route.mix_group() == rg) {
1113 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1118 MixerStrip::select_mix_group (GdkEventButton *ev)
1120 using namespace Menu_Helpers;
1122 if (group_menu == 0) {
1123 group_menu = new Menu;
1125 group_menu->set_name ("ArdourContextMenu");
1126 MenuList& items = group_menu->items();
1127 RadioMenuItem::Group group;
1130 items.push_back (RadioMenuElem (group, _("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1132 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
1134 group_menu->popup (1, 0);
1140 MixerStrip::mix_group_changed (void *ignored)
1142 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1144 RouteGroup *rg = _route.mix_group();
1147 group_label.set_text (rg->name());
1151 group_label.set_text (_("no group"));
1154 group_label.set_text (_("~G"));
1162 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1164 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1166 if (what_changed == "color") {
1167 if (set_color_from_route () == 0) {
1168 show_route_color ();
1174 MixerStrip::show_route_color ()
1176 name_button.modify_bg (STATE_NORMAL, color());
1177 route_active_changed ();
1181 MixerStrip::show_passthru_color ()
1183 route_active_changed ();
1187 MixerStrip::build_route_ops_menu ()
1189 using namespace Menu_Helpers;
1191 route_ops_menu = manage (new Menu);
1192 route_ops_menu->set_name ("ArdourContextMenu");
1194 MenuList& items = route_ops_menu->items();
1196 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1197 items.push_back (SeparatorElem());
1198 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1199 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1200 route_active_menu_item->set_active (_route.active());
1201 items.push_back (SeparatorElem());
1202 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1203 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1204 polarity_menu_item->set_active (_route.phase_invert());
1206 build_remote_control_menu ();
1208 items.push_back (SeparatorElem());
1209 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1211 items.push_back (SeparatorElem());
1212 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1216 MixerStrip::name_button_button_release (GdkEventButton* ev)
1218 if (ev->button == 3) {
1219 list_route_operations ();
1225 MixerStrip::list_route_operations ()
1227 if (route_ops_menu == 0) {
1228 build_route_ops_menu ();
1231 refresh_remote_control_menu();
1233 route_ops_menu->popup (1, 0);
1238 MixerStrip::speed_adjustment_changed ()
1240 /* since there is a usable speed adjustment, there has to be a diskstream */
1241 if (!ignore_speed_adjustment) {
1242 get_diskstream()->set_speed (speed_adjustment.get_value());
1247 MixerStrip::speed_changed ()
1249 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1253 MixerStrip::update_speed_display ()
1257 val = get_diskstream()->speed();
1260 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1262 speed_spinner.set_name ("MixerStripSpeedBase");
1265 if (speed_adjustment.get_value() != val) {
1266 ignore_speed_adjustment = true;
1267 speed_adjustment.set_value (val);
1268 ignore_speed_adjustment = false;
1274 MixerStrip::set_selected (bool yn)
1276 AxisView::set_selected (yn);
1278 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1279 global_frame.set_name ("MixerStripSelectedFrame");
1281 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1282 global_frame.set_name ("MixerStripFrame");
1284 global_frame.queue_draw ();
1288 MixerStrip::name_changed (void *src)
1292 RouteUI::name_changed (src);
1295 name_label.set_text (short_version (_route.name(), 5));
1301 MixerStrip::width_clicked ()
1314 MixerStrip::hide_clicked ()
1317 Hiding(); /* EMIT_SIGNAL */
1319 _mixer.hide_strip (this);
1324 MixerStrip::set_embedded (bool yn)
1330 MixerStrip::map_frozen ()
1332 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1334 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
1337 switch (at->freeze_state()) {
1338 case AudioTrack::Frozen:
1339 pre_redirect_box.set_sensitive (false);
1340 post_redirect_box.set_sensitive (false);
1341 speed_spinner.set_sensitive (false);
1344 pre_redirect_box.set_sensitive (true);
1345 post_redirect_box.set_sensitive (true);
1346 speed_spinner.set_sensitive (true);
1350 _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1354 MixerStrip::hide_redirect_editor (Redirect* redirect)
1356 void* gui = redirect->get_gui ();
1359 static_cast<Gtk::Widget*>(gui)->hide ();
1364 MixerStrip::route_active_changed ()
1366 RouteUI::route_active_changed ();
1368 if (is_audio_track()) {
1369 if (_route.active()) {
1370 set_name ("AudioTrackStripBase");
1371 gpm.set_meter_strip_name ("AudioTrackStripBase");
1373 set_name ("AudioTrackStripBaseInactive");
1374 gpm.set_meter_strip_name ("AudioTrackStripBaseInactive");
1376 gpm.set_fader_name ("AudioTrackFader");
1378 if (_route.active()) {
1379 set_name ("AudioBusStripBase");
1380 gpm.set_meter_strip_name ("AudioBusStripBase");
1382 set_name ("AudioBusStripBaseInactive");
1383 gpm.set_meter_strip_name ("AudioBusStripBaseInactive");
1385 gpm.set_fader_name ("AudioBusFader");
1390 MixerStrip::mix_group() const
1392 return _route.mix_group();