Remove ancient trunk folder from svn repository
[synfig.git] / synfig-studio / 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, 2009 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 #include <gtkmm/spinbutton.h>
44
45 #include <synfig/gamma.h>
46 #include <synfig/time.h>
47 #include <algorithm>
48
49 /* === M A C R O S ========================================================= */
50 #ifndef DEFAULT_PREDEFINED_SIZE
51 #define DEFAULT_PREDEFINED_SIZE _("Custom Size")
52 #endif
53 #ifndef DEFAULT_PREDEFINED_FPS
54 #define DEFAULT_PREDEFINED_FPS _("Custom fps")
55 #endif
56
57 /* === T Y P E D E F S ===================================================== */
58
59 /* === C L A S S E S & S T R U C T S ======================================= */
60
61 namespace Gtk { class Menu; };
62
63 namespace studio {
64
65 class GammaPattern : public Gtk::DrawingArea
66 {
67         float gamma_r;
68         float gamma_g;
69         float gamma_b;
70         float black_level;
71         float red_blue_level;
72
73         int tile_w, tile_h;
74
75         Gdk::Color black[4],white[4],gray50[4],gray25[4];
76
77         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; }
78         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; }
79         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; }
80
81 public:
82
83         void refresh();
84
85         void set_gamma_r(float x) { gamma_r=x; }
86         void set_gamma_g(float x) { gamma_g=x; };
87         void set_gamma_b(float x) { gamma_b=x; };
88         void set_black_level(float x) { black_level=x; };
89         void set_red_blue_level(float x) { red_blue_level=x; };
90
91         float get_gamma_r()const { return gamma_r; }
92         float get_gamma_g()const { return gamma_g; }
93         float get_gamma_b()const { return gamma_b; }
94         float get_black_level()const { return black_level; }
95         float get_red_blue_level()const { return red_blue_level; }
96
97         GammaPattern();
98
99         ~GammaPattern();
100
101         bool redraw(GdkEventExpose*bleh=NULL);
102 }; // END of class GammaPattern
103
104 class BlackLevelSelector : public Gtk::DrawingArea
105 {
106         float level;
107
108         sigc::signal<void> signal_value_changed_;
109
110 public:
111
112         BlackLevelSelector();
113
114         ~BlackLevelSelector();
115
116         sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
117
118         void set_value(float x) { level=x; queue_draw(); }
119
120         const float &get_value()const { return level; }
121
122         bool redraw(GdkEventExpose*bleh=NULL);
123
124         bool on_event(GdkEvent *event);
125 }; // END of class BlackLevelSelector
126
127 class RedBlueLevelSelector : public Gtk::DrawingArea
128 {
129         float level;
130
131         sigc::signal<void> signal_value_changed_;
132
133 public:
134
135         RedBlueLevelSelector();
136
137         ~RedBlueLevelSelector();
138
139         sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
140
141         void set_value(float x) { level=x; queue_draw(); }
142
143         const float &get_value()const { return level; }
144
145         bool redraw(GdkEventExpose*bleh=NULL);
146
147         bool on_event(GdkEvent *event);
148 }; // END of class RedBlueSelector
149
150 class Widget_Enum;
151
152 class Dialog_Setup : public Gtk::Dialog
153 {
154
155         void on_ok_pressed();
156         void on_apply_pressed();
157
158         void on_gamma_r_change();
159         void on_gamma_g_change();
160         void on_gamma_b_change();
161         void on_black_level_change();
162         void on_red_blue_level_change();
163         void on_size_template_combo_change();
164         void on_fps_template_combo_change();
165
166         GammaPattern gamma_pattern;
167         BlackLevelSelector black_level_selector;
168         RedBlueLevelSelector red_blue_level_selector;
169         Gtk::OptionMenu timestamp_optionmenu;
170
171         Gtk::Adjustment adj_gamma_r;
172         Gtk::Adjustment adj_gamma_g;
173         Gtk::Adjustment adj_gamma_b;
174
175         Gtk::Adjustment adj_recent_files;
176         Gtk::Adjustment adj_undo_depth;
177
178         Gtk::CheckButton toggle_use_colorspace_gamma;
179 #ifdef SINGLE_THREADED
180         Gtk::CheckButton toggle_single_threaded;
181 #endif
182
183         synfig::Time::Format time_format;
184
185         Gtk::Menu *timestamp_menu;
186         Widget_Enum *widget_enum;
187
188         Widget_Time auto_backup_interval;
189
190         Gtk::CheckButton toggle_restrict_radius_ducks;
191         Gtk::CheckButton toggle_resize_imported_images;
192
193         Gtk::Entry textbox_browser_command;
194
195         Gtk::ComboBoxText* size_template_combo;
196         Gtk::ComboBoxText* fps_template_combo;
197         Gtk::Entry textbox_custom_filename_prefix;
198         Gtk::Adjustment adj_pref_x_size;
199         Gtk::Adjustment adj_pref_y_size;
200         Gtk::Adjustment adj_pref_fps;
201         Gtk::SpinButton* pref_fps_spinbutton;
202         Gtk::SpinButton* pref_y_size_spinbutton;
203         Gtk::SpinButton* pref_x_size_spinbutton;
204         Gtk::Tooltips tooltips_;
205 public:
206
207         void set_time_format(synfig::Time::Format time_format);
208
209         const synfig::Time::Format& get_time_format()const { return time_format; }
210
211         Dialog_Setup();
212         ~Dialog_Setup();
213
214     void refresh();
215
216 }; // END of Dialog_Waypoint
217
218 }; // END of namespace studio
219
220 /* === E N D =============================================================== */
221
222 #endif