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.
29 #include <pbd/error.h>
30 #include <pbd/basename.h>
31 #include <pbd/fastlog.h>
32 #include <gtkmmext/pix.h>
33 #include <gtkmmext/utils.h>
34 #include <gtkmmext/click_box.h>
35 #include <gtkmmext/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"
44 #include "extra_bind.h"
49 using namespace ARDOUR;
50 using namespace Gtkmmext;
55 ARDOUR_UI::setup_windows ()
57 using namespace Menu_Helpers;
59 if (create_editor ()) {
60 error << _("UI: cannot setup editor") << endmsg;
64 if (create_mixer ()) {
65 error << _("UI: cannot setup mixer") << endmsg;
69 if (create_meter_bridge ()) {
70 error << _("UI: cannot setup meter_bridge") << endmsg;
74 /* all other dialogs are created conditionally */
76 we_have_dependents ();
83 top_packer.pack_start (menu_bar_base, false, false);
84 top_packer.pack_start (transport_frame, false, false);
86 editor->add_toplevel_controls (top_packer);
93 ARDOUR_UI::setup_adjustables ()
96 adjuster_table.set_homogeneous (true);
98 online_control_strings.push_back (_("MMC + Local"));
99 online_control_strings.push_back (_("MMC"));
100 online_control_strings.push_back (_("Local"));
102 online_control_button = new GlobalClickBox ("CONTROL",
103 online_control_strings);
105 online_control_button->adjustment.value_changed.connect(slot (*this,&ARDOUR_UI::control_methods_adjusted));
107 mmc_id_strings.push_back ("1");
108 mmc_id_strings.push_back ("2");
109 mmc_id_strings.push_back ("3");
110 mmc_id_strings.push_back ("4");
111 mmc_id_strings.push_back ("5");
112 mmc_id_strings.push_back ("6");
113 mmc_id_strings.push_back ("7");
114 mmc_id_strings.push_back ("8");
115 mmc_id_strings.push_back ("9");
117 mmc_id_button = new GlobalClickBox (_("MMC ID"), mmc_id_strings);
119 mmc_id_button->adjustment.value_changed.connect (slot (*this,&ARDOUR_UI::mmc_device_id_adjusted));
121 adjuster_table.attach (*online_control_button, 0, 2, 1, 2, GTK_FILL|GTK_EXPAND, 0, 5, 5);
122 adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, 0, 0, 5, 5);
125 #include "transport_xpms"
128 ARDOUR_UI::transport_stopped ()
130 roll_button.set_active (false);
131 play_selection_button.set_active (false);
132 auto_loop_button.set_active (false);
135 shuttle_box.queue_draw ();
137 update_disk_space ();
140 static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
143 ARDOUR_UI::transport_rolling ()
145 if (session->get_play_range()) {
147 play_selection_button.set_active (true);
148 roll_button.set_active (false);
149 auto_loop_button.set_active (false);
151 } else if (session->get_auto_loop ()) {
153 auto_loop_button.set_active (true);
154 play_selection_button.set_active (false);
155 roll_button.set_active (false);
159 roll_button.set_active (true);
160 play_selection_button.set_active (false);
161 auto_loop_button.set_active (false);
164 /* reset shuttle controller */
166 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
167 shuttle_box.queue_draw ();
171 ARDOUR_UI::transport_rewinding ()
173 roll_button.set_active (true);
174 play_selection_button.set_active (false);
175 auto_loop_button.set_active (false);
179 ARDOUR_UI::transport_forwarding ()
181 roll_button.set_active (true);
182 play_selection_button.set_active (false);
183 auto_loop_button.set_active (false);
187 ARDOUR_UI::setup_transport ()
189 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
190 transport_tearoff->set_name ("TransportBase");
192 transport_hbox.pack_start (*transport_tearoff, true, false);
194 transport_base.set_name ("TransportBase");
195 transport_base.add (transport_hbox);
197 transport_frame.set_shadow_type (GTK_SHADOW_OUT);
198 transport_frame.set_name ("BaseFrame");
199 transport_frame.add (transport_base);
201 transport_tearoff->Detach.connect (bind (slot (*this, &ARDOUR_UI::detach_tearoff), static_cast<Gtk::Box*>(&top_packer),
202 static_cast<Gtk::Widget*>(&transport_frame)));
203 transport_tearoff->Attach.connect (bind (slot (*this, &ARDOUR_UI::reattach_tearoff), static_cast<Gtk::Box*> (&top_packer),
204 static_cast<Gtk::Widget*> (&transport_frame), 1));
207 goto_start_button.add (*(manage (new Gtk::Pixmap (start_xpm))));
208 goto_end_button.add (*(manage (new Gtk::Pixmap (end_xpm))));
209 roll_button.add (*(manage (new Gtk::Pixmap (arrow_xpm))));
210 stop_button.add (*(manage (new Gtk::Pixmap (stop_xpm))));
211 play_selection_button.add (*(manage (new Gtk::Pixmap (play_selection_xpm))));
212 rec_button.add (*(manage (new Gtk::Pixmap (rec_xpm))));
213 auto_loop_button.add (*(manage (new Gtk::Pixmap (loop_xpm))));
215 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
216 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
217 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
218 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
219 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
220 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
221 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
222 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
223 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
224 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
225 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
226 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
227 ARDOUR_UI::instance()->tooltips().set_tip (follow_button, _("Enable/Disable follow playhead"));
228 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
229 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
230 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_style_button, _("Select sprung or wheel behaviour"));
231 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
233 shuttle_box.set_flags (GTK_CAN_FOCUS);
234 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);
235 shuttle_box.set_usize (100, 15);
237 shuttle_box.set_name ("TransportButton");
238 goto_start_button.set_name ("TransportButton");
239 goto_end_button.set_name ("TransportButton");
240 roll_button.set_name ("TransportButton");
241 stop_button.set_name ("TransportButton");
242 play_selection_button.set_name ("TransportButton");
243 rec_button.set_name ("TransportRecButton");
244 auto_loop_button.set_name ("TransportButton");
245 auto_return_button.set_name ("TransportButton");
246 auto_play_button.set_name ("TransportButton");
247 auto_input_button.set_name ("TransportButton");
248 punch_in_button.set_name ("TransportButton");
249 punch_out_button.set_name ("TransportButton");
250 click_button.set_name ("TransportButton");
251 follow_button.set_name ("TransportButton");
253 goto_start_button.unset_flags (GTK_CAN_FOCUS);
254 goto_end_button.unset_flags (GTK_CAN_FOCUS);
255 roll_button.unset_flags (GTK_CAN_FOCUS);
256 stop_button.unset_flags (GTK_CAN_FOCUS);
257 play_selection_button.unset_flags (GTK_CAN_FOCUS);
258 rec_button.unset_flags (GTK_CAN_FOCUS);
259 auto_loop_button.unset_flags (GTK_CAN_FOCUS);
260 auto_return_button.unset_flags (GTK_CAN_FOCUS);
261 auto_play_button.unset_flags (GTK_CAN_FOCUS);
262 auto_input_button.unset_flags (GTK_CAN_FOCUS);
263 punch_out_button.unset_flags (GTK_CAN_FOCUS);
264 punch_in_button.unset_flags (GTK_CAN_FOCUS);
265 click_button.unset_flags (GTK_CAN_FOCUS);
266 follow_button.unset_flags (GTK_CAN_FOCUS);
268 goto_start_button.set_events (goto_start_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
269 goto_end_button.set_events (goto_end_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
270 roll_button.set_events (roll_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
271 stop_button.set_events (stop_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
272 play_selection_button.set_events (play_selection_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
273 rec_button.set_events (rec_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
274 auto_loop_button.set_events (auto_loop_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
275 auto_return_button.set_events (auto_return_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
276 auto_play_button.set_events (auto_play_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
277 auto_input_button.set_events (auto_input_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
278 click_button.set_events (click_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
279 follow_button.set_events (click_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
280 punch_in_button.set_events (punch_in_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
281 punch_out_button.set_events (punch_out_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
283 goto_start_button.clicked.connect (slot (*this,&ARDOUR_UI::transport_goto_start));
284 goto_end_button.clicked.connect (slot (*this,&ARDOUR_UI::transport_goto_end));
286 roll_button.button_release_event.connect (slot (*this,&ARDOUR_UI::mouse_transport_roll));
287 play_selection_button.button_release_event.connect (slot (*this,&ARDOUR_UI::mouse_transport_play_selection));
288 auto_loop_button.button_release_event.connect (slot (*this,&ARDOUR_UI::mouse_transport_loop));
290 stop_button.button_release_event.connect (slot (*this,&ARDOUR_UI::mouse_transport_stop));
291 rec_button.button_release_event.connect (slot (*this,&ARDOUR_UI::mouse_transport_record));
293 shuttle_box.button_press_event.connect (slot (*this, &ARDOUR_UI::shuttle_box_button_press));
294 shuttle_box.button_release_event.connect (slot (*this, &ARDOUR_UI::shuttle_box_button_release));
295 shuttle_box.motion_notify_event.connect (slot (*this, &ARDOUR_UI::shuttle_box_motion));
296 shuttle_box.expose_event.connect (slot (*this, &ARDOUR_UI::shuttle_box_expose));
300 ARDOUR_UI::Clock.connect (bind (slot (primary_clock, &AudioClock::set), false));
301 ARDOUR_UI::Clock.connect (bind (slot (secondary_clock, &AudioClock::set), false));
303 primary_clock.set_mode (AudioClock::SMPTE);
304 primary_clock.set_name ("TransportClockDisplay");
305 secondary_clock.set_mode (AudioClock::BBT);
306 secondary_clock.set_name ("TransportClockDisplay");
309 primary_clock.ValueChanged.connect (slot (*this, &ARDOUR_UI::primary_clock_value_changed));
310 secondary_clock.ValueChanged.connect (slot (*this, &ARDOUR_UI::secondary_clock_value_changed));
312 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
313 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
317 auto_return_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_auto_return));
318 auto_play_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_auto_play));
319 auto_input_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_auto_input));
320 click_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_click));
321 follow_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_follow));
322 punch_in_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_punch_in));
323 punch_out_button.toggled.connect (slot (*this,&ARDOUR_UI::toggle_punch_out));
325 preroll_button.unset_flags (GTK_CAN_FOCUS);
326 preroll_button.set_events (preroll_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
327 preroll_button.set_name ("TransportButton");
329 postroll_button.unset_flags (GTK_CAN_FOCUS);
330 postroll_button.set_events (postroll_button.get_events() & ~(GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK));
331 postroll_button.set_name ("TransportButton");
333 preroll_clock.set_mode (AudioClock::MinSec);
334 preroll_clock.set_name ("TransportClockDisplay");
335 postroll_clock.set_mode (AudioClock::MinSec);
336 postroll_clock.set_name ("TransportClockDisplay");
340 /* CANNOT bind these to clicked or toggled, must use pressed or released */
342 solo_alert_button.set_name ("TransportSoloAlert");
343 solo_alert_button.pressed.connect (slot (*this,&ARDOUR_UI::solo_alert_toggle));
344 auditioning_alert_button.set_name ("TransportAuditioningAlert");
345 auditioning_alert_button.pressed.connect (slot (*this,&ARDOUR_UI::audition_alert_toggle));
347 alert_box.pack_start (solo_alert_button);
348 alert_box.pack_start (auditioning_alert_button);
350 transport_tearoff_hbox.set_border_width (5);
352 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
353 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
355 Gtk::Frame* sframe = manage (new Frame);
356 Gtk::VBox* svbox = manage (new VBox);
357 Gtk::HBox* shbox = manage (new HBox);
359 sframe->set_shadow_type (GTK_SHADOW_IN);
360 sframe->add (shuttle_box);
362 shuttle_box.set_name (X_("ShuttleControl"));
364 speed_display_box.add (speed_display_label);
365 set_usize_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
366 speed_display_box.set_name (X_("ShuttleDisplay"));
368 shuttle_units_button.set_name (X_("ShuttleButton"));
369 shuttle_units_button.clicked.connect (slot (*this, &ARDOUR_UI::shuttle_unit_clicked));
371 shuttle_style_button.set_name (X_("ShuttleButton"));
372 shuttle_style_button.clicked.connect (slot (*this, &ARDOUR_UI::shuttle_style_clicked));
374 Gtk::Frame* sdframe = manage (new Frame);
376 sdframe->set_shadow_type (GTK_SHADOW_IN);
377 sdframe->add (speed_display_box);
379 shbox->pack_start (*sdframe, false, false);
380 shbox->pack_start (shuttle_units_button, true, true);
381 shbox->pack_start (shuttle_style_button, false, false);
383 svbox->pack_start (*sframe, false, false);
384 svbox->pack_start (*shbox, false, false);
386 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
388 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
389 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
390 transport_tearoff_hbox.pack_start (roll_button, false, false);
391 transport_tearoff_hbox.pack_start (stop_button, false, false);
392 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
394 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
395 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
397 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
398 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
399 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
400 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
401 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
402 transport_tearoff_hbox.pack_start (click_button, false, false);
403 transport_tearoff_hbox.pack_start (follow_button, false, false);
407 set_transport_sensitivity (false);
409 /* catch up with editor state */
413 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
414 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
416 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
417 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
419 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
423 ARDOUR_UI::setup_clock ()
425 ARDOUR_UI::Clock.connect (bind (slot (big_clock, &AudioClock::set), false));
427 big_clock_window = new BigClockWindow;
429 big_clock_window->set_border_width (0);
430 big_clock_window->add (big_clock);
431 big_clock_window->set_title (_("ardour: clock"));
433 big_clock_window->delete_event.connect (bind (slot (just_hide_it), static_cast<Gtk::Window*>(big_clock_window)));
434 big_clock_window->realize.connect (slot (*this, &ARDOUR_UI::big_clock_realize));
435 big_clock_window->size_allocate.connect (slot (*this, &ARDOUR_UI::big_clock_size_event));
437 big_clock_window->Hiding.connect (slot (*this, &ARDOUR_UI::big_clock_hiding));
441 ARDOUR_UI::big_clock_size_event (GtkAllocation *alloc)
447 ARDOUR_UI::big_clock_realize ()
449 big_clock_window->get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH|GDK_DECOR_MAXIMIZE|GDK_DECOR_MINIMIZE));
453 ARDOUR_UI::detach_tearoff (Gtk::Box* b, Gtk::Widget* w)
455 editor->ensure_float (*transport_tearoff->tearoff_window());
460 ARDOUR_UI::reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n)
463 b->reorder_child (*w, n);
467 ARDOUR_UI::soloing_changed (bool onoff)
469 if (solo_alert_button.get_active() != onoff) {
470 solo_alert_button.set_active (onoff);
475 ARDOUR_UI::_auditioning_changed (bool onoff)
477 if (auditioning_alert_button.get_active() != onoff) {
478 auditioning_alert_button.set_active (onoff);
479 set_transport_sensitivity (!onoff);
484 ARDOUR_UI::auditioning_changed (bool onoff)
486 Gtkmmext::UI::instance()->call_slot(bind (slot (*this, &ARDOUR_UI::_auditioning_changed), onoff));
490 ARDOUR_UI::audition_alert_toggle ()
493 session->cancel_audition();
498 ARDOUR_UI::solo_alert_toggle ()
501 session->set_all_solo (!session->soloing());
506 ARDOUR_UI::solo_blink (bool onoff)
512 if (session->soloing()) {
514 solo_alert_button.set_state (GTK_STATE_ACTIVE);
516 solo_alert_button.set_state (GTK_STATE_NORMAL);
519 solo_alert_button.set_active (false);
520 solo_alert_button.set_state (GTK_STATE_NORMAL);
525 ARDOUR_UI::audition_blink (bool onoff)
531 if (session->is_auditioning()) {
533 auditioning_alert_button.set_state (GTK_STATE_ACTIVE);
535 auditioning_alert_button.set_state (GTK_STATE_NORMAL);
538 auditioning_alert_button.set_active (false);
539 auditioning_alert_button.set_state (GTK_STATE_NORMAL);
545 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
551 switch (ev->button) {
553 Gtk::Main::grab_add (shuttle_box);
554 shuttle_grabbed = true;
555 mouse_shuttle (ev->x, true);
573 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
579 switch (ev->button) {
581 mouse_shuttle (ev->x, true);
582 shuttle_grabbed = false;
583 Gtk::Main::grab_remove (shuttle_box);
584 if (shuttle_behaviour == Sprung) {
585 shuttle_fract = SHUTTLE_FRACT_SPEED1;
586 session->request_transport_speed (1.0);
587 shuttle_box.queue_draw ();
592 if (session->transport_rolling()) {
593 shuttle_fract = SHUTTLE_FRACT_SPEED1;
594 session->request_transport_speed (1.0);
598 shuttle_box.queue_draw ();
605 shuttle_fract += 0.005;
608 shuttle_fract -= 0.005;
612 use_shuttle_fract (true);
618 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
620 if (!session || !shuttle_grabbed) {
624 return mouse_shuttle (ev->x, false);
628 ARDOUR_UI::mouse_shuttle (double x, bool force)
630 double half_width = shuttle_box.width() / 2.0;
631 double distance = x - half_width;
634 distance = min (distance, half_width);
636 distance = max (distance, -half_width);
639 shuttle_fract = distance / half_width;
640 use_shuttle_fract (force);
645 ARDOUR_UI::use_shuttle_fract (bool force)
650 /* do not attempt to submit a motion-driven transport speed request
651 more than once per process cycle.
654 gettimeofday (&now, 0);
655 timersub (&now, &last_shuttle_request, &diff);
657 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
661 last_shuttle_request = now;
663 bool neg = (shuttle_fract < 0.0);
665 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
671 session->request_transport_speed (8.0 * fract); // Formula A2
672 shuttle_box.queue_draw ();
676 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
679 Gdk_Window win (shuttle_box.get_window());
681 /* redraw the background */
683 win.draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
685 event->area.x, event->area.y,
686 event->area.width, event->area.height);
689 x = (gint) floor ((shuttle_box.width() / 2.0) + (0.5 * (shuttle_box.width() * shuttle_fract)));
693 win.draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
697 shuttle_box.height());
702 ARDOUR_UI::shuttle_style_clicked ()
704 shuttle_style_menu.popup (1, 0);
708 ARDOUR_UI::shuttle_unit_clicked ()
710 shuttle_unit_menu.popup (1, 0);
714 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
716 switch ((shuttle_units = u)) {
718 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text ("% ");
721 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text (_("st"));
727 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
729 switch ((shuttle_behaviour = b)) {
731 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("sprung"));
733 shuttle_box.queue_draw ();
735 if (session->transport_rolling()) {
736 shuttle_fract = SHUTTLE_FRACT_SPEED1;
737 session->request_transport_speed (1.0);
742 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("wheel"));
748 ARDOUR_UI::update_speed_display ()
751 speed_display_label.set_text (_("stopped"));
756 float x = session->transport_speed ();
759 if (shuttle_units == Percentage) {
760 snprintf (buf, sizeof (buf), "%.4f", x);
763 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
765 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
768 speed_display_label.set_text (buf);
770 speed_display_label.set_text (_("stopped"));
775 ARDOUR_UI::set_transport_sensitivity (bool yn)
777 goto_start_button.set_sensitive (yn);
778 goto_end_button.set_sensitive (yn);
779 roll_button.set_sensitive (yn);
780 stop_button.set_sensitive (yn);
781 play_selection_button.set_sensitive (yn);
782 rec_button.set_sensitive (yn);
783 auto_loop_button.set_sensitive (yn);
784 shuttle_box.set_sensitive (yn);