summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-12-05 09:01:49 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-12-05 09:01:55 -0500
commit2449fc9681ba62eda3f3a42904a3691fe022954d (patch)
tree4a407a7afba6be2e14c64d446c7556b0c158313e
parent207fd04587e7d354c9b98453b01cc0825b2ba556 (diff)
several steps closer to more sane color system
-rw-r--r--gtk2_ardour/ardour_ui.h3
-rw-r--r--gtk2_ardour/theme_manager.cc444
-rw-r--r--gtk2_ardour/theme_manager.h57
-rw-r--r--gtk2_ardour/ui_config.cc599
-rw-r--r--gtk2_ardour/ui_config.h58
5 files changed, 509 insertions, 652 deletions
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 3a6f1b501e..f6585aa388 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -90,7 +90,7 @@
#include "route_params_ui.h"
#include "session_option_editor.h"
#include "speaker_dialog.h"
-#include "theme_manager.h"
+
class VideoTimeLine;
class ArdourKeyboard;
@@ -106,6 +106,7 @@ class SessionDialog;
class SessionOptionEditor;
class ShuttleControl;
class Splash;
+class ThemeManager;
class TimeInfoBox;
class MidiTracer;
class NSM_Client;
diff --git a/gtk2_ardour/theme_manager.cc b/gtk2_ardour/theme_manager.cc
index 9fdf7b24d2..04b6761b5c 100644
--- a/gtk2_ardour/theme_manager.cc
+++ b/gtk2_ardour/theme_manager.cc
@@ -36,6 +36,9 @@
#include "ardour/filesystem_paths.h"
+#include "canvas/container.h"
+#include "canvas/rectangle.h"
+#include "canvas/scroll_group.h"
#include "canvas/wave_view.h"
#include "ardour_button.h"
@@ -73,19 +76,24 @@ ThemeManager::ThemeManager()
, timeline_item_gradient_depth_label (_("Timeline item gradient depth"))
, all_dialogs (_("All floating windows are dialogs"))
, icon_set_label (_("Icon Set"))
+ , base_color_viewport (*base_color_scroller.get_hadjustment(), *base_color_scroller.get_vadjustment())
+ , base_color_group (0)
+ , palette_window (0)
{
set_title (_("Theme Manager"));
+ /* Basic color list */
+
color_list = TreeStore::create (columns);
color_display.set_model (color_list);
color_display.append_column (_("Object"), columns.name);
-
+
Gtkmm2ext::CellRendererColorSelector* color_renderer = manage (new Gtkmm2ext::CellRendererColorSelector);
TreeViewColumn* color_column = manage (new TreeViewColumn (_("Color"), *color_renderer));
color_column->add_attribute (color_renderer->property_color(), columns.gdkcolor);
color_display.append_column (*color_column);
-
+
color_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
color_display.get_column (0)->set_expand (true);
color_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
@@ -94,9 +102,37 @@ ThemeManager::ThemeManager()
color_display.get_selection()->set_mode (SELECTION_NONE);
color_display.set_headers_visible (true);
+ color_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::button_press_event), false);
+
scroller.add (color_display);
scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
+ /* Now the alias list */
+
+ alias_list = TreeStore::create (alias_columns);
+ alias_display.set_model (alias_list);
+ alias_display.append_column (_("Object"), columns.name);
+
+ color_renderer = manage (new Gtkmm2ext::CellRendererColorSelector);
+ color_column = manage (new TreeViewColumn (_("Color"), *color_renderer));
+ color_column->add_attribute (color_renderer->property_color(), alias_columns.color);
+
+ alias_display.append_column (*color_column);
+
+ alias_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
+ alias_display.get_column (0)->set_expand (true);
+ alias_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
+ alias_display.get_column (1)->set_expand (false);
+ alias_display.set_reorderable (false);
+ alias_display.get_selection()->set_mode (SELECTION_NONE);
+ alias_display.set_headers_visible (true);
+
+ alias_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::alias_button_press_event), false);
+
+ alias_scroller.add (alias_display);
+
+ /* various buttons */
+
RadioButton::Group group = dark_button.get_group();
light_button.set_group(group);
theme_selection_hbox.set_homogeneous(false);
@@ -143,7 +179,14 @@ ThemeManager::ThemeManager()
hbox->pack_start (timeline_item_gradient_depth_label, false, false);
vbox->pack_start (*hbox, PACK_SHRINK);
- vbox->pack_start (scroller);
+ base_color_viewport.signal_size_allocate().connect (sigc::mem_fun (*this, &ThemeManager::base_color_viewport_allocated));
+ base_color_scroller.add (base_color_viewport);
+
+ notebook.append_page (scroller, _("Palette"));
+ notebook.append_page (base_color_scroller, _("Base Colors"));
+ notebook.append_page (alias_scroller, _("Items"));
+
+ vbox->pack_start (notebook);
vbox->show_all ();
@@ -152,11 +195,9 @@ ThemeManager::ThemeManager()
waveform_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
timeline_item_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
- color_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::button_press_event), false);
-
color_dialog.get_colorsel()->set_has_opacity_control (true);
color_dialog.get_colorsel()->set_has_palette (true);
-
+
flat_buttons.set_active (ARDOUR_UI::config()->get_flat_buttons());
blink_rec_button.set_active (ARDOUR_UI::config()->get_blink_rec_arm());
region_color_button.set_active (ARDOUR_UI::config()->get_color_regions_using_track_color());
@@ -183,6 +224,7 @@ ThemeManager::ThemeManager()
set_size_request (-1, 400);
setup_theme ();
+ setup_aliases ();
}
ThemeManager::~ThemeManager()
@@ -204,8 +246,6 @@ ThemeManager::button_press_event (GdkEventButton* ev)
int cellx;
int celly;
- ColorVariable<uint32_t> *ccvar;
-
if (!color_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
return false;
}
@@ -223,7 +263,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
/* parent row, do nothing */
return false;
}
-
+
int r,g, b, a;
uint32_t rgba = (*iter)[columns.rgba];
Gdk::Color color;
@@ -232,49 +272,58 @@ ThemeManager::button_press_event (GdkEventButton* ev)
color.set_rgb_p (r / 255.0, g / 255.0, b / 255.0);
color_dialog.get_colorsel()->set_previous_color (color);
color_dialog.get_colorsel()->set_current_color (color);
- color_dialog.get_colorsel()->set_previous_alpha (a * 256);
- color_dialog.get_colorsel()->set_current_alpha (a * 256);
-
- ResponseType result = (ResponseType) color_dialog.run();
-
- switch (result) {
- case RESPONSE_CANCEL:
- break;
- case RESPONSE_ACCEPT:
- color = color_dialog.get_colorsel()->get_current_color();
- a = color_dialog.get_colorsel()->get_current_alpha();
- r = (int) floor (color.get_red_p() * 255.0);
- g = (int) floor (color.get_green_p() * 255.0);
- b = (int) floor (color.get_blue_p() * 255.0);
-
- rgba = RGBA_TO_UINT(r,g,b,a>>8);
- (*iter)[columns.rgba] = rgba;
- (*iter)[columns.gdkcolor] = color;
-
- ccvar = (*iter)[columns.pVar];
- ccvar->set(rgba);
- /* mark dirty ... */
- ARDOUR_UI::config()->set_dirty ();
- /* but save it immediately */
- ARDOUR_UI::config()->save_state ();
-
- ColorsChanged(); //EMIT SIGNAL
- break;
-
- default:
- break;
-
- }
+ color_dialog.get_colorsel()->set_previous_alpha ((guint16) (a * 256));
+ color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 256));
- color_dialog.hide ();
+ color_dialog_connection.disconnect ();
+ color_dialog_connection = color_dialog.signal_response().connect (sigc::mem_fun (*this, &ThemeManager::foobar_response));
+ color_dialog.present ();
}
- return true;
+ }
+
+ return true;
+}
+void
+ThemeManager::foobar_response (int result)
+{
+ // ColorVariable<uint32_t> *ccvar;
+ int r,g, b, a;
+ uint32_t rgba;
+ Gdk::Color color;
+
+ color_dialog_connection.disconnect ();
+
+ switch (result) {
+ case RESPONSE_CANCEL:
+ break;
+ case RESPONSE_ACCEPT:
+ color = color_dialog.get_colorsel()->get_current_color();
+ a = color_dialog.get_colorsel()->get_current_alpha();
+ r = (int) floor (color.get_red_p() * 255.0);
+ g = (int) floor (color.get_green_p() * 255.0);
+ b = (int) floor (color.get_blue_p() * 255.0);
+
+ rgba = RGBA_TO_UINT(r,g,b,a>>8);
+ // (*iter)[columns.rgba] = rgba;
+ // (*iter)[columns.gdkcolor] = color;
+
+ // ccvar = (*iter)[columns.pVar];
+ // ccvar->set(rgba);
+ /* mark dirty ... */
+ ARDOUR_UI::config()->set_dirty ();
+ /* but save it immediately */
+ ARDOUR_UI::config()->save_state ();
+
+ ColorsChanged(); //EMIT SIGNAL
+ break;
+
default:
break;
+
}
-
- return false;
+
+ color_dialog.hide ();
}
void
@@ -294,18 +343,6 @@ load_rc_file (const string& filename, bool themechange)
Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path, themechange);
}
-/* hmm, this is a problem. the profile doesn't
- exist when the theme manager is constructed
- and toggles buttons during "normal" GTK setup.
-
- a better solution will be to make all Profile
- methods static or something.
-
- XXX FIX ME
-*/
-
-#define HACK_PROFILE_IS_SAE() (getenv("ARDOUR_SAE")!=0)
-
void
ThemeManager::on_flat_buttons_toggled ()
{
@@ -490,3 +527,294 @@ ThemeManager::reset_canvas_colors()
ARDOUR_UI::config()->save_state ();
}
+struct NamedColor {
+ string name;
+ ArdourCanvas::HSV color;
+ NamedColor (string s, ArdourCanvas::HSV c) : name (s), color (c) {}
+};
+
+struct SortByHue {
+ bool operator() (NamedColor const & a, NamedColor const & b) {
+ using namespace ArdourCanvas;
+ const HSV black (0, 0, 0);
+ if (a.color.is_gray() || b.color.is_gray()) {
+ return black.distance (a.color) < black.distance (b.color);
+ } else {
+ return a.color.h < b.color.h;
+ // const HSV red (rgba_to_color (1.0, 0.0, 0.0, 1.0));
+ // return red.distance (a.color) < red.distance (b.color);
+ }
+ }
+};
+
+ArdourCanvas::Container*
+ThemeManager::initialize_canvas (ArdourCanvas::Canvas& canvas)
+{
+ using namespace ArdourCanvas;
+
+ /* hide background */
+ canvas.set_background_color (rgba_to_color (0.0, 0.0, 1.0, 0.0));
+
+ ScrollGroup* base_color_scroll_group = new ScrollGroup (canvas.root(), ScrollGroup::ScrollSensitivity (ScrollGroup::ScrollsVertically|ScrollGroup::ScrollsHorizontally));
+ canvas.add_scroller (*base_color_scroll_group);
+ return new ArdourCanvas::Container (base_color_scroll_group);
+}
+
+void
+ThemeManager::build_base_color_canvas (ArdourCanvas::Container& group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string), double width, double height)
+{
+ using namespace ArdourCanvas;
+
+ /* we want the colors sorted by hue, with their name */
+
+ UIConfiguration::RelativeColors& relatives (ARDOUR_UI::instance()->config()->relative_colors);
+ vector<NamedColor> nc;
+ for (UIConfiguration::RelativeColors::const_iterator x = relatives.begin(); x != relatives.end(); ++x) {
+ nc.push_back (NamedColor (x->first, x->second.get()));
+ }
+ SortByHue sorter;
+ sort (nc.begin(), nc.end(), sorter);
+
+ const uint32_t color_limit = nc.size();
+ const double box_size = 20.0;
+
+ uint32_t color_num = 0;
+
+ /* clear existing rects and delete them */
+
+ group.clear (true);
+
+ for (uint32_t y = 0; y < height - box_size && color_num < color_limit; y += box_size) {
+ for (uint32_t x = 0; x < width - box_size && color_num < color_limit; x += box_size) {
+ Rectangle* r = new Rectangle (&group, Rect (x, y, x + box_size, y + box_size));
+
+ string name = nc[color_num++].name;
+
+ UIConfiguration::RelativeColors::iterator c = relatives.find (name);
+
+ if (c != relatives.end()) {
+ Color color = c->second.get().color ();
+ r->set_fill_color (color);
+ r->set_outline_color (rgba_to_color (0.0, 0.0, 0.0, 1.0));
+ r->set_tooltip (name);
+ r->Event.connect (sigc::bind (sigc::mem_fun (*this, event_handler), name));
+ }
+ }
+ }
+}
+
+void
+ThemeManager::base_color_viewport_allocated (Gtk::Allocation&)
+{
+ if (!base_color_group) {
+ base_color_group = initialize_canvas (*base_color_viewport.canvas());
+ }
+
+ build_base_color_canvas (*base_color_group, &ThemeManager::base_color_event,
+ base_color_viewport.canvas()->width(),
+ base_color_viewport.canvas()->height());
+
+}
+
+bool
+ThemeManager::base_color_event (GdkEvent*ev, string name)
+{
+ switch (ev->type) {
+ case GDK_BUTTON_RELEASE:
+ edit_named_color (name);
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+void
+ThemeManager::edit_named_color (std::string name)
+{
+ using namespace ArdourCanvas;
+ double r,g, b, a;
+ UIConfiguration* uic (ARDOUR_UI::instance()->config());
+ ArdourCanvas::Color c = uic->color (name);
+ Gdk::Color gdkcolor;
+
+ color_to_rgba (c, r, g, b, a);
+
+ gdkcolor.set_rgb_p (r, g, b);
+ color_dialog.get_colorsel()->set_previous_color (gdkcolor);
+ color_dialog.get_colorsel()->set_current_color (gdkcolor);
+ color_dialog.get_colorsel()->set_previous_alpha ((guint16) (a * 65535));
+ color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 65535));
+
+ base_color_edit_name = name;
+
+ color_dialog_connection.disconnect ();
+ color_dialog_connection = color_dialog.signal_response().connect (sigc::mem_fun (*this, &ThemeManager::base_color_dialog_done));
+ color_dialog.present();
+}
+
+void
+ThemeManager::base_color_dialog_done (int result)
+{
+ using namespace ArdourCanvas;
+
+ cerr << "Done, using [" << base_color_edit_name << "] res = " << result << endl;
+
+ if (base_color_edit_name.empty()) {
+ color_dialog.hide ();
+ return;
+ }
+
+ UIConfiguration* uic (ARDOUR_UI::instance()->config());
+ UIConfiguration::RelativeHSV rhsv ("", HSV());
+ Gdk::Color gdkcolor;
+ double r,g, b, a;
+
+ switch (result) {
+ case RESPONSE_ACCEPT:
+ case RESPONSE_OK:
+ cerr << "Accepting\n";
+ gdkcolor = color_dialog.get_colorsel()->get_current_color();
+ a = color_dialog.get_colorsel()->get_current_alpha() / 65535.0;
+ r = gdkcolor.get_red_p();
+ g = gdkcolor.get_green_p();
+ b = gdkcolor.get_blue_p();
+
+ rhsv = uic->color_as_relative_hsv (rgba_to_color (r, g, b, a));
+ uic->reset_relative (base_color_edit_name, rhsv);
+
+ /* rebuild */
+
+ build_base_color_canvas (*base_color_group, &ThemeManager::base_color_event,
+ base_color_viewport.canvas()->width(),
+ base_color_viewport.canvas()->height());
+
+ ColorsChanged(); //EMIT SIGNAL
+ break;
+
+ default:
+ break;
+ }
+
+ color_dialog.hide ();
+ base_color_edit_name = "";
+}
+
+void
+ThemeManager::palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string))
+{
+ build_base_color_canvas (*group, event_handler, alloc.get_width(), alloc.get_height());
+}
+
+bool
+ThemeManager::palette_chosen (GdkEvent* ev, string name)
+{
+ switch (ev->type) {
+ case GDK_BUTTON_RELEASE:
+ break;
+ default:
+ return false;
+ break;
+ }
+
+ UIConfiguration* uic (ARDOUR_UI::instance()->config());
+ uic->set_alias (palette_edit_name, name);
+
+ (void) palette_done ((GdkEventAny*) 0);
+
+ /* rebuild alias list with new color: inefficient but simple */
+
+ setup_aliases ();
+
+ return true;
+}
+
+bool
+ThemeManager::palette_done (GdkEventAny*)
+{
+ palette_edit_name = "";
+ palette_window->hide ();
+ return true;
+}
+
+void
+ThemeManager::choose_color_from_palette (string const & name)
+{
+ if (!palette_window) {
+ palette_window = new Gtk::Window (WINDOW_TOPLEVEL);
+ ArdourCanvas::GtkCanvas* canvas = new ArdourCanvas::GtkCanvas ();
+ ArdourCanvas::Container* group = initialize_canvas (*canvas);
+
+ canvas->signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::palette_canvas_allocated), group, &ThemeManager::palette_chosen));
+ palette_window->signal_delete_event().connect (sigc::mem_fun (*this, &ThemeManager::palette_done));
+
+ palette_window->add (*canvas);
+ canvas->show ();
+ }
+
+ palette_edit_name = name;
+
+ palette_window->set_position (WIN_POS_MOUSE);
+ palette_window->present ();
+}
+
+void
+ThemeManager::setup_aliases ()
+{
+ using namespace ArdourCanvas;
+
+ UIConfiguration* uic (ARDOUR_UI::instance()->config());
+ UIConfiguration::ColorAliases& aliases (uic->color_aliases);
+
+ alias_list->clear ();
+
+ for (UIConfiguration::ColorAliases::iterator i = aliases.begin(); i != aliases.end(); ++i) {
+ TreeModel::Row row;
+
+ 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 */
+
+ double r, g, b, a;
+ color_to_rgba (c, r, g, b, a);
+ Gdk::Color gcolor;
+ gcolor.set_rgb_p (r, g, b);
+
+ row[alias_columns.color] = gcolor;
+ }
+}
+
+bool
+ThemeManager::alias_button_press_event (GdkEventButton* ev)
+{
+ TreeIter iter;
+ TreeModel::Path path;
+ TreeViewColumn* column;
+ int cellx;
+ int celly;
+
+ if (!alias_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
+ return false;
+ }
+
+ guint32 colnum = GPOINTER_TO_UINT (column->get_data (X_("colnum")));
+
+ switch (colnum) {
+ case 0:
+ /* allow normal processing to occur */
+ return false;
+
+ case 1: /* color */
+ if ((iter = alias_list->get_iter (path))) {
+ choose_color_from_palette ((*iter)[alias_columns.name]);
+ }
+ break;
+ }
+
+ return true;
+}
diff --git a/gtk2_ardour/theme_manager.h b/gtk2_ardour/theme_manager.h
index dee5b705c0..c55ef7fcc1 100644
--- a/gtk2_ardour/theme_manager.h
+++ b/gtk2_ardour/theme_manager.h
@@ -28,9 +28,18 @@
#include <gtkmm/button.h>
#include <gtkmm/scale.h>
#include <gtkmm/rc.h>
+
+#include "canvas/canvas.h"
+
#include "ardour_window.h"
+
#include "ui_config.h"
+namespace ArdourCanvas {
+ class Container;
+ class ScrollGroup;
+}
+
class ThemeManager : public ArdourWindow
{
public:
@@ -53,6 +62,8 @@ class ThemeManager : public ArdourWindow
void on_icon_set_changed ();
private:
+ Gtk::Notebook notebook;
+
struct ColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
ColorDisplayModelColumns() {
add (name);
@@ -89,7 +100,53 @@ class ThemeManager : public ArdourWindow
Gtk::Label icon_set_label;
Gtk::ComboBoxText icon_set_dropdown;
+ ColorDisplayModelColumns base_color_columns;
+ Gtk::ScrolledWindow base_color_scroller;
+ ArdourCanvas::GtkCanvasViewport base_color_viewport;
+ ArdourCanvas::Container* base_color_group;
+ std::string base_color_edit_name;
+
+ sigc::connection color_dialog_connection;
+ void foobar_response (int);
+
+ ArdourCanvas::Container* initialize_canvas (ArdourCanvas::Canvas& canvas);
+ void build_base_color_canvas (ArdourCanvas::Container&, bool (ThemeManager::*event_handler)(GdkEvent*,std::string), double width, double height);
+ void base_color_viewport_allocated (Gtk::Allocation&);
+ void base_color_dialog_done (int);
+ bool base_color_event (GdkEvent*, std::string);
+ void edit_named_color (std::string);
+
bool button_press_event (GdkEventButton*);
+
+
+ struct ColorAliasModelColumns : public Gtk::TreeModel::ColumnRecord {
+ ColorAliasModelColumns() {
+ add (name);
+ add (alias);
+ add (color);
+ }
+
+ Gtk::TreeModelColumn<std::string> name;
+ Gtk::TreeModelColumn<std::string> alias;
+ Gtk::TreeModelColumn<Gdk::Color> color;
+ };
+
+ ColorAliasModelColumns alias_columns;
+ Gtk::TreeView alias_display;
+ Glib::RefPtr<Gtk::TreeStore> alias_list;
+ Gtk::ScrolledWindow alias_scroller;
+
+ bool alias_button_press_event (GdkEventButton*);
+
+ Gtk::Window* palette_window;
+ std::string palette_edit_name;
+
+ void choose_color_from_palette (std::string const &target_name);
+ bool palette_chosen (GdkEvent*, std::string);
+ void palette_canvas_allocated (Gtk::Allocation& alloc, ArdourCanvas::Container* group, bool (ThemeManager::*event_handler)(GdkEvent*,std::string));
+ bool palette_done (GdkEventAny*);
+
+ void setup_aliases ();
};
#endif /* __ardour_gtk_color_manager_h__ */
diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc
index cafbd14e18..f096adcf5a 100644
--- a/gtk2_ardour/ui_config.cc
+++ b/gtk2_ardour/ui_config.cc
@@ -97,9 +97,6 @@ UIConfiguration::UIConfiguration ()
load_state();
- // regenerate_relative_definitions ();
- // color_compute ();
-
ARDOUR_UI_UTILS::ColorsChanged.connect (boost::bind (&UIConfiguration::color_theme_changed, this));
}
@@ -107,16 +104,8 @@ UIConfiguration::~UIConfiguration ()
{
}
-Color
-UIConfiguration::quantized (Color c)
-{
- HSV hsv (c);
- hsv.h = hue_width * (round (hsv.h/hue_width));
- return hsv.color ();
-}
-
-void
-UIConfiguration::print_relative_def (string camelcase, string name, Color c)
+UIConfiguration::RelativeHSV
+UIConfiguration::color_as_relative_hsv (Color c)
{
HSV variable (c);
HSV closest;
@@ -172,493 +161,7 @@ UIConfiguration::print_relative_def (string camelcase, string name, Color c)
delta.h = hue_width * (round (delta.h/hue_width));
- cerr << "CANVAS_COLOR(" << camelcase << ",\"" << name << "\", \"" << closest_name << "\", HSV("
- << delta.h << ',' << delta.s << ',' << delta.v << ',' << variable.a << ")) /*"
- << shortest_distance << " */" << endl;
-}
-
-void
-UIConfiguration::regenerate_relative_definitions ()
-{
- /* this takes the color definitions from around ardour 3.5.3600,
- quantizes their hues, then prints out macros to be used
- when defining these colors relative to the current
- base palette. It doesn't need to be called unless
- we change the base palette defaults.
- */
-
- map<string,HSV> c;
- c.insert (make_pair ("active crossfade", HSV (0x20b2af2e)));
- c.insert (make_pair ("arrange base", HSV (0x595959ff)));
- c.insert (make_pair ("audio bus base", HSV (0x73829968)));
- c.insert (make_pair ("audio master bus base", HSV (0x00000000)));
- c.insert (make_pair ("audio track base", HSV (0x9daac468)));
- c.insert (make_pair ("automation line", HSV (0x44bc59ff)));
- c.insert (make_pair ("automation track fill", HSV (0xa0a0ce68)));
- c.insert (make_pair ("automation track outline", HSV (0x282828ff)));
- c.insert (make_pair ("cd marker bar", HSV (0x9496a3cc)));
- c.insert (make_pair ("crossfade editor base", HSV (0x282d49ff)));
- c.insert (make_pair ("crossfade editor line", HSV (0x000000ff)));
- c.insert (make_pair ("crossfade editor line shading", HSV (0x00a0d154)));
- c.insert (make_pair ("crossfade editor point fill", HSV (0x00ff00ff)));
- c.insert (make_pair ("crossfade editor point outline", HSV (0x0000ffff)));
- c.insert (make_pair ("crossfade editor wave", HSV (0xffffff28)));
- c.insert (make_pair ("selected crossfade editor wave fill", HSV (0x00000000)));
- c.insert (make_pair ("crossfade line", HSV (0x000000ff)));
- c.insert (make_pair ("edit point", HSV (0x0000ffff)));
- c.insert (make_pair ("entered automation line", HSV (0xdd6363ff)));
- c.insert (make_pair ("control point fill", HSV (0xffffff66)));
- c.insert (make_pair ("control point outline", HSV (0xff0000ee)));
- c.insert (make_pair ("control point selected", HSV (0x55ccccff)));
- c.insert (make_pair ("entered gain line", HSV (0xdd6363ff)));
- c.insert (make_pair ("entered marker", HSV (0xdd6363ff)));
- c.insert (make_pair ("frame handle", HSV (0x7c00ff96)));
- c.insert (make_pair ("gain line", HSV (0x00bc20ff)));
- c.insert (make_pair ("gain line inactive", HSV (0x9fbca4c5)));
- c.insert (make_pair ("ghost track base", HSV (0x603e7cc6)));
- c.insert (make_pair ("ghost track midi outline", HSV (0x00000000)));
- c.insert (make_pair ("ghost track wave", HSV (0x202020d9)));
- c.insert (make_pair ("ghost track wave fill", HSV (0x20202060)));
- c.insert (make_pair ("ghost track wave clip", HSV (0x202020d9)));
- c.insert (make_pair ("ghost track zero line", HSV (0xe500e566)));
- c.insert (make_pair ("image track", HSV (0xddddd8ff)));
- c.insert (make_pair ("inactive crossfade", HSV (0xe8ed3d77)));
- c.insert (make_pair ("inactive fade handle", HSV (0xbbbbbbaa)));
- c.insert (make_pair ("inactive group tab", HSV (0x434343ff)));
- c.insert (make_pair ("location cd marker", HSV (0x1ee8c4ff)));
- c.insert (make_pair ("location loop", HSV (0x35964fff)));
- c.insert (make_pair ("location marker", HSV (0xc4f411ff)));
- c.insert (make_pair ("location punch", HSV (0x7c3a3aff)));
- c.insert (make_pair ("location range", HSV (0x497a59ff)));
- c.insert (make_pair ("marker bar", HSV (0x99a1adcc)));
- c.insert (make_pair ("marker bar separator", HSV (0x555555ff)));
- c.insert (make_pair ("marker drag line", HSV (0x004f00f9)));
- c.insert (make_pair ("marker label", HSV (0x000000ff)));
- c.insert (make_pair ("marker track", HSV (0xddddd8ff)));
- c.insert (make_pair ("measure line bar", HSV (0xffffff9c)));
- c.insert (make_pair ("measure line beat", HSV (0xa29e9e76)));
- c.insert (make_pair ("meter bar", HSV (0x626470cc)));
- c.insert (make_pair ("meter fill: 0", HSV (0x008800ff)));
- c.insert (make_pair ("meter fill: 1", HSV (0x00aa00ff)));
- c.insert (make_pair ("meter fill: 2", HSV (0x00ff00ff)));
- c.insert (make_pair ("meter fill: 3", HSV (0x00ff00ff)));
- c.insert (make_pair ("meter fill: 4", HSV (0xfff000ff)));
- c.insert (make_pair ("meter fill: 5", HSV (0xfff000ff)));
- c.insert (make_pair ("meter fill: 6", HSV (0xff8000ff)));
- c.insert (make_pair ("meter fill: 7", HSV (0xff8000ff)));
- c.insert (make_pair ("meter fill: 8", HSV (0xff0000ff)));
- c.insert (make_pair ("meter fill: 9", HSV (0xff0000ff)));
- c.insert (make_pair ("meter background: bottom", HSV (0x333333ff)));
- c.insert (make_pair ("meter background: top", HSV (0x444444ff)));
- c.insert (make_pair ("midi meter fill: 0", HSV (0xeffaa1ff)));
- c.insert (make_pair ("midi meter fill: 1", HSV (0xf2c97dff)));
- c.insert (make_pair ("midi meter fill: 2", HSV (0xf2c97dff)));
- c.insert (make_pair ("midi meter fill: 3", HSV (0xf48f52ff)));
- c.insert (make_pair ("midi meter fill: 4", HSV (0xf48f52ff)));
- c.insert (make_pair ("midi meter fill: 5", HSV (0xf83913ff)));
- c.insert (make_pair ("midi meter fill: 6", HSV (0xf83913ff)));
- c.insert (make_pair ("midi meter fill: 7", HSV (0x8fc78eff)));
- c.insert (make_pair ("midi meter fill: 8", HSV (0x8fc78eff)));
- c.insert (make_pair ("midi meter fill: 9", HSV (0x00f45600)));
- c.insert (make_pair ("meterbridge peakindicator: fill", HSV (0x444444ff)));
- c.insert (make_pair ("meterbridge peakindicator: fill active", HSV (0xff0000ff)));
- c.insert (make_pair ("meterbridge label: fill", HSV (0x444444ff)));
- c.insert (make_pair ("meterbridge label: fill active", HSV (0x333333ff)));
- c.insert (make_pair ("meterbridge label: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("meter marker", HSV (0xf2425bff)));
- c.insert (make_pair ("midi bus base", HSV (0x00000000)));
- c.insert (make_pair ("midi frame base", HSV (0x393d3766)));
- c.insert (make_pair ("midi note inactive channel", HSV (0x00000000)));
- c.insert (make_pair ("midi note color min", HSV (0x3f542aff)));
- c.insert (make_pair ("midi note color mid", HSV (0x7ea854ff)));
- c.insert (make_pair ("midi note color max", HSV (0xbfff80ff)));
- c.insert (make_pair ("selected midi note color min", HSV (0x1e1e33ff)));
- c.insert (make_pair ("selected midi note color mid", HSV (0x51518aff)));
- c.insert (make_pair ("selected midi note color max", HSV (0x8383deff)));
- c.insert (make_pair ("midi note selected", HSV (0xb2b2ffff)));
- c.insert (make_pair ("midi note velocity text", HSV (0xf4f214bc)));
- c.insert (make_pair ("midi patch change fill", HSV (0x50555aa0)));
- c.insert (make_pair ("midi patch change outline", HSV (0xc0c5caff)));
- c.insert (make_pair ("midi patch change inactive channel fill", HSV (0x50555ac0)));
- c.insert (make_pair ("midi patch change inactive channel outline", HSV (0x20252ac0)));
- c.insert (make_pair ("midi sysex fill", HSV (0xf1e139a0)));
- c.insert (make_pair ("midi sysex outline", HSV (0xa7a7d4ff)));
- c.insert (make_pair ("midi select rect fill", HSV (0x8888ff88)));
- c.insert (make_pair ("midi select rect outline", HSV (0x5555ffff)));
- c.insert (make_pair ("midi track base", HSV (0xb3cca35f)));
- c.insert (make_pair ("name highlight fill", HSV (0x0000ffff)));
- c.insert (make_pair ("name highlight outline", HSV (0x7c00ff96)));
- c.insert (make_pair ("piano roll black outline", HSV (0xf4f4f476)));
- c.insert (make_pair ("piano roll black", HSV (0x6c6e6a6b)));
- c.insert (make_pair ("piano roll white", HSV (0x979b9565)));
- c.insert (make_pair ("play head", HSV (0xff0000ff)));
- c.insert (make_pair ("processor automation line", HSV (0x7aa3f9ff)));
- c.insert (make_pair ("punch line", HSV (0xa80000ff)));
- c.insert (make_pair ("range drag bar rect", HSV (0x969696c6)));
- c.insert (make_pair ("range drag rect", HSV (0x82c696c6)));
- c.insert (make_pair ("range marker bar", HSV (0x7d7f8ccc)));
- c.insert (make_pair ("recording rect", HSV (0xcc2828ff)));
- c.insert (make_pair ("recorded waveform fill", HSV (0xffffffd9)));
- c.insert (make_pair ("recorded waveform outline", HSV (0x0f0f1fff)));
- c.insert (make_pair ("rubber band rect", HSV (0xc6c6c659)));
- c.insert (make_pair ("ruler base", HSV (0x2c2121ff)));
- c.insert (make_pair ("ruler text", HSV (0xe5e5e5ff)));
- c.insert (make_pair ("selected crossfade editor line", HSV (0x00dbdbff)));
- c.insert (make_pair ("selected crossfade editor wave", HSV (0xf9ea14a0)));
- c.insert (make_pair ("selected region base", HSV (0x585c61ff)));
- c.insert (make_pair ("selected waveform fill", HSV (0xffa500d9)));
- c.insert (make_pair ("selected waveform outline", HSV (0x0f0f0fcc)));
- c.insert (make_pair ("selection rect", HSV (0xe8f4d377)));
- c.insert (make_pair ("selection", HSV (0x636363b2)));
- c.insert (make_pair ("shuttle", HSV (0x6bb620ff)));
- c.insert (make_pair ("silence", HSV (0x9efffd7a)));
- c.insert (make_pair ("silence text", HSV (0x0e066cff)));
- c.insert (make_pair ("mono panner outline", HSV (0x33445eff)));
- c.insert (make_pair ("mono panner fill", HSV (0x7a9bccc9)));
- c.insert (make_pair ("mono panner text", HSV (0x000000ff)));
- c.insert (make_pair ("mono panner bg", HSV (0x2e2929ff)));
- c.insert (make_pair ("mono panner position fill", HSV (0x7a89b3ff)));
- c.insert (make_pair ("mono panner position outline", HSV (0x33445eff)));
- c.insert (make_pair ("stereo panner outline", HSV (0x33445eff)));
- c.insert (make_pair ("stereo panner fill", HSV (0x7a9accc9)));
- c.insert (make_pair ("stereo panner text", HSV (0x000000ff)));
- c.insert (make_pair ("stereo panner bg", HSV (0x2e2929ff)));
- c.insert (make_pair ("stereo panner rule", HSV (0x455c7fff)));
- c.insert (make_pair ("stereo panner mono outline", HSV (0xa05600ff)));
- c.insert (make_pair ("stereo panner mono fill", HSV (0xe99668ca)));
- c.insert (make_pair ("stereo panner mono text", HSV (0x000000ff)));
- c.insert (make_pair ("stereo panner mono bg", HSV (0x2e2929ff)));
- c.insert (make_pair ("stereo panner inverted outline", HSV (0xbf0a00ff)));
- c.insert (make_pair ("stereo panner inverted fill", HSV (0xe4a19cc9)));
- c.insert (make_pair ("stereo panner inverted text", HSV (0x000000ff)));
- c.insert (make_pair ("stereo panner inverted bg", HSV (0x2e2929ff)));
- c.insert (make_pair ("tempo bar", HSV (0x70727fcc)));
- c.insert (make_pair ("tempo marker", HSV (0xf2425bff)));
- c.insert (make_pair ("time axis frame", HSV (0x000000ff)));
- c.insert (make_pair ("selected time axis frame", HSV (0xee0000ff)));
- c.insert (make_pair ("time stretch fill", HSV (0xe2b5b596)));
- c.insert (make_pair ("time stretch outline", HSV (0x63636396)));
- c.insert (make_pair ("tracknumber label: fill", HSV (0x444444ff)));
- c.insert (make_pair ("tracknumber label: fill active", HSV (0x333333ff)));
- c.insert (make_pair ("tracknumber label: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("transport drag rect", HSV (0x969696c6)));
- c.insert (make_pair ("transport loop rect", HSV (0x1e7728f9)));
- c.insert (make_pair ("transport marker bar", HSV (0x8c8e98cc)));
- c.insert (make_pair ("transport punch rect", HSV (0x6d2828e5)));
- c.insert (make_pair ("trim handle locked", HSV (0xea0f0f28)));
- c.insert (make_pair ("trim handle", HSV (0x1900ff44)));
- c.insert (make_pair ("verbose canvas cursor", HSV (0xfffd2ebc)));
- c.insert (make_pair ("vestigial frame", HSV (0x0000000f)));
- c.insert (make_pair ("video timeline bar", HSV (0x303030ff)));
- c.insert (make_pair ("region base", HSV (0x838890ff)));
- c.insert (make_pair ("region area covered by another region", HSV (0x505050b0)));
- c.insert (make_pair ("waveform outline", HSV (0x000000ff)));
- c.insert (make_pair ("clipped waveform", HSV (0xff0000e5)));
- c.insert (make_pair ("waveform fill", HSV (0xffffffd9)));
- c.insert (make_pair ("zero line", HSV (0x7f7f7fe0)));
- c.insert (make_pair ("zoom rect", HSV (0xc6d1b26d)));
- c.insert (make_pair ("monitor knob", HSV (0x555050ff)));
- c.insert (make_pair ("monitor knob: arc start", HSV (0x5d90b0ff)));
- c.insert (make_pair ("monitor knob: arc end", HSV (0x154c6eff)));
- c.insert (make_pair ("button border", HSV (0x000000f0)));
- c.insert (make_pair ("border color", HSV (0x00000000)));
- c.insert (make_pair ("processor prefader: fill", HSV (0x873c3cff)));
- c.insert (make_pair ("processor prefader: fill active", HSV (0x603535ff)));
- c.insert (make_pair ("processor prefader: led", HSV (0x26550eff)));
- c.insert (make_pair ("processor prefader: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("processor prefader: text", HSV (0xaaaaa3ff)));
- c.insert (make_pair ("processor prefader: text active", HSV (0xeeeeecff)));
- c.insert (make_pair ("processor fader: fill", HSV (0x5d90b0ff)));
- c.insert (make_pair ("processor fader: fill active", HSV (0x256d8fff)));
- c.insert (make_pair ("processor fader: led", HSV (0x26550eff)));
- c.insert (make_pair ("processor fader: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("processor fader: text", HSV (0xaaaaa3ff)));
- c.insert (make_pair ("processor fader: text active", HSV (0xeeeeecff)));
- c.insert (make_pair ("processor postfader: fill", HSV (0x455a3cff)));
- c.insert (make_pair ("processor postfader: fill active", HSV (0x254528ff)));
- c.insert (make_pair ("processor postfader: led", HSV (0x26550eff)));
- c.insert (make_pair ("processor postfader: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("processor postfader: text", HSV (0xaaaaa3ff)));
- c.insert (make_pair ("processor postfader: text active", HSV (0xeeeeecff)));
- c.insert (make_pair ("processor control button: fill", HSV (0x222222ff)));
- c.insert (make_pair ("processor control button: fill active", HSV (0x333333ff)));
- c.insert (make_pair ("processor control button: led", HSV (0x101010ff)));
- c.insert (make_pair ("processor control button: led active", HSV (0x5d90b0ff)));
- c.insert (make_pair ("processor control button: text", HSV (0xffffffff)));
- c.insert (make_pair ("processor control button: text active", HSV (0xffffffff)));
- c.insert (make_pair ("midi device: fill", HSV (0x54555dff)));
- c.insert (make_pair ("midi device: fill active", HSV (0x45464cff)));
- c.insert (make_pair ("midi device: led", HSV (0x006600ff)));
- c.insert (make_pair ("midi device: led active", HSV (0x00ff00ff)));
- c.insert (make_pair ("midi device: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("midi device: text active", HSV (0xeeeeecff)));
- c.insert (make_pair ("monitor button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("monitor button: fill active", HSV (0xc56505ff)));
- c.insert (make_pair ("monitor button: led", HSV (0x660000ff)));
- c.insert (make_pair ("monitor button: led active", HSV (0xff0000ff)));
- c.insert (make_pair ("monitor button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor button: text active", HSV (0x1a1a1aff)));
- c.insert (make_pair ("solo isolate: fill", HSV (0x616268ff)));
- c.insert (make_pair ("solo isolate: fill active", HSV (0x564d48ff)));
- c.insert (make_pair ("solo isolate: led", HSV (0x660000ff)));
- c.insert (make_pair ("solo isolate: led active", HSV (0xff0000ff)));
- c.insert (make_pair ("solo isolate: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("solo isolate: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("solo safe: fill", HSV (0x616268ff)));
- c.insert (make_pair ("solo safe: fill active", HSV (0x564d48ff)));
- c.insert (make_pair ("solo safe: led", HSV (0x660000ff)));
- c.insert (make_pair ("solo safe: led active", HSV (0xff0000ff)));
- c.insert (make_pair ("solo safe: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("solo safe: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("meterbridge peaklabel", HSV (0xff1111ff)));
- c.insert (make_pair ("meter color BBC", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor section cut: fill", HSV (0x5f5a58ff)));
- c.insert (make_pair ("monitor section cut: fill active", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor section cut: led", HSV (0x473812ff)));
- c.insert (make_pair ("monitor section cut: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("monitor section cut: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor section cut: text active", HSV (0x000000ff)));
- c.insert (make_pair ("monitor section dim: fill", HSV (0x5f5a58ff)));
- c.insert (make_pair ("monitor section dim: fill active", HSV (0xe58505ff)));
- c.insert (make_pair ("monitor section dim: led", HSV (0x00000000)));
- c.insert (make_pair ("monitor section dim: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("monitor section dim: text", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("monitor section dim: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("monitor section solo: fill", HSV (0x5f5a58ff)));
- c.insert (make_pair ("monitor section solo: fill active", HSV (0x4dbb00ff)));
- c.insert (make_pair ("monitor section solo: led", HSV (0x473812ff)));
- c.insert (make_pair ("monitor section solo: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor section solo: text", HSV (0x00000000)));
- c.insert (make_pair ("monitor section solo: text active", HSV (0x00000000)));
- c.insert (make_pair ("monitor section invert: fill", HSV (0x5f5a58ff)));
- c.insert (make_pair ("monitor section invert: fill active", HSV (0x4242d0ff)));
- c.insert (make_pair ("monitor section invert: led", HSV (0x473812ff)));
- c.insert (make_pair ("monitor section invert: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("monitor section invert: text", HSV (0x00000000)));
- c.insert (make_pair ("monitor section invert: text active", HSV (0x00000000)));
- c.insert (make_pair ("monitor section mono: fill", HSV (0x5f5a58ff)));
- c.insert (make_pair ("monitor section mono: fill active", HSV (0x3232c0ff)));
- c.insert (make_pair ("monitor section mono: led", HSV (0x473812ff)));
- c.insert (make_pair ("monitor section mono: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("monitor section mono: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor section mono: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("monitor section solo model: fill", HSV (0x5d5856ff)));
- c.insert (make_pair ("monitor section solo model: fill active", HSV (0x564d48ff)));
- c.insert (make_pair ("monitor section solo model: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("monitor section solo model: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor section solo model: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor section solo model: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("monitor solo override: fill", HSV (0x5d5856ff)));
- c.insert (make_pair ("monitor solo override: fill active", HSV (0x564d48ff)));
- c.insert (make_pair ("monitor solo override: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("monitor solo override: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor solo override: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor solo override: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("monitor solo exclusive: fill", HSV (0x5d5856ff)));
- c.insert (make_pair ("monitor solo exclusive: fill active", HSV (0x564c47ff)));
- c.insert (make_pair ("monitor solo exclusive: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("monitor solo exclusive: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("monitor solo exclusive: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("monitor solo exclusive: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("rude solo: fill", HSV (0x684d4dff)));
- c.insert (make_pair ("rude solo: fill active", HSV (0xe21b1bff)));
- c.insert (make_pair ("rude solo: led", HSV (0x00000000)));
- c.insert (make_pair ("rude solo: led active", HSV (0x00000000)));
- c.insert (make_pair ("rude solo: text", HSV (0x969696ff)));
- c.insert (make_pair ("rude solo: text active", HSV (0xe5e5e5ff)));
- c.insert (make_pair ("rude isolate: fill", HSV (0x21414fff)));
- c.insert (make_pair ("rude isolate: fill active", HSV (0xb6e5fdff)));
- c.insert (make_pair ("rude isolate: led", HSV (0x00000000)));
- c.insert (make_pair ("rude isolate: led active", HSV (0x000000ff)));
- c.insert (make_pair ("rude isolate: text", HSV (0x979797ff)));
- c.insert (make_pair ("rude isolate: text active", HSV (0x000000ff)));
- c.insert (make_pair ("rude audition: fill", HSV (0x684d4dff)));
- c.insert (make_pair ("rude audition: fill active", HSV (0xe21b1bff)));
- c.insert (make_pair ("rude audition: led", HSV (0x00000000)));
- c.insert (make_pair ("rude audition: led active", HSV (0x00000000)));
- c.insert (make_pair ("rude audition: text", HSV (0x979797ff)));
- c.insert (make_pair ("rude audition: text active", HSV (0xffffffff)));
- c.insert (make_pair ("feedback alert: fill", HSV (0x684d4dff)));
- c.insert (make_pair ("feedback alert: fill active", HSV (0xe21b1bff)));
- c.insert (make_pair ("feedback alert: led", HSV (0x00000000)));
- c.insert (make_pair ("feedback alert: led active", HSV (0x00000000)));
- c.insert (make_pair ("feedback alert: text", HSV (0x969696ff)));
- c.insert (make_pair ("feedback alert: text active", HSV (0xe5e5e5ff)));
- c.insert (make_pair ("mute button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("mute button: fill active", HSV (0xbbbb00ff)));
- c.insert (make_pair ("mute button: led", HSV (0x00000000)));
- c.insert (make_pair ("mute button: led active", HSV (0x00000000)));
- c.insert (make_pair ("mute button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("mute button: text active", HSV (0x191919ff)));
- c.insert (make_pair ("solo button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("solo button: fill active", HSV (0x4dbb00ff)));
- c.insert (make_pair ("solo button: led", HSV (0x00000000)));
- c.insert (make_pair ("solo button: led active", HSV (0x00000000)));
- c.insert (make_pair ("solo button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("solo button: text active", HSV (0x191919ff)));
- c.insert (make_pair ("invert button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("invert button: fill active", HSV (0x4242d0ff)));
- c.insert (make_pair ("invert button: led", HSV (0x473812ff)));
- c.insert (make_pair ("invert button: led active", HSV (0x78cb4eff)));
- c.insert (make_pair ("invert button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("invert button: text active", HSV (0xbfbfbfff)));
- c.insert (make_pair ("record enable button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("record enable button: fill active", HSV (0xb50e0eff)));
- c.insert (make_pair ("record enable button: led", HSV (0x7b3541ff)));
- c.insert (make_pair ("record enable button: led active", HSV (0xffa3b3ff)));
- c.insert (make_pair ("record enable button: text", HSV (0xa5a5a5ff)));
- c.insert (make_pair ("record enable button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("generic button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("generic button: fill active", HSV (0xfd0000ff)));
- c.insert (make_pair ("generic button: led", HSV (0x22224fff)));
- c.insert (make_pair ("generic button: led active", HSV (0x2222ffff)));
- c.insert (make_pair ("generic button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("generic button: text active", HSV (0x191919ff)));
- c.insert (make_pair ("send alert button: fill", HSV (0x4e5647ff)));
- c.insert (make_pair ("send alert button: fill active", HSV (0x85e524ff)));
- c.insert (make_pair ("send alert button: led", HSV (0x00000000)));
- c.insert (make_pair ("send alert button: led active", HSV (0x00000000)));
- c.insert (make_pair ("send alert button: text", HSV (0xccccccff)));
- c.insert (make_pair ("send alert button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("transport button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("transport button: fill active", HSV (0x00a300ff)));
- c.insert (make_pair ("transport button: led", HSV (0x00000000)));
- c.insert (make_pair ("transport button: led active", HSV (0x00000000)));
- c.insert (make_pair ("transport button: text", HSV (0x00000000)));
- c.insert (make_pair ("transport button: text active", HSV (0x00000000)));
- c.insert (make_pair ("transport recenable button: fill", HSV (0x5f3f3fff)));
- c.insert (make_pair ("transport recenable button: fill active", HSV (0xb50e0eff)));
- c.insert (make_pair ("transport recenable button: led", HSV (0x00000000)));
- c.insert (make_pair ("transport recenable button: led active", HSV (0x00000000)));
- c.insert (make_pair ("transport recenable button: text", HSV (0x00000000)));
- c.insert (make_pair ("transport recenable button: text active", HSV (0x00000000)));
- c.insert (make_pair ("transport option button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("transport option button: fill active", HSV (0x4a4b51ff)));
- c.insert (make_pair ("transport option button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("transport option button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("transport option button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("transport option button: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("transport active option button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("transport active option button: fill active", HSV (0x00a300ff)));
- c.insert (make_pair ("transport active option button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("transport active option button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("transport active option button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("transport active option button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("plugin bypass button: fill", HSV (0x5d5856ff)));
- c.insert (make_pair ("plugin bypass button: fill active", HSV (0x564d48ff)));
- c.insert (make_pair ("plugin bypass button: led", HSV (0x660000ff)));
- c.insert (make_pair ("plugin bypass button: led active", HSV (0xff0000ff)));
- c.insert (make_pair ("plugin bypass button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("plugin bypass button: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("punch button: fill", HSV (0x603f3fff)));
- c.insert (make_pair ("punch button: fill active", HSV (0xf03020ff)));
- c.insert (make_pair ("punch button: led", HSV (0x00000000)));
- c.insert (make_pair ("punch button: led active", HSV (0x00000000)));
- c.insert (make_pair ("punch button: text", HSV (0xa5a5a5ff)));
- c.insert (make_pair ("punch button: text active", HSV (0xd8d8d8ff)));
- c.insert (make_pair ("mouse mode button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("mouse mode button: fill active", HSV (0x00b200ff)));
- c.insert (make_pair ("mouse mode button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("mouse mode button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("mouse mode button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("mouse mode button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("nudge button: fill", HSV (0x684744ff)));
- c.insert (make_pair ("nudge button: fill active", HSV (0x404045ff)));
- c.insert (make_pair ("nudge button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("nudge button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("nudge button: text", HSV (0xc7c7d8ff)));
- c.insert (make_pair ("nudge button: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("zoom menu: fill", HSV (0x99997950)));
- c.insert (make_pair ("zoom menu: fill active", HSV (0x404045ff)));
- c.insert (make_pair ("zoom menu: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("zoom menu: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("zoom menu: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("zoom menu: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("zoom button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("zoom button: fill active", HSV (0x00a300ff)));
- c.insert (make_pair ("zoom button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("zoom button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("zoom button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("zoom button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("route button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("route button: fill active", HSV (0x121212ff)));
- c.insert (make_pair ("route button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("route button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("route button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("route button: text active", HSV (0x191919ff)));
- c.insert (make_pair ("mixer strip button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("mixer strip button: fill active", HSV (0xffa500ff)));
- c.insert (make_pair ("mixer strip button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("mixer strip button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("mixer strip button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("mixer strip button: text active", HSV (0x000000ff)));
- c.insert (make_pair ("mixer strip name button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("mixer strip name button: fill active", HSV (0x121212ff)));
- c.insert (make_pair ("mixer strip name button: led", HSV (0x4f3300ff)));
- c.insert (make_pair ("mixer strip name button: led active", HSV (0xffa500ff)));
- c.insert (make_pair ("mixer strip name button: text", HSV (0xd7d7e8ff)));
- c.insert (make_pair ("mixer strip name button: text active", HSV (0xc8c8d9ff)));
- c.insert (make_pair ("midi input button: fill", HSV (0x656867ff)));
- c.insert (make_pair ("midi input button: fill active", HSV (0x00a300ff)));
- c.insert (make_pair ("midi input button: led", HSV (0x00000000)));
- c.insert (make_pair ("midi input button: led active", HSV (0x00000000)));
- c.insert (make_pair ("midi input button: text", HSV (0x00000000)));
- c.insert (make_pair ("midi input button: text active", HSV (0x00000000)));
- c.insert (make_pair ("transport clock: background", HSV (0x262626ff)));
- c.insert (make_pair ("transport clock: text", HSV (0x8df823ff)));
- c.insert (make_pair ("transport clock: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("transport clock: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("secondary clock: background", HSV (0x262626ff)));
- c.insert (make_pair ("secondary clock: text", HSV (0x8df823ff)));
- c.insert (make_pair ("secondary clock: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("secondary clock: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("transport delta clock: background", HSV (0x000000ff)));
- c.insert (make_pair ("transport delta clock: edited text", HSV (0xff0000ff)));
- c.insert (make_pair ("transport delta clock: cursor", HSV (0xf11000ff)));
- c.insert (make_pair ("transport delta clock: text", HSV (0x8ce1f8ff)));
- c.insert (make_pair ("secondary delta clock: edited text", HSV (0xff0000ff)));
- c.insert (make_pair ("secondary delta clock: cursor", HSV (0xf11000ff)));
- c.insert (make_pair ("secondary delta clock: background", HSV (0x000000ff)));
- c.insert (make_pair ("secondary delta clock: text", HSV (0x8ce1f8ff)));
- c.insert (make_pair ("big clock: background", HSV (0x020202ff)));
- c.insert (make_pair ("big clock: text", HSV (0xf0f0f0ff)));
- c.insert (make_pair ("big clock: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("big clock: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("big clock active: background", HSV (0x020202ff)));
- c.insert (make_pair ("big clock active: text", HSV (0xf11000ff)));
- c.insert (make_pair ("big clock active: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("big clock active: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("punch clock: background", HSV (0x000000ff)));
- c.insert (make_pair ("punch clock: text", HSV (0x6bb620ff)));
- c.insert (make_pair ("punch clock: edited text", HSV (0xff0000ff)));
- c.insert (make_pair ("punch clock: cursor", HSV (0xf11000ff)));
- c.insert (make_pair ("selection clock: background", HSV (0x000000ff)));
- c.insert (make_pair ("selection clock: text", HSV (0x6bb620ff)));
- c.insert (make_pair ("selection clock: edited text", HSV (0xff0000ff)));
- c.insert (make_pair ("selection clock: cursor", HSV (0xf11000ff)));
- c.insert (make_pair ("nudge clock: background", HSV (0x262626ff)));
- c.insert (make_pair ("nudge clock: text", HSV (0x6bb620ff)));
- c.insert (make_pair ("nudge clock: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("nudge clock: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("clock: background", HSV (0x000000ff)));
- c.insert (make_pair ("clock: text", HSV (0x6bb620ff)));
- c.insert (make_pair ("clock: edited text", HSV (0xffa500ff)));
- c.insert (make_pair ("clock: cursor", HSV (0xffa500ff)));
- c.insert (make_pair ("lock button: fill", HSV (0x616268ff)));
- c.insert (make_pair ("lock button: fill active", HSV (0x404045ff)));
- c.insert (make_pair ("lock button: led", HSV (0x00000000)));
- c.insert (make_pair ("lock button: led active", HSV (0x00000000)));
- c.insert (make_pair ("lock button: text", HSV (0x000024ff)));
- c.insert (make_pair ("lock button: text active", HSV (0xc8c8d9ff)));
-
- for (map<string,HSV>::iterator fp = c.begin(); fp != c.end(); ++fp) {
- fp->second.h = hue_width * (round (fp->second.h/hue_width));
- }
-
-#undef CANVAS_COLOR
-#define CANVAS_COLOR(var,name,base,modifier) print_relative_def (#var,name,c[name]);
-#include "colors.h"
-#undef CANVAS_COLOR
+ return RelativeHSV (closest_name, delta);
}
void
@@ -677,8 +180,6 @@ UIConfiguration::color_theme_changed ()
for (current_color = relative_colors.begin(); current_color != relative_colors.end(); ++current_color) {
current_color->second.quantized_hue = -1;
}
-
- color_compute ();
}
void
@@ -959,8 +460,14 @@ UIConfiguration::color (const std::string& name) const
if (rc != relative_colors.end()) {
return rc->second.get();
}
+ } else {
+ /* not an alias, try directly */
+ map<string,RelativeHSV>::const_iterator rc = relative_colors.find (name);
+ if (rc != relative_colors.end()) {
+ return rc->second.get();
+ }
}
-
+
cerr << string_compose (_("Color %1 not found"), name) << endl;
return rgba_to_color ((g_random_int()%256)/255.0,
@@ -979,8 +486,6 @@ UIConfiguration::RelativeHSV::get() const
* we need to reset base's alpha to zero before adding the modifier.
*/
- base.a = 0.0;
-
HSV self (base + modifier);
if (quantized_hue >= 0.0) {
@@ -990,70 +495,34 @@ UIConfiguration::RelativeHSV::get() const
return self;
}
-void
-UIConfiguration::color_compute ()
+Color
+UIConfiguration::quantized (Color c) const
{
- using namespace ArdourCanvas;
-
- map<std::string,ColorVariable<Color>* >::iterator f;
- map<std::string,HSV*>::iterator v;
-
- /* now compute distances */
-
- cerr << "Attempt to reduce " << relative_colors.size() << endl;
-
- map<std::string,RelativeHSV>::iterator current_color;
-
- color_aliases.clear ();
- actual_colors.clear ();
-
- for (current_color = relative_colors.begin(); current_color != relative_colors.end(); ++current_color) {
-
- map<std::string,HSV>::iterator possible_match;
- std::string equivalent_name;
- bool matched;
-
- matched = false;
-
- for (possible_match = actual_colors.begin(); possible_match != actual_colors.end(); ++possible_match) {
-
- HSV a (current_color->second.get());
- HSV b (possible_match->second);
-
- /* This uses perceptual distance to find visually
- * similar colors.
- */
-
- if (a.distance (b) < 6.0) {
- matched = true;
- break;
- }
- }
-
- if (!matched) {
-
- /* color does not match any other, generate a generic
- * name and store two aliases.
- */
+ HSV hsv (c);
+ hsv.h = hue_width * (round (hsv.h/hue_width));
+ return hsv.color ();
+}
- string alias = string_compose ("color %1", actual_colors.size() + 1);
- cerr << "CANVAS_COLOR(\"" << alias << "\", \"" << current_color->second.base_color
- << "\"," << current_color->second.modifier
- << ")\n";
- actual_colors.insert (make_pair (alias, current_color->second.get()));
- color_aliases.insert (make_pair (current_color->first, alias));
- cerr << "COLOR_ALIAS(\"" << current_color->first << "\",\"" << alias << "\")\n";
+void
+UIConfiguration::reset_relative (const string& name, const RelativeHSV& rhsv)
+{
+ RelativeColors::iterator i = relative_colors.find (name);
+ if (i == relative_colors.end()) {
+ return;
+ }
- } else {
+ i->second = rhsv;
+}
- /* this color was within the JND CIE76 distance of
- * another, so throw it away.
- */
-
- color_aliases.insert (make_pair (current_color->first, possible_match->first));
- cerr << "COLOR_ALIAS(\"" << current_color->first << "\",\"" << possible_match->first << "\")\n";
- }
+void
+UIConfiguration::set_alias (string const & name, string const & alias)
+{
+ ColorAliases::iterator i = color_aliases.find (name);
+ if (i == color_aliases.end()) {
+ return;
}
- cerr << "Ended with " << actual_colors.size() << " colors" << endl;
+ i->second = alias;
+ ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
}
+
diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h
index 49cf27c93a..294c6a36b9 100644
--- a/gtk2_ardour/ui_config.h
+++ b/gtk2_ardour/ui_config.h
@@ -24,6 +24,9 @@
#include <ostream>
#include <iostream>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+
#include "pbd/stateful.h"
#include "pbd/xml++.h"
#include "ardour/configuration_variable.h"
@@ -40,7 +43,7 @@
template<class T>
class ColorVariable : public ARDOUR::ConfigVariableBase
{
- public:
+ public:
ColorVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
ColorVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
@@ -79,7 +82,19 @@ class ColorVariable : public ARDOUR::ConfigVariableBase
class UIConfiguration : public PBD::Stateful
{
- public:
+ public:
+ struct RelativeHSV {
+ RelativeHSV (const std::string& b, const ArdourCanvas::HSV& mod)
+ : base_color (b)
+ , modifier (mod)
+ , quantized_hue (-1.0) {}
+ std::string base_color;
+ ArdourCanvas::HSV modifier;
+ double quantized_hue;
+
+ ArdourCanvas::HSV get() const;
+ };
+
UIConfiguration();
~UIConfiguration();
@@ -98,8 +113,19 @@ class UIConfiguration : public PBD::Stateful
XMLNode& get_state (void);
XMLNode& get_variables (std::string);
void set_variables (const XMLNode&);
- void pack_canvasvars ();
- void reset_derived_colors ();
+
+ typedef std::map<std::string,RelativeHSV> RelativeColors;
+ typedef std::map<std::string,std::string> ColorAliases;
+
+ RelativeColors relative_colors;
+ ColorAliases color_aliases;
+
+ void set_alias (std::string const & name, std::string const & alias);
+
+ void reset_relative (const std::string& name, const RelativeHSV& new_value);
+
+ RelativeHSV color_as_relative_hsv (ArdourCanvas::Color c);
+ ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
ArdourCanvas::Color base_color_by_name (const std::string&) const;
ArdourCanvas::Color color (const std::string&) const;
@@ -139,26 +165,6 @@ class UIConfiguration : public PBD::Stateful
#undef COLOR_ALIAS
private:
-
- struct RelativeHSV {
- RelativeHSV (const std::string& b, const ArdourCanvas::HSV& mod)
- : base_color (b)
- , modifier (mod)
- , quantized_hue (-1.0) {}
- std::string base_color;
- ArdourCanvas::HSV modifier;
- double quantized_hue;
-
- ArdourCanvas::HSV get() const;
- };
-
- /* these are loaded from serialized state (e.g. XML) */
- std::map<std::string,RelativeHSV> relative_colors;
- /* these are computed during color_compute()*/
- std::map<std::string,ArdourCanvas::HSV> actual_colors;
- /* these map from the name/key of relative colors to the color/value of actual colors */
- std::map<std::string,std::string> color_aliases;
-
/* declare variables */
#undef UI_CONFIG_VARIABLE
@@ -183,11 +189,7 @@ class UIConfiguration : public PBD::Stateful
bool _dirty;
static UIConfiguration* _instance;
- void color_compute ();
- void print_relative_def (std::string camelcase, std::string name, ArdourCanvas::Color c);
void color_theme_changed ();
- void regenerate_relative_definitions ();
- ArdourCanvas::Color quantized (ArdourCanvas::Color);
};
#endif /* __ardour_ui_configuration_h__ */