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