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

mwindowedit.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "awindowgui.h"
00004 #include "awindow.h"
00005 #include "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 // Get w and h
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 // Get aspect ratio
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 //printf("MWindow::copy 1\n");
00261         FileXML file;
00262 //printf("MWindow::copy 1\n");
00263         edl->copy(start, 
00264                 end, 
00265                 0,
00266                 0,
00267                 0,
00268                 &file, 
00269                 plugindb,
00270                 "",
00271                 1);
00272 //printf("MWindow::copy 1\n");
00273 
00274 // File is now terminated and rewound
00275 
00276 //printf("MWindow::copy 1\n");
00277         gui->get_clipboard()->to_clipboard(file.string, strlen(file.string), SECONDARY_SELECTION);
00278 //printf("MWindow::copy\n%s\n", file.string);
00279 //printf("MWindow::copy 2\n");
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 // Uses cropping coordinates in edl session to crop and translate video.
00310 // We modify the projector since camera automation depends on the track size.
00311 void MWindow::crop_video()
00312 {
00313 
00314 // Clamp EDL crop region
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 // Recalculate aspect ratio
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 // Insert data from clipboard
00501 void MWindow::insert(double position, 
00502         FileXML *file,
00503         int edit_labels,
00504         int edit_plugins,
00505         EDL *parent_edl)
00506 {
00507 // For clipboard pasting make the new edl use a separate session 
00508 // from the master EDL.  Then it can be resampled to the master rates.
00509 // For splice, overwrite, and dragging need same session to get the assets.
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 // if(vwindow->edl)
00539 // printf("MWindow::insert 5 %f %f\n", 
00540 // vwindow->edl->local_session->in_point,
00541 // vwindow->edl->local_session->out_point);
00542         new_edls.remove_all();
00543 //printf("MWindow::insert 6 %p\n", vwindow->get_edl());
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 // GUI updated in TrackCanvas, after current_operations are reset
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 // Get default keyframe
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 // Insert plugin object
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 //printf("MWindow::modify_handles 1\n");
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 // Common to edithandles and plugin handles
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,      // 1 for incremental drawing.  2 for full refresh
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,      // 1 for incremental drawing.  2 for full refresh
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,      // 1 for incremental drawing.  2 for full refresh
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,      // 1 for incremental drawing.  2 for full refresh
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 // in/out points or selection present and shorter than overwrite range
00932 // shorten the copy range
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 // HACK around paste_edl get_start/endselection on its own
00947 // so we need to clear only when not using both io points
00948 // FIXME: need to write simple overwrite_edl to be used for overwrite function
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 // For splice and overwrite
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 // Want to insert with assets shared with the master EDL.
00984         insert(start, 
00985                         file,
00986                         edit_labels,
00987                         edit_plugins,
00988                         edl);
00989 
00990         return 0;
00991 }
00992 
00993 // For editing use insertion point position
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 //printf("MWindow::load_assets 1\n");
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 //printf("MWindow::load_assets 2 %d %d\n", new_assets->values[i]->audio_length, new_assets->values[i]->video_length);
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 //printf("MWindow::load_assets 3\n");
01121 
01122         paste_edls(&new_edls, 
01123                 load_mode, 
01124                 first_track,
01125                 position,
01126                 edit_labels,
01127                 edit_plugins);
01128 //printf("MWindow::load_assets 4\n");
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->