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

vwindowgui.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "awindowgui.h"
00004 #include "awindow.h"
00005 #include "canvas.h"
00006 #include "clip.h"
00007 #include "clipedit.h"
00008 #include "edl.h"
00009 #include "edlsession.h"
00010 #include "filesystem.h"
00011 #include "filexml.h"
00012 #include "fonts.h"
00013 #include "labels.h"
00014 #include "language.h"
00015 #include "localsession.h"
00016 #include "mainclock.h"
00017 #include "mainmenu.h"
00018 #include "mainsession.h"
00019 #include "mainundo.h"
00020 #include "meterpanel.h"
00021 #include "mwindowgui.h"
00022 #include "mwindow.h"
00023 #include "playtransport.h"
00024 #include "preferences.h"
00025 #include "theme.h"
00026 #include "timebar.h"
00027 #include "tracks.h"
00028 #include "vframe.h"
00029 #include "vplayback.h"
00030 #include "vtimebar.h"
00031 #include "vwindowgui.h"
00032 #include "vwindow.h"
00033 
00034 
00035 
00036 
00037 VWindowGUI::VWindowGUI(MWindow *mwindow, VWindow *vwindow)
00038  : BC_Window(PROGRAM_NAME ": Viewer",
00039         mwindow->session->vwindow_x,
00040         mwindow->session->vwindow_y,
00041         mwindow->session->vwindow_w,
00042         mwindow->session->vwindow_h,
00043         100,
00044         100,
00045         1,
00046         1,
00047         1)
00048 {
00049         this->mwindow = mwindow;
00050         this->vwindow = vwindow;
00051 }
00052 
00053 VWindowGUI::~VWindowGUI()
00054 {
00055         delete canvas;
00056         delete transport;
00057 }
00058 
00059 void VWindowGUI::change_source(EDL *edl, char *title)
00060 {
00061         update_sources(title);
00062         char string[BCTEXTLEN];
00063         if(title[0]) 
00064                 sprintf(string, PROGRAM_NAME ": %s", title);
00065         else
00066                 sprintf(string, PROGRAM_NAME);
00067 
00068         lock_window("VWindowGUI::change_source");
00069         slider->set_position();
00070         timebar->update();
00071         set_title(string);
00072         unlock_window();
00073 }
00074 
00075 
00076 // Get source list from master EDL
00077 void VWindowGUI::update_sources(char *title)
00078 {
00079         lock_window("VWindowGUI::update_sources");
00080 
00081 //printf("VWindowGUI::update_sources 1\n");
00082         sources.remove_all_objects();
00083 //printf("VWindowGUI::update_sources 2\n");
00084 
00085 
00086 
00087         for(int i = 0;
00088                 i < mwindow->edl->clips.total;
00089                 i++)
00090         {
00091                 char *clip_title = mwindow->edl->clips.values[i]->local_session->clip_title;
00092                 int exists = 0;
00093 
00094                 for(int j = 0; j < sources.total; j++)
00095                 {
00096                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
00097                         {
00098                                 exists = 1;
00099                         }
00100                 }
00101 
00102                 if(!exists)
00103                 {
00104                         sources.append(new BC_ListBoxItem(clip_title));
00105                 }
00106         }
00107 //printf("VWindowGUI::update_sources 3\n");
00108 
00109         FileSystem fs;
00110         for(Asset *current = mwindow->edl->assets->first; 
00111                 current;
00112                 current = NEXT)
00113         {
00114                 char clip_title[BCTEXTLEN];
00115                 fs.extract_name(clip_title, current->path);
00116                 int exists = 0;
00117                 
00118                 for(int j = 0; j < sources.total; j++)
00119                 {
00120                         if(!strcasecmp(sources.values[j]->get_text(), clip_title))
00121                         {
00122                                 exists = 1;
00123                         }
00124                 }
00125                 
00126                 if(!exists)
00127                 {
00128                         sources.append(new BC_ListBoxItem(clip_title));
00129                 }
00130         }
00131 
00132 //printf("VWindowGUI::update_sources 4\n");
00133 
00134 //      source->update_list(&sources);
00135 //      source->update(title);
00136         unlock_window();
00137 }
00138 
00139 int VWindowGUI::create_objects()
00140 {
00141         in_point = 0;
00142         out_point = 0;
00143         set_icon(mwindow->theme->get_image("vwindow_icon"));
00144 
00145 //printf("VWindowGUI::create_objects 1\n");
00146         mwindow->theme->get_vwindow_sizes(this);
00147         mwindow->theme->draw_vwindow_bg(this);
00148         flash();
00149 
00150         meters = new VWindowMeters(mwindow, 
00151                 this,
00152                 mwindow->theme->vmeter_x,
00153                 mwindow->theme->vmeter_y,
00154                 mwindow->theme->vmeter_h);
00155         meters->create_objects();
00156 
00157 //printf("VWindowGUI::create_objects 1\n");
00158 // Requires meters to build
00159         edit_panel = new VWindowEditing(mwindow, vwindow);
00160         edit_panel->set_meters(meters);
00161         edit_panel->create_objects();
00162 
00163 //printf("VWindowGUI::create_objects 1\n");
00164         add_subwindow(slider = new VWindowSlider(mwindow, 
00165         vwindow, 
00166                 this, 
00167         mwindow->theme->vslider_x, 
00168         mwindow->theme->vslider_y, 
00169         mwindow->theme->vslider_w));
00170 
00171 //printf("VWindowGUI::create_objects 1\n");
00172         transport = new VWindowTransport(mwindow, 
00173                 this, 
00174                 mwindow->theme->vtransport_x, 
00175                 mwindow->theme->vtransport_y);
00176     transport->create_objects();
00177         transport->set_slider(slider);
00178 
00179 //printf("VWindowGUI::create_objects 1\n");
00180 //      add_subwindow(fps_title = new BC_Title(mwindow->theme->vedit_x, y, ""));
00181     add_subwindow(clock = new MainClock(mwindow,
00182                 mwindow->theme->vtime_x, 
00183                 mwindow->theme->vtime_y,
00184                 mwindow->theme->vtime_w));
00185 
00186 //printf("VWindowGUI::create_objects 1\n");
00187 //      add_subwindow(new BC_Title(mwindow->theme->vzoom_x, mwindow->theme->vzoom_y, "Zoom:"));
00188 //      zoom_panel = new VWindowZoom(mwindow, 
00189 //              this, 
00190 //              mwindow->theme->vzoom_x + 60, 
00191 //              mwindow->theme->vzoom_y);
00192 //      zoom_panel->create_objects();
00193 // 
00194         canvas = new VWindowCanvas(mwindow, this);
00195         canvas->create_objects(mwindow->edl);
00196 
00197 
00198 
00199 //printf("VWindowGUI::create_objects 1\n");
00200         add_subwindow(timebar = new VTimeBar(mwindow, 
00201                 this,
00202                 mwindow->theme->vtimebar_x,
00203                 mwindow->theme->vtimebar_y,
00204                 mwindow->theme->vtimebar_w, 
00205                 mwindow->theme->vtimebar_h));
00206         timebar->create_objects();
00207 //printf("VWindowGUI::create_objects 2\n");
00208 
00209 
00210 //printf("VWindowGUI::create_objects 1\n");
00211 //      source = new VWindowSource(mwindow, 
00212 //              this, 
00213 //              mwindow->theme->vsource_x,
00214 //              mwindow->theme->vsource_y);
00215 //      source->create_objects();       
00216         update_sources(_("None"));
00217 
00218 //printf("VWindowGUI::create_objects 2\n");
00219         deactivate();
00220         slider->activate();
00221         return 0;
00222 }
00223 
00224 int VWindowGUI::resize_event(int w, int h)
00225 {
00226         mwindow->session->vwindow_x = get_x();
00227         mwindow->session->vwindow_y = get_y();
00228         mwindow->session->vwindow_w = w;
00229         mwindow->session->vwindow_h = h;
00230 
00231         mwindow->theme->get_vwindow_sizes(this);
00232         mwindow->theme->draw_vwindow_bg(this);
00233         flash();
00234 
00235         edit_panel->reposition_buttons(mwindow->theme->vedit_x, 
00236                 mwindow->theme->vedit_y);
00237         slider->reposition_window(mwindow->theme->vslider_x, 
00238         mwindow->theme->vslider_y, 
00239         mwindow->theme->vslider_w);
00240 // Recalibrate pointer motion range
00241         slider->set_position();
00242         timebar->resize_event();
00243         transport->reposition_buttons(mwindow->theme->vtransport_x, 
00244                 mwindow->theme->vtransport_y);
00245         clock->reposition_window(mwindow->theme->vtime_x, 
00246                 mwindow->theme->vtime_y,
00247                 mwindow->theme->vtime_w);
00248         canvas->reposition_window(0,
00249                 mwindow->theme->vcanvas_x, 
00250                 mwindow->theme->vcanvas_y, 
00251                 mwindow->theme->vcanvas_w, 
00252                 mwindow->theme->vcanvas_h);
00253 //      source->reposition_window(mwindow->theme->vsource_x,
00254 //              mwindow->theme->vsource_y);
00255         meters->reposition_window(mwindow->theme->vmeter_x,
00256                 mwindow->theme->vmeter_y,
00257                 mwindow->theme->vmeter_h);
00258 
00259         BC_WindowBase::resize_event(w, h);
00260         return 1;
00261 }
00262 
00263 
00264 
00265 
00266 
00267 int VWindowGUI::translation_event()
00268 {
00269         mwindow->session->vwindow_x = get_x();
00270         mwindow->session->vwindow_y = get_y();
00271         return 0;
00272 }
00273 
00274 int VWindowGUI::close_event()
00275 {
00276         hide_window();
00277         mwindow->session->show_vwindow = 0;
00278         unlock_window();
00279         
00280         
00281         mwindow->gui->lock_window("VWindowGUI::close_event");
00282         mwindow->gui->mainmenu->show_vwindow->set_checked(0);
00283         mwindow->gui->unlock_window();
00284 
00285         lock_window("VWindowGUI::close_event");
00286         mwindow->save_defaults();
00287         return 1;
00288 }
00289 
00290 int VWindowGUI::keypress_event()
00291 {
00292         int result = 0;
00293         switch(get_keypress())
00294         {
00295                 case 'w':
00296                 case 'W':
00297                         close_event();
00298                         result = 1;
00299                         break;
00300                 case 'z':
00301                         mwindow->undo_entry(this);
00302                         break;
00303                 case 'Z':
00304                         mwindow->redo_entry(this);
00305                         break;
00306         }
00307         if(!result) result = transport->keypress_event();
00308         
00309         return result;
00310 }
00311 
00312 void VWindowGUI::drag_motion()
00313 {
00314         if(get_hidden()) return;
00315         if(mwindow->session->current_operation != DRAG_ASSET) return;
00316 
00317         int old_status = mwindow->session->vcanvas_highlighted;
00318 
00319         int cursor_x = get_relative_cursor_x();
00320         int cursor_y = get_relative_cursor_y();
00321         
00322         mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
00323                 cursor_x >= canvas->x &&
00324                 cursor_x < canvas->x + canvas->w &&
00325                 cursor_y >= canvas->y &&
00326                 cursor_y < canvas->y + canvas->h);
00327 //printf("VWindowGUI::drag_motion 1 %d\n", mwindow->session->vcanvas_highlighted);
00328 
00329 
00330         if(old_status != mwindow->session->vcanvas_highlighted)
00331                 canvas->draw_refresh();
00332 }
00333 
00334 int VWindowGUI::drag_stop()
00335 {
00336         if(get_hidden()) return 0;
00337 
00338         if(mwindow->session->vcanvas_highlighted &&
00339                 mwindow->session->current_operation == DRAG_ASSET)
00340         {
00341                 mwindow->session->vcanvas_highlighted = 0;
00342                 canvas->draw_refresh();
00343 
00344                 Asset *asset = mwindow->session->drag_assets->total ?
00345                         mwindow->session->drag_assets->values[0] :
00346                         0;
00347                 EDL *edl = mwindow->session->drag_clips->total ?
00348                         mwindow->session->drag_clips->values[0] :
00349                         0;
00350                 
00351                 if(asset)
00352                         vwindow->change_source(asset);
00353                 else
00354                 if(edl)
00355                         vwindow->change_source(edl);
00356                 return 1;
00357         }
00358 
00359         return 0;
00360 }
00361 
00362 
00363 
00364 
00365 
00366 VWindowMeters::VWindowMeters(MWindow *mwindow, 
00367         VWindowGUI *gui, 
00368         int x, 
00369         int y, 
00370         int h)
00371  : MeterPanel(mwindow, 
00372                 gui,
00373                 x,
00374                 y,
00375                 h,
00376                 mwindow->edl->session->audio_channels,
00377                 mwindow->edl->session->vwindow_meter)
00378 {
00379         this->mwindow = mwindow;
00380         this->gui = gui;
00381 }
00382 
00383 VWindowMeters::~VWindowMeters()
00384 {
00385 }
00386 
00387 int VWindowMeters::change_status_event()
00388 {
00389         mwindow->edl->session->vwindow_meter = use_meters;
00390 //printf("VWindowMeters::change_status_event 1 %d\n", mwindow->edl->session->vwindow_meter);
00391         mwindow->theme->get_vwindow_sizes(gui);
00392         gui->resize_event(gui->get_w(), gui->get_h());
00393         return 1;
00394 }
00395 
00396 
00397 
00398 
00399 
00400 
00401 
00402 VWindowEditing::VWindowEditing(MWindow *mwindow, VWindow *vwindow)
00403  : EditPanel(mwindow, 
00404                 vwindow->gui, 
00405                 mwindow->theme->vedit_x, 
00406                 mwindow->theme->vedit_y,
00407                 EDITING_ARROW, 
00408                 0,
00409                 0,
00410                 1, 
00411                 1,
00412                 0,
00413                 0,
00414                 1, 
00415                 0,
00416                 0,
00417                 0,
00418                 1,
00419                 1,
00420                 1,
00421                 0,
00422                 0)
00423 {
00424         this->mwindow = mwindow;
00425         this->vwindow = vwindow;
00426 }
00427 
00428 VWindowEditing::~VWindowEditing()
00429 {
00430 }
00431 
00432 void VWindowEditing::copy_selection()
00433 {
00434         vwindow->copy();
00435 }
00436 
00437 void VWindowEditing::splice_selection()
00438 {
00439         if(vwindow->get_edl())
00440         {
00441                 mwindow->gui->lock_window("VWindowEditing::splice_selection");
00442                 mwindow->splice(vwindow->get_edl());
00443                 mwindow->gui->unlock_window();
00444         }
00445 }
00446 
00447 void VWindowEditing::overwrite_selection()
00448 {
00449         if(vwindow->get_edl())
00450         {
00451                 mwindow->gui->lock_window("VWindowEditing::overwrite_selection");
00452                 mwindow->overwrite(vwindow->get_edl());
00453                 mwindow->gui->unlock_window();
00454         }
00455 }
00456 
00457 void VWindowEditing::toggle_label()
00458 {
00459         if(vwindow->get_edl())
00460         {
00461                 EDL *edl = vwindow->get_edl();
00462                 edl->labels->toggle_label(edl->local_session->get_selectionstart(1),
00463                         edl->local_session->get_selectionend(1));
00464                 vwindow->gui->timebar->update();
00465         }
00466 }
00467 
00468 void VWindowEditing::prev_label()
00469 {
00470         if(vwindow->get_edl())
00471         {
00472                 EDL *edl = vwindow->get_edl();
00473                 vwindow->gui->unlock_window();
00474                 vwindow->playback_engine->interrupt_playback(1);
00475                 vwindow->gui->lock_window("VWindowEditing::prev_label");
00476 
00477                 Label *current = edl->labels->prev_label(
00478                         edl->local_session->get_selectionstart(1));
00479                 
00480 
00481                 if(!current)
00482                 {
00483                         edl->local_session->set_selectionstart(0);
00484                         edl->local_session->set_selectionend(0);
00485                         vwindow->update_position(CHANGE_NONE, 0, 1);
00486                         vwindow->gui->timebar->update();
00487                 }
00488                 else
00489                 {
00490                         edl->local_session->set_selectionstart(current->position);
00491                         edl->local_session->set_selectionend(current->position);
00492                         vwindow->update_position(CHANGE_NONE, 0, 1);
00493                         vwindow->gui->timebar->update();
00494                 }
00495         }
00496 }
00497 
00498 void VWindowEditing::next_label()
00499 {
00500         if(vwindow->get_edl())
00501         {
00502                 EDL *edl = vwindow->get_edl();
00503                 Label *current = edl->labels->next_label(
00504                         edl->local_session->get_selectionstart(1));
00505                 if(!current)
00506                 {
00507                         vwindow->gui->unlock_window();
00508                         vwindow->playback_engine->interrupt_playback(1);
00509                         vwindow->gui->lock_window("VWindowEditing::next_label 1");
00510 
00511                         double position = edl->tracks->total_length();
00512                         edl->local_session->set_selectionstart(position);
00513                         edl->local_session->set_selectionend(position);
00514                         vwindow->update_position(CHANGE_NONE, 0, 1);
00515                         vwindow->gui->timebar->update();
00516                 }
00517                 else
00518                 {
00519                         vwindow->gui->unlock_window();
00520                         vwindow->playback_engine->interrupt_playback(1);
00521                         vwindow->gui->lock_window("VWindowEditing::next_label 2");
00522 
00523                         edl->local_session->set_selectionstart(current->position);
00524                         edl->local_session->set_selectionend(current->position);
00525                         vwindow->update_position(CHANGE_NONE, 0, 1);
00526                         vwindow->gui->timebar->update();
00527                 }
00528         }
00529 }
00530 
00531 void VWindowEditing::set_inpoint()
00532 {
00533         vwindow->set_inpoint();
00534 }
00535 
00536 void VWindowEditing::set_outpoint()
00537 {
00538         vwindow->set_outpoint();
00539 }
00540 
00541 void VWindowEditing::clear_inpoint()
00542 {
00543         vwindow->clear_inpoint();
00544 }
00545 
00546 void VWindowEditing::clear_outpoint()
00547 {
00548         vwindow->clear_outpoint();
00549 }
00550 
00551 void VWindowEditing::to_clip()
00552 {
00553         if(vwindow->get_edl())
00554         {
00555                 FileXML file;
00556                 EDL *edl = vwindow->get_edl();
00557                 double start = edl->local_session->get_selectionstart();
00558                 double end = edl->local_session->get_selectionend();
00559 
00560                 if(EQUIV(start, end))
00561                 {
00562                         end = edl->tracks->total_length();
00563                         start = 0;
00564                 }
00565 
00566 
00567 
00568                 edl->copy(start, 
00569                         end, 
00570                         1,
00571                         0,
00572                         0,
00573                         &file,
00574                         mwindow->plugindb,
00575                         "",
00576                         1);
00577 
00578 
00579 
00580 
00581                 EDL *new_edl = new EDL(mwindow->edl);
00582                 new_edl->create_objects();
00583                 new_edl->load_xml(mwindow->plugindb, &file, LOAD_ALL);
00584                 sprintf(new_edl->local_session->clip_title, _("Clip %d"), mwindow->session->clip_number++);
00585                 new_edl->local_session->set_selectionstart(0);
00586                 new_edl->local_session->set_selectionend(0);
00587 
00588 
00589 //printf("VWindowEditing::to_clip 1 %s\n", edl->local_session->clip_title);
00590                 new_edl->local_session->set_selectionstart(0.0);
00591                 new_edl->local_session->set_selectionend(0.0);
00592                 vwindow->clip_edit->create_clip(new_edl);
00593         }
00594 }
00595 
00596 
00597 
00598 
00599 
00600 
00601 VWindowSlider::VWindowSlider(MWindow *mwindow, 
00602         VWindow *vwindow, 
00603         VWindowGUI *gui,
00604         int x, 
00605         int y, 
00606         int pixels)
00607  : BC_PercentageSlider(x, 
00608                         y,
00609                         0,
00610                         pixels, 
00611                         pixels, 
00612                         0, 
00613                         1, 
00614                         0)
00615 {
00616         this->mwindow = mwindow;
00617         this->vwindow = vwindow;
00618         this->gui = gui;
00619         set_precision(0.00001);
00620 }
00621 
00622 VWindowSlider::~VWindowSlider()
00623 {
00624 }
00625 
00626 int VWindowSlider::handle_event()
00627 {
00628         unlock_window();
00629         vwindow->playback_engine->interrupt_playback(1);
00630         lock_window("VWindowSlider::handle_event");
00631 
00632         vwindow->update_position(CHANGE_NONE, 1, 0);
00633         gui->timebar->update();
00634         return 1;
00635 }
00636 
00637 void VWindowSlider::set_position()
00638 {
00639         EDL *edl = vwindow->get_edl();
00640         if(edl)
00641         {
00642                 double new_length = edl->tracks->total_playable_length();
00643                 if(EQUIV(edl->local_session->preview_end, 0))
00644                         edl->local_session->preview_end = new_length;
00645                 if(edl->local_session->preview_end > new_length)
00646                         edl->local_session->preview_end = new_length;
00647                 if(edl->local_session->preview_start > new_length)
00648                         edl->local_session->preview_start = 0;
00649 
00650                 update(mwindow->theme->vslider_w, 
00651                         edl->local_session->get_selectionstart(1), 
00652                         edl->local_session->preview_start, 
00653                         edl->local_session->preview_end);
00654         }
00655 }
00656 
00657 
00658 
00659 
00660 
00661 
00662 
00663 
00664 
00665 VWindowSource::VWindowSource(MWindow *mwindow, VWindowGUI *vwindow, int x, int y)
00666  : BC_PopupTextBox(vwindow, 
00667         &vwindow->sources, 
00668         "",
00669         x, 
00670         y, 
00671         200, 
00672         200)
00673 {
00674         this->mwindow = mwindow;
00675         this->vwindow = vwindow;
00676 }
00677 
00678 VWindowSource::~VWindowSource()
00679 {
00680 }
00681 
00682 int VWindowSource::handle_event()
00683 {
00684         return 1;
00685 }
00686 
00687 
00688 
00689 
00690 
00691 
00692 
00693 VWindowTransport::VWindowTransport(MWindow *mwindow, 
00694         VWindowGUI *gui, 
00695         int x, 
00696         int y)
00697  : PlayTransport(mwindow, 
00698         gui, 
00699         x, 
00700         y)
00701 {
00702         this->gui = gui;
00703 }
00704 
00705 EDL* VWindowTransport::get_edl()
00706 {
00707         return gui->vwindow->get_edl();
00708 }
00709 
00710 
00711 void VWindowTransport::goto_start()
00712 {
00713         gui->unlock_window();
00714         handle_transport(REWIND, 1);
00715         gui->lock_window("VWindowTransport::goto_start");
00716         gui->vwindow->goto_start();
00717 }
00718 
00719 void VWindowTransport::goto_end()
00720 {
00721         gui->unlock_window();
00722         handle_transport(GOTO_END, 1);
00723         gui->lock_window("VWindowTransport::goto_end");
00724         gui->vwindow->goto_end();
00725 }
00726 
00727 
00728 
00729 
00730 VWindowCanvas::VWindowCanvas(MWindow *mwindow, VWindowGUI *gui)
00731  : Canvas(gui,
00732                 mwindow->theme->vcanvas_x, 
00733                 mwindow->theme->vcanvas_y, 
00734                 mwindow->theme->vcanvas_w, 
00735                 mwindow->theme->vcanvas_h,
00736                 0,
00737                 0,
00738                 0,
00739                 0,
00740                 0,
00741                 1)
00742 {
00743         this->mwindow = mwindow;
00744         this->gui = gui;
00745 }
00746 
00747 void VWindowCanvas::zoom_resize_window(float percentage)
00748 {
00749         EDL *edl = mwindow->vwindow->get_edl();
00750         if(!edl) edl = mwindow->edl;
00751 
00752         int canvas_w, canvas_h;
00753         calculate_sizes(edl->get_aspect_ratio(), 
00754                 edl->session->output_w, 
00755                 edl->session->output_h, 
00756                 percentage,
00757                 canvas_w,
00758                 canvas_h);
00759         int new_w, new_h;
00760         new_w = canvas_w + (gui->get_w() - mwindow->theme->vcanvas_w);
00761         new_h = canvas_h + (gui->get_h() - mwindow->theme->vcanvas_h);
00762         gui->resize_window(new_w, new_h);
00763         gui->resize_event(new_w, new_h);
00764 }
00765 
00766 void VWindowCanvas::close_source()
00767 {
00768         mwindow->vwindow->remove_source();
00769 }
00770 
00771 
00772 void VWindowCanvas::draw_refresh()
00773 {
00774         EDL *edl = gui->vwindow->get_edl();
00775 
00776         if(!canvas->video_is_on()) canvas->clear_box(0, 0, canvas->get_w(), canvas->get_h());
00777         if(!canvas->video_is_on() && refresh_frame && edl)
00778         {
00779                 int in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h;
00780                 get_transfers(edl, 
00781                         in_x, 
00782                         in_y, 
00783                         in_w, 
00784                         in_h, 
00785                         out_x, 
00786                         out_y, 
00787                         out_w, 
00788                         out_h);
00789                 canvas->draw_vframe(refresh_frame,
00790                                 out_x, 
00791                                 out_y, 
00792                                 out_w, 
00793                                 out_h,
00794                                 in_x, 
00795                                 in_y, 
00796                                 in_w, 
00797                                 in_h,
00798                                 0);
00799         }
00800 
00801         if(!canvas->video_is_on())
00802         {
00803                 draw_overlays();
00804                 canvas->flash();
00805                 canvas->flush();
00806         }
00807 }
00808 
00809 void VWindowCanvas::draw_overlays()
00810 {
00811         if(mwindow->session->vcanvas_highlighted)
00812         {
00813                 canvas->set_color(WHITE);
00814                 canvas->set_inverse();
00815                 canvas->draw_rectangle(0, 0, canvas->get_w(), canvas->get_h());
00816                 canvas->draw_rectangle(1, 1, canvas->get_w() - 2, canvas->get_h() - 2);
00817                 canvas->set_opaque();
00818         }
00819 }
00820 
00821 
00822 
00823 
00824 
00825 
00826 
00827 
00828 
00829 
00830 
00831 
00832 
00833 
00834 
00835 
00836 
00837 
00838 
00839 
00840 
00841 
00842 
00843 
00844 
00845 
00846 
00847 
00848 
00849 
00850 
00851 
00852 
00853 
00854 
00855 
00856 
00857 #if 0
00858 void VWindowGUI::update_points()
00859 {
00860         EDL *edl = vwindow->get_edl();
00861 
00862 //printf("VWindowGUI::update_points 1\n");
00863         if(!edl) return;
00864 
00865 //printf("VWindowGUI::update_points 2\n");
00866         long pixel = (long)((double)edl->local_session->in_point / 
00867                 edl->tracks->total_playable_length() *
00868                 (mwindow->theme->vtimebar_w - 
00869                         2 * 
00870                         mwindow->theme->in_point[0]->get_w())) + 
00871                 mwindow->theme->in_point[0]->get_w();
00872 
00873 //printf("VWindowGUI::update_points 3 %d\n", edl->local_session->in_point);
00874         if(in_point)
00875         {
00876 //printf("VWindowGUI::update_points 3.1\n");
00877                 if(edl->local_session->in_point >= 0)
00878                 {
00879 //printf("VWindowGUI::update_points 4\n");
00880                         if(edl->local_session->in_point != in_point->position ||
00881                                 in_point->pixel != pixel)
00882                         {
00883                                 in_point->pixel = pixel;
00884                                 in_point->reposition();
00885                         }
00886 
00887 //printf("VWindowGUI::update_points 5\n");
00888                         in_point->position = edl->local_session->in_point;
00889 
00890 //printf("VWindowGUI::update_points 6\n");
00891                         if(edl->equivalent(in_point->position, edl->local_session->get_selectionstart(1)) ||
00892                                 edl->equivalent(in_point->position, edl->local_session->get_selectionend(1)))
00893                                 in_point->update(1);
00894                         else
00895                                 in_point->update(0);
00896 //printf("VWindowGUI::update_points 7\n");
00897                 }
00898                 else
00899                 {
00900                         delete in_point;
00901                         in_point = 0;
00902                 }
00903         }
00904         else
00905         if(edl->local_session->in_point >= 0)
00906         {
00907 //printf("VWindowGUI::update_points 8 %p\n", mwindow->theme->in_point);
00908                 add_subwindow(in_point = 
00909                         new VWindowInPoint(mwindow, 
00910                                 0, 
00911                                 this,
00912                                 pixel, 
00913                                 edl->local_session->in_point));
00914 //printf("VWindowGUI::update_points 9\n");
00915         }
00916 //printf("VWindowGUI::update_points 10\n");
00917 
00918         pixel = (long)((double)edl->local_session->out_point / 
00919                 (edl->tracks->total_playable_length() + 0.5) *
00920                 (mwindow->theme->vtimebar_w - 
00921                         2 * 
00922                         mwindow->theme->in_point[0]->get_w())) + 
00923                 mwindow->theme->in_point[0]->get_w() * 
00924                 2;
00925 
00926         if(out_point)
00927         {
00928                 if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
00929                 {
00930                         if(edl->local_session->out_point != out_point->position ||
00931                                 out_point->pixel != pixel) 
00932                         {
00933                                 out_point->pixel = pixel;
00934                                 out_point->reposition();
00935                         }
00936                         out_point->position = edl->local_session->out_point;
00937 
00938                         if(edl->equivalent(out_point->position, edl->local_session->get_selectionstart(1)) ||
00939                                 edl->equivalent(out_point->position, edl->local_session->get_selectionend(1)))
00940                                 out_point->update(1);
00941                         else
00942                                 out_point->update(0);
00943                 }
00944                 else
00945                 {
00946                         delete out_point;
00947                         out_point = 0;
00948                 }
00949         }
00950         else
00951         if(edl->local_session->out_point >= 0 && pixel >= 0 && pixel <= mwindow->theme->vtimebar_w)
00952         {
00953                 add_subwindow(out_point = 
00954                         new VWindowOutPoint(mwindow, 
00955                                 0, 
00956                                 this, 
00957                                 pixel, 
00958                                 edl->local_session->out_point));
00959         }
00960 }
00961 
00962 
00963 void VWindowGUI::update_labels()
00964 {
00965         EDL *edl = vwindow->get_edl();
00966         int output = 0;
00967 
00968         for(Label *current = edl->labels->first;
00969                 current;
00970                 current = NEXT)
00971         {
00972                 long pixel = (long)((current->position - edl->local_session->view_start) / edl->local_session->zoom_sample);
00973 
00974                 if(pixel >= 0 && pixel < mwindow->theme->vtimebar_w)
00975                 {
00976 // Create new label
00977                         if(output >= labels.total)
00978                         {
00979                                 LabelGUI *new_label;
00980                                 add_subwindow(new_label = new LabelGUI(mwindow, this, pixel, 0, current->position));
00981                                 labels.append(new_label);
00982                         }
00983                         else
00984 // Reposition old label
00985                         if(labels.values[output]->pixel != pixel)
00986                         {
00987                                 labels.values[output]->pixel = pixel;
00988                                 labels.values[output]->position = current->position;
00989                                 labels.values[output]->reposition();
00990                         }
00991 
00992                         if(mwindow->edl->local_session->get_selectionstart(1) <= current->position &&
00993                                 mwindow->edl->local_session->get_selectionend(1) >= current->position)
00994                                 labels.values[output]->update(1);
00995                         else
00996                         if(labels.values[output]->get_value())
00997                                 labels.values[output]->update(0);
00998                         output++;
00999                 }
01000         }
01001 
01002 // Delete excess labels
01003         while(labels.total > output)
01004         {
01005                 labels.remove_object();
01006         }
01007 }
01008 
01009 
01010 
01011 VWindowInPoint::VWindowInPoint(MWindow *mwindow, 
01012                 TimeBar *timebar, 
01013                 VWindowGUI *gui,
01014                 long pixel, 
01015                 double position)
01016  : InPointGUI(mwindow, 
01017                 timebar, 
01018                 pixel, 
01019                 position)
01020 {
01021         this->gui = gui;
01022 }
01023 
01024 int VWindowInPoint::handle_event()
01025 {
01026         EDL *edl = gui->vwindow->get_edl();
01027 
01028         if(edl)
01029         {
01030                 double position = edl->align_to_frame(this->position, 0);
01031 
01032                 edl->local_session->set_selectionstart(position);
01033                 edl->local_session->set_selectionend(position);
01034                 gui->timebar->update();
01035 
01036 // Que the VWindow
01037                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
01038         }
01039         return 1;
01040 }
01041 
01042 
01043 
01044 VWindowOutPoint::VWindowOutPoint(MWindow *mwindow, 
01045                 TimeBar *timebar, 
01046                 VWindowGUI *gui,
01047                 long pixel, 
01048                 double position)
01049  : OutPointGUI(mwindow, 
01050                 timebar, 
01051                 pixel, 
01052                 position)
01053 {
01054         this->gui = gui;
01055 }
01056 
01057 int VWindowOutPoint::handle_event()
01058 {
01059         EDL *edl = gui->vwindow->get_edl();
01060 
01061         if(edl)
01062         {
01063                 double position = edl->align_to_frame(this->position, 0);
01064 
01065                 edl->local_session->set_selectionstart(position);
01066                 edl->local_session->set_selectionend(position);
01067                 gui->timebar->update();
01068 
01069 // Que the VWindow
01070                 mwindow->vwindow->update_position(CHANGE_NONE, 0, 1);
01071         }
01072 
01073         return 1;
01074 }
01075 
01076 
01077 
01078 #endif
01079 

Generated on Sun Jan 8 13:39:02 2006 for Cinelerra-svn by  doxygen 1.4.4