diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 56c6c6052d..b049cd59a3 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -6,6 +6,7 @@ + diff --git a/gtk2_ardour/ardour3_ui_default.conf b/gtk2_ardour/ardour3_ui_default.conf index 40007c8680..a28fa17c1e 100644 --- a/gtk2_ardour/ardour3_ui_default.conf +++ b/gtk2_ardour/ardour3_ui_default.conf @@ -642,33 +642,43 @@ + + + + + + + + + + diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index bd494b206f..e7e0a6da0b 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -202,6 +202,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr AudioClock* primary_clock; AudioClock* secondary_clock; + void focus_on_clock (); TimeInfoBox* time_info_box; diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f7005e99d9..88b7e409b8 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -354,7 +354,7 @@ ARDOUR_UI::install_actions () ActionManager::session_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act); - act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(primary_clock, &AudioClock::focus)); + act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(*this, &ARDOUR_UI::focus_on_clock)); ActionManager::session_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act); @@ -862,3 +862,12 @@ ARDOUR_UI::resize_text_widgets () set_size_request_to_display_given_text (cpu_load_label, "DSP: 100.0%", 2, 2); set_size_request_to_display_given_text (buffer_load_label, "Buffers: p:100% c:100%", 2, 2); } + +void +ARDOUR_UI::focus_on_clock () +{ + if (editor && primary_clock) { + editor->present (); + primary_clock->focus (); + } +} diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 284885ad44..57abbe325c 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -69,6 +69,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& , _follows_playhead (follows_playhead) , _off (false) , _fixed_width (true) + , layout_x_offset (0) , ops_menu (0) , editing_attr (0) , foreground_attr (0) @@ -257,8 +258,6 @@ AudioClock::set_colors () void AudioClock::render (cairo_t* cr) { - double layout_x_offset; - /* main layout: rounded rect, plus the text */ if (_need_bg) { @@ -272,10 +271,8 @@ AudioClock::render (cairo_t* cr) } if (!_fixed_width) { - cairo_move_to (cr, 0, 0); - layout_x_offset = 0; + cairo_move_to (cr, layout_x_offset, 0); } else { - layout_x_offset = (get_width() - layout_width)/2.0; cairo_move_to (cr, layout_x_offset, (upper_height - layout_height) / 2.0); } @@ -383,6 +380,15 @@ AudioClock::on_size_allocate (Gtk::Allocation& alloc) } else { upper_height = get_height(); } + + if (_fixed_width) { + /* center display in available space */ + layout_x_offset = (get_width() - layout_width)/2.0; + } else { + /* left justify */ + layout_x_offset = 0; + } + } void @@ -1371,7 +1377,7 @@ AudioClock::on_button_press_event (GdkEventButton *ev) */ y = ev->y - ((upper_height - layout_height)/2); - x = ev->x - x_leading_padding; + x = ev->x - layout_x_offset; if (_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) { drag_field = index_to_field (index); @@ -1450,7 +1456,7 @@ AudioClock::on_scroll_event (GdkEventScroll *ev) */ y = ev->y - ((upper_height - layout_height)/2); - x = ev->x - x_leading_padding; + x = ev->x - layout_x_offset; if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) { /* not in the main layout */ @@ -1954,7 +1960,6 @@ AudioClock::focus () start_edit (); } - void AudioClock::set_corner_radius (double r) { diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index 42f2bf88be..400d5a7f28 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -97,6 +97,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr bool _follows_playhead; bool _off; bool _fixed_width; + int layout_x_offset; Gtk::Menu *ops_menu; diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index 3befc890ae..7ee144015f 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -177,7 +177,9 @@ TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src) } if (ev->button == 1) { - _session->request_locate (src->current_time ()); + if (!src->off()) { + _session->request_locate (src->current_time ()); + } return true; }