From 05c29e25f9c101cc9ecb99b8fc085e28982a0fc5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 12 Jun 2023 18:00:21 -0600 Subject: [PATCH] reorder tempo dialog contents, provide non-presented var to control focus behavior --- gtk2_ardour/tempo_dialog.cc | 25 ++++++++++++++++--------- gtk2_ardour/tempo_dialog.h | 2 ++ gtk2_ardour/ui_config_vars.h | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc index abb3ed2c37..5f53bcf7b1 100644 --- a/gtk2_ardour/tempo_dialog.cc +++ b/gtk2_ardour/tempo_dialog.cc @@ -243,7 +243,7 @@ TempoDialog::init (const Temporal::BBT_Time& when, double bpm, double end_bpm, d get_vbox ()->set_border_width (12); get_vbox ()->set_spacing (6); - get_vbox ()->pack_end (*table, false, false); + get_vbox ()->pack_start (*table, false, false); table->show_all (); table = manage (new Table (2, 2)); @@ -298,13 +298,6 @@ TempoDialog::init (const Temporal::BBT_Time& when, double bpm, double end_bpm, d /* init state */ tempo_type_change (); tapped = false; -#if 0 - bpm_spinner.select_region (0, -1); - bpm_spinner.grab_focus (); -#else - tap_tempo_button.set_can_focus (); - tap_tempo_button.grab_focus (); -#endif } TempoDialog::~TempoDialog () @@ -313,6 +306,20 @@ TempoDialog::~TempoDialog () AudioEngine::instance ()->unregister_port (_midi_tap_port); } +void +TempoDialog::on_show () +{ + ArdourDialog::on_show (); + + if (!UIConfiguration::instance().get_prefer_tap_tempo()) { + bpm_spinner.select_region (0, -1); + bpm_spinner.grab_focus (); + } else { + tap_tempo_button.set_can_focus (); + tap_tempo_button.grab_focus (); + } +} + void TempoDialog::midi_event (MIDI::byte* msg, size_t len, MIDI::samplecnt_t now) { @@ -398,7 +405,7 @@ TempoDialog::port_changed () } tap_tempo_button.set_sensitive (!rv); bpm_spinner.set_sensitive (!rv); - if (!rv) { + if (!rv && UIConfiguration::instance().get_prefer_tap_tempo()) { tap_tempo_button.grab_focus (); } } diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h index 7efd99472e..cfac32aac2 100644 --- a/gtk2_ardour/tempo_dialog.h +++ b/gtk2_ardour/tempo_dialog.h @@ -65,6 +65,8 @@ public: Temporal::Tempo::Type get_tempo_type (); Temporal::TimeDomain get_lock_style (); + void on_show (); + private: void init (const Temporal::BBT_Time& start, double bpm, double end_bpm, double note_type, Temporal::TempoPoint::Type type, bool movable, Temporal::TimeDomain style); bool is_user_input_valid() const; diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index d414d3adda..72f2093ae2 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -153,6 +153,7 @@ UI_CONFIG_VARIABLE (bool, ask_before_closing_last_window, "ask-before-closing-la UI_CONFIG_VARIABLE (bool, ask_cut_copy_section_tempo_map, "ask-cut-copy-section-tempo-map", true) UI_CONFIG_VARIABLE (std::string, freesound_dir, "freesound-dir", "") UI_CONFIG_VARIABLE (int, max_note_height, "max-note-height", 20) +UI_CONFIG_VARIABLE (bool, prefer_tap_tempo, "prefer-tap-tempo", false) #ifdef MIXBUS UI_CONFIG_VARIABLE (Editing::TempoEditBehavior, tempo_edit_behavior, "tempo-edit-behavior", Editing::TempoMapping) #else