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));
352 goto_start_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_start));
353 goto_end_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_end));
355 roll_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_roll));
356 play_selection_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_play_selection));
357 auto_loop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_loop));
359 stop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_stop));
360 rec_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_record));
363 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
364 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
365 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
366 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
370 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
371 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
373 primary_clock.set_mode (AudioClock::SMPTE);
374 primary_clock.set_name ("TransportClockDisplay");
375 secondary_clock.set_mode (AudioClock::BBT);
376 secondary_clock.set_name ("TransportClockDisplay");
379 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
380 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
382 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
383 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
387 auto_return_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_return));
388 auto_play_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_play));
389 auto_input_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_auto_input));
390 click_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_click));
391 follow_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_follow));
392 punch_in_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_in));
393 punch_out_button.signal_toggled().connect (mem_fun(*this,&ARDOUR_UI::toggle_punch_out));
395 preroll_button.unset_flags (Gtk::CAN_FOCUS);
396 preroll_button.set_events (preroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
397 preroll_button.set_name ("TransportButton");
399 postroll_button.unset_flags (Gtk::CAN_FOCUS);
400 postroll_button.set_events (postroll_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
401 postroll_button.set_name ("TransportButton");
403 preroll_clock.set_mode (AudioClock::MinSec);
404 preroll_clock.set_name ("TransportClockDisplay");
405 postroll_clock.set_mode (AudioClock::MinSec);
406 postroll_clock.set_name ("TransportClockDisplay");
410 /* CANNOT bind these to clicked or toggled, must use pressed or released */
412 solo_alert_button.set_name ("TransportSoloAlert");
413 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
414 auditioning_alert_button.set_name ("TransportAuditioningAlert");
415 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
417 alert_box.pack_start (solo_alert_button);
418 alert_box.pack_start (auditioning_alert_button);
420 transport_tearoff_hbox.set_border_width (5);
422 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
423 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
425 Gtk::Frame* sframe = manage (new Frame);
426 Gtk::VBox* svbox = manage (new VBox);
427 Gtk::HBox* shbox = manage (new HBox);
429 sframe->set_shadow_type (Gtk::SHADOW_IN);
430 sframe->add (shuttle_box);
432 shuttle_box.set_name (X_("ShuttleControl"));
434 speed_display_box.add (speed_display_label);
435 set_size_request_to_display_given_text (speed_display_box, _("stopped"), 2, 2);
436 speed_display_box.set_name (X_("ShuttleDisplay"));
438 shuttle_units_button.set_name (X_("ShuttleButton"));
439 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
441 shuttle_style_button.set_name (X_("ShuttleButton"));
442 shuttle_style_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_style_clicked));
444 Gtk::Frame* sdframe = manage (new Frame);
446 sdframe->set_shadow_type (Gtk::SHADOW_IN);
447 sdframe->add (speed_display_box);
449 shbox->pack_start (*sdframe, false, false);
450 shbox->pack_start (shuttle_units_button, true, true);
451 shbox->pack_start (shuttle_style_button, false, false);
453 svbox->pack_start (*sframe, false, false);
454 svbox->pack_start (*shbox, false, false);
456 transport_tearoff_hbox.pack_start (*svbox, false, false, 5);
458 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
459 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
460 transport_tearoff_hbox.pack_start (roll_button, false, false);
461 transport_tearoff_hbox.pack_start (stop_button, false, false);
462 transport_tearoff_hbox.pack_start (rec_button, false, false, 10);
464 transport_tearoff_hbox.pack_start (primary_clock, false, false, 5);
465 transport_tearoff_hbox.pack_start (secondary_clock, false, false, 5);
467 transport_tearoff_hbox.pack_start (punch_in_button, false, false);
468 transport_tearoff_hbox.pack_start (punch_out_button, false, false);
469 transport_tearoff_hbox.pack_start (auto_input_button, false, false);
470 transport_tearoff_hbox.pack_start (auto_return_button, false, false);
471 transport_tearoff_hbox.pack_start (auto_play_button, false, false);
472 transport_tearoff_hbox.pack_start (click_button, false, false);
473 transport_tearoff_hbox.pack_start (follow_button, false, false);
477 set_transport_sensitivity (false);
479 /* catch up with editor state */
483 // transport_tearoff_hbox.pack_start (preroll_button, false, false);
484 // transport_tearoff_hbox.pack_start (preroll_clock, false, false);
486 // transport_tearoff_hbox.pack_start (postroll_button, false, false);
487 // transport_tearoff_hbox.pack_start (postroll_clock, false, false);
489 transport_tearoff_hbox.pack_start (alert_box, false, false, 5);
493 ARDOUR_UI::setup_clock ()
495 ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
497 big_clock_window = new Gtk::Window (WINDOW_TOPLEVEL);
499 big_clock_window->set_border_width (0);
500 big_clock_window->add (big_clock);
501 big_clock_window->set_title (_("ardour: clock"));
502 big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
503 big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window, (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
504 big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
506 manage_window (*big_clock_window);
510 ARDOUR_UI::manage_window (Window& win)
512 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
513 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
514 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
518 ARDOUR_UI::detach_tearoff (Gtk::Box* b, Gtk::Widget* w)
520 editor->ensure_float (*transport_tearoff->tearoff_window());
525 ARDOUR_UI::reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n)
528 b->reorder_child (*w, n);
532 ARDOUR_UI::soloing_changed (bool onoff)
534 if (solo_alert_button.get_active() != onoff) {
535 solo_alert_button.set_active (onoff);
540 ARDOUR_UI::_auditioning_changed (bool onoff)
542 if (auditioning_alert_button.get_active() != onoff) {
543 auditioning_alert_button.set_active (onoff);
544 set_transport_sensitivity (!onoff);
549 ARDOUR_UI::auditioning_changed (bool onoff)
551 Gtkmm2ext::UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
555 ARDOUR_UI::audition_alert_toggle ()
558 session->cancel_audition();
563 ARDOUR_UI::solo_alert_toggle ()
566 session->set_all_solo (!session->soloing());
571 ARDOUR_UI::solo_blink (bool onoff)
577 if (session->soloing()) {
579 solo_alert_button.set_state (Gtk::STATE_ACTIVE);
581 solo_alert_button.set_state (Gtk::STATE_NORMAL);
584 solo_alert_button.set_active (false);
585 solo_alert_button.set_state (Gtk::STATE_NORMAL);
590 ARDOUR_UI::audition_blink (bool onoff)
596 if (session->is_auditioning()) {
598 auditioning_alert_button.set_state (Gtk::STATE_ACTIVE);
600 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
603 auditioning_alert_button.set_active (false);
604 auditioning_alert_button.set_state (Gtk::STATE_NORMAL);
610 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
616 switch (ev->button) {
618 shuttle_box.add_modal_grab ();
619 shuttle_grabbed = true;
620 mouse_shuttle (ev->x, true);
638 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
644 switch (ev->button) {
646 mouse_shuttle (ev->x, true);
647 shuttle_grabbed = false;
648 shuttle_box.remove_modal_grab ();
649 if (shuttle_behaviour == Sprung) {
650 shuttle_fract = SHUTTLE_FRACT_SPEED1;
651 session->request_transport_speed (1.0);
652 shuttle_box.queue_draw ();
657 if (session->transport_rolling()) {
658 shuttle_fract = SHUTTLE_FRACT_SPEED1;
659 session->request_transport_speed (1.0);
663 shuttle_box.queue_draw ();
670 shuttle_fract += 0.005;
673 shuttle_fract -= 0.005;
677 use_shuttle_fract (true);
683 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
685 if (!session || !shuttle_grabbed) {
689 return mouse_shuttle (ev->x, false);
693 ARDOUR_UI::mouse_shuttle (double x, bool force)
695 double half_width = shuttle_box.get_width() / 2.0;
696 double distance = x - half_width;
699 distance = min (distance, half_width);
701 distance = max (distance, -half_width);
704 shuttle_fract = distance / half_width;
705 use_shuttle_fract (force);
710 ARDOUR_UI::use_shuttle_fract (bool force)
715 /* do not attempt to submit a motion-driven transport speed request
716 more than once per process cycle.
719 gettimeofday (&now, 0);
720 timersub (&now, &last_shuttle_request, &diff);
722 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
726 last_shuttle_request = now;
728 bool neg = (shuttle_fract < 0.0);
730 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
736 session->request_transport_speed (8.0 * fract); // Formula A2
737 shuttle_box.queue_draw ();
741 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
744 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
746 /* redraw the background */
748 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
750 event->area.x, event->area.y,
751 event->area.width, event->area.height);
754 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
758 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
762 shuttle_box.get_height());
767 ARDOUR_UI::shuttle_style_clicked ()
769 if (shuttle_style_menu == 0) {
770 shuttle_style_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("ShuttleStylePopup"));
772 shuttle_style_menu->popup (1, 0);
776 ARDOUR_UI::shuttle_unit_clicked ()
778 if (shuttle_unit_menu == 0) {
779 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("ShuttleUnitPopup"));
781 shuttle_unit_menu->popup (1, 0);
785 ARDOUR_UI::set_shuttle_units (ShuttleUnits u)
787 switch ((shuttle_units = u)) {
789 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text ("% ");
792 static_cast<Gtk::Label*>(shuttle_units_button.get_child())->set_text (_("st"));
798 ARDOUR_UI::set_shuttle_behaviour (ShuttleBehaviour b)
800 switch ((shuttle_behaviour = b)) {
802 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("sprung"));
804 shuttle_box.queue_draw ();
806 if (session->transport_rolling()) {
807 shuttle_fract = SHUTTLE_FRACT_SPEED1;
808 session->request_transport_speed (1.0);
813 static_cast<Gtk::Label*>(shuttle_style_button.get_child())->set_text (_("wheel"));
819 ARDOUR_UI::update_speed_display ()
822 speed_display_label.set_text (_("stopped"));
827 float x = session->transport_speed ();
830 if (shuttle_units == Percentage) {
831 snprintf (buf, sizeof (buf), "%.4f", x);
834 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
836 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
839 speed_display_label.set_text (buf);
841 speed_display_label.set_text (_("stopped"));
846 ARDOUR_UI::set_transport_sensitivity (bool yn)
848 goto_start_button.set_sensitive (yn);
849 goto_end_button.set_sensitive (yn);
850 roll_button.set_sensitive (yn);
851 stop_button.set_sensitive (yn);
852 play_selection_button.set_sensitive (yn);
853 rec_button.set_sensitive (yn);
854 auto_loop_button.set_sensitive (yn);
855 shuttle_box.set_sensitive (yn);