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