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