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.
27 #include <sigc++/bind.h>
28 #include <pbd/error.h>
29 #include <pbd/basename.h>
30 #include <pbd/fastlog.h>
31 #include <gtkmm2ext/utils.h>
32 #include <gtkmm2ext/click_box.h>
33 #include <gtkmm2ext/tearoff.h>
35 #include <ardour/audioengine.h>
36 #include <ardour/ardour.h>
37 #include <ardour/profile.h>
38 #include <ardour/route.h>
40 #include "ardour_ui.h"
42 #include "public_editor.h"
43 #include "audio_clock.h"
46 #include "theme_manager.h"
51 using namespace ARDOUR;
53 using namespace Gtkmm2ext;
59 ARDOUR_UI::setup_windows ()
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 ();
79 theme_manager->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleThemeManager")));
82 HBox* status_bar_packer = manage (new HBox);
84 status_bar_label.set_size_request (300, -1);
85 status_bar_packer->pack_start (status_bar_label, true, true, 6);
86 status_bar_packer->pack_start (error_log_button, false, false);
88 error_log_button.signal_clicked().connect (mem_fun (*this, &UI::toggle_errors));
90 editor->get_status_bar_packer().pack_start (*status_bar_packer, true, true);
91 editor->get_status_bar_packer().pack_start (menu_bar_base, false, false, 6);
93 top_packer.pack_start (menu_bar_base, false, false);
95 top_packer.pack_start (transport_frame, false, false);
97 editor->add_toplevel_controls (top_packer);
103 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
107 UI::display_message (prefix, prefix_len, ptag, mtag, msg);
110 if (strcmp (prefix, _("[ERROR]: ")) == 0) {
111 text = "<span color=\"red\" weight=\"bold\">";
112 } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
113 text = "<span color=\"yellow\" weight=\"bold\">";
114 } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
115 text = "<span color=\"green\" weight=\"bold\">";
117 text = "<span color=\"blue\" weight=\"bold\">???";
124 status_bar_label.set_markup (text);
129 ARDOUR_UI::setup_transport ()
131 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
132 transport_tearoff->set_name ("TransportBase");
133 transport_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &transport_tearoff->tearoff_window()));
135 if (Profile->get_sae()) {
136 transport_tearoff->set_can_be_torn_off (false);
139 transport_hbox.pack_start (*transport_tearoff, true, false);
141 transport_base.set_name ("TransportBase");
142 transport_base.add (transport_hbox);
144 transport_frame.set_shadow_type (SHADOW_OUT);
145 transport_frame.set_name ("BaseFrame");
146 transport_frame.add (transport_base);
148 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
149 static_cast<Widget*>(&transport_frame)));
150 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
151 static_cast<Widget*> (&transport_frame), 1));
152 transport_tearoff->Hidden.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
153 static_cast<Widget*>(&transport_frame)));
154 transport_tearoff->Visible.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
155 static_cast<Widget*> (&transport_frame), 1));
157 shuttle_box.set_name ("TransportButton");
158 goto_start_button.set_name ("TransportButton");
159 goto_end_button.set_name ("TransportButton");
160 roll_button.set_name ("TransportButton");
161 stop_button.set_name ("TransportButton");
162 play_selection_button.set_name ("TransportButton");
163 rec_button.set_name ("TransportRecButton");
164 auto_loop_button.set_name ("TransportButton");
166 auto_return_button.set_name ("TransportButton");
167 auto_play_button.set_name ("TransportButton");
168 auto_input_button.set_name ("TransportButton");
169 punch_in_button.set_name ("TransportButton");
170 punch_out_button.set_name ("TransportButton");
171 click_button.set_name ("TransportButton");
172 time_master_button.set_name ("TransportButton");
174 stop_button.set_size_request(29, -1);
175 roll_button.set_size_request(29, -1);
176 auto_loop_button.set_size_request(29, -1);
177 play_selection_button.set_size_request(29, -1);
178 goto_start_button.set_size_request(29, -1);
179 goto_end_button.set_size_request(29, -1);
180 rec_button.set_size_request(29, -1);
184 stop_button.set_visual_state (1);
186 w = manage (new Image (get_icon (X_("transport_start"))));
188 goto_start_button.add (*w);
189 w = manage (new Image (get_icon (X_("transport_end"))));
191 goto_end_button.add (*w);
192 w = manage (new Image (get_icon (X_("transport_play"))));
194 roll_button.add (*w);
195 w = manage (new Image (get_icon (X_("transport_stop"))));
197 stop_button.add (*w);
198 w = manage (new Image (get_icon (X_("transport_range"))));
200 play_selection_button.add (*w);
201 w = manage (new Image (get_icon (X_("transport_record"))));
204 w = manage (new Image (get_icon (X_("transport_loop"))));
206 auto_loop_button.add (*w);
210 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
211 act->connect_proxy (stop_button);
212 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
213 act->connect_proxy (roll_button);
214 act = ActionManager::get_action (X_("Transport"), X_("Record"));
215 act->connect_proxy (rec_button);
216 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
217 act->connect_proxy (goto_start_button);
218 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
219 act->connect_proxy (goto_end_button);
220 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
221 act->connect_proxy (auto_loop_button);
222 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
223 act->connect_proxy (play_selection_button);
224 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
225 act->connect_proxy (time_master_button);
227 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
228 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
229 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
230 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
231 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
232 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
234 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
235 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
236 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
237 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
238 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
239 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
240 ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo, _("Positional sync source"));
241 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
242 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
243 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
244 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
246 shuttle_box.set_flags (CAN_FOCUS);
247 shuttle_box.add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK);
248 shuttle_box.set_size_request (100, 15);
250 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
251 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
252 shuttle_box.signal_scroll_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll));
253 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
254 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
258 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), 1));
259 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), 2));
261 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
262 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
263 big_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
265 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
266 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
268 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button);
269 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button);
270 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button);
271 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button);
272 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
273 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
275 preroll_button.set_name ("TransportButton");
276 postroll_button.set_name ("TransportButton");
278 preroll_clock.set_mode (AudioClock::MinSec);
279 preroll_clock.set_name ("TransportClockDisplay");
280 postroll_clock.set_mode (AudioClock::MinSec);
281 postroll_clock.set_name ("TransportClockDisplay");
285 /* CANNOT bind these to clicked or toggled, must use pressed or released */
287 solo_alert_button.set_name ("TransportSoloAlert");
288 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
289 auditioning_alert_button.set_name ("TransportAuditioningAlert");
290 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
292 tooltips().set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
293 tooltips().set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition"));
295 alert_box.pack_start (solo_alert_button, false, false);
296 alert_box.pack_start (auditioning_alert_button, false, false);
298 transport_tearoff_hbox.set_border_width (3);
300 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
301 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
303 Frame* sframe = manage (new Frame);
304 VBox* svbox = manage (new VBox);
305 HBox* shbox = manage (new HBox);
307 sframe->set_shadow_type (SHADOW_IN);
308 sframe->add (shuttle_box);
310 shuttle_box.set_name (X_("ShuttleControl"));
312 speed_display_box.add (speed_display_label);
313 speed_display_box.set_name (X_("ShuttleDisplay"));
314 set_size_request_to_display_given_text (speed_display_label, X_("> 24.0"), 2, 2);
316 shuttle_units_button.set_name (X_("ShuttleButton"));
317 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
319 shuttle_style_button.set_name (X_("ShuttleStyleButton"));
321 vector<string> shuttle_strings;
322 shuttle_strings.push_back (_("sprung"));
323 shuttle_strings.push_back (_("wheel"));
324 set_popdown_strings (shuttle_style_button, shuttle_strings, true);
325 shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
327 Frame* sdframe = manage (new Frame);
329 sdframe->set_shadow_type (SHADOW_IN);
330 sdframe->add (speed_display_box);
333 sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
334 // XXX HOW TO USE set_popdown_strings() and combo_fudge with this when we don't know
335 // the real strings till later?
336 set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 4+COMBO_FUDGE, 10);
338 shbox->pack_start (*sdframe, false, false);
339 shbox->pack_start (shuttle_units_button, true, true);
340 shbox->pack_start (shuttle_style_button, false, false);
342 svbox->pack_start (*sframe, false, false);
343 svbox->pack_start (*shbox, false, false);
345 transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
347 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
348 if (!Profile->get_sae()) {
349 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
351 transport_tearoff_hbox.pack_start (roll_button, false, false);
352 transport_tearoff_hbox.pack_start (stop_button, false, false);
353 transport_tearoff_hbox.pack_start (rec_button, false, false, 6);
355 HBox* clock_box = manage (new HBox);
356 clock_box->pack_start (primary_clock, false, false);
357 if (!ARDOUR::Profile->get_small_screen()) {
358 clock_box->pack_start (secondary_clock, false, false);
361 if (!Profile->get_sae()) {
362 VBox* time_controls_box = manage (new VBox);
363 time_controls_box->pack_start (sync_option_combo, false, false);
364 time_controls_box->pack_start (time_master_button, false, false);
365 clock_box->pack_start (*time_controls_box, false, false, 1);
368 transport_tearoff_hbox.pack_start (*clock_box, false, false, 0);
370 HBox* toggle_box = manage(new HBox);
372 VBox* punch_box = manage (new VBox);
373 punch_box->pack_start (punch_in_button, false, false);
374 punch_box->pack_start (punch_out_button, false, false);
375 toggle_box->pack_start (*punch_box, false, false);
377 VBox* auto_box = manage (new VBox);
378 auto_box->pack_start (auto_play_button, false, false);
379 auto_box->pack_start (auto_return_button, false, false);
380 toggle_box->pack_start (*auto_box, false, false);
382 VBox* io_box = manage (new VBox);
383 io_box->pack_start (auto_input_button, false, false);
384 io_box->pack_start (click_button, false, false);
385 toggle_box->pack_start (*io_box, false, false);
389 set_transport_sensitivity (false);
391 // toggle_box->pack_start (preroll_button, false, false);
392 // toggle_box->pack_start (preroll_clock, false, false);
394 // toggle_box->pack_start (postroll_button, false, false);
395 // toggle_box->pack_start (postroll_clock, false, false);
397 transport_tearoff_hbox.pack_start (*toggle_box, false, false, 4);
398 transport_tearoff_hbox.pack_start (alert_box, false, false);
400 if (Profile->get_sae()) {
401 Image* img = manage (new Image ((::get_icon (X_("sae")))));
402 transport_tearoff_hbox.pack_end (*img, false, false, 6);
407 ARDOUR_UI::manage_window (Window& win)
409 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
410 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
411 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
415 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
417 // editor->ensure_float (transport_tearoff->tearoff_window());
422 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
425 b->reorder_child (*w, n);
429 ARDOUR_UI::soloing_changed (bool onoff)
431 if (solo_alert_button.get_active() != onoff) {
432 solo_alert_button.set_active (onoff);
437 ARDOUR_UI::_auditioning_changed (bool onoff)
439 if (auditioning_alert_button.get_active() != onoff) {
440 auditioning_alert_button.set_active (onoff);
441 set_transport_sensitivity (!onoff);
446 ARDOUR_UI::auditioning_changed (bool onoff)
448 UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
452 ARDOUR_UI::audition_alert_toggle ()
455 session->cancel_audition();
460 ARDOUR_UI::solo_alert_toggle ()
463 session->set_all_solo (!session->soloing());
468 ARDOUR_UI::solo_blink (bool onoff)
474 if (session->soloing()) {
476 solo_alert_button.set_state (STATE_ACTIVE);
478 solo_alert_button.set_state (STATE_NORMAL);
481 solo_alert_button.set_active (false);
482 solo_alert_button.set_state (STATE_NORMAL);
487 ARDOUR_UI::audition_blink (bool onoff)
493 if (session->is_auditioning()) {
495 auditioning_alert_button.set_state (STATE_ACTIVE);
497 auditioning_alert_button.set_state (STATE_NORMAL);
500 auditioning_alert_button.set_active (false);
501 auditioning_alert_button.set_state (STATE_NORMAL);
506 ARDOUR_UI::build_shuttle_context_menu ()
508 using namespace Menu_Helpers;
510 shuttle_context_menu = new Menu();
511 MenuList& items = shuttle_context_menu->items();
513 Menu* speed_menu = manage (new Menu());
514 MenuList& speed_items = speed_menu->items();
516 RadioMenuItem::Group group;
518 speed_items.push_back (RadioMenuElem (group, "8", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 8.0f)));
519 if (shuttle_max_speed == 8.0) {
520 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
522 speed_items.push_back (RadioMenuElem (group, "6", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 6.0f)));
523 if (shuttle_max_speed == 6.0) {
524 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
526 speed_items.push_back (RadioMenuElem (group, "4", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 4.0f)));
527 if (shuttle_max_speed == 4.0) {
528 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
530 speed_items.push_back (RadioMenuElem (group, "3", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 3.0f)));
531 if (shuttle_max_speed == 3.0) {
532 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
534 speed_items.push_back (RadioMenuElem (group, "2", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 2.0f)));
535 if (shuttle_max_speed == 2.0) {
536 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
538 speed_items.push_back (RadioMenuElem (group, "1.5", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 1.5f)));
539 if (shuttle_max_speed == 1.5) {
540 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
543 items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
547 ARDOUR_UI::show_shuttle_context_menu ()
549 if (shuttle_context_menu == 0) {
550 build_shuttle_context_menu ();
553 shuttle_context_menu->popup (1, gtk_get_current_event_time());
557 ARDOUR_UI::set_shuttle_max_speed (float speed)
559 shuttle_max_speed = speed;
563 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
569 if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
573 if (Keyboard::is_context_menu_event (ev)) {
574 show_shuttle_context_menu ();
578 switch (ev->button) {
580 shuttle_box.add_modal_grab ();
581 shuttle_grabbed = true;
582 mouse_shuttle (ev->x, true);
595 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
601 switch (ev->button) {
603 mouse_shuttle (ev->x, true);
604 shuttle_grabbed = false;
605 shuttle_box.remove_modal_grab ();
606 if (Config->get_shuttle_behaviour() == Sprung) {
607 if (Config->get_auto_play() || roll_button.get_visual_state()) {
608 shuttle_fract = SHUTTLE_FRACT_SPEED1;
609 session->request_transport_speed (1.0);
610 stop_button.set_visual_state (0);
611 roll_button.set_visual_state (1);
614 session->request_transport_speed (0.0);
616 shuttle_box.queue_draw ();
621 if (session->transport_rolling()) {
622 shuttle_fract = SHUTTLE_FRACT_SPEED1;
623 session->request_transport_speed (1.0);
624 stop_button.set_visual_state (0);
625 roll_button.set_visual_state (1);
629 shuttle_box.queue_draw ();
638 use_shuttle_fract (true);
644 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll* ev)
650 switch (ev->direction) {
653 shuttle_fract += 0.005;
655 case GDK_SCROLL_DOWN:
656 shuttle_fract -= 0.005;
659 /* scroll left/right */
663 use_shuttle_fract (true);
669 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
671 if (!session || !shuttle_grabbed) {
675 return mouse_shuttle (ev->x, false);
679 ARDOUR_UI::mouse_shuttle (double x, bool force)
681 double half_width = shuttle_box.get_width() / 2.0;
682 double distance = x - half_width;
685 distance = min (distance, half_width);
687 distance = max (distance, -half_width);
690 shuttle_fract = distance / half_width;
691 use_shuttle_fract (force);
696 ARDOUR_UI::set_shuttle_fract (double f)
699 use_shuttle_fract (false);
703 ARDOUR_UI::use_shuttle_fract (bool force)
705 microseconds_t now = get_microseconds();
707 /* do not attempt to submit a motion-driven transport speed request
708 more than once per process cycle.
711 if (!force && (last_shuttle_request - now) < (microseconds_t) engine->usecs_per_cycle()) {
715 last_shuttle_request = now;
717 if (Config->get_shuttle_units() == Semitones) {
719 const double step = 1.0 / 24.0; // range is 24 semitones up & down
723 semitones = round (shuttle_fract / step);
724 speed = pow (2.0, (semitones / 12.0));
726 session->request_transport_speed (speed);
733 neg = (shuttle_fract < 0.0);
735 fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
741 session->request_transport_speed (shuttle_max_speed * fract);
744 shuttle_box.queue_draw ();
748 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
751 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
753 /* redraw the background */
755 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
757 event->area.x, event->area.y,
758 event->area.width, event->area.height);
761 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
765 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
769 shuttle_box.get_height());
774 ARDOUR_UI::shuttle_unit_clicked ()
776 if (shuttle_unit_menu == 0) {
777 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
779 shuttle_unit_menu->popup (1, gtk_get_current_event_time());
783 ARDOUR_UI::shuttle_style_changed ()
785 ustring str = shuttle_style_button.get_active_text ();
787 if (str == _("sprung")) {
788 Config->set_shuttle_behaviour (Sprung);
789 } else if (str == _("wheel")) {
790 Config->set_shuttle_behaviour (Wheel);
795 ARDOUR_UI::update_speed_display ()
798 if (last_speed_displayed != 0) {
799 speed_display_label.set_text (_("stop"));
800 last_speed_displayed = 0;
806 float x = session->transport_speed ();
808 if (x != last_speed_displayed) {
811 if (Config->get_shuttle_units() == Percentage) {
812 snprintf (buf, sizeof (buf), "%.2f", x);
816 snprintf (buf, sizeof (buf), "< %d", (int) round (12.0 * fast_log2 (-x)));
818 snprintf (buf, sizeof (buf), "> %d", (int) round (12.0 * fast_log2 (x)));
821 speed_display_label.set_text (buf);
823 speed_display_label.set_text (_("stop"));
826 last_speed_displayed = x;
831 ARDOUR_UI::set_transport_sensitivity (bool yn)
833 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
834 shuttle_box.set_sensitive (yn);
838 ARDOUR_UI::editor_realized ()
840 Config->map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
842 set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
847 ARDOUR_UI::sync_option_changed ()
850 ustring txt = sync_option_combo.get_active_text ();
852 session->request_slave_source (string_to_slave_source (txt));
858 ARDOUR_UI::maximise_editing_space ()
864 transport_tearoff->set_visible (false);
865 editor->maximise_editing_space ();
869 ARDOUR_UI::restore_editing_space ()
875 transport_tearoff->set_visible (true);
876 editor->restore_editing_space ();