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;
57 ARDOUR_UI::setup_windows ()
59 using namespace Menu_Helpers;
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 ();
80 top_packer.pack_start (menu_bar_base, false, false);
81 top_packer.pack_start (transport_frame, false, false);
83 editor->add_toplevel_controls (top_packer);
90 ARDOUR_UI::setup_adjustables ()
93 adjuster_table.set_homogeneous (true);
95 online_control_strings.push_back (_("MMC + Local"));
96 online_control_strings.push_back (_("MMC"));
97 online_control_strings.push_back (_("Local"));
99 online_control_button = new GlobalClickBox ("CONTROL",
100 online_control_strings);
102 online_control_button->adjustment.signal_value_changed().connect(mem_fun(*this,&ARDOUR_UI::control_methods_adjusted));
104 mmc_id_strings.push_back ("1");
105 mmc_id_strings.push_back ("2");
106 mmc_id_strings.push_back ("3");
107 mmc_id_strings.push_back ("4");
108 mmc_id_strings.push_back ("5");
109 mmc_id_strings.push_back ("6");
110 mmc_id_strings.push_back ("7");
111 mmc_id_strings.push_back ("8");
112 mmc_id_strings.push_back ("9");
114 mmc_id_button = new GlobalClickBox (_("MMC ID"), mmc_id_strings);
116 mmc_id_button->adjustment.signal_value_changed().connect (mem_fun(*this,&ARDOUR_UI::mmc_device_id_adjusted));
118 adjuster_table.attach (*online_control_button, 0, 2, 1, 2, FILL|EXPAND, FILL, 5, 5);
119 adjuster_table.attach (*mmc_id_button, 2, 3, 1, 2, FILL, FILL, 5, 5);
122 #include "transport_xpms"
125 ARDOUR_UI::transport_stopped ()
127 roll_button.set_active (false);
128 play_selection_button.set_active (false);
129 auto_loop_button.set_active (false);
132 shuttle_box.queue_draw ();
134 update_disk_space ();
137 static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
140 ARDOUR_UI::transport_rolling ()
142 if (session->get_play_range()) {
144 play_selection_button.set_active (true);
145 roll_button.set_active (false);
146 auto_loop_button.set_active (false);
148 } else if (session->get_auto_loop ()) {
150 auto_loop_button.set_active (true);
151 play_selection_button.set_active (false);
152 roll_button.set_active (false);
156 roll_button.set_active (true);
157 play_selection_button.set_active (false);
158 auto_loop_button.set_active (false);
161 /* reset shuttle controller */
163 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
164 shuttle_box.queue_draw ();
168 ARDOUR_UI::transport_rewinding ()
170 roll_button.set_active (true);
171 play_selection_button.set_active (false);
172 auto_loop_button.set_active (false);
176 ARDOUR_UI::transport_forwarding ()
178 roll_button.set_active (true);
179 play_selection_button.set_active (false);
180 auto_loop_button.set_active (false);
184 ARDOUR_UI::setup_transport ()
186 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
187 transport_tearoff->set_name ("TransportBase");
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 (Gtk::SHADOW_OUT);
195 transport_frame.set_name ("BaseFrame");
196 transport_frame.add (transport_base);
198 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Gtk::Box*>(&top_packer),
199 static_cast<Gtk::Widget*>(&transport_frame)));
200 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Gtk::Box*> (&top_packer),
201 static_cast<Gtk::Widget*> (&transport_frame), 1));
207 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(start_xpm)));
209 goto_start_button.add (*w);
210 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(end_xpm)));
212 goto_end_button.add (*w);
213 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(arrow_xpm)));
215 roll_button.add (*w);
216 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(stop_xpm)));
218 stop_button.add (*w);
219 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(play_selection_xpm)));
221 play_selection_button.add (*w);
222 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(rec_xpm)));
225 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
227 auto_loop_button.add (*w);
230 stop_button.set_use_stock (false);
231 roll_button.set_use_stock (false);
232 rec_button.set_use_stock (false);
233 goto_start_button.set_use_stock (false);
234 goto_end_button.set_use_stock (false);
235 auto_loop_button.set_use_stock (false);
237 w = manage (new Image (Stock::MEDIA_PREVIOUS, ICON_SIZE_BUTTON));
239 goto_start_button.add (*w);
240 w = manage (new Image (Stock::MEDIA_NEXT, ICON_SIZE_BUTTON));
242 goto_end_button.add (*w);
243 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
245 roll_button.add (*w);
246 w = manage (new Image (Stock::MEDIA_STOP, ICON_SIZE_BUTTON));
248 stop_button.add (*w);
249 w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
251 play_selection_button.add (*w);
252 w = manage (new Image (Stock::MEDIA_RECORD, ICON_SIZE_BUTTON));
255 w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
257 auto_loop_button.add (*w);
259 stop_button.set_use_stock (true);
260 roll_button.set_use_stock (true);
261 rec_button.set_use_stock (true);
262 goto_start_button.set_use_stock (true);
263 goto_end_button.set_use_stock (true);
264 auto_loop_button.set_use_stock (true);
269 act = ActionManager::get_action (X_("<Actions>/Common/TransportStop"));
270 act->connect_proxy (stop_button);
271 act = ActionManager::get_action (X_("<Actions>/Common/TransportRoll"));
272 act->connect_proxy (roll_button);
273 act = ActionManager::get_action (X_("<Actions>/Common/TransportRecord"));
274 act->connect_proxy (rec_button);
275 act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoStart"));
276 act->connect_proxy (goto_start_button);
277 act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoEnd"));
278 act->connect_proxy (goto_end_button);
279 act = ActionManager::get_action (X_("<Actions>/Common/TransportLoop"));
280 act->connect_proxy (auto_loop_button);
282 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
283 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
284 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
285 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
286 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
287 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
288 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
289 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
290 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
291 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
292 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
293 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
294 ARDOUR_UI::instance()->tooltips().set_tip (follow_button, _("Enable/Disable follow playhead"));
295 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
296 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
297 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_style_button, _("Select sprung or wheel behaviour"));
298 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
300 shuttle_box.set_flags (CAN_FOCUS);
301 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);
302 shuttle_box.set_size_request (100, 15);
304 shuttle_box.set_name ("TransportButton");
305 goto_start_button.set_name ("TransportButton");
306 goto_end_button.set_name ("TransportButton");
307 roll_button.set_name ("TransportButton");
308 stop_button.set_name ("TransportButton");
309 play_selection_button.set_name ("TransportButton");
310 rec_button.set_name ("TransportRecButton");
311 auto_loop_button.set_name ("TransportButton");
312 auto_return_button.set_name ("TransportButton");
313 auto_play_button.set_name ("TransportButton");
314 auto_input_button.set_name ("TransportButton");
315 punch_in_button.set_name ("TransportButton");
316 punch_out_button.set_name ("TransportButton");
317 click_button.set_name ("TransportButton");
318 follow_button.set_name ("TransportButton");
320 goto_start_button.unset_flags (Gtk::CAN_FOCUS);
321 goto_end_button.unset_flags (Gtk::CAN_FOCUS);
322 roll_button.unset_flags (Gtk::CAN_FOCUS);
323 stop_button.unset_flags (Gtk::CAN_FOCUS);
324 play_selection_button.unset_flags (Gtk::CAN_FOCUS);
325 rec_button.unset_flags (Gtk::CAN_FOCUS);
326 auto_loop_button.unset_flags (Gtk::CAN_FOCUS);
327 auto_return_button.unset_flags (Gtk::CAN_FOCUS);
328 auto_play_button.unset_flags (Gtk::CAN_FOCUS);
329 auto_input_button.unset_flags (Gtk::CAN_FOCUS);
330 punch_out_button.unset_flags (Gtk::CAN_FOCUS);
331 punch_in_button.unset_flags (Gtk::CAN_FOCUS);
332 click_button.unset_flags (Gtk::CAN_FOCUS);
333 follow_button.unset_flags (Gtk::CAN_FOCUS);
335 goto_start_button.set_events (goto_start_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
336 goto_end_button.set_events (goto_end_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
337 roll_button.set_events (roll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
338 stop_button.set_events (stop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
339 play_selection_button.set_events (play_selection_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
340 rec_button.set_events (rec_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
341 auto_loop_button.set_events (auto_loop_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
342 auto_return_button.set_events (auto_return_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
343 auto_play_button.set_events (auto_play_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
344 auto_input_button.set_events (auto_input_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
345 click_button.set_events (click_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
346 follow_button.set_events (click_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
347 punch_in_button.set_events (punch_in_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
348 punch_out_button.set_events (punch_out_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
350 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
351 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
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.set_mode (AudioClock::SMPTE);
361 primary_clock.set_name ("TransportClockDisplay");
362 secondary_clock.set_mode (AudioClock::BBT);
363 secondary_clock.set_name ("TransportClockDisplay");
366 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
367 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
369 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
370 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
374 auto_return_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_return));
375 auto_play_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_play));
376 auto_input_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_input));
377 click_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_click));
378 follow_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_follow));
379 punch_in_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_in));
380 punch_out_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_out));
382 preroll_button.unset_flags (Gtk::CAN_FOCUS);
383 preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
384 preroll_button.set_name ("TransportButton");
386 postroll_button.unset_flags (Gtk::CAN_FOCUS);
387 postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
388 postroll_button.set_name ("TransportButton");
390 preroll_clock.set_mode (AudioClock::MinSec);
391 preroll_clock.set_name ("TransportClockDisplay");
392 postroll_clock.set_mode (AudioClock::MinSec);
393 postroll_clock.set_name ("TransportClockDisplay");
397 /* CANNOT bind these to clicked or toggled, must use pressed or released */
399 solo_alert_button.set_name ("TransportSoloAlert");
400 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
401 auditioning_alert_button.set_name ("TransportAuditioningAlert");
402 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
404 alert_box.pack_start (solo_alert_button);
405 alert_box.pack_start (auditioning_alert_button);
407 transport_tearoff_hbox.set_border_width (5);
409 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
410 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
412 Gtk::Frame* sframe = manage (new Frame);
413 Gtk::VBox* svbox = manage (new VBox);
414 Gtk::HBox* shbox = manage (new HBox);
416 sframe->set_shadow_type (Gtk::SHADOW_IN);
417 sframe->add (shuttle_box);
419 shuttle_box.set_name (X_("ShuttleControl"));
421 speed_display_box.add (speed_display_label);
422 set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
423 speed_display_box.set_name (X_("ShuttleDisplay"));
425 shuttle_units_button.set_name (X_("ShuttleButton"));
426 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
428 shuttle_style_button.set_name (X_("ShuttleButton"));
429 shuttle_style_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_style_clicked));
431 Gtk::Frame* sdframe = manage (new Frame);
433 sdframe->set_shadow_type (Gtk::SHADOW_IN);
434 sdframe->add (speed_display_box);
436 shbox->pack_start (*sdframe, false, false);
437 shbox->pack_start (shuttle_units_button, true, true);
438 shbox->pack_start (shuttle_style_button, false, false);
440 svbox->pack_start (*sframe, false, false);
441 svbox->pack_start (*shbox, false, false);
443 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
445 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
446 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
447 transport_tearoff_hbox.pack_start (roll_button, false, false);
448 transport_tearoff_hbox.pack_start (stop_button, false, false);
449 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
451 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
452 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
454 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
455 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
456 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
457 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
458 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
459 transport_tearoff_hbox.pack_start (click_button, false, false);
460 transport_tearoff_hbox.pack_start (follow_button, false, false);
464 set_transport_sensitivity (false);
466 /* catch up with editor state */
470 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
471 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
473 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
474 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
476 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
480 ARDOUR_UI::setup_clock ()
482 ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
484 big_clock_window = new Gtk::Window (WINDOW_TOPLEVEL);
486 big_clock_window->set_border_width (0);
487 big_clock_window->add (big_clock);
488 big_clock_window->set_title (_("ardour: clock"));
489 big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
490 big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
491 big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
493 manage_window (*big_clock_window);
497 ARDOUR_UI::manage_window (Window& win)
499 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
500 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
501 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
505 ARDOUR_UI::detach_tearoff (Gtk::Box* b, Gtk::Widget* w)
507 editor->ensure_float (*transport_tearoff->tearoff_window());
512 ARDOUR_UI::reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n)
515 b->reorder_child (*w, n);
519 ARDOUR_UI::soloing_changed (bool onoff)
521 if (solo_alert_button.get_active() != onoff) {
522 solo_alert_button.set_active (onoff);
527 ARDOUR_UI::_auditioning_changed (bool onoff)
529 if (auditioning_alert_button.get_active() != onoff) {
530 auditioning_alert_button.set_active (onoff);
531 set_transport_sensitivity (!onoff);
536 ARDOUR_UI::auditioning_changed (bool onoff)
538 Gtkmm2ext::UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
542 ARDOUR_UI::audition_alert_toggle ()
545 session->cancel_audition();
550 ARDOUR_UI::solo_alert_toggle ()
553 session->set_all_solo (!session->soloing());
558 ARDOUR_UI::solo_blink (bool onoff)
564 if (session->soloing()) {
566 solo_alert_button.set_state (Gtk::STATE_ACTIVE);
568 solo_alert_button.set_state (Gtk::STATE_NORMAL);
571 solo_alert_button.set_active (false);
572 solo_alert_button.set_state (Gtk::STATE_NORMAL);
577 ARDOUR_UI::audition_blink (bool onoff)
583 if (session->is_auditioning()) {
585 auditioning_alert_button.set_state (Gtk::STATE_ACTIVE);
587 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
590 auditioning_alert_button.set_active (false);
591 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
597 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
603 switch (ev->button) {
605 shuttle_box.add_modal_grab ();
606 shuttle_grabbed = true;
607 mouse_shuttle (ev->x, true);
625 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
631 switch (ev->button) {
633 mouse_shuttle (ev->x, true);
634 shuttle_grabbed = false;
635 shuttle_box.remove_modal_grab ();
636 if (shuttle_behaviour == Sprung) {
637 shuttle_fract = SHUTTLE_FRACT_SPEED1;
638 session->request_transport_speed (1.0);
639 shuttle_box.queue_draw ();
644 if (session->transport_rolling()) {
645 shuttle_fract = SHUTTLE_FRACT_SPEED1;
646 session->request_transport_speed (1.0);
650 shuttle_box.queue_draw ();
657 shuttle_fract += 0.005;
660 shuttle_fract -= 0.005;
664 use_shuttle_fract (true);
670 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
672 if (!session || !shuttle_grabbed) {
676 return mouse_shuttle (ev->x, false);
680 ARDOUR_UI::mouse_shuttle (double x, bool force)
682 double half_width = shuttle_box.get_width() / 2.0;
683 double distance = x - half_width;
686 distance = min (distance, half_width);
688 distance = max (distance, -half_width);
691 shuttle_fract = distance / half_width;
692 use_shuttle_fract (force);
697 ARDOUR_UI::use_shuttle_fract (bool force)
702 /* do not attempt to submit a motion-driven transport speed request
703 more than once per process cycle.
706 gettimeofday (&now, 0);
707 timersub (&now, &last_shuttle_request, &diff);
709 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
713 last_shuttle_request = now;
715 bool neg = (shuttle_fract < 0.0);
717 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
723 session->request_transport_speed (8.0 * fract); // Formula A2
724 shuttle_box.queue_draw ();
728 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
731 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
733 /* redraw the background */
735 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
737 event->area.x, event->area.y,
738 event->area.width, event->area.height);
741 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
745 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
749 shuttle_box.get_height());
754 ARDOUR_UI::shuttle_style_clicked ()
756 if (shuttle_style_menu == 0) {
757 shuttle_style_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleStylePopup"));
759 shuttle_style_menu->popup (1, 0);
763 ARDOUR_UI::shuttle_unit_clicked ()
765 if (shuttle_unit_menu == 0) {
766 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
768 shuttle_unit_menu->popup (1, 0);
772 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
774 switch ((shuttle_units = u)) {
776 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text ("% ");
779 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text (_("st"));
785 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
787 switch ((shuttle_behaviour = b)) {
789 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("sprung"));
791 shuttle_box.queue_draw ();
793 if (session->transport_rolling()) {
794 shuttle_fract = SHUTTLE_FRACT_SPEED1;
795 session->request_transport_speed (1.0);
800 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("wheel"));
806 ARDOUR_UI::update_speed_display ()
809 speed_display_label.set_text (_("stopped"));
814 float x = session->transport_speed ();
817 if (shuttle_units == Percentage) {
818 snprintf (buf, sizeof (buf), "%.4f", x);
821 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
823 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
826 speed_display_label.set_text (buf);
828 speed_display_label.set_text (_("stopped"));
833 ARDOUR_UI::set_transport_sensitivity (bool yn)
835 goto_start_button.set_sensitive (yn);
836 goto_end_button.set_sensitive (yn);
837 roll_button.set_sensitive (yn);
838 stop_button.set_sensitive (yn);
839 play_selection_button.set_sensitive (yn);
840 rec_button.set_sensitive (yn);
841 auto_loop_button.set_sensitive (yn);
842 shuttle_box.set_sensitive (yn);