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
);
79 EventBox
* status_bar_event_box
= manage (new EventBox
);
81 status_bar_event_box
->add (status_bar_label
);
82 status_bar_event_box
->add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
);
83 status_bar_label
.set_size_request (300, -1);
84 status_bar_packer
->pack_start (*status_bar_event_box
, true, true, 6);
85 status_bar_packer
->pack_start (error_log_button
, false, false);
87 status_bar_label
.show ();
88 status_bar_event_box
->show ();
89 status_bar_packer
->show ();
90 error_log_button
.show ();
92 error_log_button
.signal_clicked().connect (mem_fun (*this, &UI::toggle_errors
));
93 status_bar_event_box
->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press
));
95 editor
->get_status_bar_packer().pack_start (*status_bar_packer
, true, true);
96 editor
->get_status_bar_packer().pack_start (menu_bar_base
, false, false, 6);
98 top_packer
.pack_start (menu_bar_base
, false, false);
101 top_packer
.pack_start (transport_frame
, false, false);
103 editor
->add_toplevel_controls (top_packer
);
115 ARDOUR_UI::setup_tooltips ()
117 set_tip (roll_button
, _("Play from playhead"));
118 set_tip (stop_button
, _("Stop playback"));
119 set_tip (rec_button
, _("Toggle record"));
120 set_tip (play_selection_button
, _("Play range/selection"));
121 set_tip (join_play_range_button
, _("Always play range/selection"));
122 set_tip (goto_start_button
, _("Go to start of session"));
123 set_tip (goto_end_button
, _("Go to end of session"));
124 set_tip (auto_loop_button
, _("Play loop range"));
126 set_tip (auto_return_button
, _("Return to last playback start when stopped"));
127 set_tip (auto_play_button
, _("Start playback after any locate"));
128 set_tip (auto_input_button
, _("Be sensible about input monitoring"));
129 set_tip (punch_in_button
, _("Start recording at auto-punch start"));
130 set_tip (punch_out_button
, _("Stop recording at auto-punch end"));
131 set_tip (click_button
, _("Enable/Disable audio click"));
132 set_tip (sync_button
, _("Enable/Disable external positional sync"));
133 set_tip (time_master_button
, string_compose (_("Does %1 control the time?"), PROGRAM_NAME
));
134 set_tip (shuttle_box
, _("Shuttle speed control"));
135 set_tip (shuttle_units_button
, _("Select semitones or %%-age for speed display"));
136 set_tip (speed_display_box
, _("Current transport speed"));
137 set_tip (solo_alert_button
, _("When active, something is soloed.\nClick to de-solo everything"));
138 set_tip (auditioning_alert_button
, _("When active, auditioning is taking place\nClick to stop the audition"));
139 set_tip (primary_clock
, _("Primary clock"));
140 set_tip (secondary_clock
, _("secondary clock"));
142 editor
->setup_tooltips ();
146 ARDOUR_UI::status_bar_button_press (GdkEventButton
* ev
)
148 bool handled
= false;
150 switch (ev
->button
) {
152 status_bar_label
.set_text ("");
163 ARDOUR_UI::display_message (const char *prefix
, gint prefix_len
, RefPtr
<TextBuffer::Tag
> ptag
, RefPtr
<TextBuffer::Tag
> mtag
, const char *msg
)
167 UI::display_message (prefix
, prefix_len
, ptag
, mtag
, msg
);
170 if (strcmp (prefix
, _("[ERROR]: ")) == 0) {
171 text
= "<span color=\"red\" weight=\"bold\">";
172 } else if (strcmp (prefix
, _("[WARNING]: ")) == 0) {
173 text
= "<span color=\"yellow\" weight=\"bold\">";
174 } else if (strcmp (prefix
, _("[INFO]: ")) == 0) {
175 text
= "<span color=\"green\" weight=\"bold\">";
177 text
= "<span color=\"white\" weight=\"bold\">???";
184 status_bar_label
.set_markup (text
);
189 ARDOUR_UI::tearoff_settings (const char* name
) const
191 XMLNode
* ui_node
= Config
->extra_xml(X_("UI"));
194 XMLNode
* tearoff_node
= ui_node
->child (X_("Tearoffs"));
196 XMLNode
* mnode
= tearoff_node
->child (name
);
205 ARDOUR_UI::setup_transport ()
207 transport_tearoff
= manage (new TearOff (transport_tearoff_hbox
));
208 transport_tearoff
->set_name ("TransportBase");
209 transport_tearoff
->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press
), &transport_tearoff
->tearoff_window()), false);
211 if (Profile
->get_sae()) {
212 transport_tearoff
->set_can_be_torn_off (false);
215 transport_hbox
.pack_start (*transport_tearoff
, true, false);
217 transport_base
.set_name ("TransportBase");
218 transport_base
.add (transport_hbox
);
220 transport_frame
.set_shadow_type (SHADOW_OUT
);
221 transport_frame
.set_name ("BaseFrame");
222 transport_frame
.add (transport_base
);
224 transport_tearoff
->Detach
.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff
), static_cast<Box
*>(&top_packer
),
225 static_cast<Widget
*>(&transport_frame
)));
226 transport_tearoff
->Attach
.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff
), static_cast<Box
*> (&top_packer
),
227 static_cast<Widget
*> (&transport_frame
), 1));
228 transport_tearoff
->Hidden
.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff
), static_cast<Box
*>(&top_packer
),
229 static_cast<Widget
*>(&transport_frame
)));
230 transport_tearoff
->Visible
.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff
), static_cast<Box
*> (&top_packer
),
231 static_cast<Widget
*> (&transport_frame
), 1));
233 shuttle_box
.set_name ("TransportButton");
234 goto_start_button
.set_name ("TransportButton");
235 goto_end_button
.set_name ("TransportButton");
236 roll_button
.set_name ("TransportButton");
237 stop_button
.set_name ("TransportButton");
238 play_selection_button
.set_name ("TransportButton");
239 rec_button
.set_name ("TransportRecButton");
240 auto_loop_button
.set_name ("TransportButton");
241 join_play_range_button
.set_name ("TransportButton");
243 auto_return_button
.set_name ("TransportButton");
244 auto_play_button
.set_name ("TransportButton");
245 auto_input_button
.set_name ("TransportButton");
246 punch_in_button
.set_name ("TransportButton");
247 punch_out_button
.set_name ("TransportButton");
248 click_button
.set_name ("TransportButton");
249 time_master_button
.set_name ("TransportButton");
250 sync_button
.set_name ("TransportSyncButton");
252 stop_button
.set_size_request(29, -1);
253 roll_button
.set_size_request(29, -1);
254 auto_loop_button
.set_size_request(29, -1);
255 play_selection_button
.set_size_request(29, -1);
256 goto_start_button
.set_size_request(29, -1);
257 goto_end_button
.set_size_request(29, -1);
258 rec_button
.set_size_request(29, -1);
262 stop_button
.set_visual_state (1);
264 w
= manage (new Image (get_icon (X_("transport_start"))));
266 goto_start_button
.add (*w
);
267 w
= manage (new Image (get_icon (X_("transport_end"))));
269 goto_end_button
.add (*w
);
270 w
= manage (new Image (get_icon (X_("transport_play"))));
272 roll_button
.add (*w
);
273 w
= manage (new Image (get_icon (X_("transport_stop"))));
275 stop_button
.add (*w
);
276 w
= manage (new Image (get_icon (X_("transport_range"))));
278 play_selection_button
.add (*w
);
279 w
= manage (new Image (get_icon (X_("transport_record"))));
282 w
= manage (new Image (get_icon (X_("transport_loop"))));
284 auto_loop_button
.add (*w
);
285 w
= manage (new Image (get_icon (X_("join_tools"))));
287 join_play_range_button
.add (*w
);
291 act
= ActionManager::get_action (X_("Transport"), X_("Stop"));
292 act
->connect_proxy (stop_button
);
293 act
= ActionManager::get_action (X_("Transport"), X_("Roll"));
294 act
->connect_proxy (roll_button
);
295 act
= ActionManager::get_action (X_("Transport"), X_("Record"));
296 act
->connect_proxy (rec_button
);
297 act
= ActionManager::get_action (X_("Transport"), X_("GotoStart"));
298 act
->connect_proxy (goto_start_button
);
299 act
= ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
300 act
->connect_proxy (goto_end_button
);
301 act
= ActionManager::get_action (X_("Transport"), X_("Loop"));
302 act
->connect_proxy (auto_loop_button
);
303 act
= ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
304 act
->connect_proxy (play_selection_button
);
305 act
= ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
306 act
->connect_proxy (time_master_button
);
307 act
= ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
308 act
->connect_proxy (sync_button
);
310 shuttle_box
.set_flags (CAN_FOCUS
);
311 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
);
312 shuttle_box
.set_size_request (100, 15);
314 shuttle_box
.signal_button_press_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press
));
315 shuttle_box
.signal_button_release_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release
));
316 shuttle_box
.signal_scroll_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll
));
317 shuttle_box
.signal_motion_notify_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_motion
));
318 shuttle_box
.signal_expose_event().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_box_expose
));
322 ARDOUR_UI::Clock
.connect (sigc::bind (sigc::mem_fun (primary_clock
, &AudioClock::set
), 'p'));
323 ARDOUR_UI::Clock
.connect (sigc::bind (sigc::mem_fun (secondary_clock
, &AudioClock::set
), 's'));
325 primary_clock
.ValueChanged
.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed
));
326 secondary_clock
.ValueChanged
.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed
));
327 big_clock
.ValueChanged
.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed
));
329 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button
);
330 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button
);
331 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button
);
332 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button
);
333 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button
);
334 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button
);
336 preroll_button
.set_name ("TransportButton");
337 postroll_button
.set_name ("TransportButton");
339 preroll_clock
.set_mode (AudioClock::MinSec
);
340 preroll_clock
.set_name ("TransportClockDisplay");
341 postroll_clock
.set_mode (AudioClock::MinSec
);
342 postroll_clock
.set_name ("TransportClockDisplay");
346 /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
348 solo_alert_button
.set_name ("TransportSoloAlert");
349 solo_alert_button
.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::solo_alert_press
), false);
350 auditioning_alert_button
.set_name ("TransportAuditioningAlert");
351 auditioning_alert_button
.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press
), false);
353 alert_box
.pack_start (solo_alert_button
, false, false);
354 alert_box
.pack_start (auditioning_alert_button
, false, false);
356 transport_tearoff_hbox
.set_border_width (3);
358 transport_tearoff_hbox
.pack_start (goto_start_button
, false, false);
359 transport_tearoff_hbox
.pack_start (goto_end_button
, false, false);
361 Frame
* sframe
= manage (new Frame
);
362 VBox
* svbox
= manage (new VBox
);
363 HBox
* shbox
= manage (new HBox
);
365 sframe
->set_shadow_type (SHADOW_IN
);
366 sframe
->add (shuttle_box
);
368 shuttle_box
.set_name (X_("ShuttleControl"));
370 speed_display_box
.add (speed_display_label
);
371 speed_display_box
.set_name (X_("ShuttleDisplay"));
372 set_size_request_to_display_given_text (speed_display_label
, X_("> 24.0"), 2, 2);
374 shuttle_units_button
.set_name (X_("ShuttleButton"));
375 shuttle_units_button
.signal_clicked().connect (sigc::mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked
));
377 shuttle_style_button
.set_name (X_("ShuttleStyleButton"));
379 vector
<string
> shuttle_strings
;
380 shuttle_strings
.push_back (_("sprung"));
381 shuttle_strings
.push_back (_("wheel"));
382 set_popdown_strings (shuttle_style_button
, shuttle_strings
, true);
383 shuttle_style_button
.signal_changed().connect (sigc::mem_fun (*this, &ARDOUR_UI::shuttle_style_changed
));
385 Frame
* sdframe
= manage (new Frame
);
387 sdframe
->set_shadow_type (SHADOW_IN
);
388 sdframe
->add (speed_display_box
);
390 /* translators: Egternal is "External" with a descender character */
391 set_size_request_to_display_given_text (sync_button
, X_("Egternal"), 4, 10);
393 shbox
->pack_start (*sdframe
, false, false);
394 shbox
->pack_start (shuttle_units_button
, true, true);
395 shbox
->pack_start (shuttle_style_button
, false, false);
397 svbox
->pack_start (*sframe
, false, false);
398 svbox
->pack_start (*shbox
, false, false);
400 transport_tearoff_hbox
.pack_start (*svbox
, false, false, 3);
402 if (Profile
->get_sae()) {
403 transport_tearoff_hbox
.pack_start (auto_loop_button
);
404 transport_tearoff_hbox
.pack_start (roll_button
);
406 transport_tearoff_hbox
.pack_start (auto_loop_button
, false, false);
407 play_range_hbox
.pack_start (play_selection_button
, false, false);
408 play_range_hbox
.pack_start (roll_button
, false, false);
409 play_range_vbox
.pack_start (play_range_hbox
, false, false);
410 play_range_vbox
.pack_start (join_play_range_button
, false, false);
411 transport_tearoff_hbox
.pack_start (play_range_vbox
, false, false);
413 transport_tearoff_hbox
.pack_start (stop_button
, false, false);
414 transport_tearoff_hbox
.pack_start (rec_button
, false, false, 6);
416 HBox
* clock_box
= manage (new HBox
);
417 clock_box
->pack_start (primary_clock
, false, false);
418 if (!ARDOUR::Profile
->get_small_screen()) {
419 clock_box
->pack_start (secondary_clock
, false, false);
422 if (!Profile
->get_sae()) {
423 VBox
* time_controls_box
= manage (new VBox
);
424 time_controls_box
->pack_start (sync_button
, false, false);
425 time_controls_box
->pack_start (time_master_button
, false, false);
426 clock_box
->pack_start (*time_controls_box
, false, false, 1);
429 transport_tearoff_hbox
.pack_start (*clock_box
, false, false, 0);
431 HBox
* toggle_box
= manage(new HBox
);
433 VBox
* punch_box
= manage (new VBox
);
434 punch_box
->pack_start (punch_in_button
, false, false);
435 punch_box
->pack_start (punch_out_button
, false, false);
436 toggle_box
->pack_start (*punch_box
, false, false);
438 VBox
* auto_box
= manage (new VBox
);
439 auto_box
->pack_start (auto_play_button
, false, false);
440 auto_box
->pack_start (auto_return_button
, false, false);
441 toggle_box
->pack_start (*auto_box
, false, false);
443 VBox
* io_box
= manage (new VBox
);
444 io_box
->pack_start (auto_input_button
, false, false);
445 io_box
->pack_start (click_button
, false, false);
446 toggle_box
->pack_start (*io_box
, false, false);
450 set_transport_sensitivity (false);
452 // toggle_box->pack_start (preroll_button, false, false);
453 // toggle_box->pack_start (preroll_clock, false, false);
455 // toggle_box->pack_start (postroll_button, false, false);
456 // toggle_box->pack_start (postroll_clock, false, false);
458 transport_tearoff_hbox
.pack_start (*toggle_box
, false, false, 4);
459 transport_tearoff_hbox
.pack_start (alert_box
, false, false);
461 if (Profile
->get_sae()) {
462 Image
* img
= manage (new Image ((::get_icon (X_("sae")))));
463 transport_tearoff_hbox
.pack_end (*img
, false, false, 6);
466 XMLNode
* tnode
= tearoff_settings ("transport");
468 transport_tearoff
->set_state (*tnode
);
473 ARDOUR_UI::manage_window (Window
& win
)
475 win
.signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it
), &win
));
476 win
.signal_enter_notify_event().connect (sigc::bind (sigc::mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window
), &win
));
477 win
.signal_leave_notify_event().connect (sigc::bind (sigc::mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window
), &win
));
481 ARDOUR_UI::detach_tearoff (Box
* b
, Widget
* w
)
483 // editor->ensure_float (transport_tearoff->tearoff_window());
488 ARDOUR_UI::reattach_tearoff (Box
* b
, Widget
* w
, int32_t n
)
491 b
->reorder_child (*w
, n
);
495 ARDOUR_UI::soloing_changed (bool onoff
)
497 if (solo_alert_button
.get_active() != onoff
) {
498 solo_alert_button
.set_active (onoff
);
503 ARDOUR_UI::_auditioning_changed (bool onoff
)
505 if (auditioning_alert_button
.get_active() != onoff
) {
506 auditioning_alert_button
.set_active (onoff
);
507 set_transport_sensitivity (!onoff
);
512 ARDOUR_UI::auditioning_changed (bool onoff
)
514 UI::instance()->call_slot (MISSING_INVALIDATOR
, boost::bind (&ARDOUR_UI::_auditioning_changed
, this, onoff
));
518 ARDOUR_UI::audition_alert_press (GdkEventButton
* ev
)
521 _session
->cancel_audition();
527 ARDOUR_UI::solo_alert_press (GdkEventButton
* ev
)
530 if (_session
->soloing()) {
531 _session
->set_solo (_session
->get_routes(), false);
532 } else if (_session
->listening()) {
533 _session
->set_listen (_session
->get_routes(), false);
540 ARDOUR_UI::solo_blink (bool onoff
)
546 if (_session
->soloing() || _session
->listening()) {
548 solo_alert_button
.set_state (STATE_ACTIVE
);
550 solo_alert_button
.set_state (STATE_NORMAL
);
553 solo_alert_button
.set_active (false);
554 solo_alert_button
.set_state (STATE_NORMAL
);
559 ARDOUR_UI::sync_blink (bool onoff
)
561 if (_session
== 0 || !_session
->config
.get_external_sync()) {
563 sync_button
.set_visual_state (0);
567 if (!_session
->transport_locked()) {
568 /* not locked, so blink on and off according to the onoff argument */
571 sync_button
.set_visual_state (1); // "-active"
573 sync_button
.set_visual_state (0); // normal
577 sync_button
.set_visual_state (1); // "-active"
582 ARDOUR_UI::audition_blink (bool onoff
)
588 if (_session
->is_auditioning()) {
590 auditioning_alert_button
.set_state (STATE_ACTIVE
);
592 auditioning_alert_button
.set_state (STATE_NORMAL
);
595 auditioning_alert_button
.set_active (false);
596 auditioning_alert_button
.set_state (STATE_NORMAL
);
601 ARDOUR_UI::build_shuttle_context_menu ()
603 using namespace Menu_Helpers
;
605 shuttle_context_menu
= new Menu();
606 MenuList
& items
= shuttle_context_menu
->items();
608 Menu
* speed_menu
= manage (new Menu());
609 MenuList
& speed_items
= speed_menu
->items();
611 RadioMenuItem::Group group
;
613 speed_items
.push_back (RadioMenuElem (group
, "8", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 8.0f
)));
614 if (shuttle_max_speed
== 8.0) {
615 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
617 speed_items
.push_back (RadioMenuElem (group
, "6", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 6.0f
)));
618 if (shuttle_max_speed
== 6.0) {
619 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
621 speed_items
.push_back (RadioMenuElem (group
, "4", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 4.0f
)));
622 if (shuttle_max_speed
== 4.0) {
623 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
625 speed_items
.push_back (RadioMenuElem (group
, "3", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 3.0f
)));
626 if (shuttle_max_speed
== 3.0) {
627 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
629 speed_items
.push_back (RadioMenuElem (group
, "2", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 2.0f
)));
630 if (shuttle_max_speed
== 2.0) {
631 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
633 speed_items
.push_back (RadioMenuElem (group
, "1.5", sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 1.5f
)));
634 if (shuttle_max_speed
== 1.5) {
635 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
638 items
.push_back (MenuElem (_("Maximum speed"), *speed_menu
));
642 ARDOUR_UI::show_shuttle_context_menu ()
644 if (shuttle_context_menu
== 0) {
645 build_shuttle_context_menu ();
648 shuttle_context_menu
->popup (1, gtk_get_current_event_time());
652 ARDOUR_UI::set_shuttle_max_speed (float speed
)
654 shuttle_max_speed
= speed
;
658 ARDOUR_UI::shuttle_box_button_press (GdkEventButton
* ev
)
664 if (shuttle_controller_binding_proxy
.button_press_handler (ev
)) {
668 if (Keyboard::is_context_menu_event (ev
)) {
669 show_shuttle_context_menu ();
673 switch (ev
->button
) {
675 shuttle_box
.add_modal_grab ();
676 shuttle_grabbed
= true;
677 mouse_shuttle (ev
->x
, true);
690 ARDOUR_UI::shuttle_box_button_release (GdkEventButton
* ev
)
696 switch (ev
->button
) {
698 mouse_shuttle (ev
->x
, true);
699 shuttle_grabbed
= false;
700 shuttle_box
.remove_modal_grab ();
701 if (Config
->get_shuttle_behaviour() == Sprung
) {
702 if (_session
->config
.get_auto_play() || roll_button
.get_visual_state()) {
703 shuttle_fract
= SHUTTLE_FRACT_SPEED1
;
704 _session
->request_transport_speed (1.0);
705 stop_button
.set_visual_state (0);
706 roll_button
.set_visual_state (1);
709 _session
->request_transport_speed (0.0);
711 shuttle_box
.queue_draw ();
716 if (_session
->transport_rolling()) {
717 shuttle_fract
= SHUTTLE_FRACT_SPEED1
;
718 _session
->request_transport_speed (1.0);
719 stop_button
.set_visual_state (0);
720 roll_button
.set_visual_state (1);
724 shuttle_box
.queue_draw ();
733 use_shuttle_fract (true);
739 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll
* ev
)
745 switch (ev
->direction
) {
748 shuttle_fract
+= 0.005;
750 case GDK_SCROLL_DOWN
:
751 shuttle_fract
-= 0.005;
754 /* scroll left/right */
758 use_shuttle_fract (true);
764 ARDOUR_UI::shuttle_box_motion (GdkEventMotion
* ev
)
766 if (!_session
|| !shuttle_grabbed
) {
770 return mouse_shuttle (ev
->x
, false);
774 ARDOUR_UI::mouse_shuttle (double x
, bool force
)
776 double half_width
= shuttle_box
.get_width() / 2.0;
777 double distance
= x
- half_width
;
780 distance
= min (distance
, half_width
);
782 distance
= max (distance
, -half_width
);
785 shuttle_fract
= distance
/ half_width
;
786 use_shuttle_fract (force
);
791 ARDOUR_UI::set_shuttle_fract (double f
)
794 use_shuttle_fract (false);
798 ARDOUR_UI::use_shuttle_fract (bool force
)
800 microseconds_t now
= get_microseconds();
802 /* do not attempt to submit a motion-driven transport speed request
803 more than once per process cycle.
806 if (!force
&& (last_shuttle_request
- now
) < (microseconds_t
) engine
->usecs_per_cycle()) {
810 last_shuttle_request
= now
;
812 if (Config
->get_shuttle_units() == Semitones
) {
814 const double step
= 1.0 / 24.0; // range is 24 semitones up & down
818 semitones
= round (shuttle_fract
/ step
);
819 speed
= pow (2.0, (semitones
/ 12.0));
821 _session
->request_transport_speed (speed
);
828 neg
= (shuttle_fract
< 0.0);
830 fract
= 1 - sqrt (1 - (shuttle_fract
* shuttle_fract
)); // Formula A1
836 _session
->request_transport_speed (shuttle_max_speed
* fract
);
839 shuttle_box
.queue_draw ();
843 ARDOUR_UI::shuttle_box_expose (GdkEventExpose
* event
)
846 Glib::RefPtr
<Gdk::Window
> win (shuttle_box
.get_window());
848 /* redraw the background */
850 win
->draw_rectangle (shuttle_box
.get_style()->get_bg_gc (shuttle_box
.get_state()),
852 event
->area
.x
, event
->area
.y
,
853 event
->area
.width
, event
->area
.height
);
856 x
= (gint
) floor ((shuttle_box
.get_width() / 2.0) + (0.5 * (shuttle_box
.get_width() * shuttle_fract
)));
860 win
->draw_line (shuttle_box
.get_style()->get_fg_gc (shuttle_box
.get_state()),
864 shuttle_box
.get_height());
869 ARDOUR_UI::shuttle_unit_clicked ()
871 if (shuttle_unit_menu
== 0) {
872 shuttle_unit_menu
= dynamic_cast<Menu
*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
874 shuttle_unit_menu
->popup (1, gtk_get_current_event_time());
878 ARDOUR_UI::shuttle_style_changed ()
880 ustring str
= shuttle_style_button
.get_active_text ();
882 if (str
== _("sprung")) {
883 Config
->set_shuttle_behaviour (Sprung
);
884 } else if (str
== _("wheel")) {
885 Config
->set_shuttle_behaviour (Wheel
);
890 ARDOUR_UI::update_speed_display ()
893 if (last_speed_displayed
!= 0) {
894 speed_display_label
.set_text (_("stop"));
895 last_speed_displayed
= 0;
901 float x
= _session
->transport_speed ();
903 if (x
!= last_speed_displayed
) {
906 if (Config
->get_shuttle_units() == Percentage
) {
907 snprintf (buf
, sizeof (buf
), "%d", (int) round (x
* 100));
911 snprintf (buf
, sizeof (buf
), "< %d", (int) round (12.0 * fast_log2 (-x
)));
913 snprintf (buf
, sizeof (buf
), "> %d", (int) round (12.0 * fast_log2 (x
)));
916 speed_display_label
.set_text (buf
);
918 speed_display_label
.set_text (_("stop"));
921 last_speed_displayed
= x
;
926 ARDOUR_UI::set_transport_sensitivity (bool yn
)
928 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions
, yn
);
929 shuttle_box
.set_sensitive (yn
);
933 ARDOUR_UI::editor_realized ()
935 boost::function
<void (string
)> pc (boost::bind (&ARDOUR_UI::parameter_changed
, this, _1
));
936 Config
->map_parameters (pc
);
938 set_size_request_to_display_given_text (speed_display_box
, _("-0.55"), 2, 2);
943 ARDOUR_UI::maximise_editing_space ()
949 transport_tearoff
->set_visible (false);
950 editor
->maximise_editing_space ();
954 ARDOUR_UI::restore_editing_space ()
960 transport_tearoff
->set_visible (true);
961 editor
->restore_editing_space ();