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/session.h"
36 #include "ardour/audioengine.h"
37 #include "ardour/ardour.h"
38 #include "ardour/profile.h"
39 #include "ardour/route.h"
41 #include "ardour_ui.h"
43 #include "public_editor.h"
44 #include "audio_clock.h"
47 #include "theme_manager.h"
52 using namespace ARDOUR;
54 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 ();
75 theme_manager->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleThemeManager")));
78 HBox* status_bar_packer = manage (new HBox);
80 status_bar_label.set_size_request (300, -1);
81 status_bar_packer->pack_start (status_bar_label, true, true, 6);
82 status_bar_packer->pack_start (error_log_button, false, false);
84 error_log_button.signal_clicked().connect (sigc::mem_fun (*this, &UI::toggle_errors));
86 editor->get_status_bar_packer().pack_start (*status_bar_packer, true, true);
87 editor->get_status_bar_packer().pack_start (menu_bar_base, false, false, 6);
89 top_packer.pack_start (menu_bar_base, false, false);
92 top_packer.pack_start (transport_frame, false, false);
94 editor->add_toplevel_controls (top_packer);
106 ARDOUR_UI::setup_tooltips ()
108 set_tip (roll_button, _("Play from playhead"));
109 set_tip (stop_button, _("Stop playback"));
110 set_tip (rec_button, _("Toggle record"));
111 set_tip (play_selection_button, _("Play range/selection"));
112 set_tip (join_play_range_button, _("Always play range/selection"));
113 set_tip (goto_start_button, _("Go to start of session"));
114 set_tip (goto_end_button, _("Go to end of session"));
115 set_tip (auto_loop_button, _("Play loop range"));
117 set_tip (auto_return_button, _("Return to last playback start when stopped"));
118 set_tip (auto_play_button, _("Start playback after any locate"));
119 set_tip (auto_input_button, _("Be sensible about input monitoring"));
120 set_tip (punch_in_button, _("Start recording at auto-punch start"));
121 set_tip (punch_out_button, _("Stop recording at auto-punch end"));
122 set_tip (click_button, _("Enable/Disable audio click"));
123 set_tip (sync_button, _("Enable/Disable external positional sync"));
124 set_tip (time_master_button, string_compose (_("Does %1 control the time?"), PROGRAM_NAME));
125 set_tip (shuttle_box, _("Shuttle speed control"));
126 set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
127 set_tip (speed_display_box, _("Current transport speed"));
128 set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
129 set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition"));
130 set_tip (primary_clock, _("Primary clock"));
131 set_tip (secondary_clock, _("secondary clock"));
133 editor->setup_tooltips ();
137 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
141 UI::display_message (prefix, prefix_len, ptag, mtag, msg);
144 if (strcmp (prefix, _("[ERROR]: ")) == 0) {
145 text = "<span color=\"red\" weight=\"bold\">";
146 } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
147 text = "<span color=\"yellow\" weight=\"bold\">";
148 } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
149 text = "<span color=\"green\" weight=\"bold\">";
151 text = "<span color=\"white\" weight=\"bold\">???";
158 status_bar_label.set_markup (text);
163 ARDOUR_UI::tearoff_settings (const char* name) const
165 XMLNode* ui_node = Config->extra_xml(X_("UI"));
168 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
170 XMLNode* mnode = tearoff_node->child (name);
179 ARDOUR_UI::setup_transport ()
181 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
182 transport_tearoff->set_name ("TransportBase");
183 transport_tearoff->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), &transport_tearoff->tearoff_window()), false);
185 if (Profile->get_sae()) {
186 transport_tearoff->set_can_be_torn_off (false);
189 transport_hbox.pack_start (*transport_tearoff, true, false);
191 transport_base.set_name ("TransportBase");
192 transport_base.add (transport_hbox);
194 transport_frame.set_shadow_type (SHADOW_OUT);
195 transport_frame.set_name ("BaseFrame");
196 transport_frame.add (transport_base);
198 transport_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
199 static_cast<Widget*>(&transport_frame)));
200 transport_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
201 static_cast<Widget*> (&transport_frame), 1));
202 transport_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
203 static_cast<Widget*>(&transport_frame)));
204 transport_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
205 static_cast<Widget*> (&transport_frame), 1));
207 shuttle_box.set_name ("TransportButton");
208 goto_start_button.set_name ("TransportButton");
209 goto_end_button.set_name ("TransportButton");
210 roll_button.set_name ("TransportButton");
211 stop_button.set_name ("TransportButton");
212 play_selection_button.set_name ("TransportButton");
213 rec_button.set_name ("TransportRecButton");
214 auto_loop_button.set_name ("TransportButton");
215 join_play_range_button.set_name ("TransportButton");
217 auto_return_button.set_name ("TransportButton");
218 auto_play_button.set_name ("TransportButton");
219 auto_input_button.set_name ("TransportButton");
220 punch_in_button.set_name ("TransportButton");
221 punch_out_button.set_name ("TransportButton");
222 click_button.set_name ("TransportButton");
223 time_master_button.set_name ("TransportButton");
224 sync_button.set_name ("TransportSyncButton");
226 stop_button.set_size_request(29, -1);
227 roll_button.set_size_request(29, -1);
228 auto_loop_button.set_size_request(29, -1);
229 play_selection_button.set_size_request(29, -1);
230 goto_start_button.set_size_request(29, -1);
231 goto_end_button.set_size_request(29, -1);
232 rec_button.set_size_request(29, -1);
236 stop_button.set_visual_state (1);
238 w = manage (new Image (get_icon (X_("transport_start"))));
240 goto_start_button.add (*w);
241 w = manage (new Image (get_icon (X_("transport_end"))));
243 goto_end_button.add (*w);
244 w = manage (new Image (get_icon (X_("transport_play"))));
246 roll_button.add (*w);
247 w = manage (new Image (get_icon (X_("transport_stop"))));
249 stop_button.add (*w);
250 w = manage (new Image (get_icon (X_("transport_range"))));
252 play_selection_button.add (*w);
253 w = manage (new Image (get_icon (X_("transport_record"))));
256 w = manage (new Image (get_icon (X_("transport_loop"))));
258 auto_loop_button.add (*w);
259 w = manage (new Image (get_icon (X_("join_tools"))));
261 join_play_range_button.add (*w);
265 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
266 act->connect_proxy (stop_button);
267 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
268 act->connect_proxy (roll_button);
269 act = ActionManager::get_action (X_("Transport"), X_("Record"));
270 act->connect_proxy (rec_button);
271 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
272 act->connect_proxy (goto_start_button);
273 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
274 act->connect_proxy (goto_end_button);
275 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
276 act->connect_proxy (auto_loop_button);
277 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
278 act->connect_proxy (play_selection_button);
279 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
280 act->connect_proxy (time_master_button);
281 act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
282 act->connect_proxy (sync_button);
284 shuttle_box.set_flags (CAN_FOCUS);
285 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);
286 shuttle_box.set_size_request (100, 15);
288 shuttle_box.signal_button_press_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
289 shuttle_box.signal_button_release_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
290 shuttle_box.signal_scroll_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll));
291 shuttle_box.signal_motion_notify_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
292 shuttle_box.signal_expose_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
296 ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &AudioClock::set), 'p'));
297 ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &AudioClock::set), 's'));
299 primary_clock.ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
300 secondary_clock.ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
301 big_clock.ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
303 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button);
304 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button);
305 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button);
306 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button);
307 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
308 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
310 preroll_button.set_name ("TransportButton");
311 postroll_button.set_name ("TransportButton");
313 preroll_clock.set_mode (AudioClock::MinSec);
314 preroll_clock.set_name ("TransportClockDisplay");
315 postroll_clock.set_mode (AudioClock::MinSec);
316 postroll_clock.set_name ("TransportClockDisplay");
320 /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
322 solo_alert_button.set_name ("TransportSoloAlert");
323 solo_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::solo_alert_press), false);
324 auditioning_alert_button.set_name ("TransportAuditioningAlert");
325 auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
327 alert_box.pack_start (solo_alert_button, false, false);
328 alert_box.pack_start (auditioning_alert_button, false, false);
330 transport_tearoff_hbox.set_border_width (3);
332 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
333 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
335 Frame* sframe = manage (new Frame);
336 VBox* svbox = manage (new VBox);
337 HBox* shbox = manage (new HBox);
339 sframe->set_shadow_type (SHADOW_IN);
340 sframe->add (shuttle_box);
342 shuttle_box.set_name (X_("ShuttleControl"));
344 speed_display_box.add (speed_display_label);
345 speed_display_box.set_name (X_("ShuttleDisplay"));
346 set_size_request_to_display_given_text (speed_display_label, X_("> 24.0"), 2, 2);
348 shuttle_units_button.set_name (X_("ShuttleButton"));
349 shuttle_units_button.signal_clicked().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
351 shuttle_style_button.set_name (X_("ShuttleStyleButton"));
353 vector<string> shuttle_strings;
354 shuttle_strings.push_back (_("sprung"));
355 shuttle_strings.push_back (_("wheel"));
356 set_popdown_strings (shuttle_style_button, shuttle_strings, true);
357 shuttle_style_button.signal_changed().connect (sigc::mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
359 Frame* sdframe = manage (new Frame);
361 sdframe->set_shadow_type (SHADOW_IN);
362 sdframe->add (speed_display_box);
364 /* translators: Egternal is "External" with a descender character */
365 set_size_request_to_display_given_text (sync_button, X_("Egternal"), 4, 10);
367 shbox->pack_start (*sdframe, false, false);
368 shbox->pack_start (shuttle_units_button, true, true);
369 shbox->pack_start (shuttle_style_button, false, false);
371 svbox->pack_start (*sframe, false, false);
372 svbox->pack_start (*shbox, false, false);
374 transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
376 if (Profile->get_sae()) {
377 transport_tearoff_hbox.pack_start (auto_loop_button);
378 transport_tearoff_hbox.pack_start (roll_button);
380 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
381 play_range_hbox.pack_start (play_selection_button, false, false);
382 play_range_hbox.pack_start (roll_button, false, false);
383 play_range_vbox.pack_start (play_range_hbox, false, false);
384 play_range_vbox.pack_start (join_play_range_button, false, false);
385 transport_tearoff_hbox.pack_start (play_range_vbox, false, false);
387 transport_tearoff_hbox.pack_start (stop_button, false, false);
388 transport_tearoff_hbox.pack_start (rec_button, false, false, 6);
390 HBox* clock_box = manage (new HBox);
391 clock_box->pack_start (primary_clock, false, false);
392 if (!ARDOUR::Profile->get_small_screen()) {
393 clock_box->pack_start (secondary_clock, false, false);
396 if (!Profile->get_sae()) {
397 VBox* time_controls_box = manage (new VBox);
398 time_controls_box->pack_start (sync_button, false, false);
399 time_controls_box->pack_start (time_master_button, false, false);
400 clock_box->pack_start (*time_controls_box, false, false, 1);
403 transport_tearoff_hbox.pack_start (*clock_box, false, false, 0);
405 HBox* toggle_box = manage(new HBox);
407 VBox* punch_box = manage (new VBox);
408 punch_box->pack_start (punch_in_button, false, false);
409 punch_box->pack_start (punch_out_button, false, false);
410 toggle_box->pack_start (*punch_box, false, false);
412 VBox* auto_box = manage (new VBox);
413 auto_box->pack_start (auto_play_button, false, false);
414 auto_box->pack_start (auto_return_button, false, false);
415 toggle_box->pack_start (*auto_box, false, false);
417 VBox* io_box = manage (new VBox);
418 io_box->pack_start (auto_input_button, false, false);
419 io_box->pack_start (click_button, false, false);
420 toggle_box->pack_start (*io_box, false, false);
424 set_transport_sensitivity (false);
426 // toggle_box->pack_start (preroll_button, false, false);
427 // toggle_box->pack_start (preroll_clock, false, false);
429 // toggle_box->pack_start (postroll_button, false, false);
430 // toggle_box->pack_start (postroll_clock, false, false);
432 transport_tearoff_hbox.pack_start (*toggle_box, false, false, 4);
433 transport_tearoff_hbox.pack_start (alert_box, false, false);
435 if (Profile->get_sae()) {
436 Image* img = manage (new Image ((::get_icon (X_("sae")))));
437 transport_tearoff_hbox.pack_end (*img, false, false, 6);
440 XMLNode* tnode = tearoff_settings ("transport");
442 transport_tearoff->set_state (*tnode);
447 ARDOUR_UI::manage_window (Window& win)
449 win.signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it), &win));
450 win.signal_enter_notify_event().connect (sigc::bind (sigc::mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
451 win.signal_leave_notify_event().connect (sigc::bind (sigc::mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
455 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
457 // editor->ensure_float (transport_tearoff->tearoff_window());
462 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
465 b->reorder_child (*w, n);
469 ARDOUR_UI::soloing_changed (bool onoff)
471 if (solo_alert_button.get_active() != onoff) {
472 solo_alert_button.set_active (onoff);
477 ARDOUR_UI::_auditioning_changed (bool onoff)
479 if (auditioning_alert_button.get_active() != onoff) {
480 auditioning_alert_button.set_active (onoff);
481 set_transport_sensitivity (!onoff);
486 ARDOUR_UI::auditioning_changed (bool onoff)
488 UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
492 ARDOUR_UI::audition_alert_press (GdkEventButton* ev)
495 _session->cancel_audition();
501 ARDOUR_UI::solo_alert_press (GdkEventButton* ev)
504 if (_session->soloing()) {
505 _session->set_solo (_session->get_routes(), false);
506 } else if (_session->listening()) {
507 _session->set_listen (_session->get_routes(), false);
514 ARDOUR_UI::solo_blink (bool onoff)
520 if (_session->soloing() || _session->listening()) {
522 solo_alert_button.set_state (STATE_ACTIVE);
524 solo_alert_button.set_state (STATE_NORMAL);
527 solo_alert_button.set_active (false);
528 solo_alert_button.set_state (STATE_NORMAL);
533 ARDOUR_UI::sync_blink (bool onoff)
535 if (_session == 0 || !_session->config.get_external_sync()) {
537 sync_button.set_visual_state (0);
541 if (!_session->transport_locked()) {
542 /* not locked, so blink on and off according to the onoff argument */
545 sync_button.set_visual_state (1); // "-active"
547 sync_button.set_visual_state (0); // normal
551 sync_button.set_visual_state (1); // "-active"
556 ARDOUR_UI::audition_blink (bool onoff)
562 if (_session->is_auditioning()) {
564 auditioning_alert_button.set_state (STATE_ACTIVE);
566 auditioning_alert_button.set_state (STATE_NORMAL);
569 auditioning_alert_button.set_active (false);
570 auditioning_alert_button.set_state (STATE_NORMAL);
575 ARDOUR_UI::build_shuttle_context_menu ()
577 using namespace Menu_Helpers;
579 shuttle_context_menu = new Menu();
580 MenuList& items = shuttle_context_menu->items();
582 Menu* speed_menu = manage (new Menu());
583 MenuList& speed_items = speed_menu->items();
585 RadioMenuItem::Group group;
587 speed_items.push_back (RadioMenuElem (group, "8", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 8.0f)));
588 if (shuttle_max_speed == 8.0) {
589 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
591 speed_items.push_back (RadioMenuElem (group, "6", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 6.0f)));
592 if (shuttle_max_speed == 6.0) {
593 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
595 speed_items.push_back (RadioMenuElem (group, "4", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 4.0f)));
596 if (shuttle_max_speed == 4.0) {
597 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
599 speed_items.push_back (RadioMenuElem (group, "3", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 3.0f)));
600 if (shuttle_max_speed == 3.0) {
601 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
603 speed_items.push_back (RadioMenuElem (group, "2", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 2.0f)));
604 if (shuttle_max_speed == 2.0) {
605 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
607 speed_items.push_back (RadioMenuElem (group, "1.5", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 1.5f)));
608 if (shuttle_max_speed == 1.5) {
609 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
612 items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
616 ARDOUR_UI::show_shuttle_context_menu ()
618 if (shuttle_context_menu == 0) {
619 build_shuttle_context_menu ();
622 shuttle_context_menu->popup (1, gtk_get_current_event_time());
626 ARDOUR_UI::set_shuttle_max_speed (float speed)
628 shuttle_max_speed = speed;
632 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
638 if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
642 if (Keyboard::is_context_menu_event (ev)) {
643 show_shuttle_context_menu ();
647 switch (ev->button) {
649 shuttle_box.add_modal_grab ();
650 shuttle_grabbed = true;
651 mouse_shuttle (ev->x, true);
664 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
670 switch (ev->button) {
672 mouse_shuttle (ev->x, true);
673 shuttle_grabbed = false;
674 shuttle_box.remove_modal_grab ();
675 if (Config->get_shuttle_behaviour() == Sprung) {
676 if (_session->config.get_auto_play() || roll_button.get_visual_state()) {
677 shuttle_fract = SHUTTLE_FRACT_SPEED1;
678 _session->request_transport_speed (1.0);
679 stop_button.set_visual_state (0);
680 roll_button.set_visual_state (1);
683 _session->request_transport_speed (0.0);
685 shuttle_box.queue_draw ();
690 if (_session->transport_rolling()) {
691 shuttle_fract = SHUTTLE_FRACT_SPEED1;
692 _session->request_transport_speed (1.0);
693 stop_button.set_visual_state (0);
694 roll_button.set_visual_state (1);
698 shuttle_box.queue_draw ();
707 use_shuttle_fract (true);
713 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll* ev)
719 switch (ev->direction) {
722 shuttle_fract += 0.005;
724 case GDK_SCROLL_DOWN:
725 shuttle_fract -= 0.005;
728 /* scroll left/right */
732 use_shuttle_fract (true);
738 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
740 if (!_session || !shuttle_grabbed) {
744 return mouse_shuttle (ev->x, false);
748 ARDOUR_UI::mouse_shuttle (double x, bool force)
750 double half_width = shuttle_box.get_width() / 2.0;
751 double distance = x - half_width;
754 distance = min (distance, half_width);
756 distance = max (distance, -half_width);
759 shuttle_fract = distance / half_width;
760 use_shuttle_fract (force);
765 ARDOUR_UI::set_shuttle_fract (double f)
768 use_shuttle_fract (false);
772 ARDOUR_UI::use_shuttle_fract (bool force)
774 microseconds_t now = get_microseconds();
776 /* do not attempt to submit a motion-driven transport speed request
777 more than once per process cycle.
780 if (!force && (last_shuttle_request - now) < (microseconds_t) engine->usecs_per_cycle()) {
784 last_shuttle_request = now;
786 if (Config->get_shuttle_units() == Semitones) {
788 const double step = 1.0 / 24.0; // range is 24 semitones up & down
792 semitones = round (shuttle_fract / step);
793 speed = pow (2.0, (semitones / 12.0));
795 _session->request_transport_speed (speed);
802 neg = (shuttle_fract < 0.0);
804 fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
810 _session->request_transport_speed (shuttle_max_speed * fract);
813 shuttle_box.queue_draw ();
817 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
820 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
822 /* redraw the background */
824 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
826 event->area.x, event->area.y,
827 event->area.width, event->area.height);
830 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
834 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
838 shuttle_box.get_height());
843 ARDOUR_UI::shuttle_unit_clicked ()
845 if (shuttle_unit_menu == 0) {
846 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
848 shuttle_unit_menu->popup (1, gtk_get_current_event_time());
852 ARDOUR_UI::shuttle_style_changed ()
854 ustring str = shuttle_style_button.get_active_text ();
856 if (str == _("sprung")) {
857 Config->set_shuttle_behaviour (Sprung);
858 } else if (str == _("wheel")) {
859 Config->set_shuttle_behaviour (Wheel);
864 ARDOUR_UI::update_speed_display ()
867 if (last_speed_displayed != 0) {
868 speed_display_label.set_text (_("stop"));
869 last_speed_displayed = 0;
875 float x = _session->transport_speed ();
877 if (x != last_speed_displayed) {
880 if (Config->get_shuttle_units() == Percentage) {
881 snprintf (buf, sizeof (buf), "%.2f", x);
885 snprintf (buf, sizeof (buf), "< %d", (int) round (12.0 * fast_log2 (-x)));
887 snprintf (buf, sizeof (buf), "> %d", (int) round (12.0 * fast_log2 (x)));
890 speed_display_label.set_text (buf);
892 speed_display_label.set_text (_("stop"));
895 last_speed_displayed = x;
900 ARDOUR_UI::set_transport_sensitivity (bool yn)
902 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
903 shuttle_box.set_sensitive (yn);
907 ARDOUR_UI::editor_realized ()
909 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
910 Config->map_parameters (pc);
912 set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
917 ARDOUR_UI::maximise_editing_space ()
923 transport_tearoff->set_visible (false);
924 editor->maximise_editing_space ();
928 ARDOUR_UI::restore_editing_space ()
934 transport_tearoff->set_visible (true);
935 editor->restore_editing_space ();