X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fwidget_coloredit.cpp;h=fc87e3c247f46d1e455d1fa1d7836c75a12562cb;hb=b91eda58d66676742f25df2d277c04d8341033b3;hp=282c4930810312fece38d015ddbfce8c6a769c61;hpb=c34eaa5441242b3e9a7b7645e9ee4983d14eae85;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/widget_coloredit.cpp b/synfig-studio/trunk/src/gtkmm/widget_coloredit.cpp index 282c493..fc87e3c 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_coloredit.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_coloredit.cpp @@ -2,7 +2,7 @@ /*! \file widget_coloredit.cpp ** \brief Template File ** -** $Id: widget_coloredit.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley @@ -50,11 +50,6 @@ using namespace studio; /* === M A C R O S ========================================================= */ -#define use_colorspace_gamma() App::use_colorspace_gamma -#define colorspace_gamma() (2.2f) -#define gamma_in(x) ((x>=0)?pow((float)x,1.0f/colorspace_gamma()):-pow((float)-x,1.0f/colorspace_gamma())) -#define gamma_out(x) ((x>=0)?pow((float)x,colorspace_gamma()):-pow((float)-x,colorspace_gamma())) - /* === G L O B A L S ======================================================= */ /* === P R O C E D U R E S ================================================= */ @@ -114,7 +109,7 @@ ColorSlider::adjust_color(Type type, Color &color, float amount) } bool -ColorSlider::redraw(GdkEventExpose*bleh) +ColorSlider::redraw(GdkEventExpose */*bleh*/) { Color color(color_); @@ -162,38 +157,18 @@ ColorSlider::redraw(GdkEventExpose*bleh) int i; for(i=width-1;i>=0;i--) { - color_func(color,float(i)/float(width)); + color_func(color,gamma_out(float(i)/float(width))); const Color c1(Color::blend(color,bg1,1.0).clamped()); const Color c2(Color::blend(color,bg2,1.0).clamped()); assert(c1.is_valid()); assert(c2.is_valid()); - gushort r1; - gushort g1; - gushort b1; - gushort r2; - gushort g2; - gushort b2; - - if(use_colorspace_gamma() && (typeset_use_markup(false); + hex_color_label->set_use_underline(false); + hex_color_label->set_attributes(attr_list); + table->attach(*hex_color_label, 0, 1, 7, 8, Gtk::SHRINK, Gtk::SHRINK, 0, 0); + + hex_color = manage(new Gtk::Entry()); + hex_color->set_width_chars(8); + hex_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_hex_edited)); + table->attach(*hex_color, 0, 1, 8, 9, Gtk::SHRINK, Gtk::SHRINK, 0, 0); } { Gtk::Table* table(yuv_table); @@ -408,6 +394,16 @@ Widget_ColorEdit::on_slider_moved(ColorSlider::Type type, float amount) } void +Widget_ColorEdit::on_hex_edited() +{ + Color color(get_value_raw()); + String s = hex_color->get_text(); + color.set_hex(s); + set_value(color); + signal_value_changed_(); +} + +void Widget_ColorEdit::on_value_changed() { if(hold_signals) @@ -424,6 +420,7 @@ Widget_ColorEdit::on_value_changed() slider_HUE->set_color(color); slider_SAT->set_color(color); slider_A->set_color(color); + hex_color->set_text(color.get_hex()); widget_color.set_value(color); activate(); @@ -488,6 +485,7 @@ Widget_ColorEdit::set_value(const synfig::Color &data) slider_HUE->set_color(color); slider_SAT->set_color(color); slider_A->set_color(color); + hex_color->set_text(color.get_hex()); widget_color.set_value(color); hold_signals=false; @@ -502,14 +500,12 @@ Widget_ColorEdit::get_value_raw() color.set_r(gamma_out(R_adjustment.get_value()/100.0f)); color.set_g(gamma_out(G_adjustment.get_value()/100.0f)); color.set_b(gamma_out(B_adjustment.get_value()/100.0f)); - assert(color.is_valid()); } else { color.set_r(R_adjustment.get_value()/100); color.set_g(G_adjustment.get_value()/100); color.set_b(B_adjustment.get_value()/100); - assert(color.is_valid()); } color.set_a(A_adjustment.get_value()/100); assert(color.is_valid());