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/audioengine.h>
36 #include <ardour/ardour.h>
37 #include <ardour/profile.h>
38 #include <ardour/route.h>
40 #include "ardour_ui.h"
42 #include "public_editor.h"
43 #include "audio_clock.h"
46 #include "theme_manager.h"
51 using namespace ARDOUR
;
53 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 ();
79 theme_manager
->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction
), X_("<Actions>/Common/ToggleThemeManager")));
82 HBox
* status_bar_packer
= manage (new HBox
);
83 EventBox
* status_bar_event_box
= manage (new EventBox
);
85 status_bar_event_box
->add (status_bar_label
);
86 status_bar_event_box
->add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
);
87 status_bar_label
.set_size_request (300, -1);
88 status_bar_packer
->pack_start (*status_bar_event_box
, true, true, 6);
89 status_bar_packer
->pack_start (error_log_button
, false, false);
91 status_bar_label
.show ();
92 status_bar_event_box
->show ();
93 status_bar_packer
->show ();
94 error_log_button
.show ();
96 error_log_button
.signal_clicked().connect (mem_fun (*this, &UI::toggle_errors
));
97 status_bar_event_box
->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press
));
99 editor
->get_status_bar_packer().pack_start (*status_bar_packer
, true, true);
100 editor
->get_status_bar_packer().pack_start (menu_bar_base
, false, false, 6);
102 top_packer
.pack_start (menu_bar_base
, false, false);
104 top_packer
.pack_start (transport_frame
, false, false);
106 editor
->add_toplevel_controls (top_packer
);
112 ARDOUR_UI::status_bar_button_press (GdkEventButton
* ev
)
114 bool handled
= false;
116 switch (ev
->button
) {
118 status_bar_label
.set_text ("");
129 ARDOUR_UI::display_message (const char *prefix
, gint prefix_len
, RefPtr
<TextBuffer::Tag
> ptag
, RefPtr
<TextBuffer::Tag
> mtag
, const char *msg
)
133 UI::display_message (prefix
, prefix_len
, ptag
, mtag
, msg
);
136 if (strcmp (prefix
, _("[ERROR]: ")) == 0) {
137 text
= "<span color=\"red\" weight=\"bold\">";
138 } else if (strcmp (prefix
, _("[WARNING]: ")) == 0) {
139 text
= "<span color=\"yellow\" weight=\"bold\">";
140 } else if (strcmp (prefix
, _("[INFO]: ")) == 0) {
141 text
= "<span color=\"green\" weight=\"bold\">";
143 text
= "<span color=\"blue\" weight=\"bold\">???";
150 status_bar_label
.set_markup (text
);
155 ARDOUR_UI::setup_transport ()
157 transport_tearoff
= manage (new TearOff (transport_tearoff_hbox
));
158 transport_tearoff
->set_name ("TransportBase");
159 transport_tearoff
->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press
), &transport_tearoff
->tearoff_window()));
161 if (Profile
->get_sae()) {
162 transport_tearoff
->set_can_be_torn_off (false);
165 transport_hbox
.pack_start (*transport_tearoff
, true, false);
167 transport_base
.set_name ("TransportBase");
168 transport_base
.add (transport_hbox
);
170 transport_frame
.set_shadow_type (SHADOW_OUT
);
171 transport_frame
.set_name ("BaseFrame");
172 transport_frame
.add (transport_base
);
174 transport_tearoff
->Detach
.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff
), static_cast<Box
*>(&top_packer
),
175 static_cast<Widget
*>(&transport_frame
)));
176 transport_tearoff
->Attach
.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff
), static_cast<Box
*> (&top_packer
),
177 static_cast<Widget
*> (&transport_frame
), 1));
178 transport_tearoff
->Hidden
.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff
), static_cast<Box
*>(&top_packer
),
179 static_cast<Widget
*>(&transport_frame
)));
180 transport_tearoff
->Visible
.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff
), static_cast<Box
*> (&top_packer
),
181 static_cast<Widget
*> (&transport_frame
), 1));
183 shuttle_box
.set_name ("TransportButton");
184 goto_start_button
.set_name ("TransportButton");
185 goto_end_button
.set_name ("TransportButton");
186 roll_button
.set_name ("TransportButton");
187 stop_button
.set_name ("TransportButton");
188 play_selection_button
.set_name ("TransportButton");
189 rec_button
.set_name ("TransportRecButton");
190 auto_loop_button
.set_name ("TransportButton");
192 auto_return_button
.set_name ("TransportButton");
193 auto_play_button
.set_name ("TransportButton");
194 auto_input_button
.set_name ("TransportButton");
195 punch_in_button
.set_name ("TransportButton");
196 punch_out_button
.set_name ("TransportButton");
197 click_button
.set_name ("TransportButton");
198 time_master_button
.set_name ("TransportButton");
200 stop_button
.set_size_request(29, -1);
201 roll_button
.set_size_request(29, -1);
202 auto_loop_button
.set_size_request(29, -1);
203 play_selection_button
.set_size_request(29, -1);
204 goto_start_button
.set_size_request(29, -1);
205 goto_end_button
.set_size_request(29, -1);
206 rec_button
.set_size_request(29, -1);
210 stop_button
.set_visual_state (1);
212 w
= manage (new Image (get_icon (X_("transport_start"))));
214 goto_start_button
.add (*w
);
215 w
= manage (new Image (get_icon (X_("transport_end"))));
217 goto_end_button
.add (*w
);
218 w
= manage (new Image (get_icon (X_("transport_play"))));
220 roll_button
.add (*w
);
221 w
= manage (new Image (get_icon (X_("transport_stop"))));
223 stop_button
.add (*w
);
224 w
= manage (new Image (get_icon (X_("transport_range"))));
226 play_selection_button
.add (*w
);
227 w
= manage (new Image (get_icon (X_("transport_record"))));
230 w
= manage (new Image (get_icon (X_("transport_loop"))));
232 auto_loop_button
.add (*w
);
236 act
= ActionManager::get_action (X_("Transport"), X_("Stop"));
237 act
->connect_proxy (stop_button
);
238 act
= ActionManager::get_action (X_("Transport"), X_("Roll"));
239 act
->connect_proxy (roll_button
);
240 act
= ActionManager::get_action (X_("Transport"), X_("Record"));
241 act
->connect_proxy (rec_button
);
242 act
= ActionManager::get_action (X_("Transport"), X_("GotoStart"));
243 act
->connect_proxy (goto_start_button
);
244 act
= ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
245 act
->connect_proxy (goto_end_button
);
246 act
= ActionManager::get_action (X_("Transport"), X_("Loop"));
247 act
->connect_proxy (auto_loop_button
);
248 act
= ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
249 act
->connect_proxy (play_selection_button
);
250 act
= ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
251 act
->connect_proxy (time_master_button
);
253 ARDOUR_UI::instance()->tooltips().set_tip (roll_button
, _("Play from playhead"));
254 ARDOUR_UI::instance()->tooltips().set_tip (stop_button
, _("Stop playback"));
255 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button
, _("Play range/selection"));
256 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button
, _("Go to start of session"));
257 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button
, _("Go to end of session"));
258 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button
, _("Play loop range"));
260 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button
, _("Return to last playback start when stopped"));
261 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button
, _("Start playback after any locate"));
262 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button
, _("Be sensible about input monitoring"));
263 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button
, _("Start recording at auto-punch start"));
264 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button
, _("Stop recording at auto-punch end"));
265 ARDOUR_UI::instance()->tooltips().set_tip (click_button
, _("Enable/Disable audio click"));
266 ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo
, _("Positional sync source"));
267 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button
, _("Does Ardour control the time?"));
268 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box
, _("Shuttle speed control"));
269 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button
, _("Select semitones or %%-age for speed display"));
270 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box
, _("Current transport speed"));
272 shuttle_box
.set_flags (CAN_FOCUS
);
273 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
);
274 shuttle_box
.set_size_request (100, 15);
276 shuttle_box
.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press
));
277 shuttle_box
.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release
));
278 shuttle_box
.signal_scroll_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll
));
279 shuttle_box
.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion
));
280 shuttle_box
.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose
));
284 ARDOUR_UI::Clock
.connect (bind (mem_fun (primary_clock
, &AudioClock::set
), 1));
285 ARDOUR_UI::Clock
.connect (bind (mem_fun (secondary_clock
, &AudioClock::set
), 2));
287 primary_clock
.ValueChanged
.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed
));
288 secondary_clock
.ValueChanged
.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed
));
289 big_clock
.ValueChanged
.connect (mem_fun(*this, &ARDOUR_UI::big_clock_value_changed
));
291 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock
, _("Primary clock"));
292 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock
, _("secondary clock"));
294 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button
);
295 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button
);
296 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button
);
297 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button
);
298 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button
);
299 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button
);
301 preroll_button
.set_name ("TransportButton");
302 postroll_button
.set_name ("TransportButton");
304 preroll_clock
.set_mode (AudioClock::MinSec
);
305 preroll_clock
.set_name ("TransportClockDisplay");
306 postroll_clock
.set_mode (AudioClock::MinSec
);
307 postroll_clock
.set_name ("TransportClockDisplay");
311 /* CANNOT bind these to clicked or toggled, must use pressed or released */
313 solo_alert_button
.set_name ("TransportSoloAlert");
314 solo_alert_button
.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle
));
315 auditioning_alert_button
.set_name ("TransportAuditioningAlert");
316 auditioning_alert_button
.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle
));
318 tooltips().set_tip (solo_alert_button
, _("When active, something is soloed.\nClick to de-solo everything"));
319 tooltips().set_tip (auditioning_alert_button
, _("When active, auditioning is taking place\nClick to stop the audition"));
321 alert_box
.pack_start (solo_alert_button
, false, false);
322 alert_box
.pack_start (auditioning_alert_button
, false, false);
324 transport_tearoff_hbox
.set_border_width (3);
326 transport_tearoff_hbox
.pack_start (goto_start_button
, false, false);
327 transport_tearoff_hbox
.pack_start (goto_end_button
, false, false);
329 Frame
* sframe
= manage (new Frame
);
330 VBox
* svbox
= manage (new VBox
);
331 HBox
* shbox
= manage (new HBox
);
333 sframe
->set_shadow_type (SHADOW_IN
);
334 sframe
->add (shuttle_box
);
336 shuttle_box
.set_name (X_("ShuttleControl"));
338 speed_display_box
.add (speed_display_label
);
339 speed_display_box
.set_name (X_("ShuttleDisplay"));
340 set_size_request_to_display_given_text (speed_display_label
, X_("> 24.0"), 2, 2);
342 shuttle_units_button
.set_name (X_("ShuttleButton"));
343 shuttle_units_button
.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked
));
345 shuttle_style_button
.set_name (X_("ShuttleStyleButton"));
347 vector
<string
> shuttle_strings
;
348 shuttle_strings
.push_back (_("sprung"));
349 shuttle_strings
.push_back (_("wheel"));
350 set_popdown_strings (shuttle_style_button
, shuttle_strings
, true);
351 shuttle_style_button
.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed
));
353 Frame
* sdframe
= manage (new Frame
);
355 sdframe
->set_shadow_type (SHADOW_IN
);
356 sdframe
->add (speed_display_box
);
359 sync_option_combo
.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed
));
360 // XXX HOW TO USE set_popdown_strings() and combo_fudge with this when we don't know
361 // the real strings till later?
362 set_size_request_to_display_given_text (sync_option_combo
, X_("Igternal"), 4+COMBO_FUDGE
, 10);
364 shbox
->pack_start (*sdframe
, false, false);
365 shbox
->pack_start (shuttle_units_button
, true, true);
366 shbox
->pack_start (shuttle_style_button
, false, false);
368 svbox
->pack_start (*sframe
, false, false);
369 svbox
->pack_start (*shbox
, false, false);
371 transport_tearoff_hbox
.pack_start (*svbox
, false, false, 3);
373 transport_tearoff_hbox
.pack_start (auto_loop_button
, false, false);
374 if (!Profile
->get_sae()) {
375 transport_tearoff_hbox
.pack_start (play_selection_button
, false, false);
377 transport_tearoff_hbox
.pack_start (roll_button
, false, false);
378 transport_tearoff_hbox
.pack_start (stop_button
, false, false);
379 transport_tearoff_hbox
.pack_start (rec_button
, false, false, 6);
381 HBox
* clock_box
= manage (new HBox
);
382 clock_box
->pack_start (primary_clock
, false, false);
383 if (!ARDOUR::Profile
->get_small_screen()) {
384 clock_box
->pack_start (secondary_clock
, false, false);
387 if (!Profile
->get_sae()) {
388 VBox
* time_controls_box
= manage (new VBox
);
389 time_controls_box
->pack_start (sync_option_combo
, false, false);
390 time_controls_box
->pack_start (time_master_button
, false, false);
391 clock_box
->pack_start (*time_controls_box
, false, false, 1);
394 transport_tearoff_hbox
.pack_start (*clock_box
, false, false, 0);
396 HBox
* toggle_box
= manage(new HBox
);
398 VBox
* punch_box
= manage (new VBox
);
399 punch_box
->pack_start (punch_in_button
, false, false);
400 punch_box
->pack_start (punch_out_button
, false, false);
401 toggle_box
->pack_start (*punch_box
, false, false);
403 VBox
* auto_box
= manage (new VBox
);
404 auto_box
->pack_start (auto_play_button
, false, false);
405 auto_box
->pack_start (auto_return_button
, false, false);
406 toggle_box
->pack_start (*auto_box
, false, false);
408 VBox
* io_box
= manage (new VBox
);
409 io_box
->pack_start (auto_input_button
, false, false);
410 io_box
->pack_start (click_button
, false, false);
411 toggle_box
->pack_start (*io_box
, false, false);
415 set_transport_sensitivity (false);
417 // toggle_box->pack_start (preroll_button, false, false);
418 // toggle_box->pack_start (preroll_clock, false, false);
420 // toggle_box->pack_start (postroll_button, false, false);
421 // toggle_box->pack_start (postroll_clock, false, false);
423 transport_tearoff_hbox
.pack_start (*toggle_box
, false, false, 4);
424 transport_tearoff_hbox
.pack_start (alert_box
, false, false);
426 if (Profile
->get_sae()) {
427 Image
* img
= manage (new Image ((::get_icon (X_("sae")))));
428 transport_tearoff_hbox
.pack_end (*img
, false, false, 6);
433 ARDOUR_UI::manage_window (Window
& win
)
435 win
.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it
), &win
));
436 win
.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window
), &win
));
437 win
.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window
), &win
));
441 ARDOUR_UI::detach_tearoff (Box
* b
, Widget
* w
)
443 // editor->ensure_float (transport_tearoff->tearoff_window());
448 ARDOUR_UI::reattach_tearoff (Box
* b
, Widget
* w
, int32_t n
)
451 b
->reorder_child (*w
, n
);
455 ARDOUR_UI::soloing_changed (bool onoff
)
457 if (solo_alert_button
.get_active() != onoff
) {
458 solo_alert_button
.set_active (onoff
);
463 ARDOUR_UI::_auditioning_changed (bool onoff
)
465 if (auditioning_alert_button
.get_active() != onoff
) {
466 auditioning_alert_button
.set_active (onoff
);
467 set_transport_sensitivity (!onoff
);
472 ARDOUR_UI::auditioning_changed (bool onoff
)
474 UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed
), onoff
));
478 ARDOUR_UI::audition_alert_toggle ()
481 session
->cancel_audition();
486 ARDOUR_UI::solo_alert_toggle ()
489 session
->set_all_solo (!session
->soloing());
494 ARDOUR_UI::solo_blink (bool onoff
)
500 if (session
->soloing()) {
502 solo_alert_button
.set_state (STATE_ACTIVE
);
504 solo_alert_button
.set_state (STATE_NORMAL
);
507 solo_alert_button
.set_active (false);
508 solo_alert_button
.set_state (STATE_NORMAL
);
513 ARDOUR_UI::audition_blink (bool onoff
)
519 if (session
->is_auditioning()) {
521 auditioning_alert_button
.set_state (STATE_ACTIVE
);
523 auditioning_alert_button
.set_state (STATE_NORMAL
);
526 auditioning_alert_button
.set_active (false);
527 auditioning_alert_button
.set_state (STATE_NORMAL
);
532 ARDOUR_UI::build_shuttle_context_menu ()
534 using namespace Menu_Helpers
;
536 shuttle_context_menu
= new Menu();
537 MenuList
& items
= shuttle_context_menu
->items();
539 Menu
* speed_menu
= manage (new Menu());
540 MenuList
& speed_items
= speed_menu
->items();
542 RadioMenuItem::Group group
;
544 speed_items
.push_back (RadioMenuElem (group
, "8", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 8.0f
)));
545 if (shuttle_max_speed
== 8.0) {
546 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
548 speed_items
.push_back (RadioMenuElem (group
, "6", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 6.0f
)));
549 if (shuttle_max_speed
== 6.0) {
550 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
552 speed_items
.push_back (RadioMenuElem (group
, "4", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 4.0f
)));
553 if (shuttle_max_speed
== 4.0) {
554 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
556 speed_items
.push_back (RadioMenuElem (group
, "3", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 3.0f
)));
557 if (shuttle_max_speed
== 3.0) {
558 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
560 speed_items
.push_back (RadioMenuElem (group
, "2", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 2.0f
)));
561 if (shuttle_max_speed
== 2.0) {
562 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
564 speed_items
.push_back (RadioMenuElem (group
, "1.5", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed
), 1.5f
)));
565 if (shuttle_max_speed
== 1.5) {
566 static_cast<RadioMenuItem
*>(&speed_items
.back())->set_active ();
569 items
.push_back (MenuElem (_("Maximum speed"), *speed_menu
));
573 ARDOUR_UI::show_shuttle_context_menu ()
575 if (shuttle_context_menu
== 0) {
576 build_shuttle_context_menu ();
579 shuttle_context_menu
->popup (1, gtk_get_current_event_time());
583 ARDOUR_UI::set_shuttle_max_speed (float speed
)
585 shuttle_max_speed
= speed
;
589 ARDOUR_UI::shuttle_box_button_press (GdkEventButton
* ev
)
595 if (shuttle_controller_binding_proxy
.button_press_handler (ev
)) {
599 if (Keyboard::is_context_menu_event (ev
)) {
600 show_shuttle_context_menu ();
604 switch (ev
->button
) {
606 shuttle_box
.add_modal_grab ();
607 shuttle_grabbed
= true;
608 mouse_shuttle (ev
->x
, true);
621 ARDOUR_UI::shuttle_box_button_release (GdkEventButton
* ev
)
627 switch (ev
->button
) {
629 mouse_shuttle (ev
->x
, true);
630 shuttle_grabbed
= false;
631 shuttle_box
.remove_modal_grab ();
632 if (Config
->get_shuttle_behaviour() == Sprung
) {
633 if (Config
->get_auto_play() || roll_button
.get_visual_state()) {
634 shuttle_fract
= SHUTTLE_FRACT_SPEED1
;
635 session
->request_transport_speed (1.0);
636 stop_button
.set_visual_state (0);
637 roll_button
.set_visual_state (1);
640 session
->request_stop ();
642 shuttle_box
.queue_draw ();
647 if (session
->transport_rolling()) {
648 shuttle_fract
= SHUTTLE_FRACT_SPEED1
;
649 session
->request_transport_speed (1.0);
650 stop_button
.set_visual_state (0);
651 roll_button
.set_visual_state (1);
655 shuttle_box
.queue_draw ();
664 use_shuttle_fract (true);
670 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll
* ev
)
676 switch (ev
->direction
) {
679 shuttle_fract
+= 0.005;
681 case GDK_SCROLL_DOWN
:
682 shuttle_fract
-= 0.005;
685 /* scroll left/right */
689 use_shuttle_fract (true);
695 ARDOUR_UI::shuttle_box_motion (GdkEventMotion
* ev
)
697 if (!session
|| !shuttle_grabbed
) {
701 return mouse_shuttle (ev
->x
, false);
705 ARDOUR_UI::mouse_shuttle (double x
, bool force
)
707 double half_width
= shuttle_box
.get_width() / 2.0;
708 double distance
= x
- half_width
;
711 distance
= min (distance
, half_width
);
713 distance
= max (distance
, -half_width
);
716 shuttle_fract
= distance
/ half_width
;
717 use_shuttle_fract (force
);
722 ARDOUR_UI::set_shuttle_fract (double f
)
725 use_shuttle_fract (false);
729 ARDOUR_UI::use_shuttle_fract (bool force
)
731 microseconds_t now
= get_microseconds();
733 /* do not attempt to submit a motion-driven transport speed request
734 more than once per process cycle.
737 if (!force
&& (last_shuttle_request
- now
) < (microseconds_t
) engine
->usecs_per_cycle()) {
741 last_shuttle_request
= now
;
743 if (Config
->get_shuttle_units() == Semitones
) {
745 const double step
= 1.0 / 24.0; // range is 24 semitones up & down
749 semitones
= round (shuttle_fract
/ step
);
750 speed
= pow (2.0, (semitones
/ 12.0));
752 session
->request_transport_speed (speed
);
759 neg
= (shuttle_fract
< 0.0);
761 fract
= 1 - sqrt (1 - (shuttle_fract
* shuttle_fract
)); // Formula A1
767 session
->request_transport_speed (shuttle_max_speed
* fract
);
770 shuttle_box
.queue_draw ();
774 ARDOUR_UI::shuttle_box_expose (GdkEventExpose
* event
)
777 Glib::RefPtr
<Gdk::Window
> win (shuttle_box
.get_window());
779 /* redraw the background */
781 win
->draw_rectangle (shuttle_box
.get_style()->get_bg_gc (shuttle_box
.get_state()),
783 event
->area
.x
, event
->area
.y
,
784 event
->area
.width
, event
->area
.height
);
787 x
= (gint
) floor ((shuttle_box
.get_width() / 2.0) + (0.5 * (shuttle_box
.get_width() * shuttle_fract
)));
791 win
->draw_line (shuttle_box
.get_style()->get_fg_gc (shuttle_box
.get_state()),
795 shuttle_box
.get_height());
800 ARDOUR_UI::shuttle_unit_clicked ()
802 if (shuttle_unit_menu
== 0) {
803 shuttle_unit_menu
= dynamic_cast<Menu
*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
805 shuttle_unit_menu
->popup (1, gtk_get_current_event_time());
809 ARDOUR_UI::shuttle_style_changed ()
811 ustring str
= shuttle_style_button
.get_active_text ();
813 if (str
== _("sprung")) {
814 Config
->set_shuttle_behaviour (Sprung
);
815 } else if (str
== _("wheel")) {
816 Config
->set_shuttle_behaviour (Wheel
);
821 ARDOUR_UI::update_speed_display ()
824 if (last_speed_displayed
!= 0) {
825 speed_display_label
.set_text (_("stop"));
826 last_speed_displayed
= 0;
832 float x
= session
->transport_speed ();
834 if (x
!= last_speed_displayed
) {
837 if (Config
->get_shuttle_units() == Percentage
) {
838 snprintf (buf
, sizeof (buf
), "%.2f", x
);
842 snprintf (buf
, sizeof (buf
), "< %d", (int) round (12.0 * fast_log2 (-x
)));
844 snprintf (buf
, sizeof (buf
), "> %d", (int) round (12.0 * fast_log2 (x
)));
847 speed_display_label
.set_text (buf
);
849 speed_display_label
.set_text (_("stop"));
852 last_speed_displayed
= x
;
857 ARDOUR_UI::set_transport_sensitivity (bool yn
)
859 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions
, yn
);
860 shuttle_box
.set_sensitive (yn
);
864 ARDOUR_UI::editor_realized ()
866 Config
->map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed
));
868 set_size_request_to_display_given_text (speed_display_box
, _("-0.55"), 2, 2);
873 ARDOUR_UI::sync_option_changed ()
876 ustring txt
= sync_option_combo
.get_active_text ();
878 session
->request_slave_source (string_to_slave_source (txt
));
884 ARDOUR_UI::maximise_editing_space ()
890 transport_tearoff
->set_visible (false);
891 editor
->maximise_editing_space ();
895 ARDOUR_UI::restore_editing_space ()
901 transport_tearoff
->set_visible (true);
902 editor
->restore_editing_space ();