Merge branch 'master' into windows
[ardour.git] / libs / surfaces / generic_midi / gmcp_gui.cc
index f27e1c5e8b72eb6d79b475b4184d1f5679efa2b7..6c1ee1ba3d3e340c281fd42c857ee659ccc111c4 100644 (file)
@@ -28,6 +28,7 @@
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/table.h>
 
+#include "gtkmm2ext/gtk_ui.h"
 #include "gtkmm2ext/utils.h"
 
 #include "generic_midi_control_protocol.h"
@@ -46,10 +47,13 @@ private:
        Gtk::Adjustment bank_adjustment;
        Gtk::SpinButton bank_spinner;
        Gtk::CheckButton motorised_button;
+       Gtk::Adjustment threshold_adjustment;
+       Gtk::SpinButton threshold_spinner;
 
        void binding_changed ();
        void bank_changed ();
        void motorised_changed ();
+       void threshold_changed ();
 };
 
 using namespace PBD;
@@ -86,6 +90,8 @@ GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
        , bank_adjustment (1, 1, 100, 1, 10)
        , bank_spinner (bank_adjustment)
        , motorised_button ("Motorised")
+       , threshold_adjustment (p.threshold(), 1, 127, 1, 10)
+       , threshold_spinner (threshold_adjustment)
 {
        vector<string> popdowns;
        popdowns.push_back (_("Reset All"));
@@ -140,7 +146,23 @@ GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
 
        motorised_button.show ();
 
+       threshold_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &GMCPGUI::threshold_changed));
+
+       Gtkmm2ext::UI::instance()->set_tip (threshold_spinner, 
+                                           string_compose (_("Controls how %1 behaves if the MIDI controller sends discontinuous values"), PROGRAM_NAME));
+
+       label = manage (new Label (_("Smoothing:")));
+       label->set_alignment (0, 0.5);
+       table->attach (*label, 0, 1, n, n + 1);
+       table->attach (threshold_spinner, 1, 2, n, n + 1);
+       ++n;
+
+       threshold_spinner.show ();
+       label->show ();
+
        pack_start (*table, false, false);
+
+       binding_changed ();
 }
 
 GMCPGUI::~GMCPGUI ()
@@ -165,6 +187,8 @@ GMCPGUI::binding_changed ()
                for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
                        if (str == x->name) {
                                cp.load_bindings (x->path);
+                               motorised_button.set_active (cp.motorised ());
+                               threshold_adjustment.set_value (cp.threshold ());
                                break;
                        }
                }
@@ -176,3 +200,9 @@ GMCPGUI::motorised_changed ()
 {
        cp.set_motorised (motorised_button.get_active ());
 }
+
+void
+GMCPGUI::threshold_changed ()
+{
+       cp.set_threshold (threshold_adjustment.get_value());
+}