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/route.h>
39 #include "ardour_ui.h"
41 #include "public_editor.h"
42 #include "audio_clock.h"
45 #include "color_manager.h"
50 using namespace ARDOUR;
52 using namespace Gtkmm2ext;
58 ARDOUR_UI::setup_windows ()
60 if (create_editor ()) {
61 error << _("UI: cannot setup editor") << endmsg;
65 if (create_mixer ()) {
66 error << _("UI: cannot setup mixer") << endmsg;
70 /* all other dialogs are created conditionally */
72 we_have_dependents ();
78 color_manager->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleColorManager")));
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);
89 ARDOUR_UI::transport_stopped ()
91 stop_button.set_visual_state (1);
93 roll_button.set_visual_state (0);
94 play_selection_button.set_visual_state (0);
95 auto_loop_button.set_visual_state (0);
98 shuttle_box.queue_draw ();
100 update_disk_space ();
104 ARDOUR_UI::transport_rolling ()
106 stop_button.set_visual_state (0);
107 if (session->get_play_range()) {
108 play_selection_button.set_visual_state (1);
109 roll_button.set_visual_state (0);
110 auto_loop_button.set_visual_state (0);
112 } else if (session->get_play_loop ()) {
113 auto_loop_button.set_visual_state (1);
114 play_selection_button.set_visual_state (0);
115 roll_button.set_visual_state (0);
119 roll_button.set_visual_state (1);
120 play_selection_button.set_visual_state (0);
121 auto_loop_button.set_visual_state (0);
124 /* reset shuttle controller */
126 shuttle_fract = SHUTTLE_FRACT_SPEED1; /* speed = 1.0, believe it or not */
127 shuttle_box.queue_draw ();
131 ARDOUR_UI::transport_rewinding ()
133 stop_button.set_visual_state (0);
134 roll_button.set_visual_state (1);
135 play_selection_button.set_visual_state (0);
136 auto_loop_button.set_visual_state (0);
140 ARDOUR_UI::transport_forwarding ()
142 stop_button.set_visual_state (0);
143 roll_button.set_visual_state (1);
144 play_selection_button.set_visual_state (0);
145 auto_loop_button.set_visual_state (0);
149 ARDOUR_UI::setup_transport ()
151 transport_tearoff = manage (new TearOff (transport_tearoff_hbox));
152 transport_tearoff->set_name ("TransportBase");
154 transport_hbox.pack_start (*transport_tearoff, true, false);
156 transport_base.set_name ("TransportBase");
157 transport_base.add (transport_hbox);
159 transport_frame.set_shadow_type (SHADOW_OUT);
160 transport_frame.set_name ("BaseFrame");
161 transport_frame.add (transport_base);
163 transport_tearoff->Detach.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
164 static_cast<Widget*>(&transport_frame)));
165 transport_tearoff->Attach.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
166 static_cast<Widget*> (&transport_frame), 1));
167 transport_tearoff->Hidden.connect (bind (mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
168 static_cast<Widget*>(&transport_frame)));
169 transport_tearoff->Visible.connect (bind (mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
170 static_cast<Widget*> (&transport_frame), 1));
172 shuttle_box.set_name ("TransportButton");
173 goto_start_button.set_name ("TransportButton");
174 goto_end_button.set_name ("TransportButton");
175 roll_button.set_name ("TransportButton");
176 stop_button.set_name ("TransportButton");
177 play_selection_button.set_name ("TransportButton");
178 rec_button.set_name ("TransportRecButton");
179 auto_loop_button.set_name ("TransportButton");
181 auto_return_button.set_name ("TransportButton");
182 auto_play_button.set_name ("TransportButton");
183 auto_input_button.set_name ("TransportButton");
184 punch_in_button.set_name ("TransportButton");
185 punch_out_button.set_name ("TransportButton");
186 click_button.set_name ("TransportButton");
187 time_master_button.set_name ("TransportButton");
189 stop_button.set_size_request(29, -1);
190 roll_button.set_size_request(29, -1);
191 auto_loop_button.set_size_request(29, -1);
192 play_selection_button.set_size_request(29, -1);
193 goto_start_button.set_size_request(29, -1);
194 goto_end_button.set_size_request(29, -1);
195 rec_button.set_size_request(29, -1);
199 stop_button.set_visual_state (1);
201 w = manage (new Image (get_icon (X_("transport_start"))));
203 goto_start_button.add (*w);
204 w = manage (new Image (get_icon (X_("transport_end"))));
206 goto_end_button.add (*w);
207 w = manage (new Image (get_icon (X_("transport_play"))));
209 roll_button.add (*w);
210 w = manage (new Image (get_icon (X_("transport_stop"))));
212 stop_button.add (*w);
213 w = manage (new Image (get_icon (X_("transport_range"))));
215 play_selection_button.add (*w);
216 w = manage (new Image (get_icon (X_("transport_record"))));
219 w = manage (new Image (get_icon (X_("transport_loop"))));
221 auto_loop_button.add (*w);
225 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
226 act->connect_proxy (stop_button);
227 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
228 act->connect_proxy (roll_button);
229 act = ActionManager::get_action (X_("Transport"), X_("Record"));
230 act->connect_proxy (rec_button);
231 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
232 act->connect_proxy (goto_start_button);
233 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
234 act->connect_proxy (goto_end_button);
235 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
236 act->connect_proxy (auto_loop_button);
237 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
238 act->connect_proxy (play_selection_button);
239 act = ActionManager::get_action (X_("Transport"), X_("ToggleTimeMaster"));
240 act->connect_proxy (time_master_button);
242 ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
243 ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
244 ARDOUR_UI::instance()->tooltips().set_tip (play_selection_button, _("Play range/selection"));
245 ARDOUR_UI::instance()->tooltips().set_tip (goto_start_button, _("Go to start of session"));
246 ARDOUR_UI::instance()->tooltips().set_tip (goto_end_button, _("Go to end of session"));
247 ARDOUR_UI::instance()->tooltips().set_tip (auto_loop_button, _("Play loop range"));
249 ARDOUR_UI::instance()->tooltips().set_tip (auto_return_button, _("Return to last playback start when stopped"));
250 ARDOUR_UI::instance()->tooltips().set_tip (auto_play_button, _("Start playback after any locate"));
251 ARDOUR_UI::instance()->tooltips().set_tip (auto_input_button, _("Be sensible about input monitoring"));
252 ARDOUR_UI::instance()->tooltips().set_tip (punch_in_button, _("Start recording at auto-punch start"));
253 ARDOUR_UI::instance()->tooltips().set_tip (punch_out_button, _("Stop recording at auto-punch end"));
254 ARDOUR_UI::instance()->tooltips().set_tip (click_button, _("Enable/Disable audio click"));
255 ARDOUR_UI::instance()->tooltips().set_tip (sync_option_combo, _("Positional sync source"));
256 ARDOUR_UI::instance()->tooltips().set_tip (time_master_button, _("Does Ardour control the time?"));
257 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_box, _("Shuttle speed control"));
258 ARDOUR_UI::instance()->tooltips().set_tip (shuttle_units_button, _("Select semitones or %%-age for speed display"));
259 ARDOUR_UI::instance()->tooltips().set_tip (speed_display_box, _("Current transport speed"));
261 shuttle_box.set_flags (CAN_FOCUS);
262 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);
263 shuttle_box.set_size_request (100, 15);
265 shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
266 shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
267 shuttle_box.signal_scroll_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_scroll));
268 shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
269 shuttle_box.signal_expose_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_expose));
273 ARDOUR_UI::Clock.connect (bind (mem_fun (primary_clock, &AudioClock::set), false));
274 ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
276 primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
277 secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
279 ARDOUR_UI::instance()->tooltips().set_tip (primary_clock, _("Primary clock"));
280 ARDOUR_UI::instance()->tooltips().set_tip (secondary_clock, _("secondary clock"));
282 ActionManager::get_action ("Transport", "ToggleAutoReturn")->connect_proxy (auto_return_button);
283 ActionManager::get_action ("Transport", "ToggleAutoPlay")->connect_proxy (auto_play_button);
284 ActionManager::get_action ("Transport", "ToggleAutoInput")->connect_proxy (auto_input_button);
285 ActionManager::get_action ("Transport", "ToggleClick")->connect_proxy (click_button);
286 ActionManager::get_action ("Transport", "TogglePunchIn")->connect_proxy (punch_in_button);
287 ActionManager::get_action ("Transport", "TogglePunchOut")->connect_proxy (punch_out_button);
289 preroll_button.set_name ("TransportButton");
290 postroll_button.set_name ("TransportButton");
292 preroll_clock.set_mode (AudioClock::MinSec);
293 preroll_clock.set_name ("TransportClockDisplay");
294 postroll_clock.set_mode (AudioClock::MinSec);
295 postroll_clock.set_name ("TransportClockDisplay");
299 /* CANNOT bind these to clicked or toggled, must use pressed or released */
301 solo_alert_button.set_name ("TransportSoloAlert");
302 solo_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::solo_alert_toggle));
303 auditioning_alert_button.set_name ("TransportAuditioningAlert");
304 auditioning_alert_button.signal_pressed().connect (mem_fun(*this,&ARDOUR_UI::audition_alert_toggle));
306 tooltips().set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
307 tooltips().set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition"));
309 alert_box.pack_start (solo_alert_button, false, false);
310 alert_box.pack_start (auditioning_alert_button, false, false);
312 transport_tearoff_hbox.set_border_width (3);
314 transport_tearoff_hbox.pack_start (goto_start_button, false, false);
315 transport_tearoff_hbox.pack_start (goto_end_button, false, false);
317 Frame* sframe = manage (new Frame);
318 VBox* svbox = manage (new VBox);
319 HBox* shbox = manage (new HBox);
321 sframe->set_shadow_type (SHADOW_IN);
322 sframe->add (shuttle_box);
324 shuttle_box.set_name (X_("ShuttleControl"));
326 speed_display_box.add (speed_display_label);
327 speed_display_box.set_name (X_("ShuttleDisplay"));
329 shuttle_units_button.set_name (X_("ShuttleButton"));
330 shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked));
332 shuttle_style_button.set_name (X_("ShuttleButton"));
334 vector<string> shuttle_strings;
335 shuttle_strings.push_back (_("sprung"));
336 shuttle_strings.push_back (_("wheel"));
337 set_popdown_strings (shuttle_style_button, shuttle_strings);
338 shuttle_style_button.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::shuttle_style_changed));
340 Frame* sdframe = manage (new Frame);
342 sdframe->set_shadow_type (SHADOW_IN);
343 sdframe->add (speed_display_box);
346 sync_option_combo.signal_changed().connect (mem_fun (*this, &ARDOUR_UI::sync_option_changed));
347 const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
348 set_size_request_to_display_given_text (sync_option_combo, X_("Igternal"), 2+FUDGE, 10);
350 shbox->pack_start (*sdframe, false, false);
351 shbox->pack_start (shuttle_units_button, true, true);
352 shbox->pack_start (shuttle_style_button, false, false);
354 svbox->pack_start (*sframe, false, false);
355 svbox->pack_start (*shbox, false, false);
357 transport_tearoff_hbox.pack_start (*svbox, false, false, 3);
359 transport_tearoff_hbox.pack_start (auto_loop_button, false, false);
360 transport_tearoff_hbox.pack_start (play_selection_button, false, false);
361 transport_tearoff_hbox.pack_start (roll_button, false, false);
362 transport_tearoff_hbox.pack_start (stop_button, false, false);
363 transport_tearoff_hbox.pack_start (rec_button, false, false, 6);
365 HBox* clock_box = manage (new HBox);
366 clock_box->pack_start (primary_clock, false, false);
367 clock_box->pack_start (secondary_clock, false, false);
368 VBox* time_controls_box = manage (new VBox);
369 time_controls_box->pack_start (sync_option_combo, false, false);
370 time_controls_box->pack_start (time_master_button, false, false);
371 clock_box->pack_start (*time_controls_box, false, false, 1);
372 transport_tearoff_hbox.pack_start (*clock_box, false, false, 0);
374 HBox* toggle_box = manage(new HBox);
376 VBox* punch_box = manage (new VBox);
377 punch_box->pack_start (punch_in_button, false, false);
378 punch_box->pack_start (punch_out_button, false, false);
379 toggle_box->pack_start (*punch_box, false, false);
381 VBox* auto_box = manage (new VBox);
382 auto_box->pack_start (auto_play_button, false, false);
383 auto_box->pack_start (auto_return_button, false, false);
384 toggle_box->pack_start (*auto_box, false, false);
386 VBox* io_box = manage (new VBox);
387 io_box->pack_start (auto_input_button, false, false);
388 io_box->pack_start (click_button, false, false);
389 toggle_box->pack_start (*io_box, false, false);
393 set_transport_sensitivity (false);
395 // toggle_box->pack_start (preroll_button, false, false);
396 // toggle_box->pack_start (preroll_clock, false, false);
398 // toggle_box->pack_start (postroll_button, false, false);
399 // toggle_box->pack_start (postroll_clock, false, false);
401 transport_tearoff_hbox.pack_start (*toggle_box, false, false, 4);
402 transport_tearoff_hbox.pack_start (alert_box, false, false);
406 ARDOUR_UI::manage_window (Window& win)
408 win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
409 win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
410 win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
414 ARDOUR_UI::detach_tearoff (Box* b, Widget* w)
416 // editor->ensure_float (transport_tearoff->tearoff_window());
421 ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n)
424 b->reorder_child (*w, n);
428 ARDOUR_UI::soloing_changed (bool onoff)
430 if (solo_alert_button.get_active() != onoff) {
431 solo_alert_button.set_active (onoff);
436 ARDOUR_UI::_auditioning_changed (bool onoff)
438 if (auditioning_alert_button.get_active() != onoff) {
439 auditioning_alert_button.set_active (onoff);
440 set_transport_sensitivity (!onoff);
445 ARDOUR_UI::auditioning_changed (bool onoff)
447 UI::instance()->call_slot(bind (mem_fun(*this, &ARDOUR_UI::_auditioning_changed), onoff));
451 ARDOUR_UI::audition_alert_toggle ()
454 session->cancel_audition();
459 ARDOUR_UI::solo_alert_toggle ()
462 session->set_all_solo (!session->soloing());
467 ARDOUR_UI::solo_blink (bool onoff)
473 if (session->soloing()) {
475 solo_alert_button.set_state (STATE_ACTIVE);
477 solo_alert_button.set_state (STATE_NORMAL);
480 solo_alert_button.set_active (false);
481 solo_alert_button.set_state (STATE_NORMAL);
486 ARDOUR_UI::audition_blink (bool onoff)
492 if (session->is_auditioning()) {
494 auditioning_alert_button.set_state (STATE_ACTIVE);
496 auditioning_alert_button.set_state (STATE_NORMAL);
499 auditioning_alert_button.set_active (false);
500 auditioning_alert_button.set_state (STATE_NORMAL);
505 ARDOUR_UI::build_shuttle_context_menu ()
507 using namespace Menu_Helpers;
509 shuttle_context_menu = new Menu();
510 MenuList& items = shuttle_context_menu->items();
512 Menu* speed_menu = manage (new Menu());
513 MenuList& speed_items = speed_menu->items();
515 RadioMenuItem::Group group;
517 speed_items.push_back (RadioMenuElem (group, "8", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 8.0f)));
518 if (shuttle_max_speed == 8.0) {
519 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
521 speed_items.push_back (RadioMenuElem (group, "6", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 6.0f)));
522 if (shuttle_max_speed == 6.0) {
523 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
525 speed_items.push_back (RadioMenuElem (group, "4", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 4.0f)));
526 if (shuttle_max_speed == 4.0) {
527 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
529 speed_items.push_back (RadioMenuElem (group, "3", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 3.0f)));
530 if (shuttle_max_speed == 3.0) {
531 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
533 speed_items.push_back (RadioMenuElem (group, "2", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 2.0f)));
534 if (shuttle_max_speed == 2.0) {
535 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
537 speed_items.push_back (RadioMenuElem (group, "1.5", bind (mem_fun (*this, &ARDOUR_UI::set_shuttle_max_speed), 1.5f)));
538 if (shuttle_max_speed == 1.5) {
539 static_cast<RadioMenuItem*>(&speed_items.back())->set_active ();
542 items.push_back (MenuElem (_("Maximum speed"), *speed_menu));
546 ARDOUR_UI::show_shuttle_context_menu ()
548 if (shuttle_context_menu == 0) {
549 build_shuttle_context_menu ();
552 shuttle_context_menu->popup (1, gtk_get_current_event_time());
556 ARDOUR_UI::set_shuttle_max_speed (float speed)
558 shuttle_max_speed = speed;
562 ARDOUR_UI::shuttle_box_button_press (GdkEventButton* ev)
568 if (shuttle_controller_binding_proxy.button_press_handler (ev)) {
572 if (Keyboard::is_context_menu_event (ev)) {
573 show_shuttle_context_menu ();
577 switch (ev->button) {
579 shuttle_box.add_modal_grab ();
580 shuttle_grabbed = true;
581 mouse_shuttle (ev->x, true);
594 ARDOUR_UI::shuttle_box_button_release (GdkEventButton* ev)
600 switch (ev->button) {
602 mouse_shuttle (ev->x, true);
603 shuttle_grabbed = false;
604 shuttle_box.remove_modal_grab ();
605 if (Config->get_shuttle_behaviour() == Sprung) {
606 if (Config->get_auto_play() || roll_button.get_state()) {
607 shuttle_fract = SHUTTLE_FRACT_SPEED1;
608 session->request_transport_speed (1.0);
609 stop_button.set_visual_state (0);
610 roll_button.set_visual_state (1);
613 session->request_transport_speed (0.0);
615 shuttle_box.queue_draw ();
620 if (session->transport_rolling()) {
621 shuttle_fract = SHUTTLE_FRACT_SPEED1;
622 session->request_transport_speed (1.0);
623 stop_button.set_visual_state (0);
624 roll_button.set_visual_state (1);
628 shuttle_box.queue_draw ();
637 use_shuttle_fract (true);
643 ARDOUR_UI::shuttle_box_scroll (GdkEventScroll* ev)
649 switch (ev->direction) {
652 shuttle_fract += 0.005;
654 case GDK_SCROLL_DOWN:
655 shuttle_fract -= 0.005;
658 /* scroll left/right */
662 use_shuttle_fract (true);
668 ARDOUR_UI::shuttle_box_motion (GdkEventMotion* ev)
670 if (!session || !shuttle_grabbed) {
674 return mouse_shuttle (ev->x, false);
678 ARDOUR_UI::mouse_shuttle (double x, bool force)
680 double half_width = shuttle_box.get_width() / 2.0;
681 double distance = x - half_width;
684 distance = min (distance, half_width);
686 distance = max (distance, -half_width);
689 shuttle_fract = distance / half_width;
690 use_shuttle_fract (force);
695 ARDOUR_UI::set_shuttle_fract (double f)
698 use_shuttle_fract (false);
702 ARDOUR_UI::use_shuttle_fract (bool force)
707 /* do not attempt to submit a motion-driven transport speed request
708 more than once per process cycle.
711 gettimeofday (&now, 0);
712 timersub (&now, &last_shuttle_request, &diff);
714 if (!force && (diff.tv_usec + (diff.tv_sec * 1000000)) < engine->usecs_per_cycle()) {
718 last_shuttle_request = now;
720 bool neg = (shuttle_fract < 0.0);
722 double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1
728 session->request_transport_speed (shuttle_max_speed * fract); // Formula A2
729 shuttle_box.queue_draw ();
733 ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
736 Glib::RefPtr<Gdk::Window> win (shuttle_box.get_window());
738 /* redraw the background */
740 win->draw_rectangle (shuttle_box.get_style()->get_bg_gc (shuttle_box.get_state()),
742 event->area.x, event->area.y,
743 event->area.width, event->area.height);
746 x = (gint) floor ((shuttle_box.get_width() / 2.0) + (0.5 * (shuttle_box.get_width() * shuttle_fract)));
750 win->draw_line (shuttle_box.get_style()->get_fg_gc (shuttle_box.get_state()),
754 shuttle_box.get_height());
759 ARDOUR_UI::shuttle_unit_clicked ()
761 if (shuttle_unit_menu == 0) {
762 shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
764 shuttle_unit_menu->popup (1, gtk_get_current_event_time());
768 ARDOUR_UI::shuttle_style_changed ()
770 ustring str = shuttle_style_button.get_active_text ();
772 if (str == _("sprung")) {
773 Config->set_shuttle_behaviour (Sprung);
774 } else if (str == _("wheel")) {
775 Config->set_shuttle_behaviour (Wheel);
780 ARDOUR_UI::update_speed_display ()
783 if (last_speed_displayed != 0) {
784 speed_display_label.set_text (_("stop"));
785 last_speed_displayed = 0;
791 float x = session->transport_speed ();
793 if (x != last_speed_displayed) {
796 if (Config->get_shuttle_units() == Percentage) {
797 snprintf (buf, sizeof (buf), "%.2f", x);
800 snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x));
802 snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x));
805 speed_display_label.set_text (buf);
807 speed_display_label.set_text (_("stop"));
810 last_speed_displayed = x;
815 ARDOUR_UI::set_transport_sensitivity (bool yn)
817 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
818 shuttle_box.set_sensitive (yn);
822 ARDOUR_UI::editor_realized ()
824 Config->map_parameters (mem_fun (*this, &ARDOUR_UI::parameter_changed));
826 set_size_request_to_display_given_text (speed_display_box, _("-0.55"), 2, 2);
827 const guint32 FUDGE = 25; // Combo's are stupid - they steal space from the entry for the button
828 set_size_request_to_display_given_text (shuttle_style_button, _("sprung"), 2+FUDGE, 10);
832 ARDOUR_UI::sync_option_changed ()
835 session->request_slave_source (string_to_slave_source (sync_option_combo.get_active_text()));
840 ARDOUR_UI::maximise_editing_space ()
846 transport_tearoff->set_visible (false);
847 editor->maximise_editing_space ();
851 ARDOUR_UI::restore_editing_space ()
857 transport_tearoff->set_visible (true);
858 editor->restore_editing_space ();