1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
5 ** $Id: renddesc.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
33 #include <gtkmm/label.h>
34 #include <gtkmm/frame.h>
36 #include <synfig/general.h>
37 //#include <gtkmm/seperator.h>
41 /* === U S I N G =========================================================== */
45 using namespace synfig;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 #ifndef SYNFIG_MAX_PIXEL_WIDTH
51 #define SYNFIG_MAX_PIXEL_WIDTH (~(1<<31))
54 #ifndef SYNFIG_MAX_PIXEL_HEIGHT
55 #define SYNFIG_MAX_PIXEL_HEIGHT (~(1<<31))
63 #define DPM2DPI(x) ((x)/39.3700787402)
64 #define DPI2DPM(x) ((x)*39.3700787402)
68 #define METERS2INCHES(x) ((x)*39.3700787402)
69 #define INCHES2METERS(x) ((x)/39.3700787402)
72 /* === G L O B A L S ======================================================= */
74 /* === P R O C E D U R E S ================================================= */
76 /* === M E T H O D S ======================================================= */
78 Widget_RendDesc::Widget_RendDesc():
79 Gtk::Table(1,2,false),
80 adjustment_width(1,1,SYNFIG_MAX_PIXEL_WIDTH),
81 adjustment_height(1,1,SYNFIG_MAX_PIXEL_HEIGHT),
82 adjustment_xres(0,0,10000000),
83 adjustment_yres(0,0,10000000),
84 adjustment_phy_width(0,0,10000000),
85 adjustment_phy_height(0,0,10000000),
86 adjustment_fps(0,0,10000000),
87 adjustment_span(0,0,10000000)
91 Gtk::Frame *size_frame=manage(new Gtk::Frame(_("Image Size")));
92 Gtk::Frame *area_frame=manage(new Gtk::Frame(_("Image Area")));
93 time_frame=manage(new Gtk::Frame(_("Time")));
95 Gtk::Table *size_table=manage(new Gtk::Table(2,2,false));
96 size_frame->add(*size_table);
98 Gtk::Table *area_table=manage(new Gtk::Table(2,2,false));
99 area_frame->add(*area_table);
101 time_table=manage(new Gtk::Table(2,2,false));
102 time_frame->add(*time_table);
104 Gtk::Frame *other_frame=manage(new Gtk::Frame(_("Other")));
105 Gtk::Table *other_table=manage(new Gtk::Table(2,2,false));
106 other_frame->add(*other_table);
108 Gtk::Frame *lock_frame=manage(new Gtk::Frame(_("Locks and Links")));
109 Gtk::Table *lock_table=manage(new Gtk::Table(2,2,false));
110 lock_frame->add(*lock_table);
112 entry_width=manage(new Gtk::SpinButton(adjustment_width,1,0));
113 entry_height=manage(new Gtk::SpinButton(adjustment_height,1,0));
114 entry_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_width_changed));
115 entry_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_height_changed));
116 size_table->attach(*manage(new Gtk::Label(_("Width"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
117 size_table->attach(*manage(new Gtk::Label(_("Height"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
118 size_table->attach(*entry_width, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
119 size_table->attach(*entry_height, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
121 entry_xres=manage(new Gtk::SpinButton(adjustment_xres,0.5,1));
122 entry_yres=manage(new Gtk::SpinButton(adjustment_yres,0.5,1));
123 entry_xres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_xres_changed));
124 entry_yres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_yres_changed));
125 size_table->attach(*manage(new Gtk::Label(_("XRes"))), 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
126 size_table->attach(*manage(new Gtk::Label(_("YRes"))), 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
127 size_table->attach(*entry_xres, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
128 size_table->attach(*entry_yres, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
130 entry_phy_width=manage(new Gtk::SpinButton(adjustment_phy_width,0.25,2));
131 entry_phy_height=manage(new Gtk::SpinButton(adjustment_phy_height,0.25,2));
132 entry_phy_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_width_changed));
133 entry_phy_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_height_changed));
134 size_table->attach(*manage(new Gtk::Label(_("PhyWidth"))), 4, 5, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
135 size_table->attach(*manage(new Gtk::Label(_("PhyHeight"))), 4, 5, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
136 size_table->attach(*entry_phy_width, 5, 6, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
137 size_table->attach(*entry_phy_height, 5, 6, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
140 entry_span=manage(new Gtk::SpinButton(adjustment_span,0.1,4));
141 entry_span->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_span_changed));
142 size_table->attach(*manage(new Gtk::Label(_("Span"))), 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
143 size_table->attach(*entry_span, 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
145 entry_tl=manage(new Widget_Vector());
146 entry_br=manage(new Widget_Vector());
147 entry_tl->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_tl_changed));
148 entry_br->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_br_changed));
149 area_table->attach(*manage(new Gtk::Label(_("Top-Left"))), 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
150 area_table->attach(*manage(new Gtk::Label(_("Bottom-Right"))), 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
151 area_table->attach(*entry_tl, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
152 area_table->attach(*entry_br, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
154 entry_fps=manage(new Gtk::SpinButton(adjustment_fps,1,5));
155 entry_start_time=manage(new Widget_Time());
156 entry_end_time=manage(new Widget_Time());
157 //entry_start_frame=manage(new Gtk::SpinButton(adjustment_start_frame,1,0));
158 //entry_end_frame=manage(new Gtk::SpinButton(adjustment_end_frame,1,0));
159 entry_fps->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_fps_changed));
160 entry_start_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_time_changed));
161 entry_end_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_time_changed));
162 //entry_start_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_frame_changed));
163 //entry_end_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_frame_changed));
164 time_table->attach(*manage(new Gtk::Label(_("FPS"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
165 time_table->attach(*manage(new Gtk::Label(_("Start Time"))), 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
166 time_table->attach(*manage(new Gtk::Label(_("End Time"))), 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
167 //time_table->attach(*manage(new Gtk::Label(_("Start Frame"))), 4, 5, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
168 //time_table->attach(*manage(new Gtk::Label(_("End Frame"))), 4, 5, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
169 time_table->attach(*entry_fps, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
170 time_table->attach(*entry_start_time, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
171 time_table->attach(*entry_end_time, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
172 //time_table->attach(*entry_start_frame, 5, 6, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
173 //time_table->attach(*entry_end_frame, 5, 6, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
175 entry_focus=manage(new Widget_Vector());
176 entry_focus->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_focus_changed));
177 other_table->attach(*manage(new Gtk::Label(_("Focus Point"))), 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
178 other_table->attach(*entry_focus, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
182 toggle_px_aspect=manage(new Gtk::CheckButton(_("Pixel Aspect")));
183 toggle_px_width=manage(new Gtk::CheckButton(_("Pixel Width")));
184 toggle_px_height=manage(new Gtk::CheckButton(_("Pixel Height")));
186 toggle_im_aspect=manage(new Gtk::CheckButton(_("Image Aspect")));
187 toggle_im_width=manage(new Gtk::CheckButton(_("Image Width")));
188 toggle_im_height=manage(new Gtk::CheckButton(_("Image Height")));
189 toggle_im_span=manage(new Gtk::CheckButton(_("Image Span")));
191 toggle_px_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
192 toggle_px_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
193 toggle_px_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
194 toggle_im_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
195 toggle_im_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
196 toggle_im_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
197 toggle_im_span->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
199 lock_table->attach(*toggle_px_aspect, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
200 lock_table->attach(*toggle_px_width, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
201 lock_table->attach(*toggle_px_height, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
203 lock_table->attach(*toggle_im_aspect, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
204 lock_table->attach(*toggle_im_width, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
205 lock_table->attach(*toggle_im_height, 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
206 lock_table->attach(*toggle_im_span, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK|Gtk::FILL, 0, 0);
209 lock_frame->show_all();
210 other_frame->show_all();
211 size_frame->show_all();
212 area_frame->show_all();
213 time_frame->show_all();
214 attach(*size_frame, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
215 attach(*area_frame, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
216 attach(*lock_frame, 0, 1, 2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
217 attach(*time_frame, 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
218 attach(*other_frame, 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
221 Widget_RendDesc::~Widget_RendDesc()
225 void Widget_RendDesc::set_rend_desc(const synfig::RendDesc &rend_desc)
227 if(update_lock)return;
229 rend_desc_=rend_desc;
234 Widget_RendDesc::refresh()
236 UpdateLock lock(update_lock);
237 adjustment_width.set_value(rend_desc_.get_w());
238 adjustment_height.set_value(rend_desc_.get_h());
239 adjustment_phy_width.set_value(METERS2INCHES(rend_desc_.get_physical_w()));
240 adjustment_phy_height.set_value(METERS2INCHES(rend_desc_.get_physical_h()));
241 adjustment_xres.set_value(DPM2DPI(rend_desc_.get_x_res()));
242 adjustment_yres.set_value(DPM2DPI(rend_desc_.get_y_res()));
243 entry_start_time->set_fps(rend_desc_.get_frame_rate());
244 entry_start_time->set_value(rend_desc_.get_time_start());
245 entry_end_time->set_fps(rend_desc_.get_frame_rate());
246 entry_end_time->set_value(rend_desc_.get_time_end());
248 adjustment_fps.set_value(rend_desc_.get_frame_rate());
249 adjustment_span.set_value(rend_desc_.get_span());
250 entry_tl->set_value(rend_desc_.get_tl());
251 entry_br->set_value(rend_desc_.get_br());
252 entry_focus->set_value(rend_desc_.get_focus());
254 toggle_px_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_ASPECT));
255 toggle_px_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_W));
256 toggle_px_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_H));
258 toggle_im_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_ASPECT));
259 toggle_im_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_W));
260 toggle_im_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_H));
261 toggle_im_span->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_SPAN));
264 void Widget_RendDesc::apply_rend_desc(const synfig::RendDesc &rend_desc)
266 set_rend_desc(rend_desc);
269 const synfig::RendDesc &
270 Widget_RendDesc::get_rend_desc()
276 Widget_RendDesc::on_width_changed()
278 if(update_lock)return;
279 UpdateLock lock(update_lock);
280 rend_desc_.set_w(round_to_int(adjustment_width.get_value()));
286 Widget_RendDesc::on_lock_changed()
288 if(update_lock)return;
289 UpdateLock lock(update_lock);
291 #define DO_TOGGLE(x,y) if(toggle_ ## x->get_active()) \
292 rend_desc_.set_flags(rend_desc_.get_flags()|RendDesc:: y); \
294 rend_desc_.set_flags(rend_desc_.get_flags()&~RendDesc:: y)
296 DO_TOGGLE(px_aspect,PX_ASPECT);
297 DO_TOGGLE(px_width,PX_W);
298 DO_TOGGLE(px_height,PX_H);
300 DO_TOGGLE(im_aspect,IM_ASPECT);
301 DO_TOGGLE(im_width,IM_W);
302 DO_TOGGLE(im_height,IM_H);
303 DO_TOGGLE(im_span,IM_SPAN);
312 Widget_RendDesc::on_height_changed()
314 if(update_lock)return;
315 UpdateLock lock(update_lock);
316 rend_desc_.set_h(round_to_int(adjustment_height.get_value()));
322 Widget_RendDesc::on_phy_width_changed()
324 if(update_lock)return;
325 UpdateLock lock(update_lock);
326 rend_desc_.set_physical_w(INCHES2METERS(adjustment_phy_width.get_value()));
332 Widget_RendDesc::on_phy_height_changed()
334 if(update_lock)return;
335 UpdateLock lock(update_lock);
336 rend_desc_.set_physical_h(INCHES2METERS(adjustment_phy_height.get_value()));
342 Widget_RendDesc::on_xres_changed()
344 if(update_lock)return;
345 UpdateLock lock(update_lock);
346 rend_desc_.set_x_res(DPI2DPM(adjustment_xres.get_value()));
352 Widget_RendDesc::on_yres_changed()
354 if(update_lock)return;
355 UpdateLock lock(update_lock);
356 rend_desc_.set_y_res(DPI2DPM(adjustment_yres.get_value()));
362 Widget_RendDesc::on_start_time_changed()
364 if(update_lock)return;
365 UpdateLock lock(update_lock);
366 rend_desc_.set_time_start(entry_start_time->get_value());
372 Widget_RendDesc::on_end_time_changed()
374 if(update_lock)return;
375 UpdateLock lock(update_lock);
376 rend_desc_.set_time_end(entry_end_time->get_value());
383 Widget_RendDesc::on_start_frame_changed()
385 if(update_lock)return;
386 UpdateLock lock(update_lock);
387 rend_desc_.set_frame_start((int)(adjustment_start_frame.get_value()+0.5));
393 Widget_RendDesc::on_end_frame_changed()
395 if(update_lock)return;
396 UpdateLock lock(update_lock);
397 rend_desc_.set_frame_end((int)(adjustment_end_frame.get_value()+0.5));
404 Widget_RendDesc::on_fps_changed()
406 if(update_lock)return;
407 UpdateLock lock(update_lock);
408 rend_desc_.set_frame_rate((int)(adjustment_fps.get_value()+0.5));
414 Widget_RendDesc::on_tl_changed()
416 if(update_lock)return;
417 UpdateLock lock(update_lock);
418 rend_desc_.set_tl(entry_tl->get_value());
424 Widget_RendDesc::on_br_changed()
426 if(update_lock)return;
427 UpdateLock lock(update_lock);
428 rend_desc_.set_br(entry_br->get_value());
434 Widget_RendDesc::on_focus_changed()
436 if(update_lock)return;
437 UpdateLock lock(update_lock);
438 rend_desc_.set_focus(entry_focus->get_value());
444 Widget_RendDesc::on_span_changed()
446 if(update_lock)return;
447 UpdateLock lock(update_lock);
448 rend_desc_.set_span(adjustment_span.get_value());
454 Widget_RendDesc::disable_time_section()
456 time_frame->set_sensitive(false);
459 Gtk::Table::TableList &list=time_table->children();
460 Gtk::Table::TableList::iterator iter;
461 for(iter=list.begin();iter!=list.end();iter++)
462 iter->get_widget()->set_sensitive(false);
467 Widget_RendDesc::enable_time_section()
469 time_frame->set_sensitive(true);
472 Gtk::Table::TableList &list=time_table->children();
473 Gtk::Table::TableList::iterator iter;
474 for(iter=list.begin();iter!=list.end();iter++)
475 iter->get_widget()->set_sensitive(true);