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;
148 width_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(lr_xpm)))));
149 hide_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(small_x_xpm)))));
152 input_label.set_text (_("INPUT"));
153 input_button.add (input_label);
154 input_button.set_name ("MixerIOButton");
155 input_label.set_name ("MixerIOButtonLabel");
157 output_label.set_text (_("OUTPUT"));
158 output_button.add (output_label);
159 output_button.set_name ("MixerIOButton");
160 output_label.set_name ("MixerIOButtonLabel");
162 rec_enable_button->set_name ("MixerRecordEnableButton");
163 rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
165 solo_button->set_name ("MixerSoloButton");
166 mute_button->set_name ("MixerMuteButton");
167 gain_automation_style_button.set_name ("MixerAutomationModeButton");
168 gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
169 pan_automation_style_button.set_name ("MixerAutomationModeButton");
170 pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
171 polarity_button.set_name ("MixerPhaseInvertButton");
173 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
174 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Gain automation mode"));
176 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
177 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Gain automation type"));
179 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
181 width_button.unset_flags (Gtk::CAN_FOCUS);
182 hide_button.unset_flags (Gtk::CAN_FOCUS);
183 input_button.unset_flags (Gtk::CAN_FOCUS);
184 output_button.unset_flags (Gtk::CAN_FOCUS);
185 solo_button->unset_flags (Gtk::CAN_FOCUS);
186 mute_button->unset_flags (Gtk::CAN_FOCUS);
187 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
188 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
189 pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
190 pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
191 polarity_button.unset_flags (Gtk::CAN_FOCUS);
193 button_table.set_homogeneous (true);
195 button_table.attach (name_button, 0, 2, 0, 1);
196 button_table.attach (group_button, 0, 2, 1, 2);
197 button_table.attach (input_button, 0, 2, 2, 3);
199 button_table.attach (polarity_button, 0, 2, 3, 4);
201 button_table.attach (*solo_button, 0, 1, 4, 5);
202 button_table.attach (*mute_button, 1, 2, 4, 5);
204 // button_table.attach (gain_automation_style_button, 0, 1, 5, 6);
205 button_table.attach (gain_automation_state_button, 0, 1, 5, 6);
206 // button_table.attach (pan_automation_style_button, 0, 1, 6, 7);
207 button_table.attach (pan_automation_state_button, 1, 2, 5, 6);
209 using namespace Menu_Helpers;
211 gain_astate_menu.items().push_back (MenuElem (_("off"),
212 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Off)));
213 gain_astate_menu.items().push_back (MenuElem (_("play"),
214 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Play)));
215 gain_astate_menu.items().push_back (MenuElem (_("write"),
216 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Write)));
217 gain_astate_menu.items().push_back (MenuElem (_("touch"),
218 bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Touch)));
220 gain_astyle_menu.items().push_back (MenuElem (_("trim")));
221 gain_astyle_menu.items().push_back (MenuElem (_("abs")));
223 pan_astate_menu.items().push_back (MenuElem (_("off"),
224 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Off)));
225 pan_astate_menu.items().push_back (MenuElem (_("play"),
226 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Play)));
227 pan_astate_menu.items().push_back (MenuElem (_("write"),
228 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Write)));
229 pan_astate_menu.items().push_back (MenuElem (_("touch"),
230 bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Touch)));
232 pan_astyle_menu.items().push_back (MenuElem (_("trim")));
233 pan_astyle_menu.items().push_back (MenuElem (_("abs")));
235 gain_astate_menu.set_name ("ArdourContextMenu");
236 gain_astyle_menu.set_name ("ArdourContextMenu");
237 pan_astate_menu.set_name ("ArdourContextMenu");
238 pan_astyle_menu.set_name ("ArdourContextMenu");
240 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("gain automation mode"));
241 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("pan automation mode"));
242 ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("gain automation state"));
243 ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("pan automation state"));
245 if (is_audio_track()) {
247 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
249 at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen));
251 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
253 speed_frame.set_name ("BaseFrame");
254 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
255 speed_frame.add (speed_spinner);
257 speed_spinner.set_print_func (speed_printer, 0);
259 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
261 speed_spinner.show ();
264 button_table.attach (speed_frame, 0, 2, 6, 7);
265 button_table.attach (*rec_enable_button, 0, 2, 7, 8);
268 name_button.add (name_label);
269 name_button.set_name ("MixerNameButton");
270 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
272 name_label.set_name ("MixerNameButtonLabel");
273 name_label.set_text (_route.name());
275 group_button.add (group_label);
276 group_button.set_name ("MixerGroupButton");
277 group_label.set_name ("MixerGroupButtonLabel");
279 comment_button.set_name ("MixerCommentButton");
280 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ?
281 _("click to add/edit comments"):
283 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
285 global_vpacker.set_border_width (4);
286 global_vpacker.set_spacing (4);
288 Gtk::VBox *whvbox = manage (new Gtk::VBox);
290 width_button.set_name ("MixerWidthButton");
291 hide_button.set_name ("MixerHideButton");
293 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
294 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
296 width_hide_box.pack_start (width_button, false, true);
297 width_hide_box.pack_end (hide_button, false, true);
299 whvbox->pack_start (width_hide_box, true, true);
301 global_vpacker.pack_start (*whvbox, false, false);
302 global_vpacker.pack_start (button_table, false, false);
303 global_vpacker.pack_start (pre_redirect_box, true, true);
304 global_vpacker.pack_start (gpm, false, false);
305 global_vpacker.pack_start (post_redirect_box, true, true);
306 global_vpacker.pack_start (panners, false, false);
307 global_vpacker.pack_start (output_button, false, false);
308 global_vpacker.pack_start (comment_button, false, false);
310 global_frame.add (global_vpacker);
311 global_frame.set_shadow_type (Gtk::SHADOW_IN);
312 global_frame.set_name ("BaseFrame");
316 /* force setting of visible selected status */
319 set_selected (false);
325 output_label.show ();
326 pre_redirect_box.show_all ();
327 post_redirect_box.show_all ();
328 button_table.show ();
329 comment_button.show ();
331 input_button.show ();
332 group_button.show ();
333 output_button.show ();
334 rec_enable_button->show ();
335 solo_button->show ();
336 mute_button->show ();
337 gain_automation_style_button.show ();
338 gain_automation_state_button.show ();
339 pan_automation_style_button.show ();
340 pan_automation_state_button.show ();
341 polarity_button.show ();
342 global_vpacker.show ();
343 global_frame.show ();
348 _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed));
349 _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed));
350 _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
351 _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
352 _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
353 _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed));
354 _route.gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_state_changed));
355 _route.gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_style_changed));
356 _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan));
358 if (is_audio_track()) {
359 audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed));
360 get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed));
363 _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed));
364 _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
365 _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
367 input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press));
368 output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press));
370 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
371 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press));
372 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
373 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press));
374 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
376 gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event));
377 gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event));
378 pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event));
379 pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event));
381 gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event));
382 gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event));
383 pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event));
384 pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event));
386 polarity_button.signal_toggled().connect (mem_fun(*this, &MixerStrip::polarity_toggled));
388 name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release));
390 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group));
393 set_stuff_from_route ();
395 /* start off as a passthru strip. we'll correct this, if necessary,
396 in update_diskstream_display().
399 set_name ("AudioTrackStripBase");
401 /* now force an update of all the various elements */
403 pre_redirect_box.update();
404 post_redirect_box.update();
409 mix_group_changed (0);
410 gain_automation_state_changed ();
411 pan_automation_state_changed ();
414 panners.setup_pan ();
416 if (is_audio_track()) {
420 /* XXX hack: no phase invert changed signal */
422 polarity_button.set_active (_route.phase_invert());
424 update_diskstream_display ();
425 update_input_display ();
426 update_output_display ();
428 add_events (Gdk::BUTTON_RELEASE_MASK);
431 MixerStrip::~MixerStrip ()
433 GoingAway(); /* EMIT_SIGNAL */
435 if (input_selector) {
436 delete input_selector;
439 if (output_selector) {
440 delete output_selector;
445 MixerStrip::set_stuff_from_route ()
451 if ((prop = xml_node->property ("strip_width")) != 0) {
452 if (prop->value() == "wide") {
454 } else if (prop->value() == "narrow") {
458 error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg;
466 if ((prop = xml_node->property ("shown_mixer")) != 0) {
467 if (prop->value() == "no") {
468 _marked_for_display = false;
470 _marked_for_display = true;
474 /* backwards compatibility */
475 _marked_for_display = true;
480 MixerStrip::set_width (Width w)
482 /* always set the gpm width again, things may be hidden */
484 panners.set_width (w);
485 pre_redirect_box.set_width (w);
486 post_redirect_box.set_width (w);
498 set_size_request (-1, -1);
499 xml_node->add_property ("strip_width", "wide");
501 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("RECORD"));
502 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("mute"));
503 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("solo"));
504 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("comments"));
505 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
506 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
507 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
508 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
509 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("polarity"));
510 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
514 set_size_request (50, -1);
515 xml_node->add_property ("strip_width", "narrow");
517 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("REC"));
518 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("m"));
519 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("s"));
520 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("cmt"));
521 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
522 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
523 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
524 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
525 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("pol"));
526 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
530 update_input_display ();
531 update_output_display ();
532 mix_group_changed (0);
537 MixerStrip::set_packed (bool yn)
544 xml_node->add_property ("shown_mixer", "yes");
546 xml_node->add_property ("shown_mixer", "no");
552 MixerStrip::output_press (GdkEventButton *ev)
554 using namespace Menu_Helpers;
556 if (!_session.engine().connected()) {
557 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
561 MenuList& citems = output_menu.items();
562 output_menu.set_name ("ArdourContextMenu");
565 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
566 citems.push_back (SeparatorElem());
567 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
568 citems.push_back (SeparatorElem());
570 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
572 output_menu.popup (1, ev->time);
578 MixerStrip::edit_output_configuration ()
580 if (output_selector == 0) {
581 output_selector = new IOSelectorWindow (_session, _route, false);
584 if (output_selector->is_visible()) {
585 output_selector->get_toplevel()->get_window()->raise();
587 output_selector->show_all ();
592 MixerStrip::edit_input_configuration ()
594 if (input_selector == 0) {
595 input_selector = new IOSelectorWindow (_session, _route, true);
598 if (input_selector->is_visible()) {
599 input_selector->get_toplevel()->get_window()->raise();
601 input_selector->show_all ();
606 MixerStrip::input_press (GdkEventButton *ev)
608 using namespace Menu_Helpers;
610 MenuList& citems = input_menu.items();
611 input_menu.set_name ("ArdourContextMenu");
614 if (!_session.engine().connected()) {
615 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
619 #if ADVANCED_ROUTE_DISKSTREAM_CONNECTIVITY
620 if (is_audio_track()) {
621 citems.push_back (MenuElem (_("Track"), mem_fun(*this, &MixerStrip::select_stream_input)));
624 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
625 citems.push_back (SeparatorElem());
626 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
627 citems.push_back (SeparatorElem());
629 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
631 input_menu.popup (1, ev->time);
637 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
639 if (!ignore_toggle) {
642 _route.use_input_connection (*c, this);
645 catch (AudioEngine::PortRegistrationFailure& err) {
646 error << _("could not register new ports required for that connection")
653 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
655 if (!ignore_toggle) {
658 _route.use_output_connection (*c, this);
661 catch (AudioEngine::PortRegistrationFailure& err) {
662 error << _("could not register new ports required for that connection")
669 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
671 using namespace Menu_Helpers;
673 if (dynamic_cast<InputConnection *> (c) == 0) {
677 MenuList& citems = input_menu.items();
679 if (c->nports() == _route.n_inputs()) {
681 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
683 ARDOUR::Connection *current = _route.input_connection();
686 ignore_toggle = true;
687 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
688 ignore_toggle = false;
694 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
696 using namespace Menu_Helpers;
698 if (dynamic_cast<OutputConnection *> (c) == 0) {
702 if (c->nports() == _route.n_outputs()) {
704 MenuList& citems = output_menu.items();
705 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
707 ARDOUR::Connection *current = _route.output_connection();
710 ignore_toggle = true;
711 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
712 ignore_toggle = false;
718 MixerStrip::select_stream_input ()
720 using namespace Menu_Helpers;
722 Menu *stream_menu = manage (new Menu);
723 MenuList& items = stream_menu->items();
724 stream_menu->set_name ("ArdourContextMenu");
726 Session::DiskStreamList streams = _session.disk_streams();
728 for (Session::DiskStreamList::iterator i = streams.begin(); i != streams.end(); ++i) {
730 if (!(*i)->hidden()) {
732 items.push_back (CheckMenuElem ((*i)->name(), bind (mem_fun(*this, &MixerStrip::stream_input_chosen), *i)));
734 if (get_diskstream() == *i) {
735 ignore_toggle = true;
736 static_cast<CheckMenuItem *> (&items.back())->set_active (true);
737 ignore_toggle = false;
742 stream_menu->popup (1, 0);
746 MixerStrip::stream_input_chosen (DiskStream *stream)
748 if (is_audio_track()) {
749 audio_track()->set_diskstream (*stream, this);
754 MixerStrip::update_diskstream_display ()
756 if (is_audio_track()) {
760 update_input_display ();
762 if (input_selector) {
763 input_selector->hide_all ();
772 update_input_display ();
773 show_passthru_color ();
778 MixerStrip::connect_to_pan ()
780 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
782 panstate_connection.disconnect ();
783 panstyle_connection.disconnect ();
785 if (!_route.panner().empty()) {
786 StreamPanner* sp = _route.panner().front();
788 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_state_changed));
789 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_style_changed));
792 panners.pan_changed (this);
796 MixerStrip::update_input_display ()
798 ARDOUR::Connection *c;
800 if ((c = _route.input_connection()) != 0) {
801 input_label.set_text (c->name());
805 input_label.set_text (_("INPUT"));
808 input_label.set_text (_("IN"));
813 panners.setup_pan ();
817 MixerStrip::update_output_display ()
819 ARDOUR::Connection *c;
821 if ((c = _route.output_connection()) != 0) {
822 output_label.set_text (c->name());
826 output_label.set_text (_("OUTPUT"));
829 output_label.set_text (_("OUT"));
835 panners.setup_pan ();
839 MixerStrip::update ()
841 gpm.update_meters ();
845 MixerStrip::fast_update ()
847 if (_session.meter_falloff() > 0.0f) {
848 gpm.update_meters_falloff ();
853 MixerStrip::gain_automation_state_button_event (GdkEventButton *ev)
855 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
859 switch (ev->button) {
861 switch (ev->button) {
863 gain_astate_menu.popup (1, ev->time);
874 MixerStrip::gain_automation_style_button_event (GdkEventButton *ev)
876 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
880 switch (ev->button) {
882 gain_astyle_menu.popup (1, ev->time);
891 MixerStrip::pan_automation_state_button_event (GdkEventButton *ev)
893 using namespace Menu_Helpers;
895 if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
899 switch (ev->button) {
901 pan_astate_menu.popup (1, ev->time);
911 MixerStrip::pan_automation_style_button_event (GdkEventButton *ev)
913 switch (ev->button) {
915 pan_astyle_menu.popup (1, ev->time);
924 MixerStrip::astate_string (AutoState state)
926 return _astate_string (state, false);
930 MixerStrip::short_astate_string (AutoState state)
932 return _astate_string (state, true);
936 MixerStrip::_astate_string (AutoState state, bool shrt)
942 sstr = (shrt ? "--" : _("off"));
945 sstr = (shrt ? "P" : _("aplay"));
948 sstr = (shrt ? "T" : _("touch"));
951 sstr = (shrt ? "W" : _("awrite"));
959 MixerStrip::astyle_string (AutoStyle style)
961 return _astyle_string (style, false);
965 MixerStrip::short_astyle_string (AutoStyle style)
967 return _astyle_string (style, true);
971 MixerStrip::_astyle_string (AutoStyle style, bool shrt)
976 /* XXX it might different in different languages */
978 return (shrt ? _("abs") : _("abs"));
983 MixerStrip::diskstream_changed (void *src)
985 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
989 MixerStrip::gain_automation_style_changed ()
993 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
996 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
1002 MixerStrip::gain_automation_state_changed ()
1004 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::gain_automation_state_changed));
1010 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
1013 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
1017 x = (_route.gain_automation_state() != Off);
1019 if (gain_automation_state_button.get_active() != x) {
1020 ignore_toggle = true;
1021 gain_automation_state_button.set_active (x);
1022 ignore_toggle = false;
1025 gpm.update_gain_sensitive ();
1027 /* start watching automation so that things move */
1029 gain_watching.disconnect();
1032 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (gpm, &GainMeter::effective_gain_display));
1037 MixerStrip::pan_automation_style_changed ()
1039 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_style_changed));
1043 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
1046 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
1052 MixerStrip::pan_automation_state_changed ()
1054 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_state_changed));
1060 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
1063 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
1067 /* when creating a new session, we get to create busses (and
1068 sometimes tracks) with no outputs by the time they get
1072 if (_route.panner().empty()) {
1076 x = (_route.panner().front()->automation().automation_state() != Off);
1078 if (pan_automation_state_button.get_active() != x) {
1079 ignore_toggle = true;
1080 pan_automation_state_button.set_active (x);
1081 ignore_toggle = false;
1084 panners.update_pan_sensitive ();
1086 /* start watching automation so that things move */
1088 pan_watching.disconnect();
1091 pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (panners, &PannerUI::effective_pan_display));
1096 MixerStrip::input_changed (IOChange change, void *src)
1098 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1102 MixerStrip::output_changed (IOChange change, void *src)
1104 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1108 MixerStrip::comment_button_clicked ()
1110 if (comment_window == 0) {
1111 setup_comment_editor ();
1114 if (comment_window->is_visible()) {
1115 comment_window->hide ();
1117 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1118 comment_window->show_all ();
1123 MixerStrip::setup_comment_editor ()
1125 comment_window = new Window (WINDOW_TOPLEVEL);
1128 str = _route.name();
1129 str += _(": comment editor");
1130 comment_window->set_title (str);
1132 comment_area.set_name ("MixerTrackCommentArea");
1133 comment_area.set_editable (true);
1134 comment_area.signal_focus_in_event().connect (ptr_fun (ARDOUR_UI::generic_focus_in_event));
1135 comment_area.signal_focus_out_event().connect (ptr_fun (ARDOUR_UI::generic_focus_out_event));
1136 comment_area.changed.connect (mem_fun(*this, &MixerStrip::comment_edited));
1138 // comment_area.signal_button_release_event().connect_after (ptr_fun (do_not_propagate));
1139 comment_area.show ();
1141 comment_window->add (comment_area);
1142 comment_window->signal_delete_event().connect (bind (ptr_fun (just_hide_it), comment_window));
1146 MixerStrip::comment_changed (void *src)
1148 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1151 ignore_comment_edit = true;
1152 // comment_area.freeze ();
1153 //comment_area.get_buffer()->delete_text (0, -1);
1154 //comment_area.set_point (0);
1155 comment_area.get_buffer()->set_text (_route.comment());
1156 // comment_area.thaw ();
1157 ignore_comment_edit = false;
1162 MixerStrip::comment_edited ()
1164 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::comment_edited));
1166 if (!ignore_comment_edit) {
1167 string str = comment_area.get_buffer()->get_text();
1168 _route.set_comment (str, this);
1169 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1170 str.empty() ? _("click to add/edit comments") : str);
1175 MixerStrip::set_mix_group (RouteGroup *rg)
1178 _route.set_mix_group (rg, this);
1184 MixerStrip::add_mix_group_to_menu (RouteGroup *rg)
1186 using namespace Menu_Helpers;
1188 MenuList& items = group_menu->items();
1189 items.push_back (MenuElem (rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1193 MixerStrip::select_mix_group (GdkEventButton *ev)
1195 using namespace Menu_Helpers;
1197 group_menu = new Menu;
1198 group_menu->set_name ("ArdourContextMenu");
1199 MenuList& items = group_menu->items();
1201 items.push_back (MenuElem (_("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1202 _session.foreach_mix_group (this, &MixerStrip::add_mix_group_to_menu);
1204 group_menu->popup (ev->button, 0);
1205 return stop_signal (group_button, "button_press_event");
1209 MixerStrip::mix_group_changed (void *ignored)
1211 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1213 RouteGroup *rg = _route.mix_group();
1216 group_label.set_text (rg->name());
1220 group_label.set_text (_("no group"));
1223 group_label.set_text (_("~G"));
1230 MixerStrip::polarity_toggled ()
1234 if ((x = polarity_button.get_active()) != _route.phase_invert()) {
1235 _route.set_phase_invert (x, this);
1241 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1243 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1245 if (what_changed == "color") {
1246 if (set_color_from_route () == 0) {
1247 show_route_color ();
1253 MixerStrip::show_route_color ()
1255 Glib::RefPtr<Gtk::Style> style;
1257 name_button.ensure_style ();
1258 style = name_button.get_style()->copy();
1259 style->set_bg (Gtk::STATE_NORMAL, color());
1260 name_button.set_style (style);
1261 style->unreference();
1263 route_active_changed ();
1267 MixerStrip::show_passthru_color ()
1269 route_active_changed ();
1273 MixerStrip::build_route_ops_menu ()
1275 using namespace Menu_Helpers;
1277 route_ops_menu = new Menu;
1278 route_ops_menu->set_name ("ArdourContextMenu");
1280 MenuList& items = route_ops_menu->items();
1282 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1283 items.push_back (SeparatorElem());
1284 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
1285 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1286 route_active_menu_item->set_active (_route.active());
1288 items.push_back (SeparatorElem());
1289 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1293 MixerStrip::name_button_button_release (GdkEventButton* ev)
1295 if (ev->button == 3) {
1296 list_route_operations ();
1302 MixerStrip::list_route_operations ()
1304 if (route_ops_menu == 0) {
1305 build_route_ops_menu ();
1308 route_ops_menu->popup (1, 0);
1313 MixerStrip::speed_adjustment_changed ()
1315 /* since there is a usable speed adjustment, there has to be a diskstream */
1316 if (!ignore_speed_adjustment) {
1317 get_diskstream()->set_speed (speed_adjustment.get_value());
1322 MixerStrip::speed_changed ()
1324 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1328 MixerStrip::update_speed_display ()
1332 val = get_diskstream()->speed();
1335 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1337 speed_spinner.set_name ("MixerStripSpeedBase");
1340 if (speed_adjustment.get_value() != val) {
1341 ignore_speed_adjustment = true;
1342 speed_adjustment.set_value (val);
1343 ignore_speed_adjustment = false;
1349 MixerStrip::set_selected (bool yn)
1351 AxisView::set_selected (yn);
1353 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1354 global_frame.set_name ("MixerStripSelectedFrame");
1356 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1357 global_frame.set_name ("MixerStripFrame");
1359 global_frame.queue_draw ();
1363 MixerStrip::name_changed (void *src)
1367 RouteUI::name_changed (src);
1370 name_label.set_text (short_version (_route.name(), 5));
1376 MixerStrip::width_clicked ()
1389 MixerStrip::hide_clicked ()
1392 Hiding(); /* EMIT_SIGNAL */
1394 _mixer.unselect_strip_in_display (this);
1399 MixerStrip::set_embedded (bool yn)
1405 MixerStrip::map_frozen ()
1407 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1409 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
1412 switch (at->freeze_state()) {
1413 case AudioTrack::Frozen:
1414 pre_redirect_box.set_sensitive (false);
1415 post_redirect_box.set_sensitive (false);
1416 speed_spinner.set_sensitive (false);
1419 pre_redirect_box.set_sensitive (true);
1420 post_redirect_box.set_sensitive (true);
1421 speed_spinner.set_sensitive (true);
1425 _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1429 MixerStrip::hide_redirect_editor (Redirect* redirect)
1431 void* gui = redirect->get_gui ();
1434 static_cast<Gtk::Widget*>(gui)->hide ();
1439 MixerStrip::route_active_changed ()
1441 RouteUI::route_active_changed ();
1443 if (is_audio_track()) {
1444 if (_route.active()) {
1445 set_name ("AudioTrackStripBase");
1446 gpm.set_meter_strip_name ("AudioTrackStripBase");
1448 set_name ("AudioTrackStripBaseInactive");
1449 gpm.set_meter_strip_name ("AudioTrackStripBaseInactive");
1451 gpm.set_fader_name ("AudioTrackFader");
1453 if (_route.active()) {
1454 set_name ("AudioBusStripBase");
1455 gpm.set_meter_strip_name ("AudioBusStripBase");
1457 set_name ("AudioBusStripBaseInactive");
1458 gpm.set_meter_strip_name ("AudioBusStripBaseInactive");
1460 gpm.set_fader_name ("AudioBusFader");