summaryrefslogtreecommitdiff
path: root/gtk2_ardour/option_editor.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2015-11-04 23:10:27 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2015-11-04 23:23:12 +0100
commitd6219416e63dcf3e45593b2ffb6a5953709b492b (patch)
treeddebea6f12934584b79234a353d1bf20cdd0f5f2 /gtk2_ardour/option_editor.cc
parent02124c0d16d48d7151c7e68ee8f2355e2536aba9 (diff)
Let Entry of FaderOption react on ENTER and allow only numerical input.
This enables setting click gain and solo gain in the preferences using the text field. -- fixes #6668
Diffstat (limited to 'gtk2_ardour/option_editor.cc')
-rw-r--r--gtk2_ardour/option_editor.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc
index a8c35f250f..9ce4997bb8 100644
--- a/gtk2_ardour/option_editor.cc
+++ b/gtk2_ardour/option_editor.cc
@@ -31,9 +31,10 @@
#include "pbd/configuration.h"
#include "pbd/replace_all.h"
-#include "public_editor.h"
-#include "option_editor.h"
#include "gui_thread.h"
+#include "option_editor.h"
+#include "public_editor.h"
+#include "utils.h"
#include "i18n.h"
using namespace std;
@@ -289,6 +290,8 @@ FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t>
set_size_request_to_display_given_text (_db_display, "-99.00", 12, 12);
_db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FaderOption::db_changed));
+ _db_display.signal_activate().connect (sigc::mem_fun (*this, &FaderOption::on_activate));
+ _db_display.signal_key_press_event().connect (sigc::mem_fun (*this, &FaderOption::on_key_press), false);
}
void
@@ -315,6 +318,26 @@ FaderOption::db_changed ()
}
void
+FaderOption::on_activate ()
+{
+ float db_val = atof (_db_display.get_text ().c_str ());
+ gain_t coeff_val = dB_to_coefficient (db_val);
+
+ _db_adjustment.set_value (gain_to_slider_position_with_max (coeff_val, Config->get_max_gain ()));
+}
+
+bool
+FaderOption::on_key_press (GdkEventKey* ev)
+{
+ if (ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (ev->keyval)) {
+ /* drop through to normal handling */
+ return false;
+ }
+ /* illegal key for gain entry */
+ return true;
+}
+
+void
FaderOption::add_to_page (OptionEditorPage* p)
{
add_widgets_to_page (p, &_label, &_box);