5 #include <gtkmm/comboboxtext.h>
6 #include <gtkmm/label.h>
8 #include <gtkmm/adjustment.h>
9 #include <gtkmm/spinbutton.h>
11 #include "gtkmm2ext/utils.h"
13 #include "generic_midi_control_protocol.h"
17 class GMCPGUI : public Gtk::VBox
20 GMCPGUI (GenericMidiControlProtocol&);
24 GenericMidiControlProtocol& cp;
25 Gtk::ComboBoxText map_combo;
26 Gtk::Adjustment bank_adjustment;
27 Gtk::SpinButton bank_spinner;
29 void binding_changed ();
34 using namespace ARDOUR;
37 using namespace Gtkmm2ext;
40 GenericMidiControlProtocol::get_gui () const
43 const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
49 GenericMidiControlProtocol::tear_down_gui ()
51 delete (GMCPGUI*) gui;
55 GenericMidiControlProtocol::build_gui ()
57 gui = (void*) new GMCPGUI (*this);
60 /*--------------------*/
62 GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
64 , bank_adjustment (1, 1, 100, 1, 10)
65 , bank_spinner (bank_adjustment)
67 vector<string> popdowns;
68 popdowns.push_back (_("Reset All"));
70 for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
71 popdowns.push_back ((*x).name);
74 set_popdown_strings (map_combo, popdowns, true, 5, 2);
76 if (cp.current_binding().empty()) {
77 map_combo.set_active_text (popdowns[0]);
79 map_combo.set_active_text (cp.current_binding());
82 map_combo.signal_changed().connect (sigc::mem_fun (*this, &GMCPGUI::binding_changed));
85 set_border_width (12);
87 Label* label = manage (new Label (_("Available MIDI bindings:")));
88 HBox* hpack = manage (new HBox);
90 hpack->set_spacing (6);
91 hpack->pack_start (*label, false, false);
92 hpack->pack_start (map_combo, false, false);
98 pack_start (*hpack, false, false);
101 bank_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &GMCPGUI::bank_change));
103 label = manage (new Label (_("Current Bank:")));
104 hpack = manage (new HBox);
106 hpack->set_spacing (6);
107 hpack->pack_start (*label, false, false);
108 hpack->pack_start (bank_spinner, false, false);
111 bank_spinner.show ();
115 pack_start (*hpack, false, false);
124 GMCPGUI::bank_change ()
126 int new_bank = bank_adjustment.get_value() - 1;
127 cp.set_current_bank (new_bank);
131 GMCPGUI::binding_changed ()
133 string str = map_combo.get_active_text ();
135 if (str == _("Reset All")) {
138 for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
139 if (str == (*x).name) {
140 cp.load_bindings ((*x).path);