lots more color work, closer and closer to being ready for ... being taken apart again
This commit is contained in:
parent
e1c6f3bf6c
commit
624a86c39d
|
@ -317,6 +317,9 @@ COLOR_ALIAS(RecEnableButtonFill,"record enable button: led active","color 85")
|
|||
COLOR_ALIAS(RecEnableButtonTextActive,"recorded waveform fill","color 13")
|
||||
COLOR_ALIAS(RecEnableButtonText,"recorded waveform outline","color 43")
|
||||
COLOR_ALIAS(RecordingRect,"recording rect","color 86")
|
||||
COLOR_ALIAS(RegionListAutomatic, "region list automatic", "color 53")
|
||||
COLOR_ALIAS(RegionListMissingSource, "region list missing source", "color 9")
|
||||
COLOR_ALIAS(RegionListWholeFile, "region list whole file", "color 1")
|
||||
COLOR_ALIAS(CoveredRegion,"region area covered by another region","color 87")
|
||||
COLOR_ALIAS(FrameBase,"region base","color 11")
|
||||
COLOR_ALIAS(RouteButtonFillActive,"route button: fill","color 25")
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
<Option name="colorDlight" value="0x00b3ffff"/>
|
||||
<Option name="colorDA" value="0x8000ffff"/>
|
||||
|
||||
<Option name="meterColor0" value="008800FF"/>
|
||||
<Option name="meterColor1" value="00AA00FF"/>
|
||||
<Option name="meterColor2" value="00FF00FF"/>
|
||||
<Option name="meterColor3" value="00FF00FF"/>
|
||||
<Option name="meterColor4" value="FFF000ff"/>
|
||||
<Option name="meterColor5" value="FFF000ff"/>
|
||||
<Option name="meterColor6" value="FF8800ff"/>
|
||||
<Option name="meterColor7" value="FF8800ff"/>
|
||||
<Option name="meterColor8" value="FF0000ff"/>
|
||||
<Option name="meterColor9" value="FF0000ff"/>
|
||||
<Option name="meterColor0" value="0x008800FF"/>
|
||||
<Option name="meterColor1" value="0x00AA00FF"/>
|
||||
<Option name="meterColor2" value="0x00FF00FF"/>
|
||||
<Option name="meterColor3" value="0x00FF00FF"/>
|
||||
<Option name="meterColor4" value="0xFFF000ff"/>
|
||||
<Option name="meterColor5" value="0xFFF000ff"/>
|
||||
<Option name="meterColor6" value="0xFF8800ff"/>
|
||||
<Option name="meterColor7" value="0xFF8800ff"/>
|
||||
<Option name="meterColor8" value="0xFF0000ff"/>
|
||||
<Option name="meterColor9" value="0xFF0000ff"/>
|
||||
|
||||
<Option name="small font" value="@FONT_SMALL@"/>
|
||||
<Option name="smaller font" value="@FONT_SMALLER@"/>
|
||||
|
@ -396,6 +396,9 @@
|
|||
<ColorAlias name="recorded waveform fill" alias="color 13"/>
|
||||
<ColorAlias name="recorded waveform outline" alias="color 43"/>
|
||||
<ColorAlias name="recording rect" alias="color 86"/>
|
||||
<ColorAlias name="region list automatic" alias="color 53"/>
|
||||
<ColorAlias name="region list missing source" alias="color 9"/>
|
||||
<ColorAlias name="region list whole file" alias="color 1"/>
|
||||
<ColorAlias name="region area covered by another region" alias="color 87"/>
|
||||
<ColorAlias name="region base" alias="color 11"/>
|
||||
<ColorAlias name="route button: fill" alias="color 25"/>
|
||||
|
|
|
@ -266,7 +266,7 @@ ThemeManager::basic_color_button_press_event (GdkEventButton* ev)
|
|||
case 1: /* color */
|
||||
if ((iter = basic_color_list->get_iter (path))) {
|
||||
|
||||
ColorVariable<ArdourCanvas::Color>* var = (*iter)[basic_color_columns.pVar];
|
||||
ColorVariable<ArdourCanvas::Color>* var = (*iter)[basic_color_columns.color_variable];
|
||||
if (!var) {
|
||||
/* parent row, do nothing */
|
||||
return false;
|
||||
|
@ -282,10 +282,8 @@ ThemeManager::basic_color_button_press_event (GdkEventButton* ev)
|
|||
color_dialog.get_colorsel()->set_previous_alpha ((guint16) (a * 65535.0));
|
||||
color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 65535.0));
|
||||
|
||||
ColorVariable<ArdourCanvas::Color>* ccvar = (*iter)[basic_color_columns.pVar];
|
||||
|
||||
color_dialog_connection.disconnect ();
|
||||
color_dialog_connection = color_dialog.signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::basic_color_response), ccvar));
|
||||
color_dialog_connection = color_dialog.signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::basic_color_response), var));
|
||||
color_dialog.present ();
|
||||
}
|
||||
}
|
||||
|
@ -415,64 +413,25 @@ ThemeManager::on_light_theme_button_toggled()
|
|||
void
|
||||
ThemeManager::setup_basic_color_display ()
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
||||
basic_color_list->clear();
|
||||
|
||||
for (std::map<std::string,ColorVariable<uint32_t> *>::iterator i = ARDOUR_UI::config()->configurable_colors.begin(); i != ARDOUR_UI::config()->configurable_colors.end(); i++) {
|
||||
|
||||
|
||||
ColorVariable<uint32_t>* var = i->second;
|
||||
|
||||
TreeModel::Children rows = basic_color_list->children();
|
||||
for (UIConfiguration::BaseColors::const_iterator i = ARDOUR_UI::config()->base_colors.begin(); i != ARDOUR_UI::config()->base_colors.end(); i++) {
|
||||
TreeModel::Row row;
|
||||
string::size_type colon;
|
||||
|
||||
if ((colon = var->name().find (':')) != string::npos) {
|
||||
row = *(basic_color_list->append());
|
||||
row[basic_color_columns.name] = i->second->name();
|
||||
row[basic_color_columns.color_variable] = i->second;
|
||||
|
||||
/* this is supposed to be a child node, so find the
|
||||
* parent
|
||||
*/
|
||||
ArdourCanvas::Color c = i->second->get();
|
||||
|
||||
string parent = var->name().substr (0, colon);
|
||||
TreeModel::iterator ri;
|
||||
/* Gdk colors don't support alpha */
|
||||
|
||||
for (ri = rows.begin(); ri != rows.end(); ++ri) {
|
||||
string s = (*ri)[basic_color_columns.name];
|
||||
if (s == parent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
double r, g, b, a;
|
||||
ArdourCanvas::color_to_rgba (c, r, g, b, a);
|
||||
Gdk::Color gcolor;
|
||||
gcolor.set_rgb_p (r, g, b);
|
||||
|
||||
if (ri == rows.end()) {
|
||||
/* not found, add the parent as new top level row */
|
||||
row = *(basic_color_list->append());
|
||||
row[basic_color_columns.name] = parent;
|
||||
row[basic_color_columns.pVar] = 0;
|
||||
|
||||
/* now add the child as a child of this one */
|
||||
|
||||
row = *(basic_color_list->insert (row->children().end()));
|
||||
row[basic_color_columns.name] = var->name().substr (colon+1);
|
||||
} else {
|
||||
row = *(basic_color_list->insert ((*ri)->children().end()));
|
||||
row[basic_color_columns.name] = var->name().substr (colon+1);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* add as a child */
|
||||
row = *(basic_color_list->append());
|
||||
row[basic_color_columns.name] = var->name();
|
||||
}
|
||||
|
||||
Gdk::Color col;
|
||||
uint32_t rgba = var->get();
|
||||
UINT_TO_RGBA (rgba, &r, &g, &b, &a);
|
||||
col.set_rgb_p (r / 255.0, g / 255.0, b / 255.0);
|
||||
|
||||
row[basic_color_columns.pVar] = var;
|
||||
row[basic_color_columns.rgba] = rgba;
|
||||
row[basic_color_columns.gdkcolor] = col;
|
||||
row[basic_color_columns.gdkcolor] = gcolor;
|
||||
}
|
||||
|
||||
UIConfiguration* uic (ARDOUR_UI::config());
|
||||
|
@ -753,22 +712,56 @@ ThemeManager::setup_aliases ()
|
|||
alias_list->clear ();
|
||||
|
||||
for (UIConfiguration::ColorAliases::iterator i = aliases.begin(); i != aliases.end(); ++i) {
|
||||
TreeModel::Children rows = alias_list->children();
|
||||
TreeModel::Row row;
|
||||
string::size_type colon;
|
||||
|
||||
if ((colon = i->first.find (':')) != string::npos) {
|
||||
|
||||
/* this is supposed to be a child node, so find the
|
||||
* parent
|
||||
*/
|
||||
|
||||
string parent = i->first.substr (0, colon);
|
||||
TreeModel::iterator ri;
|
||||
|
||||
for (ri = rows.begin(); ri != rows.end(); ++ri) {
|
||||
string s = (*ri)[alias_columns.name];
|
||||
if (s == parent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ri == rows.end()) {
|
||||
/* not found, add the parent as new top level row */
|
||||
row = *(alias_list->append());
|
||||
row[alias_columns.name] = parent;
|
||||
row[alias_columns.alias] = "";
|
||||
|
||||
/* now add the child as a child of this one */
|
||||
|
||||
row = *(alias_list->insert (row->children().end()));
|
||||
row[alias_columns.name] = i->first.substr (colon+1);
|
||||
} else {
|
||||
row = *(alias_list->insert ((*ri)->children().end()));
|
||||
row[alias_columns.name] = i->first.substr (colon+1);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* add as a child */
|
||||
row = *(alias_list->append());
|
||||
row[alias_columns.name] = i->first;
|
||||
}
|
||||
|
||||
row = *(alias_list->append());
|
||||
row[alias_columns.name] = i->first;
|
||||
row[alias_columns.alias] = i->second;
|
||||
|
||||
Color c = uic->color (i->second);
|
||||
|
||||
/* Gdk colors don't support alpha */
|
||||
|
||||
Gdk::Color col;
|
||||
double r, g, b, a;
|
||||
Color c (uic->color (i->second));
|
||||
color_to_rgba (c, r, g, b, a);
|
||||
Gdk::Color gcolor;
|
||||
gcolor.set_rgb_p (r, g, b);
|
||||
col.set_rgb_p (r, g, b);
|
||||
|
||||
row[alias_columns.color] = gcolor;
|
||||
row[alias_columns.color] = col;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,14 +71,12 @@ class ThemeManager : public ArdourWindow
|
|||
BasicColorDisplayModelColumns() {
|
||||
add (name);
|
||||
add (gdkcolor);
|
||||
add (pVar);
|
||||
add (rgba);
|
||||
add (color_variable);
|
||||
}
|
||||
|
||||
Gtk::TreeModelColumn<std::string> name;
|
||||
Gtk::TreeModelColumn<Gdk::Color> gdkcolor;
|
||||
Gtk::TreeModelColumn<ColorVariable<ArdourCanvas::Color> *> pVar;
|
||||
Gtk::TreeModelColumn<ArdourCanvas::Color> rgba;
|
||||
Gtk::TreeModelColumn<ColorVariable<ArdourCanvas::Color> *> color_variable;
|
||||
};
|
||||
|
||||
BasicColorDisplayModelColumns basic_color_columns;
|
||||
|
|
|
@ -88,7 +88,7 @@ UIConfiguration::UIConfiguration ()
|
|||
*/
|
||||
|
||||
#undef CANVAS_BASE_COLOR
|
||||
#define CANVAS_BASE_COLOR(var,name,color) configurable_colors.insert (make_pair (name,&var));
|
||||
#define CANVAS_BASE_COLOR(var,name,color) base_colors.insert (make_pair (name,&var));
|
||||
#include "base_colors.h"
|
||||
#undef CANVAS_BASE_COLOR
|
||||
|
||||
|
@ -133,7 +133,7 @@ UIConfiguration::colors_changed ()
|
|||
GTK RC file, which causes a reset of all styles and a redraw
|
||||
*/
|
||||
|
||||
parameter_changed ("ui-rc_file");
|
||||
parameter_changed ("ui-rc-file");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -182,7 +182,7 @@ UIConfiguration::color_as_relative_hsv (Color c)
|
|||
map<string,ColorVariable<Color>*>::iterator f;
|
||||
std::map<std::string,HSV> palette;
|
||||
|
||||
for (f = configurable_colors.begin(); f != configurable_colors.end(); ++f) {
|
||||
for (f = base_colors.begin(); f != base_colors.end(); ++f) {
|
||||
/* Do not include any specialized base colors in the palette
|
||||
we use to do comparisons
|
||||
*/
|
||||
|
@ -385,20 +385,25 @@ UIConfiguration::get_state ()
|
|||
root->add_child_nocopy (get_variables ("UI"));
|
||||
root->add_child_nocopy (get_variables ("Canvas"));
|
||||
|
||||
if (derived_modified) {
|
||||
|
||||
XMLNode* parent = new XMLNode (X_("RelativeColors"));
|
||||
for (RelativeColors::const_iterator i = relative_colors.begin(); i != relative_colors.end(); ++i) {
|
||||
XMLNode* node = new XMLNode (X_("RelativeColor"));
|
||||
node->add_property (X_("name"), i->first);
|
||||
node->add_property (X_("base"), i->second.base_color);
|
||||
node->add_property (X_("modifier"), i->second.modifier.to_string());
|
||||
parent->add_child_nocopy (*node);
|
||||
}
|
||||
root->add_child_nocopy (*parent);
|
||||
|
||||
if (aliases_modified) {
|
||||
XMLNode* parent = new XMLNode (X_("ColorAliases"));
|
||||
for (ColorAliases::const_iterator i = color_aliases.begin(); i != color_aliases.end(); ++i) {
|
||||
XMLNode* node = new XMLNode (X_("ColorAlias"));
|
||||
node->add_property (X_("name"), i->first);
|
||||
node->add_property (X_("alias"), i->second);
|
||||
parent->add_child_nocopy (*node);
|
||||
}
|
||||
root->add_child_nocopy (*parent);
|
||||
|
||||
parent = new XMLNode (X_("ColorAliases"));
|
||||
for (ColorAliases::const_iterator i = color_aliases.begin(); i != color_aliases.end(); ++i) {
|
||||
XMLNode* node = new XMLNode (X_("ColorAlias"));
|
||||
node->add_property (X_("name"), i->first);
|
||||
node->add_property (X_("alias"), i->second);
|
||||
parent->add_child_nocopy (*node);
|
||||
}
|
||||
root->add_child_nocopy (*parent);
|
||||
|
||||
if (_extra_xml) {
|
||||
root->add_child_copy (*_extra_xml);
|
||||
|
@ -453,7 +458,7 @@ UIConfiguration::set_state (const XMLNode& root, int /*version*/)
|
|||
XMLNode* relative = find_named_node (root, X_("RelativeColors"));
|
||||
|
||||
if (relative) {
|
||||
// load_relative_colors (*relative);
|
||||
load_relative_colors (*relative);
|
||||
}
|
||||
|
||||
|
||||
|
@ -489,44 +494,39 @@ UIConfiguration::load_color_aliases (XMLNode const & node)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void
|
||||
UIConfiguration::load_relative_colors (XMLNode const & node)
|
||||
{
|
||||
XMLNodeList const nlist = node.children();
|
||||
XMLNodeConstIterator niter;
|
||||
XMLProperty const *name;
|
||||
XMLProperty const *alias;
|
||||
XMLProperty const *base;
|
||||
XMLProperty const *modifier;
|
||||
|
||||
color_aliases.clear ();
|
||||
relative_colors.clear ();
|
||||
|
||||
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
||||
if ((*niter)->name() != X_("RelativeColor")) {
|
||||
continue;
|
||||
}
|
||||
name = (*niter)->property (X_("name"));
|
||||
alias = (*niter)->property (X_("alias"));
|
||||
base = (*niter)->property (X_("base"));
|
||||
modifier = (*niter)->property (X_("modifier"));
|
||||
|
||||
if (name && alias) {
|
||||
color_aliases.insert (make_pair (name->value(), alias->value()));
|
||||
if (name && base && modifier) {
|
||||
RelativeHSV rhsv (base->value(), HSV (modifier->value()));
|
||||
relative_colors.insert (make_pair (name->value(), rhsv));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
UIConfiguration::set_variables (const XMLNode& node)
|
||||
{
|
||||
#undef UI_CONFIG_VARIABLE
|
||||
#define UI_CONFIG_VARIABLE(Type,var,name,val) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
#define CANVAS_FONT_VARIABLE(var,name) \
|
||||
if (var.set_from_node (node)) { \
|
||||
ParameterChanged (name); \
|
||||
}
|
||||
#define UI_CONFIG_VARIABLE(Type,var,name,val) if (var.set_from_node (node)) { ParameterChanged (name); }
|
||||
#define CANVAS_FONT_VARIABLE(var,name) if (var.set_from_node (node)) { ParameterChanged (name); }
|
||||
#include "ui_config_vars.h"
|
||||
#include "canvas_vars.h"
|
||||
#undef UI_CONFIG_VARIABLE
|
||||
|
@ -535,8 +535,7 @@ UIConfiguration::set_variables (const XMLNode& node)
|
|||
/* Reset base colors */
|
||||
|
||||
#undef CANVAS_BASE_COLOR
|
||||
#define CANVAS_BASE_COLOR(var,name,val) \
|
||||
var.set_from_node (node);
|
||||
#define CANVAS_BASE_COLOR(var,name,val) var.set_from_node (node); /* we don't care about ParameterChanged here */
|
||||
#include "base_colors.h"
|
||||
#undef CANVAS_BASE_COLOR
|
||||
|
||||
|
@ -557,9 +556,9 @@ UIConfiguration::dirty () const
|
|||
ArdourCanvas::Color
|
||||
UIConfiguration::base_color_by_name (const std::string& name) const
|
||||
{
|
||||
map<std::string,ColorVariable<Color>* >::const_iterator i = configurable_colors.find (name);
|
||||
map<std::string,ColorVariable<Color>* >::const_iterator i = base_colors.find (name);
|
||||
|
||||
if (i != configurable_colors.end()) {
|
||||
if (i != base_colors.end()) {
|
||||
return i->second->get();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,6 @@ class UIConfiguration : public PBD::Stateful
|
|||
|
||||
static UIConfiguration* instance() { return _instance; }
|
||||
|
||||
std::map<std::string,ColorVariable<ArdourCanvas::Color> *> configurable_colors;
|
||||
|
||||
bool dirty () const;
|
||||
void set_dirty ();
|
||||
|
||||
|
@ -118,9 +116,11 @@ class UIConfiguration : public PBD::Stateful
|
|||
|
||||
typedef std::map<std::string,RelativeHSV> RelativeColors;
|
||||
typedef std::map<std::string,std::string> ColorAliases;
|
||||
typedef std::map<std::string,ColorVariable<ArdourCanvas::Color> *> BaseColors;
|
||||
|
||||
BaseColors base_colors;
|
||||
RelativeColors relative_colors;
|
||||
ColorAliases color_aliases;
|
||||
ColorAliases color_aliases;
|
||||
|
||||
void set_alias (std::string const & name, std::string const & alias);
|
||||
|
||||
|
@ -191,6 +191,7 @@ class UIConfiguration : public PBD::Stateful
|
|||
static UIConfiguration* _instance;
|
||||
|
||||
void load_color_aliases (XMLNode const &);
|
||||
void load_relative_colors (XMLNode const &);
|
||||
void reset_gtk_theme ();
|
||||
void colors_changed ();
|
||||
|
||||
|
|
|
@ -44,12 +44,14 @@ struct LIBCANVAS_API HSV
|
|||
HSV ();
|
||||
HSV (double h, double s, double v, double a = 1.0);
|
||||
HSV (Color);
|
||||
|
||||
HSV (const std::string&);
|
||||
|
||||
double h;
|
||||
double s;
|
||||
double v;
|
||||
double a;
|
||||
|
||||
std::string to_string() const;
|
||||
bool is_gray() const;
|
||||
|
||||
Color color() const { return hsva_to_color (h,s, v, a); }
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
#include <stdint.h>
|
||||
#include <cfloat>
|
||||
|
@ -236,6 +237,26 @@ HSV::HSV (Color c)
|
|||
color_to_hsva (c, h, s, v, a);
|
||||
}
|
||||
|
||||
HSV::HSV (const std::string& str)
|
||||
{
|
||||
stringstream ss (str);
|
||||
ss >> h;
|
||||
ss >> s;
|
||||
ss >> v;
|
||||
ss >> a;
|
||||
}
|
||||
|
||||
string
|
||||
HSV::to_string () const
|
||||
{
|
||||
stringstream ss;
|
||||
ss << h << ' ';
|
||||
ss << s << ' ';
|
||||
ss << v << ' ';
|
||||
ss << a;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool
|
||||
HSV::is_gray () const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue