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);
124 static const gchar * loop_xpm[] = {
226 "* ! ! ~ % { ] ^ % / . ! * ~ * + ",
227 "~ % % % % ( _ : < % % % % % % % ) ",
228 "* % $ [ % } | 1 % 2 3 ^ 4 5 6 % 7 ",
229 "* % 8 9 % 0 0 % a b c d c _ e % f ",
230 "* % g 8 % h % a b i b j c 4 k % 7 ",
231 "* % l g % % . m i j j 3 n o o % 7 ",
232 "~ % p l % q d i j r b # % 0 s % 7 ",
233 "~ % t u v b w j r d x % % y z % 7 ",
234 "~ % A B A b j ] d C % [ % D E % 7 ",
235 "F % G H I { ] b C % q J % f K % 7 ",
236 "~ % L M G { b N % O P Q % R S % 7 ",
237 "+ % % % % % % % T U V W % % % % D ",
238 " X 7 D 7 7 Y = % I Z b % 7 7 K 7 ",
248 static const gchar * loop_xpm[] = {
258 " ..+++.+++..+++.. ",
259 " ..++...++.....++..",
265 " ..++.....++...++..",
266 " ..+++..+++.+++.. ",
276 ARDOUR_UI::transport_stopped ()
278 stop_button.set_active (true);
280 roll_button.set_active (false);
281 play_selection_button.set_active (false);
282 auto_loop_button.set_active (false);
285 shuttle_box.queue_draw ();
287 update_disk_space ();
290 static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
293 ARDOUR_UI::transport_rolling ()
295 stop_button.set_active (false);
296 if (session->get_play_range()) {
298 play_selection_button.set_active (true);
299 roll_button.set_active (false);
300 auto_loop_button.set_active (false);
302 } else if (session->get_auto_loop ()) {
304 auto_loop_button.set_active (true);
305 play_selection_button.set_active (false);
306 roll_button.set_active (false);
310 roll_button.set_active (true);
311 play_selection_button.set_active (false);
312 auto_loop_button.set_active (false);
315 /* reset shuttle controller */
317 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
318 shuttle_box.queue_draw ();
322 ARDOUR_UI::transport_rewinding ()
324 stop_button.set_active(false);
325 roll_button.set_active (true);
326 play_selection_button.set_active (false);
327 auto_loop_button.set_active (false);
331 ARDOUR_UI::transport_forwarding ()
333 stop_button.set_active (false);
334 roll_button.set_active (true);
335 play_selection_button.set_active (false);
336 auto_loop_button.set_active (false);
340 ARDOUR_UI::setup_transport ()
342 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
343 transport_tearoff->set_name ("TransportBase");
345 transport_hbox.pack_start (*transport_tearoff, true, false);
347 transport_base.set_name ("TransportBase");
348 transport_base.add (transport_hbox);
350 transport_frame.set_shadow_type (SHADOW_OUT);
351 transport_frame.set_name ("BaseFrame");
352 transport_frame.add (transport_base);
354 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
355 static_cast<Widget*>(&transport_frame)));
356 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
357 static_cast<Widget*> (&transport_frame), 1));
358 transport_tearoff->Hidden.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
359 static_cast<Widget*>(&transport_frame)));
360 transport_tearoff->Visible.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
361 static_cast<Widget*> (&transport_frame), 1));
363 shuttle_box.set_name ("TransportButton");
364 goto_start_button.set_name ("TransportButton");
365 goto_end_button.set_name ("TransportButton");
366 roll_button.set_name ("TransportButton");
367 stop_button.set_name ("TransportButton");
368 play_selection_button.set_name ("TransportButton");
369 rec_button.set_name ("TransportRecButton");
370 auto_loop_button.set_name ("TransportButton");
371 auto_return_button.set_name ("TransportButton");
372 auto_play_button.set_name ("TransportButton");
373 auto_input_button.set_name ("TransportButton");
374 punch_in_button.set_name ("TransportButton");
375 punch_out_button.set_name ("TransportButton");
376 click_button.set_name ("TransportButton");
377 time_master_button.set_name ("TransportButton");
379 vector<Gdk::Color> colors;
382 /* record button has 3 color states, so we set 2 extra here */
383 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_PRELIGHT, false ));
384 colors.push_back (c);
386 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_ACTIVE, false ));
387 colors.push_back (c);
389 rec_button.set_colors (colors);
392 /* other buttons get 2 color states, so add one here */
393 set_color(c, rgba_from_style ("TransportButton", 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false ));
394 colors.push_back (c);
396 stop_button.set_colors (colors);
397 roll_button.set_colors (colors);
398 auto_loop_button.set_colors (colors);
399 play_selection_button.set_colors (colors);
400 goto_start_button.set_colors (colors);
401 goto_end_button.set_colors (colors);
405 stop_button.set_active (true);
407 w = manage (new Image (Stock::MEDIA_PREVIOUS, ICON_SIZE_BUTTON));
409 goto_start_button.add (*w);
410 w = manage (new Image (Stock::MEDIA_NEXT, ICON_SIZE_BUTTON));
412 goto_end_button.add (*w);
413 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
415 roll_button.add (*w);
416 w = manage (new Image (Stock::MEDIA_STOP, ICON_SIZE_BUTTON));
418 stop_button.add (*w);
419 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
421 play_selection_button.add (*w);
422 w = manage (new Image (Stock::MEDIA_RECORD, ICON_SIZE_BUTTON));
425 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
427 auto_loop_button.add (*w);
431 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
432 act->connect_proxy (stop_button);
433 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
434 act->connect_proxy (roll_button);
435 act = ActionManager::get_action (X_("Transport"), X_("Record"));
436 act->connect_proxy (rec_button);
437 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
438 act->connect_proxy (goto_start_button);
439 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
440 act->connect_proxy (goto_end_button);
441 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
442 act->connect_proxy (auto_loop_button);
443 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
444 act->connect_proxy (play_selection_button);
445 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
446 act->connect_proxy (time_master_button);
448 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
449 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
450 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
451 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
452 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
453 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
454 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
455 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
456 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
457 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
458 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
459 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
460 ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo, _("Positional sync source"));
461 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
462 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
463 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
464 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
466 shuttle_box.set_flags (CAN_FOCUS);
467 shuttle_box.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK);
468 shuttle_box.set_size_request (100, 15);
470 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
471 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
472 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
473 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
477 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
478 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
480 primary_clock.set_mode (AudioClock::SMPTE);
481 secondary_clock.set_mode (AudioClock::BBT);
483 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
484 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
486 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
487 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
489 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button);
490 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button);
491 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button);
492 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button);
493 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
494 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
496 preroll_button.unset_flags (CAN_FOCUS);
497 preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
498 preroll_button.set_name ("TransportButton");
500 postroll_button.unset_flags (CAN_FOCUS);
501 postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
502 postroll_button.set_name ("TransportButton");
504 preroll_clock.set_mode (AudioClock::MinSec);
505 preroll_clock.set_name ("TransportClockDisplay");
506 postroll_clock.set_mode (AudioClock::MinSec);
507 postroll_clock.set_name ("TransportClockDisplay");
511 /* CANNOT bind these to clicked or toggled, must use pressed or released */
513 solo_alert_button.set_name ("TransportSoloAlert");
514 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
515 auditioning_alert_button.set_name ("TransportAuditioningAlert");
516 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
518 alert_box.pack_start (solo_alert_button);
519 alert_box.pack_start (auditioning_alert_button);
521 transport_tearoff_hbox.set_border_width (5);
523 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
524 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
526 Frame* sframe = manage (new Frame);
527 VBox* svbox = manage (new VBox);
528 HBox* shbox = manage (new HBox);
530 sframe->set_shadow_type (SHADOW_IN);
531 sframe->add (shuttle_box);
533 shuttle_box.set_name (X_("ShuttleControl"));
535 speed_display_box.add (speed_display_label);
536 speed_display_box.set_name (X_("ShuttleDisplay"));
538 shuttle_units_button.set_name (X_("ShuttleButton"));
539 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
541 shuttle_style_button.set_name (X_("ShuttleButton"));
543 vector<string> shuttle_strings;
544 shuttle_strings.push_back (_("sprung"));
545 shuttle_strings.push_back (_("wheel"));
546 set_popdown_strings (shuttle_style_button, shuttle_strings);
547 shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
549 Frame* sdframe = manage (new Frame);
551 sdframe->set_shadow_type (SHADOW_IN);
552 sdframe->add (speed_display_box);
555 sync_option_combo.set_active_text (positional_sync_strings.front());
556 sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
558 shbox->pack_start (*sdframe, false, false);
559 shbox->pack_start (shuttle_units_button, true, true);
560 shbox->pack_start (shuttle_style_button, false, false);
562 svbox->pack_start (*sframe, false, false);
563 svbox->pack_start (*shbox, false, false);
565 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
567 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
568 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
569 transport_tearoff_hbox.pack_start (roll_button, false, false);
570 transport_tearoff_hbox.pack_start (stop_button, false, false);
571 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
573 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
574 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
576 transport_tearoff_hbox.pack_start (sync_option_combo, false, false);
577 transport_tearoff_hbox.pack_start (time_master_button, false, false);
578 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
579 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
580 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
581 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
582 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
583 transport_tearoff_hbox.pack_start (click_button, false, false);
587 set_transport_sensitivity (false);
589 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
590 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
592 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
593 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
595 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
599 ARDOUR_UI::setup_clock ()
601 ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
603 big_clock_window = new Window (WINDOW_TOPLEVEL);
605 big_clock_window->set_border_width (0);
606 big_clock_window->add (big_clock);
607 big_clock_window->set_title (_("ardour: clock"));
608 big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
609 big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
610 big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
612 manage_window (*big_clock_window);
616 ARDOUR_UI::manage_window (Window& win)
618 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
619 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
620 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
624 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
626 // editor->ensure_float (transport_tearoff->tearoff_window());
631 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
634 b->reorder_child (*w, n);
638 ARDOUR_UI::soloing_changed (bool onoff)
640 if (solo_alert_button.get_active() != onoff) {
641 solo_alert_button.set_active (onoff);
646 ARDOUR_UI::_auditioning_changed (bool onoff)
648 if (auditioning_alert_button.get_active() != onoff) {
649 auditioning_alert_button.set_active (onoff);
650 set_transport_sensitivity (!onoff);
655 ARDOUR_UI::auditioning_changed (bool onoff)
657 Gtkmm2ext::UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
661 ARDOUR_UI::audition_alert_toggle ()
664 session->cancel_audition();
669 ARDOUR_UI::solo_alert_toggle ()
672 session->set_all_solo (!session->soloing());
677 ARDOUR_UI::solo_blink (bool onoff)
683 if (session->soloing()) {
685 solo_alert_button.set_state (STATE_ACTIVE);
687 solo_alert_button.set_state (STATE_NORMAL);
690 solo_alert_button.set_active (false);
691 solo_alert_button.set_state (STATE_NORMAL);
696 ARDOUR_UI::audition_blink (bool onoff)
702 if (session->is_auditioning()) {
704 auditioning_alert_button.set_state (STATE_ACTIVE);
706 auditioning_alert_button.set_state (STATE_NORMAL);
709 auditioning_alert_button.set_active (false);
710 auditioning_alert_button.set_state (STATE_NORMAL);
716 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
722 switch (ev->button) {
724 shuttle_box.add_modal_grab ();
725 shuttle_grabbed = true;
726 mouse_shuttle (ev->x, true);
739 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
745 switch (ev->button) {
747 mouse_shuttle (ev->x, true);
748 shuttle_grabbed = false;
749 shuttle_box.remove_modal_grab ();
750 if (shuttle_behaviour == Sprung) {
751 shuttle_fract = SHUTTLE_FRACT_SPEED1;
752 session->request_transport_speed (1.0);
753 shuttle_box.queue_draw ();
758 if (session->transport_rolling()) {
759 shuttle_fract = SHUTTLE_FRACT_SPEED1;
760 session->request_transport_speed (1.0);
764 shuttle_box.queue_draw ();
771 shuttle_fract += 0.005;
774 shuttle_fract -= 0.005;
778 use_shuttle_fract (true);
784 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
786 if (!session || !shuttle_grabbed) {
790 return mouse_shuttle (ev->x, false);
794 ARDOUR_UI::mouse_shuttle (double x, bool force)
796 double half_width = shuttle_box.get_width() / 2.0;
797 double distance = x - half_width;
800 distance = min (distance, half_width);
802 distance = max (distance, -half_width);
805 shuttle_fract = distance / half_width;
806 use_shuttle_fract (force);
811 ARDOUR_UI::use_shuttle_fract (bool force)
816 /* do not attempt to submit a motion-driven transport speed request
817 more than once per process cycle.
820 gettimeofday (&now, 0);
821 timersub (&now, &last_shuttle_request, &diff);
823 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
827 last_shuttle_request = now;
829 bool neg = (shuttle_fract < 0.0);
831 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
837 session->request_transport_speed (8.0 * fract); // Formula A2
838 shuttle_box.queue_draw ();
842 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
845 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
847 /* redraw the background */
849 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
851 event->area.x, event->area.y,
852 event->area.width, event->area.height);
855 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
859 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
863 shuttle_box.get_height());
868 ARDOUR_UI::shuttle_unit_clicked ()
870 if (shuttle_unit_menu == 0) {
871 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
873 shuttle_unit_menu->popup (1, 0);
877 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
879 switch ((shuttle_units = u)) {
881 static_cast<Label*>(shuttle_units_button.get_child())->set_text ("% ");
884 static_cast<Label*>(shuttle_units_button.get_child())->set_text (_("st"));
890 ARDOUR_UI::shuttle_style_changed ()
892 ustring str = shuttle_style_button.get_active_text ();
894 if (str == _("sprung")) {
895 set_shuttle_behaviour (Sprung);
896 } else if (str == _("wheel")) {
897 set_shuttle_behaviour (Wheel);
903 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
905 switch ((shuttle_behaviour = b)) {
907 shuttle_style_button.set_active_text (_("sprung"));
909 shuttle_box.queue_draw ();
911 if (session->transport_rolling()) {
912 shuttle_fract = SHUTTLE_FRACT_SPEED1;
913 session->request_transport_speed (1.0);
918 shuttle_style_button.set_active_text (_("wheel"));
924 ARDOUR_UI::update_speed_display ()
927 if (last_speed_displayed != 0) {
928 speed_display_label.set_text (_("stopped"));
929 last_speed_displayed = 0;
935 float x = session->transport_speed ();
937 if (x != last_speed_displayed) {
940 if (shuttle_units == Percentage) {
941 snprintf (buf, sizeof (buf), "%.4f", x);
944 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
946 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
949 speed_display_label.set_text (buf);
951 speed_display_label.set_text (_("stopped"));
954 last_speed_displayed = x;
959 ARDOUR_UI::set_transport_sensitivity (bool yn)
961 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
962 shuttle_box.set_sensitive (yn);
966 ARDOUR_UI::editor_realized ()
968 set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
969 /* XXX: this should really be saved in instant.xml or something similar and restored from there */
970 shuttle_style_button.set_active_text (_("sprung"));
971 const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
972 set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
976 ARDOUR_UI::sync_option_changed ()
984 which = sync_option_combo.get_active_text();
986 if (which == positional_sync_strings[Session::None]) {
987 session->request_slave_source (Session::None);
988 } else if (which == positional_sync_strings[Session::MTC]) {
989 session->request_slave_source (Session::MTC);
990 } else if (which == positional_sync_strings[Session::JACK]) {
991 session->request_slave_source (Session::JACK);
996 ARDOUR_UI::maximise_editing_space ()
1002 transport_tearoff->set_visible (false);
1003 editor->maximise_editing_space ();
1007 ARDOUR_UI::restore_editing_space ()
1013 transport_tearoff->set_visible (true);
1014 editor->restore_editing_space ();