Progressing Preferences panel and UI

[git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 456933]
This commit is contained in:
Valeriy Kamyshniy 2014-05-01 06:06:16 -05:00
parent 9a37477ccd
commit ea0adfc024
15 changed files with 661 additions and 356 deletions

27
gtk2_ardour/dbg_msg.h Normal file
View file

@ -0,0 +1,27 @@
/*
Copyright (C) 2014 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.
*/
#ifndef __dbg_msg_h__
#define __dbg_msg_h__
#include <gtkmm/messagedialog.h>
#define dbg_msg(a) Gtk::MessageDialog (a, PROGRAM_NAME).run()
#endif /* __dbg_msg_h__ */

View file

@ -0,0 +1,100 @@
/*
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);
}

View file

@ -0,0 +1,51 @@
/*
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.
*/
#ifndef __device_connection_conrol_h__
#define __device_connection_conrol_h__
#include <inttypes.h>
#include <gtkmm/layout.h>
#include "waves_ui.h"
class XMLTree;
class DeviceConnectionControl : public Gtk::Layout
{
public:
DeviceConnectionControl (std::string device_capture_name, bool active, uint16_t capture_number, std::string track_name);
DeviceConnectionControl (std::string device_playback_name, bool active, uint16_t playback_number);
bool build_layout (std::string file_name);
private:
void init(std::string name, bool active, uint16_t number, std::string track_name="");
void on_switch_on(WavesButton*);
void on_switch_off(WavesButton*);
sigc::signal2<void, DeviceConnectionControl*, bool> _switch_changed;
WavesUI::WidgetMap _children;
WavesButton* _switch_on_button;
WavesButton* _switch_off_button;
Gtk::Label* _name_label;
Gtk::Label* _number_label;
Gtk::Label* _track_name_label;
};
#endif // __device_connection_conrol_h__

View file

@ -61,27 +61,29 @@ using namespace Glib;
TracksControlPanel::TracksControlPanel ()
: WavesDialog ("tracks_preferences.xml")
, audio_settings_layout(get_layout ("audio_settings_layout"))
, midi_settings_layout(get_layout ("midi_settings_layout"))
, session_settings_layout(get_layout ("session_settings_layout"))
, audio_settings_tab_button (get_waves_button ("audio_settings_tab_button"))
, midi_settings_tab_button (get_waves_button ("midi_settings_tab_button"))
, session_settings_tab_button (get_waves_button ("session_settings_tab_button"))
, ok_button (get_waves_button ("ok_button"))
, cancel_button (get_waves_button ("cancel_button"))
, apply_button (get_waves_button ("apply_button"))
, control_panel_button (get_waves_button ("control_panel_button"))
, no_button (get_waves_button ("no_button"))
, name_track_after_driver_button (get_waves_button ("name_track_after_driver_button"))
, reset_track_names_button (get_waves_button ("reset_track_names_button"))
, yes_button (get_waves_button ("yes_button"))
, engine_combo (get_combo_box_text ("engine_combo"))
, device_combo (get_combo_box_text ("device_combo"))
, sample_rate_combo (get_combo_box_text ("sample_rate_combo"))
, buffer_size_combo (get_combo_box_text ("buffer_size_combo"))
, latency_label (get_label("latency_label"))
, multi_out_button(get_waves_button ("multi_out_button"))
, stereo_out_button(get_waves_button ("stereo_out_button"))
, _device_capture_list (named_children ().get_vbox("device_capture_list"))
, _device_playback_list (named_children ().get_vbox("device_playback_list"))
, _audio_settings_layout (named_children ().get_layout ("audio_settings_layout"))
, _midi_settings_layout (named_children ().get_layout ("midi_settings_layout"))
, _session_settings_layout (named_children ().get_layout ("session_settings_layout"))
, _audio_settings_tab_button (named_children ().get_waves_button ("audio_settings_tab_button"))
, _midi_settings_tab_button (named_children ().get_waves_button ("midi_settings_tab_button"))
, _session_settings_tab_button (named_children ().get_waves_button ("session_settings_tab_button"))
, _ok_button (named_children ().get_waves_button ("ok_button"))
, _cancel_button (named_children ().get_waves_button ("cancel_button"))
, _apply_button (named_children ().get_waves_button ("apply_button"))
, _control_panel_button (named_children ().get_waves_button ("control_panel_button"))
, _no_button (named_children ().get_waves_button ("no_button"))
, _name_track_after_driver_button (named_children ().get_waves_button ("name_track_after_driver_button"))
, _reset_track_names_button (named_children ().get_waves_button ("reset_track_names_button"))
, _yes_button (named_children ().get_waves_button ("yes_button"))
, _engine_combo (named_children ().get_combo_box_text ("engine_combo"))
, _device_combo (named_children ().get_combo_box_text ("device_combo"))
, _sample_rate_combo (named_children ().get_combo_box_text ("sample_rate_combo"))
, _buffer_size_combo (named_children ().get_combo_box_text ("buffer_size_combo"))
, _latency_label (named_children ().get_label("latency_label"))
, _multi_out_button(named_children ().get_waves_button ("multi_out_button"))
, _stereo_out_button(named_children ().get_waves_button ("stereo_out_button"))
, _have_control (false)
, _ignore_changes (0)
{

View file

@ -48,27 +48,29 @@ class TracksControlPanel : public WavesDialog, public PBD::ScopedConnectionList
~TracksControlPanel ();
private:
Gtk::Layout& audio_settings_layout;
Gtk::Layout& midi_settings_layout;
Gtk::Layout& session_settings_layout;
WavesButton& audio_settings_tab_button;
WavesButton& session_settings_tab_button;
WavesButton& midi_settings_tab_button;
WavesButton& multi_out_button;
WavesButton& stereo_out_button;
WavesButton& ok_button;
WavesButton& cancel_button;
WavesButton& apply_button;
WavesButton& control_panel_button;
WavesButton& no_button;
WavesButton& name_track_after_driver_button;
WavesButton& reset_track_names_button;
WavesButton& yes_button;
Gtk::ComboBoxText& engine_combo;
Gtk::ComboBoxText& device_combo;
Gtk::ComboBoxText& sample_rate_combo;
Gtk::ComboBoxText& buffer_size_combo;
Gtk::Label& latency_label;
Gtk::VBox& _device_capture_list;
Gtk::VBox& _device_playback_list;
Gtk::Layout& _audio_settings_layout;
Gtk::Layout& _midi_settings_layout;
Gtk::Layout& _session_settings_layout;
WavesButton& _audio_settings_tab_button;
WavesButton& _session_settings_tab_button;
WavesButton& _midi_settings_tab_button;
WavesButton& _multi_out_button;
WavesButton& _stereo_out_button;
WavesButton& _ok_button;
WavesButton& _cancel_button;
WavesButton& _apply_button;
WavesButton& _control_panel_button;
WavesButton& _no_button;
WavesButton& _name_track_after_driver_button;
WavesButton& _reset_track_names_button;
WavesButton& _yes_button;
Gtk::ComboBoxText& _engine_combo;
Gtk::ComboBoxText& _device_combo;
Gtk::ComboBoxText& _sample_rate_combo;
Gtk::ComboBoxText& _buffer_size_combo;
Gtk::Label& _latency_label;
#include "tracks_control_panel.logic.h"
};

