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)"));
154 // *** CONTEXT_HELP ***
155 context_help_set_keyword("Compositor Toolbar");
157 CPanelProtect::~CPanelProtect()
160 int CPanelProtect::handle_event()
162 gui->subwindow->set_operation(CWINDOW_PROTECT);
171 CPanelMask::CPanelMask(MWindow *mwindow, CPanel *gui, int x, int y)
174 mwindow->theme->get_image_set("mask"),
175 mwindow->edl->session->cwindow_operation == CWINDOW_MASK)
177 this->mwindow = mwindow;
179 set_tooltip(_("Edit mask (F3)"));
180 // *** CONTEXT_HELP ***
181 context_help_set_keyword("Masks");
183 CPanelMask::~CPanelMask()
186 int CPanelMask::handle_event()
188 gui->subwindow->set_operation(CWINDOW_MASK);
195 CPanelRuler::CPanelRuler(MWindow *mwindow, CPanel *gui, int x, int y)
198 mwindow->theme->get_image_set("ruler"),
199 mwindow->edl->session->cwindow_operation == CWINDOW_RULER)
201 this->mwindow = mwindow;
203 set_tooltip(_("Ruler (F4)"));
204 // *** CONTEXT_HELP ***
205 context_help_set_keyword("Compositor Toolbar");
207 CPanelRuler::~CPanelRuler()
210 int CPanelRuler::handle_event()
212 gui->subwindow->set_operation(CWINDOW_RULER);
219 CPanelMagnify::CPanelMagnify(MWindow *mwindow, CPanel *gui, int x, int y)
222 mwindow->theme->get_image_set("magnify"),
223 mwindow->edl->session->cwindow_operation == CWINDOW_ZOOM)
225 this->mwindow = mwindow;
227 set_tooltip(_("Zoom view (F2)"));
228 // *** CONTEXT_HELP ***
229 context_help_set_keyword("Compositor Toolbar");
231 CPanelMagnify::~CPanelMagnify()
234 int CPanelMagnify::handle_event()
236 gui->subwindow->set_operation(CWINDOW_ZOOM);
241 CPanelCamera::CPanelCamera(MWindow *mwindow, CPanel *gui, int x, int y)
244 mwindow->theme->get_image_set("camera"),
245 mwindow->edl->session->cwindow_operation == CWINDOW_CAMERA)
247 this->mwindow = mwindow;
249 set_tooltip(_("Adjust camera automation (F5)"));
250 // *** CONTEXT_HELP ***
251 context_help_set_keyword("Camera and Projector");
253 CPanelCamera::~CPanelCamera()
256 int CPanelCamera::handle_event()
258 gui->subwindow->set_operation(CWINDOW_CAMERA);
263 CPanelProj::CPanelProj(MWindow *mwindow, CPanel *gui, int x, int y)
266 mwindow->theme->get_image_set("projector"),
267 mwindow->edl->session->cwindow_operation == CWINDOW_PROJECTOR)
269 this->mwindow = mwindow;
271 set_tooltip(_("Adjust projector automation (F6)"));
272 // *** CONTEXT_HELP ***
273 context_help_set_keyword("Camera and Projector");
275 CPanelProj::~CPanelProj()
278 int CPanelProj::handle_event()
280 gui->subwindow->set_operation(CWINDOW_PROJECTOR);
285 CPanelCrop::CPanelCrop(MWindow *mwindow, CPanel *gui, int x, int y)
288 mwindow->theme->get_image_set("crop"),
289 mwindow->edl->session->cwindow_operation == CWINDOW_CROP)
291 this->mwindow = mwindow;
293 set_tooltip(_("Crop a layer or output (F7)"));
294 // *** CONTEXT_HELP ***
295 context_help_set_keyword("Cropping");
298 CPanelCrop::~CPanelCrop()
302 int CPanelCrop::handle_event()
304 gui->subwindow->set_operation(CWINDOW_CROP);
311 CPanelEyedrop::CPanelEyedrop(MWindow *mwindow, CPanel *gui, int x, int y)
314 mwindow->theme->get_image_set("eyedrop"),
315 mwindow->edl->session->cwindow_operation == CWINDOW_EYEDROP)
317 this->mwindow = mwindow;
319 set_tooltip(_("Get color (F8)"));
320 // *** CONTEXT_HELP ***
321 context_help_set_keyword("Compositor Toolbar");
324 CPanelEyedrop::~CPanelEyedrop()
328 int CPanelEyedrop::handle_event()
330 gui->subwindow->set_operation(CWINDOW_EYEDROP);
337 CPanelToolWindow::CPanelToolWindow(MWindow *mwindow, CPanel *gui, int x, int y)
340 mwindow->theme->get_image_set("tool"),
341 mwindow->edl->session->tool_window)
343 this->mwindow = mwindow;
345 set_tooltip(_("Show tool info (F9)"));
346 // *** CONTEXT_HELP ***
347 context_help_set_keyword("Compositor Toolbar");
350 CPanelToolWindow::~CPanelToolWindow()
354 int CPanelToolWindow::handle_event()
356 mwindow->edl->session->tool_window = get_value();
357 gui->subwindow->tool_panel->update_show_window();
361 int CPanelToolWindow::set_shown(int shown)
364 mwindow->edl->session->tool_window = shown;
365 gui->subwindow->tool_panel->update_show_window();
370 CPanelTitleSafe::CPanelTitleSafe(MWindow *mwindow, CPanel *gui, int x, int y)
373 mwindow->theme->get_image_set("titlesafe"),
374 mwindow->edl->session->safe_regions)
376 this->mwindow = mwindow;
378 set_tooltip(_("Show safe regions (F10)"));
379 // *** CONTEXT_HELP ***
380 context_help_set_keyword("Compositor Toolbar");
382 CPanelTitleSafe::~CPanelTitleSafe()
385 int CPanelTitleSafe::handle_event()
387 mwindow->edl->session->safe_regions = get_value();
388 return gui->subwindow->canvas->refresh(1);
391 CPanelZoom::CPanelZoom(MWindow *mwindow, CPanel *gui, int x, int y, int h)
392 : BC_FSlider(x, y, 1, h, h, -2., 2., 0, 0)
394 this->mwindow = mwindow;
396 set_precision(0.001);
397 set_tooltip(_("Zoom"));
399 CPanelZoom::~CPanelZoom()
402 int CPanelZoom::handle_event()
404 FloatAuto *z_auto = 0;
406 float value = get_value();
407 BC_FSlider::update(value);
408 double zoom = pow(10.,value);
409 switch( mwindow->edl->session->cwindow_operation ) {
411 gui->subwindow->canvas->set_zoom(mwindow->edl, zoom);
412 gui->subwindow->update_canvas();
415 aidx = AUTOMATION_CAMERA_Z;
417 case CWINDOW_PROJECTOR:
418 aidx = AUTOMATION_PROJECTOR_Z;
421 if( aidx < 0 ) return 1;
422 Track *track = mwindow->cwindow->calculate_affected_track();
423 if( !track ) return 1;
424 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
425 track->automation->autos[aidx], 1);
426 if( !z_auto ) return 1;
427 z_auto->set_value(zoom);
428 gui->subwindow->sync_parameters(CHANGE_PARAMS, 1, 1);
432 int CPanelZoom::set_shown(int shown)
436 update(gui->subwindow->canvas->get_zoom());
443 char *CPanelZoom::get_caption()
445 double value = get_value();
446 int frac = value >= 0. ? 1 : value >= -1. ? 2 : 3;
447 double zoom = pow(10., value);
448 char *caption = BC_Slider::get_caption();
449 sprintf(caption, "%.*f", frac, zoom);
453 void CPanelZoom::update(float zoom)
456 if( zoom < 0.01 ) zoom = 0.01;
457 float value = log10f(zoom);
458 BC_FSlider::update(value);