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 += 15;
83 subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y, h-y-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-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);
137 cpanel_zoom->set_shown(0);
144 CPanelProtect::CPanelProtect(MWindow *mwindow, CPanel *gui, int x, int y)
147 mwindow->theme->get_image_set("protect"),
148 mwindow->edl->session->cwindow_operation == CWINDOW_PROTECT)
150 this->mwindow = mwindow;
152 set_tooltip(_("Protect video from changes"));
154 CPanelProtect::~CPanelProtect()
157 int CPanelProtect::handle_event()
159 gui->subwindow->set_operation(CWINDOW_PROTECT);
168 CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
171 mwindow->theme->get_image_set("mask"),
172 mwindow->edl->session->cwindow_operation == CWINDOW_MASK)
174 this->mwindow = mwindow;
176 set_tooltip(_("Edit mask"));
178 CPanelMask::~CPanelMask()
181 int CPanelMask::handle_event()
183 gui->subwindow->set_operation(CWINDOW_MASK);
190 CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
193 mwindow->theme->get_image_set("ruler"),
194 mwindow->edl->session->cwindow_operation == CWINDOW_RULER)
196 this->mwindow = mwindow;
198 set_tooltip(_("Ruler"));
200 CPanelRuler::~CPanelRuler()
203 int CPanelRuler::handle_event()
205 gui->subwindow->set_operation(CWINDOW_RULER);
212 CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
215 mwindow->theme->get_image_set("magnify"),
216 mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM)
218 this->mwindow = mwindow;
220 set_tooltip(_("Zoom view"));
222 CPanelMagnify::~CPanelMagnify()
225 int CPanelMagnify::handle_event()
227 gui->subwindow->set_operation(CWINDOW_ZOOM);
232 CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
235 mwindow->theme->get_image_set("camera"),
236 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
238 this->mwindow = mwindow;
240 set_tooltip(_("Adjust camera automation"));
242 CPanelCamera::~CPanelCamera()
245 int CPanelCamera::handle_event()
247 gui->subwindow->set_operation(CWINDOW_CAMERA);
252 CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
255 mwindow->theme->get_image_set("projector"),
256 mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
258 this->mwindow = mwindow;
260 set_tooltip(_("Adjust projector automation"));
262 CPanelProj::~CPanelProj()
265 int CPanelProj::handle_event()
267 gui->subwindow->set_operation(CWINDOW_PROJECTOR);
272 CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
275 mwindow->theme->get_image_set("crop"),
276 mwindow->edl->session->cwindow_operation == CWINDOW_CROP)
278 this->mwindow = mwindow;
280 set_tooltip(_("Crop a layer or output"));
283 CPanelCrop::~CPanelCrop()
287 int CPanelCrop::handle_event()
289 gui->subwindow->set_operation(CWINDOW_CROP);
296 CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
299 mwindow->theme->get_image_set("eyedrop"),
300 mwindow->edl->session->cwindow_operation == CWINDOW_EYEDROP)
302 this->mwindow = mwindow;
304 set_tooltip(_("Get color"));
307 CPanelEyedrop::~CPanelEyedrop()
311 int CPanelEyedrop::handle_event()
313 gui->subwindow->set_operation(CWINDOW_EYEDROP);
320 CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
323 mwindow->theme->get_image_set("tool"),
324 mwindow->edl->session->tool_window)
326 this->mwindow = mwindow;
328 set_tooltip(_("Show tool info"));
331 CPanelToolWindow::~CPanelToolWindow()
335 int CPanelToolWindow::handle_event()
337 mwindow->edl->session->tool_window = get_value();
338 gui->subwindow->tool_panel->update_show_window();
342 int CPanelToolWindow::set_shown(int shown)
345 mwindow->edl->session->tool_window = shown;
346 gui->subwindow->tool_panel->update_show_window();
351 CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
354 mwindow->theme->get_image_set("titlesafe"),
355 mwindow->edl->session->safe_regions)
357 this->mwindow = mwindow;
359 set_tooltip(_("Show safe regions"));
361 CPanelTitleSafe::~CPanelTitleSafe()
364 int CPanelTitleSafe::handle_event()
366 mwindow->edl->session->safe_regions = get_value();
367 gui->subwindow->canvas->draw_refresh();
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->zoom_canvas(zoom, 1);
394 aidx = AUTOMATION_CAMERA_Z;
396 case CWINDOW_PROJECTOR:
397 aidx = AUTOMATION_PROJECTOR_Z;
400 if( aidx < 0 ) return 1;
401 Track *track = mwindow->cwindow->calculate_affected_track();
402 if( !track ) return 1;
403 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
404 track->automation->autos[aidx], 1);
405 if( !z_auto ) return 1;
406 z_auto->set_value(zoom);
407 gui->subwindow->update_tool();
408 mwindow->gui->lock_window("CPanelZoom::handle_event 1");
409 mwindow->gui->draw_overlays(1);
410 mwindow->gui->unlock_window();
411 mwindow->sync_parameters(CHANGE_PARAMS);
415 int CPanelZoom::set_shown(int shown)
419 update(gui->subwindow->canvas->get_zoom());
426 char *CPanelZoom::get_caption()
428 double value = get_value();
429 int frac = value >= 0. ? 1 : value >= -1. ? 2 : 3;
430 double zoom = pow(10., value);
431 char *caption = BC_Slider::get_caption();
432 sprintf(caption, "%.*f", frac, zoom);
436 void CPanelZoom::update(float zoom)
439 if( zoom < 0.01 ) zoom = 0.01;
440 float value = log(zoom) / log(10.);
441 BC_FSlider::update(value);