2 Copyright (C) 1999 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.
28 #include <sigc++/bind.h>
29 #include <pbd/error.h>
30 #include <pbd/basename.h>
31 #include <pbd/fastlog.h>
32 #include <gtkmm2ext/pix.h>
33 #include <gtkmm2ext/utils.h>
34 #include <gtkmm2ext/click_box.h>
35 #include <gtkmm2ext/tearoff.h>
37 #include <ardour/audioengine.h>
38 #include <ardour/ardour.h>
39 #include <ardour/route.h>
41 #include "ardour_ui.h"
42 #include "public_editor.h"
43 #include "audio_clock.h"
50 using namespace ARDOUR;
51 using namespace Gtkmm2ext;
57 ARDOUR_UI::setup_windows ()
59 using namespace Menu_Helpers;
61 if (create_editor ()) {
62 error << _("UI: cannot setup editor") << endmsg;
66 if (create_mixer ()) {
67 error << _("UI: cannot setup mixer") << endmsg;
71 /* all other dialogs are created conditionally */
73 we_have_dependents ();
80 top_packer.pack_start (menu_bar_base, false, false);
81 top_packer.pack_start (transport_frame, false, false);
83 editor->add_toplevel_controls (top_packer);
89 ARDOUR_UI::setup_adjustables ()
91 adjuster_table.set_homogeneous (true);
93 online_control_strings.push_back (_("MMC + Local"));
94 online_control_strings.push_back (_("MMC"));
95 online_control_strings.push_back (_("Local"));
97 online_control_button = new GlobalClickBox ("CONTROL",
98 online_control_strings);
100 online_control_button->adjustment.signal_value_changed().connect(mem_fun(*this,&ARDOUR_UI::control_methods_adjusted));
102 mmc_id_strings.push_back ("1");
103 mmc_id_strings.push_back ("2");
104 mmc_id_strings.push_back ("3");
105 mmc_id_strings.push_back ("4");
106 mmc_id_strings.push_back ("5");
107 mmc_id_strings.push_back ("6");
108 mmc_id_strings.push_back ("7");
109 mmc_id_strings.push_back ("8");
110 mmc_id_strings.push_back ("9");
112 mmc_id_button = new GlobalClickBox (_("MMC ID"), mmc_id_strings);
114 mmc_id_button->adjustment.signal_value_changed().connect (mem_fun(*this,&ARDOUR_UI::mmc_device_id_adjusted));
116 adjuster_table.attach (*online_control_button, 0, 2, 1, 2, FILL|EXPAND, FILL, 5, 5);
117 adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, FILL, FILL, 5, 5);
120 static const gchar * loop_xpm[] = {
130 " ..+++.+++..+++.. ",
131 " ..++...++.....++..",
137 " ..++.....++...++..",
138 " ..+++..+++.+++.. ",
146 ARDOUR_UI::transport_stopped ()
148 stop_button.set_active (true);
150 roll_button.set_active (false);
151 play_selection_button.set_active (false);
152 auto_loop_button.set_active (false);
155 shuttle_box.queue_draw ();
157 update_disk_space ();
160 static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
163 ARDOUR_UI::transport_rolling ()
165 stop_button.set_active (false);
166 if (session->get_play_range()) {
168 play_selection_button.set_active (true);
169 roll_button.set_active (false);
170 auto_loop_button.set_active (false);
172 } else if (session->get_auto_loop ()) {
174 auto_loop_button.set_active (true);
175 play_selection_button.set_active (false);
176 roll_button.set_active (false);
180 roll_button.set_active (true);
181 play_selection_button.set_active (false);
182 auto_loop_button.set_active (false);
185 /* reset shuttle controller */
187 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
188 shuttle_box.queue_draw ();
192 ARDOUR_UI::transport_rewinding ()
194 stop_button.set_active(false);
195 roll_button.set_active (true);
196 play_selection_button.set_active (false);
197 auto_loop_button.set_active (false);
201 ARDOUR_UI::transport_forwarding ()
203 stop_button.set_active (false);
204 roll_button.set_active (true);
205 play_selection_button.set_active (false);
206 auto_loop_button.set_active (false);
210 ARDOUR_UI::setup_transport ()
212 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
213 transport_tearoff->set_name ("TransportBase");
215 transport_hbox.pack_start (*transport_tearoff, true, false);
217 transport_base.set_name ("TransportBase");
218 transport_base.add (transport_hbox);
220 transport_frame.set_shadow_type (SHADOW_OUT);
221 transport_frame.set_name ("BaseFrame");
222 transport_frame.add (transport_base);
224 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
225 static_cast<Widget*>(&transport_frame)));
226 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
227 static_cast<Widget*> (&transport_frame), 1));
229 shuttle_box.set_name ("TransportButton");
230 goto_start_button.set_name ("TransportButton");
231 goto_end_button.set_name ("TransportButton");
232 roll_button.set_name ("TransportButton");
233 stop_button.set_name ("TransportButton");
234 play_selection_button.set_name ("TransportButton");
235 rec_button.set_name ("TransportRecButton");
236 auto_loop_button.set_name ("TransportButton");
237 auto_return_button.set_name ("TransportButton");
238 auto_play_button.set_name ("TransportButton");
239 auto_input_button.set_name ("TransportButton");
240 punch_in_button.set_name ("TransportButton");
241 punch_out_button.set_name ("TransportButton");
242 click_button.set_name ("TransportButton");
243 time_master_button.set_name ("TransportButton");
245 vector<Gdk::Color> colors;
248 /* record button has 3 color states, so we set 2 extra here */
249 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_PRELIGHT, false ));
250 colors.push_back (c);
252 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_ACTIVE, false ));
253 colors.push_back (c);
255 rec_button.set_colors (colors);
258 /* other buttons get 2 color states, so add one here */
259 set_color(c, rgba_from_style ("TransportButton", 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false ));
260 colors.push_back (c);
262 stop_button.set_colors (colors);
263 roll_button.set_colors (colors);
264 auto_loop_button.set_colors (colors);
265 play_selection_button.set_colors (colors);
266 goto_start_button.set_colors (colors);
267 goto_end_button.set_colors (colors);
271 stop_button.set_active (true);
273 w = manage (new Image (Stock::MEDIA_PREVIOUS, ICON_SIZE_BUTTON));
275 goto_start_button.add (*w);
276 w = manage (new Image (Stock::MEDIA_NEXT, ICON_SIZE_BUTTON));
278 goto_end_button.add (*w);
279 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
281 roll_button.add (*w);
282 w = manage (new Image (Stock::MEDIA_STOP, ICON_SIZE_BUTTON));
284 stop_button.add (*w);
285 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
287 play_selection_button.add (*w);
288 w = manage (new Image (Stock::MEDIA_RECORD, ICON_SIZE_BUTTON));
291 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
293 auto_loop_button.add (*w);
297 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
298 act->connect_proxy (stop_button);
299 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
300 act->connect_proxy (roll_button);
301 act = ActionManager::get_action (X_("Transport"), X_("Record"));
302 act->connect_proxy (rec_button);
303 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
304 act->connect_proxy (goto_start_button);
305 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
306 act->connect_proxy (goto_end_button);
307 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
308 act->connect_proxy (auto_loop_button);
309 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
310 act->connect_proxy (play_selection_button);
311 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
312 act->connect_proxy (time_master_button);
314 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
315 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
316 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
317 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
318 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
319 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
320 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
321 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
322 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
323 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
324 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
325 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
326 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
327 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
328 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
329 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
331 shuttle_box.set_flags (CAN_FOCUS);
332 shuttle_box.set_events (shuttle_box.get_events() | Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK);
333 shuttle_box.set_size_request (100, 15);
335 goto_start_button.unset_flags (CAN_FOCUS);
336 goto_end_button.unset_flags (CAN_FOCUS);
337 roll_button.unset_flags (CAN_FOCUS);
338 stop_button.unset_flags (CAN_FOCUS);
339 play_selection_button.unset_flags (CAN_FOCUS);
340 rec_button.unset_flags (CAN_FOCUS);
341 auto_loop_button.unset_flags (CAN_FOCUS);
342 auto_return_button.unset_flags (CAN_FOCUS);
343 auto_play_button.unset_flags (CAN_FOCUS);
344 auto_input_button.unset_flags (CAN_FOCUS);
345 punch_out_button.unset_flags (CAN_FOCUS);
346 punch_in_button.unset_flags (CAN_FOCUS);
347 click_button.unset_flags (CAN_FOCUS);
348 time_master_button.unset_flags (CAN_FOCUS);
350 goto_start_button.set_events (goto_start_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
351 goto_end_button.set_events (goto_end_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
352 roll_button.set_events (roll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
353 stop_button.set_events (stop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
354 play_selection_button.set_events (play_selection_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
355 rec_button.set_events (rec_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
356 auto_loop_button.set_events (auto_loop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
357 auto_return_button.set_events (auto_return_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
358 auto_play_button.set_events (auto_play_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
359 auto_input_button.set_events (auto_input_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
360 click_button.set_events (click_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
361 punch_in_button.set_events (punch_in_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
362 punch_out_button.set_events (punch_out_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
363 time_master_button.set_events (punch_out_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
365 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
366 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
367 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
368 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
372 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
373 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
375 primary_clock.set_mode (AudioClock::SMPTE);
376 secondary_clock.set_mode (AudioClock::BBT);
378 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
379 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
381 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
382 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
384 /* options: XXX these should all be actions with the buttons as proxies */
386 auto_return_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_return));
387 auto_play_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_play));
388 auto_input_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_input));
389 click_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_click));
390 punch_in_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_in));
391 punch_out_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_out));
393 preroll_button.unset_flags (CAN_FOCUS);
394 preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
395 preroll_button.set_name ("TransportButton");
397 postroll_button.unset_flags (CAN_FOCUS);
398 postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
399 postroll_button.set_name ("TransportButton");
401 preroll_clock.set_mode (AudioClock::MinSec);
402 preroll_clock.set_name ("TransportClockDisplay");
403 postroll_clock.set_mode (AudioClock::MinSec);
404 postroll_clock.set_name ("TransportClockDisplay");
408 /* CANNOT bind these to clicked or toggled, must use pressed or released */
410 solo_alert_button.set_name ("TransportSoloAlert");
411 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
412 auditioning_alert_button.set_name ("TransportAuditioningAlert");
413 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
415 alert_box.pack_start (solo_alert_button);
416 alert_box.pack_start (auditioning_alert_button);
418 transport_tearoff_hbox.set_border_width (5);
420 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
421 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
423 Frame* sframe = manage (new Frame);
424 VBox* svbox = manage (new VBox);
425 HBox* shbox = manage (new HBox);
427 sframe->set_shadow_type (SHADOW_IN);
428 sframe->add (shuttle_box);
430 shuttle_box.set_name (X_("ShuttleControl"));
432 speed_display_box.add (speed_display_label);
433 speed_display_box.set_name (X_("ShuttleDisplay"));
435 shuttle_units_button.set_name (X_("ShuttleButton"));
436 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
438 shuttle_style_button.set_name (X_("ShuttleButton"));
440 vector<string> shuttle_strings;
441 shuttle_strings.push_back (_("sprung"));
442 shuttle_strings.push_back (_("wheel"));
443 set_popdown_strings (shuttle_style_button, shuttle_strings);
444 shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
446 Frame* sdframe = manage (new Frame);
448 sdframe->set_shadow_type (SHADOW_IN);
449 sdframe->add (speed_display_box);
452 sync_option_combo.set_active_text (positional_sync_strings.front());
453 sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
455 shbox->pack_start (*sdframe, false, false);
456 shbox->pack_start (shuttle_units_button, true, true);
457 shbox->pack_start (shuttle_style_button, false, false);
459 svbox->pack_start (*sframe, false, false);
460 svbox->pack_start (*shbox, false, false);
462 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
464 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
465 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
466 transport_tearoff_hbox.pack_start (roll_button, false, false);
467 transport_tearoff_hbox.pack_start (stop_button, false, false);
468 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
470 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
471 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
473 transport_tearoff_hbox.pack_start (sync_option_combo, false, false);
474 transport_tearoff_hbox.pack_start (time_master_button, false, false);
475 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
476 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
477 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
478 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
479 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
480 transport_tearoff_hbox.pack_start (click_button, false, false);
484 set_transport_sensitivity (false);
486 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
487 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
489 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
490 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
492 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
496 ARDOUR_UI::setup_clock ()
498 ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
500 big_clock_window = new Window (WINDOW_TOPLEVEL);
502 big_clock_window->set_border_width (0);
503 big_clock_window->add (big_clock);
504 big_clock_window->set_title (_("ardour: clock"));
505 big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
506 big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
507 big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
509 manage_window (*big_clock_window);
513 ARDOUR_UI::manage_window (Window& win)
515 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
516 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
517 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
521 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
523 // editor->ensure_float (transport_tearoff->tearoff_window());
528 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
531 b->reorder_child (*w, n);
535 ARDOUR_UI::soloing_changed (bool onoff)
537 if (solo_alert_button.get_active() != onoff) {
538 solo_alert_button.set_active (onoff);
543 ARDOUR_UI::_auditioning_changed (bool onoff)
545 if (auditioning_alert_button.get_active() != onoff) {
546 auditioning_alert_button.set_active (onoff);
547 set_transport_sensitivity (!onoff);
552 ARDOUR_UI::auditioning_changed (bool onoff)
554 Gtkmm2ext::UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
558 ARDOUR_UI::audition_alert_toggle ()
561 session->cancel_audition();
566 ARDOUR_UI::solo_alert_toggle ()
569 session->set_all_solo (!session->soloing());
574 ARDOUR_UI::solo_blink (bool onoff)
580 if (session->soloing()) {
582 solo_alert_button.set_state (STATE_ACTIVE);
584 solo_alert_button.set_state (STATE_NORMAL);
587 solo_alert_button.set_active (false);
588 solo_alert_button.set_state (STATE_NORMAL);
593 ARDOUR_UI::audition_blink (bool onoff)
599 if (session->is_auditioning()) {
601 auditioning_alert_button.set_state (STATE_ACTIVE);
603 auditioning_alert_button.set_state (STATE_NORMAL);
606 auditioning_alert_button.set_active (false);
607 auditioning_alert_button.set_state (STATE_NORMAL);
613 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
619 switch (ev->button) {
621 shuttle_box.add_modal_grab ();
622 shuttle_grabbed = true;
623 mouse_shuttle (ev->x, true);
636 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
642 switch (ev->button) {
644 mouse_shuttle (ev->x, true);
645 shuttle_grabbed = false;
646 shuttle_box.remove_modal_grab ();
647 if (shuttle_behaviour == Sprung) {
648 shuttle_fract = SHUTTLE_FRACT_SPEED1;
649 session->request_transport_speed (1.0);
650 shuttle_box.queue_draw ();
655 if (session->transport_rolling()) {
656 shuttle_fract = SHUTTLE_FRACT_SPEED1;
657 session->request_transport_speed (1.0);
661 shuttle_box.queue_draw ();
668 shuttle_fract += 0.005;
671 shuttle_fract -= 0.005;
675 use_shuttle_fract (true);
681 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
683 if (!session || !shuttle_grabbed) {
687 return mouse_shuttle (ev->x, false);
691 ARDOUR_UI::mouse_shuttle (double x, bool force)
693 double half_width = shuttle_box.get_width() / 2.0;
694 double distance = x - half_width;
697 distance = min (distance, half_width);
699 distance = max (distance, -half_width);
702 shuttle_fract = distance / half_width;
703 use_shuttle_fract (force);
708 ARDOUR_UI::use_shuttle_fract (bool force)
713 /* do not attempt to submit a motion-driven transport speed request
714 more than once per process cycle.
717 gettimeofday (&now, 0);
718 timersub (&now, &last_shuttle_request, &diff);
720 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
724 last_shuttle_request = now;
726 bool neg = (shuttle_fract < 0.0);
728 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
734 session->request_transport_speed (8.0 * fract); // Formula A2
735 shuttle_box.queue_draw ();
739 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
742 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
744 /* redraw the background */
746 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
748 event->area.x, event->area.y,
749 event->area.width, event->area.height);
752 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
756 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
760 shuttle_box.get_height());
765 ARDOUR_UI::shuttle_unit_clicked ()
767 if (shuttle_unit_menu == 0) {
768 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
770 shuttle_unit_menu->popup (1, 0);
774 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
776 switch ((shuttle_units = u)) {
778 static_cast<Label*>(shuttle_units_button.get_child())->set_text ("% ");
781 static_cast<Label*>(shuttle_units_button.get_child())->set_text (_("st"));
787 ARDOUR_UI::shuttle_style_changed ()
789 ustring str = shuttle_style_button.get_active_text ();
791 if (str == _("sprung")) {
792 set_shuttle_behaviour (Sprung);
793 } else if (str == _("wheel")) {
794 set_shuttle_behaviour (Wheel);
800 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
802 switch ((shuttle_behaviour = b)) {
804 shuttle_style_button.set_active_text (_("sprung"));
806 shuttle_box.queue_draw ();
808 if (session->transport_rolling()) {
809 shuttle_fract = SHUTTLE_FRACT_SPEED1;
810 session->request_transport_speed (1.0);
815 shuttle_style_button.set_active_text (_("wheel"));
821 ARDOUR_UI::update_speed_display ()
824 if (last_speed_displayed != 0) {
825 speed_display_label.set_text (_("stopped"));
826 last_speed_displayed = 0;
832 float x = session->transport_speed ();
834 if (x != last_speed_displayed) {
837 if (shuttle_units == Percentage) {
838 snprintf (buf, sizeof (buf), "%.4f", x);
841 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
843 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
846 speed_display_label.set_text (buf);
848 speed_display_label.set_text (_("stopped"));
851 last_speed_displayed = x;
856 ARDOUR_UI::set_transport_sensitivity (bool yn)
858 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
859 shuttle_box.set_sensitive (yn);
863 ARDOUR_UI::editor_realized ()
865 set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
866 /* XXX: this should really be saved in instant.xml or something similar and restored from there */
867 shuttle_style_button.set_active_text (_("sprung"));
868 const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
869 set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
873 ARDOUR_UI::sync_option_changed ()
881 which = sync_option_combo.get_active_text();
883 if (which == positional_sync_strings[Session::None]) {
884 session->request_slave_source (Session::None);
885 } else if (which == positional_sync_strings[Session::MTC]) {
886 session->request_slave_source (Session::MTC);
887 } else if (which == positional_sync_strings[Session::JACK]) {
888 session->request_slave_source (Session::JACK);