00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "awindowgui.h"
00004 #include "awindow.h"
00005 #include "bcsignals.h"
00006 #include "cache.h"
00007 #include "clip.h"
00008 #include "clipedit.h"
00009 #include "cplayback.h"
00010 #include "ctimebar.h"
00011 #include "cwindow.h"
00012 #include "cwindowgui.h"
00013 #include "defaults.h"
00014 #include "edl.h"
00015 #include "edlsession.h"
00016 #include "filexml.h"
00017 #include "gwindow.h"
00018 #include "gwindowgui.h"
00019 #include "keyframe.h"
00020 #include "language.h"
00021 #include "labels.h"
00022 #include "levelwindow.h"
00023 #include "localsession.h"
00024 #include "mainclock.h"
00025 #include "maincursor.h"
00026 #include "mainindexes.h"
00027 #include "mainmenu.h"
00028 #include "mainsession.h"
00029 #include "mainundo.h"
00030 #include "maskautos.h"
00031 #include "mtimebar.h"
00032 #include "mwindowgui.h"
00033 #include "mwindow.h"
00034 #include "patchbay.h"
00035 #include "playbackengine.h"
00036 #include "pluginset.h"
00037 #include "recordlabel.h"
00038 #include "samplescroll.h"
00039 #include "trackcanvas.h"
00040 #include "track.h"
00041 #include "trackscroll.h"
00042 #include "tracks.h"
00043 #include "transition.h"
00044 #include "transportque.h"
00045 #include "units.h"
00046 #include "undostackitem.h"
00047 #include "vplayback.h"
00048 #include "vwindow.h"
00049 #include "vwindowgui.h"
00050 #include "zoombar.h"
00051 #include "automation.h"
00052 #include "maskautos.h"
00053
00054
00055 #include <string.h>
00056
00057
00058
00059
00060
00061
00062 void MWindow::add_audio_track_entry(int above, Track *dst)
00063 {
00064 add_audio_track(above, dst);
00065 save_backup();
00066 undo->update_undo(_("add track"), LOAD_ALL);
00067
00068 restart_brender();
00069 gui->get_scrollbars();
00070 gui->canvas->draw();
00071 gui->patchbay->update();
00072 gui->cursor->draw();
00073 gui->canvas->flash();
00074 gui->canvas->activate();
00075 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00076 CHANGE_EDL,
00077 edl,
00078 1);
00079 }
00080
00081 void MWindow::add_video_track_entry(Track *dst)
00082 {
00083 add_video_track(1, dst);
00084 undo->update_undo(_("add track"), LOAD_ALL);
00085
00086 restart_brender();
00087 gui->get_scrollbars();
00088 gui->canvas->draw();
00089 gui->patchbay->update();
00090 gui->cursor->draw();
00091 gui->canvas->flash();
00092 gui->canvas->activate();
00093 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00094 CHANGE_EDL,
00095 edl,
00096 1);
00097 save_backup();
00098 }
00099
00100
00101 int MWindow::add_audio_track(int above, Track *dst)
00102 {
00103 edl->tracks->add_audio_track(above, dst);
00104 edl->tracks->update_y_pixels(theme);
00105 save_backup();
00106 return 0;
00107 }
00108
00109 int MWindow::add_video_track(int above, Track *dst)
00110 {
00111 edl->tracks->add_video_track(above, dst);
00112 edl->tracks->update_y_pixels(theme);
00113 save_backup();
00114 return 0;
00115 }
00116
00117
00118
00119
00120
00121 void MWindow::asset_to_size()
00122 {
00123 if(session->drag_assets->total &&
00124 session->drag_assets->values[0]->video_data)
00125 {
00126 int w, h;
00127
00128
00129 w = session->drag_assets->values[0]->width;
00130 h = session->drag_assets->values[0]->height;
00131
00132
00133 edl->session->output_w = w;
00134 edl->session->output_h = h;
00135
00136
00137 if(defaults->get("AUTOASPECT", 0))
00138 {
00139 create_aspect_ratio(edl->session->aspect_w,
00140 edl->session->aspect_h,
00141 w,
00142 h);
00143 }
00144
00145 save_backup();
00146
00147 undo->update_undo(_("asset to size"), LOAD_ALL);
00148 restart_brender();
00149 sync_parameters(CHANGE_ALL);
00150 }
00151 }
00152
00153
00154
00155 void MWindow::clear_entry()
00156 {
00157 clear(1);
00158
00159 edl->optimize();
00160 save_backup();
00161 undo->update_undo(_("clear"), LOAD_EDITS | LOAD_TIMEBAR);
00162
00163 restart_brender();
00164 update_plugin_guis();
00165 gui->update(1, 2, 1, 1, 1, 1, 0);
00166 cwindow->update(1, 0, 0, 0, 1);
00167 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00168 CHANGE_EDL,
00169 edl,
00170 1);
00171 }
00172
00173 void MWindow::clear(int clear_handle)
00174 {
00175 double start = edl->local_session->get_selectionstart();
00176 double end = edl->local_session->get_selectionend();
00177 if(clear_handle || !EQUIV(start, end))
00178 {
00179 edl->clear(start,
00180 end,
00181 edl->session->labels_follow_edits,
00182 edl->session->plugins_follow_edits);
00183 }
00184 }
00185
00186 void MWindow::clear_automation()
00187 {
00188 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
00189 edl->local_session->get_selectionend());
00190 save_backup();
00191 undo->update_undo(_("clear keyframes"), LOAD_AUTOMATION);
00192
00193 restart_brender();
00194 update_plugin_guis();
00195 gui->canvas->draw_overlays();
00196 gui->canvas->flash();
00197 sync_parameters(CHANGE_PARAMS);
00198 gui->patchbay->update();
00199 cwindow->update(1, 0, 0);
00200 }
00201
00202 int MWindow::clear_default_keyframe()
00203 {
00204 edl->tracks->clear_default_keyframe();
00205 save_backup();
00206 undo->update_undo(_("clear default keyframe"), LOAD_AUTOMATION);
00207
00208 restart_brender();
00209 gui->canvas->draw_overlays();
00210 gui->canvas->flash();
00211 sync_parameters(CHANGE_PARAMS);
00212 gui->patchbay->update();
00213 cwindow->update(1, 0, 0);
00214
00215 return 0;
00216 }
00217
00218 void MWindow::clear_labels()
00219 {
00220 clear_labels(edl->local_session->get_selectionstart(),
00221 edl->local_session->get_selectionend());
00222 undo->update_undo(_("clear labels"), LOAD_TIMEBAR);
00223
00224 gui->timebar->update();
00225 cwindow->update(0, 0, 0, 0, 1);
00226 save_backup();
00227 }
00228
00229 int MWindow::clear_labels(double start, double end)
00230 {
00231 edl->labels->clear(start, end, 0);
00232 return 0;
00233 }
00234
00235 void MWindow::concatenate_tracks()
00236 {
00237 edl->tracks->concatenate_tracks(edl->session->plugins_follow_edits);
00238 save_backup();
00239 undo->update_undo(_("concatenate tracks"), LOAD_EDITS);
00240
00241 restart_brender();
00242 gui->update(1, 1, 0, 0, 1, 0, 0);
00243 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00244 CHANGE_EDL,
00245 edl,
00246 1);
00247 }
00248
00249
00250 void MWindow::copy()
00251 {
00252 copy(edl->local_session->get_selectionstart(),
00253 edl->local_session->get_selectionend());
00254 }
00255
00256 int MWindow::copy(double start, double end)
00257 {
00258 if(start == end) return 1;
00259
00260
00261 FileXML file;
00262
00263 edl->copy(start,
00264 end,
00265 0,
00266 0,
00267 0,
00268 &file,
00269 plugindb,
00270 "",
00271 1);
00272
00273
00274
00275
00276
00277 gui->get_clipboard()->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
00278
00279
00280 save_backup();
00281 return 0;
00282 }
00283
00284 int MWindow::copy_automation()
00285 {
00286 FileXML file;
00287 edl->tracks->copy_automation(edl->local_session->get_selectionstart(),
00288 edl->local_session->get_selectionend(),
00289 &file,
00290 0,
00291 0);
00292 gui->get_clipboard()->to_clipboard(file.string,
00293 strlen(file.string),
00294 SECONDARY_SELECTION);
00295 return 0;
00296 }
00297
00298 int MWindow::copy_default_keyframe()
00299 {
00300 FileXML file;
00301 edl->tracks->copy_default_keyframe(&file);
00302 gui->get_clipboard()->to_clipboard(file.string,
00303 strlen(file.string),
00304 SECONDARY_SELECTION);
00305 return 0;
00306 }
00307
00308
00309
00310
00311 void MWindow::crop_video()
00312 {
00313
00314
00315 if(edl->session->crop_x1 > edl->session->crop_x2)
00316 {
00317 edl->session->crop_x1 ^= edl->session->crop_x2;
00318 edl->session->crop_x2 ^= edl->session->crop_x1;
00319 edl->session->crop_x1 ^= edl->session->crop_x2;
00320 }
00321 if(edl->session->crop_y1 > edl->session->crop_y2)
00322 {
00323 edl->session->crop_y1 ^= edl->session->crop_y2;
00324 edl->session->crop_y2 ^= edl->session->crop_y1;
00325 edl->session->crop_y1 ^= edl->session->crop_y2;
00326 }
00327
00328 float old_projector_x = (float)edl->session->output_w / 2;
00329 float old_projector_y = (float)edl->session->output_h / 2;
00330 float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
00331 float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
00332 float projector_offset_x = -(new_projector_x - old_projector_x);
00333 float projector_offset_y = -(new_projector_y - old_projector_y);
00334
00335 edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
00336
00337 edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
00338 edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
00339 edl->session->crop_x1 = 0;
00340 edl->session->crop_y1 = 0;
00341 edl->session->crop_x2 = edl->session->output_w;
00342 edl->session->crop_y2 = edl->session->output_h;
00343
00344
00345 if(defaults->get("AUTOASPECT", 0))
00346 {
00347 create_aspect_ratio(edl->session->aspect_w,
00348 edl->session->aspect_h,
00349 edl->session->output_w,
00350 edl->session->output_h);
00351 }
00352
00353 undo->update_undo(_("crop"), LOAD_ALL);
00354
00355 restart_brender();
00356 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00357 CHANGE_ALL,
00358 edl,
00359 1);
00360 save_backup();
00361 }
00362
00363 void MWindow::cut()
00364 {
00365
00366 double start = edl->local_session->get_selectionstart();
00367 double end = edl->local_session->get_selectionend();
00368
00369 copy(start, end);
00370 edl->clear(start,
00371 end,
00372 edl->session->labels_follow_edits,
00373 edl->session->plugins_follow_edits);
00374
00375
00376 edl->optimize();
00377 save_backup();
00378 undo->update_undo(_("cut"), LOAD_EDITS | LOAD_TIMEBAR);
00379
00380 restart_brender();
00381 update_plugin_guis();
00382 gui->update(1, 2, 1, 1, 1, 1, 0);
00383 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00384 CHANGE_EDL,
00385 edl,
00386 1);
00387 }
00388
00389 int MWindow::cut_automation()
00390 {
00391
00392 copy_automation();
00393
00394 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
00395 edl->local_session->get_selectionend());
00396 save_backup();
00397 undo->update_undo(_("cut keyframes"), LOAD_AUTOMATION);
00398
00399
00400 restart_brender();
00401 update_plugin_guis();
00402 gui->canvas->draw_overlays();
00403 gui->canvas->flash();
00404 sync_parameters(CHANGE_PARAMS);
00405 gui->patchbay->update();
00406 cwindow->update(1, 0, 0);
00407 return 0;
00408 }
00409
00410 int MWindow::cut_default_keyframe()
00411 {
00412
00413 copy_default_keyframe();
00414 edl->tracks->clear_default_keyframe();
00415 undo->update_undo(_("cut default keyframe"), LOAD_AUTOMATION);
00416
00417 restart_brender();
00418 gui->canvas->draw_overlays();
00419 gui->canvas->flash();
00420 sync_parameters(CHANGE_PARAMS);
00421 gui->patchbay->update();
00422 cwindow->update(1, 0, 0);
00423 save_backup();
00424
00425
00426 return 0;
00427 }
00428
00429 void MWindow::delete_inpoint()
00430 {
00431 edl->local_session->unset_inpoint();
00432 save_backup();
00433 }
00434
00435 void MWindow::delete_outpoint()
00436 {
00437 edl->local_session->unset_outpoint();
00438 save_backup();
00439 }
00440
00441 void MWindow::delete_track()
00442 {
00443 if (edl->tracks->last)
00444 delete_track(edl->tracks->last);
00445 }
00446
00447 void MWindow::delete_tracks()
00448 {
00449 edl->tracks->delete_tracks();
00450 undo->update_undo(_("delete tracks"), LOAD_ALL);
00451 save_backup();
00452
00453 restart_brender();
00454 update_plugin_states();
00455 gui->update(1, 1, 1, 0, 1, 0, 0);
00456 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00457 CHANGE_EDL,
00458 edl,
00459 1);
00460 }
00461
00462 void MWindow::delete_track(Track *track)
00463 {
00464 edl->tracks->delete_track(track);
00465 undo->update_undo(_("delete track"), LOAD_ALL);
00466
00467 restart_brender();
00468 update_plugin_states();
00469 gui->update(1, 1, 1, 0, 1, 0, 0);
00470 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00471 CHANGE_EDL,
00472 edl,
00473 1);
00474 save_backup();
00475 }
00476
00477 void MWindow::detach_transition(Transition *transition)
00478 {
00479 hide_plugin(transition, 1);
00480 int is_video = (transition->edit->track->data_type == TRACK_VIDEO);
00481 transition->edit->detach_transition();
00482 save_backup();
00483 undo->update_undo(_("detach transition"), LOAD_ALL);
00484
00485 if(is_video) restart_brender();
00486 gui->update(0,
00487 1,
00488 0,
00489 0,
00490 0,
00491 0,
00492 0);
00493 sync_parameters(CHANGE_EDL);
00494 }
00495
00496
00497
00498
00499
00500
00501 void MWindow::insert(double position,
00502 FileXML *file,
00503 int edit_labels,
00504 int edit_plugins,
00505 EDL *parent_edl)
00506 {
00507
00508
00509
00510 EDL edl(parent_edl);
00511 ArrayList<EDL*> new_edls;
00512 uint32_t load_flags = LOAD_ALL;
00513 SET_TRACE
00514
00515 new_edls.append(&edl);
00516 edl.create_objects();
00517 SET_TRACE
00518
00519
00520
00521 if(parent_edl) load_flags &= ~LOAD_SESSION;
00522 if(!edl.session->autos_follow_edits) load_flags &= ~LOAD_AUTOMATION;
00523 if(!edl.session->labels_follow_edits) load_flags &= ~LOAD_TIMEBAR;
00524 SET_TRACE
00525 edl.load_xml(plugindb, file, load_flags);
00526
00527 SET_TRACE
00528
00529
00530
00531
00532 paste_edls(&new_edls,
00533 LOAD_PASTE,
00534 0,
00535 position,
00536 edit_labels,
00537 edit_plugins);
00538
00539
00540
00541
00542 new_edls.remove_all();
00543
00544 }
00545
00546 void MWindow::insert_effects_canvas(double start,
00547 double length)
00548 {
00549 Track *dest_track = session->track_highlighted;
00550 if(!dest_track) return;
00551
00552
00553 for(int i = 0; i < session->drag_pluginservers->total; i++)
00554 {
00555 PluginServer *plugin = session->drag_pluginservers->values[i];
00556
00557 insert_effect(plugin->title,
00558 0,
00559 dest_track,
00560 i == 0 ? session->pluginset_highlighted : 0,
00561 start,
00562 length,
00563 PLUGIN_STANDALONE);
00564 }
00565
00566 save_backup();
00567 undo->update_undo(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
00568 restart_brender();
00569 sync_parameters(CHANGE_EDL);
00570
00571 }
00572
00573 void MWindow::insert_effects_cwindow(Track *dest_track)
00574 {
00575 if(!dest_track) return;
00576
00577
00578 double start = 0;
00579 double length = dest_track->get_length();
00580
00581 if(edl->local_session->get_selectionend() >
00582 edl->local_session->get_selectionstart())
00583 {
00584 start = edl->local_session->get_selectionstart();
00585 length = edl->local_session->get_selectionend() -
00586 edl->local_session->get_selectionstart();
00587 }
00588
00589 for(int i = 0; i < session->drag_pluginservers->total; i++)
00590 {
00591 PluginServer *plugin = session->drag_pluginservers->values[i];
00592
00593
00594 insert_effect(plugin->title,
00595 0,
00596 dest_track,
00597 0,
00598 start,
00599 length,
00600 PLUGIN_STANDALONE);
00601 }
00602
00603 save_backup();
00604 undo->update_undo(_("insert effect"), LOAD_EDITS | LOAD_PATCHES);
00605 restart_brender();
00606 sync_parameters(CHANGE_EDL);
00607 gui->update(1,
00608 1,
00609 0,
00610 0,
00611 1,
00612 0,
00613 0);
00614 }
00615
00616
00617
00618 void MWindow::insert_effect(char *title,
00619 SharedLocation *shared_location,
00620 Track *track,
00621 PluginSet *plugin_set,
00622 double start,
00623 double length,
00624 int plugin_type)
00625 {
00626 KeyFrame *default_keyframe = 0;
00627 PluginServer *server = 0;
00628
00629
00630
00631
00632
00633
00634
00635 if(plugin_type == PLUGIN_STANDALONE)
00636 {
00637 default_keyframe = new KeyFrame;
00638 server = new PluginServer(*scan_plugindb(title, track->data_type));
00639
00640 server->open_plugin(0, preferences, edl, 0, -1);
00641 server->save_data(default_keyframe);
00642 }
00643
00644
00645
00646
00647 track->insert_effect(title,
00648 shared_location,
00649 default_keyframe,
00650 plugin_set,
00651 start,
00652 length,
00653 plugin_type);
00654
00655 track->optimize();
00656
00657
00658 if(plugin_type == PLUGIN_STANDALONE)
00659 {
00660 server->close_plugin();
00661 delete server;
00662 delete default_keyframe;
00663 }
00664 }
00665
00666 int MWindow::modify_edithandles()
00667 {
00668
00669
00670
00671
00672
00673 edl->modify_edithandles(session->drag_start,
00674 session->drag_position,
00675 session->drag_handle,
00676 edl->session->edit_handle_mode[session->drag_button],
00677 edl->session->labels_follow_edits,
00678 edl->session->plugins_follow_edits);
00679
00680 finish_modify_handles();
00681
00682
00683
00684 return 0;
00685 }
00686
00687 int MWindow::modify_pluginhandles()
00688 {
00689
00690 edl->modify_pluginhandles(session->drag_start,
00691 session->drag_position,
00692 session->drag_handle,
00693 edl->session->edit_handle_mode[session->drag_button],
00694 edl->session->labels_follow_edits,
00695 session->trim_edits);
00696
00697 finish_modify_handles();
00698
00699 return 0;
00700 }
00701
00702
00703
00704 void MWindow::finish_modify_handles()
00705 {
00706 int edit_mode = edl->session->edit_handle_mode[session->drag_button];
00707
00708 if((session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) ||
00709 (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT))
00710 {
00711 edl->local_session->set_selectionstart(session->drag_position);
00712 edl->local_session->set_selectionend(session->drag_position);
00713 }
00714 else
00715 if(edit_mode != MOVE_NO_EDITS)
00716 {
00717 edl->local_session->set_selectionstart(session->drag_start);
00718 edl->local_session->set_selectionend(session->drag_start);
00719 }
00720
00721 if(edl->local_session->get_selectionstart(1) < 0)
00722 {
00723 edl->local_session->set_selectionstart(0);
00724 edl->local_session->set_selectionend(0);
00725 }
00726
00727 save_backup();
00728 undo->update_undo(_("drag handle"), LOAD_EDITS | LOAD_TIMEBAR);
00729 restart_brender();
00730 sync_parameters(CHANGE_EDL);
00731 update_plugin_guis();
00732 gui->update(1, 2, 1, 1, 1, 1, 0);
00733 cwindow->update(1, 0, 0, 0, 1);
00734 }
00735
00736 void MWindow::match_output_size(Track *track)
00737 {
00738 track->track_w = edl->session->output_w;
00739 track->track_h = edl->session->output_h;
00740 save_backup();
00741 undo->update_undo(_("match output size"), LOAD_ALL);
00742
00743 restart_brender();
00744 sync_parameters(CHANGE_EDL);
00745 }
00746
00747
00748 void MWindow::move_edits(ArrayList<Edit*> *edits,
00749 Track *track,
00750 double position,
00751 int behaviour)
00752 {
00753
00754 edl->tracks->move_edits(edits,
00755 track,
00756 position,
00757 edl->session->labels_follow_edits,
00758 edl->session->plugins_follow_edits,
00759 behaviour);
00760
00761 save_backup();
00762 undo->update_undo(_("move edit"), LOAD_ALL);
00763
00764 restart_brender();
00765 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00766 CHANGE_EDL,
00767 edl,
00768 1);
00769
00770 update_plugin_guis();
00771 gui->update(1,
00772 1,
00773 1,
00774 0,
00775 0,
00776 0,
00777 0);
00778 }
00779
00780 void MWindow::move_effect(Plugin *plugin,
00781 PluginSet *dest_plugin_set,
00782 Track *dest_track,
00783 int64_t dest_position)
00784 {
00785
00786 edl->tracks->move_effect(plugin,
00787 dest_plugin_set,
00788 dest_track,
00789 dest_position);
00790
00791 save_backup();
00792 undo->update_undo(_("move effect"), LOAD_ALL);
00793
00794 restart_brender();
00795 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00796 CHANGE_EDL,
00797 edl,
00798 1);
00799
00800 update_plugin_guis();
00801 gui->update(1,
00802 1,
00803 0,
00804 0,
00805 0,
00806 0,
00807 0);
00808 }
00809
00810 void MWindow::move_plugins_up(PluginSet *plugin_set)
00811 {
00812
00813 plugin_set->track->move_plugins_up(plugin_set);
00814
00815 save_backup();
00816 undo->update_undo(_("move effect up"), LOAD_ALL);
00817 restart_brender();
00818 gui->update(1,
00819 1,
00820 0,
00821 0,
00822 0,
00823 0,
00824 0);
00825 sync_parameters(CHANGE_EDL);
00826 }
00827
00828 void MWindow::move_plugins_down(PluginSet *plugin_set)
00829 {
00830
00831 plugin_set->track->move_plugins_down(plugin_set);
00832
00833 save_backup();
00834 undo->update_undo(_("move effect down"), LOAD_ALL);
00835 restart_brender();
00836 gui->update(1,
00837 1,
00838 0,
00839 0,
00840 0,
00841 0,
00842 0);
00843 sync_parameters(CHANGE_EDL);
00844 }
00845
00846 void MWindow::move_track_down(Track *track)
00847 {
00848 edl->tracks->move_track_down(track);
00849 save_backup();
00850 undo->update_undo(_("move track down"), LOAD_ALL);
00851
00852 restart_brender();
00853 gui->update(1, 1, 0, 0, 1, 0, 0);
00854 sync_parameters(CHANGE_EDL);
00855 save_backup();
00856 }
00857
00858 void MWindow::move_tracks_down()
00859 {
00860 edl->tracks->move_tracks_down();
00861 save_backup();
00862 undo->update_undo(_("move tracks down"), LOAD_ALL);
00863
00864 restart_brender();
00865 gui->update(1, 1, 0, 0, 1, 0, 0);
00866 sync_parameters(CHANGE_EDL);
00867 save_backup();
00868 }
00869
00870 void MWindow::move_track_up(Track *track)
00871 {
00872 edl->tracks->move_track_up(track);
00873 save_backup();
00874 undo->update_undo(_("move track up"), LOAD_ALL);
00875 restart_brender();
00876 gui->update(1, 1, 0, 0, 1, 0, 0);
00877 sync_parameters(CHANGE_EDL);
00878 save_backup();
00879 }
00880
00881 void MWindow::move_tracks_up()
00882 {
00883 edl->tracks->move_tracks_up();
00884 save_backup();
00885 undo->update_undo(_("move tracks up"), LOAD_ALL);
00886 restart_brender();
00887 gui->update(1, 1, 0, 0, 1, 0, 0);
00888 sync_parameters(CHANGE_EDL);
00889 }
00890
00891
00892 void MWindow::mute_selection()
00893 {
00894 double start = edl->local_session->get_selectionstart();
00895 double end = edl->local_session->get_selectionend();
00896 if(start != end)
00897 {
00898 edl->clear(start,
00899 end,
00900 0,
00901 edl->session->plugins_follow_edits);
00902 edl->local_session->set_selectionend(end);
00903 edl->local_session->set_selectionstart(start);
00904 edl->paste_silence(start, end, 0, edl->session->plugins_follow_edits);
00905 save_backup();
00906 undo->update_undo(_("mute"), LOAD_EDITS);
00907
00908 restart_brender();
00909 update_plugin_guis();
00910 gui->update(1, 2, 1, 1, 1, 1, 0);
00911 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
00912 CHANGE_EDL,
00913 edl,
00914 1);
00915 }
00916 }
00917
00918
00919
00920 void MWindow::overwrite(EDL *source)
00921 {
00922 FileXML file;
00923
00924 double src_start = source->local_session->get_selectionstart();
00925 double overwrite_len = source->local_session->get_selectionend() - src_start;
00926 double dst_start = edl->local_session->get_selectionstart();
00927 double dst_len = edl->local_session->get_selectionend() - dst_start;
00928
00929 if (!EQUIV(dst_len, 0) && (dst_len < overwrite_len))
00930 {
00931
00932
00933 overwrite_len = dst_len;
00934 }
00935
00936 source->copy(src_start,
00937 src_start + overwrite_len,
00938 1,
00939 0,
00940 0,
00941 &file,
00942 plugindb,
00943 "",
00944 1);
00945
00946
00947
00948
00949 if (edl->local_session->get_inpoint() < 0 ||
00950 edl->local_session->get_outpoint() < 0)
00951 edl->clear(dst_start,
00952 dst_start + overwrite_len,
00953 0,
00954 0);
00955
00956 paste(dst_start,
00957 dst_start + overwrite_len,
00958 &file,
00959 0,
00960 0);
00961
00962 edl->local_session->set_selectionstart(dst_start + overwrite_len);
00963 edl->local_session->set_selectionend(dst_start + overwrite_len);
00964
00965 save_backup();
00966 undo->update_undo(_("overwrite"), LOAD_EDITS);
00967
00968 restart_brender();
00969 update_plugin_guis();
00970 gui->update(1, 1, 1, 1, 0, 1, 0);
00971 sync_parameters(CHANGE_EDL);
00972 }
00973
00974
00975 int MWindow::paste(double start,
00976 double end,
00977 FileXML *file,
00978 int edit_labels,
00979 int edit_plugins)
00980 {
00981 clear(0);
00982
00983
00984 insert(start,
00985 file,
00986 edit_labels,
00987 edit_plugins,
00988 edl);
00989
00990 return 0;
00991 }
00992
00993
00994 void MWindow::paste()
00995 {
00996 SET_TRACE
00997 double start = edl->local_session->get_selectionstart();
00998 double end = edl->local_session->get_selectionend();
00999 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
01000
01001 if(len)
01002 {
01003 char *string = new char[len + 1];
01004
01005 SET_TRACE
01006
01007 gui->get_clipboard()->from_clipboard(string,
01008 len,
01009 SECONDARY_SELECTION);
01010 FileXML file;
01011 file.read_from_string(string);
01012
01013 SET_TRACE
01014
01015
01016 clear(0);
01017 SET_TRACE
01018 insert(start,
01019 &file,
01020 edl->session->labels_follow_edits,
01021 edl->session->plugins_follow_edits);
01022 SET_TRACE
01023 edl->optimize();
01024 SET_TRACE
01025
01026 delete [] string;
01027
01028 SET_TRACE
01029
01030 save_backup();
01031
01032
01033 undo->update_undo(_("paste"), LOAD_EDITS | LOAD_TIMEBAR);
01034 restart_brender();
01035 update_plugin_guis();
01036 gui->update(1, 2, 1, 1, 0, 1, 0);
01037 awindow->gui->update_assets();
01038 sync_parameters(CHANGE_EDL);
01039 }
01040 SET_TRACE
01041 }
01042
01043 int MWindow::paste_assets(double position, Track *dest_track)
01044 {
01045 int result = 0;
01046
01047
01048
01049
01050 if(session->drag_assets->total)
01051 {
01052 load_assets(session->drag_assets,
01053 position,
01054 LOAD_PASTE,
01055 dest_track,
01056 0,
01057 edl->session->labels_follow_edits,
01058 edl->session->plugins_follow_edits);
01059 result = 1;
01060 }
01061
01062
01063 if(session->drag_clips->total)
01064 {
01065 paste_edls(session->drag_clips,
01066 LOAD_PASTE,
01067 dest_track,
01068 position,
01069 edl->session->labels_follow_edits,
01070 edl->session->plugins_follow_edits);
01071 result = 1;
01072 }
01073
01074
01075 save_backup();
01076
01077 undo->update_undo(_("paste assets"), LOAD_EDITS);
01078 restart_brender();
01079 gui->update(1,
01080 2,
01081 1,
01082 0,
01083 0,
01084 1,
01085 0);
01086 sync_parameters(CHANGE_EDL);
01087 return result;
01088 }
01089
01090 void MWindow::load_assets(ArrayList<Asset*> *new_assets,
01091 double position,
01092 int load_mode,
01093 Track *first_track,
01094 RecordLabels *labels,
01095 int edit_labels,
01096 int edit_plugins)
01097 {
01098
01099 if(position < 0) position = edl->local_session->get_selectionstart();
01100
01101 ArrayList<EDL*> new_edls;
01102 for(int i = 0; i < new_assets->total; i++)
01103 {
01104 EDL *new_edl = new EDL;
01105 new_edl->create_objects();
01106 new_edl->copy_session(edl);
01107 new_edls.append(new_edl);
01108
01109
01110
01111 asset_to_edl(new_edl, new_assets->values[i]);
01112
01113
01114 if(labels)
01115 for(RecordLabel *label = labels->first; label; label = label->next)
01116 {
01117 new_edl->labels->toggle_label(label->position, label->position);
01118 }
01119 }
01120
01121
01122 paste_edls(&new_edls,
01123 load_mode,
01124 first_track,
01125 position,
01126 edit_labels,
01127 edit_plugins);
01128
01129
01130
01131 save_backup();
01132 new_edls.remove_all_objects();
01133
01134 }
01135
01136 int MWindow::paste_automation()
01137 {
01138 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
01139
01140 if(len)
01141 {
01142 char *string = new char[len + 1];
01143 gui->get_clipboard()->from_clipboard(string,
01144 len,
01145 SECONDARY_SELECTION);
01146 FileXML file;
01147 file.read_from_string(string);
01148
01149 edl->tracks->clear_automation(edl->local_session->get_selectionstart(),
01150 edl->local_session->get_selectionend());
01151 edl->tracks->paste_automation(edl->local_session->get_selectionstart(),
01152 &file,
01153 0);
01154 save_backup();
01155 undo->update_undo(_("paste keyframes"), LOAD_AUTOMATION);
01156 delete [] string;
01157
01158
01159 restart_brender();
01160 update_plugin_guis();
01161 gui->canvas->draw_overlays();
01162 gui->canvas->flash();
01163 sync_parameters(CHANGE_PARAMS);
01164 gui->patchbay->update();
01165 cwindow->update(1, 0, 0);
01166 }
01167
01168 return 0;
01169 }
01170
01171 int MWindow::paste_default_keyframe()
01172 {
01173 int64_t len = gui->get_clipboard()->clipboard_len(SECONDARY_SELECTION);
01174
01175 if(len)
01176 {
01177 char *string = new char[len + 1];
01178 gui->get_clipboard()->from_clipboard(string,
01179 len,
01180 SECONDARY_SELECTION);
01181 FileXML file;
01182 file.read_from_string(string);
01183 edl->tracks->paste_default_keyframe(&file);
01184 undo->update_undo(_("paste default keyframe"), LOAD_AUTOMATION);
01185
01186
01187 restart_brender();
01188 update_plugin_guis();
01189 gui->canvas->draw_overlays();
01190 gui->canvas->flash();
01191 sync_parameters(CHANGE_PARAMS);
01192 gui->patchbay->update();
01193 cwindow->update(1, 0, 0);
01194 delete [] string;
01195 save_backup();
01196 }
01197
01198 return 0;
01199 }
01200
01201
01202
01203 int MWindow::paste_edls(ArrayList<EDL*> *new_edls,
01204 int load_mode,
01205 Track *first_track,
01206 double current_position,
01207 int edit_labels,
01208 int edit_plugins)
01209 {
01210 SET_TRACE
01211 ArrayList<Track*> destination_tracks;
01212 int need_new_tracks = 0;
01213
01214 if(!new_edls->total) return 0;
01215 SET_TRACE
01216
01217
01218
01219 if(load_mode == LOAD_REPLACE ||
01220 load_mode == LOAD_REPLACE_CONCATENATE)
01221 {
01222 SET_TRACE
01223 edl->save_defaults(defaults);
01224 SET_TRACE
01225 hide_plugins();
01226 SET_TRACE
01227 delete edl;
01228 SET_TRACE
01229 edl = new EDL;
01230 SET_TRACE
01231 edl->create_objects();
01232 SET_TRACE
01233 edl->copy_session(new_edls->values[0]);
01234 SET_TRACE
01235 gui->mainmenu->update_toggles(0);
01236 SET_TRACE
01237
01238 gui->unlock_window();
01239 SET_TRACE
01240 gwindow->gui->update_toggles(1);
01241 SET_TRACE
01242 gui->lock_window("MWindow::paste_edls");
01243 SET_TRACE
01244
01245
01246 edit_labels = 1;
01247 edit_plugins = 1;
01248 }
01249 SET_TRACE
01250
01251
01252
01253 for(int i = 0; i < new_edls->total; i++)
01254 {
01255 EDL *new_edl = new_edls->values[i];
01256
01257 for(int j = 0; j < new_edl->clips.total; j++)
01258 {
01259 edl->add_clip(new_edl->clips.values[j]);
01260 }
01261
01262 if(new_edl->vwindow_edl)
01263 {
01264 if(edl->vwindow_edl) delete edl->vwindow_edl;
01265 edl->vwindow_edl = new EDL(edl);
01266 edl->vwindow_edl->create_objects();
01267 edl->vwindow_edl->copy_all(new_edl->vwindow_edl);
01268 }
01269 }
01270 SET_TRACE
01271
01272
01273 if(load_mode == LOAD_REPLACE ||
01274 load_mode == LOAD_REPLACE_CONCATENATE ||
01275 load_mode == LOAD_NEW_TRACKS)
01276 {
01277 SET_TRACE
01278 need_new_tracks = 1;
01279 for(int i = 0; i < new_edls->total; i++)
01280 {
01281 EDL *new_edl = new_edls->values[i];
01282 for(Track *current = new_edl->tracks->first;
01283 current;
01284 current = NEXT)
01285 {
01286 if(current->data_type == TRACK_VIDEO)
01287 {
01288 edl->tracks->add_video_track(0, 0);
01289 if(current->draw) edl->tracks->last->draw = 1;
01290 destination_tracks.append(edl->tracks->last);
01291 }
01292 else
01293 if(current->data_type == TRACK_AUDIO)
01294 {
01295 edl->tracks->add_audio_track(0, 0);
01296 destination_tracks.append(edl->tracks->last);
01297 }
01298 edl->session->highlighted_track = edl->tracks->total() - 1;
01299 }
01300
01301
01302 if(load_mode == LOAD_REPLACE_CONCATENATE) break;
01303 }
01304 SET_TRACE
01305 }
01306 else
01307
01308 if(load_mode == LOAD_CONCATENATE || load_mode == LOAD_PASTE)
01309 {
01310 SET_TRACE
01311
01312
01313
01314 if(load_mode == LOAD_PASTE && edl->session->labels_follow_edits)
01315 edl->labels->clear(edl->local_session->get_selectionstart(),
01316 edl->local_session->get_selectionend(),
01317 1);
01318
01319 Track *current = first_track ? first_track : edl->tracks->first;
01320 for( ; current; current = NEXT)
01321 {
01322 if(current->record)
01323 {
01324 destination_tracks.append(current);
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334 }
01335 }
01336 SET_TRACE
01337 }
01338
01339
01340 SET_TRACE
01341
01342 int destination_track = 0;
01343 double *paste_position = new double[destination_tracks.total];
01344
01345 SET_TRACE
01346
01347
01348
01349
01350 for(int i = 0; i < new_edls->total; i++)
01351 {
01352 SET_TRACE
01353 EDL *new_edl = new_edls->values[i];
01354 double edl_length = new_edl->local_session->clipboard_length ?
01355 new_edl->local_session->clipboard_length :
01356 new_edl->tracks->total_length();
01357
01358
01359
01360
01361 SET_TRACE
01362
01363
01364 new_edl->resample(new_edl->session->sample_rate,
01365 edl->session->sample_rate,
01366 TRACK_AUDIO);
01367 new_edl->resample(new_edl->session->frame_rate,
01368 edl->session->frame_rate,
01369 TRACK_VIDEO);
01370
01371 SET_TRACE
01372
01373
01374
01375 for(Asset *new_asset = new_edl->assets->first;
01376 new_asset;
01377 new_asset = new_asset->next)
01378 {
01379 mainindexes->add_next_asset(0, new_asset);
01380 }
01381
01382 edl->update_assets(new_edl);
01383
01384 SET_TRACE
01385
01386
01387 switch(load_mode)
01388 {
01389 case LOAD_REPLACE:
01390 case LOAD_NEW_TRACKS:
01391 current_position = 0;
01392 break;
01393
01394 case LOAD_CONCATENATE:
01395 case LOAD_REPLACE_CONCATENATE:
01396 destination_track = 0;
01397 if(destination_tracks.total)
01398 current_position = destination_tracks.values[0]->get_length();
01399 else
01400 current_position = 0;
01401 break;
01402
01403 case LOAD_PASTE:
01404 destination_track = 0;
01405 if(i == 0)
01406 {
01407 for(int j = 0; j < destination_tracks.total; j++)
01408 {
01409 paste_position[j] = (current_position >= 0) ?
01410 current_position :
01411 edl->local_session->get_selectionstart();
01412 }
01413 }
01414 break;
01415
01416 case LOAD_RESOURCESONLY:
01417 edl->add_clip(new_edl);
01418 break;
01419 }
01420
01421
01422 SET_TRACE
01423
01424
01425
01426 if(load_mode != LOAD_RESOURCESONLY)
01427 {
01428
01429
01430 if(load_mode == LOAD_PASTE)
01431 edl->labels->insert_labels(new_edl->labels,
01432 destination_tracks.total ? paste_position[0] : 0.0,
01433 edl_length,
01434 edit_labels);
01435 else
01436 edl->labels->insert_labels(new_edl->labels,
01437 current_position,
01438 edl_length,
01439 edit_labels);
01440
01441 for(Track *new_track = new_edl->tracks->first;
01442 new_track;
01443 new_track = new_track->next)
01444 {
01445
01446 for(int k = 0;
01447 k < destination_tracks.total &&
01448 destination_tracks.values[destination_track]->data_type != new_track->data_type;
01449 k++, destination_track++)
01450 {
01451 if(destination_track >= destination_tracks.total - 1)
01452 destination_track = 0;
01453 }
01454
01455
01456 if(destination_track < destination_tracks.total &&
01457 destination_tracks.values[destination_track]->data_type == new_track->data_type)
01458 {
01459 Track *track = destination_tracks.values[destination_track];
01460
01461
01462
01463
01464
01465
01466 int replace_default = (i == 0) && need_new_tracks;
01467
01468
01469
01470 switch(load_mode)
01471 {
01472 case LOAD_REPLACE_CONCATENATE:
01473 case LOAD_CONCATENATE:
01474 current_position = track->get_length();
01475 break;
01476
01477 case LOAD_PASTE:
01478 current_position = paste_position[destination_track];
01479 paste_position[destination_track] += new_track->get_length();
01480 break;
01481 }
01482
01483 track->insert_track(new_track,
01484 current_position,
01485 replace_default,
01486 edit_plugins);
01487 }
01488
01489
01490 destination_track++;
01491 if(destination_track >= destination_tracks.total)
01492 destination_track = 0;
01493 }
01494 }
01495
01496 if(load_mode == LOAD_PASTE)
01497 current_position += edl_length;
01498 }
01499
01500
01501
01502 SET_TRACE
01503 if(paste_position) delete [] paste_position;
01504
01505 SET_TRACE
01506
01507
01508
01509 SET_TRACE
01510
01511
01512 mainindexes->start_build();
01513 SET_TRACE
01514
01515
01516
01517 SET_TRACE
01518 return 0;
01519 }
01520
01521 void MWindow::paste_silence()
01522 {
01523 double start = edl->local_session->get_selectionstart();
01524 double end = edl->local_session->get_selectionend();
01525 edl->paste_silence(start,
01526 end,
01527 edl->session->labels_follow_edits,
01528 edl->session->plugins_follow_edits);
01529 edl->optimize();
01530 save_backup();
01531 undo->update_undo(_("silence"), LOAD_EDITS | LOAD_TIMEBAR);
01532
01533 update_plugin_guis();
01534 restart_brender();
01535 gui->update(1, 2, 1, 1, 1, 1, 0);
01536 cwindow->update(1, 0, 0, 0, 1);
01537 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01538 CHANGE_EDL,
01539 edl,
01540 1);
01541 }
01542
01543 void MWindow::paste_transition()
01544 {
01545
01546 PluginServer *server = session->drag_pluginservers->values[0];
01547 if(server->audio)
01548 strcpy(edl->session->default_atransition, server->title);
01549 else
01550 strcpy(edl->session->default_vtransition, server->title);
01551
01552 edl->tracks->paste_transition(server, session->edit_highlighted);
01553 save_backup();
01554 undo->update_undo(_("transition"), LOAD_EDITS);
01555
01556 if(server->video) restart_brender();
01557 sync_parameters(CHANGE_ALL);
01558 }
01559
01560 void MWindow::paste_transition_cwindow(Track *dest_track)
01561 {
01562 PluginServer *server = session->drag_pluginservers->values[0];
01563 edl->tracks->paste_video_transition(server, 1);
01564 save_backup();
01565 undo->update_undo(_("transition"), LOAD_EDITS);
01566 restart_brender();
01567 gui->update(0, 1, 0, 0, 0, 0, 0);
01568 sync_parameters(CHANGE_ALL);
01569 }
01570
01571 void MWindow::paste_audio_transition()
01572 {
01573 PluginServer *server = scan_plugindb(edl->session->default_atransition,
01574 TRACK_AUDIO);
01575 if(!server)
01576 {
01577 char string[BCTEXTLEN];
01578 sprintf(string, _("No default transition %s found."), edl->session->default_atransition);
01579 gui->show_message(string);
01580 return;
01581 }
01582
01583 edl->tracks->paste_audio_transition(server);
01584 save_backup();
01585 undo->update_undo(_("transition"), LOAD_EDITS);
01586
01587 sync_parameters(CHANGE_ALL);
01588 gui->update(0, 1, 0, 0, 0, 0, 0);
01589 }
01590
01591 void MWindow::paste_video_transition()
01592 {
01593 PluginServer *server = scan_plugindb(edl->session->default_vtransition,
01594 TRACK_VIDEO);
01595 if(!server)
01596 {
01597 char string[BCTEXTLEN];
01598 sprintf(string, _("No default transition %s found."), edl->session->default_vtransition);
01599 gui->show_message(string);
01600 return;
01601 }
01602
01603
01604 edl->tracks->paste_video_transition(server);
01605 save_backup();
01606 undo->update_undo(_("transition"), LOAD_EDITS);
01607
01608 sync_parameters(CHANGE_ALL);
01609 restart_brender();
01610 gui->update(0, 1, 0, 0, 0, 0, 0);
01611 }
01612
01613
01614 void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
01615 {
01616
01617 calling_window_gui->unlock_window();
01618
01619 cwindow->playback_engine->que->send_command(STOP,
01620 CHANGE_NONE,
01621 0,
01622 0);
01623 vwindow->playback_engine->que->send_command(STOP,
01624 CHANGE_NONE,
01625 0,
01626 0);
01627 cwindow->playback_engine->interrupt_playback(0);
01628 vwindow->playback_engine->interrupt_playback(0);
01629
01630
01631 cwindow->gui->lock_window("MWindow::redo_entry");
01632 vwindow->gui->lock_window("MWindow::undo_entry 2");
01633 gui->lock_window();
01634
01635 undo->redo();
01636
01637 save_backup();
01638 update_plugin_states();
01639 update_plugin_guis();
01640 restart_brender();
01641 gui->update(1, 2, 1, 1, 1, 1, 1);
01642 cwindow->update(1, 1, 1, 1, 1);
01643
01644 if (calling_window_gui != cwindow->gui)
01645 cwindow->gui->unlock_window();
01646 if (calling_window_gui != gui)
01647 gui->unlock_window();
01648 if (calling_window_gui != vwindow->gui)
01649 vwindow->gui->unlock_window();
01650
01651 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01652 CHANGE_ALL,
01653 edl,
01654 1);
01655
01656 }
01657
01658
01659 void MWindow::resize_track(Track *track, int w, int h)
01660 {
01661
01662 ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->translate_masks(
01663 (w - track->track_w) / 2,
01664 (h - track->track_h) / 2);
01665 track->track_w = w;
01666 track->track_h = h;
01667 undo->update_undo(_("resize track"), LOAD_ALL);
01668 save_backup();
01669
01670 restart_brender();
01671 sync_parameters(CHANGE_EDL);
01672 }
01673
01674
01675 class InPointUndoItem : public UndoStackItem
01676 {
01677 public:
01678 InPointUndoItem(double old_position, double new_position, EDL *edl);
01679 void undo();
01680 int get_size();
01681 private:
01682 double old_position;
01683 double new_position;
01684 EDL *edl;
01685 };
01686
01687 InPointUndoItem::InPointUndoItem(
01688 double old_position, double new_position, EDL *edl)
01689 {
01690 set_description(_("in point"));
01691 this->old_position = old_position;
01692 this->new_position = new_position;
01693 this->edl = edl;
01694 }
01695
01696 void InPointUndoItem::undo()
01697 {
01698 edl->set_inpoint(old_position);
01699
01700 double tmp = new_position;
01701 new_position = old_position;
01702 old_position = tmp;
01703 }
01704
01705 int InPointUndoItem::get_size()
01706 {
01707 return 20;
01708 }
01709
01710 void MWindow::set_inpoint(int is_mwindow)
01711 {
01712 InPointUndoItem *undo_item;
01713
01714 undo_item = new InPointUndoItem(edl->local_session->get_inpoint(),
01715 edl->local_session->get_selectionstart(1), edl);
01716 undo->push_undo_item(undo_item);
01717
01718 edl->set_inpoint(edl->local_session->get_selectionstart(1));
01719 save_backup();
01720
01721 if(!is_mwindow)
01722 {
01723 gui->lock_window("MWindow::set_inpoint 1");
01724 }
01725 gui->timebar->update();
01726 gui->flush();
01727 if(!is_mwindow)
01728 {
01729 gui->unlock_window();
01730 }
01731
01732 if(is_mwindow)
01733 {
01734 cwindow->gui->lock_window("MWindow::set_inpoint 2");
01735 }
01736 cwindow->gui->timebar->update();
01737 cwindow->gui->flush();
01738 if(is_mwindow)
01739 {
01740 cwindow->gui->unlock_window();
01741 }
01742 }
01743
01744 class OutPointUndoItem : public UndoStackItem
01745 {
01746 public:
01747 OutPointUndoItem(double old_position, double new_position, EDL *edl);
01748 void undo();
01749 int get_size();
01750 private:
01751 double old_position;
01752 double new_position;
01753 EDL *edl;
01754 };
01755
01756 OutPointUndoItem::OutPointUndoItem(
01757 double old_position, double new_position, EDL *edl)
01758 {
01759 set_description(_("out point"));
01760 this->old_position = old_position;
01761 this->new_position = new_position;
01762 this->edl = edl;
01763 }
01764
01765 void OutPointUndoItem::undo()
01766 {
01767 edl->set_outpoint(old_position);
01768
01769 double tmp = new_position;
01770 new_position = old_position;
01771 old_position = tmp;
01772 }
01773
01774 int OutPointUndoItem::get_size()
01775 {
01776 return 20;
01777 }
01778
01779 void MWindow::set_outpoint(int is_mwindow)
01780 {
01781 OutPointUndoItem *undo_item;
01782
01783 undo_item = new OutPointUndoItem(edl->local_session->get_outpoint(),
01784 edl->local_session->get_selectionend(1), edl);
01785 undo->push_undo_item(undo_item);
01786
01787 edl->set_outpoint(edl->local_session->get_selectionend(1));
01788 save_backup();
01789
01790 if(!is_mwindow)
01791 {
01792 gui->lock_window("MWindow::set_outpoint 1");
01793 }
01794 gui->timebar->update();
01795 gui->flush();
01796 if(!is_mwindow)
01797 {
01798 gui->unlock_window();
01799 }
01800
01801 if(is_mwindow)
01802 {
01803 cwindow->gui->lock_window("MWindow::set_outpoint 2");
01804 }
01805 cwindow->gui->timebar->update();
01806 cwindow->gui->flush();
01807 if(is_mwindow)
01808 {
01809 cwindow->gui->unlock_window();
01810 }
01811 }
01812
01813 void MWindow::splice(EDL *source)
01814 {
01815 FileXML file;
01816
01817 source->copy(source->local_session->get_selectionstart(),
01818 source->local_session->get_selectionend(),
01819 1,
01820 0,
01821 0,
01822 &file,
01823 plugindb,
01824 "",
01825 1);
01826
01827
01828
01829
01830 double start = edl->local_session->get_selectionstart();
01831 double end = edl->local_session->get_selectionend();
01832 double source_start = source->local_session->get_selectionstart();
01833 double source_end = source->local_session->get_selectionend();
01834
01835 paste(start,
01836 start,
01837 &file,
01838 edl->session->labels_follow_edits,
01839 edl->session->plugins_follow_edits);
01840
01841
01842 edl->local_session->set_selectionstart(start +
01843 source_end -
01844 source_start);
01845 edl->local_session->set_selectionend(start +
01846 source_end -
01847 source_start);
01848
01849 save_backup();
01850 undo->update_undo(_("splice"), LOAD_EDITS | LOAD_TIMEBAR);
01851 update_plugin_guis();
01852 restart_brender();
01853 gui->update(1, 1, 1, 1, 0, 1, 0);
01854 sync_parameters(CHANGE_EDL);
01855 }
01856
01857 void MWindow::to_clip()
01858 {
01859 FileXML file;
01860 double start, end;
01861
01862 start = edl->local_session->get_selectionstart();
01863 end = edl->local_session->get_selectionend();
01864
01865 if(EQUIV(end, start))
01866 {
01867 start = 0;
01868 end = edl->tracks->total_length();
01869 }
01870
01871
01872 edl->copy(start,
01873 end,
01874 0,
01875 0,
01876 0,
01877 &file,
01878 plugindb,
01879 "",
01880 1);
01881
01882
01883 EDL *new_edl = new EDL(edl);
01884 new_edl->create_objects();
01885 new_edl->load_xml(plugindb, &file, LOAD_ALL);
01886 sprintf(new_edl->local_session->clip_title, _("Clip %d"), session->clip_number++);
01887 new_edl->local_session->set_selectionstart(0);
01888 new_edl->local_session->set_selectionend(0);
01889
01890 awindow->clip_edit->create_clip(new_edl);
01891 save_backup();
01892 }
01893
01894 class LabelUndoItem : public UndoStackItem
01895 {
01896 public:
01897 LabelUndoItem(double position1, double position2, EDL *edl);
01898 void undo();
01899 int get_size();
01900 private:
01901 double position1;
01902 double position2;
01903 EDL *edl;
01904 };
01905
01906 LabelUndoItem::LabelUndoItem(
01907 double position1, double position2, EDL *edl)
01908 {
01909 set_description(_("label"));
01910 this->position1 = position1;
01911 this->position2 = position2;
01912 this->edl = edl;
01913 }
01914
01915 void LabelUndoItem::undo()
01916 {
01917 edl->labels->toggle_label(position1, position2);
01918 }
01919
01920 int LabelUndoItem::get_size()
01921 {
01922 return 20;
01923 }
01924
01925 int MWindow::toggle_label(int is_mwindow)
01926 {
01927 LabelUndoItem *undo_item;
01928 double position1, position2;
01929
01930 if(cwindow->playback_engine->is_playing_back)
01931 {
01932 position1 = position2 =
01933 cwindow->playback_engine->get_tracking_position();
01934 }
01935 else
01936 {
01937 position1 = edl->local_session->get_selectionstart(1);
01938 position2 = edl->local_session->get_selectionend(1);
01939 }
01940
01941 position1 = edl->align_to_frame(position1, 0);
01942 position2 = edl->align_to_frame(position2, 0);
01943
01944
01945 undo_item = new LabelUndoItem(position1, position2, edl);
01946 undo->push_undo_item(undo_item);
01947
01948 edl->labels->toggle_label(position1, position2);
01949 save_backup();
01950
01951 if(!is_mwindow)
01952 {
01953 gui->lock_window("MWindow::toggle_label 1");
01954 }
01955 gui->timebar->update();
01956 gui->canvas->activate();
01957 gui->flush();
01958 if(!is_mwindow)
01959 {
01960 gui->unlock_window();
01961 }
01962
01963 if(is_mwindow)
01964 {
01965 cwindow->gui->lock_window("MWindow::toggle_label 2");
01966 }
01967 cwindow->gui->timebar->update();
01968 cwindow->gui->flush();
01969 if(is_mwindow)
01970 {
01971 cwindow->gui->unlock_window();
01972 }
01973
01974 return 0;
01975 }
01976
01977 void MWindow::trim_selection()
01978 {
01979
01980
01981 edl->trim_selection(edl->local_session->get_selectionstart(),
01982 edl->local_session->get_selectionend(),
01983 edl->session->labels_follow_edits,
01984 edl->session->plugins_follow_edits);
01985
01986 save_backup();
01987 undo->update_undo(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR);
01988 update_plugin_guis();
01989 gui->update(1, 2, 1, 1, 1, 1, 0);
01990 restart_brender();
01991 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
01992 CHANGE_EDL,
01993 edl,
01994 1);
01995 }
01996
01997
01998
01999 void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
02000 {
02001
02002
02003
02004
02005 calling_window_gui->unlock_window();
02006
02007 cwindow->playback_engine->que->send_command(STOP,
02008 CHANGE_NONE,
02009 0,
02010 0);
02011 vwindow->playback_engine->que->send_command(STOP,
02012 CHANGE_NONE,
02013 0,
02014 0);
02015 cwindow->playback_engine->interrupt_playback(0);
02016 vwindow->playback_engine->interrupt_playback(0);
02017
02018 cwindow->gui->lock_window("MWindow::undo_entry 1");
02019 vwindow->gui->lock_window("MWindow::undo_entry 4");
02020 gui->lock_window("MWindow::undo_entry 2");
02021
02022 undo->undo();
02023
02024 save_backup();
02025 restart_brender();
02026 update_plugin_states();
02027 update_plugin_guis();
02028 gui->update(1, 2, 1, 1, 1, 1, 1);
02029 cwindow->update(1, 1, 1, 1, 1);
02030
02031
02032
02033
02034
02035 if (calling_window_gui != cwindow->gui)
02036 cwindow->gui->unlock_window();
02037 if (calling_window_gui != gui)
02038 gui->unlock_window();
02039 if (calling_window_gui != vwindow->gui)
02040 vwindow->gui->unlock_window();
02041
02042
02043 awindow->gui->lock_window("MWindow::undo_entry 3");
02044 awindow->gui->update_assets();
02045 awindow->gui->flush();
02046 awindow->gui->unlock_window();
02047 cwindow->playback_engine->que->send_command(CURRENT_FRAME,
02048 CHANGE_ALL,
02049 edl,
02050 1);
02051 }
02052
02053
02054
02055 void MWindow::new_folder(char *new_folder)
02056 {
02057 edl->new_folder(new_folder);
02058 undo->update_undo(_("new folder"), LOAD_ALL);
02059 awindow->gui->lock_window("MWindow::new_folder");
02060 awindow->gui->update_assets();
02061 awindow->gui->unlock_window();
02062 }
02063
02064 void MWindow::delete_folder(char *folder)
02065 {
02066
02067 }
02068
02069 void MWindow::select_point(double position)
02070 {
02071 edl->local_session->set_selectionstart(position);
02072 edl->local_session->set_selectionend(position);
02073
02074
02075 cwindow->update(1, 0, 0, 0, 1);
02076 update_plugin_guis();
02077 gui->patchbay->update();
02078 gui->cursor->hide();
02079 gui->cursor->draw();
02080 gui->mainclock->update(edl->local_session->get_selectionstart(1));
02081 gui->zoombar->update();
02082 gui->canvas->flash();
02083 gui->flush();
02084 }
02085
02086
02087