rework set default transtion, nested proxy edl fixes, doubleclick proxy media fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindowedit.C
index 065c1f9f08d475fe994aec06fb3a1f39de87cd04..3016050ba567e6451c6357143feeea4ff74fa016 100644 (file)
@@ -1655,11 +1655,6 @@ void MWindow::paste_transition()
        PluginServer *server = session->drag_pluginservers->values[0];
 
        undo->update_undo_before();
-       if( server->audio )
-               strcpy(edl->session->default_atransition, server->title);
-       else
-               strcpy(edl->session->default_vtransition, server->title);
-
        edl->tracks->paste_transition(server, session->edit_highlighted);
        save_backup();
        undo->update_undo_after(_("transition"), LOAD_EDITS);
@@ -1676,7 +1671,6 @@ void MWindow::paste_transitions(int track_type, char *title)
        double start = edl->local_session->get_selectionstart();
        double end = edl->local_session->get_selectionend();
        edl->tracks->paste_transitions(start, end, track_type, title);
-
        save_backup();
        undo->update_undo_after(_("attach transitions"), LOAD_EDITS);
 
@@ -2319,114 +2313,27 @@ void MWindow::remap_audio(int pattern)
        }
 }
 
-void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale,
-               ArrayList<Indexable*> *orig_assets,
-               ArrayList<Indexable*> *proxy_assets)
-{
-       int orig_use_scaler = edl->session->proxy_use_scaler;
-       int orig_scale = edl->session->proxy_scale;
-// rescale to full size asset in read_frame
-       edl->session->proxy_use_scaler = use_scaler;
-       edl->session->proxy_scale = new_scale;
-       edl->session->proxy_auto_scale = auto_scale;
-
-       if( use_scaler ) {
-               for( int i=0; i<proxy_assets->size(); ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
-               new_scale = 1;
-       }
-
-       if( !orig_use_scaler && new_scale != orig_scale ) {
-// project size
-               float orig_w = (float)edl->session->output_w * orig_scale;
-               float orig_h = (float)edl->session->output_h * orig_scale;
-               edl->session->output_w = Units::round(orig_w / new_scale);
-               edl->session->output_h = Units::round(orig_h / new_scale);
-
-// track sizes
-               for( Track *track=edl->tracks->first; track; track=track->next ) {
-                       if( track->data_type != TRACK_VIDEO ) continue;
-                       orig_w = (float)track->track_w * orig_scale;
-                       orig_h = (float)track->track_h * orig_scale;
-                       track->track_w = Units::round(orig_w / new_scale);
-                       track->track_h = Units::round(orig_h / new_scale);
-                       ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->
-                               set_proxy(orig_scale, new_scale);
-                       ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_X])->
-                               set_proxy(orig_scale, new_scale);
-                       ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_Y])->
-                               set_proxy(orig_scale, new_scale);
-                       ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_X])->
-                               set_proxy(orig_scale, new_scale);
-                       ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_Y])->
-                               set_proxy(orig_scale, new_scale);
-               }
-       }
 
-// change original assets to proxy assets
-       int awindow_folder = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
-       for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-               Asset *proxy_asset = edl->assets->update((Asset *)proxy_assets->get(i));
-               proxy_asset->awindow_folder = awindow_folder;
-// replace track contents
-               for( Track *track=edl->tracks->first; track; track=track->next ) {
-                       if( track->data_type != TRACK_VIDEO ) continue;
-                       for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
-                               if( !edit->asset ) continue;
-                               if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) {
-                                       edit->asset = proxy_asset;
-                               }
-                       }
-               }
-               for( int j=0,m=edl->clips.size(); j<m; ++j ) {
-                       EDL *clip = edl->clips[j];
-                       for( Track *track=clip->tracks->first; track; track=track->next ) {
-                               if( track->data_type != TRACK_VIDEO ) continue;
-                               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
-                                       if( !edit->asset ) continue;
-                                       if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) {
-                                               edit->asset = proxy_asset;
-                                       }
-                               }
-                       }
-               }
-       }
+void MWindow::rescale_proxy(EDL *clip, int orig_scale, int new_scale)
+{
+       edl->rescale_proxy(orig_scale, new_scale);
 }
 
-void MWindow::add_proxy(int use_scaler,
-               ArrayList<Indexable*> *orig_assets,
-               ArrayList<Indexable*> *proxy_assets)
-{
-       if( use_scaler ) {
-               for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
-       }
+void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale,
+       ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+{
+       edl->set_proxy(use_scaler, new_scale, auto_scale, orig_assets, proxy_assets);
+}
 
-// change original assets to proxy assets
-       for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-               Asset *proxy_asset = edl->assets->update((Asset *)proxy_assets->get(i));
-               proxy_asset->awindow_folder = AW_PROXY_FOLDER;
-// replace track contents
-               for( Track *track=edl->tracks->first; track; track=track->next ) {
-                       if( track->data_type != TRACK_VIDEO ) continue;
-                       for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
-                               if( !edit->asset ) continue;
-                               if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) {
-                                       edit->asset = proxy_asset;
-                               }
-                       }
-               }
-       }
+void MWindow::add_proxy(int use_scaler,
+       ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+{
+       edl->add_proxy(use_scaler, orig_assets, proxy_assets);
 }
 
 void MWindow::cut_commercials()
 {
+#ifdef HAVE_COMMERCIAL
        undo->update_undo_before();
        commercials->scan_media();
        edl->optimize();
@@ -2438,6 +2345,7 @@ void MWindow::cut_commercials()
        gui->update(1, 2, 1, 1, 1, 1, 0);
        cwindow->update(1, 0, 0, 0, 1);
        cwindow->refresh_frame(CHANGE_EDL);
+#endif
 }
 
 int MWindow::normalize_speed(EDL *old_edl, EDL *new_edl)