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.
23 #include <sigc++/bind.h>
25 #include <pbd/convert.h>
26 #include <pbd/enumwriter.h>
28 #include <gtkmm2ext/gtk_ui.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/choice.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/doi.h>
33 #include <gtkmm2ext/slider_controller.h>
34 #include <gtkmm2ext/bindable_button.h>
36 #include <ardour/ardour.h>
37 #include <ardour/session.h>
38 #include <ardour/audioengine.h>
39 #include <ardour/route.h>
40 #include <ardour/audio_track.h>
41 #include <ardour/audio_diskstream.h>
42 #include <ardour/panner.h>
43 #include <ardour/send.h>
44 #include <ardour/insert.h>
45 #include <ardour/profile.h>
46 #include <ardour/ladspa_plugin.h>
47 #include <ardour/connection.h>
48 #include <ardour/session_connection.h>
50 #include "ardour_ui.h"
51 #include "ardour_dialog.h"
52 #include "mixer_strip.h"
55 #include "public_editor.h"
57 #include "io_selector.h"
59 #include "gui_thread.h"
64 using namespace ARDOUR;
67 using namespace Gtkmm2ext;
70 int MixerStrip::scrollbar_height = 0;
72 #ifdef VARISPEED_IN_MIXER_STRIP
74 speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg)
76 float val = adj.get_value ();
81 snprintf (buf, 32, "%.3f", val);
86 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
88 RouteUI (sess, _("Mute"), _("Solo"), _("Record")),
90 _mixer_owned (in_mixer),
91 pre_redirect_box (PreFader, sess, mx.plugin_selector(), mx.selection(), in_mixer),
92 post_redirect_box (PostFader, sess, mx.plugin_selector(), mx.selection(), in_mixer),
96 middle_button_table (1, 2),
97 bottom_button_table (1, 2),
98 meter_point_label (_("pre")),
99 comment_button (_("Comments")),
100 speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
101 speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
107 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer)
109 RouteUI (sess, _("Mute"), _("Solo"), _("Record")),
111 _mixer_owned (in_mixer),
112 pre_redirect_box (PreFader, sess, mx.plugin_selector(), mx.selection(), in_mixer),
113 post_redirect_box (PostFader, sess, mx.plugin_selector(), mx.selection(), in_mixer),
117 middle_button_table (1, 2),
118 bottom_button_table (1, 2),
119 meter_point_label (_("pre")),
120 comment_button (_("Comments")),
121 speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
122 speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
135 _marked_for_display = false;
137 ignore_comment_edit = false;
138 ignore_toggle = false;
139 ignore_speed_adjustment = false;
144 width_button.add (*(manage (new Gtk::Image (::get_icon("strip_width")))));
145 hide_button.add (*(manage (new Gtk::Image (::get_icon("hide")))));
147 input_label.set_text (_("Input"));
148 input_button.add (input_label);
149 input_button.set_name ("MixerIOButton");
150 input_label.set_name ("MixerIOButtonLabel");
152 output_label.set_text (_("Output"));
153 output_button.add (output_label);
154 output_button.set_name ("MixerIOButton");
155 output_label.set_name ("MixerIOButtonLabel");
157 meter_point_button.add (meter_point_label);
158 meter_point_button.set_name ("MixerStripMeterPreButton");
159 meter_point_label.set_name ("MixerStripMeterPreButton");
161 /* TRANSLATORS: this string should be longest of the strings
162 used to describe meter points. In english, it's "input".
164 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
166 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
168 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
169 /* XXX what is this meant to do? */
170 //meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
172 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
174 mute_button->set_name ("MixerMuteButton");
175 solo_button->set_name ("MixerSoloButton");
177 button_table.set_homogeneous (true);
178 button_table.set_spacings (0);
180 button_table.attach (name_button, 0, 2, 0, 1);
181 button_table.attach (input_button, 0, 2, 1, 2);
183 middle_button_table.set_homogeneous (true);
184 middle_button_table.set_spacings (0);
185 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
186 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
188 bottom_button_table.set_col_spacings (0);
189 bottom_button_table.set_homogeneous (true);
190 bottom_button_table.attach (group_button, 0, 1, 0, 1);
192 name_button.add (name_label);
193 name_button.set_name ("MixerNameButton");
194 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
196 name_label.set_name ("MixerNameButtonLabel");
197 group_button.add (group_label);
198 group_button.set_name ("MixerGroupButton");
199 group_label.set_name ("MixerGroupButtonLabel");
201 comment_button.set_name ("MixerCommentButton");
203 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
205 global_vpacker.set_border_width (0);
206 global_vpacker.set_spacing (0);
208 VBox *whvbox = manage (new VBox);
210 width_button.set_name ("MixerWidthButton");
211 hide_button.set_name ("MixerHideButton");
212 top_event_box.set_name ("MixerTopEventBox");
214 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
215 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
217 width_hide_box.pack_start (width_button, false, true);
218 width_hide_box.pack_start (top_event_box, true, true);
219 width_hide_box.pack_end (hide_button, false, true);
220 Gtk::Alignment *gain_meter_alignment = Gtk::manage(new Gtk::Alignment());
221 gain_meter_alignment->set_padding(0, 4, 0, 0);
222 gain_meter_alignment->add(gpm);
224 whvbox->pack_start (width_hide_box, true, true);
226 global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
227 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
228 global_vpacker.pack_start (pre_redirect_box, true, true);
229 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
230 global_vpacker.pack_start (*gain_meter_alignment,Gtk::PACK_SHRINK);
231 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
232 global_vpacker.pack_start (post_redirect_box, true, true);
233 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
235 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
237 global_frame.add (global_vpacker);
238 global_frame.set_shadow_type (Gtk::SHADOW_IN);
239 global_frame.set_name ("BaseFrame");
243 /* force setting of visible selected status */
246 set_selected (false);
251 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
252 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
254 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
255 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
257 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
258 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
259 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
260 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
262 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
266 rec_enable_button->set_name ("MixerRecordEnableButton");
267 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
268 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
270 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
271 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
275 /* start off as a passthru strip. we'll correct this, if necessary,
276 in update_diskstream_display().
279 set_name ("AudioTrackStripBase");
281 add_events (Gdk::BUTTON_RELEASE_MASK);
284 MixerStrip::~MixerStrip ()
286 GoingAway(); /* EMIT_SIGNAL */
288 if (input_selector) {
289 delete input_selector;
292 if (output_selector) {
293 delete output_selector;
298 MixerStrip::set_route (boost::shared_ptr<Route> rt)
300 if (rec_enable_button->get_parent()) {
301 button_table.remove (*rec_enable_button);
304 #ifdef VARISPEED_IN_MIXER_STRIP
305 if (speed_frame->get_parent()) {
306 button_table.remove (*speed_frame);
310 RouteUI::set_route (rt);
312 if (input_selector) {
313 delete input_selector;
317 if (output_selector) {
318 delete output_selector;
324 pre_redirect_box.set_route (rt);
325 post_redirect_box.set_route (rt);
327 if (set_color_from_route()) {
328 set_color (unique_random_color());
331 if (_mixer_owned && (route()->master() || route()->control())) {
333 if (scrollbar_height == 0) {
334 HScrollbar scrollbar;
335 Gtk::Requisition requisition(scrollbar.size_request ());
336 scrollbar_height = requisition.height;
339 EventBox* spacer = manage (new EventBox);
340 spacer->set_size_request (-1, scrollbar_height);
341 global_vpacker.pack_start (*spacer, false, false);
344 if (is_audio_track()) {
346 boost::shared_ptr<AudioTrack> at = audio_track();
348 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
350 #ifdef VARISPEED_IN_MIXER_STRIP
351 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
353 speed_frame.set_name ("BaseFrame");
354 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
355 speed_frame.add (speed_spinner);
357 speed_spinner.set_print_func (speed_printer, 0);
359 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("Varispeed"));
361 button_table.attach (speed_frame, 0, 2, 5, 6);
362 #endif /* VARISPEED_IN_MIXER_STRIP */
364 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
365 rec_enable_button->show();
368 if (_route->phase_invert()) {
369 name_label.set_text (X_("Ø ") + name_label.get_text());
371 name_label.set_text (_route->name());
374 switch (_route->meter_point()) {
376 meter_point_label.set_text (_("input"));
380 meter_point_label.set_text (_("pre"));
384 meter_point_label.set_text (_("post"));
388 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
389 _("Click to Add/Edit Comments"):
392 connections.push_back (_route->meter_change.connect (mem_fun(*this, &MixerStrip::meter_changed)));
393 connections.push_back (_route->input_changed.connect (mem_fun(*this, &MixerStrip::input_changed)));
394 connections.push_back (_route->output_changed.connect (mem_fun(*this, &MixerStrip::output_changed)));
395 connections.push_back (_route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)));
396 connections.push_back (_route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)));
397 connections.push_back (_route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)));
398 connections.push_back (_route->mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed)));
399 connections.push_back (_route->panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan)));
401 if (is_audio_track()) {
402 connections.push_back (audio_track()->DiskstreamChanged.connect (mem_fun(*this, &MixerStrip::diskstream_changed)));
403 connections.push_back (get_diskstream()->SpeedChanged.connect (mem_fun(*this, &MixerStrip::speed_changed)));
406 connections.push_back (_route->name_changed.connect (mem_fun(*this, &RouteUI::name_changed)));
407 connections.push_back (_route->comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed)));
408 connections.push_back (_route->gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed)));
410 set_stuff_from_route ();
412 /* now force an update of all the various elements */
414 pre_redirect_box.update();
415 post_redirect_box.update();
420 mix_group_changed (0);
424 panners.setup_pan ();
426 if (is_audio_track()) {
430 update_diskstream_display ();
431 update_input_display ();
432 update_output_display ();
436 MixerStrip::set_stuff_from_route ()
442 /* if width is not set, it will be set by the MixerUI or editor */
444 if ((prop = xml_node->property ("strip_width")) != 0) {
445 set_width (Width (string_2_enum (prop->value(), _width)), this);
448 if ((prop = xml_node->property ("shown_mixer")) != 0) {
449 if (prop->value() == "no") {
450 _marked_for_display = false;
452 _marked_for_display = true;
455 /* backwards compatibility */
456 _marked_for_display = true;
461 MixerStrip::set_width (Width w, void* owner)
463 /* always set the gpm width again, things may be hidden */
466 panners.set_width (w);
467 pre_redirect_box.set_width (w);
468 post_redirect_box.set_width (w);
470 _width_owner = owner;
476 if (_width_owner == this) {
477 xml_node->add_property ("strip_width", enum_2_string (_width));
483 if (rec_enable_button) {
484 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Record"));
486 ((Gtk::Label*)mute_button->get_child())->set_text (_("Mute"));
487 ((Gtk::Label*)solo_button->get_child())->set_text (_("Solo"));
489 if (_route->comment() == "") {
490 comment_button.unset_bg (STATE_NORMAL);
491 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
493 comment_button.modify_bg (STATE_NORMAL, color());
494 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
497 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.astyle_string(_route->gain_automation_curve().automation_style()));
498 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.astate_string(_route->gain_automation_curve().automation_state()));
499 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.astyle_string(_route->panner().automation_style()));
500 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.astate_string(_route->panner().automation_state()));
501 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
502 set_size_request (-1, -1);
509 if (rec_enable_button) {
510 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec"));
512 ((Gtk::Label*)mute_button->get_child())->set_text (_("M"));
513 ((Gtk::Label*)solo_button->get_child())->set_text (_("S"));
515 if (_route->comment() == "") {
516 comment_button.unset_bg (STATE_NORMAL);
517 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
519 comment_button.modify_bg (STATE_NORMAL, color());
520 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
523 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.short_astyle_string(_route->gain_automation_curve().automation_style()));
524 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.short_astate_string(_route->gain_automation_curve().automation_state()));
525 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.short_astyle_string(_route->panner().automation_style()));
526 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.short_astate_string(_route->panner().automation_state()));
527 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
528 set_size_request (max (50, gpm.get_gm_width()), -1);
531 update_input_display ();
532 update_output_display ();
533 mix_group_changed (0);
538 MixerStrip::set_packed (bool yn)
545 xml_node->add_property ("shown_mixer", "yes");
547 xml_node->add_property ("shown_mixer", "no");
553 MixerStrip::output_press (GdkEventButton *ev)
555 using namespace Menu_Helpers;
556 if (!_session.engine().connected()) {
557 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
562 MenuList& citems = output_menu.items();
563 switch (ev->button) {
566 output_menu.set_name ("ArdourContextMenu");
569 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
570 citems.push_back (SeparatorElem());
571 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
572 citems.push_back (SeparatorElem());
574 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
576 output_menu.popup (1, ev->time);
586 MixerStrip::edit_output_configuration ()
588 if (output_selector == 0) {
589 output_selector = new IOSelectorWindow (_session, _route, false);
592 if (output_selector->is_visible()) {
593 output_selector->get_toplevel()->get_window()->raise();
595 output_selector->show_all ();
600 MixerStrip::edit_input_configuration ()
602 if (input_selector == 0) {
603 input_selector = new IOSelectorWindow (_session, _route, true);
606 if (input_selector->is_visible()) {
607 input_selector->get_toplevel()->get_window()->raise();
609 input_selector->show_all ();
614 MixerStrip::input_press (GdkEventButton *ev)
616 using namespace Menu_Helpers;
618 MenuList& citems = input_menu.items();
619 input_menu.set_name ("ArdourContextMenu");
622 if (!_session.engine().connected()) {
623 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
628 switch (ev->button) {
631 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
632 citems.push_back (SeparatorElem());
633 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
634 citems.push_back (SeparatorElem());
636 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
638 input_menu.popup (1, ev->time);
648 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
650 if (!ignore_toggle) {
653 _route->use_input_connection (*c, this);
656 catch (AudioEngine::PortRegistrationFailure& err) {
657 error << _("could not register new ports required for that connection")
664 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
666 if (!ignore_toggle) {
669 _route->use_output_connection (*c, this);
672 catch (AudioEngine::PortRegistrationFailure& err) {
673 error << _("could not register new ports required for that connection")
680 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
682 using namespace Menu_Helpers;
684 if (dynamic_cast<InputConnection *> (c) == 0) {
688 MenuList& citems = input_menu.items();
690 if (c->nports() == _route->n_inputs()) {
692 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
694 ARDOUR::Connection *current = _route->input_connection();
697 ignore_toggle = true;
698 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
699 ignore_toggle = false;
705 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
707 using namespace Menu_Helpers;
709 if (dynamic_cast<OutputConnection *> (c) == 0) {
713 if (c->nports() == _route->n_outputs()) {
715 MenuList& citems = output_menu.items();
716 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
718 ARDOUR::Connection *current = _route->output_connection();
721 ignore_toggle = true;
722 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
723 ignore_toggle = false;
729 MixerStrip::update_diskstream_display ()
732 update_input_display ();
734 if (is_audio_track()) {
736 if (input_selector) {
737 input_selector->hide_all ();
744 show_passthru_color ();
749 MixerStrip::connect_to_pan ()
751 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
753 panstate_connection.disconnect ();
754 panstyle_connection.disconnect ();
756 if (!_route->panner().empty()) {
757 StreamPanner* sp = _route->panner().front();
759 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
760 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
763 panners.pan_changed (this);
767 MixerStrip::update_input_display ()
769 ARDOUR::Connection *c;
771 if ((c = _route->input_connection()) != 0) {
772 input_label.set_text (c->name());
776 input_label.set_text (_(" Input"));
779 input_label.set_text (_("I"));
783 panners.setup_pan ();
787 MixerStrip::update_output_display ()
789 ARDOUR::Connection *c;
791 if ((c = _route->output_connection()) != 0) {
792 output_label.set_text (c->name());
796 output_label.set_text (_("Output"));
799 output_label.set_text (_("O"));
805 panners.setup_pan ();
809 MixerStrip::fast_update ()
811 gpm.update_meters ();
815 MixerStrip::diskstream_changed ()
817 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
821 MixerStrip::input_changed (IOChange change, void *src)
823 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
824 set_width(_width, this);
828 MixerStrip::output_changed (IOChange change, void *src)
830 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
831 set_width(_width, this);
836 MixerStrip::comment_editor_done_editing()
838 string str = comment_area->get_buffer()->get_text();
839 if (_route->comment() != str) {
840 _route->set_comment (str, this);
846 comment_button.modify_bg (STATE_NORMAL, color());
847 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
849 comment_button.unset_bg (STATE_NORMAL);
850 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
856 comment_button.modify_bg (STATE_NORMAL, color());
857 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
859 comment_button.unset_bg (STATE_NORMAL);
860 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
865 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
866 str.empty() ? _("Click to Add/Edit Comments") : str);
872 MixerStrip::comment_button_clicked ()
874 if (comment_window == 0) {
875 setup_comment_editor ();
878 int x, y, cw_width, cw_height;
880 if (comment_window->is_visible()) {
881 comment_window->hide ();
885 comment_window->get_size (cw_width, cw_height);
886 comment_window->get_position(x, y);
887 comment_window->move(x, y - (cw_height / 2) - 45);
889 half the dialog height minus the comments button height
890 with some window decoration fudge thrown in.
893 comment_window->show();
894 comment_window->present();
898 MixerStrip::setup_comment_editor ()
901 title = _route->name();
902 title += _(": comment editor");
904 comment_window = new ArdourDialog (title, false);
905 comment_window->set_position (Gtk::WIN_POS_MOUSE);
906 comment_window->set_skip_taskbar_hint (true);
907 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
909 comment_area = manage (new TextView());
910 comment_area->set_name ("MixerTrackCommentArea");
911 comment_area->set_size_request (110, 178);
912 comment_area->set_wrap_mode (WRAP_WORD);
913 comment_area->set_editable (true);
914 comment_area->get_buffer()->set_text (_route->comment());
915 comment_area->show ();
917 comment_window->get_vbox()->pack_start (*comment_area);
918 comment_window->get_action_area()->hide();
922 MixerStrip::comment_changed (void *src)
924 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
927 ignore_comment_edit = true;
929 comment_area->get_buffer()->set_text (_route->comment());
931 ignore_comment_edit = false;
936 MixerStrip::set_mix_group (RouteGroup *rg)
938 _route->set_mix_group (rg, this);
942 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
944 using namespace Menu_Helpers;
946 MenuList& items = group_menu->items();
948 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
950 if (_route->mix_group() == rg) {
951 static_cast<RadioMenuItem*>(&items.back())->set_active ();
956 MixerStrip::select_mix_group (GdkEventButton *ev)
958 using namespace Menu_Helpers;
960 if (group_menu == 0) {
961 group_menu = new Menu;
963 group_menu->set_name ("ArdourContextMenu");
964 MenuList& items = group_menu->items();
965 RadioMenuItem::Group group;
967 switch (ev->button) {
971 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
973 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
975 group_menu->popup (1, ev->time);
986 MixerStrip::mix_group_changed (void *ignored)
988 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
990 RouteGroup *rg = _route->mix_group();
993 group_label.set_text (rg->name());
997 group_label.set_text (_("Grp"));
1000 group_label.set_text (_("~G"));
1008 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1010 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1012 if (what_changed == "color") {
1013 if (set_color_from_route () == 0) {
1014 show_route_color ();
1020 MixerStrip::show_route_color ()
1022 name_button.modify_bg (STATE_NORMAL, color());
1023 top_event_box.modify_bg (STATE_NORMAL, color());
1024 route_active_changed ();
1028 MixerStrip::show_passthru_color ()
1030 route_active_changed ();
1034 MixerStrip::build_route_ops_menu ()
1036 using namespace Menu_Helpers;
1037 route_ops_menu = manage (new Menu);
1038 route_ops_menu->set_name ("ArdourContextMenu");
1040 MenuList& items = route_ops_menu->items();
1042 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1043 items.push_back (SeparatorElem());
1044 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1045 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1046 route_active_menu_item->set_active (_route->active());
1047 items.push_back (SeparatorElem());
1048 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1049 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1050 polarity_menu_item->set_active (_route->phase_invert());
1051 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1052 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1053 denormal_menu_item->set_active (_route->denormal_protection());
1055 build_remote_control_menu ();
1057 items.push_back (SeparatorElem());
1058 if (!Profile->get_sae()) {
1059 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1062 items.push_back (SeparatorElem());
1063 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1067 MixerStrip::name_button_button_press (GdkEventButton* ev)
1069 if (ev->button == 1) {
1070 list_route_operations ();
1072 Menu_Helpers::MenuList& items = route_ops_menu->items();
1073 /* do not allow rename if the track is record-enabled */
1074 static_cast<MenuItem*> (&items.front())->set_sensitive (!_route->record_enabled());
1076 route_ops_menu->popup (1, ev->time);
1082 MixerStrip::list_route_operations ()
1084 if (route_ops_menu == 0) {
1085 build_route_ops_menu ();
1088 refresh_remote_control_menu();
1093 MixerStrip::speed_adjustment_changed ()
1095 /* since there is a usable speed adjustment, there has to be a diskstream */
1096 if (!ignore_speed_adjustment) {
1097 get_diskstream()->set_speed (speed_adjustment.get_value());
1102 MixerStrip::speed_changed ()
1104 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1108 MixerStrip::update_speed_display ()
1112 val = get_diskstream()->speed();
1115 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1117 speed_spinner.set_name ("MixerStripSpeedBase");
1120 if (speed_adjustment.get_value() != val) {
1121 ignore_speed_adjustment = true;
1122 speed_adjustment.set_value (val);
1123 ignore_speed_adjustment = false;
1129 MixerStrip::set_selected (bool yn)
1131 AxisView::set_selected (yn);
1133 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1134 global_frame.set_name ("MixerStripSelectedFrame");
1136 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1137 global_frame.set_name ("MixerStripFrame");
1139 global_frame.queue_draw ();
1143 MixerStrip::name_changed (void *src)
1147 RouteUI::name_changed (src);
1150 name_label.set_text (PBD::short_version (_route->name(), 5));
1153 if (_route->phase_invert()) {
1154 name_label.set_text (X_("Ø ") + name_label.get_text());
1159 MixerStrip::width_clicked ()
1163 set_width (Narrow, this);
1166 set_width (Wide, this);
1172 MixerStrip::hide_clicked ()
1174 // LAME fix to reset the button status for when it is redisplayed (part 1)
1175 hide_button.set_sensitive(false);
1178 Hiding(); /* EMIT_SIGNAL */
1180 _mixer.hide_strip (this);
1184 hide_button.set_sensitive(true);
1188 MixerStrip::set_embedded (bool yn)
1194 MixerStrip::map_frozen ()
1196 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1198 boost::shared_ptr<AudioTrack> at = audio_track();
1201 switch (at->freeze_state()) {
1202 case AudioTrack::Frozen:
1203 pre_redirect_box.set_sensitive (false);
1204 post_redirect_box.set_sensitive (false);
1205 speed_spinner.set_sensitive (false);
1208 pre_redirect_box.set_sensitive (true);
1209 post_redirect_box.set_sensitive (true);
1210 speed_spinner.set_sensitive (true);
1211 // XXX need some way, maybe, to retoggle redirect editors
1216 hide_redirect_editors ();
1220 MixerStrip::hide_redirect_editors ()
1222 _route->foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1226 MixerStrip::hide_redirect_editor (boost::shared_ptr<Redirect> redirect)
1228 void* gui = redirect->get_gui ();
1231 static_cast<Gtk::Widget*>(gui)->hide ();
1236 MixerStrip::route_active_changed ()
1238 RouteUI::route_active_changed ();
1240 if (is_audio_track()) {
1241 if (_route->active()) {
1242 set_name ("AudioTrackStripBase");
1243 gpm.set_meter_strip_name ("AudioTrackMetrics");
1245 set_name ("AudioTrackStripBaseInactive");
1246 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1248 gpm.set_fader_name ("AudioTrackFader");
1249 } else { // FIXME: assumed audio bus
1250 if (_route->active()) {
1251 set_name ("AudioBusStripBase");
1252 gpm.set_meter_strip_name ("AudioBusMetrics");
1254 set_name ("AudioBusStripBaseInactive");
1255 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1257 gpm.set_fader_name ("AudioBusFader");
1262 MixerStrip::mix_group() const
1264 return _route->mix_group();
1268 MixerStrip::engine_stopped ()
1273 MixerStrip::engine_running ()
1278 MixerStrip::meter_changed (void *src)
1281 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1283 switch (_route->meter_point()) {
1285 meter_point_label.set_text (_("input"));
1289 meter_point_label.set_text (_("pre"));
1292 case MeterPostFader:
1293 meter_point_label.set_text (_("post"));
1297 gpm.setup_meters ();
1298 // reset peak when meter point changes
1299 gpm.reset_peak_display();
1300 set_width (_width, this);