Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

cwindowtool.C

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

Generated on Sun Jan 8 13:38:52 2006 for Cinelerra-svn by  doxygen 1.4.4