13
0
livetrax/libs/surfaces/mackie/gui.cc
Paul Davis 0c4fe26b41 MCP: switch devices on the fly; name MIDI ports appropriately; fix active state; move sysex parsing into Surface
git-svn-id: svn://localhost/ardour2/branches/3.0@11942 d708f5d6-7413-0410-9779-e7cbd77b26cf
2012-04-12 16:41:07 +00:00

103 lines
2.5 KiB
C++

/*
Copyright (C) 2010 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.
*/
#include <gtkmm/comboboxtext.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/table.h>
#include "gtkmm2ext/utils.h"
#include "ardour/rc_configuration.h"
#include "mackie_control_protocol.h"
#include "device_info.h"
#include "i18n.h"
using namespace std;
using namespace Mackie;
class MackieControlProtocolGUI : public Gtk::VBox
{
public:
MackieControlProtocolGUI (MackieControlProtocol &);
private:
void surface_combo_changed ();
MackieControlProtocol& _cp;
Gtk::ComboBoxText _surface_combo;
};
void*
MackieControlProtocol::get_gui () const
{
if (!_gui) {
const_cast<MackieControlProtocol*>(this)->build_gui ();
}
return _gui;
}
void
MackieControlProtocol::tear_down_gui ()
{
delete (MackieControlProtocolGUI*) _gui;
}
void
MackieControlProtocol::build_gui ()
{
_gui = (void *) new MackieControlProtocolGUI (*this);
}
MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
: _cp (p)
{
Gtk::Table* table = Gtk::manage (new Gtk::Table (2, 2));
table->set_spacings (4);
table->attach (*manage (new Gtk::Label (_("Surface type:"))), 0, 1, 0, 1);
table->attach (_surface_combo, 1, 2, 0, 1);
vector<string> surfaces;
for (std::map<std::string,DeviceInfo>::iterator i = DeviceInfo::device_info.begin(); i != DeviceInfo::device_info.end(); ++i) {
std::cerr << "Dveice known: " << i->first << endl;
surfaces.push_back (i->first);
}
Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
_surface_combo.set_active_text (p.device_info().name());
pack_start (*table);
set_spacing (4);
set_border_width (12);
show_all ();
_surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
}
void
MackieControlProtocolGUI::surface_combo_changed ()
{
_cp.set_device (_surface_combo.get_active_text());
}