2012-03-18 21:34:40 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009-2012 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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>
|
2012-03-18 21:34:40 -04:00
|
|
|
#include <gtkmm/table.h>
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2013-06-06 08:31:46 -04:00
|
|
|
#include "gtkmm2ext/gtk_ui.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:
|
2012-03-18 21:34:40 -04:00
|
|
|
GMCPGUI (GenericMidiControlProtocol&);
|
|
|
|
~GMCPGUI ();
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
private:
|
2012-03-18 21:34:40 -04:00
|
|
|
GenericMidiControlProtocol& cp;
|
|
|
|
Gtk::ComboBoxText map_combo;
|
|
|
|
Gtk::Adjustment bank_adjustment;
|
|
|
|
Gtk::SpinButton bank_spinner;
|
|
|
|
Gtk::CheckButton motorised_button;
|
2012-06-13 17:53:50 -04:00
|
|
|
Gtk::Adjustment threshold_adjustment;
|
|
|
|
Gtk::SpinButton threshold_spinner;
|
2012-03-18 21:34:40 -04:00
|
|
|
|
|
|
|
void binding_changed ();
|
|
|
|
void bank_changed ();
|
|
|
|
void motorised_changed ();
|
2012-06-13 17:53:50 -04:00
|
|
|
void threshold_changed ();
|
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)
|
2012-03-18 21:34:40 -04:00
|
|
|
, motorised_button ("Motorised")
|
2013-06-10 12:37:09 -04:00
|
|
|
, threshold_adjustment (p.threshold(), 1, 127, 1, 10)
|
2012-06-13 17:53:50 -04:00
|
|
|
, threshold_spinner (threshold_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) {
|
2012-03-18 21:34:40 -04:00
|
|
|
popdowns.push_back (x->name);
|
2009-12-29 16:31:14 -05:00
|
|
|
}
|
|
|
|
|
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);
|
2012-03-18 21:34:40 -04:00
|
|
|
set_border_width (6);
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
Table* table = manage (new Table);
|
|
|
|
table->set_row_spacings (6);
|
|
|
|
table->set_col_spacings (6);
|
|
|
|
table->show ();
|
|
|
|
|
|
|
|
int n = 0;
|
2009-12-29 16:31:14 -05:00
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
Label* label = manage (new Label (_("MIDI Bindings:")));
|
|
|
|
label->set_alignment (0, 0.5);
|
|
|
|
table->attach (*label, 0, 1, n, n + 1);
|
|
|
|
table->attach (map_combo, 1, 2, n, n + 1);
|
|
|
|
++n;
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
map_combo.show ();
|
|
|
|
label->show ();
|
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
bank_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &GMCPGUI::bank_changed));
|
2010-01-01 13:14:32 -05:00
|
|
|
|
|
|
|
label = manage (new Label (_("Current Bank:")));
|
2012-03-18 21:34:40 -04:00
|
|
|
label->set_alignment (0, 0.5);
|
|
|
|
table->attach (*label, 0, 1, n, n + 1);
|
|
|
|
table->attach (bank_spinner, 1, 2, n, n + 1);
|
|
|
|
++n;
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
bank_spinner.show ();
|
2009-12-29 16:31:14 -05:00
|
|
|
label->show ();
|
2010-01-01 13:14:32 -05:00
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
motorised_button.signal_toggled().connect (sigc::mem_fun (*this, &GMCPGUI::motorised_changed));
|
|
|
|
table->attach (motorised_button, 0, 2, n, n + 1);
|
|
|
|
++n;
|
2010-01-01 13:14:32 -05:00
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
motorised_button.show ();
|
|
|
|
|
2012-06-13 17:53:50 -04:00
|
|
|
threshold_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &GMCPGUI::threshold_changed));
|
|
|
|
|
2013-06-06 08:31:46 -04:00
|
|
|
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:")));
|
2012-06-13 17:53:50 -04:00
|
|
|
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 ();
|
|
|
|
|
2012-03-18 21:34:40 -04:00
|
|
|
pack_start (*table, false, false);
|
2012-06-13 17:53:50 -04:00
|
|
|
|
|
|
|
binding_changed ();
|
2009-12-29 16:31:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GMCPGUI::~GMCPGUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-01-01 13:14:32 -05:00
|
|
|
void
|
2012-03-18 21:34:40 -04:00
|
|
|
GMCPGUI::bank_changed ()
|
2010-01-01 13:14:32 -05:00
|
|
|
{
|
|
|
|
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) {
|
2012-03-18 21:34:40 -04:00
|
|
|
if (str == x->name) {
|
|
|
|
cp.load_bindings (x->path);
|
2012-03-20 22:19:59 -04:00
|
|
|
motorised_button.set_active (cp.motorised ());
|
2012-06-13 17:53:50 -04:00
|
|
|
threshold_adjustment.set_value (cp.threshold ());
|
2009-12-29 16:31:14 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-18 21:34:40 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
GMCPGUI::motorised_changed ()
|
|
|
|
{
|
|
|
|
cp.set_motorised (motorised_button.get_active ());
|
|
|
|
}
|
2012-06-13 17:53:50 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
GMCPGUI::threshold_changed ()
|
|
|
|
{
|
|
|
|
cp.set_threshold (threshold_adjustment.get_value());
|
|
|
|
}
|