View file

@ -26,11 +26,12 @@
#include "ardour/audio_backend.h"
#include "ardour/audioengine.h"
#include "ardour/rc_configuration.h"
#include "device_connection_conrol.h"
#include "ardour_ui.h"
#include "gui_thread.h"
#include "utils.h"
#include "i18n.h"
#include "pbd/convert.h"
using namespace std;
using namespace Gtk;
@ -43,17 +44,17 @@ using namespace Glib;
void
TracksControlPanel::init ()
{
ok_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_ok));
cancel_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_cancel));
apply_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_apply));
_ok_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_ok));
_cancel_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_cancel));
_apply_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_apply));
audio_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_audio_settings));
midi_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_midi_settings));
session_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_session_settings));
control_panel_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_control_panel));
_audio_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_audio_settings));
_midi_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_midi_settings));
_session_settings_tab_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_session_settings));
_control_panel_button.signal_clicked.connect (sigc::mem_fun (*this, &TracksControlPanel::on_control_panel));
multi_out_button.signal_clicked.connect(sigc::mem_fun (*this, &TracksControlPanel::on_multi_out));
stereo_out_button.signal_clicked.connect(sigc::mem_fun (*this, &TracksControlPanel::on_stereo_out));
_multi_out_button.signal_clicked.connect(sigc::mem_fun (*this, &TracksControlPanel::on_multi_out));
_stereo_out_button.signal_clicked.connect(sigc::mem_fun (*this, &TracksControlPanel::on_stereo_out));
ARDOUR::AudioEngine::instance ()->Running.connect (running_connection, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::engine_running, this), gui_context());
ARDOUR::AudioEngine::instance ()->Stopped.connect (stopped_connection, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::engine_stopped, this), gui_context());
@ -63,17 +64,17 @@ TracksControlPanel::init ()
ARDOUR::AudioEngine::instance()->BufferSizeChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::update_current_buffer_size, this, _1), gui_context());
ARDOUR::AudioEngine::instance()->DeviceListChanged.connect (update_connections, MISSING_INVALIDATOR, boost::bind (&TracksControlPanel::update_device_list, this), gui_context());
engine_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::engine_changed));
device_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::device_changed));
sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::sample_rate_changed));
buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::buffer_size_changed));
_engine_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::engine_changed));
_device_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::device_changed));
_sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::sample_rate_changed));
_buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &TracksControlPanel::buffer_size_changed));
populate_engine_combo ();
midi_settings_layout.hide ();
session_settings_layout.hide ();
audio_settings_tab_button.set_active(true);
multi_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectPhysical);
stereo_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectMaster);
_midi_settings_layout.hide ();
_session_settings_layout.hide ();
_audio_settings_tab_button.set_active(true);
_multi_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectPhysical);
_stereo_out_button.set_active(ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectMaster);
}
void
@ -83,7 +84,7 @@ TracksControlPanel::populate_engine_combo()
return;
}
vector<string> strings;
std::vector<std::string> strings;
vector<const ARDOUR::AudioBackendInfo*> backends = ARDOUR::AudioEngine::instance()->available_backends();
if (backends.empty()) {
@ -98,13 +99,13 @@ TracksControlPanel::populate_engine_combo()
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (engine_combo, strings);
engine_combo.set_sensitive (strings.size() > 1);
set_popdown_strings (_engine_combo, strings);
_engine_combo.set_sensitive (strings.size() > 1);
}
if (!strings.empty() )
{
engine_combo.set_active_text (strings.front());
_engine_combo.set_active_text (strings.front());
}
}
@ -124,12 +125,12 @@ TracksControlPanel::populate_device_combo()
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (device_combo, available_devices);
device_combo.set_sensitive (available_devices.size() > 1);
set_popdown_strings (_device_combo, available_devices);
_device_combo.set_sensitive (available_devices.size() > 1);
}
if(!available_devices.empty() ) {
device_combo.set_active_text (available_devices.front() );
_device_combo.set_active_text (available_devices.front() );
}
}
@ -139,7 +140,7 @@ TracksControlPanel::populate_sample_rate_combo()
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
assert (backend);
std::string device_name = device_combo.get_active_text ();
std::string device_name = _device_combo.get_active_text ();
std::vector<std::string> s;
vector<float> sr;
@ -151,8 +152,8 @@ TracksControlPanel::populate_sample_rate_combo()
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (sample_rate_combo, s);
sample_rate_combo.set_sensitive (s.size() > 1);
set_popdown_strings (_sample_rate_combo, s);
_sample_rate_combo.set_sensitive (s.size() > 1);
}
if (!s.empty() ) {
@ -162,7 +163,7 @@ TracksControlPanel::populate_sample_rate_combo()
if (std::find(s.begin(), s.end(), active_sr) == s.end()) {
active_sr = s.front();
}
sample_rate_combo.set_active_text(active_sr);
_sample_rate_combo.set_active_text(active_sr);
}
}
@ -171,7 +172,7 @@ TracksControlPanel::populate_buffer_size_combo()
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
assert (backend);
std::string device_name = device_combo.get_active_text ();
std::string device_name = _device_combo.get_active_text ();
std::vector<std::string> s;
std::vector<uint32_t> bs;
@ -183,8 +184,8 @@ TracksControlPanel::populate_buffer_size_combo()
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (buffer_size_combo, s);
buffer_size_combo.set_sensitive (s.size() > 1);
set_popdown_strings (_buffer_size_combo, s);
_buffer_size_combo.set_sensitive (s.size() > 1);
}
if (!s.empty() ) {
@ -192,13 +193,23 @@ TracksControlPanel::populate_buffer_size_combo()
if (std::find(s.begin(), s.end(), active_bs) == s.end() ) {
active_bs = s.front();
}
buffer_size_combo.set_active_text(active_bs);
_buffer_size_combo.set_active_text(active_bs);
}
}
void
TracksControlPanel::on_control_panel(WavesButton*)
{
static uint16_t number = 0;
static bool active = false;
number++;
active = !active;
std::string name = string_compose (_("Input %1"), number);
_device_capture_list.pack_start (*manage (new DeviceConnectionControl(name, active, 1, name)), false, false);
name = string_compose (_("Output %1"), number);
_device_playback_list.pack_start (*manage (new DeviceConnectionControl(name, active, 1)), false, false);
}
void TracksControlPanel::engine_changed ()
@ -207,7 +218,7 @@ void TracksControlPanel::engine_changed ()
return;
}
string backend_name = engine_combo.get_active_text();
string backend_name = _engine_combo.get_active_text();
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->set_backend (backend_name, "ardour", "");
if (!backend)
{
@ -226,7 +237,7 @@ void TracksControlPanel::device_changed ()
return;
}
string newDevice = device_combo.get_active_text();
std::string newDevice = _device_combo.get_active_text();
if (newDevice != "None") {
_current_device = newDevice;
}
@ -261,13 +272,13 @@ TracksControlPanel::update_current_buffer_size (uint32_t new_buffer_size)
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
assert (backend);
string new_buffer_size_str = bufsize_as_string(new_buffer_size);
std::string new_buffer_size_str = bufsize_as_string(new_buffer_size);
/* check if new buffer size value is no the same as already set in combobox */
if ( new_buffer_size_str != buffer_size_combo.get_active_text() ) {
if ( new_buffer_size_str != _buffer_size_combo.get_active_text() ) {
vector<string> s;
vector<uint32_t> bs;
string device_name = device_combo.get_active_text ();
std::string device_name = _device_combo.get_active_text ();
bs = backend->available_buffer_sizes(device_name);
for (vector<uint32_t>::const_iterator x = bs.begin(); x != bs.end(); ++x) {
@ -277,13 +288,13 @@ TracksControlPanel::update_current_buffer_size (uint32_t new_buffer_size)
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (buffer_size_combo, s);
buffer_size_combo.set_sensitive (s.size() > 1);
set_popdown_strings (_buffer_size_combo, s);
_buffer_size_combo.set_sensitive (s.size() > 1);
}
if (!s.empty() ) {
if (std::find(s.begin(), s.end(), new_buffer_size_str) == s.end() ) {
buffer_size_combo.set_active_text (new_buffer_size_str );
_buffer_size_combo.set_active_text (new_buffer_size_str );
} else {
MessageDialog( _("Buffer size changed to the value which is not supported"), PROGRAM_NAME).run();
}
@ -311,10 +322,10 @@ TracksControlPanel::update_device_list ()
if (!available_devices.empty()) {
/* Now get current device name */
string current_active_device = device_combo.get_active_text ();
std::string current_active_device = _device_combo.get_active_text ();
/* If previous device is available again we should switch to it from "None" */
string newDevice;
std::string newDevice;
if (current_active_device == "None" && !_current_device.empty() ){
newDevice = _current_device;
} else {
@ -325,8 +336,8 @@ TracksControlPanel::update_device_list ()
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
set_popdown_strings (device_combo, available_devices);
device_combo.set_sensitive (available_devices.size() > 1);
set_popdown_strings (_device_combo, available_devices);
_device_combo.set_sensitive (available_devices.size() > 1);
for (vector<string>::const_iterator i = available_devices.begin(); i != available_devices.end(); ++i) {
if (newDevice == *i) {
@ -348,14 +359,14 @@ TracksControlPanel::update_device_list ()
void
TracksControlPanel::switch_to_device(const string& device_name)
TracksControlPanel::switch_to_device(const std::string& device_name)
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
{
// set _ignore_changes flag to ignore changes in combo-box callbacks
PBD::Unwinder<uint32_t> protect_ignore_changes (_ignore_changes, _ignore_changes + 1);
device_combo.set_active_text(device_name);
_device_combo.set_active_text(device_name);
}
if (backend->device_name() != device_name) {
@ -372,12 +383,12 @@ TracksControlPanel::engine_running ()
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
assert (backend);
buffer_size_combo.set_active_text (bufsize_as_string (backend->buffer_size()));
_buffer_size_combo.set_active_text (bufsize_as_string (backend->buffer_size()));
sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
_sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
buffer_size_combo.set_sensitive (true);
sample_rate_combo.set_sensitive (true);
_buffer_size_combo.set_sensitive (true);
_sample_rate_combo.set_sensitive (true);
}
@ -390,36 +401,36 @@ TracksControlPanel::engine_stopped ()
void
TracksControlPanel::on_audio_settings (WavesButton*)
{
midi_settings_layout.hide ();
midi_settings_tab_button.set_active(false);
session_settings_layout.hide ();
session_settings_tab_button.set_active(false);
audio_settings_layout.show ();
audio_settings_tab_button.set_active(true);
_midi_settings_layout.hide ();
_midi_settings_tab_button.set_active(false);
_session_settings_layout.hide ();
_session_settings_tab_button.set_active(false);
_audio_settings_layout.show ();
_audio_settings_tab_button.set_active(true);
}
void
TracksControlPanel::on_midi_settings (WavesButton*)
{
audio_settings_layout.hide ();
audio_settings_tab_button.set_active(false);
session_settings_layout.hide ();
session_settings_tab_button.set_active(false);
midi_settings_layout.show ();
midi_settings_tab_button.set_active(true);
_audio_settings_layout.hide ();
_audio_settings_tab_button.set_active(false);
_session_settings_layout.hide ();
_session_settings_tab_button.set_active(false);
_midi_settings_layout.show ();
_midi_settings_tab_button.set_active(true);
}
void
TracksControlPanel::on_session_settings (WavesButton*)
{
audio_settings_layout.hide ();
audio_settings_tab_button.set_active(false);
midi_settings_layout.hide ();
midi_settings_tab_button.set_active(false);
session_settings_layout.show ();
session_settings_tab_button.set_active(true);
_audio_settings_layout.hide ();
_audio_settings_tab_button.set_active(false);
_midi_settings_layout.hide ();
_midi_settings_tab_button.set_active(false);
_session_settings_layout.show ();
_session_settings_tab_button.set_active(true);
}
@ -431,22 +442,22 @@ TracksControlPanel::on_multi_out (WavesButton*)
}
ARDOUR::Config->set_output_auto_connect(ARDOUR::AutoConnectPhysical);
stereo_out_button.set_active(false);
multi_out_button.set_active(true);
_stereo_out_button.set_active(false);
_multi_out_button.set_active(true);
}
void
TracksControlPanel::on_stereo_out (WavesButton*)
{
if (ARDOUR::Config->get_output_auto_connect() & ARDOUR::AutoConnectMaster) {
return;
}
ARDOUR::Config->set_output_auto_connect(ARDOUR::AutoConnectMaster);
multi_out_button.set_active(false);
stereo_out_button.set_active(true);
_multi_out_button.set_active(false);
_stereo_out_button.set_active(true);
}
void
@ -489,11 +500,11 @@ TracksControlPanel::set_desired_sample_rate (uint32_t sr)
{
_desired_sample_rate = sr;
std::string active_sr = rate_as_string(_desired_sample_rate);
std::string prev_selected = sample_rate_combo.get_active_text();
sample_rate_combo.set_active_text(active_sr);
active_sr = sample_rate_combo.get_active_text();
std::string prev_selected = _sample_rate_combo.get_active_text();
_sample_rate_combo.set_active_text(active_sr);
active_sr = _sample_rate_combo.get_active_text();
if (active_sr.empty()) {
sample_rate_combo.set_active_text(prev_selected);
_sample_rate_combo.set_active_text(prev_selected);
}
}
@ -542,7 +553,7 @@ TracksControlPanel::set_state (const XMLNode& root)
float
TracksControlPanel::get_sample_rate () const
{
float r = atof (sample_rate_combo.get_active_text ());
float r = atof (_sample_rate_combo.get_active_text ());
/* the string may have been translated with an abbreviation for
* thousands, so use a crude heuristic to fix this.
*/
@ -554,7 +565,7 @@ TracksControlPanel::get_sample_rate () const
uint32_t TracksControlPanel::get_buffer_size() const
{
string bs_text = buffer_size_combo.get_active_text ();
string bs_text = _buffer_size_combo.get_active_text ();
uint32_t samples = atoi (bs_text); /* will ignore trailing text */
return samples;
}
@ -567,7 +578,7 @@ TracksControlPanel::show_buffer_duration ()
char buf[256];
snprintf (buf, sizeof (buf), _("INPUT LATENCY: %.1f MS OUTPUT LATENCY: %.1f MS TOTAL LATENCY: %.1f MS"),
latency, latency, 2*latency);
latency_label.set_text (buf);
_latency_label.set_text (buf);
}
int

View file

@ -27,7 +27,7 @@
void switch_to_device(const std::string& device_name);
float get_sample_rate() const;
std::string get_device_name() const { return device_combo.get_active_text (); };
std::string get_device_name() const { return _device_combo.get_active_text (); };
private:
// data types:

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout bgnormal="#565656" width="274" height="20">
<style name="generic_control" font ="Arial 10"/>
<Layout bgnormal="#862579" x="0" y="0" width="3" height="20"/>
<Layout bgnormal="#797979" x="6" y="0" width="85" height="19">
<Label style="generic_control"
id="capture_name_label"
text="-"
fgnormal="#000000"
x="7" y="3"/>
</Layout>
<Button id="capture_on_button"
text="ON"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#1CA3B3"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="95" y="0" width="29" height="19"/>
<Button id="capture_off_button"
text="OFF"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#FC3334"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="125" y="0" width="29" height="19"/>
<Layout bgnormal="#797979" x="158" y="0" width="26" height="19">
<Label style="generic_control"
id="capture_number_label"
text="-"
fgnormal="#000000"
x="7"
y="3"/>
</Layout>
<Layout bgnormal="#797979" x="186" y="0" width="85" height="19">
<Label style="generic_control"
id="track_name_label"
text="-"
fgnormal="#000000"
x="7" y="3"/>
</Layout>
</Layout>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout bgnormal="#565656" width="184" height="20">
<style name="generic_control" font ="Arial 10"/>
<Layout bgnormal="#862579" x="0" y="0" width="3" height="20"/>
<Layout bgnormal="#797979" x="6" y="0" width="85" height="19">
<Label style="generic_control"
id="playback_name_label"
text="-"
fgnormal="#000000"
x="7" y="3"/>
</Layout>
<Button id="playback_on_button"
text="ON"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#1CA3B3"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="95" y="0" width="29" height="19"/>
<Button id="playback_off_button"
text="OFF"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#FC3334"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="125" y="0" width="29" height="19"/>
<Layout bgnormal="#797979" x="158" y="0" width="26" height="19">
<Label style="generic_control"
id="playback_number_label"
text="-"
fgnormal="#000000"
x="7"
y="3"/>
</Layout>
</Layout>

View file

@ -155,76 +155,11 @@
<Layout bgnormal="#797979" x="448" y="35" width="26" height="19">
<Label style="generic_control" text="#" fgnormal="#000000" x="7" y="3"/>
</Layout>
<ScrolledWindow x="14" y="62" width="480" height="299">
<ScrolledWindow x="14" y="62" width="480" height="299" hscroll="never" vscroll="always">
<HBox>
<VBox>
<Layout bgnormal="#565656" width="274" height="20">
<Layout bgnormal="#862579" x="0" y="0" width="3" height="19"/>
<Layout bgnormal="#797979" x="6" y="0" width="85" height="19">
<Label style="generic_control" text="In 1" fgnormal="#000000" x="7" y="3"/>
</Layout>
<Button id="input_on_button"
text="ON"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#1CA3B3"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="95" y="0" width="29" height="19"/>
<Button id="input_off_button"
text="OFF"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#FC3334"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="125" y="0" width="29" height="19"/>
<Layout bgnormal="#797979" x="158" y="0" width="26" height="19">
<Label style="generic_control" text="1" fgnormal="#000000" x="7" y="3"/>
</Layout>
<Layout bgnormal="#797979" x="186" y="0" width="85" height="19">
<Label style="generic_control" text="Track Name" fgnormal="#000000" x="7" y="3"/>
</Layout>
</Layout>
<VBox id="device_capture_list">
</VBox>
<VBox>
<Layout bgnormal="#565656" width="184" height="20">
<Layout bgnormal="#27ae36" x="0" y="0" width="3" height="19"/>
<Layout bgnormal="#797979" x="6" y="0" width="85" height="19">
<Label style="generic_control" text="Out 1" fgnormal="#000000" x="7" y="3"/>
</Layout>
<Button id="output_on_button"
text="ON"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#1CA3B3"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="95" y="0" width="29" height="19"/>
<Button id="output_off_button"
text="OFF"
style="generic_control"
fgnormal="#FFFFFF"
bgnormal="#606060"
fgactive="#FFFFFF"
bgactive="#FC3334"
fghover="#FFFFFF"
bghover="#808080"
borderwidth="0 0 0 0"
x="125" y="0" width="29" height="19"/>
<Layout bgnormal="#797979" x="158" y="0" width="26" height="19">
<Label style="generic_control" text="1" fgnormal="#000000" x="7" y="3"/>
</Layout>
</Layout>
<VBox id="device_playback_list">
</VBox>
</HBox>
</ScrolledWindow>
@ -274,7 +209,7 @@
x="419" y="18" width="71" height="28"/>
</Layout>
<Layout id="midi_settings_layout" bgnormal="#565656" x="113" y="1" width="505" height="557">
<Layout id="midi_settings_layout" bgnormal="#565656" x="113" y="1" width="505" height="557" visible="false">
<Layout bgnormal="#000000" x="21" y="20" width="291" height="19">
<Label style="generic_control" text="MIDI PORTS" fgnormal="#ffffff" font ="Arial Bold 10" x="7" y="3"/>
</Layout>
@ -285,7 +220,7 @@
<Label style="generic_control" text="OUTPUT" fgnormal="#ffffff" font="Arial Bold 10" x="7" y="3"/>
</Layout>
</Layout>
<Layout id="session_settings_layout" bgnormal="#565656" x="113" y="1" width="505" height="557">
<Layout id="session_settings_layout" bgnormal="#565656" x="113" y="1" width="505" height="557" visible="false">
<!--
Igor! Add feel free to add what you need here!

View file

@ -22,7 +22,6 @@
#include <sigc++/bind.h>
#include <boost/algorithm/string.hpp>
#include "pbd/xml++.h"
#include "waves_ui.h"
#include <gtkmm2ext/doi.h>
@ -38,7 +37,6 @@
#include "utils.h"
#include "window_manager.h"
using namespace std;
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace PBD;
@ -46,10 +44,10 @@ using namespace ARDOUR;
WavesDialog::WavesDialog (std::string layout_script_file, bool modal, bool use_seperator)
: Dialog ("", modal, use_seperator)
, proxy (0)
, _proxy (0)
, _splash_pushed (false)
{
list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
std::list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
Glib::RefPtr<Gdk::Pixbuf> icon;
if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
@ -80,8 +78,8 @@ WavesDialog::WavesDialog (std::string layout_script_file, bool modal, bool use_s
ARDOUR_UI::CloseAllDialogs.connect (sigc::bind (sigc::mem_fun (*this, &WavesDialog::response), RESPONSE_CANCEL));
proxy = new WM::ProxyTemporary (get_title(), this);
WM::Manager::instance().register_window (proxy);
_proxy = new WM::ProxyTemporary (get_title(), this);
WM::Manager::instance().register_window (_proxy);
get_vbox()->set_spacing (0);
get_vbox()->set_border_width (0);
@ -99,7 +97,7 @@ WavesDialog::~WavesDialog ()
spl->pop_front();
}
}
WM::Manager::instance().remove (proxy);
WM::Manager::instance().remove (_proxy);
}
bool
@ -157,16 +155,11 @@ WavesDialog::on_delete_event (GdkEventAny*)
bool
WavesDialog::read_layout (std::string file_name)
{
std::string layout_file;
Searchpath spath (ardour_data_search_path());
spath.add_subdirectory_to_paths("ui");
if (!find_file_in_search_path (spath, file_name, layout_file)) {
const XMLTree* layout = WavesUI::load_layout(file_name);
if (layout == NULL) {
return false;
}
XMLTree layout(layout_file, false);
XMLNode* root = layout.root();
XMLNode* root = layout->root();
if ((root == NULL) || strcasecmp(root->name().c_str(), "dialog")) {
return false;
}
@ -179,62 +172,5 @@ WavesDialog::read_layout (std::string file_name)
set_border_width(0);
WavesUI::create_ui(layout, *get_vbox(), _children);
return true;
}
Gtk::Widget*
WavesDialog::get_widget(char *id)
{
Gtk::Widget *child = NULL;
std::map<std::string, Gtk::Widget*>::iterator it = _children.find(id);
if(it != _children.end())
child = it->second;
return child;
}
Gtk::Layout&
WavesDialog::get_layout (char* id)
{
Gtk::Layout* child = dynamic_cast<Gtk::Layout*> (get_widget(id));
if (child == NULL ) {
throw exception();
}
return *child;
}
Gtk::Label&
WavesDialog::get_label (char* id)
{
Gtk::Label* child = dynamic_cast<Gtk::Label*> (get_widget(id));
if (child == NULL ) {
throw exception();
}
return *child;
}
Gtk::ComboBoxText&
WavesDialog::get_combo_box_text (char* id)
{
Gtk::ComboBoxText* child = dynamic_cast<Gtk::ComboBoxText*> (get_widget(id));
if (child == NULL ) {
throw exception();
}
return *child;
}
WavesButton&
WavesDialog::get_waves_button (char* id)
{
WavesButton* child = dynamic_cast<WavesButton*> (get_widget(id));
if (child == NULL ) {
throw exception();
}
return *child;
}

View file

@ -23,6 +23,7 @@
#include <gtkmm.h>
#include "ardour/session_handle.h"
#include "waves_ui.h"
#include "canvas/xml_ui.h"
using namespace ArdourCanvas::XMLUI;
@ -57,21 +58,15 @@ class WavesDialog : public Gtk::Dialog, public ARDOUR::SessionHandlePtr
protected:
bool read_layout (std::string file_name);
Gtk::Layout& get_layout (char* id);
Gtk::Label& get_label (char* id);
Gtk::ComboBoxText& get_combo_box_text (char* id);
WavesButton& get_waves_button (char* id);
WavesUI::WidgetMap& named_children() { return _children; }
private:
WM::ProxyTemporary* proxy;
WM::ProxyTemporary* _proxy;
bool _splash_pushed;
std::map<std::string, Gtk::Widget*> _children;
WavesUI::WidgetMap _children;
Gtk::Widget* get_widget(char *id);
static sigc::signal<void> CloseAllDialogs;
};

View file

@ -16,14 +16,19 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "waves_ui.h"
#include "canvas/canvas.h"
#include "waves_button.h"
//std::ofstream dbg_out("/users/WavesUILog.txt");
#include <exception>
#include "waves_ui.h"
#include "pbd/file_utils.h"
#include "ardour/filesystem_paths.h"
#include "dbg_msg.h"
using namespace PBD;
using namespace ARDOUR;
Gtk::Widget*
WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets)
{
Gtk::Widget* child = NULL;
std::string widget_type = definition.name();
@ -33,6 +38,7 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, std
boost::replace_all(text, "\\n", "\n");
std::transform(widget_type.begin(), widget_type.end(), widget_type.begin(), ::toupper);
if (widget_type == "BUTTON") {
child = manage (new WavesButton(text));
((WavesButton*)child)->set_border_width (xml_property (definition, "borderwidth", styles, "0").c_str());
@ -48,6 +54,25 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, std
child = manage (new ArdourCanvas::GtkCanvas(definition, styles, named_items));
} else if (widget_type == "SCROLLEDWINDOW") {
child = manage (new Gtk::ScrolledWindow);
Gtk::PolicyType hscrollbar_policy = Gtk::POLICY_AUTOMATIC;
Gtk::PolicyType vscrollbar_policy = Gtk::POLICY_AUTOMATIC;
std::string property = xml_property (definition, "hscroll", styles, "");
if (property == "never") {
hscrollbar_policy = Gtk::POLICY_NEVER;
} else if (property == "always") {
hscrollbar_policy = Gtk::POLICY_ALWAYS;
} else if (property == "auto") {
hscrollbar_policy = Gtk::POLICY_AUTOMATIC;
}
property = xml_property (definition, "vscroll", styles, "");
if (property == "never") {
vscrollbar_policy = Gtk::POLICY_NEVER;
} else if (property == "always") {
vscrollbar_policy = Gtk::POLICY_ALWAYS;
} else if (property == "auto") {
vscrollbar_policy = Gtk::POLICY_AUTOMATIC;
}
((Gtk::ScrolledWindow*)child)->set_policy(hscrollbar_policy, vscrollbar_policy);
} else if (widget_type == "VBOX") {
child = manage (new Gtk::VBox);
} else if (widget_type == "HBOX") {
@ -55,71 +80,18 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, std
}
if (child != NULL) {
int height = xml_property (definition, "height", styles, -1);
int width = xml_property (definition, "width", styles, -1);
child->set_size_request (width, height);
if (!widget_id.empty())
{
named_widgets[widget_id] = child;
}
std::string property = xml_property (definition, "bgnormal", styles, "");
if (!property.empty()) {
child->modify_bg(Gtk::STATE_NORMAL, Gdk::Color(property));
}
property = xml_property (definition, "bgdisabled", styles, property);
if (!property.empty()) {
child->modify_bg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
}
property = xml_property (definition, "bgactive", styles, "");
if (!property.empty()) {
child->modify_bg(Gtk::STATE_ACTIVE, Gdk::Color(property));
}
property = xml_property (definition, "bghover", styles, "");
if (!property.empty()) {
child->modify_bg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
}
property = xml_property (definition, "fgnormal", styles, "");
if (!property.empty()) {
child->modify_fg(Gtk::STATE_NORMAL, Gdk::Color(property));
}
property = xml_property (definition, "fgdisabled", styles, property);
if (!property.empty()) {
child->modify_fg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
}
property = xml_property (definition, "fgactive", styles, "");
if (!property.empty()) {
child->modify_fg(Gtk::STATE_ACTIVE, Gdk::Color(property));
}
property = xml_property (definition, "fghover", styles, "");
if (!property.empty()) {
child->modify_fg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
}
property = xml_property (definition, "font", styles, "");
if (!property.empty()) {
child->modify_font(Pango::FontDescription(property));
}
if (xml_property (definition, "visible", styles, true)) {
child->show();
} else {
child->hide();
}
set_attributes(*child, definition, styles);
}
return child;
}
Gtk::Widget*
WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets)
{
Gtk::Widget* child = create_widget(definition, styles, named_widgets);
@ -132,7 +104,7 @@ WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeM
Gtk::Widget*
WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets)
{
Gtk::Widget* child = create_widget(definition, styles, named_widgets);
@ -145,7 +117,7 @@ WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, con
Gtk::Widget*
WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets)
{
Gtk::Widget* child = create_widget(definition, styles, named_widgets);
@ -160,7 +132,7 @@ WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNo
Gtk::Widget*
WavesUI::add_widget (Gtk::Widget& parent, const XMLNode &definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets)
{
Gtk::Widget* child = NULL;
if(dynamic_cast<Gtk::Layout*> (&parent)) {
@ -171,25 +143,190 @@ WavesUI::add_widget (Gtk::Widget& parent, const XMLNode &definition, const XMLNo
child = WavesUI::add_widget (*dynamic_cast<Gtk::ScrolledWindow*> (&parent), definition, styles, named_widgets);
}
if (child != NULL) {
WavesUI::create_ui (definition.children(), styles, *child, named_widgets);
Gtk::Container* container = dynamic_cast<Gtk::Container*>(child);
if (container != NULL) {
WavesUI::create_ui (definition.children(), styles, *container, named_widgets);
}
return child;
}
void
WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Widget& root, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root, std::map<std::string, Gtk::Widget*>& named_widgets)
{
for (XMLNodeList::const_iterator i = definition.begin(); i != definition.end(); ++i) {
WavesUI::add_widget ((Gtk::Widget&)root, **i, styles, named_widgets);
WavesUI::add_widget (root, **i, styles, named_widgets);
}
}
void
WavesUI::create_ui (const XMLTree& layout, Gtk::Widget& root, std::map<std::string, Gtk::Widget*> &named_widgets)
WavesUI::create_ui (const XMLTree& layout, Gtk::Container& root, std::map<std::string, Gtk::Widget*>& named_widgets)
{
XMLNodeMap styles;
get_styles(layout, styles);
const XMLNodeList& definition = layout.root()->children();
WavesUI::create_ui (definition, styles, root, named_widgets);
}
}
static std::map<std::string, const XMLTree*> xml_tree_cache;
const XMLTree*
WavesUI::load_layout (const std::string xml_file_name)
{
std::map<std::string, const XMLTree*>::const_iterator it = xml_tree_cache.find(xml_file_name);
if (it != xml_tree_cache.end()) {
return (*it).second;
}
std::string layout_file;
Searchpath spath (ardour_data_search_path());
spath.add_subdirectory_to_paths("ui");
if (!find_file_in_search_path (spath, xml_file_name, layout_file)) {
dbg_msg("File not found: " + xml_file_name);
return NULL;
}
const XMLTree* tree = new XMLTree (layout_file, false);
xml_tree_cache[xml_file_name] = tree;
return tree;
}
void
WavesUI::set_attributes (Gtk::Widget& widget, const XMLNode& definition, const XMLNodeMap& styles)
{
int height = xml_property (definition, "height", styles, -1);
int width = xml_property (definition, "width", styles, -1);
widget.set_size_request (width, height);
std::string property = xml_property (definition, "bgnormal", styles, "");
if (!property.empty()) {
widget.modify_bg(Gtk::STATE_NORMAL, Gdk::Color(property));
}
property = xml_property (definition, "bgdisabled", styles, property);
if (!property.empty()) {
widget.modify_bg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
}
property = xml_property (definition, "bgactive", styles, "");
if (!property.empty()) {
widget.modify_bg(Gtk::STATE_ACTIVE, Gdk::Color(property));
}
property = xml_property (definition, "bghover", styles, "");
if (!property.empty()) {
widget.modify_bg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
}
property = xml_property (definition, "fgnormal", styles, "");
if (!property.empty()) {
widget.modify_fg(Gtk::STATE_NORMAL, Gdk::Color(property));
}
property = xml_property (definition, "fgdisabled", styles, property);
if (!property.empty()) {
widget.modify_fg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
}
property = xml_property (definition, "fgactive", styles, "");
if (!property.empty()) {
widget.modify_fg(Gtk::STATE_ACTIVE, Gdk::Color(property));
}
property = xml_property (definition, "fghover", styles, "");
if (!property.empty()) {
widget.modify_fg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
}
property = xml_property (definition, "font", styles, "");
if (!property.empty()) {
widget.modify_font(Pango::FontDescription(property));
}
if (xml_property (definition, "visible", styles, true)) {
widget.show();
} else {
widget.hide();
}
}
Gtk::Widget*
WavesUI::WidgetMap::get_widget(char *id)
{
Gtk::Widget *child = NULL;
std::map<std::string, Gtk::Widget*>::iterator it = find(id);
if(it != end())
child = it->second;
return child;
}
Gtk::VBox&
WavesUI::WidgetMap::get_vbox (char* id)
{
Gtk::VBox* child = dynamic_cast<Gtk::VBox*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}
Gtk::HBox&
WavesUI::WidgetMap::get_hbox (char* id)
{
Gtk::HBox* child = dynamic_cast<Gtk::HBox*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}
Gtk::Layout&
WavesUI::WidgetMap::get_layout (char* id)
{
Gtk::Layout* child = dynamic_cast<Gtk::Layout*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}
Gtk::Label&
WavesUI::WidgetMap::get_label (char* id)
{
Gtk::Label* child = dynamic_cast<Gtk::Label*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}
Gtk::ComboBoxText&
WavesUI::WidgetMap::get_combo_box_text (char* id)
{
Gtk::ComboBoxText* child = dynamic_cast<Gtk::ComboBoxText*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}
WavesButton&
WavesUI::WidgetMap::get_waves_button (char* id)
{
WavesButton* child = dynamic_cast<WavesButton*> (get_widget(id));
if (child == NULL ) {
throw std::exception();
}
return *child;
}

View file

@ -23,22 +23,39 @@
#include <string>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include "gtkmm/box.h"
#include "gtkmm/layout.h"
#include "gtkmm/label.h"
#include "gtkmm/scrolledwindow.h"
#include <gtkmm/box.h>
#include <gtkmm/layout.h>
#include <gtkmm/label.h>
#include <gtkmm/scrolledwindow.h>
#include "canvas/canvas.h"
#include "canvas/xml_ui.h"
#include "waves_button.h"
using namespace ArdourCanvas::XMLUI;
namespace WavesUI {
void create_ui (const XMLTree& layout, Gtk::Widget& root, std::map<std::string, Gtk::Widget*> &named_widgets);
void create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Widget& root, std::map<std::string, Gtk::Widget*> &named_widgets);
Gtk::Widget* create_widget (const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets);
Gtk::Widget* add_widget (Gtk::Box& parent, const XMLNode &definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets);
Gtk::Widget* add_widget (Gtk::ScrolledWindow& parent, const XMLNode &definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets);
Gtk::Widget* add_widget (Gtk::Layout& parent, const XMLNode &definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets);
Gtk::Widget* add_widget (Gtk::Widget& parent, const XMLNode &definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*> &named_widgets);
class WidgetMap : public std::map<std::string, Gtk::Widget*>
{
public:
Gtk::VBox& get_vbox (char* id);
Gtk::HBox& get_hbox (char* id);
Gtk::Layout& get_layout (char* id);
Gtk::Label& get_label (char* id);
Gtk::ComboBoxText& get_combo_box_text (char* id);
WavesButton& get_waves_button (char* id);
private:
Gtk::Widget* get_widget(char *id);
};
const XMLTree* load_layout (const std::string xml_file_name);
void create_ui (const XMLTree& layout, Gtk::Container& root, std::map<std::string, Gtk::Widget*>& named_widgets);
void create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root, std::map<std::string, Gtk::Widget*>& named_widgets);
Gtk::Widget* create_widget (const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets);
Gtk::Widget* add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets);
Gtk::Widget* add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets);
Gtk::Widget* add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets);
Gtk::Widget* add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles, std::map<std::string, Gtk::Widget*>& named_widgets);
void set_attributes (Gtk::Widget& widget, const XMLNode& definition, const XMLNodeMap& styles);
}

View file

@ -65,6 +65,7 @@ gtk2_ardour_sources = [
'control_point_dialog.cc',
'curvetest.cc',
'debug.cc',
'device_connection_conrol.cc',
'edit_note_dialog.cc',
'editing.cc',
'editor.cc',