diff options
author | Robin Gareus <robin@gareus.org> | 2017-03-11 02:23:34 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-03-11 02:23:34 +0100 |
commit | 0a87fbe820385308fea2857e3caf434d64508bf0 (patch) | |
tree | 088e8dc52872a8733643621ae8d02f593f2004ed | |
parent | d0fc7d37ab74cc90ed42d021864c4f3ee4cc7088 (diff) |
Allow to customize color-picker-palette
-rw-r--r-- | gtk2_ardour/stripable_colorpicker.cc | 31 | ||||
-rw-r--r-- | gtk2_ardour/stripable_colorpicker.h | 6 | ||||
-rw-r--r-- | gtk2_ardour/ui_config_vars.h | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/gtk2_ardour/stripable_colorpicker.cc b/gtk2_ardour/stripable_colorpicker.cc index 6f89e615f3..a7db947df8 100644 --- a/gtk2_ardour/stripable_colorpicker.cc +++ b/gtk2_ardour/stripable_colorpicker.cc @@ -20,13 +20,18 @@ #include "pbd/i18n.h" #include "stripable_colorpicker.h" +#include "ui_config.h" #include "utils.h" using namespace Gtk; using namespace ARDOUR_UI_UTILS; +bool StripableColorDialog::palette_initialized = false; +Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook; + StripableColorDialog::StripableColorDialog () { + initialize_color_palette (); signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit)); } @@ -36,6 +41,32 @@ StripableColorDialog::~StripableColorDialog () } void +StripableColorDialog::palette_changed_hook (const Glib::RefPtr<Gdk::Screen>& s, const Gdk::ArrayHandle_Color& c) +{ + std::string p = std::string (ColorSelection::palette_to_string (c)); + UIConfiguration::instance ().set_stripable_color_palette (p); + gtk_palette_changed_hook (s, c); +} + +void +StripableColorDialog::initialize_color_palette () +{ + // non-static member, because it needs a screen() + if (palette_initialized) { + return; + } + gtk_palette_changed_hook = + get_colorsel()->set_change_palette_hook (&StripableColorDialog::palette_changed_hook); + + std::string cp = UIConfiguration::instance ().get_stripable_color_palette (); + if (!cp.empty()) { + Gdk::ArrayHandle_Color c = ColorSelection::palette_from_string (cp); + gtk_palette_changed_hook (get_screen (), c); + } + palette_initialized = true; +} + +void StripableColorDialog::reset () { hide (); diff --git a/gtk2_ardour/stripable_colorpicker.h b/gtk2_ardour/stripable_colorpicker.h index 79b7ffcf62..d05d67e974 100644 --- a/gtk2_ardour/stripable_colorpicker.h +++ b/gtk2_ardour/stripable_colorpicker.h @@ -32,9 +32,15 @@ public: void popup (boost::shared_ptr<ARDOUR::Stripable> s); private: + void initialize_color_palette (); void finish_color_edit (int response); boost::shared_ptr<ARDOUR::Stripable> _stripable; + + + static bool palette_initialized; + static void palette_changed_hook (const Glib::RefPtr<Gdk::Screen>&, const Gdk::ArrayHandle_Color&); + static Gtk::ColorSelection::SlotChangePaletteHook gtk_palette_changed_hook; }; #endif diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index d72bea3874..fc868978f6 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -92,3 +92,4 @@ UI_CONFIG_VARIABLE (bool, show_inline_display_by_default, "show-inline-display-b UI_CONFIG_VARIABLE (bool, prefer_inline_over_gui, "prefer-inline-over-gui", true) UI_CONFIG_VARIABLE (uint32_t, action_table_columns, "action-table-columns", 0) UI_CONFIG_VARIABLE (bool, use_wm_visibility, "use-wm-visibility", true) +UI_CONFIG_VARIABLE (std::string, stripable_color_palette, "stripable-color-palette", "#7F7F7F:#FF0000:#800080:#0000FF:#ADD8E6:#008000:#FFFF00:#FFA500:#E6E6FA:#A52A2A:#8B6914:#1E90FF:#FFC0CB:#90EE90:#1A1A1A:#4D4D4D:#BFBFBF:#E5E5E5:#AAAAAA:#444444") /* Gtk::ColorSelection::palette_to_string */ |