synfig-studio  1.0.3
dialog_setup.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
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/comboboxtext.h>
39 #include <gtkmm/checkbutton.h>
41 #include <gtkmm/tooltip.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 #include "app.h"
50 
51 /* === M A C R O S ========================================================= */
52 #ifndef DEFAULT_PREDEFINED_SIZE
53 #define DEFAULT_PREDEFINED_SIZE _("Custom Size")
54 #endif
55 #ifndef DEFAULT_PREDEFINED_FPS
56 #define DEFAULT_PREDEFINED_FPS _("Custom fps")
57 #endif
58 
59 /* === T Y P E D E F S ===================================================== */
60 
61 /* === C L A S S E S & S T R U C T S ======================================= */
62 
63 namespace Gtk { class Menu; };
64 
65 namespace studio {
66 
67 class GammaPattern : public Gtk::DrawingArea
68 {
69  float gamma_r;
70  float gamma_g;
71  float gamma_b;
72  float black_level;
73  float red_blue_level;
74 
75  int tile_w, tile_h;
76 
77  Gdk::Color black[4],white[4],gray50[4],gray25[4];
78 
79  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; }
80  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; }
81  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; }
82 
83 public:
84 
85  void refresh();
86 
87  void set_gamma_r(float x) { gamma_r=x; }
88  void set_gamma_g(float x) { gamma_g=x; };
89  void set_gamma_b(float x) { gamma_b=x; };
90  void set_black_level(float x) { black_level=x; };
91  void set_red_blue_level(float x) { red_blue_level=x; };
92 
93  float get_gamma_r()const { return gamma_r; }
94  float get_gamma_g()const { return gamma_g; }
95  float get_gamma_b()const { return gamma_b; }
96  float get_black_level()const { return black_level; }
97  float get_red_blue_level()const { return red_blue_level; }
98 
99  GammaPattern();
100 
101  ~GammaPattern();
102 
103  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
104 }; // END of class GammaPattern
105 
106 class BlackLevelSelector : public Gtk::DrawingArea
107 {
108  float level;
109 
110  sigc::signal<void> signal_value_changed_;
111 
112 public:
113 
115 
117 
118  sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
119 
120  void set_value(float x) { level=x; queue_draw(); }
121 
122  const float &get_value()const { return level; }
123 
124  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
125 
126  bool on_event(GdkEvent *event);
127 }; // END of class BlackLevelSelector
128 
129 class RedBlueLevelSelector : public Gtk::DrawingArea
130 {
131  float level;
132 
133  sigc::signal<void> signal_value_changed_;
134 
135 public:
136 
138 
140 
141  sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
142 
143  void set_value(float x) { level=x; queue_draw(); }
144 
145  const float &get_value()const { return level; }
146 
147  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr);
148 
149  bool on_event(GdkEvent *event);
150 }; // END of class RedBlueSelector
151 
152 class Widget_Enum;
153 
154 class Dialog_Setup : public Gtk::Dialog
155 {
156 
157  void on_ok_pressed();
158  void on_apply_pressed();
159  void on_restore_pressed();
160 
161  void on_gamma_r_change();
162  void on_gamma_g_change();
163  void on_gamma_b_change();
164  void on_black_level_change();
165  void on_red_blue_level_change();
166  void on_size_template_combo_change();
167  void on_fps_template_combo_change();
168  void on_ui_language_combo_change();
169  void on_time_format_changed();
170 
171  GammaPattern gamma_pattern;
172  BlackLevelSelector black_level_selector;
173  RedBlueLevelSelector red_blue_level_selector;
174  Gtk::ComboBoxText timestamp_comboboxtext;
175  std::map<std::string, synfig::Time::Format> time_formats;
176 
177  Glib::RefPtr<Gtk::Adjustment> adj_gamma_r;
178  Glib::RefPtr<Gtk::Adjustment> adj_gamma_g;
179  Glib::RefPtr<Gtk::Adjustment> adj_gamma_b;
180 
181  Glib::RefPtr<Gtk::Adjustment> adj_recent_files;
182  Glib::RefPtr<Gtk::Adjustment> adj_undo_depth;
183 
184  Gtk::CheckButton toggle_use_colorspace_gamma;
185 #ifdef SINGLE_THREADED
186  Gtk::CheckButton toggle_single_threaded;
187 #endif
188 
189  synfig::Time::Format time_format;
190 
191  Gtk::Menu *timestamp_menu;
192  Widget_Enum *widget_enum;
193 
194  Widget_Time auto_backup_interval;
195 
196  Gtk::CheckButton toggle_restrict_radius_ducks;
197  Gtk::CheckButton toggle_resize_imported_images;
198  Gtk::CheckButton toggle_enable_experimental_features;
199  Gtk::CheckButton toggle_use_dark_theme;
200 
201  Gtk::Entry textbox_browser_command;
202  Gtk::Entry textbox_brushes_path;
203 
204  Gtk::ComboBoxText* size_template_combo;
205  Gtk::ComboBoxText* fps_template_combo;
206  Gtk::ComboBoxText ui_language_combo;
207  std::vector<Glib::ustring> _lang_codes;
208 
209 
210  Gtk::Entry textbox_custom_filename_prefix;
211  Glib::RefPtr<Gtk::Adjustment> adj_pref_x_size;
212  Glib::RefPtr<Gtk::Adjustment> adj_pref_y_size;
213  Glib::RefPtr<Gtk::Adjustment> adj_pref_fps;
214  Gtk::SpinButton* pref_fps_spinbutton;
215  Gtk::SpinButton* pref_y_size_spinbutton;
216  Gtk::SpinButton* pref_x_size_spinbutton;
217 
218  Gtk::Entry image_sequence_separator;
219  Gtk::CheckButton toggle_navigator_uses_cairo;
220  Gtk::CheckButton toggle_workarea_uses_cairo;
221 
222 public:
223 
224  void set_time_format(synfig::Time::Format time_format);
225 
226  const synfig::Time::Format& get_time_format()const { return time_format; }
227 
228  Dialog_Setup(Gtk::Window& parent);
229  ~Dialog_Setup();
230 
231  void refresh();
232 
233 }; // END of Dialog_Waypoint
234 
235 }; // END of namespace studio
236 
237 /* === E N D =============================================================== */
238 
239 #endif