86d96945e64644154aa091578e4c4ddbe14ab28d
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_setup.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dialog_setup.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_STUDIO_DIALOG_SETUP_H
26 #define __SYNFIG_STUDIO_DIALOG_SETUP_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <gtk/gtk.h>
31 #include <gtkmm/adjustment.h>
32 #include <gtkmm/table.h>
33 #include <gtkmm/button.h>
34 #include <gtkmm/dialog.h>
35 #include <gtkmm/drawingarea.h>
36 #include <gtkmm/optionmenu.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/widget_time.h>
39
40 #include <synfig/gamma.h>
41 #include <synfig/time.h>
42 #include <algorithm>
43
44 /* === M A C R O S ========================================================= */
45
46 /* === T Y P E D E F S ===================================================== */
47
48 /* === C L A S S E S & S T R U C T S ======================================= */
49
50 namespace Gtk { class Menu; };
51
52 namespace studio {
53
54 class GammaPattern : public Gtk::DrawingArea
55 {
56         float gamma_r;
57         float gamma_g;
58         float gamma_b;
59         float black_level;
60         float red_blue_level;
61
62         int tile_w, tile_h;
63
64         Gdk::Color black[4],white[4],gray50[4],gray25[4];
65
66         float r_F32_to_F32(float x)const { float f((pow(x,gamma_r)*std::min(red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
67         float g_F32_to_F32(float x)const { float f((pow(x,gamma_g)*sqrt(std::min(2.0f-red_blue_level,red_blue_level))*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
68         float b_F32_to_F32(float x)const { float f((pow(x,gamma_b)*std::min(2.0f-red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
69
70 public:
71
72         void refresh();
73
74         void set_gamma_r(float x) { gamma_r=x; }
75         void set_gamma_g(float x) { gamma_g=x; };
76         void set_gamma_b(float x) { gamma_b=x; };
77         void set_black_level(float x) { black_level=x; };
78         void set_red_blue_level(float x) { red_blue_level=x; };
79
80         float get_gamma_r()const { return gamma_r; }
81         float get_gamma_g()const { return gamma_g; }
82         float get_gamma_b()const { return gamma_b; }
83         float get_black_level()const { return black_level; }
84         float get_red_blue_level()const { return red_blue_level; }
85
86         GammaPattern();
87
88         ~GammaPattern();
89
90         bool redraw(GdkEventExpose*bleh=NULL);
91 }; // END of class GammaPattern
92
93 class BlackLevelSelector : public Gtk::DrawingArea
94 {
95         float level;
96
97         sigc::signal<void> signal_value_changed_;
98
99 public:
100
101         BlackLevelSelector();
102
103         ~BlackLevelSelector();
104
105         sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
106
107         void set_value(float x) { level=x; queue_draw(); }
108
109         const float &get_value()const { return level; }
110
111         bool redraw(GdkEventExpose*bleh=NULL);
112
113         bool on_event(GdkEvent *event);
114 }; // END of class BlackLevelSelector
115
116 class RedBlueLevelSelector : public Gtk::DrawingArea
117 {
118         float level;
119
120         sigc::signal<void> signal_value_changed_;
121
122 public:
123
124         RedBlueLevelSelector();
125
126         ~RedBlueLevelSelector();
127
128         sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
129
130         void set_value(float x) { level=x; queue_draw(); }
131
132         const float &get_value()const { return level; }
133
134         bool redraw(GdkEventExpose*bleh=NULL);
135
136         bool on_event(GdkEvent *event);
137 }; // END of class RedBlueSelector
138
139 class Widget_Enum;
140
141 class Dialog_Setup : public Gtk::Dialog
142 {
143
144         void on_ok_pressed();
145         void on_apply_pressed();
146
147         void on_gamma_r_change();
148         void on_gamma_g_change();
149         void on_gamma_b_change();
150         void on_black_level_change();
151         void on_red_blue_level_change();
152
153         GammaPattern gamma_pattern;
154         BlackLevelSelector black_level_selector;
155         RedBlueLevelSelector red_blue_level_selector;
156         Gtk::OptionMenu timestamp_optionmenu;
157
158         Gtk::Adjustment adj_gamma_r;
159         Gtk::Adjustment adj_gamma_g;
160         Gtk::Adjustment adj_gamma_b;
161
162         Gtk::Adjustment adj_recent_files;
163         Gtk::Adjustment adj_undo_depth;
164
165         Gtk::CheckButton toggle_use_colorspace_gamma;
166         Gtk::CheckButton toggle_single_threaded;
167
168         synfig::Time::Format time_format;
169
170         Gtk::Menu *timestamp_menu;
171         Widget_Enum *widget_enum;
172
173         Widget_Time auto_backup_interval;
174
175         Gtk::CheckButton toggle_restrict_radius_ducks;
176 public:
177
178         void set_time_format(synfig::Time::Format time_format);
179
180         const synfig::Time::Format& get_time_format()const { return time_format; }
181
182         Dialog_Setup();
183         ~Dialog_Setup();
184
185     void refresh();
186
187 }; // END of Dialog_Waypoint
188
189 }; // END of namespace studio
190
191 /* === E N D =============================================================== */
192
193 #endif