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));
482 set_size_request (-1, -1);
484 if (rec_enable_button) {
485 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Record"));
487 ((Gtk::Label*)mute_button->get_child())->set_text (_("Mute"));
488 ((Gtk::Label*)solo_button->get_child())->set_text (_("Solo"));
490 if (_route->comment() == "") {
491 comment_button.unset_bg (STATE_NORMAL);
492 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
494 comment_button.modify_bg (STATE_NORMAL, color());
495 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
498 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.astyle_string(_route->gain_automation_curve().automation_style()));
499 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.astate_string(_route->gain_automation_curve().automation_state()));
500 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.astyle_string(_route->panner().automation_style()));
501 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.astate_string(_route->panner().automation_state()));
502 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
506 if (rec_enable_button) {
507 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec"));
509 ((Gtk::Label*)mute_button->get_child())->set_text (_("M"));
510 ((Gtk::Label*)solo_button->get_child())->set_text (_("S"));
512 if (_route->comment() == "") {
513 comment_button.unset_bg (STATE_NORMAL);
514 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
516 comment_button.modify_bg (STATE_NORMAL, color());
517 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
520 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (gpm.short_astyle_string(_route->gain_automation_curve().automation_style()));
521 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (gpm.short_astate_string(_route->gain_automation_curve().automation_state()));
522 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.short_astyle_string(_route->panner().automation_style()));
523 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.short_astate_string(_route->panner().automation_state()));
524 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
525 set_size_request (max (50, gpm.get_gm_width()), -1);
529 update_input_display ();
530 update_output_display ();
531 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;
555 if (!_session.engine().connected()) {
556 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
561 MenuList& citems = output_menu.items();
562 switch (ev->button) {
565 output_menu.set_name ("ArdourContextMenu");
568 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
569 citems.push_back (SeparatorElem());
570 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
571 citems.push_back (SeparatorElem());
573 _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
575 output_menu.popup (1, ev->time);
585 MixerStrip::edit_output_configuration ()
587 if (output_selector == 0) {
588 output_selector = new IOSelectorWindow (_session, _route, false);
591 if (output_selector->is_visible()) {
592 output_selector->get_toplevel()->get_window()->raise();
594 output_selector->show_all ();
599 MixerStrip::edit_input_configuration ()
601 if (input_selector == 0) {
602 input_selector = new IOSelectorWindow (_session, _route, true);
605 if (input_selector->is_visible()) {
606 input_selector->get_toplevel()->get_window()->raise();
608 input_selector->show_all ();
613 MixerStrip::input_press (GdkEventButton *ev)
615 using namespace Menu_Helpers;
617 MenuList& citems = input_menu.items();
618 input_menu.set_name ("ArdourContextMenu");
621 if (!_session.engine().connected()) {
622 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
627 switch (ev->button) {
630 citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
631 citems.push_back (SeparatorElem());
632 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
633 citems.push_back (SeparatorElem());
635 _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
637 input_menu.popup (1, ev->time);
647 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
649 if (!ignore_toggle) {
652 _route->use_input_connection (*c, this);
655 catch (AudioEngine::PortRegistrationFailure& err) {
656 error << _("could not register new ports required for that connection")
663 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
665 if (!ignore_toggle) {
668 _route->use_output_connection (*c, this);
671 catch (AudioEngine::PortRegistrationFailure& err) {
672 error << _("could not register new ports required for that connection")
679 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
681 using namespace Menu_Helpers;
683 if (dynamic_cast<InputConnection *> (c) == 0) {
687 MenuList& citems = input_menu.items();
689 if (c->nports() == _route->n_inputs()) {
691 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
693 ARDOUR::Connection *current = _route->input_connection();
696 ignore_toggle = true;
697 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
698 ignore_toggle = false;
704 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
706 using namespace Menu_Helpers;
708 if (dynamic_cast<OutputConnection *> (c) == 0) {
712 if (c->nports() == _route->n_outputs()) {
714 MenuList& citems = output_menu.items();
715 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
717 ARDOUR::Connection *current = _route->output_connection();
720 ignore_toggle = true;
721 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
722 ignore_toggle = false;
728 MixerStrip::update_diskstream_display ()
731 update_input_display ();
733 if (is_audio_track()) {
735 if (input_selector) {
736 input_selector->hide_all ();
743 show_passthru_color ();
748 MixerStrip::connect_to_pan ()
750 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
752 panstate_connection.disconnect ();
753 panstyle_connection.disconnect ();
755 if (!_route->panner().empty()) {
756 StreamPanner* sp = _route->panner().front();
758 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
759 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
762 panners.pan_changed (this);
766 MixerStrip::update_input_display ()
768 ARDOUR::Connection *c;
770 if ((c = _route->input_connection()) != 0) {
771 input_label.set_text (c->name());
775 input_label.set_text (_(" Input"));
778 input_label.set_text (_("I"));
782 panners.setup_pan ();
786 MixerStrip::update_output_display ()
788 ARDOUR::Connection *c;
790 if ((c = _route->output_connection()) != 0) {
791 output_label.set_text (c->name());
795 output_label.set_text (_("Output"));
798 output_label.set_text (_("O"));
804 panners.setup_pan ();
808 MixerStrip::fast_update ()
810 gpm.update_meters ();
814 MixerStrip::diskstream_changed ()
816 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
820 MixerStrip::input_changed (IOChange change, void *src)
822 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
823 set_width(_width, this);
827 MixerStrip::output_changed (IOChange change, void *src)
829 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
830 set_width(_width, this);
835 MixerStrip::comment_editor_done_editing()
837 string str = comment_area->get_buffer()->get_text();
838 if (_route->comment() != str) {
839 _route->set_comment (str, this);
845 comment_button.modify_bg (STATE_NORMAL, color());
846 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
848 comment_button.unset_bg (STATE_NORMAL);
849 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
855 comment_button.modify_bg (STATE_NORMAL, color());
856 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
858 comment_button.unset_bg (STATE_NORMAL);
859 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
864 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
865 str.empty() ? _("Click to Add/Edit Comments") : str);
871 MixerStrip::comment_button_clicked ()
873 if (comment_window == 0) {
874 setup_comment_editor ();
877 int x, y, cw_width, cw_height;
879 if (comment_window->is_visible()) {
880 comment_window->hide ();
884 comment_window->get_size (cw_width, cw_height);
885 comment_window->get_position(x, y);
886 comment_window->move(x, y - (cw_height / 2) - 45);
888 half the dialog height minus the comments button height
889 with some window decoration fudge thrown in.
892 comment_window->show();
893 comment_window->present();
897 MixerStrip::setup_comment_editor ()
900 title = _route->name();
901 title += _(": comment editor");
903 comment_window = new ArdourDialog (title, false);
904 comment_window->set_position (Gtk::WIN_POS_MOUSE);
905 comment_window->set_skip_taskbar_hint (true);
906 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
908 comment_area = manage (new TextView());
909 comment_area->set_name ("MixerTrackCommentArea");
910 comment_area->set_size_request (110, 178);
911 comment_area->set_wrap_mode (WRAP_WORD);
912 comment_area->set_editable (true);
913 comment_area->get_buffer()->set_text (_route->comment());
914 comment_area->show ();
916 comment_window->get_vbox()->pack_start (*comment_area);
917 comment_window->get_action_area()->hide();
921 MixerStrip::comment_changed (void *src)
923 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
926 ignore_comment_edit = true;
928 comment_area->get_buffer()->set_text (_route->comment());
930 ignore_comment_edit = false;
935 MixerStrip::set_mix_group (RouteGroup *rg)
937 _route->set_mix_group (rg, this);
941 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
943 using namespace Menu_Helpers;
945 MenuList& items = group_menu->items();
947 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
949 if (_route->mix_group() == rg) {
950 static_cast<RadioMenuItem*>(&items.back())->set_active ();
955 MixerStrip::select_mix_group (GdkEventButton *ev)
957 using namespace Menu_Helpers;
959 if (group_menu == 0) {
960 group_menu = new Menu;
962 group_menu->set_name ("ArdourContextMenu");
963 MenuList& items = group_menu->items();
964 RadioMenuItem::Group group;
966 switch (ev->button) {
970 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
972 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
974 group_menu->popup (1, ev->time);
985 MixerStrip::mix_group_changed (void *ignored)
987 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
989 RouteGroup *rg = _route->mix_group();
992 group_label.set_text (rg->name());
996 group_label.set_text (_("Grp"));
999 group_label.set_text (_("~G"));
1007 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1009 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1011 if (what_changed == "color") {
1012 if (set_color_from_route () == 0) {
1013 show_route_color ();
1019 MixerStrip::show_route_color ()
1021 name_button.modify_bg (STATE_NORMAL, color());
1022 top_event_box.modify_bg (STATE_NORMAL, color());
1023 route_active_changed ();
1027 MixerStrip::show_passthru_color ()
1029 route_active_changed ();
1033 MixerStrip::build_route_ops_menu ()
1035 using namespace Menu_Helpers;
1036 route_ops_menu = manage (new Menu);
1037 route_ops_menu->set_name ("ArdourContextMenu");
1039 MenuList& items = route_ops_menu->items();
1041 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1042 items.push_back (SeparatorElem());
1043 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1044 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1045 route_active_menu_item->set_active (_route->active());
1046 items.push_back (SeparatorElem());
1047 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1048 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1049 polarity_menu_item->set_active (_route->phase_invert());
1050 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1051 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1052 denormal_menu_item->set_active (_route->denormal_protection());
1054 build_remote_control_menu ();
1056 items.push_back (SeparatorElem());
1057 if (!Profile->get_sae()) {
1058 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1061 items.push_back (SeparatorElem());
1062 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1066 MixerStrip::name_button_button_press (GdkEventButton* ev)
1068 if (ev->button == 1) {
1069 list_route_operations ();
1071 Menu_Helpers::MenuList& items = route_ops_menu->items();
1072 /* do not allow rename if the track is record-enabled */
1073 static_cast<MenuItem*> (&items.front())->set_sensitive (!_route->record_enabled());
1075 route_ops_menu->popup (1, ev->time);
1081 MixerStrip::list_route_operations ()
1083 if (route_ops_menu == 0) {
1084 build_route_ops_menu ();
1087 refresh_remote_control_menu();
1092 MixerStrip::speed_adjustment_changed ()
1094 /* since there is a usable speed adjustment, there has to be a diskstream */
1095 if (!ignore_speed_adjustment) {
1096 get_diskstream()->set_speed (speed_adjustment.get_value());
1101 MixerStrip::speed_changed ()
1103 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1107 MixerStrip::update_speed_display ()
1111 val = get_diskstream()->speed();
1114 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1116 speed_spinner.set_name ("MixerStripSpeedBase");
1119 if (speed_adjustment.get_value() != val) {
1120 ignore_speed_adjustment = true;
1121 speed_adjustment.set_value (val);
1122 ignore_speed_adjustment = false;
1128 MixerStrip::set_selected (bool yn)
1130 AxisView::set_selected (yn);
1132 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1133 global_frame.set_name ("MixerStripSelectedFrame");
1135 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1136 global_frame.set_name ("MixerStripFrame");
1138 global_frame.queue_draw ();
1142 MixerStrip::name_changed (void *src)
1146 RouteUI::name_changed (src);
1149 name_label.set_text (PBD::short_version (_route->name(), 5));
1152 if (_route->phase_invert()) {
1153 name_label.set_text (X_("Ø ") + name_label.get_text());
1158 MixerStrip::width_clicked ()
1162 set_width (Narrow, this);
1165 set_width (Wide, this);
1171 MixerStrip::hide_clicked ()
1173 // LAME fix to reset the button status for when it is redisplayed (part 1)
1174 hide_button.set_sensitive(false);
1177 Hiding(); /* EMIT_SIGNAL */
1179 _mixer.hide_strip (this);
1183 hide_button.set_sensitive(true);
1187 MixerStrip::set_embedded (bool yn)
1193 MixerStrip::map_frozen ()
1195 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1197 boost::shared_ptr<AudioTrack> at = audio_track();
1200 switch (at->freeze_state()) {
1201 case AudioTrack::Frozen:
1202 pre_redirect_box.set_sensitive (false);
1203 post_redirect_box.set_sensitive (false);
1204 speed_spinner.set_sensitive (false);
1207 pre_redirect_box.set_sensitive (true);
1208 post_redirect_box.set_sensitive (true);
1209 speed_spinner.set_sensitive (true);
1210 // XXX need some way, maybe, to retoggle redirect editors
1215 hide_redirect_editors ();
1219 MixerStrip::hide_redirect_editors ()
1221 _route->foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1225 MixerStrip::hide_redirect_editor (boost::shared_ptr<Redirect> redirect)
1227 void* gui = redirect->get_gui ();
1230 static_cast<Gtk::Widget*>(gui)->hide ();
1235 MixerStrip::route_active_changed ()
1237 RouteUI::route_active_changed ();
1239 if (is_audio_track()) {
1240 if (_route->active()) {
1241 set_name ("AudioTrackStripBase");
1242 gpm.set_meter_strip_name ("AudioTrackMetrics");
1244 set_name ("AudioTrackStripBaseInactive");
1245 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1247 gpm.set_fader_name ("AudioTrackFader");
1248 } else { // FIXME: assumed audio bus
1249 if (_route->active()) {
1250 set_name ("AudioBusStripBase");
1251 gpm.set_meter_strip_name ("AudioBusMetrics");
1253 set_name ("AudioBusStripBaseInactive");
1254 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1256 gpm.set_fader_name ("AudioBusFader");
1261 MixerStrip::mix_group() const
1263 return _route->mix_group();
1267 MixerStrip::engine_stopped ()
1272 MixerStrip::engine_running ()
1277 MixerStrip::meter_changed (void *src)
1280 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1282 switch (_route->meter_point()) {
1284 meter_point_label.set_text (_("input"));
1288 meter_point_label.set_text (_("pre"));
1291 case MeterPostFader:
1292 meter_point_label.set_text (_("post"));
1296 gpm.setup_meters ();
1297 // reset peak when meter point changes
1298 gpm.reset_peak_display();
1299 set_width (_width, this);