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