From 9ac551abab0fd80d3e61cb084d2e70c4ecc78310 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 8 Dec 2014 18:19:11 -0500 Subject: [PATCH] another metric ton of color work --- gtk2_ardour/ardour_ui.cc | 4 +- gtk2_ardour/ardour_ui_ed.cc | 4 +- gtk2_ardour/dark.colors | 593 +++++++++++++++++++++++++++++ gtk2_ardour/default_ui_config.in | 485 +---------------------- gtk2_ardour/editor_route_groups.cc | 1 - gtk2_ardour/theme_manager.cc | 66 ++-- gtk2_ardour/theme_manager.h | 6 +- gtk2_ardour/ui_config.cc | 225 ++++++----- gtk2_ardour/ui_config.h | 76 +--- gtk2_ardour/ui_config_vars.h | 3 +- gtk2_ardour/wscript | 1 + tools/linux_packaging/build | 22 +- tools/osx_packaging/osx_build | 23 +- 13 files changed, 792 insertions(+), 717 deletions(-) create mode 100644 gtk2_ardour/dark.colors diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 70ff7a6081..a94e77acc4 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -572,9 +572,7 @@ ARDOUR_UI::post_engine () ARDOUR_UI::~ARDOUR_UI () { - if (ui_config->dirty()) { - ui_config->save_state(); - } + ui_config->save_state(); stop_video_server(); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index e442e8dda4..7e426fa40e 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -615,9 +615,7 @@ ARDOUR_UI::save_ardour_state () Config->save_state(); - if (ui_config->dirty()) { - ui_config->save_state (); - } + ui_config->save_state (); XMLNode& enode (static_cast(editor)->get_state()); XMLNode& mnode (mixer->get_state()); diff --git a/gtk2_ardour/dark.colors b/gtk2_ardour/dark.colors new file mode 100644 index 0000000000..76dc06f8cc --- /dev/null +++ b/gtk2_ardour/dark.colors @@ -0,0 +1,593 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk2_ardour/default_ui_config.in b/gtk2_ardour/default_ui_config.in index 9cc771c70e..bd8cf934c7 100644 --- a/gtk2_ardour/default_ui_config.in +++ b/gtk2_ardour/default_ui_config.in @@ -3,6 +3,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gtk2_ardour/editor_route_groups.cc b/gtk2_ardour/editor_route_groups.cc index 6d56b7d8c0..dbf7173082 100644 --- a/gtk2_ardour/editor_route_groups.cc +++ b/gtk2_ardour/editor_route_groups.cc @@ -272,7 +272,6 @@ EditorRouteGroups::button_press_event (GdkEventButton* ev) case RESPONSE_ACCEPT: c = color_dialog.get_colorsel()->get_current_color(); GroupTabs::set_group_color (group, gdk_color_to_rgba (c)); - ARDOUR_UI::config()->set_dirty (); break; default: diff --git a/gtk2_ardour/theme_manager.cc b/gtk2_ardour/theme_manager.cc index d7749030af..1f333058ed 100644 --- a/gtk2_ardour/theme_manager.cc +++ b/gtk2_ardour/theme_manager.cc @@ -59,7 +59,6 @@ using namespace ARDOUR_UI_UTILS; namespace ARDOUR_UI_UTILS { sigc::signal ColorsChanged; - sigc::signal ColorChanged; } ThemeManager::ThemeManager() @@ -230,15 +229,25 @@ ThemeManager::ThemeManager() /* no need to call setup_palette() here, it will be done when its size is allocated */ setup_aliases (); - /* Trigger setting up the GTK color scheme and loading the RC file */ - cerr << "Load RC file\n"; - UIConfiguration::load_rc_file (ARDOUR_UI::config()->get_ui_rc_file(), false); + /* Trigger setting up the color scheme and loading the GTK RC file */ + + ARDOUR_UI::config()->load_rc_file (false); + + ARDOUR_UI_UTILS::ColorsChanged.connect (sigc::mem_fun (*this, &ThemeManager::colors_changed)); } ThemeManager::~ThemeManager() { } +void +ThemeManager::colors_changed () +{ + setup_basic_color_display (); + setup_palette (); + setup_aliases (); +} + int ThemeManager::save (string /*path*/) { @@ -266,16 +275,11 @@ ThemeManager::basic_color_button_press_event (GdkEventButton* ev) case 1: /* color */ if ((iter = basic_color_list->get_iter (path))) { - ColorVariable* var = (*iter)[basic_color_columns.color_variable]; - if (!var) { - /* parent row, do nothing */ - return false; - } - + string color_name = (*iter)[basic_color_columns.name]; Gdk::Color color; double r, g, b, a; - ArdourCanvas::color_to_rgba (var->get(), r, g, b, a); + ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->base_color_by_name (color_name), r, g, b, a); color.set_rgb_p (r, g, b); color_dialog.get_colorsel()->set_previous_color (color); color_dialog.get_colorsel()->set_current_color (color); @@ -283,7 +287,7 @@ ThemeManager::basic_color_button_press_event (GdkEventButton* ev) color_dialog.get_colorsel()->set_current_alpha ((guint16) (a * 65535.0)); color_dialog_connection.disconnect (); - color_dialog_connection = color_dialog.signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::basic_color_response), var)); + color_dialog_connection = color_dialog.signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ThemeManager::basic_color_response), color_name)); color_dialog.present (); } } @@ -292,7 +296,7 @@ ThemeManager::basic_color_button_press_event (GdkEventButton* ev) } void -ThemeManager::basic_color_response (int result, ColorVariable* color_variable) +ThemeManager::basic_color_response (int result, string name) { Gdk::Color color; double a; @@ -307,14 +311,10 @@ ThemeManager::basic_color_response (int result, ColorVariableget_current_color(); a = color_dialog.get_colorsel()->get_current_alpha() / 65535.0; - color_variable->set (ArdourCanvas::rgba_to_color (color.get_red_p(), - color.get_green_p(), - color.get_blue_p(), - a)); - setup_basic_color_display (); - setup_palette (); - setup_aliases (); - ColorsChanged(); //EMIT SIGNAL + ARDOUR_UI::config()->set_base (name, ArdourCanvas::rgba_to_color (color.get_red_p(), + color.get_green_p(), + color.get_blue_p(), + a)); break; default: @@ -329,7 +329,6 @@ void ThemeManager::on_flat_buttons_toggled () { ARDOUR_UI::config()->set_flat_buttons (flat_buttons.get_active()); - ARDOUR_UI::config()->set_dirty (); ArdourButton::set_flat_buttons (flat_buttons.get_active()); /* force a redraw */ gtk_rc_reset_styles (gtk_settings_get_default()); @@ -339,7 +338,6 @@ void ThemeManager::on_blink_rec_arm_toggled () { ARDOUR_UI::config()->set_blink_rec_arm (blink_rec_button.get_active()); - ARDOUR_UI::config()->set_dirty (); ARDOUR::Config->ParameterChanged("blink-rec-arm"); } @@ -347,21 +345,18 @@ void ThemeManager::on_region_color_toggled () { ARDOUR_UI::config()->set_color_regions_using_track_color (region_color_button.get_active()); - ARDOUR_UI::config()->set_dirty (); } void ThemeManager::on_show_clip_toggled () { ARDOUR_UI::config()->set_show_waveform_clipping (show_clipping_button.get_active()); - ARDOUR_UI::config()->set_dirty (); } void ThemeManager::on_all_dialogs_toggled () { ARDOUR_UI::config()->set_all_floating_windows_are_dialogs (all_dialogs.get_active()); - ARDOUR_UI::config()->set_dirty (); } void @@ -370,7 +365,6 @@ ThemeManager::on_waveform_gradient_depth_change () double v = waveform_gradient_depth.get_value(); ARDOUR_UI::config()->set_waveform_gradient_depth (v); - ARDOUR_UI::config()->set_dirty (); ArdourCanvas::WaveView::set_global_gradient_depth (v); } @@ -380,7 +374,6 @@ ThemeManager::on_timeline_item_gradient_depth_change () double v = timeline_item_gradient_depth.get_value(); ARDOUR_UI::config()->set_timeline_item_gradient_depth (v); - ARDOUR_UI::config()->set_dirty (); } void @@ -397,7 +390,7 @@ ThemeManager::on_dark_theme_button_toggled() UIConfiguration* uic (ARDOUR_UI::config()); - uic->set_ui_rc_file("ui_dark.rc"); + uic->set_color_file("dark"); } void @@ -407,7 +400,7 @@ ThemeManager::on_light_theme_button_toggled() UIConfiguration* uic (ARDOUR_UI::config()); - uic->set_ui_rc_file("ui_light.rc"); + uic->set_color_file("light"); } void @@ -419,10 +412,9 @@ ThemeManager::setup_basic_color_display () TreeModel::Row row; row = *(basic_color_list->append()); - row[basic_color_columns.name] = i->second->name(); - row[basic_color_columns.color_variable] = i->second; + row[basic_color_columns.name] = i->first; - ArdourCanvas::Color c = i->second->get(); + ArdourCanvas::Color c = i->second; /* Gdk colors don't support alpha */ @@ -448,7 +440,6 @@ ThemeManager::reset_canvas_colors() { ARDOUR_UI::config()->load_defaults(); setup_basic_color_display (); - ARDOUR_UI::config()->set_dirty (); ARDOUR_UI::config()->save_state (); } @@ -621,12 +612,7 @@ ThemeManager::palette_color_response (int result, std::string name) b = gdkcolor.get_blue_p(); rhsv = uic->color_as_relative_hsv (rgba_to_color (r, g, b, a)); - uic->reset_relative (name, rhsv); - - /* rebuild */ - - setup_palette (); - ColorsChanged(); //EMIT SIGNAL + uic->set_relative (name, rhsv); break; default: diff --git a/gtk2_ardour/theme_manager.h b/gtk2_ardour/theme_manager.h index 18044a7812..dee3f5d151 100644 --- a/gtk2_ardour/theme_manager.h +++ b/gtk2_ardour/theme_manager.h @@ -71,12 +71,10 @@ class ThemeManager : public ArdourWindow BasicColorDisplayModelColumns() { add (name); add (gdkcolor); - add (color_variable); } Gtk::TreeModelColumn name; Gtk::TreeModelColumn gdkcolor; - Gtk::TreeModelColumn *> color_variable; }; BasicColorDisplayModelColumns basic_color_columns; @@ -109,7 +107,7 @@ class ThemeManager : public ArdourWindow /* handles response from color dialog when it used to edit a basic color */ - void basic_color_response (int, ColorVariable*); + void basic_color_response (int, std::string); /* handls response from color dialog when it is used to edit a derived color. @@ -175,6 +173,8 @@ class ThemeManager : public ArdourWindow void setup_aliases (); void setup_palette (); + + void colors_changed (); }; #endif /* __ardour_gtk_color_manager_h__ */ diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index ece4d7ac50..e39336491f 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -64,22 +64,10 @@ UIConfiguration::UIConfiguration () #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE - /* initialize all the base colors using default - colors for now. these will be reset when/if - we load the UI config file. - */ - -#undef CANVAS_BASE_COLOR -#define CANVAS_BASE_COLOR(var,name,val) var (name,quantized (val)), -#include "base_colors.h" -#undef CANVAS_BASE_COLOR - _dirty (false), + base_modified (false), aliases_modified (false), - derived_modified (false), - _saved_state_node (""), - _saved_state_version (-1) - + derived_modified (false) { _instance = this; @@ -88,7 +76,7 @@ UIConfiguration::UIConfiguration () */ #undef CANVAS_BASE_COLOR -#define CANVAS_BASE_COLOR(var,name,color) base_colors.insert (make_pair (name,&var)); +#define CANVAS_BASE_COLOR(var,name,color) base_colors.insert (make_pair (name,color)); #include "base_colors.h" #undef CANVAS_BASE_COLOR @@ -110,7 +98,7 @@ UIConfiguration::UIConfiguration () /* force GTK theme setting, so that loading an RC file will work */ - reset_gtk_theme (); + load_color_theme (); } UIConfiguration::~UIConfiguration () @@ -120,8 +108,6 @@ UIConfiguration::~UIConfiguration () void UIConfiguration::colors_changed () { - _dirty = true; - reset_gtk_theme (); /* In theory, one of these ought to work: @@ -142,7 +128,12 @@ UIConfiguration::parameter_changed (string param) _dirty = true; if (param == "ui-rc-file") { - load_rc_file (get_ui_rc_file(), true); + load_rc_file (true); + } else if (param == "color-file") { + load_color_theme (); + } else if (param == "base-color") { /* one of many */ + base_modified = true; + ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ } save_state (); @@ -179,16 +170,16 @@ UIConfiguration::color_as_relative_hsv (Color c) double shortest_distance = DBL_MAX; string closest_name; - map*>::iterator f; + BaseColors::iterator f; std::map palette; 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 + we use to do comparisons (e.g. meter colors) */ if (f->first.find ("color") == 0) { - palette.insert (make_pair (f->first, HSV (f->second->get()))); + palette.insert (make_pair (f->first, HSV (f->second))); } } @@ -287,7 +278,6 @@ UIConfiguration::load_defaults () _dirty = false; - ARDOUR_UI_UTILS::ColorsChanged (); } else { warning << string_compose (_("Could not find default UI configuration file %1"), default_ui_config_file_name) << endmsg; } @@ -295,6 +285,76 @@ UIConfiguration::load_defaults () return found; } +int +UIConfiguration::load_color_theme () +{ + std::string cfile; + string basename = color_file.get(); + + basename += ".colors"; + + if (find_file (ardour_config_search_path(), basename, cfile)) { + XMLTree tree; + + info << string_compose (_("Loading color file %1"), cfile) << endmsg; + + if (!tree.read (cfile.c_str())) { + error << string_compose(_("cannot read color file \"%1\""), cfile) << endmsg; + return -1; + } + + if (set_state (*tree.root(), Stateful::loading_state_version)) { + error << string_compose(_("color file \"%1\" not loaded successfully."), cfile) << endmsg; + return -1; + } + + ARDOUR_UI_UTILS::ColorsChanged (); + } else { + warning << string_compose (_("Color file %1 not found"), basename) << endmsg; + } + + return 0; +} + +int +UIConfiguration::store_color_theme (string const& path) +{ + XMLNode* root; + LocaleGuard lg (X_("POSIX")); + + root = new XMLNode("Ardour"); + + 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); + + + 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); + + XMLTree tree; + + tree.set_root (root); + if (!tree.write (path.c_str())){ + error << string_compose (_("Color file %1 not saved"), path) << endmsg; + return -1; + } + + return 0; +} + int UIConfiguration::load_state () { @@ -317,8 +377,6 @@ UIConfiguration::load_state () error << string_compose(_("default ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; return -1; } - - /* make a copy */ } if (find_file (ardour_config_search_path(), ui_config_file_name, rcfile)) { @@ -344,32 +402,42 @@ UIConfiguration::load_state () error << _("could not find any ui configuration file, canvas will look broken.") << endmsg; } - ARDOUR_UI_UTILS::ColorsChanged (); - return 0; } int UIConfiguration::save_state() { - XMLTree tree; - if (!dirty()) { - return 0; - } - - std::string rcfile(user_config_directory()); - rcfile = Glib::build_filename (rcfile, ui_config_file_name); + if (_dirty) { + std::string rcfile = Glib::build_filename (user_config_directory(), ui_config_file_name); + + XMLTree tree; - if (rcfile.length()) { tree.set_root (&get_state()); + if (!tree.write (rcfile.c_str())){ error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg; return -1; } + + _dirty = false; } - _dirty = false; + if (base_modified || aliases_modified || derived_modified) { + std::string colorfile = Glib::build_filename (user_config_directory(), (color_file.get() + ".colors")); + + cerr << "Save colors to " << colorfile << endl; + if (store_color_theme (colorfile)) { + error << string_compose (_("Color file %1 not saved"), color_file.get()) << endmsg; + return -1; + } + + base_modified = false; + aliases_modified = false; + derived_modified = false; + } + return 0; } @@ -385,26 +453,6 @@ UIConfiguration::get_state () root->add_child_nocopy (get_variables ("UI")); root->add_child_nocopy (get_variables ("Canvas")); - 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); - - - 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); } @@ -435,6 +483,8 @@ UIConfiguration::get_variables (std::string which_node) int UIConfiguration::set_state (const XMLNode& root, int /*version*/) { + /* this can load a generic UI configuration file or a colors file */ + if (root.name() != "Ardour") { return -1; } @@ -455,6 +505,13 @@ UIConfiguration::set_state (const XMLNode& root, int /*version*/) } } + XMLNode* base = find_named_node (root, X_("BaseColors")); + + if (base) { + load_base_colors (*base); + } + + XMLNode* relative = find_named_node (root, X_("RelativeColors")); if (relative) { @@ -471,6 +528,12 @@ UIConfiguration::set_state (const XMLNode& root, int /*version*/) return 0; } +void +UIConfiguration::load_base_colors (XMLNode const &) +{ + +} + void UIConfiguration::load_color_aliases (XMLNode const & node) { @@ -531,35 +594,15 @@ UIConfiguration::set_variables (const XMLNode& node) #include "canvas_vars.h" #undef UI_CONFIG_VARIABLE #undef CANVAS_FONT_VARIABLE - - /* Reset base colors */ - -#undef CANVAS_BASE_COLOR -#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 - -} - -void -UIConfiguration::set_dirty () -{ - _dirty = true; -} - -bool -UIConfiguration::dirty () const -{ - return _dirty || aliases_modified || derived_modified; } ArdourCanvas::Color UIConfiguration::base_color_by_name (const std::string& name) const { - map* >::const_iterator i = base_colors.find (name); + BaseColors::const_iterator i = base_colors.find (name); if (i != base_colors.end()) { - return i->second->get(); + return i->second; } cerr << string_compose (_("Base Color %1 not found"), name) << endl; @@ -620,7 +663,20 @@ UIConfiguration::quantized (Color c) const } void -UIConfiguration::reset_relative (const string& name, const RelativeHSV& rhsv) +UIConfiguration::set_base (string const& name, ArdourCanvas::Color color) +{ + BaseColors::iterator i = base_colors.find (name); + if (i == base_colors.end()) { + return; + } + i->second = color; + base_modified = true; + + ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ +} + +void +UIConfiguration::set_relative (const string& name, const RelativeHSV& rhsv) { RelativeColors::iterator i = relative_colors.find (name); @@ -632,8 +688,6 @@ UIConfiguration::reset_relative (const string& name, const RelativeHSV& rhsv) derived_modified = true; ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ - - save_state (); } void @@ -648,18 +702,17 @@ UIConfiguration::set_alias (string const & name, string const & alias) aliases_modified = true; ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */ - - save_state (); } void -UIConfiguration::load_rc_file (const string& filename, bool themechange) +UIConfiguration::load_rc_file (bool themechange) { + string basename = ui_rc_file.get(); std::string rc_file_path; - if (!find_file (ardour_config_search_path(), filename, rc_file_path)) { + if (!find_file (ardour_config_search_path(), basename, rc_file_path)) { warning << string_compose (_("Unable to find UI style file %1 in search path %2. %3 will look strange"), - filename, ardour_config_search_path().to_string(), PROGRAM_NAME) + basename, ardour_config_search_path().to_string(), PROGRAM_NAME) << endmsg; return; } diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h index bcfb1092e6..dc7d93e5e1 100644 --- a/gtk2_ardour/ui_config.h +++ b/gtk2_ardour/ui_config.h @@ -35,51 +35,6 @@ #include "utils.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 ColorVariable : public ARDOUR::ConfigVariableBase -{ - public: - 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) { - return false; - } - value = val; - return true; - } - - T get() const { - return value; - } - - std::string get_as_string () const { - std::stringstream ss; - ss << std::hex; - ss.fill('0'); - ss.width(8); - ss << value; - return ss.str (); - } - - void set_from_string (std::string const & s) { - std::stringstream ss; - ss << std::hex; - ss << s; - ss >> value; - } - - protected: - T get_for_save() { return value; } - T value; -}; - class UIConfiguration : public PBD::Stateful { public: @@ -93,21 +48,18 @@ class UIConfiguration : public PBD::Stateful double quantized_hue; ArdourCanvas::HSV get() const; -}; + }; UIConfiguration(); ~UIConfiguration(); static UIConfiguration* instance() { return _instance; } - bool dirty () const; - void set_dirty (); - int load_state (); int save_state (); int load_defaults (); - static void load_rc_file (std::string const &, bool themechange); + void load_rc_file (bool themechange); int set_state (const XMLNode&, int version); XMLNode& get_state (void); @@ -116,15 +68,15 @@ class UIConfiguration : public PBD::Stateful typedef std::map RelativeColors; typedef std::map ColorAliases; - typedef std::map *> BaseColors; + typedef std::map BaseColors; BaseColors base_colors; 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); + void set_relative (const std::string& name, const RelativeHSV& new_value); + void set_base (const std::string& name, ArdourCanvas::Color); RelativeHSV color_as_relative_hsv (ArdourCanvas::Color c); std::string color_as_alias (ArdourCanvas::Color c); @@ -153,9 +105,7 @@ class UIConfiguration : public PBD::Stateful #undef CANVAS_BASE_COLOR #define CANVAS_BASE_COLOR(var,name,val) \ - ArdourCanvas::Color get_##var() const { return var.get(); } \ - bool set_##var (ArdourCanvas::Color v) { bool ret = var.set (v); if (ret) { ParameterChanged (name); } return ret; } \ - bool set_##var(const ArdourCanvas::HSV& v) const { return set_##var (v.color()); } + ArdourCanvas::Color get_##var() const { return base_color_by_name (name); } #include "base_colors.h" #undef CANVAS_BASE_COLOR @@ -176,27 +126,21 @@ class UIConfiguration : public PBD::Stateful #include "canvas_vars.h" #undef CANVAS_FONT_VARIABLE - /* declare base color variables (these are modifiable by the user) */ - -#undef CANVAS_BASE_COLOR -#define CANVAS_BASE_COLOR(var,name,val) ColorVariable var; -#include "base_colors.h" -#undef CANVAS_BASE_COLOR - XMLNode& state (); bool _dirty; + bool base_modified; bool aliases_modified; bool derived_modified; static UIConfiguration* _instance; + int store_color_theme (std::string const &); + void load_base_colors (XMLNode const &); void load_color_aliases (XMLNode const &); void load_relative_colors (XMLNode const &); void reset_gtk_theme (); void colors_changed (); - - XMLNode _saved_state_node; - int _saved_state_version; + int load_color_theme (); }; std::ostream& operator<< (std::ostream& o, const UIConfiguration::RelativeHSV& rhsv); diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index 91bb75a761..b6e9595174 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -18,7 +18,8 @@ */ UI_CONFIG_VARIABLE(std::string, icon_set, "icon-set", "default") -UI_CONFIG_VARIABLE(std::string, ui_rc_file, "ui-rc-file", "ui_dark.rc") +UI_CONFIG_VARIABLE(std::string, ui_rc_file, "ui-rc-file", "clearlooks.rc") +UI_CONFIG_VARIABLE(std::string, color_file, "color-file", "dark") UI_CONFIG_VARIABLE(bool, flat_buttons, "flat-buttons", false) UI_CONFIG_VARIABLE(bool, blink_rec_arm, "blink-rec-arm", false) UI_CONFIG_VARIABLE(float, waveform_gradient_depth, "waveform-gradient-depth", 0) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index ab04d7b7d3..f9c0ba6c5c 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -650,6 +650,7 @@ def build(bld): obj.install_path = bld.env['CONFDIR'] # not modified at present + bld.install_files(bld.env['CONFDIR'], 'dark.colors') bld.install_files(bld.env['CONFDIR'], 'step_editing.bindings') bld.install_files(bld.env['CONFDIR'], 'mixer.bindings') diff --git a/tools/linux_packaging/build b/tools/linux_packaging/build index f1bc92733d..116b20b468 100755 --- a/tools/linux_packaging/build +++ b/tools/linux_packaging/build @@ -537,21 +537,23 @@ find $APPLIB/ -name "*.so*" | xargs chmod a+rx echo "Copying other stuff to $APPDIR ..." # these are all generated by waf -#cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Etc cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Etc cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Etc -cp ../../system_config $Etc/system_config cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Etc cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Etc -# these are copied straight from the source tree +# Copied directly from source tree -cp ../../instant.xml $Etc/instant.xml -cp ../../gtk2_ardour/step_editing.bindings $Etc -cp ../../gtk2_ardour/mixer.bindings $Etc +cp ../../system_config $Etc/system_config +cp ../../gtk2_ardour/dark.colors $Etc +cp ../../instant.xml $Shared/instant.xml +cp ../../gtk2_ardour/step_editing.bindings $Shared +cp ../../gtk2_ardour/mixer.bindings $Shared cp -r ../../gtk2_ardour/icons $Shared cp -r ../../gtk2_ardour/pixmaps $Shared - +cp -r ../../gtk2_ardour/splash.png $Shared +cp -r ../../gtk2_ardour/small-splash.png $Shared +cp -r ../../gtk2_ardour/ArdourMono.ttf $Shared # # put sooper sekrit ingredients here and they will be copied @@ -561,12 +563,6 @@ if [ -d specialSauce ] ; then cp -r specialSauce $Etc fi -# share stuff - -cp -R ../../gtk2_ardour/splash.png $Shared -cp -R ../../gtk2_ardour/small-splash.png $Shared -cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared - # install bundled LV2s to /lib/LV2/ cp -R $BUILD_ROOT/libs/LV2 $APPLIB/ diff --git a/tools/osx_packaging/osx_build b/tools/osx_packaging/osx_build index 6bbf6176a0..81892ccc46 100755 --- a/tools/osx_packaging/osx_build +++ b/tools/osx_packaging/osx_build @@ -443,30 +443,19 @@ echo "Copying other stuff to $APPDIR ..." #cp $BUILD_ROOT/gtk2_ardour/ergonomic-us.bindings $Resources cp $BUILD_ROOT/gtk2_ardour/mnemonic-us.bindings $Resources -cp ../../gtk2_ardour/mixer.bindings $Resources -cp ../../gtk2_ardour/step_editing.bindings $Resources cp $BUILD_ROOT/gtk2_ardour/ardour.menus $Resources - -if test x$SAE != x ; then - cp $BUILD_ROOT/gtk2_ardour/SAE-de-keypad.bindings $Resources - cp $BUILD_ROOT/gtk2_ardour/SAE-de-nokeypad.bindings $Resources - cp $BUILD_ROOT/gtk2_ardour/SAE-us-keypad.bindings $Resources - cp $BUILD_ROOT/gtk2_ardour/SAE-us-nokeypad.bindings $Resources - cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml - echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml -else - cp ../../system_config $Resources/system_config - cp ../../instant.xml $Resources/instant.xml - echo cp ../../instant.xml $Resources/instant.xml -fi cp $BUILD_ROOT/gtk2_ardour/default_ui_config $Resources cp $BUILD_ROOT/gtk2_ardour/clearlooks.rc $Resources +# Copied directly from source tree +cp ../../system_config $Resources/system_config +cp ../../instant.xml $Resources/instant.xml +cp ../../gtk2_ardour/step_editing.bindings $Resources +cp ../../gtk2_ardour/mixer.bindings $Resources cp -r ../../gtk2_ardour/icons $Resources cp -r ../../gtk2_ardour/pixmaps $Resources - -# shared stuff +cp ../../gtk2_ardour/dark.colors $Resources cp -R ../../gtk2_ardour/splash.png $Shared cp -R ../../gtk2_ardour/small-splash.png $Shared cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared -- 2.30.2