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