rework histogram_bezier, init wm icon set_icon(gg), update de.po+msg/txt
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.C
index 4411bf4bd0c652d0a065bb72f85e32ffbb7648f8..77705fcf53f2e2b2b741373b696eecc48e3f905c 100644 (file)
@@ -342,6 +342,7 @@ int EDL::save_xml(FileXML *file, const char *output_path)
 int EDL::copy_all(EDL *edl)
 {
        if( this == edl ) return 0;
+       folder_no = edl->folder_no;
        update_index(edl);
        copy_session(edl);
        copy_assets(edl);
@@ -402,7 +403,6 @@ void EDL::copy_session(EDL *edl, int session_only)
 
        if( !session_only ) {
                strcpy(this->path, edl->path);
-               awindow_folder = edl->awindow_folder;
                folders.copy_from(&edl->folders);
        }
 
@@ -410,7 +410,7 @@ void EDL::copy_session(EDL *edl, int session_only)
                session->copy(edl->session);
        }
 
-       if( !session_only ) {
+       if( session_only <= 0 ) {
                local_session->copy_from(edl->local_session);
        }
 }
@@ -1029,6 +1029,7 @@ EDL* EDL::add_clip(EDL *edl)
        EDL *new_edl = new EDL(this);
        new_edl->create_objects();
        new_edl->copy_all(edl);
+       new_edl->folder_no = AW_CLIP_FOLDER;
        clips.append(new_edl);
        return new_edl;
 }
@@ -1226,7 +1227,7 @@ const char *EDL::get_folder_name(int no)
        return !fp ? "" : fp->title;
 }
 
-int EDL::new_folder(const char *title)
+int EDL::new_folder(const char *title, int is_clips)
 {
        if( !title[0] ) return 1;
        int ret = get_folder_number(title);
@@ -1237,7 +1238,7 @@ int EDL::new_folder(const char *title)
                int no = fp->awindow_folder;
                if( no >= idx ) idx = no+1;
        }
-       folders.append(new BinFolder(idx, title));
+       folders.append(new BinFolder(idx, is_clips, title));
        return 0;
 }
 
@@ -1402,7 +1403,6 @@ int64_t EDL::get_video_frames()
                session->frame_rate);
 }
 
-
 void EDL::remove_vwindow_edls()
 {
        for( int i=0; i<total_vwindow_edls(); ++i ) {
@@ -1541,43 +1541,59 @@ void EDL::set_proxy(int new_scale, int use_scaler,
                rescale_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;
+       int folder_no = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
        for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-               const char *orig_path = orig_assets->get(i)->path;
                Indexable *proxy_idxbl = proxy_assets->get(i);
-               proxy_idxbl->awindow_folder = awindow_folder;
-               Asset *proxy_asset = proxy_idxbl->is_asset ? assets->update((Asset *)proxy_idxbl) : 0;
-               EDL *proxy_edl = !proxy_idxbl->is_asset ? (EDL *)proxy_idxbl : 0;
+               proxy_idxbl->folder_no = folder_no;
+               if( !proxy_idxbl->is_asset ) continue;
+               Asset *proxy_asset = assets->update((Asset *)proxy_idxbl);
+               if( proxy_asset == (Asset *)proxy_idxbl ) continue;
+               proxy_asset->width = proxy_idxbl->get_w();
+               proxy_asset->height = proxy_idxbl->get_h();
+       }
 // replace track contents
-               for( Track *track=tracks->first; track; track=track->next ) {
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( track->data_type != TRACK_VIDEO ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       Indexable *idxbl = (Indexable *)edit->asset;
+                       if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
+                       if( !idxbl ) continue;
+                       int i = orig_assets->size();
+                       while( --i>=0 && strcmp(orig_assets->get(i)->path, idxbl->path) );
+                       if( i < 0 ) continue;
+                       Indexable *proxy_idxbl = proxy_assets->get(i);
+                       Asset *proxy_asset = proxy_idxbl->is_asset ?
+                               assets->update((Asset *)proxy_idxbl) : 0;
+                       EDL *proxy_edl = !proxy_idxbl->is_asset ?
+                               (EDL *)proxy_idxbl : 0;
+                       edit->asset = proxy_asset;
+                       edit->nested_edl = proxy_edl;
+               }
+       }
+       for( int j=0,n=clips.size(); j<n; ++j ) {
+               EDL *clip = clips[j];
+               int has_proxy = 0;
+               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 ) {
                                Indexable *idxbl = (Indexable *)edit->asset;
                                if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
                                if( !idxbl ) continue;
-                               if( strcmp(idxbl->path, orig_path) ) continue;
+                               int i = orig_assets->size();
+                               while( --i>=0 && strcmp(orig_assets->get(i)->path, idxbl->path) );
+                               if( i < 0 ) continue;
+                               Indexable *proxy_idxbl = proxy_assets->get(i);
+                               Asset *proxy_asset = proxy_idxbl->is_asset ?
+                                       assets->update((Asset *)proxy_idxbl) : 0;
+                               EDL *proxy_edl = !proxy_idxbl->is_asset ?
+                                       (EDL *)proxy_idxbl : 0;
                                edit->asset = proxy_asset;
                                edit->nested_edl = proxy_edl;
+                               has_proxy = 1;
                        }
                }
-               for( int j=0,m=clips.size(); j<m; ++j ) {
-                       EDL *clip = clips[j];
-                       int has_proxy = 0;
-                       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 ) {
-                                       Indexable *idxbl = (Indexable *)edit->asset;
-                                       if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
-                                       if( !idxbl ) continue;
-                                       if( strcmp(idxbl->path, orig_path) ) continue;
-                                       edit->asset = proxy_asset;
-                                       edit->nested_edl = proxy_edl;
-                                       has_proxy = 1;
-                               }
-                       }
-                       if( has_proxy && !orig_use_scaler )
-                               clip->rescale_proxy(orig_scale, new_scale);
-               }
+               if( has_proxy && !orig_use_scaler )
+                       clip->rescale_proxy(orig_scale, new_scale);
        }
 }
 
@@ -1595,7 +1611,7 @@ void EDL::add_proxy(int use_scaler,
 // change original assets to proxy assets
        for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
                Asset *proxy_asset = assets->update((Asset *)proxy_assets->get(i));
-               proxy_asset->awindow_folder = AW_PROXY_FOLDER;
+               proxy_asset->folder_no = AW_PROXY_FOLDER;
 // replace track contents
                for( Track *track=tracks->first; track; track=track->next ) {
                        if( track->data_type != TRACK_VIDEO ) continue;
@@ -1609,6 +1625,12 @@ void EDL::add_proxy(int use_scaler,
        }
 }
 
+Asset *EDL::get_proxy_asset()
+{
+       return folder_no == AW_PROXY_FOLDER ?
+               tracks->first->edits->first->asset : 0;
+}
+
 double EDL::get_cursor_position(int cursor_x, int pane_no)
 {
        return (double)cursor_x * local_session->zoom_sample / session->sample_rate +