From c30255b1eb705a49ad4e4c7425789d8d17d56caa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 20 Aug 2009 15:30:18 +0200 Subject: [PATCH] Use Gtk::ColorSelectionDialog instead of custom color edit widget. --- synfig-studio/src/gtkmm/dialog_color.cpp | 18 ++++++++++++++++-- synfig-studio/src/gtkmm/dialog_color.h | 7 ++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/synfig-studio/src/gtkmm/dialog_color.cpp b/synfig-studio/src/gtkmm/dialog_color.cpp index 6953a75..9d984cf 100644 --- a/synfig-studio/src/gtkmm/dialog_color.cpp +++ b/synfig-studio/src/gtkmm/dialog_color.cpp @@ -80,8 +80,9 @@ Dialog_Color::~Dialog_Color() void Dialog_Color::create_color_edit_widget() { - color_edit_widget = manage(new Widget_ColorEdit()); - color_edit_widget->signal_value_changed().connect(sigc::mem_fun(*this, + color_edit_widget = manage(new Gtk::ColorSelection()); + color_edit_widget->set_has_opacity_control(true); + color_edit_widget->signal_color_changed().connect(sigc::mem_fun(*this, &studio::Dialog_Color::on_color_changed)); get_vbox()->pack_start(*color_edit_widget); } @@ -149,6 +150,19 @@ Dialog_Color::on_close_pressed() } void +Dialog_Color::set_color(const synfig::Color& color) +{ + color_edit_widget->set_current_color(studio::colorconv_synfig2gdk(color)); + color_edit_widget->set_current_alpha(color.get_a()); +} + +synfig::Color +Dialog_Color::get_color() const +{ + return studio::colorconv_gdk2synfig(color_edit_widget->get_current_color(), color_edit_widget->get_current_alpha() / 65535.0); +} + +void Dialog_Color::reset() { signal_edited_.clear(); diff --git a/synfig-studio/src/gtkmm/dialog_color.h b/synfig-studio/src/gtkmm/dialog_color.h index ee350cf..6e4163f 100644 --- a/synfig-studio/src/gtkmm/dialog_color.h +++ b/synfig-studio/src/gtkmm/dialog_color.h @@ -28,6 +28,7 @@ /* === H E A D E R S ======================================================= */ #include +#include #include #include #include @@ -50,7 +51,7 @@ class Dialog_Color : public Gtk::Dialog DialogSettings dialog_settings; Gtk::Tooltips tooltips; - Widget_ColorEdit* color_edit_widget; + Gtk::ColorSelection* color_edit_widget; sigc::signal signal_edited_; @@ -73,8 +74,8 @@ public: sigc::signal& signal_edited() { return signal_edited_; } - void set_color(const synfig::Color& x) { color_edit_widget->set_value(x); } - synfig::Color get_color() const { return color_edit_widget->get_value(); } + void set_color(const synfig::Color& x); + synfig::Color get_color() const; void reset(); bool busy() const { return busy_; } -- 2.7.4