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