00001 #include "automation.h"
00002 #include "clip.h"
00003 #include "condition.h"
00004 #include "cpanel.h"
00005 #include "cplayback.h"
00006 #include "cwindow.h"
00007 #include "cwindowgui.h"
00008 #include "cwindowtool.h"
00009 #include "edl.h"
00010 #include "edlsession.h"
00011 #include "floatauto.h"
00012 #include "floatautos.h"
00013 #include "keys.h"
00014 #include "language.h"
00015 #include "localsession.h"
00016 #include "mainsession.h"
00017 #include "maskauto.h"
00018 #include "maskautos.h"
00019 #include "mutex.h"
00020 #include "mwindow.h"
00021 #include "mwindowgui.h"
00022 #include "theme.h"
00023 #include "track.h"
00024 #include "trackcanvas.h"
00025 #include "transportque.h"
00026
00027
00028 CWindowTool::CWindowTool(MWindow *mwindow, CWindowGUI *gui)
00029 : Thread()
00030 {
00031 this->mwindow = mwindow;
00032 this->gui = gui;
00033 tool_gui = 0;
00034 done = 0;
00035 current_tool = CWINDOW_NONE;
00036 set_synchronous(1);
00037 input_lock = new Condition(0, "CWindowTool::input_lock");
00038 output_lock = new Condition(1, "CWindowTool::output_lock");
00039 tool_gui_lock = new Mutex("CWindowTool::tool_gui_lock");
00040 }
00041
00042 CWindowTool::~CWindowTool()
00043 {
00044 done = 1;
00045 stop_tool();
00046 input_lock->unlock();
00047 Thread::join();
00048 delete input_lock;
00049 delete output_lock;
00050 delete tool_gui_lock;
00051 }
00052
00053 void CWindowTool::start_tool(int operation)
00054 {
00055 CWindowToolGUI *new_gui = 0;
00056 int result = 0;
00057
00058
00059 if(current_tool != operation)
00060 {
00061 current_tool = operation;
00062 switch(operation)
00063 {
00064 case CWINDOW_EYEDROP:
00065 new_gui = new CWindowEyedropGUI(mwindow, this);
00066 break;
00067 case CWINDOW_CROP:
00068 new_gui = new CWindowCropGUI(mwindow, this);
00069 break;
00070 case CWINDOW_CAMERA:
00071 new_gui = new CWindowCameraGUI(mwindow, this);
00072 break;
00073 case CWINDOW_PROJECTOR:
00074 new_gui = new CWindowProjectorGUI(mwindow, this);
00075 break;
00076 case CWINDOW_MASK:
00077 new_gui = new CWindowMaskGUI(mwindow, this);
00078 break;
00079 default:
00080 result = 1;
00081 stop_tool();
00082 break;
00083 }
00084
00085
00086
00087
00088 if(!result)
00089 {
00090 stop_tool();
00091
00092 output_lock->lock("CWindowTool::start_tool");
00093 this->tool_gui = new_gui;
00094 tool_gui->create_objects();
00095
00096 if(mwindow->edl->session->tool_window &&
00097 mwindow->session->show_cwindow) tool_gui->show_window();
00098 tool_gui->flush();
00099
00100
00101
00102 input_lock->unlock();
00103 }
00104
00105 }
00106 else
00107 if(tool_gui)
00108 {
00109 tool_gui->lock_window("CWindowTool::start_tool");
00110 tool_gui->update();
00111 tool_gui->unlock_window();
00112 }
00113
00114
00115
00116 }
00117
00118
00119 void CWindowTool::stop_tool()
00120 {
00121 if(tool_gui)
00122 {
00123 tool_gui->lock_window("CWindowTool::stop_tool");
00124 tool_gui->set_done(0);
00125 tool_gui->unlock_window();
00126 }
00127 }
00128
00129 void CWindowTool::show_tool()
00130 {
00131 if(tool_gui && mwindow->edl->session->tool_window)
00132 {
00133 tool_gui->lock_window("CWindowTool::show_tool");
00134 tool_gui->show_window();
00135 tool_gui->unlock_window();
00136 }
00137 }
00138
00139 void CWindowTool::hide_tool()
00140 {
00141 if(tool_gui && mwindow->edl->session->tool_window)
00142 {
00143 tool_gui->lock_window("CWindowTool::show_tool");
00144 tool_gui->hide_window();
00145 tool_gui->unlock_window();
00146 }
00147 }
00148
00149
00150 void CWindowTool::run()
00151 {
00152 while(!done)
00153 {
00154 input_lock->lock("CWindowTool::run");
00155 if(!done)
00156 {
00157 tool_gui->run_window();
00158 tool_gui_lock->lock("CWindowTool::run");
00159 delete tool_gui;
00160 tool_gui = 0;
00161 tool_gui_lock->unlock();
00162 }
00163 output_lock->unlock();
00164 }
00165 }
00166
00167 void CWindowTool::update_show_window()
00168 {
00169 if(tool_gui)
00170 {
00171 tool_gui->lock_window("CWindowTool::update_show_window");
00172
00173 if(mwindow->edl->session->tool_window)
00174 {
00175 tool_gui->update();
00176 tool_gui->show_window();
00177 }
00178 else
00179 tool_gui->hide_window();
00180 tool_gui->flush();
00181
00182 tool_gui->unlock_window();
00183 }
00184 }
00185
00186 void CWindowTool::update_values()
00187 {
00188 tool_gui_lock->lock("CWindowTool::update_values");
00189 if(tool_gui)
00190 {
00191 tool_gui->lock_window("CWindowTool::update_values");
00192 tool_gui->update();
00193 tool_gui->flush();
00194 tool_gui->unlock_window();
00195 }
00196 tool_gui_lock->unlock();
00197 }
00198
00199
00200
00201
00202
00203
00204
00205 CWindowToolGUI::CWindowToolGUI(MWindow *mwindow,
00206 CWindowTool *thread,
00207 char *title,
00208 int w,
00209 int h)
00210 : BC_Window(title,
00211 mwindow->session->ctool_x,
00212 mwindow->session->ctool_y,
00213 w,
00214 h,
00215 w,
00216 h,
00217 0,
00218 0,
00219 1)
00220 {
00221 this->mwindow = mwindow;
00222 this->thread = thread;
00223 current_operation = 0;
00224 }
00225
00226 CWindowToolGUI::~CWindowToolGUI()
00227 {
00228 }
00229
00230 int CWindowToolGUI::close_event()
00231 {
00232 hide_window();
00233 flush();
00234 mwindow->edl->session->tool_window = 0;
00235 unlock_window();
00236
00237
00238
00239 thread->gui->lock_window("CWindowToolGUI::close_event");
00240 thread->gui->composite_panel->set_operation(mwindow->edl->session->cwindow_operation);
00241 thread->gui->flush();
00242 thread->gui->unlock_window();
00243
00244 lock_window("CWindowToolGUI::close_event");
00245 return 1;
00246 }
00247
00248 int CWindowToolGUI::keypress_event()
00249 {
00250 if(get_keypress() == 'w' || get_keypress() == 'W')
00251 return close_event();
00252 return 0;
00253 }
00254
00255 int CWindowToolGUI::translation_event()
00256 {
00257 mwindow->session->ctool_x = get_x();
00258 mwindow->session->ctool_y = get_y();
00259 return 0;
00260 }
00261
00262
00263
00264
00265
00266
00267 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int log_increment = 0)
00268 : BC_TumbleTextBox(gui,
00269 (float)value,
00270 (float)-65536,
00271 (float)65536,
00272 x,
00273 y,
00274 100)
00275 {
00276 this->gui = gui;
00277 set_log_floatincrement(log_increment);
00278 }
00279
00280 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
00281 : BC_TumbleTextBox(gui,
00282 (int64_t)value,
00283 (int64_t)-65536,
00284 (int64_t)65536,
00285 x,
00286 y,
00287 100)
00288 {
00289 this->gui = gui;
00290 }
00291 int CWindowCoord::handle_event()
00292 {
00293 gui->event_caller = this;
00294 gui->handle_event();
00295 return 1;
00296 }
00297
00298
00299 CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
00300 : BC_GenericButton(x, y, _("Do it"))
00301 {
00302 this->mwindow = mwindow;
00303 this->gui = gui;
00304 }
00305 int CWindowCropOK::handle_event()
00306 {
00307 mwindow->crop_video();
00308 return 1;
00309 }
00310
00311
00312 int CWindowCropOK::keypress_event()
00313 {
00314 if(get_keypress() == 0xd)
00315 {
00316 handle_event();
00317 return 1;
00318 }
00319 return 0;
00320 }
00321
00322
00323
00324
00325
00326
00327
00328 CWindowCropGUI::CWindowCropGUI(MWindow *mwindow, CWindowTool *thread)
00329 : CWindowToolGUI(mwindow,
00330 thread,
00331 PROGRAM_NAME ": Crop",
00332 330,
00333 100)
00334 {
00335 }
00336
00337
00338 CWindowCropGUI::~CWindowCropGUI()
00339 {
00340 }
00341
00342 void CWindowCropGUI::create_objects()
00343 {
00344 int x = 10, y = 10;
00345 BC_TumbleTextBox *textbox;
00346 BC_Title *title;
00347
00348 int column1 = 0;
00349 int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1),
00350 BC_Title::calculate_h(this, "X")) + 5;
00351 add_subwindow(title = new BC_Title(x, y, _("X1:")));
00352 column1 = MAX(column1, title->get_w());
00353 y += pad;
00354 add_subwindow(title = new BC_Title(x, y, _("W:")));
00355 column1 = MAX(column1, title->get_w());
00356 y += pad;
00357 add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
00358
00359 x += column1 + 5;
00360 y = 10;
00361 x1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_x1);
00362 x1->create_objects();
00363 y += pad;
00364 width = new CWindowCoord(thread->tool_gui,
00365 x,
00366 y,
00367 mwindow->edl->session->crop_x2 -
00368 mwindow->edl->session->crop_x1);
00369 width->create_objects();
00370
00371
00372 x += x1->get_w() + 10;
00373 y = 10;
00374 int column2 = 0;
00375 add_subwindow(title = new BC_Title(x, y, _("Y1:")));
00376 column2 = MAX(column2, title->get_w());
00377 y += pad;
00378 add_subwindow(title = new BC_Title(x, y, _("H:")));
00379 column2 = MAX(column2, title->get_w());
00380 y += pad;
00381
00382 y = 10;
00383 x += column2 + 5;
00384 y1 = new CWindowCoord(thread->tool_gui, x, y, mwindow->edl->session->crop_y1);
00385 y1->create_objects();
00386 y += pad;
00387 height = new CWindowCoord(thread->tool_gui,
00388 x,
00389 y,
00390 mwindow->edl->session->crop_y2 -
00391 mwindow->edl->session->crop_y1);
00392 height->create_objects();
00393 }
00394
00395 void CWindowCropGUI::handle_event()
00396 {
00397 int new_x1, new_y1;
00398 new_x1 = atol(x1->get_text());
00399 new_y1 = atol(y1->get_text());
00400 if(new_x1 != mwindow->edl->session->crop_x1)
00401 {
00402 mwindow->edl->session->crop_x2 = new_x1 +
00403 mwindow->edl->session->crop_x2 -
00404 mwindow->edl->session->crop_x1;
00405 mwindow->edl->session->crop_x1 = new_x1;
00406 }
00407 if(new_y1 != mwindow->edl->session->crop_y1)
00408 {
00409 mwindow->edl->session->crop_y2 = new_y1 +
00410 mwindow->edl->session->crop_y2 -
00411 mwindow->edl->session->crop_y1;
00412 mwindow->edl->session->crop_y1 = atol(y1->get_text());
00413 }
00414 mwindow->edl->session->crop_x2 = atol(width->get_text()) +
00415 mwindow->edl->session->crop_x1;
00416 mwindow->edl->session->crop_y2 = atol(height->get_text()) +
00417 mwindow->edl->session->crop_y1;
00418 update();
00419 mwindow->cwindow->gui->lock_window("CWindowCropGUI::handle_event");
00420 mwindow->cwindow->gui->canvas->draw_refresh();
00421 mwindow->cwindow->gui->unlock_window();
00422 }
00423
00424 void CWindowCropGUI::update()
00425 {
00426 x1->update((int64_t)mwindow->edl->session->crop_x1);
00427 y1->update((int64_t)mwindow->edl->session->crop_y1);
00428 width->update((int64_t)mwindow->edl->session->crop_x2 -
00429 mwindow->edl->session->crop_x1);
00430 height->update((int64_t)mwindow->edl->session->crop_y2 -
00431 mwindow->edl->session->crop_y1);
00432 }
00433
00434
00435
00436
00437
00438
00439 CWindowEyedropGUI::CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread)
00440 : CWindowToolGUI(mwindow,
00441 thread,
00442 PROGRAM_NAME ": Color",
00443 150,
00444 150)
00445 {
00446 }
00447
00448 CWindowEyedropGUI::~CWindowEyedropGUI()
00449 {
00450 }
00451
00452 void CWindowEyedropGUI::create_objects()
00453 {
00454 int x = 10;
00455 int y = 10;
00456 int x2 = 70;
00457 BC_Title *title1, *title2, *title3;
00458 add_subwindow(title1 = new BC_Title(x, y, "Red:"));
00459 y += title1->get_h() + 5;
00460 add_subwindow(title2 = new BC_Title(x, y, "Green:"));
00461 y += title2->get_h() + 5;
00462 add_subwindow(title3 = new BC_Title(x, y, "Blue:"));
00463
00464
00465 add_subwindow(red = new BC_Title(x2, title1->get_y(), "0"));
00466 add_subwindow(green = new BC_Title(x2, title2->get_y(), "0"));
00467 add_subwindow(blue = new BC_Title(x2, title3->get_y(), "0"));
00468
00469 y = blue->get_y() + blue->get_h() + 5;
00470 add_subwindow(sample = new BC_SubWindow(x, y, 50, 50));
00471 update();
00472 }
00473
00474 void CWindowEyedropGUI::update()
00475 {
00476 red->update(mwindow->edl->local_session->red);
00477 green->update(mwindow->edl->local_session->green);
00478 blue->update(mwindow->edl->local_session->blue);
00479
00480 int red = (int)(CLIP(mwindow->edl->local_session->red, 0, 1) * 0xff);
00481 int green = (int)(CLIP(mwindow->edl->local_session->green, 0, 1) * 0xff);
00482 int blue = (int)(CLIP(mwindow->edl->local_session->blue, 0, 1) * 0xff);
00483 sample->set_color((red << 16) | (green << 8) | blue);
00484 sample->draw_box(0, 0, sample->get_w(), sample->get_h());
00485 sample->set_color(BLACK);
00486 sample->draw_rectangle(0, 0, sample->get_w(), sample->get_h());
00487 sample->flash();
00488 }
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 CWindowCameraGUI::CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread)
00499 : CWindowToolGUI(mwindow,
00500 thread,
00501 PROGRAM_NAME ": Camera",
00502 170,
00503 170)
00504 {
00505 }
00506 CWindowCameraGUI::~CWindowCameraGUI()
00507 {
00508 }
00509
00510 void CWindowCameraGUI::create_objects()
00511 {
00512 int x = 10, y = 10, x1;
00513 Track *track = mwindow->cwindow->calculate_affected_track();
00514 FloatAuto *x_auto = 0;
00515 FloatAuto *y_auto = 0;
00516 FloatAuto *z_auto = 0;
00517 BC_Title *title;
00518 BC_Button *button;
00519
00520 if(track)
00521 {
00522 mwindow->cwindow->calculate_affected_autos(&x_auto,
00523 &y_auto,
00524 &z_auto,
00525 track,
00526 1,
00527 0,
00528 0,
00529 0);
00530 }
00531
00532 add_subwindow(title = new BC_Title(x, y, _("X:")));
00533 x += title->get_w();
00534 this->x = new CWindowCoord(this,
00535 x,
00536 y,
00537 x_auto ? x_auto->value : (float)0);
00538 this->x->create_objects();
00539 y += 30;
00540 x = 10;
00541 add_subwindow(title = new BC_Title(x, y, _("Y:")));
00542 x += title->get_w();
00543 this->y = new CWindowCoord(this,
00544 x,
00545 y,
00546 y_auto ? y_auto->value : (float)0);
00547 this->y->create_objects();
00548 y += 30;
00549 x = 10;
00550 add_subwindow(title = new BC_Title(x, y, _("Z:")));
00551 x += title->get_w();
00552 this->z = new CWindowCoord(this,
00553 x,
00554 y,
00555 z_auto ? z_auto->value : (float)1,
00556 1);
00557 this->z->create_objects();
00558 this->z->set_boundaries((float).0001, (float)256.0);
00559
00560 y += 30;
00561 x1 = 10;
00562 add_subwindow(button = new CWindowCameraLeft(mwindow, this, x1, y));
00563 x1 += button->get_w();
00564 add_subwindow(button = new CWindowCameraCenter(mwindow, this, x1, y));
00565 x1 += button->get_w();
00566 add_subwindow(button = new CWindowCameraRight(mwindow, this, x1, y));
00567
00568 y += button->get_h();
00569 x1 = 10;
00570 add_subwindow(button = new CWindowCameraTop(mwindow, this, x1, y));
00571 x1 += button->get_w();
00572 add_subwindow(button = new CWindowCameraMiddle(mwindow, this, x1, y));
00573 x1 += button->get_w();
00574 add_subwindow(button = new CWindowCameraBottom(mwindow, this, x1, y));
00575
00576 }
00577
00578 void CWindowCameraGUI::update_preview()
00579 {
00580 mwindow->restart_brender();
00581 mwindow->sync_parameters(CHANGE_PARAMS);
00582
00583 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00584 CHANGE_NONE,
00585 mwindow->edl,
00586 1);
00587 mwindow->cwindow->gui->lock_window("CWindowCameraGUI::update_preview");
00588 mwindow->cwindow->gui->canvas->draw_refresh();
00589 mwindow->cwindow->gui->unlock_window();
00590 }
00591
00592
00593 void CWindowCameraGUI::handle_event()
00594 {
00595 FloatAuto *x_auto = 0;
00596 FloatAuto *y_auto = 0;
00597 FloatAuto *z_auto = 0;
00598 Track *track = mwindow->cwindow->calculate_affected_track();
00599 if(track)
00600 {
00601 if(event_caller == x)
00602 {
00603 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
00604 track->automation->autos[AUTOMATION_CAMERA_X],
00605 1);
00606 if(x_auto)
00607 {
00608 x_auto->value = atof(x->get_text());
00609 update_preview();
00610 }
00611 }
00612 else
00613 if(event_caller == y)
00614 {
00615 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
00616 track->automation->autos[AUTOMATION_CAMERA_Y],
00617 1);
00618 if(y_auto)
00619 {
00620 y_auto->value = atof(y->get_text());
00621 update_preview();
00622 }
00623 }
00624 else
00625 if(event_caller == z)
00626 {
00627 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
00628 track->automation->autos[AUTOMATION_CAMERA_Z],
00629 1);
00630 if(z_auto)
00631 {
00632 float zoom = atof(z->get_text());
00633 if(zoom > 10) zoom = 10;
00634 else
00635 if(zoom < 0) zoom = 0;
00636
00637
00638
00639
00640 z_auto->value = zoom;
00641 mwindow->gui->lock_window("CWindowCameraGUI::handle_event");
00642 mwindow->gui->canvas->draw_overlays();
00643 mwindow->gui->canvas->flash();
00644 mwindow->gui->unlock_window();
00645 update_preview();
00646 }
00647 }
00648 }
00649 }
00650
00651 void CWindowCameraGUI::update()
00652 {
00653 FloatAuto *x_auto = 0;
00654 FloatAuto *y_auto = 0;
00655 FloatAuto *z_auto = 0;
00656 Track *track = mwindow->cwindow->calculate_affected_track();
00657
00658 if(track)
00659 {
00660 mwindow->cwindow->calculate_affected_autos(&x_auto,
00661 &y_auto,
00662 &z_auto,
00663 track,
00664 1,
00665 0,
00666 0,
00667 0);
00668 }
00669
00670 if(x_auto)
00671 x->update(x_auto->value);
00672 if(y_auto)
00673 y->update(y_auto->value);
00674 if(z_auto)
00675 z->update(z_auto->value);
00676 }
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 CWindowCameraLeft::CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00691 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
00692 {
00693 this->gui = gui;
00694 this->mwindow = mwindow;
00695 set_tooltip(_("Left justify"));
00696 }
00697 int CWindowCameraLeft::handle_event()
00698 {
00699 FloatAuto *x_auto = 0;
00700 FloatAuto *z_auto = 0;
00701 Track *track = mwindow->cwindow->calculate_affected_track();
00702 if(track)
00703 {
00704 mwindow->cwindow->calculate_affected_autos(&x_auto,
00705 0,
00706 &z_auto,
00707 track,
00708 1,
00709 1,
00710 0,
00711 0);
00712 }
00713
00714 if(x_auto && z_auto)
00715 {
00716 int w = 0, h = 0;
00717 track->get_source_dimensions(
00718 mwindow->edl->local_session->get_selectionstart(1),
00719 w,
00720 h);
00721
00722 if(w && h)
00723 {
00724 x_auto->value =
00725 (double)track->track_w / z_auto->value / 2 -
00726 (double)w / 2;
00727 gui->update();
00728 gui->update_preview();
00729 }
00730 }
00731
00732 return 1;
00733 }
00734
00735
00736 CWindowCameraCenter::CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00737 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
00738 {
00739 this->gui = gui;
00740 this->mwindow = mwindow;
00741 set_tooltip(_("Center horizontal"));
00742 }
00743 int CWindowCameraCenter::handle_event()
00744 {
00745 FloatAuto *x_auto = 0;
00746 Track *track = mwindow->cwindow->calculate_affected_track();
00747 if(track)
00748 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
00749 track->automation->autos[AUTOMATION_CAMERA_X],
00750 1);
00751
00752 if(x_auto)
00753 {
00754 x_auto->value = 0;
00755 gui->update();
00756 gui->update_preview();
00757 }
00758
00759 return 1;
00760 }
00761
00762
00763 CWindowCameraRight::CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00764 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
00765 {
00766 this->gui = gui;
00767 this->mwindow = mwindow;
00768 set_tooltip(_("Right justify"));
00769 }
00770 int CWindowCameraRight::handle_event()
00771 {
00772 FloatAuto *x_auto = 0;
00773 FloatAuto *z_auto = 0;
00774 Track *track = mwindow->cwindow->calculate_affected_track();
00775 if(track)
00776 {
00777 mwindow->cwindow->calculate_affected_autos(&x_auto,
00778 0,
00779 &z_auto,
00780 track,
00781 1,
00782 1,
00783 0,
00784 0);
00785 }
00786
00787 if(x_auto && z_auto)
00788 {
00789 int w = 0, h = 0;
00790 track->get_source_dimensions(
00791 mwindow->edl->local_session->get_selectionstart(1),
00792 w,
00793 h);
00794
00795 if(w && h)
00796 {
00797 x_auto->value = -((double)track->track_w / z_auto->value / 2 -
00798 (double)w / 2);
00799 gui->update();
00800 gui->update_preview();
00801 }
00802 }
00803
00804 return 1;
00805 }
00806
00807
00808 CWindowCameraTop::CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00809 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
00810 {
00811 this->gui = gui;
00812 this->mwindow = mwindow;
00813 set_tooltip(_("Top justify"));
00814 }
00815 int CWindowCameraTop::handle_event()
00816 {
00817 FloatAuto *y_auto = 0;
00818 FloatAuto *z_auto = 0;
00819 Track *track = mwindow->cwindow->calculate_affected_track();
00820 if(track)
00821 {
00822 mwindow->cwindow->calculate_affected_autos(0,
00823 &y_auto,
00824 &z_auto,
00825 track,
00826 1,
00827 0,
00828 1,
00829 0);
00830 }
00831
00832 if(y_auto && z_auto)
00833 {
00834 int w = 0, h = 0;
00835 track->get_source_dimensions(
00836 mwindow->edl->local_session->get_selectionstart(1),
00837 w,
00838 h);
00839
00840 if(w && h)
00841 {
00842 y_auto->value = (double)track->track_h / z_auto->value / 2 -
00843 (double)h / 2;
00844 gui->update();
00845 gui->update_preview();
00846 }
00847 }
00848
00849 return 1;
00850 }
00851
00852
00853 CWindowCameraMiddle::CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00854 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
00855 {
00856 this->gui = gui;
00857 this->mwindow = mwindow;
00858 set_tooltip(_("Center vertical"));
00859 }
00860 int CWindowCameraMiddle::handle_event()
00861 {
00862 FloatAuto *y_auto = 0;
00863 Track *track = mwindow->cwindow->calculate_affected_track();
00864 if(track)
00865 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
00866 track->automation->autos[AUTOMATION_CAMERA_Y], 1);
00867
00868 if(y_auto)
00869 {
00870 y_auto->value = 0;
00871 gui->update();
00872 gui->update_preview();
00873 }
00874
00875 return 1;
00876 }
00877
00878
00879 CWindowCameraBottom::CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y)
00880 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
00881 {
00882 this->gui = gui;
00883 this->mwindow = mwindow;
00884 set_tooltip(_("Bottom justify"));
00885 }
00886 int CWindowCameraBottom::handle_event()
00887 {
00888 FloatAuto *y_auto = 0;
00889 FloatAuto *z_auto = 0;
00890 Track *track = mwindow->cwindow->calculate_affected_track();
00891 if(track)
00892 {
00893 mwindow->cwindow->calculate_affected_autos(0,
00894 &y_auto,
00895 &z_auto,
00896 track,
00897 1,
00898 0,
00899 1,
00900 0);
00901 }
00902
00903 if(y_auto && z_auto)
00904 {
00905 int w = 0, h = 0;
00906 track->get_source_dimensions(
00907 mwindow->edl->local_session->get_selectionstart(1),
00908 w,
00909 h);
00910
00911 if(w && h)
00912 {
00913 y_auto->value = -((double)track->track_h / z_auto->value / 2 -
00914 (double)h / 2);
00915 gui->update();
00916 gui->update_preview();
00917 }
00918 }
00919
00920 return 1;
00921 }
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939 CWindowProjectorGUI::CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread)
00940 : CWindowToolGUI(mwindow,
00941 thread,
00942 PROGRAM_NAME ": Projector",
00943 170,
00944 170)
00945 {
00946 }
00947 CWindowProjectorGUI::~CWindowProjectorGUI()
00948 {
00949 }
00950 void CWindowProjectorGUI::create_objects()
00951 {
00952 int x = 10, y = 10, x1;
00953 Track *track = mwindow->cwindow->calculate_affected_track();
00954 FloatAuto *x_auto = 0;
00955 FloatAuto *y_auto = 0;
00956 FloatAuto *z_auto = 0;
00957 BC_Title *title;
00958 BC_Button *button;
00959
00960 if(track)
00961 {
00962 mwindow->cwindow->calculate_affected_autos(&x_auto,
00963 &y_auto,
00964 &z_auto,
00965 track,
00966 0,
00967 0,
00968 0,
00969 0);
00970 }
00971
00972 add_subwindow(title = new BC_Title(x, y, _("X:")));
00973 x += title->get_w();
00974 this->x = new CWindowCoord(this,
00975 x,
00976 y,
00977 x_auto ? x_auto->value : (float)0);
00978 this->x->create_objects();
00979 y += 30;
00980 x = 10;
00981 add_subwindow(title = new BC_Title(x, y, _("Y:")));
00982 x += title->get_w();
00983 this->y = new CWindowCoord(this,
00984 x,
00985 y,
00986 y_auto ? y_auto->value : (float)0);
00987 this->y->create_objects();
00988 y += 30;
00989 x = 10;
00990 add_subwindow(title = new BC_Title(x, y, _("Z:")));
00991 x += title->get_w();
00992 this->z = new CWindowCoord(this,
00993 x,
00994 y,
00995 z_auto ? z_auto->value : (float)1,
00996 1);
00997 this->z->create_objects();
00998 this->z->set_boundaries((float).0001, (float)256.0);
00999
01000 y += 30;
01001 x1 = 10;
01002 add_subwindow(button = new CWindowProjectorLeft(mwindow, this, x1, y));
01003 x1 += button->get_w();
01004 add_subwindow(button = new CWindowProjectorCenter(mwindow, this, x1, y));
01005 x1 += button->get_w();
01006 add_subwindow(button = new CWindowProjectorRight(mwindow, this, x1, y));
01007
01008 y += button->get_h();
01009 x1 = 10;
01010 add_subwindow(button = new CWindowProjectorTop(mwindow, this, x1, y));
01011 x1 += button->get_w();
01012 add_subwindow(button = new CWindowProjectorMiddle(mwindow, this, x1, y));
01013 x1 += button->get_w();
01014 add_subwindow(button = new CWindowProjectorBottom(mwindow, this, x1, y));
01015
01016 }
01017
01018 void CWindowProjectorGUI::update_preview()
01019 {
01020 mwindow->restart_brender();
01021 mwindow->sync_parameters(CHANGE_PARAMS);
01022 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01023 CHANGE_NONE,
01024 mwindow->edl,
01025 1);
01026 mwindow->cwindow->gui->lock_window("CWindowProjectorGUI::update_preview");
01027 mwindow->cwindow->gui->canvas->draw_refresh();
01028 mwindow->cwindow->gui->unlock_window();
01029 }
01030
01031 void CWindowProjectorGUI::handle_event()
01032 {
01033 FloatAuto *x_auto = 0;
01034 FloatAuto *y_auto = 0;
01035 FloatAuto *z_auto = 0;
01036 Track *track = mwindow->cwindow->calculate_affected_track();
01037
01038 if(track)
01039 {
01040 if(event_caller == x)
01041 {
01042 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
01043 track->automation->autos[AUTOMATION_PROJECTOR_X],
01044 1);
01045 if(x_auto)
01046 {
01047 x_auto->value = atof(x->get_text());
01048 update_preview();
01049 }
01050 }
01051 else
01052 if(event_caller == y)
01053 {
01054 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
01055 track->automation->autos[AUTOMATION_PROJECTOR_Y],
01056 1);
01057 if(y_auto)
01058 {
01059 y_auto->value = atof(y->get_text());
01060 update_preview();
01061 }
01062 }
01063 else
01064 if(event_caller == z)
01065 {
01066 z_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
01067 track->automation->autos[AUTOMATION_PROJECTOR_Z],
01068 1);
01069 if(z_auto)
01070 {
01071 float zoom = atof(z->get_text());
01072 if(zoom > 10000) zoom = 10000;
01073 else
01074 if(zoom < 0) zoom = 0;
01075
01076
01077 z_auto->value = zoom;
01078
01079 mwindow->gui->lock_window("CWindowProjectorGUI::handle_event");
01080 mwindow->gui->canvas->draw_overlays();
01081 mwindow->gui->canvas->flash();
01082 mwindow->gui->unlock_window();
01083
01084 update_preview();
01085 }
01086 }
01087 }
01088 }
01089
01090 void CWindowProjectorGUI::update()
01091 {
01092 FloatAuto *x_auto = 0;
01093 FloatAuto *y_auto = 0;
01094 FloatAuto *z_auto = 0;
01095 Track *track = mwindow->cwindow->calculate_affected_track();
01096
01097 if(track)
01098 {
01099 mwindow->cwindow->calculate_affected_autos(&x_auto,
01100 &y_auto,
01101 &z_auto,
01102 track,
01103 0,
01104 0,
01105 0,
01106 0);
01107 }
01108
01109 if(x_auto)
01110 x->update(x_auto->value);
01111 if(y_auto)
01112 y->update(y_auto->value);
01113 if(z_auto)
01114 z->update(z_auto->value);
01115 }
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164 CWindowProjectorLeft::CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01165 : BC_Button(x, y, mwindow->theme->get_image_set("left_justify"))
01166 {
01167 this->gui = gui;
01168 this->mwindow = mwindow;
01169 set_tooltip(_("Left justify"));
01170 }
01171 int CWindowProjectorLeft::handle_event()
01172 {
01173 FloatAuto *x_auto = 0;
01174 FloatAuto *z_auto = 0;
01175 Track *track = mwindow->cwindow->calculate_affected_track();
01176 if(track)
01177 {
01178 mwindow->cwindow->calculate_affected_autos(&x_auto,
01179 0,
01180 &z_auto,
01181 track,
01182 0,
01183 1,
01184 0,
01185 0);
01186 }
01187 if(x_auto && z_auto)
01188 {
01189 x_auto->value = (double)track->track_w * z_auto->value / 2 -
01190 (double)mwindow->edl->session->output_w / 2;
01191 gui->update();
01192 gui->update_preview();
01193 }
01194
01195 return 1;
01196 }
01197
01198
01199 CWindowProjectorCenter::CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01200 : BC_Button(x, y, mwindow->theme->get_image_set("center_justify"))
01201 {
01202 this->gui = gui;
01203 this->mwindow = mwindow;
01204 set_tooltip(_("Center horizontal"));
01205 }
01206 int CWindowProjectorCenter::handle_event()
01207 {
01208 FloatAuto *x_auto = 0;
01209 Track *track = mwindow->cwindow->calculate_affected_track();
01210 if(track)
01211 x_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
01212 track->automation->autos[AUTOMATION_PROJECTOR_X],
01213 1);
01214
01215 if(x_auto)
01216 {
01217 x_auto->value = 0;
01218 gui->update();
01219 gui->update_preview();
01220 }
01221
01222 return 1;
01223 }
01224
01225
01226 CWindowProjectorRight::CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01227 : BC_Button(x, y, mwindow->theme->get_image_set("right_justify"))
01228 {
01229 this->gui = gui;
01230 this->mwindow = mwindow;
01231 set_tooltip(_("Right justify"));
01232 }
01233 int CWindowProjectorRight::handle_event()
01234 {
01235 FloatAuto *x_auto = 0;
01236 FloatAuto *z_auto = 0;
01237 Track *track = mwindow->cwindow->calculate_affected_track();
01238 if(track)
01239 {
01240 mwindow->cwindow->calculate_affected_autos(&x_auto,
01241 0,
01242 &z_auto,
01243 track,
01244 0,
01245 1,
01246 0,
01247 0);
01248 }
01249
01250 if(x_auto && z_auto)
01251 {
01252 x_auto->value = -((double)track->track_w * z_auto->value / 2 -
01253 (double)mwindow->edl->session->output_w / 2);
01254 gui->update();
01255 gui->update_preview();
01256 }
01257
01258 return 1;
01259 }
01260
01261
01262 CWindowProjectorTop::CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01263 : BC_Button(x, y, mwindow->theme->get_image_set("top_justify"))
01264 {
01265 this->gui = gui;
01266 this->mwindow = mwindow;
01267 set_tooltip(_("Top justify"));
01268 }
01269 int CWindowProjectorTop::handle_event()
01270 {
01271 FloatAuto *y_auto = 0;
01272 FloatAuto *z_auto = 0;
01273 Track *track = mwindow->cwindow->calculate_affected_track();
01274 if(track)
01275 {
01276 mwindow->cwindow->calculate_affected_autos(0,
01277 &y_auto,
01278 &z_auto,
01279 track,
01280 0,
01281 0,
01282 1,
01283 0);
01284 }
01285
01286 if(y_auto && z_auto)
01287 {
01288 y_auto->value = (double)track->track_h * z_auto->value / 2 -
01289 (double)mwindow->edl->session->output_h / 2;
01290 gui->update();
01291 gui->update_preview();
01292 }
01293
01294 return 1;
01295 }
01296
01297
01298 CWindowProjectorMiddle::CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01299 : BC_Button(x, y, mwindow->theme->get_image_set("middle_justify"))
01300 {
01301 this->gui = gui;
01302 this->mwindow = mwindow;
01303 set_tooltip(_("Center vertical"));
01304 }
01305 int CWindowProjectorMiddle::handle_event()
01306 {
01307 FloatAuto *y_auto = 0;
01308 Track *track = mwindow->cwindow->calculate_affected_track();
01309 if(track)
01310 y_auto = (FloatAuto*)mwindow->cwindow->calculate_affected_auto(
01311 track->automation->autos[AUTOMATION_PROJECTOR_Y], 1);
01312
01313 if(y_auto)
01314 {
01315 y_auto->value = 0;
01316 gui->update();
01317 gui->update_preview();
01318 }
01319
01320 return 1;
01321 }
01322
01323
01324 CWindowProjectorBottom::CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y)
01325 : BC_Button(x, y, mwindow->theme->get_image_set("bottom_justify"))
01326 {
01327 this->gui = gui;
01328 this->mwindow = mwindow;
01329 set_tooltip(_("Bottom justify"));
01330 }
01331 int CWindowProjectorBottom::handle_event()
01332 {
01333 FloatAuto *y_auto = 0;
01334 FloatAuto *z_auto = 0;
01335 Track *track = mwindow->cwindow->calculate_affected_track();
01336 if(track)
01337 {
01338 mwindow->cwindow->calculate_affected_autos(0,
01339 &y_auto,
01340 &z_auto,
01341 track,
01342 0,
01343 0,
01344 1,
01345 0);
01346 }
01347
01348 if(y_auto && z_auto)
01349 {
01350 y_auto->value = -((double)track->track_h * z_auto->value / 2 -
01351 (double)mwindow->edl->session->output_h / 2);
01352 gui->update();
01353 gui->update_preview();
01354 }
01355
01356 return 1;
01357 }
01358
01359
01360
01361
01362
01363
01364
01365
01366 CWindowMaskMode::CWindowMaskMode(MWindow *mwindow,
01367 CWindowToolGUI *gui,
01368 int x,
01369 int y,
01370 char *text)
01371 : BC_PopupMenu(x,
01372 y,
01373 200,
01374 text,
01375 1)
01376 {
01377 this->mwindow = mwindow;
01378 this->gui = gui;
01379 }
01380
01381 void CWindowMaskMode::create_objects()
01382 {
01383 add_item(new BC_MenuItem(mode_to_text(MASK_MULTIPLY_ALPHA)));
01384 add_item(new BC_MenuItem(mode_to_text(MASK_SUBTRACT_ALPHA)));
01385 }
01386
01387 char* CWindowMaskMode::mode_to_text(int mode)
01388 {
01389 switch(mode)
01390 {
01391 case MASK_MULTIPLY_ALPHA:
01392 return _("Multiply alpha");
01393 break;
01394
01395 case MASK_SUBTRACT_ALPHA:
01396 return _("Subtract alpha");
01397 break;
01398 }
01399
01400 return _("Subtract alpha");
01401 }
01402
01403 int CWindowMaskMode::text_to_mode(char *text)
01404 {
01405 if(!strcasecmp(text, _("Multiply alpha")))
01406 return MASK_MULTIPLY_ALPHA;
01407 else
01408 if(!strcasecmp(text, _("Subtract alpha")))
01409 return MASK_SUBTRACT_ALPHA;
01410
01411 return MASK_SUBTRACT_ALPHA;
01412 }
01413
01414 int CWindowMaskMode::handle_event()
01415 {
01416 MaskAuto *keyframe;
01417 Track *track;
01418 MaskPoint *point;
01419 SubMask *mask;
01420 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01421 keyframe,
01422 mask,
01423 point,
01424 0);
01425
01426 if(track)
01427 {
01428 ((MaskAuto*)track->automation->autos[AUTOMATION_MASK]->default_auto)->mode =
01429 text_to_mode(get_text());
01430 }
01431
01432
01433 gui->update_preview();
01434 return 1;
01435 }
01436
01437
01438
01439
01440
01441
01442
01443
01444 CWindowMaskDelete::CWindowMaskDelete(MWindow *mwindow,
01445 CWindowToolGUI *gui,
01446 int x,
01447 int y)
01448 : BC_GenericButton(x, y, _("Delete"))
01449 {
01450 this->mwindow = mwindow;
01451 this->gui = gui;
01452 }
01453
01454 int CWindowMaskDelete::handle_event()
01455 {
01456 MaskAuto *keyframe;
01457 Track *track = mwindow->cwindow->calculate_affected_track();
01458 MaskPoint *point;
01459 SubMask *mask;
01460
01461
01462 if(track)
01463 {
01464 MaskAutos *mask_autos = (MaskAutos*)track->automation->autos[AUTOMATION_MASK];
01465 for(MaskAuto *current = (MaskAuto*)mask_autos->default_auto;
01466 current; )
01467 {
01468 SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
01469
01470
01471
01472 for(int i = mwindow->cwindow->gui->affected_point;
01473 i < submask->points.total - 1;
01474 i++)
01475 {
01476 *submask->points.values[i] = *submask->points.values[i + 1];
01477 }
01478
01479 if(submask->points.total)
01480 {
01481 submask->points.remove_object(
01482 submask->points.values[submask->points.total - 1]);
01483 }
01484
01485
01486 if(current == (MaskAuto*)mask_autos->default_auto)
01487 current = (MaskAuto*)mask_autos->first;
01488 else
01489 current = (MaskAuto*)NEXT;
01490 }
01491 gui->update();
01492 gui->update_preview();
01493 }
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522 return 1;
01523 }
01524
01525 int CWindowMaskDelete::keypress_event()
01526 {
01527 if(get_keypress() == BACKSPACE ||
01528 get_keypress() == DELETE)
01529 return handle_event();
01530 return 0;
01531 }
01532
01533
01534 CWindowMaskCycleNext::CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
01535 : BC_GenericButton(x, y, _("Cycle next"))
01536 {
01537 this->mwindow = mwindow;
01538 this->gui = gui;
01539 }
01540 int CWindowMaskCycleNext::handle_event()
01541 {
01542 MaskAuto *keyframe;
01543 Track *track;
01544 MaskPoint *point;
01545 SubMask *mask;
01546 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01547 keyframe,
01548 mask,
01549 point,
01550 0);
01551
01552 MaskPoint *temp;
01553
01554
01555 if(keyframe && mask->points.total)
01556 {
01557 temp = mask->points.values[0];
01558
01559 for(int i = 0; i < mask->points.total - 1; i++)
01560 {
01561 mask->points.values[i] = mask->points.values[i + 1];
01562 }
01563 mask->points.values[mask->points.total - 1] = temp;
01564
01565 mwindow->cwindow->gui->affected_point--;
01566 if(mwindow->cwindow->gui->affected_point < 0)
01567 mwindow->cwindow->gui->affected_point = mask->points.total - 1;
01568
01569 gui->update();
01570 gui->update_preview();
01571 }
01572
01573 return 1;
01574 }
01575
01576 CWindowMaskCyclePrev::CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
01577 : BC_GenericButton(x, y, _("Cycle prev"))
01578 {
01579 this->mwindow = mwindow;
01580 this->gui = gui;
01581 }
01582 int CWindowMaskCyclePrev::handle_event()
01583 {
01584 MaskAuto *keyframe;
01585 Track *track;
01586 MaskPoint *point;
01587 SubMask *mask;
01588 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01589 keyframe,
01590 mask,
01591 point,
01592 0);
01593
01594
01595 MaskPoint *temp;
01596 if(keyframe && mask->points.total)
01597 {
01598 temp = mask->points.values[mask->points.total - 1];
01599
01600 for(int i = mask->points.total - 1; i > 0; i--)
01601 {
01602 mask->points.values[i] = mask->points.values[i - 1];
01603 }
01604 mask->points.values[0] = temp;
01605
01606 mwindow->cwindow->gui->affected_point++;
01607 if(mwindow->cwindow->gui->affected_point >= mask->points.total)
01608 mwindow->cwindow->gui->affected_point = 0;
01609
01610 gui->update();
01611 gui->update_preview();
01612 }
01613 return 1;
01614 }
01615
01616
01617 CWindowMaskNumber::CWindowMaskNumber(MWindow *mwindow,
01618 CWindowToolGUI *gui,
01619 int x,
01620 int y)
01621 : BC_TumbleTextBox(gui,
01622 (int64_t)mwindow->edl->session->cwindow_mask,
01623 (int64_t)0,
01624 (int64_t)SUBMASKS - 1,
01625 x,
01626 y,
01627 100)
01628 {
01629 this->mwindow = mwindow;
01630 this->gui = gui;
01631 }
01632
01633 CWindowMaskNumber::~CWindowMaskNumber()
01634 {
01635 }
01636
01637 int CWindowMaskNumber::handle_event()
01638 {
01639 mwindow->edl->session->cwindow_mask = atol(get_text());
01640 gui->update();
01641 gui->update_preview();
01642 return 1;
01643 }
01644
01645
01646
01647
01648
01649 CWindowMaskFeather::CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
01650 : BC_TumbleTextBox(gui,
01651 (int64_t)0,
01652 (int64_t)0,
01653 (int64_t)0xff,
01654 x,
01655 y,
01656 100)
01657 {
01658 this->mwindow = mwindow;
01659 this->gui = gui;
01660 }
01661 CWindowMaskFeather::~CWindowMaskFeather()
01662 {
01663 }
01664 int CWindowMaskFeather::handle_event()
01665 {
01666 MaskAuto *keyframe;
01667 Track *track;
01668 MaskPoint *point;
01669 SubMask *mask;
01670 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01671 keyframe,
01672 mask,
01673 point,
01674 1);
01675
01676 keyframe->feather = atof(get_text());
01677 gui->update_preview();
01678 return 1;
01679 }
01680
01681 CWindowMaskValue::CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
01682 : BC_ISlider(x,
01683 y,
01684 0,
01685 200,
01686 200,
01687 0,
01688 100,
01689 0)
01690 {
01691 this->mwindow = mwindow;
01692 this->gui = gui;
01693 }
01694
01695 CWindowMaskValue::~CWindowMaskValue()
01696 {
01697 }
01698
01699 int CWindowMaskValue::handle_event()
01700 {
01701 MaskAuto *keyframe;
01702 Track *track;
01703 MaskPoint *point;
01704 SubMask *mask;
01705 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01706 keyframe,
01707 mask,
01708 point,
01709 1);
01710
01711 keyframe->value = get_value();
01712 gui->update_preview();
01713 return 1;
01714 }
01715
01716
01717
01718 CWindowMaskBeforePlugins::CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y)
01719 : BC_CheckBox(x,
01720 y,
01721 1,
01722 _("Apply mask before plugins"))
01723 {
01724 this->gui = gui;
01725 }
01726
01727 int CWindowMaskBeforePlugins::handle_event()
01728 {
01729 MaskAuto *keyframe;
01730 Track *track;
01731 MaskPoint *point;
01732 SubMask *mask;
01733 ((CWindowMaskGUI*)gui)->get_keyframe(track,
01734 keyframe,
01735 mask,
01736 point,
01737 1);
01738
01739 keyframe->apply_before_plugins = get_value();
01740 gui->update_preview();
01741 return 1;
01742 }
01743
01744
01745
01746
01747
01748
01749
01750
01751 CWindowMaskGUI::CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread)
01752 : CWindowToolGUI(mwindow,
01753 thread,
01754 PROGRAM_NAME ": Mask",
01755 330,
01756 280)
01757 {
01758 this->mwindow = mwindow;
01759 this->thread = thread;
01760 }
01761 CWindowMaskGUI::~CWindowMaskGUI()
01762 {
01763 delete number;
01764 delete feather;
01765 }
01766
01767 void CWindowMaskGUI::create_objects()
01768 {
01769 int x = 10, y = 10;
01770 MaskAuto *keyframe = 0;
01771 Track *track = mwindow->cwindow->calculate_affected_track();
01772 if(track)
01773 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], 0);
01774
01775 BC_Title *title;
01776 add_subwindow(title = new BC_Title(x, y, _("Mode:")));
01777 add_subwindow(mode = new CWindowMaskMode(mwindow,
01778 this,
01779 x + title->get_w(),
01780 y,
01781 ""));
01782 mode->create_objects();
01783 y += 40;
01784 add_subwindow(new BC_Title(x, y, _("Value:")));
01785 add_subwindow(value = new CWindowMaskValue(mwindow, this, x + 50, y));
01786 y += 30;
01787 add_subwindow(delete_point = new CWindowMaskDelete(mwindow, this, x, y));
01788 y += 30;
01789 add_subwindow(new BC_Title(x, y, _("Mask number:")));
01790 number = new CWindowMaskNumber(mwindow,
01791 this,
01792 x + 110,
01793 y);
01794 number->create_objects();
01795 y += 30;
01796 add_subwindow(new BC_Title(x, y, _("Feather:")));
01797 feather = new CWindowMaskFeather(mwindow,
01798 this,
01799 x + 110,
01800 y);
01801 feather->create_objects();
01802 y += 30;
01803 add_subwindow(title = new BC_Title(x, y, _("X:")));
01804 x += title->get_w();
01805 this->x = new CWindowCoord(this,
01806 x,
01807 y,
01808 (float)0.0);
01809 this->x->create_objects();
01810 x += 150;
01811 add_subwindow(title = new BC_Title(x, y, _("Y:")));
01812 x += title->get_w();
01813 this->y = new CWindowCoord(this,
01814 x,
01815 y,
01816 (float)0.0);
01817 this->y->create_objects();
01818
01819 y += 30;
01820
01821
01822 add_subwindow(this->apply_before_plugins = new CWindowMaskBeforePlugins(this,
01823 10,
01824 y));
01825
01826
01827
01828 update();
01829 }
01830
01831 void CWindowMaskGUI::get_keyframe(Track* &track,
01832 MaskAuto* &keyframe,
01833 SubMask* &mask,
01834 MaskPoint* &point,
01835 int create_it)
01836 {
01837 keyframe = 0;
01838 track = mwindow->cwindow->calculate_affected_track();
01839 if(track)
01840 keyframe = (MaskAuto*)mwindow->cwindow->calculate_affected_auto(track->automation->autos[AUTOMATION_MASK], create_it);
01841 else
01842 keyframe = 0;
01843
01844 if(keyframe)
01845 mask = keyframe->get_submask(mwindow->edl->session->cwindow_mask);
01846 else
01847 mask = 0;
01848
01849 point = 0;
01850 if(keyframe)
01851 {
01852 if(mwindow->cwindow->gui->affected_point < mask->points.total &&
01853 mwindow->cwindow->gui->affected_point >= 0)
01854 {
01855 point = mask->points.values[mwindow->cwindow->gui->affected_point];
01856 }
01857 }
01858 }
01859
01860 void CWindowMaskGUI::update()
01861 {
01862 MaskAuto *keyframe;
01863 Track *track;
01864 MaskPoint *point;
01865 SubMask *mask;
01866
01867 get_keyframe(track,
01868 keyframe,
01869 mask,
01870 point,
01871 0);
01872
01873
01874 if(point)
01875 {
01876 x->update(point->x);
01877 y->update(point->y);
01878 }
01879
01880
01881 if(mask)
01882 {
01883 feather->update((int64_t)keyframe->feather);
01884 value->update((int64_t)keyframe->value);
01885 apply_before_plugins->update((int64_t)keyframe->apply_before_plugins);
01886 }
01887
01888
01889 number->update((int64_t)mwindow->edl->session->cwindow_mask);
01890
01891
01892 if(track)
01893 {
01894 mode->set_text(
01895 CWindowMaskMode::mode_to_text(((MaskAuto*)track->automation->autos[AUTOMATION_MASK]->default_auto)->mode));
01896 }
01897
01898 }
01899
01900 void CWindowMaskGUI::handle_event()
01901 {
01902 MaskAuto *keyframe;
01903 Track *track;
01904 MaskPoint *point;
01905 SubMask *mask;
01906 get_keyframe(track,
01907 keyframe,
01908 mask,
01909 point,
01910 0);
01911
01912 if(point)
01913 {
01914 point->x = atof(x->get_text());
01915 point->y = atof(y->get_text());
01916 }
01917
01918 update_preview();
01919 }
01920
01921 void CWindowMaskGUI::update_preview()
01922 {
01923 mwindow->restart_brender();
01924 mwindow->sync_parameters(CHANGE_PARAMS);
01925 mwindow->cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01926 CHANGE_NONE,
01927 mwindow->edl,
01928 1);
01929 mwindow->cwindow->gui->lock_window("CWindowMaskGUI::update_preview");
01930 mwindow->cwindow->gui->canvas->draw_refresh();
01931 mwindow->cwindow->gui->unlock_window();
01932 }
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942