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/utils.h>
33 #include <gtkmm2ext/click_box.h>
34 #include <gtkmm2ext/tearoff.h>
36 #include <ardour/audioengine.h>
37 #include <ardour/ardour.h>
38 #include <ardour/route.h>
40 #include "ardour_ui.h"
42 #include "public_editor.h"
43 #include "audio_clock.h"
50 using namespace ARDOUR;
52 using namespace Gtkmm2ext;
58 ARDOUR_UI::setup_windows ()
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);
88 ARDOUR_UI::setup_adjustables ()
90 adjuster_table.set_homogeneous (true);
92 online_control_strings.push_back (_("MMC + Local"));
93 online_control_strings.push_back (_("MMC"));
94 online_control_strings.push_back (_("Local"));
96 online_control_button = new GlobalClickBox ("CONTROL",
97 online_control_strings);
99 online_control_button->adjustment.signal_value_changed().connect(mem_fun(*this,&ARDOUR_UI::control_methods_adjusted));
101 mmc_id_strings.push_back ("1");
102 mmc_id_strings.push_back ("2");
103 mmc_id_strings.push_back ("3");
104 mmc_id_strings.push_back ("4");
105 mmc_id_strings.push_back ("5");
106 mmc_id_strings.push_back ("6");
107 mmc_id_strings.push_back ("7");
108 mmc_id_strings.push_back ("8");
109 mmc_id_strings.push_back ("9");
111 mmc_id_button = new GlobalClickBox (_("MMC ID"), mmc_id_strings);
113 mmc_id_button->adjustment.signal_value_changed().connect (mem_fun(*this,&ARDOUR_UI::mmc_device_id_adjusted));
115 adjuster_table.attach (*online_control_button, 0, 2, 1, 2, FILL|EXPAND, FILL, 5, 5);
116 adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, FILL, FILL, 5, 5);
120 ARDOUR_UI::transport_stopped ()
122 stop_button.set_visual_state (1);
124 roll_button.set_visual_state (0);
125 play_selection_button.set_visual_state (0);
126 auto_loop_button.set_visual_state (0);
129 shuttle_box.queue_draw ();
131 update_disk_space ();
135 ARDOUR_UI::transport_rolling ()
137 stop_button.set_visual_state (0);
138 if (session->get_play_range()) {
139 play_selection_button.set_visual_state (1);
140 roll_button.set_visual_state (0);
141 auto_loop_button.set_visual_state (0);
143 } else if (session->get_play_loop ()) {
144 auto_loop_button.set_visual_state (1);
145 play_selection_button.set_visual_state (0);
146 roll_button.set_visual_state (0);
150 roll_button.set_visual_state (1);
151 play_selection_button.set_visual_state (0);
152 auto_loop_button.set_visual_state (0);
155 /* reset shuttle controller */
157 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
158 shuttle_box.queue_draw ();
162 ARDOUR_UI::transport_rewinding ()
164 stop_button.set_visual_state (0);
165 roll_button.set_visual_state (1);
166 play_selection_button.set_visual_state (0);
167 auto_loop_button.set_visual_state (0);
171 ARDOUR_UI::transport_forwarding ()
173 stop_button.set_visual_state (0);
174 roll_button.set_visual_state (1);
175 play_selection_button.set_visual_state (0);
176 auto_loop_button.set_visual_state (0);
180 messagefoo (GdkEventButton* ev)
182 cerr << " roll button pressed\n";
187 messagefoo2 (GdkEventButton* ev)
189 cerr << " roll button release\n";
194 ARDOUR_UI::setup_transport ()
196 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
197 transport_tearoff->set_name ("TransportBase");
199 transport_hbox.pack_start (*transport_tearoff, true, false);
201 transport_base.set_name ("TransportBase");
202 transport_base.add (transport_hbox);
204 transport_frame.set_shadow_type (SHADOW_OUT);
205 transport_frame.set_name ("BaseFrame");
206 transport_frame.add (transport_base);
208 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
209 static_cast<Widget*>(&transport_frame)));
210 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
211 static_cast<Widget*> (&transport_frame), 1));
212 transport_tearoff->Hidden.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
213 static_cast<Widget*>(&transport_frame)));
214 transport_tearoff->Visible.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
215 static_cast<Widget*> (&transport_frame), 1));
217 shuttle_box.set_name ("TransportButton");
218 goto_start_button.set_name ("TransportButton");
219 goto_end_button.set_name ("TransportButton");
220 roll_button.set_name ("TransportButton");
221 stop_button.set_name ("TransportButton");
222 play_selection_button.set_name ("TransportButton");
223 rec_button.set_name ("TransportRecButton");
224 auto_loop_button.set_name ("TransportButton");
226 vector<Gdk::Color> colors;
229 set_color(c, rgba_from_style ("TransportButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_ACTIVE, false ));
230 colors.push_back (c);
232 auto_return_button.set_name ("TransportButton");
233 auto_return_button.set_colors (colors);
234 auto_play_button.set_name ("TransportButton");
235 auto_play_button.set_colors (colors);
236 auto_input_button.set_name ("TransportButton");
237 auto_input_button.set_colors (colors);
238 punch_in_button.set_name ("TransportButton");
239 punch_in_button.set_colors (colors);
240 punch_out_button.set_name ("TransportButton");
241 punch_out_button.set_colors (colors);
242 click_button.set_name ("TransportButton");
243 click_button.set_colors (colors);
244 time_master_button.set_name ("TransportButton");
245 time_master_button.set_colors (colors);
249 /* record button has 3 color states, so we set 2 extra here */
250 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_PRELIGHT, false ));
251 colors.push_back (c);
253 set_color(c, rgba_from_style ("TransportRecButton", 0xff, 0, 0, 0, "bg", Gtk::STATE_ACTIVE, false ));
254 colors.push_back (c);
256 rec_button.set_colors (colors);
259 /* other buttons get 2 color states, so add one here */
260 set_color(c, rgba_from_style ("TransportButton", 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false ));
261 colors.push_back (c);
263 stop_button.set_colors (colors);
264 roll_button.set_colors (colors);
265 auto_loop_button.set_colors (colors);
266 play_selection_button.set_colors (colors);
267 goto_start_button.set_colors (colors);
268 goto_end_button.set_colors (colors);
270 stop_button.set_size_request(29, -1);
271 roll_button.set_size_request(29, -1);
272 auto_loop_button.set_size_request(29, -1);
273 play_selection_button.set_size_request(29, -1);
274 goto_start_button.set_size_request(29, -1);
275 goto_end_button.set_size_request(29, -1);
276 rec_button.set_size_request(29, -1);
280 stop_button.set_visual_state (1);
282 w = manage (new Image (get_icon (X_("transport_start"))));
284 goto_start_button.add (*w);
285 w = manage (new Image (get_icon (X_("transport_end"))));
287 goto_end_button.add (*w);
288 w = manage (new Image (get_icon (X_("transport_play"))));
290 roll_button.add (*w);
291 w = manage (new Image (get_icon (X_("transport_stop"))));
293 stop_button.add (*w);
294 w = manage (new Image (get_icon (X_("transport_range"))));
296 play_selection_button.add (*w);
297 w = manage (new Image (get_icon (X_("transport_record"))));
300 w = manage (new Image (get_icon (X_("transport_loop"))));
302 auto_loop_button.add (*w);
306 roll_button.signal_button_press_event().connect (sigc::ptr_fun (messagefoo));
307 roll_button.signal_button_release_event().connect (sigc::ptr_fun (messagefoo2));
309 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
310 act->connect_proxy (stop_button);
311 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
312 act->connect_proxy (roll_button);
313 act = ActionManager::get_action (X_("Transport"), X_("Record"));
314 act->connect_proxy (rec_button);
315 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
316 act->connect_proxy (goto_start_button);
317 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
318 act->connect_proxy (goto_end_button);
319 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
320 act->connect_proxy (auto_loop_button);
321 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
322 act->connect_proxy (play_selection_button);
323 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
324 act->connect_proxy (time_master_button);
326 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
327 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
328 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
329 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
330 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
331 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
333 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
334 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
335 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
336 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
337 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
338 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
339 ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo, _("Positional sync source"));
340 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
341 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
342 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
343 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
345 shuttle_box.set_flags (CAN_FOCUS);
346 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);
347 shuttle_box.set_size_request (100, 15);
349 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
350 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
351 shuttle_box.signal_scroll_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll));
352 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
353 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
357 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
358 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
360 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
361 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
363 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
364 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
366 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button);
367 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button);
368 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button);
369 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button);
370 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
371 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
373 preroll_button.set_name ("TransportButton");
374 postroll_button.set_name ("TransportButton");
376 preroll_clock.set_mode (AudioClock::MinSec);
377 preroll_clock.set_name ("TransportClockDisplay");
378 postroll_clock.set_mode (AudioClock::MinSec);
379 postroll_clock.set_name ("TransportClockDisplay");
383 /* CANNOT bind these to clicked or toggled, must use pressed or released */
385 solo_alert_button.set_name ("TransportSoloAlert");
386 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
387 auditioning_alert_button.set_name ("TransportAuditioningAlert");
388 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
390 tooltips().set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
391 tooltips().set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition"));
393 alert_box.pack_start (solo_alert_button, false, false);
394 alert_box.pack_start (auditioning_alert_button, false, false);
396 transport_tearoff_hbox.set_border_width (3);
398 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
399 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
401 Frame* sframe = manage (new Frame);
402 VBox* svbox = manage (new VBox);
403 HBox* shbox = manage (new HBox);
405 sframe->set_shadow_type (SHADOW_IN);
406 sframe->add (shuttle_box);
408 shuttle_box.set_name (X_("ShuttleControl"));
410 speed_display_box.add (speed_display_label);
411 speed_display_box.set_name (X_("ShuttleDisplay"));
413 shuttle_units_button.set_name (X_("ShuttleButton"));
414 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
416 shuttle_style_button.set_name (X_("ShuttleButton"));
418 vector<string> shuttle_strings;
419 shuttle_strings.push_back (_("sprung"));
420 shuttle_strings.push_back (_("wheel"));
421 set_popdown_strings (shuttle_style_button, shuttle_strings);
422 shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
424 Frame* sdframe = manage (new Frame);
426 sdframe->set_shadow_type (SHADOW_IN);
427 sdframe->add (speed_display_box);
430 sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
431 const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
432 set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 2+FUDGE, 10);
434 shbox->pack_start (*sdframe, false, false);
435 shbox->pack_start (shuttle_units_button, true, true);
436 shbox->pack_start (shuttle_style_button, false, false);
438 svbox->pack_start (*sframe, false, false);
439 svbox->pack_start (*shbox, false, false);
441 transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
443 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
444 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
445 transport_tearoff_hbox.pack_start (roll_button, false, false);
446 transport_tearoff_hbox.pack_start (stop_button, false, false);
447 transport_tearoff_hbox.pack_start (rec_button, false, false, 6);
449 HBox* clock_box = manage (new HBox);
450 clock_box->pack_start (primary_clock, false, false);
451 clock_box->pack_start (secondary_clock, false, false);
452 VBox* time_controls_box = manage (new VBox);
453 time_controls_box->pack_start (sync_option_combo, false, false);
454 time_controls_box->pack_start (time_master_button, false, false);
455 clock_box->pack_start (*time_controls_box, false, false, 1);
456 transport_tearoff_hbox.pack_start (*clock_box, false, false, 0);
458 HBox* toggle_box = manage(new HBox);
460 VBox* punch_box = manage (new VBox);
461 punch_box->pack_start (punch_in_button, false, false);
462 punch_box->pack_start (punch_out_button, false, false);
463 toggle_box->pack_start (*punch_box, false, false);
465 VBox* auto_box = manage (new VBox);
466 auto_box->pack_start (auto_play_button, false, false);
467 auto_box->pack_start (auto_return_button, false, false);
468 toggle_box->pack_start (*auto_box, false, false);
470 VBox* io_box = manage (new VBox);
471 io_box->pack_start (auto_input_button, false, false);
472 io_box->pack_start (click_button, false, false);
473 toggle_box->pack_start (*io_box, false, false);
477 set_transport_sensitivity (false);
479 // toggle_box->pack_start (preroll_button, false, false);
480 // toggle_box->pack_start (preroll_clock, false, false);
482 // toggle_box->pack_start (postroll_button, false, false);
483 // toggle_box->pack_start (postroll_clock, false, false);
485 transport_tearoff_hbox.pack_start (*toggle_box, false, false, 4);
486 transport_tearoff_hbox.pack_start (alert_box, false, false);
490 ARDOUR_UI::manage_window (Window& win)
492 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
493 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
494 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
498 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
500 // editor->ensure_float (transport_tearoff->tearoff_window());
505 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
508 b->reorder_child (*w, n);
512 ARDOUR_UI::soloing_changed (bool onoff)
514 if (solo_alert_button.get_active() != onoff) {
515 solo_alert_button.set_active (onoff);
520 ARDOUR_UI::_auditioning_changed (bool onoff)
522 if (auditioning_alert_button.get_active() != onoff) {
523 auditioning_alert_button.set_active (onoff);
524 set_transport_sensitivity (!onoff);
529 ARDOUR_UI::auditioning_changed (bool onoff)
531 UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
535 ARDOUR_UI::audition_alert_toggle ()
538 session->cancel_audition();
543 ARDOUR_UI::solo_alert_toggle ()
546 session->set_all_solo (!session->soloing());
551 ARDOUR_UI::solo_blink (bool onoff)
557 if (session->soloing()) {
559 solo_alert_button.set_state (STATE_ACTIVE);
561 solo_alert_button.set_state (STATE_NORMAL);
564 solo_alert_button.set_active (false);
565 solo_alert_button.set_state (STATE_NORMAL);
570 ARDOUR_UI::audition_blink (bool onoff)
576 if (session->is_auditioning()) {
578 auditioning_alert_button.set_state (STATE_ACTIVE);
580 auditioning_alert_button.set_state (STATE_NORMAL);
583 auditioning_alert_button.set_active (false);
584 auditioning_alert_button.set_state (STATE_NORMAL);
589 ARDOUR_UI::build_shuttle_context_menu ()
591 using namespace Menu_Helpers;
593 shuttle_context_menu = new Menu();
594 MenuList& items = shuttle_context_menu->items();
596 Menu* speed_menu = manage (new Menu());
597 MenuList& speed_items = speed_menu->items();
599 RadioMenuItem::Group group;
601 speed_items.push_back (RadioMenuElem (group, "8", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 8.0f)));
602 if (shuttle_max_speed == 8.0) {
603 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
605 speed_items.push_back (RadioMenuElem (group, "6", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 6.0f)));
606 if (shuttle_max_speed == 6.0) {
607 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
609 speed_items.push_back (RadioMenuElem (group, "4", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 4.0f)));
610 if (shuttle_max_speed == 4.0) {
611 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
613 speed_items.push_back (RadioMenuElem (group, "3", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 3.0f)));
614 if (shuttle_max_speed == 3.0) {
615 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
617 speed_items.push_back (RadioMenuElem (group, "2", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 2.0f)));
618 if (shuttle_max_speed == 2.0) {
619 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
621 speed_items.push_back (RadioMenuElem (group, "1.5", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 1.5f)));
622 if (shuttle_max_speed == 1.5) {
623 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
626 items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
630 ARDOUR_UI::show_shuttle_context_menu ()
632 if (shuttle_context_menu == 0) {
633 build_shuttle_context_menu ();
636 shuttle_context_menu->popup (1, gtk_get_current_event_time());
640 ARDOUR_UI::set_shuttle_max_speed (float speed)
642 shuttle_max_speed = speed;
646 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
652 if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
656 if (Keyboard::is_context_menu_event (ev)) {
657 show_shuttle_context_menu ();
661 switch (ev->button) {
663 shuttle_box.add_modal_grab ();
664 shuttle_grabbed = true;
665 mouse_shuttle (ev->x, true);
678 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
684 switch (ev->button) {
686 mouse_shuttle (ev->x, true);
687 shuttle_grabbed = false;
688 shuttle_box.remove_modal_grab ();
689 if (Config->get_shuttle_behaviour() == Sprung) {
690 if (Config->get_auto_play() || roll_button.get_state()) {
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);
697 session->request_transport_speed (0.0);
699 shuttle_box.queue_draw ();
704 if (session->transport_rolling()) {
705 shuttle_fract = SHUTTLE_FRACT_SPEED1;
706 session->request_transport_speed (1.0);
707 stop_button.set_visual_state (0);
708 roll_button.set_visual_state (1);
712 shuttle_box.queue_draw ();
719 shuttle_fract += 0.005;
722 shuttle_fract -= 0.005;
726 use_shuttle_fract (true);
732 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll* ev)
738 switch (ev->direction) {
741 shuttle_fract += 0.005;
743 case GDK_SCROLL_DOWN:
744 shuttle_fract -= 0.005;
747 /* scroll left/right */
751 use_shuttle_fract (true);
757 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
759 if (!session || !shuttle_grabbed) {
763 return mouse_shuttle (ev->x, false);
767 ARDOUR_UI::mouse_shuttle (double x, bool force)
769 double half_width = shuttle_box.get_width() / 2.0;
770 double distance = x - half_width;
773 distance = min (distance, half_width);
775 distance = max (distance, -half_width);
778 shuttle_fract = distance / half_width;
779 use_shuttle_fract (force);
784 ARDOUR_UI::set_shuttle_fract (double f)
787 use_shuttle_fract (false);
791 ARDOUR_UI::use_shuttle_fract (bool force)
796 /* do not attempt to submit a motion-driven transport speed request
797 more than once per process cycle.
800 gettimeofday (&now, 0);
801 timersub (&now, &last_shuttle_request, &diff);
803 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
807 last_shuttle_request = now;
809 bool neg = (shuttle_fract < 0.0);
811 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
817 session->request_transport_speed (shuttle_max_speed * fract); // Formula A2
818 shuttle_box.queue_draw ();
822 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
825 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
827 /* redraw the background */
829 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
831 event->area.x, event->area.y,
832 event->area.width, event->area.height);
835 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
839 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
843 shuttle_box.get_height());
848 ARDOUR_UI::shuttle_unit_clicked ()
850 if (shuttle_unit_menu == 0) {
851 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
853 shuttle_unit_menu->popup (1, gtk_get_current_event_time());
857 ARDOUR_UI::shuttle_style_changed ()
859 ustring str = shuttle_style_button.get_active_text ();
861 if (str == _("sprung")) {
862 Config->set_shuttle_behaviour (Sprung);
863 } else if (str == _("wheel")) {
864 Config->set_shuttle_behaviour (Wheel);
869 ARDOUR_UI::update_speed_display ()
872 if (last_speed_displayed != 0) {
873 speed_display_label.set_text (_("stop"));
874 last_speed_displayed = 0;
880 float x = session->transport_speed ();
882 if (x != last_speed_displayed) {
885 if (Config->get_shuttle_units() == Percentage) {
886 snprintf (buf, sizeof (buf), "%.2f", x);
889 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
891 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
894 speed_display_label.set_text (buf);
896 speed_display_label.set_text (_("stop"));
899 last_speed_displayed = x;
904 ARDOUR_UI::set_transport_sensitivity (bool yn)
906 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
907 shuttle_box.set_sensitive (yn);
911 ARDOUR_UI::editor_realized ()
913 Config->map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
915 set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
916 const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
917 set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
921 ARDOUR_UI::sync_option_changed ()
924 session->request_slave_source (string_to_slave_source (sync_option_combo.get_active_text()));
929 ARDOUR_UI::maximise_editing_space ()
935 transport_tearoff->set_visible (false);
936 editor->maximise_editing_space ();
940 ARDOUR_UI::restore_editing_space ()
946 transport_tearoff->set_visible (true);
947 editor->restore_editing_space ();