mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-26 06:58:22 +01:00
introduce ArdourColorDialog, a Gtk::ColorSelectionDialog with a palette
This commit is contained in:
parent
e6bf82f37f
commit
4aeba817b9
2 changed files with 52 additions and 40 deletions
|
|
@ -31,20 +31,52 @@
|
|||
|
||||
using namespace Gtk;
|
||||
|
||||
bool StripableColorDialog::palette_initialized = false;
|
||||
Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook;
|
||||
bool ArdourColorDialog::palette_initialized = false;
|
||||
Gtk::ColorSelection::SlotChangePaletteHook ArdourColorDialog::gtk_palette_changed_hook;
|
||||
|
||||
ArdourColorDialog::ArdourColorDialog ()
|
||||
{
|
||||
initialize_color_palette ();
|
||||
get_color_selection()->set_has_opacity_control (false);
|
||||
get_color_selection()->set_has_palette (true);
|
||||
}
|
||||
|
||||
void
|
||||
ArdourColorDialog::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
|
||||
ArdourColorDialog::initialize_color_palette ()
|
||||
{
|
||||
// non-static member, because it needs a screen()
|
||||
if (palette_initialized) {
|
||||
return;
|
||||
}
|
||||
gtk_palette_changed_hook = get_color_selection()->set_change_palette_hook (&ArdourColorDialog::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;
|
||||
}
|
||||
|
||||
/* ---------- */
|
||||
|
||||
StripableColorDialog::StripableColorDialog (std::shared_ptr<ARDOUR::Stripable> s)
|
||||
{
|
||||
assert (s);
|
||||
|
||||
initialize_color_palette ();
|
||||
signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
|
||||
|
||||
_stripable = s;
|
||||
_stripable->set_active_color_picker (this);
|
||||
_stripable->DropReferences.connect (_connections, invalidator (*this), [this]() { delete this; }, gui_context ());
|
||||
|
||||
signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
|
||||
}
|
||||
|
||||
StripableColorDialog::~StripableColorDialog ()
|
||||
|
|
@ -56,31 +88,6 @@ StripableColorDialog::~StripableColorDialog ()
|
|||
_color_changed_connection.disconnect ();
|
||||
}
|
||||
|
||||
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_color_selection()->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::popup (Gtk::Window* parent)
|
||||
{
|
||||
|
|
@ -122,9 +129,6 @@ StripableColorDialog::popup (const std::string& name, uint32_t color, Gtk::Windo
|
|||
|
||||
Gtk::ColorSelection* color_selection (get_color_selection());
|
||||
|
||||
color_selection->set_has_opacity_control (false);
|
||||
color_selection->set_has_palette (true);
|
||||
|
||||
Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba (_initial_color);
|
||||
|
||||
color_selection->set_previous_color (c);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,23 @@
|
|||
#include "ardour/presentation_info.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
class Stripable;
|
||||
class Stripable;
|
||||
}
|
||||
|
||||
class StripableColorDialog : public Gtk::ColorSelectionDialog
|
||||
class ArdourColorDialog : public Gtk::ColorSelectionDialog
|
||||
{
|
||||
public:
|
||||
ArdourColorDialog ();
|
||||
|
||||
private:
|
||||
void initialize_color_palette ();
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class StripableColorDialog : public ArdourColorDialog
|
||||
{
|
||||
public:
|
||||
StripableColorDialog (std::shared_ptr<ARDOUR::Stripable>);
|
||||
|
|
@ -38,7 +51,6 @@ public:
|
|||
sigc::signal<void, uint32_t> ColorChanged;
|
||||
|
||||
private:
|
||||
void initialize_color_palette ();
|
||||
void finish_color_edit (int response);
|
||||
void color_changed ();
|
||||
void popup (const std::string& name, uint32_t color, Gtk::Window* parent);
|
||||
|
|
@ -48,8 +60,4 @@ private:
|
|||
|
||||
sigc::connection _color_changed_connection;
|
||||
PBD::ScopedConnectionList _connections;
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue