4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "automation.h"
25 #include "cwindowgui.h"
26 #include "cwindowtool.h"
28 #include "edlsession.h"
29 #include "floatauto.h"
33 #include "mwindowgui.h"
40 CPanel::CPanel(MWindow *mwindow,
41 CWindowGUI *subwindow,
47 this->mwindow = mwindow;
48 this->subwindow = subwindow;
59 void CPanel::create_objects()
61 int x = this->x, y = this->y;
62 subwindow->add_subwindow(operation[CWINDOW_PROTECT] = new CPanelProtect(mwindow, this, x, y));
63 y += operation[CWINDOW_PROTECT]->get_h();
64 subwindow->add_subwindow(operation[CWINDOW_ZOOM] = new CPanelMagnify(mwindow, this, x, y));
65 y += operation[CWINDOW_ZOOM]->get_h();
66 subwindow->add_subwindow(operation[CWINDOW_MASK] = new CPanelMask(mwindow, this, x, y));
67 y += operation[CWINDOW_MASK]->get_h();
68 subwindow->add_subwindow(operation[CWINDOW_RULER] = new CPanelRuler(mwindow, this, x, y));
69 y += operation[CWINDOW_RULER]->get_h();
70 subwindow->add_subwindow(operation[CWINDOW_CAMERA] = new CPanelCamera(mwindow, this, x, y));
71 y += operation[CWINDOW_CAMERA]->get_h();
72 subwindow->add_subwindow(operation[CWINDOW_PROJECTOR] = new CPanelProj(mwindow, this, x, y));
73 y += operation[CWINDOW_PROJECTOR]->get_h();
74 subwindow->add_subwindow(operation[CWINDOW_CROP] = new CPanelCrop(mwindow, this, x, y));
75 y += operation[CWINDOW_CROP]->get_h();
76 subwindow->add_subwindow(operation[CWINDOW_EYEDROP] = new CPanelEyedrop(mwindow, this, x, y));
77 y += operation[CWINDOW_EYEDROP]->get_h();
78 subwindow->add_subwindow(operation[CWINDOW_TOOL_WINDOW] = new CPanelToolWindow(mwindow, this, x, y));
79 y += operation[CWINDOW_TOOL_WINDOW]->get_h();
80 subwindow->add_subwindow(operation[CWINDOW_TITLESAFE] = new CPanelTitleSafe(mwindow, this, x, y));
81 y += operation[CWINDOW_TITLESAFE]->get_h();
82 x += (w - BC_Slider::get_span(1)) / 2; y += yS(15);
83 subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y, h-y-yS(20)));
86 void CPanel::reposition_buttons(int x, int y, int h)
92 for(int i = 0; i < CPANEL_OPERATIONS; i++)
94 operation[i]->reposition_window(x, y);
95 y += operation[i]->get_h();
97 x += (w - BC_Slider::get_span(1)) / 2;
99 h = this->h - this->y;
100 cpanel_zoom->reposition_window(x, y, w, h-y-yS(20));
101 cpanel_zoom->set_pointer_motion_range(h);
105 void CPanel::set_operation(int value)
107 for(int i = 0; i < CPANEL_OPERATIONS; i++)
109 if(i == CWINDOW_TOOL_WINDOW)
111 operation[i]->update(mwindow->edl->session->tool_window);
114 if(i == CWINDOW_TITLESAFE)
116 operation[i]->update(mwindow->edl->session->safe_regions);
119 // if(i == CWINDOW_SHOW_METERS)
121 // operation[i]->update(mwindow->edl->session->cwindow_meter);
126 operation[i]->update(0);
128 operation[i]->update(1);
131 if( operation[CWINDOW_ZOOM]->get_value() ||
132 operation[CWINDOW_CAMERA]->get_value() ||
133 operation[CWINDOW_PROJECTOR]->get_value() ) {
134 cpanel_zoom->set_shown(1);
135 subwindow->update_canvas(0);
138 cpanel_zoom->set_shown(0);
145 CPanelProtect::CPanelProtect(MWindow *mwindow, CPanel *gui, int x, int y)
148 mwindow->theme->get_image_set("protect"),
149 mwindow->edl->session->cwindow_operation == CWINDOW_PROTECT)
151 this->mwindow = mwindow;
153 set_tooltip(_("Protect video from changes (F1)"));
155 CPanelProtect::~CPanelProtect()
158 int CPanelProtect::handle_event()
160 gui->subwindow->set_operation(CWINDOW_PROTECT);
169 CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
172 mwindow->theme->get_image_set("mask"),
173 mwindow->edl->session->cwindow_operation == CWINDOW_MASK)
175 this->mwindow = mwindow;
177 set_tooltip(_("Edit mask (F3)"));
179 CPanelMask::~CPanelMask()
182 int CPanelMask::handle_event()
184 gui->subwindow->set_operation(CWINDOW_MASK);
191 CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
194 mwindow->theme->get_image_set("ruler"),
195 mwindow->edl->session->cwindow_operation == CWINDOW_RULER)
197 this->mwindow = mwindow;
199 set_tooltip(_("Ruler (F4)"));
201 CPanelRuler::~CPanelRuler()
204 int CPanelRuler::handle_event()
206 gui->subwindow->set_operation(CWINDOW_RULER);
213 CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
216 mwindow->theme->get_image_set("magnify"),
217 mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM)
219 this->mwindow = mwindow;
221 set_tooltip(_("Zoom view (F2)"));
223 CPanelMagnify::~CPanelMagnify()
226 int CPanelMagnify::handle_event()
228 gui->subwindow->set_operation(CWINDOW_ZOOM);
233 CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
236 mwindow->theme->get_image_set("camera"),
237 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
239 this->mwindow = mwindow;
241 set_tooltip(_("Adjust camera automation (F5)"));
243 CPanelCamera::~CPanelCamera()
246 int CPanelCamera::handle_event()
248 gui->subwindow->set_operation(CWINDOW_CAMERA);
253 CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
256 mwindow->theme->get_image_set("projector"),
257 mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
259 this->mwindow = mwindow;
261 set_tooltip(_("Adjust projector automation (F6)"));
263 CPanelProj::~CPanelProj()
266 int CPanelProj::handle_event()
268 gui->subwindow->set_operation(CWINDOW_PROJECTOR);
273 CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
276 mwindow->theme->get_image_set("crop"),
277 mwindow->edl->session->cwindow_operation == CWINDOW_CROP)
279 this->mwindow = mwindow;
281 set_tooltip(_("Crop a layer or output (F7)"));
284 CPanelCrop::~CPanelCrop()
288 int CPanelCrop::handle_event()
290 gui->subwindow->set_operation(CWINDOW_CROP);
297 CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
300 mwindow->theme->get_image_set("eyedrop"),
301 mwindow->edl->session->cwindow_operation == CWINDOW_EYEDROP)
303 this->mwindow = mwindow;
305 set_tooltip(_("Get color (F8)"));
308 CPanelEyedrop::~CPanelEyedrop()
312 int CPanelEyedrop::handle_event()
314 gui->subwindow->set_operation(CWINDOW_EYEDROP);
321 CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
324 mwindow->theme->get_image_set("tool"),
325 mwindow->edl->session->tool_window)
327 this->mwindow = mwindow;
329 set_tooltip(_("Show tool info (F9)"));
332 CPanelToolWindow::~CPanelToolWindow()
336 int CPanelToolWindow::handle_event()
338 mwindow->edl->session->tool_window = get_value();
339 gui->subwindow->tool_panel->update_show_window();
343 int CPanelToolWindow::set_shown(int shown)
346 mwindow->edl->session->tool_window = shown;
347 gui->subwindow->tool_panel->update_show_window();
352 CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
355 mwindow->theme->get_image_set("titlesafe"),
356 mwindow->edl->session->safe_regions)
358 this->mwindow = mwindow;
360 set_tooltip(_("Show safe regions (F10)"));
362 CPanelTitleSafe::~CPanelTitleSafe()
365 int CPanelTitleSafe::handle_event()
367 mwindow->edl->session->safe_regions = get_value();
368 return gui->subwindow->canvas->refresh(1);
371 CPanelZoom::CPanelZoom(MWindow *mwindow, CPanel *gui, int x, int y, int h)
372 : BC_FSlider(x, y, 1, h, h, -2., 2., 0, 0)
374 this->mwindow = mwindow;
376 set_precision(0.001);
377 set_tooltip(_("Zoom"));
379 CPanelZoom::~CPanelZoom()
382 int CPanelZoom::handle_event()
384 FloatAuto *z_auto = 0;
386 float value = get_value();
387 BC_FSlider::update(value);
388 double zoom = pow(10.,value);
389 switch( mwindow->edl->session->cwindow_operation ) {
391 gui->subwindow->canvas->set_zoom(mwindow->edl, zoom);
392 gui->subwindow->update_canvas();
395 aidx = AUTOMATION_CAMERA_Z;
397 case CWINDOW_PROJECTOR:
398 aidx = AUTOMATION_PROJECTOR_Z;
401 if( aidx < 0 ) return 1;
402 Track *track = mwindow->cwindow->calculate_affected_track();
403 if( !track ) return 1;
404 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
405 track->automation->autos[aidx], 1);
406 if( !z_auto ) return 1;
407 z_auto->set_value(zoom);
408 gui->subwindow->sync_parameters(CHANGE_PARAMS, 1, 1);
412 int CPanelZoom::set_shown(int shown)
416 update(gui->subwindow->canvas->get_zoom());
423 char *CPanelZoom::get_caption()
425 double value = get_value();
426 int frac = value >= 0. ? 1 : value >= -1. ? 2 : 3;
427 double zoom = pow(10., value);
428 char *caption = BC_Slider::get_caption();
429 sprintf(caption, "%.*f", frac, zoom);
433 void CPanelZoom::update(float zoom)
436 if( zoom < 0.01 ) zoom = 0.01;
437 float value = log10f(zoom);
438 BC_FSlider::update(value);