rework proxy scaler, fix crop-gui coord, video_data tweak for proxy_format
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindowedit.C
index c34513d3add94843c33a3f2fa755882424e5b020..2d09eeb0434a94d283b4c8496645e4c257b71ffb 100644 (file)
@@ -203,7 +203,7 @@ void MWindow::asset_to_all()
                                }
                        }
 
-
+#ifdef GLx4
                        if( ((edl->session->output_w % 4) ||
                                (edl->session->output_h % 4)) &&
                                edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
@@ -211,7 +211,7 @@ void MWindow::asset_to_all()
                                        _("This project's dimensions are not multiples of 4 so\n"
                                        "it can't be rendered by OpenGL."));
                        }
-
+#endif
 // Get aspect ratio
                        if( defaults->get("AUTOASPECT", 0) ) {
                                create_aspect_ratio(
@@ -250,7 +250,7 @@ void MWindow::asset_to_size()
                h = indexable->get_h();
                edl->session->output_w = w;
                edl->session->output_h = h;
-
+#ifdef GLx4
                if( ((edl->session->output_w % 4) ||
                        (edl->session->output_h % 4)) &&
                        edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
@@ -258,7 +258,7 @@ void MWindow::asset_to_size()
                                _("This project's dimensions are not multiples of 4 so\n"
                                "it can't be rendered by OpenGL."));
                }
-
+#endif
 // Get aspect ratio
                if( defaults->get("AUTOASPECT", 0) ) {
                        create_aspect_ratio(edl->session->aspect_w,
@@ -403,10 +403,43 @@ void MWindow::clear_labels()
 
 int MWindow::clear_labels(double start, double end)
 {
+       if( start == end ) {
+               start = 0;
+               end = edl->tracks->total_length();
+       }
        edl->labels->clear(start, end, 0);
        return 0;
 }
 
+void MWindow::clear_hard_edges()
+{
+       undo_before();
+       clear_hard_edges(edl->local_session->get_selectionstart(),
+               edl->local_session->get_selectionend());
+       edl->optimize();
+       save_backup();
+       undo_after(_("clear hard edges"), LOAD_EDITS);
+       restart_brender();
+       gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
+       cwindow->refresh_frame(CHANGE_EDL);
+}
+
+int MWindow::clear_hard_edges(double start, double end)
+{
+       if( start == end ) {
+               start = 0;
+               end = edl->tracks->total_length();
+       }
+       edl->clear_hard_edges(start, end);
+       return 0;
+}
+
+void MWindow::clear_select()
+{
+       edl->tracks->clear_selected_edits();
+       gui->draw_overlays(1);
+}
+
 void MWindow::concatenate_tracks()
 {
        undo_before();
@@ -478,12 +511,10 @@ int MWindow::copy_default_keyframe()
        return 0;
 }
 
-
 // Uses cropping coordinates in edl session to crop and translate video.
 // We modify the projector since camera automation depends on the track size.
-void MWindow::crop_video()
+void MWindow::crop_video(int mode)
 {
-
        undo_before();
 // Clamp EDL crop region
        if( edl->session->crop_x1 > edl->session->crop_x2 ) {
@@ -496,22 +527,54 @@ void MWindow::crop_video()
                edl->session->crop_y2 ^= edl->session->crop_y1;
                edl->session->crop_y1 ^= edl->session->crop_y2;
        }
-
-       float old_projector_x = (float)edl->session->output_w / 2;
-       float old_projector_y = (float)edl->session->output_h / 2;
-       float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
-       float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
-       float projector_offset_x = -(new_projector_x - old_projector_x);
-       float projector_offset_y = -(new_projector_y - old_projector_y);
-
-       edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
-
-       edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
-       edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
-       edl->session->crop_x1 = 0;
-       edl->session->crop_y1 = 0;
-       edl->session->crop_x2 = edl->session->output_w;
-       edl->session->crop_y2 = edl->session->output_h;
+       switch( mode ) {
+       case CROP_REFORMAT: {
+               float ctr_x = edl->session->output_w / 2.;
+               float ctr_y = edl->session->output_h / 2.;
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               float dx = -(new_x - ctr_x), dy = -(new_y - ctr_y);
+               edl->tracks->translate_projector(dx, dy, 1);
+
+               edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
+               edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
+               edl->session->crop_x1 = edl->session->crop_y1 = 0;
+               edl->session->crop_x2 = edl->session->output_w;
+               edl->session->crop_y2 = edl->session->output_h;
+               break; }
+       case CROP_RESIZE: {
+               float old_w = edl->session->output_w;
+               float old_h = edl->session->output_h;
+               float new_w = edl->session->crop_x2 - edl->session->crop_x1;
+               float new_h = edl->session->crop_y2 - edl->session->crop_y1;
+               if( !new_w ) new_w = 1;
+               if( !new_h ) new_h = 1;
+               float xzoom = old_w / new_w, yzoom = old_h / new_h;
+               float new_z = bmin(xzoom, yzoom);
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               edl->tracks->crop_resize(new_x, new_y, new_z);
+
+               edl->session->crop_x1 = 0;
+               edl->session->crop_y1 = 0;
+               edl->session->crop_x2 = edl->session->output_w;
+               edl->session->crop_y2 = edl->session->output_h;
+               break; }
+       case CROP_SHRINK: {
+               float old_w = edl->session->output_w;
+               float old_h = edl->session->output_h;
+               float new_w = edl->session->crop_x2 - edl->session->crop_x1;
+               float new_h = edl->session->crop_y2 - edl->session->crop_y1;
+               if( !new_w ) new_w = 1;
+               if( !new_h ) new_h = 1;
+               float xzoom = old_w / new_w, yzoom = old_h / new_h;
+               float new_z = bmin(xzoom, yzoom);
+
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               edl->tracks->crop_shrink(new_x, new_y, new_z);
+               break; }
+       }
 
 // Recalculate aspect ratio
        if( defaults->get("AUTOASPECT", 0) ) {
@@ -646,12 +709,6 @@ int MWindow::cut_default_keyframe()
 }
 
 
-void MWindow::delete_track()
-{
-       if( edl->tracks->last )
-               delete_track(edl->tracks->last);
-}
-
 void MWindow::delete_tracks()
 {
        undo_before();
@@ -914,190 +971,6 @@ void MWindow::match_output_size(Track *track)
 }
 
 
-EDL *MWindow::selected_edits_to_clip(int packed,
-               double *start_position, Track **start_track,
-               int edit_labels, int edit_autos, int edit_plugins)
-{
-       double start = DBL_MAX, end = DBL_MIN;
-       Track *first_track=0, *last_track = 0;
-       for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
-               int empty = 1;
-               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
-                       if( !edit->is_selected || edit->silence() ) continue;
-                       double edit_pos = track->from_units(edit->startproject);
-                       if( start > edit_pos ) start = edit_pos;
-                       if( end < (edit_pos+=edit->length) ) end = edit_pos;
-                       empty = 0;
-               }
-               if( empty ) continue;
-               if( !first_track ) first_track = track;
-               last_track = track;
-       }
-       if( start_position ) *start_position = start;
-       if( start_track ) *start_track = first_track;
-       if( !first_track ) return 0;
-       EDL *new_edl = new EDL();
-       new_edl->create_objects();
-       new_edl->copy_session(edl);
-       const char *text = _("new_edl edit");
-       new_edl->set_path(text);
-       strcpy(new_edl->local_session->clip_title, text);
-       strcpy(new_edl->local_session->clip_notes, text);
-       new_edl->session->video_tracks = 0;
-       new_edl->session->audio_tracks = 0;
-       for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
-               if( first_track ) {
-                       if( first_track != track ) continue;
-                       first_track = 0;
-               }
-               Track *new_track = 0;
-               if( !packed )
-                       new_track = new_edl->add_new_track(track->data_type);
-               int64_t start_pos = track->to_units(start, 0);
-               int64_t end_pos = track->to_units(end, 0);
-               int64_t startproject = 0;
-               Edit *edit = track->edits->first;
-               for( ; edit; edit=edit->next ) {
-                       if( !edit->is_selected || edit->silence() ) continue;
-                       if( edit->startproject < start_pos ) continue;
-                       if( edit->startproject >= end_pos ) break;
-                       int64_t edit_start_pos = edit->startproject;
-                       int64_t edit_end_pos = edit->startproject + edit->length;
-                       if( !new_track )
-                               new_track = new_edl->add_new_track(track->data_type);
-                       int64_t edit_pos = edit_start_pos - start_pos;
-                       if( !packed && edit_pos > startproject ) {
-                               Edit *silence = new Edit(new_edl, new_track);
-                               silence->startproject = startproject;
-                               silence->length = edit_pos - startproject;
-                               new_track->edits->append(silence);
-                               startproject = edit_pos;
-                       }
-                       int64_t clip_start_pos = startproject;
-                       Edit *clip_edit = new Edit(new_edl, new_track);
-                       clip_edit->copy_from(edit);
-                       clip_edit->startproject = startproject;
-                       startproject += clip_edit->length;
-                       new_track->edits->append(clip_edit);
-                       if( edit_labels ) {
-                               double edit_start = track->from_units(edit_start_pos);
-                               double edit_end = track->from_units(edit_end_pos);
-                               double clip_start = new_track->from_units(clip_start_pos);
-                               Label *label = edl->labels->first;
-                               for( ; label; label=label->next ) {
-                                       if( label->position < edit_start ) continue;
-                                       if( label->position >= edit_end ) break;
-                                       double clip_position = label->position - edit_start + clip_start;
-                                       Label *clip_label = new_edl->labels->first;
-                                       while( clip_label && clip_label->position<clip_position )
-                                               clip_label = clip_label->next;
-                                       if( clip_label && clip_label->position == clip_position ) continue;
-                                       Label *new_label = new Label(new_edl,
-                                               new_edl->labels, clip_position, label->textstr);
-                                       new_edl->labels->insert_before(clip_label, new_label);
-                               }
-                       }
-                       if( edit_autos ) {
-                               Automation *automation = track->automation;
-                               Automation *new_automation = new_track->automation;
-                               for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
-                                       Autos *autos = automation->autos[i];
-                                       if( !autos ) continue;
-                                       Autos *new_autos = new_automation->autos[i];
-                                       new_autos->default_auto->copy_from(autos->default_auto);
-                                       Auto *aut0 = autos->first;
-                                       for( ; aut0; aut0=aut0->next ) {
-                                               if( aut0->position < edit_start_pos ) continue;
-                                               if( aut0->position >= edit_end_pos ) break;
-                                               Auto *new_auto = new_autos->new_auto();
-                                               new_auto->copy_from(aut0);
-                                               int64_t clip_position = aut0->position - edit_start_pos + clip_start_pos;
-                                               new_auto->position = clip_position;
-                                               new_autos->append(new_auto);
-                                       }
-                               }
-                       }
-                       if( edit_plugins ) {
-                               while( new_track->plugin_set.size() < track->plugin_set.size() )
-                                       new_track->plugin_set.append(0);
-                               for( int i=0; i<track->plugin_set.total; ++i ) {
-                                       PluginSet *plugin_set = track->plugin_set[i];
-                                       if( !plugin_set ) continue;
-                                       PluginSet *new_plugin_set = new_track->plugin_set[i];
-                                       if( !new_plugin_set ) {
-                                               new_plugin_set = new PluginSet(new_edl, new_track);
-                                               new_track->plugin_set[i] = new_plugin_set;
-                                       }
-                                       Plugin *plugin = (Plugin*)plugin_set->first;
-                                       int64_t startplugin = new_plugin_set->length();
-                                       for( ; plugin ; plugin=(Plugin*)plugin->next ) {
-                                               if( plugin->silence() ) continue;
-                                               int64_t plugin_start_pos = plugin->startproject;
-                                               int64_t plugin_end_pos = plugin_start_pos + plugin->length;
-                                               if( plugin_end_pos < start_pos ) continue;
-                                               if( plugin_start_pos > end_pos ) break;
-                                               if( plugin_start_pos < edit_start_pos )
-                                                       plugin_start_pos = edit_start_pos;
-                                               if( plugin_end_pos > edit_end_pos )
-                                                       plugin_end_pos = edit_end_pos;
-                                               if( plugin_start_pos >= plugin_end_pos ) continue;
-                                               int64_t plugin_pos = plugin_start_pos - start_pos;
-                                               if( !packed && plugin_pos > startplugin ) {
-                                                       Plugin *silence = new Plugin(new_edl, new_track, "");
-                                                       silence->startproject = startplugin;
-                                                       silence->length = plugin_pos - startplugin;
-                                                       new_plugin_set->append(silence);
-                                                       startplugin = plugin_pos;
-                                               }
-                                               Plugin *new_plugin = new Plugin(new_edl, new_track, plugin->title);
-                                               new_plugin->copy_base(plugin);
-                                               new_plugin->startproject = startplugin;
-                                               new_plugin->length = plugin_end_pos - plugin_start_pos;
-                                               startplugin += new_plugin->length;
-                                               new_plugin_set->append(new_plugin);
-                                               KeyFrames *keyframes = plugin->keyframes;
-                                               KeyFrames *new_keyframes = new_plugin->keyframes;
-                                               new_keyframes->default_auto->copy_from(keyframes->default_auto);
-                                               new_keyframes->default_auto->position = new_plugin->startproject;
-                                               KeyFrame *keyframe = (KeyFrame*)keyframes->first;
-                                               for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
-                                                       if( keyframe->position < edit_start_pos ) continue;
-                                                       if( keyframe->position >= edit_end_pos ) break;
-                                                       KeyFrame *clip_keyframe = new KeyFrame(new_edl, new_keyframes);
-                                                       clip_keyframe->copy_from(keyframe);
-                                                       int64_t key_position = keyframe->position - start_pos;
-                                                       if( packed )
-                                                               key_position += new_plugin->startproject - plugin_pos;
-                                                       clip_keyframe->position = key_position;
-                                                       new_keyframes->append(clip_keyframe);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               if( last_track == track ) break;
-       }
-       return new_edl;
-}
-
-void MWindow::selected_edits_to_clipboard(int packed)
-{
-       EDL *new_edl = selected_edits_to_clip(packed, 0, 0,
-               edl->session->labels_follow_edits,
-               edl->session->autos_follow_edits,
-               edl->session->plugins_follow_edits);
-       if( !new_edl ) return;
-       FileXML file;
-       new_edl->copy(COPY_EDL, &file, "", 1);
-       const char *file_string = file.string();
-       long file_length = strlen(file_string);
-       gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
-       gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
-       new_edl->remove_user();
-}
-
 void MWindow::delete_edit(Edit *edit, const char *msg, int collapse)
 {
        ArrayList<Edit*> edits;
@@ -1164,131 +1037,20 @@ void MWindow::move_edits(ArrayList<Edit*> *edits,
        gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0);
 }
 
-void MWindow::paste_edits(EDL *clip, Track *first_track, double position, int overwrite,
-               int edit_edits, int edit_labels, int edit_autos, int edit_plugins)
+void MWindow::selected_edits_to_clipboard(int packed)
 {
-       if( !first_track )
-               first_track = edl->tracks->first;
-       Track *src = clip->tracks->first;
-       for( Track *track=first_track; track && src; track=track->next ) {
-               if( !track->record ) continue;
-               int64_t pos = track->to_units(position, 0);
-               if( edit_edits ) {
-                       for( Edit *edit=src->edits->first; edit; edit=edit->next ) {
-                               if( edit->silence() ) continue;
-                               int64_t start = pos + edit->startproject;
-                               int64_t len = edit->length, end = start + len;
-                               if( overwrite )
-                                       track->edits->clear(start, end);
-                               Edit *dst = track->edits->insert_new_edit(start);
-                               dst->copy_from(edit);
-                               dst->startproject = start;
-                               dst->is_selected = 1;
-                               while( (dst=dst->next) != 0 )
-                                       dst->startproject += edit->length;
-                               if( overwrite ) continue;
-                               if( edit_labels && track == first_track ) {
-                                       double dst_pos = track->from_units(start);
-                                       double dst_len = track->from_units(len);
-                                       for( Label *label=edl->labels->first; label; label=label->next ) {
-                                               if( label->position >= dst_pos )
-                                                       label->position += dst_len;
-                                       }
-                               }
-                               if( edit_autos ) {
-                                       for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
-                                               Autos *autos = track->automation->autos[i];
-                                               if( !autos ) continue;
-                                               for( Auto *aut0=autos->first; aut0; aut0=aut0->next ) {
-                                                       if( aut0->position >= start )
-                                                               aut0->position += edit->length;
-                                               }
-                                       }
-                               }
-                               if( edit_plugins ) {
-                                       for( int i=0; i<track->plugin_set.size(); ++i ) {
-                                               PluginSet *plugin_set = track->plugin_set[i];
-                                               Plugin *plugin = (Plugin *)plugin_set->first;
-                                               for( ; plugin; plugin=(Plugin *)plugin->next ) {
-                                                       if( plugin->startproject >= start )
-                                                               plugin->startproject += edit->length;
-                                                       else if( plugin->startproject+plugin->length > end )
-                                                               plugin->length += edit->length;
-                                                       Auto *default_keyframe = plugin->keyframes->default_auto;
-                                                       if( default_keyframe->position >= start )
-                                                               default_keyframe->position += edit->length;
-                                                       KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
-                                                       for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
-                                                               if( keyframe->position >= start )
-                                                                       keyframe->position += edit->length;
-                                                       }
-                                               }
-                                               plugin_set->optimize();
-                                       }
-                               }
-                       }
-               }
-               if( edit_autos ) {
-                       for( int i=0; i<AUTOMATION_TOTAL; ++i ) {
-                               Autos *src_autos = src->automation->autos[i];
-                               if( !src_autos ) continue;
-                               Autos *autos = track->automation->autos[i];
-                               for( Auto *aut0=src_autos->first; aut0; aut0=aut0->next ) {
-                                       int64_t auto_pos = pos + aut0->position;
-                                       autos->insert_auto(auto_pos, aut0);
-                               }
-                       }
-               }
-               if( edit_plugins ) {
-                       for( int i=0; i<src->plugin_set.size(); ++i ) {
-                               PluginSet *plugin_set = src->plugin_set[i];
-                               if( !plugin_set ) continue;
-                               while( i >= track->plugin_set.size() )
-                                       track->plugin_set.append(0);
-                               PluginSet *dst_plugin_set = track->plugin_set[i];
-                               if( !dst_plugin_set ) {
-                                       dst_plugin_set = new PluginSet(edl, track);
-                                       track->plugin_set[i] = dst_plugin_set;
-                               }
-                               Plugin *plugin = (Plugin *)plugin_set->first;
-                               if( plugin ) track->expand_view = 1;
-                               for( ; plugin; plugin=(Plugin *)plugin->next ) {
-                                       int64_t start = pos + plugin->startproject;
-                                       int64_t end = start + plugin->length;
-                                       if( overwrite || edit_edits )
-                                               dst_plugin_set->clear(start, end, 1);
-                                       Plugin *new_plugin = dst_plugin_set->insert_plugin(plugin->title,
-                                               start, end-start, plugin->plugin_type, &plugin->shared_location,
-                                               (KeyFrame*)plugin->keyframes->default_auto, 0);
-                                       KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
-                                       for( ; keyframe; keyframe=(KeyFrame*)keyframe->next ) {
-                                               int64_t keyframe_pos = pos + keyframe->position;
-                                               new_plugin->keyframes->insert_auto(keyframe_pos, keyframe);
-                                       }
-                                       while( (new_plugin=(Plugin *)new_plugin->next) ) {
-                                               KeyFrame *keyframe = (KeyFrame*)new_plugin->keyframes->first;
-                                               for( ; keyframe; keyframe=(KeyFrame*)keyframe->next )
-                                                       keyframe->position += plugin->length;
-                                       }
-                               }
-                       }
-               }
-               src = src->next;
-       }
-       if( edit_labels ) {
-               Label *edl_label = edl->labels->first;
-               for( Label *label=clip->labels->first; label; label=label->next ) {
-                       double label_pos = position + label->position;
-                       int exists = 0;
-                       while( edl_label &&
-                               !(exists=edl->equivalent(edl_label->position, label_pos)) &&
-                               edl_label->position < position ) edl_label = edl_label->next;
-                       if( exists ) continue;
-                       edl->labels->insert_before(edl_label,
-                               new Label(edl, edl->labels, label_pos, label->textstr));
-               }
-       }
-       edl->optimize();
+       EDL *new_edl = edl->selected_edits_to_clip(packed, 0, 0,
+               edl->session->labels_follow_edits,
+               edl->session->autos_follow_edits,
+               edl->session->plugins_follow_edits);
+       if( !new_edl ) return;
+       FileXML file;
+       new_edl->copy(COPY_EDL, &file, "", 1);
+       const char *file_string = file.string();
+       long file_length = strlen(file_string);
+       gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
+       gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
+       new_edl->remove_user();
 }
 
 void MWindow::paste_clipboard(Track *first_track, double position, int overwrite,
@@ -1305,7 +1067,7 @@ void MWindow::paste_clipboard(Track *first_track, double position, int overwrite
        clip->create_objects();
        if( !clip->load_xml(&file, LOAD_ALL) ) {
                undo_before();
-               paste_edits(clip, first_track, position, overwrite,
+               edl->paste_edits(clip, first_track, position, overwrite,
                        edit_edits, edit_labels, edit_autos, edit_plugins);
                save_backup();
                undo_after(_("paste clip"), LOAD_ALL);
@@ -1330,7 +1092,7 @@ void MWindow::move_group(EDL *group, Track *first_track, double position, int ov
        if( edl->session->labels_follow_edits )
                edl->delete_edit_labels(&edits, 0);
        edl->delete_edits(&edits, 0);
-       paste_edits(group, first_track, position, overwrite, 1,
+       edl->paste_edits(group, first_track, position, overwrite, 1,
                edl->session->labels_follow_edits,
                edl->session->autos_follow_edits,
                edl->session->plugins_follow_edits);
@@ -1620,7 +1382,8 @@ void MWindow::load_assets(ArrayList<Indexable*> *new_assets,
                load_mode = LOADMODE_ASSETSONLY;
 const int debug = 0;
 if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
-       if( position < 0 ) position = edl->local_session->get_selectionstart();
+       if( position < 0 )
+               position = edl->local_session->get_selectionstart();
 
        ArrayList<EDL*> new_edls;
        for( int i=0; i<new_assets->total; ++i ) {
@@ -1786,6 +1549,9 @@ int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
                                default:
                                        continue;
                                }
+// re-label only if not already labeled
+                               if( new_edl->local_session->asset2edl )
+                                       strcpy(current->title, edl->tracks->last->title);
                                destination_tracks.append(edl->tracks->last);
                        }
 
@@ -1843,9 +1609,12 @@ int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
 // Get starting point of insertion.  Need this to paste labels.
                switch( load_mode ) {
                case LOADMODE_REPLACE:
-               case LOADMODE_NEW_TRACKS:
                        current_position = 0;
                        break;
+               case LOADMODE_NEW_TRACKS:
+                       if( !overwrite )
+                               current_position = 0;
+                       break;
 
                case LOADMODE_CONCATENATE:
                case LOADMODE_REPLACE_CONCATENATE:
@@ -1872,22 +1641,19 @@ int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
                        edl->add_clip(new_edl);
                        break;
                }
-//PRINT_TRACE
 // Insert edl
                if( load_mode != LOADMODE_RESOURCESONLY &&
                    load_mode != LOADMODE_ASSETSONLY ) {
 // Insert labels
-                       if( edl->session->labels_follow_edits ) {
-//printf("MWindow::paste_edls %f %f\n", current_position, edl_length);
+                       if( edit_labels ) {
                                if( load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED )
                                        edl->labels->insert_labels(new_edl->labels,
                                                destination_tracks.total ? paste_position[0] : 0.0,
-                                               edl_length, edit_labels);
+                                               edl_length, 1);
                                else
                                        edl->labels->insert_labels(new_edl->labels, current_position,
-                                               edl_length, edit_labels);
+                                               edl_length, 1);
                        }
-//PRINT_TRACE
                        double total_length = new_edl->tracks->total_length();
                        for( Track *new_track=new_edl->tracks->first;
                             new_track; new_track=new_track->next ) {
@@ -2286,8 +2052,8 @@ void MWindow::redo_entry(BC_WindowBase *calling_window_gui)
        gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 1);
        gui->update_proxy_toggle();
        gui->unlock_window();
-       cwindow->update(1, 1, 1, 1, 1);
        cwindow->gui->unlock_window();
+       cwindow->update(1, 1, 1, 1, 1);
 
        for( int i=0; i < vwindows.size(); ++i ) {
                if( vwindows.get(i)->is_running() ) {
@@ -2561,8 +2327,8 @@ void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
        gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 1);
        gui->update_proxy_toggle();
        gui->unlock_window();
-       cwindow->update(1, 1, 1, 1, 1);
        cwindow->gui->unlock_window();
+       cwindow->update(1, 1, 1, 1, 1);
 
        for( int i=0; i<vwindows.size(); ++i ) {
                if( vwindows.get(i)->is_running() ) {
@@ -2691,10 +2457,9 @@ 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)
+void MWindow::add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
-       edl->add_proxy(use_scaler, orig_assets, proxy_assets);
+       edl->add_proxy(orig_assets, proxy_assets);
 }
 
 void MWindow::cut_commercials()