2009-12-29 16:31:14 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <gtkmm/comboboxtext.h>
|
|
|
|
#include <gtkmm/label.h>
|
|
|
|
#include <gtkmm/box.h>
|
2010-01-01 13:14:32 -05:00
|
|
|
#include <gtkmm/adjustment.h>
|
|
|
|
#include <gtkmm/spinbutton.h>
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
|
|
#include "generic_midi_control_protocol.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
class GMCPGUI : public Gtk::VBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GMCPGUI (GenericMidiControlProtocol&);
|
|
|
|
~GMCPGUI ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
GenericMidiControlProtocol& cp;
|
|
|
|
Gtk::ComboBoxText map_combo;
|
2010-01-01 13:14:32 -05:00
|
|
|
Gtk::Adjustment bank_adjustment;
|
|
|
|
Gtk::SpinButton bank_spinner;
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
void binding_changed ();
|
2010-01-01 13:14:32 -05:00
|
|
|
void bank_change ();
|
2009-12-29 16:31:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
|
|
|
|
void*
|
|
|
|
GenericMidiControlProtocol::get_gui () const
|
|
|
|
{
|
|
|
|
if (!gui) {
|
|
|
|
const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
|
|
|
|
}
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::tear_down_gui ()
|
|
|
|
{
|
|
|
|
delete (GMCPGUI*) gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::build_gui ()
|
|
|
|
{
|
|
|
|
gui = (void*) new GMCPGUI (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------*/
|
|
|
|
|
|
|
|
GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
|
|
|
|
: cp (p)
|
2010-01-01 13:14:32 -05:00
|
|
|
, bank_adjustment (1, 1, 100, 1, 10)
|
|
|
|
, bank_spinner (bank_adjustment)
|
2009-12-29 16:31:14 -05:00
|
|
|
{
|
|
|
|
vector<string> popdowns;
|
|
|
|
popdowns.push_back (_("Reset All"));
|
|
|
|
|
|
|
|
for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
|
|
|
|
popdowns.push_back ((*x).name);
|
|
|
|
}
|
|
|
|
|
2011-11-23 03:35:41 -05:00
|
|
|
set_popdown_strings (map_combo, popdowns);
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
if (cp.current_binding().empty()) {
|
|
|
|
map_combo.set_active_text (popdowns[0]);
|
|
|
|
} else {
|
|
|
|
map_combo.set_active_text (cp.current_binding());
|
|
|
|
}
|
|
|
|
|
|
|
|
map_combo.signal_changed().connect (sigc::mem_fun (*this, &GMCPGUI::binding_changed));
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
set_spacing (6);
|
2009-12-29 16:31:14 -05:00
|
|
|
set_border_width (12);
|
|
|
|
|
|
|
|
Label* label = manage (new Label (_("Available MIDI bindings:")));
|
|
|
|
HBox* hpack = manage (new HBox);
|
|
|
|
|
|
|
|
hpack->set_spacing (6);
|
|
|
|
hpack->pack_start (*label, false, false);
|
|
|
|
hpack->pack_start (map_combo, false, false);
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
map_combo.show ();
|
|
|
|
label->show ();
|
|
|
|
hpack->show ();
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
pack_start (*hpack, false, false);
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
|
|
|
|
bank_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &GMCPGUI::bank_change));
|
|
|
|
|
|
|
|
label = manage (new Label (_("Current Bank:")));
|
|
|
|
hpack = manage (new HBox);
|
|
|
|
|
|
|
|
hpack->set_spacing (6);
|
|
|
|
hpack->pack_start (*label, false, false);
|
|
|
|
hpack->pack_start (bank_spinner, false, false);
|
|
|
|
|
|
|
|
|
|
|
|
bank_spinner.show ();
|
2009-12-29 16:31:14 -05:00
|
|
|
label->show ();
|
|
|
|
hpack->show ();
|
2010-01-01 13:14:32 -05:00
|
|
|
|
|
|
|
pack_start (*hpack, false, false);
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GMCPGUI::~GMCPGUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
void
|
|
|
|
GMCPGUI::bank_change ()
|
|
|
|
{
|
|
|
|
int new_bank = bank_adjustment.get_value() - 1;
|
|
|
|
cp.set_current_bank (new_bank);
|
|
|
|
}
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
void
|
|
|
|
GMCPGUI::binding_changed ()
|
|
|
|
{
|
|
|
|
string str = map_combo.get_active_text ();
|
|
|
|
|
|
|
|
if (str == _("Reset All")) {
|
|
|
|
cp.drop_bindings ();
|
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|