1 /* === S Y N F I G ========================================================= */
2 /*! \file dialog_setup.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
10 ** Copyright (c) 2008 Carlos López
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include "dialog_setup.h"
36 #include <gtkmm/scale.h>
37 #include <gtkmm/table.h>
38 #include <gtkmm/frame.h>
39 #include <gtkmm/notebook.h>
40 #include <gtkmm/spinbutton.h>
41 #include "widget_enum.h"
42 #include "autorecover.h"
44 #include <ETL/stringf>
50 /* === U S I N G =========================================================== */
54 using namespace synfig;
55 using namespace studio;
57 /* === M A C R O S ========================================================= */
59 /* === G L O B A L S ======================================================= */
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
66 attach_label(Gtk::Table *table, String str, guint col, guint xpadding, guint ypadding)
68 Gtk::Label* label(manage(new Gtk::Label((str + ":").c_str())));
69 label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
70 table->attach(*label, 0, 1, col, col+1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
73 Dialog_Setup::Dialog_Setup():
74 Dialog(_("Synfig Studio Setup"),false,true),
75 adj_gamma_r(2.2,0.1,3.0,0.025,0.025,0.025),
76 adj_gamma_g(2.2,0.1,3.0,0.025,0.025,0.025),
77 adj_gamma_b(2.2,0.1,3.0,0.025,0.025,0.025),
78 adj_recent_files(15,1,50,1,1,0),
79 adj_undo_depth(100,10,5000,1,1,1),
80 toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
81 #ifdef SINGLE_THREADED
82 toggle_single_threaded(_("Use Only a Single Thread")),
84 toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant")),
85 toggle_resize_imported_images(_("Scale New Imported Images to Fit Canvas")),
86 adj_pref_x_size(480,1,10000,1,10,0),
87 adj_pref_y_size(270,1,10000,1,10,0),
88 adj_pref_fps(24.0,1.0,100,0.1,1,0)
93 Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
95 add_action_widget(*ok_button,2);
96 ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_ok_pressed));
98 Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
100 add_action_widget(*apply_button,1);
101 apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_apply_pressed));
103 Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
104 cancel_button->show();
105 add_action_widget(*cancel_button,0);
106 cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::hide));
110 Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
111 get_vbox()->pack_start(*notebook);
115 Gtk::Table *gamma_table=manage(new Gtk::Table(2,2,false));
116 notebook->append_page(*gamma_table,_("Gamma"));
117 //gamma_frame->add(*gamma_table);
119 gamma_table->attach(gamma_pattern, 0, 2, 0, 1, Gtk::EXPAND, Gtk::SHRINK|Gtk::FILL, 0, 0);
121 Gtk::HScale* scale_gamma_r(manage(new Gtk::HScale(adj_gamma_r)));
122 gamma_table->attach(*manage(new Gtk::Label(_("Red"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
123 gamma_table->attach(*scale_gamma_r, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
124 adj_gamma_r.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_r_change));
126 Gtk::HScale* scale_gamma_g(manage(new Gtk::HScale(adj_gamma_g)));
127 gamma_table->attach(*manage(new Gtk::Label(_("Green"))), 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
128 gamma_table->attach(*scale_gamma_g, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
129 adj_gamma_g.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_g_change));
131 Gtk::HScale* scale_gamma_b(manage(new Gtk::HScale(adj_gamma_b)));
132 gamma_table->attach(*manage(new Gtk::Label(_("Blue"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
133 gamma_table->attach(*scale_gamma_b, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
134 adj_gamma_b.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_b_change));
136 gamma_table->attach(*manage(new Gtk::Label(_("Black Level"))), 0, 1, 4, 5, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
137 gamma_table->attach(black_level_selector, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
138 black_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_black_level_change));
140 //gamma_table->attach(*manage(new Gtk::Label(_("Red-Blue Level"))), 0, 1, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
141 //gamma_table->attach(red_blue_level_selector, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
142 //red_blue_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_red_blue_level_change));
146 Gtk::Table *misc_table=manage(new Gtk::Table(2,2,false));
147 notebook->append_page(*misc_table,_("Misc."));
149 int xpadding(8), ypadding(8);
152 timestamp_menu=manage(new class Gtk::Menu());
153 attach_label(misc_table, _("Timestamp"), 0, xpadding, ypadding);
154 misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
156 #define ADD_TIMESTAMP(desc,x) \
157 timestamp_menu->items().push_back( \
158 Gtk::Menu_Helpers::MenuElem( \
163 &studio::Dialog_Setup::set_time_format), \
165 ADD_TIMESTAMP("HH:MM:SS.FF", Time::FORMAT_VIDEO );
166 ADD_TIMESTAMP("(HHh MMm SSs) FFf", Time::FORMAT_NORMAL );
167 ADD_TIMESTAMP("(HHhMMmSSs)FFf", Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES );
168 ADD_TIMESTAMP("HHh MMm SSs FFf", Time::FORMAT_NORMAL | Time::FORMAT_FULL );
169 ADD_TIMESTAMP("HHhMMmSSsFFf", Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES | Time::FORMAT_FULL);
170 ADD_TIMESTAMP("FFf", Time::FORMAT_FRAMES );
172 timestamp_optionmenu.set_menu(*timestamp_menu);
177 ParamDesc param_desc;
180 .add_enum_value(Distance::SYSTEM_UNITS,"u",_("Units"))
181 .add_enum_value(Distance::SYSTEM_PIXELS,"px",_("Pixels"))
182 .add_enum_value(Distance::SYSTEM_POINTS,"pt",_("Points"))
183 .add_enum_value(Distance::SYSTEM_INCHES,"in",_("Inches"))
184 .add_enum_value(Distance::SYSTEM_METERS,"m",_("Meters"))
185 .add_enum_value(Distance::SYSTEM_CENTIMETERS,"cm",_("Centimeters"))
186 .add_enum_value(Distance::SYSTEM_MILLIMETERS,"mm",_("Millimeters"));
188 widget_enum=manage(new Widget_Enum());
189 widget_enum->set_param_desc(param_desc);
191 attach_label(misc_table, _("Unit System"), 1, xpadding, ypadding);
192 misc_table->attach(*widget_enum, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
195 // Misc - recent files
196 Gtk::SpinButton* recent_files_spinbutton(manage(new Gtk::SpinButton(adj_recent_files,1,0)));
197 attach_label(misc_table, _("Recent Files"), 2, xpadding, ypadding);
198 misc_table->attach(*recent_files_spinbutton, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
200 // Misc - use_colorspace_gamma
201 misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
203 #ifdef SINGLE_THREADED
204 // Misc - single_threaded
205 misc_table->attach(toggle_single_threaded, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
208 // Misc - auto backup interval
209 attach_label(misc_table, _("Auto Backup Interval (0 to disable)"), 3, xpadding, ypadding);
210 misc_table->attach(auto_backup_interval, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
212 // Misc - restrict_radius_ducks
213 misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
215 // Misc - resize_imported_images
216 misc_table->attach(toggle_resize_imported_images, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
218 // Misc - browser_command
219 attach_label(misc_table, _("Browser Command"), 4, xpadding, ypadding);
220 misc_table->attach(textbox_browser_command, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
223 Gtk::Table *document_table=manage(new Gtk::Table(2,4,false));
224 notebook->append_page(*document_table,_("Document"));
226 // Document - Preferred file name prefix
227 attach_label(document_table, _("New Document filename prefix"), 0, xpadding, ypadding);
228 document_table->attach(textbox_custom_filename_prefix, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
229 tooltips_.set_tip(textbox_custom_filename_prefix,_("File name prefix for the new created document"));
231 // Document - New Document X size
232 Gtk::SpinButton* pref_x_size_spinbutton(manage(new Gtk::SpinButton(adj_pref_x_size,1,0)));
233 attach_label(document_table,_("New Document X size"),1, xpadding, ypadding);
234 document_table->attach(*pref_x_size_spinbutton, 1, 2, 1, 2,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
235 tooltips_.set_tip(*pref_x_size_spinbutton,_("Width in pixels of the new created document"));
237 // Document - New Document Y size
238 Gtk::SpinButton* pref_y_size_spinbutton(manage(new Gtk::SpinButton(adj_pref_y_size,1,0)));
239 attach_label(document_table,_("New Document Y size"),2, xpadding, ypadding);
240 document_table->attach(*pref_y_size_spinbutton, 1, 2, 2, 3,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
241 tooltips_.set_tip(*pref_y_size_spinbutton,_("High in pixels of the new created document"));
243 //Document - Template for predefined sizes of canvases.
244 size_template_combo=Gtk::manage(new Gtk::ComboBoxText());
245 Gtk::Label* label(manage(new Gtk::Label(_("Predefined Resolutions:"))));
246 label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
247 document_table->attach(*label, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
248 document_table->attach(*size_template_combo,2, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
249 size_template_combo->signal_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_size_template_combo_change));
250 size_template_combo->prepend_text(_("4096x3112 Full Aperture 4K"));
251 size_template_combo->prepend_text(_("2048x1556 Full Aperture Native 2K"));
252 size_template_combo->prepend_text(_("1920x1080 HDTV 1080p/i"));
253 size_template_combo->prepend_text(_("1280x720 HDTV 720p"));
254 size_template_combo->prepend_text(_("720x576 DVD PAL"));
255 size_template_combo->prepend_text(_("720x480 DVD NTSC"));
256 size_template_combo->prepend_text(_("720x540 Web 720x"));
257 size_template_combo->prepend_text(_("720x405 Web 720x HD"));
258 size_template_combo->prepend_text(_("640x480 Web 640x"));
259 size_template_combo->prepend_text(_("640x360 Web 640x HD"));
260 size_template_combo->prepend_text(_("480x360 Web 480x"));
261 size_template_combo->prepend_text(_("480x270 Web 480x HD"));
262 size_template_combo->prepend_text(_("360x270 Web 360x"));
263 size_template_combo->prepend_text(_("360x203 Web 360x HD"));
264 size_template_combo->prepend_text(DEFAULT_PREDEFINED_SIZE);
266 //Document - Template for predefined fps
267 fps_template_combo=Gtk::manage(new Gtk::ComboBoxText());
268 Gtk::Label* label1(manage(new Gtk::Label(_("Predefined FPS:"))));
269 label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
270 document_table->attach(*label1, 2, 3, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
271 document_table->attach(*fps_template_combo,2, 3, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
272 fps_template_combo->signal_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_fps_template_combo_change));
273 fps_template_combo->prepend_text("60,0"); // It seems that the period is a ',' instead of a '.' for GTK.
274 fps_template_combo->prepend_text("50,0");
275 fps_template_combo->prepend_text("30,0");
276 fps_template_combo->prepend_text("25,0");
277 fps_template_combo->prepend_text("24,976");
278 fps_template_combo->prepend_text("24,0");
279 fps_template_combo->prepend_text("15,0");
280 fps_template_combo->prepend_text("12,0");
281 fps_template_combo->prepend_text(DEFAULT_PREDEFINED_FPS);
283 // Document - New Document FPS
284 Gtk::SpinButton* pref_fps_spinbutton(manage(new Gtk::SpinButton(adj_pref_fps,1,3)));
285 attach_label(document_table,_("New Document FPS"),4, xpadding, ypadding);
286 document_table->attach(*pref_fps_spinbutton, 1, 2, 4, 5,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
287 tooltips_.set_tip(*pref_fps_spinbutton,_("Frames per second of the new created document"));
292 Dialog_Setup::~Dialog_Setup()
297 Dialog_Setup::on_ok_pressed()
304 Dialog_Setup::on_apply_pressed()
306 App::gamma.set_all(1.0/adj_gamma_r.get_value(),1.0/adj_gamma_g.get_value(),1.0/adj_gamma_b.get_value(),black_level_selector.get_value(),red_blue_level_selector.get_value());
308 App::set_max_recent_files((int)adj_recent_files.get_value());
310 // Set the time format
311 App::set_time_format(get_time_format());
313 // Set the use_colorspace_gamma flag
314 App::use_colorspace_gamma=toggle_use_colorspace_gamma.get_active();
316 #ifdef SINGLE_THREADED
317 // Set the single_threaded flag
318 App::single_threaded=toggle_single_threaded.get_active();
321 // Set the auto backup interval
322 App::auto_recover->set_timeout(auto_backup_interval.get_value() * 1000);
324 App::distance_system=Distance::System(widget_enum->get_value());
326 // Set the restrict_radius_ducks flag
327 App::restrict_radius_ducks=toggle_restrict_radius_ducks.get_active();
329 // Set the resize_imported_images flag
330 App::resize_imported_images=toggle_resize_imported_images.get_active();
332 // Set the browser_command textbox
333 App::browser_command=textbox_browser_command.get_text();
335 // Set the preferred file name prefix
336 App::custom_filename_prefix=textbox_custom_filename_prefix.get_text();
338 // Set the preferred new Document X dimension
339 App::preferred_x_size=int(adj_pref_x_size.get_value());
341 // Set the preferred new Document Y dimension
342 App::preferred_y_size=int(adj_pref_y_size.get_value());
344 // Set the preferred Predefined size
345 App::predefined_size=size_template_combo->get_active_text();
347 // Set the preferred Predefined fps
348 App::predefined_fps=fps_template_combo->get_active_text();
350 // Set the preferred FPS
351 App::preferred_fps=Real(adj_pref_fps.get_value());
353 App::save_settings();
357 Dialog_Setup::on_gamma_r_change()
359 gamma_pattern.set_gamma_r(1.0/adj_gamma_r.get_value());
360 gamma_pattern.refresh();
361 gamma_pattern.queue_draw();
365 Dialog_Setup::on_gamma_g_change()
367 gamma_pattern.set_gamma_g(1.0/adj_gamma_g.get_value());
368 gamma_pattern.refresh();
369 gamma_pattern.queue_draw();
373 Dialog_Setup::on_gamma_b_change()
375 gamma_pattern.set_gamma_b(1.0/adj_gamma_b.get_value());
376 gamma_pattern.refresh();
377 gamma_pattern.queue_draw();
381 Dialog_Setup::on_black_level_change()
383 gamma_pattern.set_black_level(black_level_selector.get_value());
384 gamma_pattern.refresh();
385 gamma_pattern.queue_draw();
389 Dialog_Setup::on_red_blue_level_change()
391 gamma_pattern.set_red_blue_level(red_blue_level_selector.get_value());
392 gamma_pattern.refresh();
393 gamma_pattern.queue_draw();
397 Dialog_Setup::on_size_template_combo_change()
399 String selection(size_template_combo->get_active_text());
400 if(selection==DEFAULT_PREDEFINED_SIZE)
404 String::size_type locx=selection.find_first_of("x"); // here should be some comparison with string::npos
405 String::size_type locspace=selection.find_first_of(" ");
406 String x_size(selection.substr(0,locx));
407 String y_size(selection.substr(locx+1,locspace));
408 int x=atoi(x_size.c_str());
409 int y=atoi(y_size.c_str());
410 adj_pref_x_size.set_value(x);
411 adj_pref_y_size.set_value(y);
416 Dialog_Setup::on_fps_template_combo_change()
418 String selection(fps_template_combo->get_active_text());
419 if(selection==DEFAULT_PREDEFINED_FPS)
423 adj_pref_fps.set_value(atof(selection.c_str()));
428 Dialog_Setup::refresh()
430 // Refresh the temporary gamma; do this before adjusting the sliders,
431 // or variables will be used before their initialization.
432 gamma_pattern.set_gamma_r(App::gamma.get_gamma_r());
433 gamma_pattern.set_gamma_g(App::gamma.get_gamma_g());
434 gamma_pattern.set_gamma_b(App::gamma.get_gamma_b());
435 gamma_pattern.set_black_level(App::gamma.get_black_level());
436 gamma_pattern.set_red_blue_level(App::gamma.get_red_blue_level());
438 adj_gamma_r.set_value(1.0/App::gamma.get_gamma_r());
439 adj_gamma_g.set_value(1.0/App::gamma.get_gamma_g());
440 adj_gamma_b.set_value(1.0/App::gamma.get_gamma_b());
441 black_level_selector.set_value(App::gamma.get_black_level());
442 red_blue_level_selector.set_value(App::gamma.get_red_blue_level());
444 gamma_pattern.refresh();
446 adj_recent_files.set_value(App::get_max_recent_files());
448 // Refresh the time format
449 set_time_format(App::get_time_format());
451 widget_enum->set_value(App::distance_system);
453 // Refresh the status of the use_colorspace_gamma flag
454 toggle_use_colorspace_gamma.set_active(App::use_colorspace_gamma);
456 #ifdef SINGLE_THREADED
457 // Refresh the status of the single_threaded flag
458 toggle_single_threaded.set_active(App::single_threaded);
461 // Refresh the value of the auto backup interval
462 auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
464 // Refresh the status of the restrict_radius_ducks flag
465 toggle_restrict_radius_ducks.set_active(App::restrict_radius_ducks);
467 // Refresh the status of the resize_imported_images flag
468 toggle_resize_imported_images.set_active(App::resize_imported_images);
470 // Refresh the browser_command textbox
471 textbox_browser_command.set_text(App::browser_command);
473 // Refresh the preferred filename prefix
474 textbox_custom_filename_prefix.set_text(App::custom_filename_prefix);
476 // Refresh the preferred new Document X dimension
477 adj_pref_x_size.set_value(App::preferred_x_size);
479 // Refresh the preferred new Document Y dimension
480 adj_pref_y_size.set_value(App::preferred_y_size);
482 // Refresh the preferred Predefined size
483 size_template_combo->set_active_text(App::predefined_size);
485 //Refresh the preferred FPS
486 adj_pref_fps.set_value(App::preferred_fps);
488 //Refresh the predefined FPS
489 fps_template_combo->set_active_text(App::predefined_fps);
492 GammaPattern::GammaPattern():
496 set_size_request(tile_w*4,tile_h*3);
497 signal_expose_event().connect(sigc::mem_fun(*this, &studio::GammaPattern::redraw));
500 GammaPattern::~GammaPattern()
505 GammaPattern::refresh()
529 black[1].set_rgb(black[0].get_red(),0,0);
530 gray25[1].set_rgb(gray25[0].get_red(),0,0);
531 gray50[1].set_rgb(gray50[0].get_red(),0,0);
532 white[1].set_rgb(white[0].get_red(),0,0);
535 black[2].set_rgb(0,black[0].get_green(),0);
536 gray25[2].set_rgb(0,gray25[0].get_green(),0);
537 gray50[2].set_rgb(0,gray50[0].get_green(),0);
538 white[2].set_rgb(0,white[0].get_green(),0);
541 black[3].set_rgb(0,0,black[0].get_blue());
542 gray25[3].set_rgb(0,0,gray25[0].get_blue());
543 gray50[3].set_rgb(0,0,gray50[0].get_blue());
544 white[3].set_rgb(0,0,white[0].get_blue());
548 GammaPattern::redraw(GdkEventExpose */*bleh*/)
550 static const char hlines[] = { 3, 0 };
552 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
555 Gdk::Color trueblack("#000000");
560 gc->set_rgb_fg_color(black[i]);
561 get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
563 gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
564 gc->set_fill(Gdk::STIPPLED);
565 gc->set_rgb_fg_color(white[i]);
566 get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
568 gc->set_fill(Gdk::SOLID);
569 gc->set_rgb_fg_color(gray50[i]);
571 get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
577 gc->set_rgb_fg_color(black[i]);
578 get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
580 gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
581 gc->set_fill(Gdk::STIPPLED);
582 gc->set_rgb_fg_color(gray50[i]);
583 get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
585 gc->set_fill(Gdk::SOLID);
586 gc->set_rgb_fg_color(gray25[i]);
588 get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
591 // Black-level Pattern
592 gc->set_rgb_fg_color(trueblack);
593 get_window()->draw_rectangle(gc, true, 0, tile_h*2, tile_w*4, tile_h);
594 gc->set_fill(Gdk::SOLID);
597 gc->set_rgb_fg_color(black[i]);
599 get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h*2+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
606 BlackLevelSelector::BlackLevelSelector()
608 set_size_request(-1,24);
609 signal_expose_event().connect(sigc::mem_fun(*this, &studio::BlackLevelSelector::redraw));
611 add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
612 add_events(Gdk::BUTTON1_MOTION_MASK);
613 add_events(Gdk::BUTTON1_MOTION_MASK);
616 BlackLevelSelector::~BlackLevelSelector()
621 BlackLevelSelector::redraw(GdkEventExpose */*bleh*/)
623 const int w(get_width()),h(get_height());
627 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
634 color.set_rgb(i*65536/w,i*65536/w,i*65536/w);
636 gc->set_rgb_fg_color(color);
637 get_window()->draw_rectangle(gc, true, i, 0, 1, h);
641 gc->set_rgb_fg_color(Gdk::Color("#000000"));
642 get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
644 // Draw the position of the current value
645 i=(int)(level*w+0.5);
646 gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
647 get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
649 // Print out the value
650 Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
651 layout->set_text(etl::strprintf("%0.01f%%",level*100.0f));
652 layout->set_alignment(Pango::ALIGN_CENTER);
653 gc->set_rgb_fg_color(Gdk::Color("#a00000"));
654 get_window()->draw_layout(gc, w/2, 4, layout);
662 BlackLevelSelector::on_event(GdkEvent *event)
664 int x(round_to_int(event->button.x));
665 //int y(round_to_int(event->button.y));
669 case GDK_MOTION_NOTIFY:
670 level=(float)x/(float)get_width();
671 if(level<0.0f)level=0.0f;
672 if(level>1.0f)level=1.0f;
673 signal_value_changed_();
677 case GDK_BUTTON_PRESS:
678 case GDK_BUTTON_RELEASE:
679 if(event->button.button==1)
681 level=(float)x/(float)get_width();
682 if(level<0.0f)level=0.0f;
683 if(level>1.0f)level=1.0f;
684 signal_value_changed_();
698 Dialog_Setup::set_time_format(synfig::Time::Format x)
701 if (x <= Time::FORMAT_VIDEO)
702 timestamp_optionmenu.set_history(0);
703 else if (x == (Time::FORMAT_NORMAL))
704 timestamp_optionmenu.set_history(1);
705 else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES))
706 timestamp_optionmenu.set_history(2);
707 else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_FULL))
708 timestamp_optionmenu.set_history(3);
709 else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES | Time::FORMAT_FULL))
710 timestamp_optionmenu.set_history(4);
711 else if (x == (Time::FORMAT_FRAMES))
712 timestamp_optionmenu.set_history(5);
714 timestamp_optionmenu.set_history(1);
732 RedBlueLevelSelector::RedBlueLevelSelector()
734 set_size_request(-1,24);
735 signal_expose_event().connect(sigc::mem_fun(*this, &studio::RedBlueLevelSelector::redraw));
737 add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
738 add_events(Gdk::BUTTON1_MOTION_MASK);
739 add_events(Gdk::BUTTON1_MOTION_MASK);
742 RedBlueLevelSelector::~RedBlueLevelSelector()
747 RedBlueLevelSelector::redraw(GdkEventExpose */*bleh*/)
749 const int w(get_width()),h(get_height());
753 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
760 float red_blue(((float(i)/float(w)+0.5f)-1.0f)/2.0f+1.0f);
761 float blue_red(2.0f-(red_blue));
762 if(red_blue>1.0f)red_blue=1.0f;
763 if(blue_red>1.0f)blue_red=1.0f;
766 round_to_int(min(red_blue,1.0f)*65535),
767 round_to_int(sqrt(min(red_blue,blue_red))*65535),
768 round_to_int(min(blue_red,1.0f)*65535)
771 gc->set_rgb_fg_color(color);
772 get_window()->draw_rectangle(gc, true, i, 0, 1, h);
776 gc->set_rgb_fg_color(Gdk::Color("#000000"));
777 get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
779 // Draw the position of the current value
780 i=(int)(((level-1.0f)*2.0f+1.0f-0.5f)*w+0.5);
781 gc->set_rgb_fg_color(Gdk::Color("#00ff00"));
782 get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
784 // Print out the value
785 Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
786 layout->set_text(etl::strprintf("%0.02f",level));
787 layout->set_alignment(Pango::ALIGN_CENTER);
788 gc->set_rgb_fg_color(Gdk::Color("#a00000"));
789 get_window()->draw_layout(gc, w/2, 4, layout);
797 RedBlueLevelSelector::on_event(GdkEvent *event)
799 int x(round_to_int(event->button.x));
800 //int y(round_to_int(event->button.y));
804 case GDK_MOTION_NOTIFY:
805 level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
806 if(level<0.5f)level=0.5f;
807 if(level>1.5f)level=1.5f;
808 signal_value_changed_();
812 case GDK_BUTTON_PRESS:
813 case GDK_BUTTON_RELEASE:
814 if(event->button.button==1)
816 level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
817 if(level<0.5f)level=0.5f;
818 if(level>1.5f)level=1.5f;
819 signal_value_changed_();