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