13
0

Allow to customize color-picker-palette

This commit is contained in:
Robin Gareus 2017-03-11 02:23:34 +01:00
parent d0fc7d37ab
commit 0a87fbe820
3 changed files with 38 additions and 0 deletions

View File

@ -20,13 +20,18 @@
#include "pbd/i18n.h" #include "pbd/i18n.h"
#include "stripable_colorpicker.h" #include "stripable_colorpicker.h"
#include "ui_config.h"
#include "utils.h" #include "utils.h"
using namespace Gtk; using namespace Gtk;
using namespace ARDOUR_UI_UTILS; using namespace ARDOUR_UI_UTILS;
bool StripableColorDialog::palette_initialized = false;
Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook;
StripableColorDialog::StripableColorDialog () StripableColorDialog::StripableColorDialog ()
{ {
initialize_color_palette ();
signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit)); signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
} }
@ -35,6 +40,32 @@ StripableColorDialog::~StripableColorDialog ()
reset (); reset ();
} }
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 void
StripableColorDialog::reset () StripableColorDialog::reset ()
{ {

View File

@ -32,9 +32,15 @@ public:
void popup (boost::shared_ptr<ARDOUR::Stripable> s); void popup (boost::shared_ptr<ARDOUR::Stripable> s);
private: private:
void initialize_color_palette ();
void finish_color_edit (int response); void finish_color_edit (int response);
boost::shared_ptr<ARDOUR::Stripable> _stripable; 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 #endif

View File

@ -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 (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 (uint32_t, action_table_columns, "action-table-columns", 0)
UI_CONFIG_VARIABLE (bool, use_wm_visibility, "use-wm-visibility", true) 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 */