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;
83 subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y+15, h-y-15));
86 void CPanel::reposition_buttons(int x, int y)
91 for(int i = 0; i < CPANEL_OPERATIONS; i++)
93 operation[i]->reposition_window(x, y);
94 y += operation[i]->get_h();
96 x += (w - BC_Slider::get_span(1)) / 2;
97 cpanel_zoom->reposition_window(x, y+15);
101 void CPanel::set_operation(int value)
103 for(int i = 0; i < CPANEL_OPERATIONS; i++)
105 if(i == CWINDOW_TOOL_WINDOW)
107 operation[i]->update(mwindow->edl->session->tool_window);
110 if(i == CWINDOW_TITLESAFE)
112 operation[i]->update(mwindow->edl->session->safe_regions);
115 // if(i == CWINDOW_SHOW_METERS)
117 // operation[i]->update(mwindow->edl->session->cwindow_meter);
122 operation[i]->update(0);
124 operation[i]->update(1);
127 if( operation[CWINDOW_ZOOM]->get_value() ||
128 operation[CWINDOW_CAMERA]->get_value() ||
129 operation[CWINDOW_PROJECTOR]->get_value() ) {
130 cpanel_zoom->set_shown(1);
133 cpanel_zoom->set_shown(0);
140 CPanelProtect::CPanelProtect(MWindow *mwindow, CPanel *gui, int x, int y)
143 mwindow->theme->get_image_set("protect"),
144 mwindow->edl->session->cwindow_operation == CWINDOW_PROTECT)
146 this->mwindow = mwindow;
148 set_tooltip(_("Protect video from changes"));
150 CPanelProtect::~CPanelProtect()
153 int CPanelProtect::handle_event()
155 gui->subwindow->set_operation(CWINDOW_PROTECT);
164 CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
167 mwindow->theme->get_image_set("mask"),
168 mwindow->edl->session->cwindow_operation == CWINDOW_MASK)
170 this->mwindow = mwindow;
172 set_tooltip(_("Edit mask"));
174 CPanelMask::~CPanelMask()
177 int CPanelMask::handle_event()
179 gui->subwindow->set_operation(CWINDOW_MASK);
186 CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
189 mwindow->theme->get_image_set("ruler"),
190 mwindow->edl->session->cwindow_operation == CWINDOW_RULER)
192 this->mwindow = mwindow;
194 set_tooltip(_("Ruler"));
196 CPanelRuler::~CPanelRuler()
199 int CPanelRuler::handle_event()
201 gui->subwindow->set_operation(CWINDOW_RULER);
208 CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
211 mwindow->theme->get_image_set("magnify"),
212 mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM)
214 this->mwindow = mwindow;
216 set_tooltip(_("Zoom view"));
218 CPanelMagnify::~CPanelMagnify()
221 int CPanelMagnify::handle_event()
223 gui->subwindow->set_operation(CWINDOW_ZOOM);
228 CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
231 mwindow->theme->get_image_set("camera"),
232 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
234 this->mwindow = mwindow;
236 set_tooltip(_("Adjust camera automation"));
238 CPanelCamera::~CPanelCamera()
241 int CPanelCamera::handle_event()
243 gui->subwindow->set_operation(CWINDOW_CAMERA);
248 CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
251 mwindow->theme->get_image_set("projector"),
252 mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
254 this->mwindow = mwindow;
256 set_tooltip(_("Adjust projector automation"));
258 CPanelProj::~CPanelProj()
261 int CPanelProj::handle_event()
263 gui->subwindow->set_operation(CWINDOW_PROJECTOR);
268 CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
271 mwindow->theme->get_image_set("crop"),
272 mwindow->edl->session->cwindow_operation == CWINDOW_CROP)
274 this->mwindow = mwindow;
276 set_tooltip(_("Crop a layer or output"));
279 CPanelCrop::~CPanelCrop()
283 int CPanelCrop::handle_event()
285 gui->subwindow->set_operation(CWINDOW_CROP);
292 CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
295 mwindow->theme->get_image_set("eyedrop"),
296 mwindow->edl->session->cwindow_operation == CWINDOW_EYEDROP)
298 this->mwindow = mwindow;
300 set_tooltip(_("Get color"));
303 CPanelEyedrop::~CPanelEyedrop()
307 int CPanelEyedrop::handle_event()
309 gui->subwindow->set_operation(CWINDOW_EYEDROP);
316 CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
319 mwindow->theme->get_image_set("tool"),
320 mwindow->edl->session->tool_window)
322 this->mwindow = mwindow;
324 set_tooltip(_("Show tool info"));
327 CPanelToolWindow::~CPanelToolWindow()
331 int CPanelToolWindow::handle_event()
333 mwindow->edl->session->tool_window = get_value();
334 gui->subwindow->tool_panel->update_show_window();
338 int CPanelToolWindow::set_shown(int shown)
341 mwindow->edl->session->tool_window = shown;
342 gui->subwindow->tool_panel->update_show_window();
347 CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
350 mwindow->theme->get_image_set("titlesafe"),
351 mwindow->edl->session->safe_regions)
353 this->mwindow = mwindow;
355 set_tooltip(_("Show safe regions"));
357 CPanelTitleSafe::~CPanelTitleSafe()
360 int CPanelTitleSafe::handle_event()
362 mwindow->edl->session->safe_regions = get_value();
363 gui->subwindow->canvas->draw_refresh();
367 CPanelZoom::CPanelZoom(MWindow *mwindow, CPanel *gui, int x, int y, int h)
368 : BC_FSlider(x, y, 1, h-30, h, -2., 2., 0, 0)
370 this->mwindow = mwindow;
372 set_precision(0.001);
373 set_tooltip(_("Zoom"));
375 CPanelZoom::~CPanelZoom()
378 int CPanelZoom::handle_event()
380 FloatAuto *z_auto = 0;
382 float value = get_value();
383 BC_FSlider::update(value);
384 double zoom = pow(10.,value);
385 switch( mwindow->edl->session->cwindow_operation ) {
387 gui->subwindow->zoom_canvas(zoom, 1);
390 aidx = AUTOMATION_CAMERA_Z;
392 case CWINDOW_PROJECTOR:
393 aidx = AUTOMATION_PROJECTOR_Z;
396 if( aidx < 0 ) return 1;
397 Track *track = mwindow->cwindow->calculate_affected_track();
398 if( !track ) return 1;
399 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
400 track->automation->autos[aidx], 1);
401 if( !z_auto ) return 1;
402 z_auto->set_value(zoom);
403 gui->subwindow->update_tool();
404 mwindow->gui->lock_window("CPanelZoom::handle_event 1");
405 mwindow->gui->draw_overlays(1);
406 mwindow->gui->unlock_window();
407 mwindow->sync_parameters(CHANGE_PARAMS);
411 int CPanelZoom::set_shown(int shown)
415 update(gui->subwindow->canvas->get_zoom());
422 char *CPanelZoom::get_caption()
424 double value = get_value();
425 int frac = value >= 0. ? 1 : value >= -1. ? 2 : 3;
426 double zoom = pow(10., value);
427 char *caption = BC_Slider::get_caption();
428 sprintf(caption, "%.*f", frac, zoom);
432 void CPanelZoom::update(float zoom)
435 if( zoom < 0.01 ) zoom = 0.01;
436 float value = log(zoom) / log(10.);
437 BC_FSlider::update(value);