2014-03-29 18:56:09 -05:00
|
|
|
/*
|
2014-05-19 16:30:55 -05:00
|
|
|
Copyright (C) 2014 Waves Audio Ltd.
|
2014-03-29 18:56:09 -05:00
|
|
|
|
|
|
|
|
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-01 06:06:16 -05:00
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
|
|
2014-03-29 18:56:09 -05:00
|
|
|
#include "waves_ui.h"
|
2014-05-01 06:06:16 -05:00
|
|
|
#include "pbd/file_utils.h"
|
2014-06-11 06:00:48 -05:00
|
|
|
#include "pbd/failed_constructor.h"
|
2014-05-01 06:06:16 -05:00
|
|
|
#include "ardour/filesystem_paths.h"
|
2014-05-15 08:25:23 -05:00
|
|
|
#include "utils.h"
|
2014-05-07 10:29:26 -05:00
|
|
|
|
|
|
|
|
#include "pbd/convert.h"
|
2014-05-01 06:06:16 -05:00
|
|
|
#include "dbg_msg.h"
|
2014-03-29 18:56:09 -05:00
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
using namespace PBD;
|
|
|
|
|
using namespace ARDOUR;
|
2014-03-29 18:56:09 -05:00
|
|
|
|
2014-06-11 06:00:48 -05:00
|
|
|
std::map<std::string, const XMLTree*> WavesUI::__xml_tree_cache;
|
|
|
|
|
|
2014-06-24 19:06:00 +03:00
|
|
|
WavesUI::WavesUI (const std::string& layout_script_file, Gtk::Container& root)
|
2014-06-11 06:00:48 -05:00
|
|
|
: _xml_tree (NULL)
|
2014-07-04 18:04:39 +03:00
|
|
|
, _scrip_file_name (layout_script_file)
|
|
|
|
|
, _root_container (root)
|
2014-06-11 06:00:48 -05:00
|
|
|
{
|
|
|
|
|
// To avoid a need of reading the same file many times:
|
|
|
|
|
std::map<std::string, const XMLTree*>::const_iterator it = __xml_tree_cache.find(layout_script_file);
|
|
|
|
|
if (it != __xml_tree_cache.end()) {
|
|
|
|
|
_xml_tree = (*it).second;
|
|
|
|
|
} else {
|
|
|
|
|
std::string layout_file;
|
|
|
|
|
Searchpath spath (ardour_data_search_path());
|
|
|
|
|
spath.add_subdirectory_to_paths("ui");
|
|
|
|
|
|
|
|
|
|
if (!find_file_in_search_path (spath, layout_script_file, layout_file)) {
|
|
|
|
|
dbg_msg("File not found: " + layout_script_file);
|
|
|
|
|
throw failed_constructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_xml_tree = new XMLTree (layout_file, false);
|
|
|
|
|
__xml_tree_cache[layout_script_file] = _xml_tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
create_ui(_xml_tree, root);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 18:56:09 -05:00
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles)
|
2014-03-29 18:56:09 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::Object* child = NULL;
|
2014-03-29 18:56:09 -05:00
|
|
|
std::string widget_type = definition.name();
|
2014-04-14 12:37:20 -05:00
|
|
|
std::string widget_id = xml_property (definition, "id", styles, "");
|
2014-03-29 18:56:09 -05:00
|
|
|
|
2014-04-14 12:37:20 -05:00
|
|
|
std::string text = xml_property (definition, "text", styles, "");
|
2014-03-29 18:56:09 -05:00
|
|
|
boost::replace_all(text, "\\n", "\n");
|
|
|
|
|
|
|
|
|
|
std::transform(widget_type.begin(), widget_type.end(), widget_type.begin(), ::toupper);
|
2014-05-01 06:06:16 -05:00
|
|
|
|
2014-03-29 18:56:09 -05:00
|
|
|
if (widget_type == "BUTTON") {
|
2014-05-21 06:02:59 -05:00
|
|
|
child = manage (new WavesButton(text));
|
2014-05-15 08:25:23 -05:00
|
|
|
} else if (widget_type == "ICONBUTTON") {
|
2014-05-21 06:02:59 -05:00
|
|
|
child = manage (new WavesIconButton);
|
2014-05-20 17:20:19 -05:00
|
|
|
} else if (widget_type == "ICON") {
|
|
|
|
|
std::string image_path;
|
|
|
|
|
Searchpath spath(ARDOUR::ardour_data_search_path());
|
|
|
|
|
|
|
|
|
|
spath.add_subdirectory_to_paths("icons");
|
|
|
|
|
|
|
|
|
|
if (find_file_in_search_path (spath,
|
|
|
|
|
xml_property (definition, "source", styles, ""),
|
|
|
|
|
image_path)) {
|
|
|
|
|
Gtk::Image& icon = *manage (new Gtk::Image(image_path));
|
|
|
|
|
child = &icon;
|
|
|
|
|
} else {
|
|
|
|
|
dbg_msg(xml_property (definition, "source", styles, "") + " NOT FOUND");
|
|
|
|
|
}
|
2014-03-29 18:56:09 -05:00
|
|
|
} else if (widget_type == "COMBOBOXTEXT") {
|
|
|
|
|
child = manage (new Gtk::ComboBoxText);
|
|
|
|
|
} else if (widget_type == "LABEL") {
|
2014-06-24 11:30:09 +03:00
|
|
|
child = manage (new Gtk::Label (text));
|
|
|
|
|
} else if (widget_type == "ENTRY") {
|
|
|
|
|
child = manage (new Gtk::Entry ());
|
2014-07-04 18:04:39 +03:00
|
|
|
} else if (widget_type == "FOCUSENTRY") {
|
|
|
|
|
child = manage (new Gtkmm2ext::FocusEntry ());
|
2014-06-26 10:54:31 +03:00
|
|
|
} else if (widget_type == "SPINBUTTON") {
|
|
|
|
|
child = manage (new Gtk::SpinButton ());
|
|
|
|
|
} else if (widget_type == "LAYOUT") {
|
2014-03-29 18:56:09 -05:00
|
|
|
child = manage (new Gtk::Layout);
|
2014-04-14 12:37:20 -05:00
|
|
|
} else if (widget_type == "CANVAS") {
|
|
|
|
|
std::map<std::string, ArdourCanvas::Item*> named_items;
|
2014-06-24 11:30:09 +03:00
|
|
|
child = manage (new ArdourCanvas::GtkCanvas (definition, styles, named_items));
|
2014-04-29 01:07:37 -05:00
|
|
|
} else if (widget_type == "SCROLLEDWINDOW") {
|
|
|
|
|
child = manage (new Gtk::ScrolledWindow);
|
|
|
|
|
} else if (widget_type == "VBOX") {
|
|
|
|
|
child = manage (new Gtk::VBox);
|
|
|
|
|
} else if (widget_type == "HBOX") {
|
|
|
|
|
child = manage (new Gtk::HBox);
|
2014-05-21 06:02:59 -05:00
|
|
|
} else if (widget_type == "EVENTBOX") {
|
|
|
|
|
child = manage (new Gtk::EventBox);
|
2014-05-27 15:53:33 -05:00
|
|
|
} else if (widget_type == "FADER") {
|
|
|
|
|
std::string face_image = xml_property (definition, "facesource", styles, "");
|
|
|
|
|
if (face_image.empty()) {
|
|
|
|
|
dbg_msg("Fader's facesource NOT SPECIFIED!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
2014-07-10 00:34:23 +03:00
|
|
|
|
|
|
|
|
std::string underlay_image = xml_property (definition, "underlaysource", styles, "");
|
|
|
|
|
std::string active_face_image = xml_property (definition, "activefacesource", styles, "");
|
|
|
|
|
|
2014-05-27 15:53:33 -05:00
|
|
|
std::string handle_image = xml_property (definition, "handlesource", styles, "");
|
|
|
|
|
if (handle_image.empty()) {
|
|
|
|
|
dbg_msg("Fader's handlesource NOT SPECIFIED!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
2014-05-28 08:49:09 -05:00
|
|
|
std::string active_handle_image = xml_property (definition, "activehandlesource", styles, handle_image);
|
|
|
|
|
if (handle_image.empty()) {
|
|
|
|
|
dbg_msg("Fader's handlesource NOT SPECIFIED!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
2014-05-27 15:53:33 -05:00
|
|
|
std::string adjustment_id = xml_property (definition, "adjustment", styles, "");
|
|
|
|
|
if (adjustment_id.empty()) {
|
|
|
|
|
dbg_msg("Fader's adjustment_id NOT SPECIFIED!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
2014-05-28 08:49:09 -05:00
|
|
|
int minposx = xml_property (definition, "minposx", styles, -1);
|
|
|
|
|
int minposy = xml_property (definition, "minposy", styles, -1);
|
|
|
|
|
int maxposx = xml_property (definition, "maxposx", styles, minposx);
|
|
|
|
|
int maxposy = xml_property (definition, "maxposy", styles, minposy);
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Adjustment& adjustment = get_adjustment(adjustment_id.c_str());
|
2014-07-10 00:34:23 +03:00
|
|
|
child = manage (new Gtkmm2ext::Fader(adjustment,
|
|
|
|
|
face_image,
|
|
|
|
|
active_face_image,
|
|
|
|
|
underlay_image,
|
|
|
|
|
handle_image,
|
|
|
|
|
active_handle_image,
|
|
|
|
|
minposx,
|
|
|
|
|
minposy,
|
|
|
|
|
maxposx,
|
|
|
|
|
maxposy));
|
2014-05-27 15:53:33 -05:00
|
|
|
} else if (widget_type == "ADJUSTMENT") {
|
|
|
|
|
double min_value = xml_property (definition, "minvalue", styles, 0.0);
|
|
|
|
|
double max_value = xml_property (definition, "maxvalue", styles, 100.0);
|
|
|
|
|
double initial_value = xml_property (definition, "initialvalue", styles, min_value);
|
|
|
|
|
double step = xml_property (definition, "step", styles, (max_value-min_value)/100.0);
|
|
|
|
|
double page_increment = xml_property (definition, "pageincrement", styles, (max_value-min_value)/10);
|
|
|
|
|
|
|
|
|
|
child = manage (new Gtk::Adjustment (initial_value,
|
|
|
|
|
min_value,
|
|
|
|
|
max_value,
|
|
|
|
|
step,
|
|
|
|
|
page_increment));
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (child != NULL) {
|
2014-05-21 06:02:59 -05:00
|
|
|
if (!widget_id.empty()) {
|
2014-06-11 06:00:48 -05:00
|
|
|
(*this)[widget_id] = child;
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
2014-05-27 15:53:33 -05:00
|
|
|
if (dynamic_cast<Gtk::Widget*>(child)) {
|
|
|
|
|
set_attributes(*dynamic_cast<Gtk::Widget*>(child), definition, styles);
|
|
|
|
|
}
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
2014-05-27 15:53:33 -05:00
|
|
|
return dynamic_cast<Gtk::Widget*>(child);
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-03-29 18:56:09 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Widget* child = create_widget(definition, styles);
|
2014-03-29 18:56:09 -05:00
|
|
|
|
|
|
|
|
if (child != NULL)
|
|
|
|
|
{
|
2014-05-20 12:39:45 -05:00
|
|
|
std::string property = xml_property (definition, "box.pack", styles, "start");
|
|
|
|
|
bool expand = xml_property (definition, "box.expand", styles, false);
|
|
|
|
|
bool fill = xml_property (definition, "box.fill", styles, false);
|
|
|
|
|
uint32_t padding = xml_property (definition, "box.padding", styles, 0);
|
|
|
|
|
|
|
|
|
|
if (property == "start") {
|
|
|
|
|
parent.pack_start(*child, expand, fill, padding);
|
|
|
|
|
} else {
|
|
|
|
|
parent.pack_end(*child, expand, fill, padding);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-04-29 01:07:37 -05:00
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-04-29 01:07:37 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Widget* child = create_widget(definition, styles);
|
2014-04-29 01:07:37 -05:00
|
|
|
|
|
|
|
|
if (child != NULL)
|
|
|
|
|
{
|
|
|
|
|
parent.add(*child);
|
|
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-05-19 16:30:55 -05:00
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-05-19 16:30:55 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Widget* child = create_widget(definition, styles);
|
2014-05-19 16:30:55 -05:00
|
|
|
|
|
|
|
|
if (child != NULL)
|
|
|
|
|
{
|
|
|
|
|
parent.add(*child);
|
|
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-05-21 06:02:59 -05:00
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-05-21 06:02:59 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Widget* child = create_widget(definition, styles);
|
2014-05-21 06:02:59 -05:00
|
|
|
|
|
|
|
|
if (child != NULL)
|
|
|
|
|
{
|
|
|
|
|
parent.add(*child);
|
|
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-29 18:56:09 -05:00
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-03-29 18:56:09 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
Gtk::Widget* child = create_widget(definition, styles);
|
2014-03-29 18:56:09 -05:00
|
|
|
|
|
|
|
|
if (child != NULL)
|
|
|
|
|
{
|
|
|
|
|
parent.put (*child,
|
2014-04-14 12:37:20 -05:00
|
|
|
xml_property (definition, "x", styles, 0),
|
|
|
|
|
xml_property (definition, "y", styles, 0));
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Widget*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles)
|
2014-03-29 18:56:09 -05:00
|
|
|
{
|
|
|
|
|
Gtk::Widget* child = NULL;
|
|
|
|
|
if(dynamic_cast<Gtk::Layout*> (&parent)) {
|
2014-06-11 06:00:48 -05:00
|
|
|
child = WavesUI::add_widget (*dynamic_cast<Gtk::Layout*> (&parent), definition, styles);
|
2014-04-29 01:07:37 -05:00
|
|
|
} else if(dynamic_cast<Gtk::Box*> (&parent)) {
|
2014-06-11 06:00:48 -05:00
|
|
|
child = WavesUI::add_widget (*dynamic_cast<Gtk::Box*> (&parent), definition, styles);
|
2014-04-29 01:07:37 -05:00
|
|
|
} else if(dynamic_cast<Gtk::ScrolledWindow*> (&parent)) {
|
2014-06-11 06:00:48 -05:00
|
|
|
child = WavesUI::add_widget (*dynamic_cast<Gtk::ScrolledWindow*> (&parent), definition, styles);
|
2014-05-19 17:28:29 -05:00
|
|
|
} else if(dynamic_cast<Gtk::Window*> (&parent)) {
|
2014-06-11 06:00:48 -05:00
|
|
|
child = WavesUI::add_widget (*dynamic_cast<Gtk::Window*> (&parent), definition, styles);
|
2014-05-21 06:02:59 -05:00
|
|
|
} else if(dynamic_cast<Gtk::EventBox*> (&parent)) {
|
2014-06-11 06:00:48 -05:00
|
|
|
child = WavesUI::add_widget (*dynamic_cast<Gtk::EventBox*> (&parent), definition, styles);
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
Gtk::Container* container = dynamic_cast<Gtk::Container*>(child);
|
|
|
|
|
|
|
|
|
|
if (container != NULL) {
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::create_ui (definition.children(), styles, *container);
|
2014-05-07 10:29:26 -05:00
|
|
|
Gtk::ScrolledWindow* sw = dynamic_cast<Gtk::ScrolledWindow*>(child);
|
|
|
|
|
if (sw != NULL) {
|
|
|
|
|
Gtk::Viewport* vp = (Gtk::Viewport*)sw->get_child();
|
|
|
|
|
if (vp != NULL) {
|
|
|
|
|
set_attributes(*(Gtk::Widget*)vp, definition, styles);
|
|
|
|
|
vp->set_shadow_type(Gtk::SHADOW_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 16:03:54 -05:00
|
|
|
void
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root)
|
2014-03-29 18:56:09 -05:00
|
|
|
{
|
|
|
|
|
for (XMLNodeList::const_iterator i = definition.begin(); i != definition.end(); ++i) {
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::add_widget (root, **i, styles);
|
2014-03-29 18:56:09 -05:00
|
|
|
}
|
2014-04-01 16:03:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::create_ui (const XMLTree& layout, Gtk::Container& root)
|
2014-04-01 16:03:54 -05:00
|
|
|
{
|
|
|
|
|
XMLNodeMap styles;
|
2014-04-14 12:37:20 -05:00
|
|
|
get_styles(layout, styles);
|
2014-04-01 16:03:54 -05:00
|
|
|
const XMLNodeList& definition = layout.root()->children();
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::create_ui (definition, styles, root);
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const XMLTree*
|
2014-06-24 19:06:00 +03:00
|
|
|
WavesUI::load_layout (const std::string& xml_file_name)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-06-11 06:00:48 -05:00
|
|
|
std::map<std::string, const XMLTree*>::const_iterator it = __xml_tree_cache.find(xml_file_name);
|
|
|
|
|
if (it != __xml_tree_cache.end()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
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);
|
2014-06-11 06:00:48 -05:00
|
|
|
__xml_tree_cache[xml_file_name] = tree;
|
2014-05-01 06:06:16 -05:00
|
|
|
|
|
|
|
|
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, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-21 06:02:59 -05:00
|
|
|
widget.unset_bg(Gtk::STATE_NORMAL);
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_bg(Gtk::STATE_NORMAL, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "bgdisabled", styles, property);
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-21 06:02:59 -05:00
|
|
|
widget.unset_bg(Gtk::STATE_INSENSITIVE);
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_bg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "bgactive", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-21 06:02:59 -05:00
|
|
|
widget.unset_bg(Gtk::STATE_ACTIVE);
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_bg(Gtk::STATE_ACTIVE, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "bghover", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-21 06:02:59 -05:00
|
|
|
widget.unset_bg(Gtk::STATE_PRELIGHT);
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_bg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "fgnormal", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_fg(Gtk::STATE_NORMAL, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "fgdisabled", styles, property);
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_fg(Gtk::STATE_INSENSITIVE, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "fgactive", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_fg(Gtk::STATE_ACTIVE, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "fghover", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_fg(Gtk::STATE_PRELIGHT, Gdk::Color(property));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property = xml_property (definition, "font", styles, "");
|
2014-05-15 08:25:23 -05:00
|
|
|
if (!property.empty ()) {
|
2014-05-01 06:06:16 -05:00
|
|
|
widget.modify_font(Pango::FontDescription(property));
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-04 18:04:39 +03:00
|
|
|
widget.set_visible (xml_property (definition, "visible", styles, true));
|
|
|
|
|
widget.set_no_show_all (xml_property (definition, "noshowall", styles, false));
|
2014-05-15 08:25:23 -05:00
|
|
|
|
2014-05-20 12:39:45 -05:00
|
|
|
property = xml_property (definition, "tooltip", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
|
|
|
|
widget.set_tooltip_text (property);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 11:30:09 +03:00
|
|
|
Gtk::Label* label = dynamic_cast<Gtk::Label*> (&widget);
|
|
|
|
|
if (label) {
|
|
|
|
|
property = xml_property (definition, "justify", styles, "left");
|
2014-07-16 11:39:57 +03:00
|
|
|
std::transform(property.begin(), property.end(), property.begin(), ::tolower);
|
2014-06-24 11:30:09 +03:00
|
|
|
Gtk::Justification justification = Gtk::JUSTIFY_LEFT;
|
|
|
|
|
if (property == "left") {
|
|
|
|
|
justification = Gtk::JUSTIFY_LEFT;
|
|
|
|
|
} else if (property == "right") {
|
|
|
|
|
justification = Gtk::JUSTIFY_RIGHT;
|
|
|
|
|
} else if (property == "center") {
|
|
|
|
|
justification = Gtk::JUSTIFY_CENTER;
|
|
|
|
|
} else if (property == "fill") {
|
|
|
|
|
justification = Gtk::JUSTIFY_FILL;
|
|
|
|
|
} else {
|
|
|
|
|
dbg_msg ("Invalid justification for Gtk::Label !");
|
|
|
|
|
}
|
|
|
|
|
label->set_justify (justification);
|
2014-07-16 11:39:57 +03:00
|
|
|
|
|
|
|
|
property = xml_property (definition, "ellipsize", styles, "none");
|
|
|
|
|
std::transform(property.begin(), property.end(), property.begin(), ::tolower);
|
|
|
|
|
Pango::EllipsizeMode ellipsize_mode = Pango::ELLIPSIZE_NONE;
|
|
|
|
|
if (property == "none") {
|
|
|
|
|
ellipsize_mode = Pango::ELLIPSIZE_NONE;
|
|
|
|
|
} else if (property == "start") {
|
|
|
|
|
ellipsize_mode = Pango::ELLIPSIZE_START;
|
|
|
|
|
} else if (property == "middle") {
|
|
|
|
|
ellipsize_mode = Pango::ELLIPSIZE_MIDDLE;
|
|
|
|
|
} else if (property == "end") {
|
|
|
|
|
ellipsize_mode = Pango::ELLIPSIZE_END;
|
|
|
|
|
} else {
|
|
|
|
|
dbg_msg ("Invalid ellipsize mode for Gtk::Label !");
|
|
|
|
|
}
|
|
|
|
|
label->set_ellipsize (ellipsize_mode);
|
2014-06-24 11:30:09 +03:00
|
|
|
}
|
|
|
|
|
|
2014-05-15 08:25:23 -05:00
|
|
|
Gtk::Box* box = dynamic_cast<Gtk::Box*> (&widget);
|
2014-05-21 06:02:59 -05:00
|
|
|
if (box) {
|
2014-05-15 08:25:23 -05:00
|
|
|
box->set_spacing(xml_property (definition, "spacing", styles, 0));
|
|
|
|
|
}
|
2014-05-21 06:02:59 -05:00
|
|
|
|
|
|
|
|
Gtk::Container* container = dynamic_cast<Gtk::Container*> (&widget);
|
|
|
|
|
if (container) {
|
|
|
|
|
container->set_border_width (xml_property (definition, "borderwidth", styles, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WavesButton* button = dynamic_cast<WavesButton*> (&widget);
|
|
|
|
|
if (button) {
|
|
|
|
|
button->set_border_width (xml_property (definition, "borderwidth", styles, "0").c_str());
|
|
|
|
|
button->set_border_color (xml_property (definition, "bordercolor", styles, "#000000").c_str());
|
|
|
|
|
button->set_active (xml_property (definition, "active", styles, false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WavesIconButton* iconbutton = dynamic_cast<WavesIconButton*> (&widget);
|
|
|
|
|
if (iconbutton) {
|
|
|
|
|
property = xml_property (definition, "normalicon", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
2014-07-08 12:12:12 +03:00
|
|
|
iconbutton->set_normal_image (get_icon (property.c_str ()));
|
2014-05-21 06:02:59 -05:00
|
|
|
}
|
|
|
|
|
property = xml_property (definition, "activeicon", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
2014-07-08 12:12:12 +03:00
|
|
|
iconbutton->set_active_image (get_icon (property.c_str ()));
|
2014-05-21 06:02:59 -05:00
|
|
|
}
|
|
|
|
|
property = xml_property (definition, "prelighticon", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
2014-07-08 12:12:12 +03:00
|
|
|
iconbutton->set_prelight_image (get_icon (property.c_str ()));
|
2014-05-21 06:02:59 -05:00
|
|
|
}
|
|
|
|
|
property = xml_property (definition, "inactiveicon", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
2014-07-08 12:12:12 +03:00
|
|
|
iconbutton->set_inactive_image (get_icon (property.c_str ()));
|
|
|
|
|
}
|
|
|
|
|
property = xml_property (definition, "implicitactiveicon", styles, "");
|
|
|
|
|
if (!property.empty ()) {
|
|
|
|
|
iconbutton->set_implicit_active_image (get_icon (property.c_str ()));
|
2014-05-21 06:02:59 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gtk::ScrolledWindow* scrolled_window = dynamic_cast<Gtk::ScrolledWindow*> (&widget);
|
|
|
|
|
|
|
|
|
|
if (scrolled_window) {
|
|
|
|
|
Gtk::PolicyType hscrollbar_policy = Gtk::POLICY_AUTOMATIC;
|
|
|
|
|
Gtk::PolicyType vscrollbar_policy = Gtk::POLICY_AUTOMATIC;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
scrolled_window->set_policy(hscrollbar_policy, vscrollbar_policy);
|
|
|
|
|
}
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::Object*
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_object(const char *id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::Object* object = NULL;
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::iterator it = find(id);
|
2014-05-01 06:06:16 -05:00
|
|
|
if(it != end())
|
2014-05-27 15:53:33 -05:00
|
|
|
object = it->second;
|
2014-05-01 06:06:16 -05:00
|
|
|
|
2014-05-27 15:53:33 -05:00
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gtk::Adjustment&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_adjustment(const char* id)
|
2014-05-27 15:53:33 -05:00
|
|
|
{
|
|
|
|
|
Gtk::Adjustment* child = dynamic_cast<Gtk::Adjustment*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Adjustment ") + id + " not found in " + _scrip_file_name + "!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gtk::Container&
|
|
|
|
|
WavesUI::get_container (const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtk::Container* child = dynamic_cast<Gtk::Container*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
|
|
|
|
dbg_msg (std::string("Gtk::Container ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-27 15:53:33 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
2014-05-01 06:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-07-04 18:04:39 +03:00
|
|
|
|
2014-06-26 17:40:20 +03:00
|
|
|
Gtk::EventBox&
|
|
|
|
|
WavesUI::get_event_box (const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtk::EventBox* child = dynamic_cast<Gtk::EventBox*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::EventBox ") + id + " not found in " + _scrip_file_name + "!");
|
2014-06-26 17:40:20 +03:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 19:06:00 +03:00
|
|
|
|
|
|
|
|
Gtk::Box&
|
|
|
|
|
WavesUI::get_box (const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtk::Box* child = dynamic_cast<Gtk::Box*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::Box ") + id + " not found in " + _scrip_file_name + "!");
|
2014-06-24 19:06:00 +03:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
Gtk::VBox&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_v_box (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::VBox* child = dynamic_cast<Gtk::VBox*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::VBox ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::HBox&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_h_box (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::HBox* child = dynamic_cast<Gtk::HBox*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::HBox ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Layout&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_layout (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::Layout* child = dynamic_cast<Gtk::Layout*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::Layout ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Label&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_label (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::Label* child = dynamic_cast<Gtk::Label*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::Label ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::ComboBoxText&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_combo_box_text (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtk::ComboBoxText* child = dynamic_cast<Gtk::ComboBoxText*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::ComboBoxText ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-24 19:06:00 +03:00
|
|
|
Gtk::Entry&
|
|
|
|
|
WavesUI::get_entry(const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtk::Entry* child = dynamic_cast<Gtk::Entry*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::Entry ") + id + " not found in " + _scrip_file_name + "!");
|
|
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gtkmm2ext::FocusEntry&
|
|
|
|
|
WavesUI::get_focus_entry(const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtkmm2ext::FocusEntry* child = dynamic_cast<Gtkmm2ext::FocusEntry*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
|
|
|
|
dbg_msg (std::string("Gtkmm2ext::FocusEntry ") + id + " not found in " + _scrip_file_name + "!");
|
2014-06-24 19:06:00 +03:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 10:54:31 +03:00
|
|
|
Gtk::SpinButton&
|
|
|
|
|
WavesUI::get_spin_button(const char* id)
|
|
|
|
|
{
|
|
|
|
|
Gtk::SpinButton* child = dynamic_cast<Gtk::SpinButton*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtk::SpinButton ") + id + " not found in " + _scrip_file_name + "!");
|
2014-06-26 10:54:31 +03:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 06:06:16 -05:00
|
|
|
WavesButton&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_waves_button (const char* id)
|
2014-05-27 15:53:33 -05:00
|
|
|
{
|
|
|
|
|
WavesButton* child = dynamic_cast<WavesButton*> (get_object(id));
|
|
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("WavesButton ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-27 15:53:33 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gtkmm2ext::Fader&
|
2014-06-11 06:00:48 -05:00
|
|
|
WavesUI::get_fader (const char* id)
|
2014-05-01 06:06:16 -05:00
|
|
|
{
|
2014-05-27 15:53:33 -05:00
|
|
|
Gtkmm2ext::Fader* child = dynamic_cast<Gtkmm2ext::Fader*> (get_object(id));
|
2014-05-01 06:06:16 -05:00
|
|
|
if (child == NULL ) {
|
2014-07-04 18:04:39 +03:00
|
|
|
dbg_msg (std::string("Gtkmm2ext::Fader ") + id + " not found in " + _scrip_file_name + "!");
|
2014-05-01 06:06:16 -05:00
|
|
|
throw std::exception();
|
|
|
|
|
}
|
|
|
|
|
return *child;
|
|
|
|
|
}
|