mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 13:46:30 +01:00
101 lines
3.4 KiB
C++
101 lines
3.4 KiB
C++
|
|
/*
|
||
|
|
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.
|
||
|
|
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include "device_connection_conrol.h"
|
||
|
|
#include "pbd/convert.h"
|
||
|
|
|
||
|
|
DeviceConnectionControl::DeviceConnectionControl (std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name)
|
||
|
|
|
||
|
|
: Gtk::Layout()
|
||
|
|
, _switch_on_button (NULL)
|
||
|
|
, _switch_off_button (NULL)
|
||
|
|
, _name_label (NULL)
|
||
|
|
, _track_name_label (NULL)
|
||
|
|
{
|
||
|
|
build_layout("device_capture_connection_conrol.xml");
|
||
|
|
_switch_on_button = &_children.get_waves_button ("capture_on_button");
|
||
|
|
_switch_off_button = &_children.get_waves_button ("capture_off_button");
|
||
|
|
_name_label = &_children.get_label ("capture_name_label");
|
||
|
|
_number_label = &_children.get_label ("capture_number_label");
|
||
|
|
_track_name_label = &_children.get_label ("track_name_label");
|
||
|
|
init(device_capture_name, active, capture_number, track_name);
|
||
|
|
}
|
||
|
|
|
||
|
|
DeviceConnectionControl::DeviceConnectionControl (std::string device_playback_name, bool active, uint16_t playback_number)
|
||
|
|
|
||
|
|
: Gtk::Layout()
|
||
|
|
, _switch_on_button (NULL)
|
||
|
|
, _switch_off_button (NULL)
|
||
|
|
, _name_label (NULL)
|
||
|
|
, _track_name_label (NULL)
|
||
|
|
{
|
||
|
|
build_layout("device_playback_connection_conrol.xml");
|
||
|
|
_switch_on_button = &_children.get_waves_button ("playback_on_button");
|
||
|
|
_switch_off_button = &_children.get_waves_button ("playback_off_button");
|
||
|
|
_name_label = &_children.get_label ("playback_name_label");
|
||
|
|
_number_label = &_children.get_label ("playback_number_label");
|
||
|
|
init(device_playback_name, active, playback_number);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DeviceConnectionControl::init(std::string name, bool active, uint16_t number, std::string track_name)
|
||
|
|
{
|
||
|
|
_switch_on_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_switch_on));
|
||
|
|
_switch_off_button->signal_clicked.connect (sigc::mem_fun (*this, &DeviceConnectionControl::on_switch_off));
|
||
|
|
_name_label->set_text (name);
|
||
|
|
_number_label->set_text(PBD::to_string (number, std::dec));
|
||
|
|
if (_track_name_label != NULL) {
|
||
|
|
_track_name_label->set_text (track_name);
|
||
|
|
}
|
||
|
|
_switch_on_button->set_active (active);
|
||
|
|
_switch_off_button->set_active (!active);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool
|
||
|
|
DeviceConnectionControl::build_layout (std::string file_name)
|
||
|
|
{
|
||
|
|
const XMLTree* layout = WavesUI::load_layout(file_name);
|
||
|
|
if (layout == NULL) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
XMLNode* root = layout->root();
|
||
|
|
if ((root == NULL) || strcasecmp(root->name().c_str(), "layout")) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
WavesUI::set_attributes(*this, *root, XMLNodeMap());
|
||
|
|
WavesUI::create_ui(layout, *this, _children);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void
|
||
|
|
DeviceConnectionControl::on_switch_on(WavesButton*)
|
||
|
|
{
|
||
|
|
_switch_on_button->set_active (true);
|
||
|
|
_switch_off_button->set_active (false);
|
||
|
|
_switch_changed(this, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
void
|
||
|
|
DeviceConnectionControl::on_switch_off(WavesButton*)
|
||
|
|
{
|
||
|
|
_switch_on_button->set_active (false);
|
||
|
|
_switch_off_button->set_active (true);
|
||
|
|
_switch_changed(this, false);
|
||
|
|
}
|