2014-05-01 06:06:16 -05:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2012 Waves Audio Ltd.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2014-05-06 03:21:18 -05:00
|
|
|
#include "device_connection_control.h"
|
2014-05-01 06:06:16 -05:00
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
|
2014-05-22 08:42:52 -05:00
|
|
|
const char * DeviceConnectionControl::id_name = "_id_name";
|
|
|
|
|
|
2014-05-19 18:04:58 -05:00
|
|
|
DeviceConnectionControl::DeviceConnectionControl (const std::string& device_capture_name, bool active, uint16_t capture_number, const std::string& track_name)
|
2014-05-01 06:06:16 -05:00
|
|
|
|
2014-06-11 06:00:48 -05:00
|
|
|
: Gtk::Layout(),
|
|
|
|
|
WavesUI("device_capture_control.xml", *this)
|
2014-06-03 02:02:01 -05:00
|
|
|
, _active(false)
|
2014-05-06 03:21:18 -05:00
|
|
|
, _active_on_button (NULL)
|
|
|
|
|
, _active_off_button (NULL)
|
2014-05-01 06:06:16 -05:00
|
|
|
, _name_label (NULL)
|
|
|
|
|
, _track_name_label (NULL)
|
2014-05-12 09:21:16 -05:00
|
|
|
, _number_label (NULL)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
XMLNode* root = xml_tree()->root();
|
|
|
|
|
WavesUI::set_attributes(*this, *root, XMLNodeMap());
|
|
|
|
|
|
|
|
|
|
_active_on_button = &get_waves_button ("capture_on_button");
|
|
|
|
|
_active_off_button = &get_waves_button ("capture_off_button");
|
|
|
|
|
_name_label = &get_label ("capture_name_label");
|
|
|
|
|
_number_label = &get_label ("capture_number_label");
|
|
|
|
|
_track_name_label = &get_label ("track_name_label");
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
init(device_capture_name, active, capture_number, track_name);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-19 18:04:58 -05:00
|
|
|
DeviceConnectionControl::DeviceConnectionControl (const std::string& device_playback_name, bool active, uint16_t playback_number)
|
2014-05-01 06:06:16 -05:00
|
|
|
|
|
|
|
|
: Gtk::Layout()
|
2014-06-11 06:00:48 -05:00
|
|
|
, WavesUI("device_playback_control.xml", *this)
|
2014-06-03 02:02:01 -05:00
|
|
|
, _active(false)
|
2014-05-06 03:21:18 -05:00
|
|
|
, _active_on_button (NULL)
|
|
|
|
|
, _active_off_button (NULL)
|
2014-05-01 06:06:16 -05:00
|
|
|
, _name_label (NULL)
|
|
|
|
|
, _track_name_label (NULL)
|
2014-05-12 09:21:16 -05:00
|
|
|
, _number_label (NULL)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
XMLNode* root = xml_tree()->root();
|
|
|
|
|
WavesUI::set_attributes(*this, *root, XMLNodeMap());
|
|
|
|
|
|
|
|
|
|
_active_on_button = &get_waves_button ("playback_on_button");
|
|
|
|
|
_active_off_button = &get_waves_button ("playback_off_button");
|
|
|
|
|
_name_label = &get_label ("playback_name_label");
|
|
|
|
|
_number_label = &get_label ("playback_number_label");
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
init(device_playback_name, active, playback_number);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-12 09:21:16 -05:00
|
|
|
|
2014-05-19 18:04:58 -05:00
|
|
|
void DeviceConnectionControl::init(const std::string& name, bool active, uint16_t number, const std::string& track_name)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-06 03:21:18 -05:00
|
|
|
_active_on_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_active_on));
|
|
|
|
|
_active_off_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_active_off));
|
2014-05-12 09:21:16 -05:00
|
|
|
|
|
|
|
|
if (_name_label != NULL) {
|
|
|
|
|
_name_label->set_text (name);
|
2014-06-24 16:44:19 +03:00
|
|
|
_name_label->set_tooltip_text(name);
|
2014-05-12 09:21:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_number_label != NULL) {
|
|
|
|
|
_number_label->set_text(PBD::to_string (number, std::dec));
|
2014-05-19 18:04:58 -05:00
|
|
|
|
|
|
|
|
if (number == NoNumber) {
|
|
|
|
|
_number_label->get_parent()->hide ();
|
|
|
|
|
}
|
2014-05-12 09:21:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
if (_track_name_label != NULL) {
|
|
|
|
|
_track_name_label->set_text (track_name);
|
|
|
|
|
}
|
2014-05-19 18:04:58 -05:00
|
|
|
|
2014-05-12 09:21:16 -05:00
|
|
|
|
2014-05-16 04:53:12 -05:00
|
|
|
set_active(active);
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2014-05-06 03:21:18 -05:00
|
|
|
DeviceConnectionControl::set_number (uint16_t number)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-12 09:21:16 -05:00
|
|
|
if (_number_label != NULL) {
|
|
|
|
|
if (number == NoNumber) {
|
|
|
|
|
_number_label->get_parent()->hide ();
|
|
|
|
|
} else {
|
|
|
|
|
_number_label->get_parent()->show ();
|
|
|
|
|
_number_label->set_text(PBD::to_string (number, std::dec));
|
|
|
|
|
}
|
2014-05-06 03:21:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DeviceConnectionControl::set_active (bool active)
|
|
|
|
|
{
|
|
|
|
|
_active_on_button->set_active (active);
|
|
|
|
|
_active_off_button->set_active (!active);
|
2014-05-16 04:53:12 -05:00
|
|
|
_active = active;
|
2014-05-06 03:21:18 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-19 18:04:58 -05:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DeviceConnectionControl::set_track_name (const std::string& new_track_name)
|
|
|
|
|
{
|
|
|
|
|
if (_track_name_label != NULL ) {
|
|
|
|
|
_track_name_label->set_text (new_track_name);
|
2014-06-24 16:44:19 +03:00
|
|
|
_track_name_label->set_tooltip_text(new_track_name);
|
2014-05-19 18:04:58 -05:00
|
|
|
if (new_track_name.empty() ) {
|
|
|
|
|
_track_name_label->get_parent()->hide();
|
|
|
|
|
} else {
|
|
|
|
|
_track_name_label->get_parent()->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-05-26 07:39:06 -05:00
|
|
|
std::string
|
|
|
|
|
DeviceConnectionControl::get_port_name ()
|
|
|
|
|
{
|
|
|
|
|
std::string name;
|
|
|
|
|
if (_name_label != NULL) {
|
|
|
|
|
name = _name_label->get_text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-05-06 03:21:18 -05:00
|
|
|
void
|
|
|
|
|
DeviceConnectionControl::on_active_on(WavesButton*)
|
|
|
|
|
{
|
2014-05-16 04:53:12 -05:00
|
|
|
if (_active) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-06 03:21:18 -05:00
|
|
|
set_active (true);
|
|
|
|
|
signal_active_changed(this, true);
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2014-05-06 03:21:18 -05:00
|
|
|
DeviceConnectionControl::on_active_off(WavesButton*)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-16 04:53:12 -05:00
|
|
|
if (!_active) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-06 03:21:18 -05:00
|
|
|
set_active (false);
|
|
|
|
|
signal_active_changed(this, false);
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|