13
0

rename UIConfigVariable as ColorVariable since that is really it should be used for; use ARDOUR::ConfigVariable for everything else in UI config

This commit is contained in:
Paul Davis 2014-06-13 10:54:12 -04:00
parent f2404a522d
commit a50569e787
3 changed files with 31 additions and 14 deletions

View File

@ -197,7 +197,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
int cellx;
int celly;
UIConfigVariable<uint32_t> *ccvar;
ColorVariable<uint32_t> *ccvar;
if (!color_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
return false;
@ -211,7 +211,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
case 1: /* color */
if ((iter = color_list->get_iter (path))) {
UIConfigVariable<uint32_t>* var = (*iter)[columns.pVar];
ColorVariable<uint32_t>* var = (*iter)[columns.pVar];
if (!var) {
/* parent row, do nothing */
return false;
@ -392,10 +392,10 @@ ThemeManager::setup_theme ()
color_list->clear();
for (std::map<std::string,UIConfigVariable<uint32_t> *>::iterator i = ARDOUR_UI::config()->canvas_colors.begin(); i != ARDOUR_UI::config()->canvas_colors.end(); i++) {
for (std::map<std::string,ColorVariable<uint32_t> *>::iterator i = ARDOUR_UI::config()->canvas_colors.begin(); i != ARDOUR_UI::config()->canvas_colors.end(); i++) {
UIConfigVariable<uint32_t>* var = i->second;
ColorVariable<uint32_t>* var = i->second;
TreeModel::Children rows = color_list->children();
TreeModel::Row row;

View File

@ -45,13 +45,16 @@ UIConfiguration::UIConfiguration ()
#undef UI_CONFIG_VARIABLE
#undef CANVAS_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,val) var (name,val),
#define CANVAS_VARIABLE(var,name) var (name),
#define CANVAS_VARIABLE(var,val) var (val),
#define CANVAS_STRING_VARIABLE(var,val) var (val),
#include "ui_config_vars.h"
#include "canvas_vars.h"
#undef UI_CONFIG_VARIABLE
#undef CANVAS_VARIABLE
#undef CANVAS_STRING_VARIABLE
_dirty (false)
{
std::cerr << "Ruler FOnt in constructor " << canvasvar_RulerFont.get() << "\n";
load_state();
}
@ -215,10 +218,12 @@ UIConfiguration::get_variables (std::string which_node)
#undef CANVAS_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,Name,value) if (node->name() == "UI") { var.add_to_node (*node); }
#define CANVAS_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
#define CANVAS_STRING_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
#include "ui_config_vars.h"
#include "canvas_vars.h"
#undef UI_CONFIG_VARIABLE
#undef CANVAS_VARIABLE
#undef CANVAS_STRING_VARIABLE
return *node;
}
@ -262,25 +267,32 @@ UIConfiguration::set_variables (const XMLNode& node)
if (var.set_from_node (node)) { \
ParameterChanged (name); \
}
#define CANVAS_STRING_VARIABLE(var,name) \
if (var.set_from_node (node)) { \
ParameterChanged (name); \
}
#include "ui_config_vars.h"
#include "canvas_vars.h"
#undef UI_CONFIG_VARIABLE
#undef CANVAS_VARIABLE
#undef CANVAS_STRING_VARIABLE
}
void
UIConfiguration::pack_canvasvars ()
{
#undef CANVAS_VARIABLE
#define CANVAS_VARIABLE(var,name) canvas_colors.insert (std::pair<std::string,UIConfigVariable<uint32_t>* >(name,&var));
#define CANVAS_VARIABLE(var,name) canvas_colors.insert (std::pair<std::string,ColorVariable<uint32_t>* >(name,&var));
#define CANVAS_STRING_VARIABLE(var,name)
#include "canvas_vars.h"
#undef CANVAS_VARIABLE
#undef CANVAS_STRING_VARIABLE
}
uint32_t
UIConfiguration::color_by_name (const std::string& name)
{
map<std::string,UIConfigVariable<uint32_t>* >::iterator i = canvas_colors.find (name);
map<std::string,ColorVariable<uint32_t>* >::iterator i = canvas_colors.find (name);
if (i != canvas_colors.end()) {
return i->second->get();

View File

@ -28,12 +28,17 @@
#include "pbd/xml++.h"
#include "ardour/configuration_variable.h"
/* This is very similar to ARDOUR::ConfigVariable but expects numeric values to
* be in hexadecimal. This is because it is intended for use with color
* specifications which are easier to scan for issues in "rrggbbaa" format than
* as decimals.
*/
template<class T>
class UIConfigVariable : public ARDOUR::ConfigVariableBase
class ColorVariable : public ARDOUR::ConfigVariableBase
{
public:
UIConfigVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
UIConfigVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
ColorVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
ColorVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
bool set (T val) {
if (val == value) {
@ -74,7 +79,7 @@ class UIConfiguration : public PBD::Stateful
UIConfiguration();
~UIConfiguration();
std::map<std::string,UIConfigVariable<uint32_t> *> canvas_colors;
std::map<std::string,ColorVariable<uint32_t> *> canvas_colors;
bool dirty () const;
void set_dirty ();
@ -117,13 +122,13 @@ class UIConfiguration : public PBD::Stateful
/* declare variables */
#undef UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,value) UIConfigVariable<Type> var;
#define UI_CONFIG_VARIABLE(Type,var,name,value) ARDOUR::ConfigVariable<Type> var;
#include "ui_config_vars.h"
#undef UI_CONFIG_VARIABLE
#undef CANVAS_VARIABLE
#define CANVAS_VARIABLE(var,name) UIConfigVariable<uint32_t> var;
#define CANVAS_STRING_VARIABLE(var,name) UIConfigVariable<std::string> var;
#define CANVAS_VARIABLE(var,name) ColorVariable<uint32_t> var;
#define CANVAS_STRING_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
#include "canvas_vars.h"
#undef CANVAS_VARIABLE
#undef CANVAS_STRING_VARIABLE