synfig-studio  1.0.3
widget_coloredit.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
21 /* ========================================================================= */
22 
23 /* === S T A R T =========================================================== */
24 
25 #ifndef __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
26 #define __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
27 
28 /* === H E A D E R S ======================================================= */
29 
30 #include <gtkmm/box.h>
31 #include <gtkmm/table.h>
32 #include <gtkmm/spinbutton.h>
33 #include <gtkmm/adjustment.h>
34 #include <gtkmm/drawingarea.h>
35 #include <gtkmm/colorselection.h>
36 #include <synfig/color.h>
37 #include <synfig/gamma.h>
38 #include "widgets/widget_color.h"
39 
40 /* === M A C R O S ========================================================= */
41 
42 /* === T Y P E D E F S ===================================================== */
43 
44 /* === C L A S S E S & S T R U C T S ======================================= */
45 
46 namespace Gtk {
47  class Notebook;
48 };
49 
50 namespace studio {
51 
52 class ColorSlider : public Gtk::DrawingArea
53 {
54 public:
55  enum Type
56  {
66 
68  };
69 
70 private:
71 
72  sigc::signal<void,Type,float> signal_slider_moved_;
73  sigc::signal<void> signal_activated_;
74 
75  Type type;
76  synfig::Color color_, orig_color;
77 
78 public:
79 
80  sigc::signal<void,Type,float>& signal_slider_moved() { return signal_slider_moved_; }
81  sigc::signal<void>& signal_activated() { return signal_activated_; }
82 
83  Type
84  get_type()const { return type; }
85 
86  const synfig::Color&
87  get_color()const { return color_; }
88 
89 
90  ColorSlider(const Type &x=TYPE_Y);
91 
92  void
93  set_type(Type x);
94 
95  void
96  set_color(synfig::Color x);
97 
98  static void adjust_color(Type type, synfig::Color &color, float amount);
99 
100 private:
101  typedef void (*slider_color_func)(synfig::Color &,float);
102 
103  static void slider_color_TYPE_R(synfig::Color &color, float amount);
104  static void slider_color_TYPE_G(synfig::Color &color, float amount);
105  static void slider_color_TYPE_B(synfig::Color &color, float amount);
106  static void slider_color_TYPE_Y(synfig::Color &color, float amount);
107  static void slider_color_TYPE_U(synfig::Color &color, float amount);
108  static void slider_color_TYPE_V(synfig::Color &color, float amount);
109  static void slider_color_TYPE_HUE(synfig::Color &color, float amount);
110  static void slider_color_TYPE_SAT(synfig::Color &color, float amount);
111  static void slider_color_TYPE_A(synfig::Color &color, float amount);
112 
113  bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
114  bool on_event(GdkEvent *event);
115 
117  void draw_arrow(
118  const Cairo::RefPtr<Cairo::Context> &cr,
119  double x, double y,
120  double width, double height,
121  int size,
122  bool fill);
123 }; // END of class ColorSlider
124 
125 
126 class Widget_ColorEdit : public Gtk::Table
127 {
128  sigc::signal<void> signal_activated_;
129  sigc::signal<void> signal_value_changed_;
130 
131  ColorSlider *slider_R;
132  ColorSlider *slider_G;
133  ColorSlider *slider_B;
134  Gtk::Label *hex_color_label;
135  Gtk::Entry *hex_color;
136 
137  ColorSlider *slider_A;
138  ColorSlider *slider_Y;
139  ColorSlider *slider_U;
140  ColorSlider *slider_V;
141  ColorSlider *slider_SAT;
142  ColorSlider *slider_HUE;
143 
144  Widget_Color widget_color;
145 
146  bool hold_signals;
147 
148  bool clamp_;
149 
150  Gtk::SpinButton *spinbutton_R;
151  Gtk::SpinButton *spinbutton_G;
152  Gtk::SpinButton *spinbutton_B;
153  Gtk::SpinButton *spinbutton_A;
154 
155  Gtk::ColorSelection * hvsColorWidget;
156 
157  Glib::RefPtr<Gtk::Adjustment> R_adjustment;
158  Glib::RefPtr<Gtk::Adjustment> G_adjustment;
159  Glib::RefPtr<Gtk::Adjustment> B_adjustment;
160  Glib::RefPtr<Gtk::Adjustment> A_adjustment;
161 
162  synfig::Color color;
163 
164  Gtk::Notebook* notebook;
165 
166  static synfig::Gamma hvs_gamma;
167  static synfig::Gamma hvs_gamma_in;
168 
169 protected:
170 
171  void on_value_changed();
172 
173 public:
174 
175  sigc::signal<void>& signal_activated() { return signal_activated_; }
176 
177  sigc::signal<void>& signal_activate() { return signal_activated_; }
178 
179  void on_slider_moved(ColorSlider::Type type, float amount);
180  void on_hex_edited();
181  bool on_hex_focus_out(GdkEventFocus* event);
182 
183  //Glib::SignalProxy0<void> signal_activate() { return spinbutton_A->signal_activate(); }
184 
185  sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
186 
187  void on_color_changed();
188 
189  void activated() { signal_activated_(); }
190  void activate() { signal_activated_(); }
191  void set_value(const synfig::Color &data);
192  const synfig::Color &get_value();
193  synfig::Color get_value_raw();
194  void set_has_frame(bool x);
195  void set_digits(int x);
198 
199 private:
200  bool colorHVSChanged; //Spike. Look more in the code.
202  void setHVSColor(synfig::Color color);
204  void SliderRow(int i,ColorSlider * n, char * l, Pango::AttrList & attr_list, Gtk::Table* table);
206  void AttachSpinButton(int i, Gtk::SpinButton * n, Gtk::Table * table);
207 
208 }; // END of class Widget_ColorEdit
209 
210 }; // END of namespace studio
211 
212 /* === E N D =============================================================== */
213 
214 #endif