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;
56 ARDOUR_UI::setup_windows ()
58 using namespace Menu_Helpers;
60 if (create_editor ()) {
61 error << _("UI: cannot setup editor") << endmsg;
65 if (create_mixer ()) {
66 error << _("UI: cannot setup mixer") << endmsg;
70 /* all other dialogs are created conditionally */
72 we_have_dependents ();
79 top_packer.pack_start (menu_bar_base, false, false);
80 top_packer.pack_start (transport_frame, false, false);
82 editor->add_toplevel_controls (top_packer);
89 ARDOUR_UI::setup_adjustables ()
92 adjuster_table.set_homogeneous (true);
94 online_control_strings.push_back (_("MMC + Local"));
95 online_control_strings.push_back (_("MMC"));
96 online_control_strings.push_back (_("Local"));
98 online_control_button = new GlobalClickBox ("CONTROL",
99 online_control_strings);
101 online_control_button->adjustment.signal_value_changed().connect(mem_fun(*this,&ARDOUR_UI::control_methods_adjusted));
103 mmc_id_strings.push_back ("1");
104 mmc_id_strings.push_back ("2");
105 mmc_id_strings.push_back ("3");
106 mmc_id_strings.push_back ("4");
107 mmc_id_strings.push_back ("5");
108 mmc_id_strings.push_back ("6");
109 mmc_id_strings.push_back ("7");
110 mmc_id_strings.push_back ("8");
111 mmc_id_strings.push_back ("9");
113 mmc_id_button = new GlobalClickBox (_("MMC ID"), mmc_id_strings);
115 mmc_id_button->adjustment.signal_value_changed().connect (mem_fun(*this,&ARDOUR_UI::mmc_device_id_adjusted));
117 adjuster_table.attach (*online_control_button, 0, 2, 1, 2, FILL|EXPAND, FILL, 5, 5);
118 adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, FILL, FILL, 5, 5);
121 #include "transport_xpms"
124 ARDOUR_UI::transport_stopped ()
126 roll_button.set_active (false);
127 play_selection_button.set_active (false);
128 auto_loop_button.set_active (false);
131 shuttle_box.queue_draw ();
133 update_disk_space ();
136 static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
139 ARDOUR_UI::transport_rolling ()
141 if (session->get_play_range()) {
143 play_selection_button.set_active (true);
144 roll_button.set_active (false);
145 auto_loop_button.set_active (false);
147 } else if (session->get_auto_loop ()) {
149 auto_loop_button.set_active (true);
150 play_selection_button.set_active (false);
151 roll_button.set_active (false);
155 roll_button.set_active (true);
156 play_selection_button.set_active (false);
157 auto_loop_button.set_active (false);
160 /* reset shuttle controller */
162 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
163 shuttle_box.queue_draw ();
167 ARDOUR_UI::transport_rewinding ()
169 roll_button.set_active (true);
170 play_selection_button.set_active (false);
171 auto_loop_button.set_active (false);
175 ARDOUR_UI::transport_forwarding ()
177 roll_button.set_active (true);
178 play_selection_button.set_active (false);
179 auto_loop_button.set_active (false);
183 ARDOUR_UI::setup_transport ()
185 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
186 transport_tearoff->set_name ("TransportBase");
188 transport_hbox.pack_start (*transport_tearoff, true, false);
190 transport_base.set_name ("TransportBase");
191 transport_base.add (transport_hbox);
193 transport_frame.set_shadow_type (Gtk::SHADOW_OUT);
194 transport_frame.set_name ("BaseFrame");
195 transport_frame.add (transport_base);
197 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Gtk::Box*>(&top_packer),
198 static_cast<Gtk::Widget*>(&transport_frame)));
199 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Gtk::Box*> (&top_packer),
200 static_cast<Gtk::Widget*> (&transport_frame), 1));
203 goto_start_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(start_xpm)))));
204 goto_end_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(end_xpm)))));
205 roll_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(arrow_xpm)))));
207 stop_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(stop_xpm)))));
208 play_selection_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(play_selection_xpm)))));
209 rec_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(rec_xpm)))));
210 auto_loop_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)))));
212 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
213 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
214 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
215 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
216 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
217 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
218 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
219 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
220 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
221 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
222 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
223 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
224 ARDOUR_UI::instance()->tooltips().set_tip (follow_button, _("Enable/Disable follow playhead"));
225 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
226 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
227 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_style_button, _("Select sprung or wheel behaviour"));
228 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
230 shuttle_box.set_flags (CAN_FOCUS);
231 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);
232 shuttle_box.set_size_request (100, 15);
234 shuttle_box.set_name ("TransportButton");
235 goto_start_button.set_name ("TransportButton");
236 goto_end_button.set_name ("TransportButton");
237 roll_button.set_name ("TransportButton");
238 stop_button.set_name ("TransportButton");
239 play_selection_button.set_name ("TransportButton");
240 rec_button.set_name ("TransportRecButton");
241 auto_loop_button.set_name ("TransportButton");
242 auto_return_button.set_name ("TransportButton");
243 auto_play_button.set_name ("TransportButton");
244 auto_input_button.set_name ("TransportButton");
245 punch_in_button.set_name ("TransportButton");
246 punch_out_button.set_name ("TransportButton");
247 click_button.set_name ("TransportButton");
248 follow_button.set_name ("TransportButton");
250 goto_start_button.unset_flags (Gtk::CAN_FOCUS);
251 goto_end_button.unset_flags (Gtk::CAN_FOCUS);
252 roll_button.unset_flags (Gtk::CAN_FOCUS);
253 stop_button.unset_flags (Gtk::CAN_FOCUS);
254 play_selection_button.unset_flags (Gtk::CAN_FOCUS);
255 rec_button.unset_flags (Gtk::CAN_FOCUS);
256 auto_loop_button.unset_flags (Gtk::CAN_FOCUS);
257 auto_return_button.unset_flags (Gtk::CAN_FOCUS);
258 auto_play_button.unset_flags (Gtk::CAN_FOCUS);
259 auto_input_button.unset_flags (Gtk::CAN_FOCUS);
260 punch_out_button.unset_flags (Gtk::CAN_FOCUS);
261 punch_in_button.unset_flags (Gtk::CAN_FOCUS);
262 click_button.unset_flags (Gtk::CAN_FOCUS);
263 follow_button.unset_flags (Gtk::CAN_FOCUS);
265 goto_start_button.set_events (goto_start_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
266 goto_end_button.set_events (goto_end_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
267 roll_button.set_events (roll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
268 stop_button.set_events (stop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
269 play_selection_button.set_events (play_selection_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
270 rec_button.set_events (rec_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
271 auto_loop_button.set_events (auto_loop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
272 auto_return_button.set_events (auto_return_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
273 auto_play_button.set_events (auto_play_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
274 auto_input_button.set_events (auto_input_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
275 click_button.set_events (click_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
276 follow_button.set_events (click_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
277 punch_in_button.set_events (punch_in_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
278 punch_out_button.set_events (punch_out_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
280 goto_start_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_start));
281 goto_end_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_end));
283 roll_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_roll));
284 play_selection_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_play_selection));
285 auto_loop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_loop));
287 stop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_stop));
288 rec_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_record));
290 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
291 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
292 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
293 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
297 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
298 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
300 primary_clock.set_mode (AudioClock::SMPTE);
301 primary_clock.set_name ("TransportClockDisplay");
302 secondary_clock.set_mode (AudioClock::BBT);
303 secondary_clock.set_name ("TransportClockDisplay");
306 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
307 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
309 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
310 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
314 auto_return_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_return));
315 auto_play_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_play));
316 auto_input_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_input));
317 click_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_click));
318 follow_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_follow));
319 punch_in_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_in));
320 punch_out_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_out));
322 preroll_button.unset_flags (Gtk::CAN_FOCUS);
323 preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
324 preroll_button.set_name ("TransportButton");
326 postroll_button.unset_flags (Gtk::CAN_FOCUS);
327 postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
328 postroll_button.set_name ("TransportButton");
330 preroll_clock.set_mode (AudioClock::MinSec);
331 preroll_clock.set_name ("TransportClockDisplay");
332 postroll_clock.set_mode (AudioClock::MinSec);
333 postroll_clock.set_name ("TransportClockDisplay");
337 /* CANNOT bind these to clicked or toggled, must use pressed or released */
339 solo_alert_button.set_name ("TransportSoloAlert");
340 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
341 auditioning_alert_button.set_name ("TransportAuditioningAlert");
342 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
344 alert_box.pack_start (solo_alert_button);
345 alert_box.pack_start (auditioning_alert_button);
347 transport_tearoff_hbox.set_border_width (5);
349 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
350 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
352 Gtk::Frame* sframe = manage (new Frame);
353 Gtk::VBox* svbox = manage (new VBox);
354 Gtk::HBox* shbox = manage (new HBox);
356 sframe->set_shadow_type (Gtk::SHADOW_IN);
357 sframe->add (shuttle_box);
359 shuttle_box.set_name (X_("ShuttleControl"));
361 speed_display_box.add (speed_display_label);
362 set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
363 speed_display_box.set_name (X_("ShuttleDisplay"));
365 shuttle_units_button.set_name (X_("ShuttleButton"));
366 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
368 shuttle_style_button.set_name (X_("ShuttleButton"));
369 shuttle_style_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_style_clicked));
371 Gtk::Frame* sdframe = manage (new Frame);
373 sdframe->set_shadow_type (Gtk::SHADOW_IN);
374 sdframe->add (speed_display_box);
376 shbox->pack_start (*sdframe, false, false);
377 shbox->pack_start (shuttle_units_button, true, true);
378 shbox->pack_start (shuttle_style_button, false, false);
380 svbox->pack_start (*sframe, false, false);
381 svbox->pack_start (*shbox, false, false);
383 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
385 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
386 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
387 transport_tearoff_hbox.pack_start (roll_button, false, false);
388 transport_tearoff_hbox.pack_start (stop_button, false, false);
389 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
391 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
392 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
394 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
395 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
396 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
397 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
398 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
399 transport_tearoff_hbox.pack_start (click_button, false, false);
400 transport_tearoff_hbox.pack_start (follow_button, false, false);
404 set_transport_sensitivity (false);
406 /* catch up with editor state */
410 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
411 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
413 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
414 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
416 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
420 ARDOUR_UI::setup_clock ()
422 ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
424 big_clock_window = new Gtk::Window (WINDOW_TOPLEVEL);
426 big_clock_window->set_border_width (0);
427 big_clock_window->add (big_clock);
428 big_clock_window->set_title (_("ardour: clock"));
429 big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
430 big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
431 big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
433 manage_window (*big_clock_window);
437 ARDOUR_UI::manage_window (Window& win)
439 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
440 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
441 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
445 ARDOUR_UI::detach_tearoff (Gtk::Box* b, Gtk::Widget* w)
447 editor->ensure_float (*transport_tearoff->tearoff_window());
452 ARDOUR_UI::reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n)
455 b->reorder_child (*w, n);
459 ARDOUR_UI::soloing_changed (bool onoff)
461 if (solo_alert_button.get_active() != onoff) {
462 solo_alert_button.set_active (onoff);
467 ARDOUR_UI::_auditioning_changed (bool onoff)
469 if (auditioning_alert_button.get_active() != onoff) {
470 auditioning_alert_button.set_active (onoff);
471 set_transport_sensitivity (!onoff);
476 ARDOUR_UI::auditioning_changed (bool onoff)
478 Gtkmm2ext::UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
482 ARDOUR_UI::audition_alert_toggle ()
485 session->cancel_audition();
490 ARDOUR_UI::solo_alert_toggle ()
493 session->set_all_solo (!session->soloing());
498 ARDOUR_UI::solo_blink (bool onoff)
504 if (session->soloing()) {
506 solo_alert_button.set_state (Gtk::STATE_ACTIVE);
508 solo_alert_button.set_state (Gtk::STATE_NORMAL);
511 solo_alert_button.set_active (false);
512 solo_alert_button.set_state (Gtk::STATE_NORMAL);
517 ARDOUR_UI::audition_blink (bool onoff)
523 if (session->is_auditioning()) {
525 auditioning_alert_button.set_state (Gtk::STATE_ACTIVE);
527 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
530 auditioning_alert_button.set_active (false);
531 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
537 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
543 switch (ev->button) {
545 shuttle_box.add_modal_grab ();
546 shuttle_grabbed = true;
547 mouse_shuttle (ev->x, true);
565 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
571 switch (ev->button) {
573 mouse_shuttle (ev->x, true);
574 shuttle_grabbed = false;
575 shuttle_box.remove_modal_grab ();
576 if (shuttle_behaviour == Sprung) {
577 shuttle_fract = SHUTTLE_FRACT_SPEED1;
578 session->request_transport_speed (1.0);
579 shuttle_box.queue_draw ();
584 if (session->transport_rolling()) {
585 shuttle_fract = SHUTTLE_FRACT_SPEED1;
586 session->request_transport_speed (1.0);
590 shuttle_box.queue_draw ();
597 shuttle_fract += 0.005;
600 shuttle_fract -= 0.005;
604 use_shuttle_fract (true);
610 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
612 if (!session || !shuttle_grabbed) {
616 return mouse_shuttle (ev->x, false);
620 ARDOUR_UI::mouse_shuttle (double x, bool force)
622 double half_width = shuttle_box.get_width() / 2.0;
623 double distance = x - half_width;
626 distance = min (distance, half_width);
628 distance = max (distance, -half_width);
631 shuttle_fract = distance / half_width;
632 use_shuttle_fract (force);
637 ARDOUR_UI::use_shuttle_fract (bool force)
642 /* do not attempt to submit a motion-driven transport speed request
643 more than once per process cycle.
646 gettimeofday (&now, 0);
647 timersub (&now, &last_shuttle_request, &diff);
649 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
653 last_shuttle_request = now;
655 bool neg = (shuttle_fract < 0.0);
657 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
663 session->request_transport_speed (8.0 * fract); // Formula A2
664 shuttle_box.queue_draw ();
668 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
671 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
673 /* redraw the background */
675 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
677 event->area.x, event->area.y,
678 event->area.width, event->area.height);
681 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
685 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
689 shuttle_box.get_height());
694 ARDOUR_UI::shuttle_style_clicked ()
696 if (shuttle_style_menu == 0) {
697 shuttle_style_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("ShuttleStylePopup"));
699 shuttle_style_menu->popup (1, 0);
703 ARDOUR_UI::shuttle_unit_clicked ()
705 if (shuttle_unit_menu == 0) {
706 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("ShuttleUnitPopup"));
708 shuttle_unit_menu->popup (1, 0);
712 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
714 switch ((shuttle_units = u)) {
716 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text ("% ");
719 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text (_("st"));
725 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
727 switch ((shuttle_behaviour = b)) {
729 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("sprung"));
731 shuttle_box.queue_draw ();
733 if (session->transport_rolling()) {
734 shuttle_fract = SHUTTLE_FRACT_SPEED1;
735 session->request_transport_speed (1.0);
740 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("wheel"));
746 ARDOUR_UI::update_speed_display ()
749 speed_display_label.set_text (_("stopped"));
754 float x = session->transport_speed ();
757 if (shuttle_units == Percentage) {
758 snprintf (buf, sizeof (buf), "%.4f", x);
761 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
763 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
766 speed_display_label.set_text (buf);
768 speed_display_label.set_text (_("stopped"));
773 ARDOUR_UI::set_transport_sensitivity (bool yn)
775 goto_start_button.set_sensitive (yn);
776 goto_end_button.set_sensitive (yn);
777 roll_button.set_sensitive (yn);
778 stop_button.set_sensitive (yn);
779 play_selection_button.set_sensitive (yn);
780 rec_button.set_sensitive (yn);
781 auto_loop_button.set_sensitive (yn);
782 shuttle_box.set_sensitive (yn);