add binfolder path relative filters, fix gbrp color model, vwdw timebar tweaks, title...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edit.C
index 0ede9b9ef2a34acfc7dc22f38bcb52771b469055..198a0fdfc0f62e435cb7cf2347f1132858c1f82e 100644 (file)
@@ -32,7 +32,7 @@
 #include "localsession.h"
 #include "plugin.h"
 #include "mainsession.h"
-#include "nestededls.h"
+#include "strack.h"
 #include "trackcanvas.h"
 #include "tracks.h"
 #include "transition.h"
@@ -83,6 +83,8 @@ void Edit::reset()
        user_title[0] = 0;
        nested_edl = 0;
        is_plugin = 0;
+       hard_left = 0;
+       hard_right = 0;
 }
 
 Indexable* Edit::get_source()
@@ -136,6 +138,8 @@ int Edit::copy(int64_t start,
                        file->tag.set_property("STARTSOURCE", startsource_in_selection);
                        file->tag.set_property("CHANNEL", (int64_t)channel);
                        file->tag.set_property("LENGTH", length_in_selection);
+                       file->tag.set_property("HARD_LEFT", hard_left);
+                       file->tag.set_property("HARD_RIGHT", hard_right);
                        if(user_title[0]) file->tag.set_property("USER_TITLE", user_title);
 //printf("Edit::copy 5\n");
 
@@ -150,6 +154,9 @@ int Edit::copy(int64_t start,
                                file->tag.set_title("NESTED_EDL");
                                file->tag.set_property("SRC", nested_edl->path);
                                file->append_tag();
+                               file->tag.set_title("/NESTED_EDL");
+                               file->append_tag();
+                               file->append_newline();
                        }
 
                        if(asset)
@@ -213,10 +220,8 @@ int64_t Edit::get_source_end(int64_t default_)
 void Edit::insert_transition(char *title)
 {
 //printf("Edit::insert_transition this=%p title=%p title=%s\n", this, title, title);
-       detach_transition();
-       transition = new Transition(edl,
-               this,
-               title,
+       delete transition;
+       transition = new Transition(edl, this, title,
                track->to_units(edl->session->default_transition_length, 1));
 }
 
@@ -228,20 +233,21 @@ void Edit::detach_transition()
 
 int Edit::silence()
 {
-       if(asset || nested_edl)
-               return 0;
-       else
-               return 1;
+       return (track->data_type != TRACK_SUBTITLE ?
+               asset || nested_edl :
+               *((SEdit *)this)->get_text()) ? 0 : 1;
 }
 
 
 void Edit::copy_from(Edit *edit)
 {
-       this->nested_edl = edl->nested_edls->get_copy(edit->nested_edl);
+       this->nested_edl = edl->nested_edls.get_nested(edit->nested_edl);
        this->asset = edl->assets->update(edit->asset);
        this->startsource = edit->startsource;
        this->startproject = edit->startproject;
        this->length = edit->length;
+       this->hard_left = edit->hard_left;
+       this->hard_right = edit->hard_right;
        strcpy (this->user_title, edit->user_title);
 
        if(edit->transition)
@@ -284,7 +290,7 @@ void Edit::equivalent_output(Edit *edit, int64_t *result)
                        !transition->identical(edit->transition)) ||
 // Asset changed
                (asset && edit->asset &&
-                       !asset->equivalent(*edit->asset, 1, 1)) ||
+                       !asset->equivalent(*edit->asset, 1, 1, edl)) ||
 // Nested EDL changed
                (nested_edl && edit->nested_edl &&
                        strcmp(nested_edl->path, edit->nested_edl->path))
@@ -317,6 +323,8 @@ int Edit::identical(Edit &edit)
                this->startsource == edit.startsource &&
                this->startproject == edit.startproject &&
                this->length == edit.length &&
+               this->hard_left == edit.hard_left &&
+               this->hard_right == edit.hard_right &&
                this->transition == edit.transition &&
                this->channel == edit.channel);
        return result;
@@ -374,8 +382,8 @@ int Edit::dump(FILE *fp)
                fprintf(fp,"      TRANSITION %p\n", transition);
                transition->dump(fp);
        }
-       fprintf(fp,"      startsource %jd startproject %jd length %jd\n",
-               startsource, startproject, length); fflush(fp);
+       fprintf(fp,"      startsource %jd startproject %jd hard lt/rt %d/%d length %jd\n",
+               startsource, startproject, hard_left, hard_right, length); fflush(fp);
        return 0;
 }
 
@@ -383,6 +391,8 @@ int Edit::load_properties(FileXML *file, int64_t &startproject)
 {
        startsource = file->tag.get_property("STARTSOURCE", (int64_t)0);
        length = file->tag.get_property("LENGTH", (int64_t)0);
+       hard_left = file->tag.get_property("HARD_LEFT", (int64_t)0);
+       hard_right = file->tag.get_property("HARD_RIGHT", (int64_t)0);
        user_title[0] = 0;
        file->tag.get_property("USER_TITLE", user_title);
        this->startproject = startproject;
@@ -692,11 +702,11 @@ int Edit::shift_end_out(int edit_mode,
 
 // Effects are shifted in length extension
                if(edit_plugins)
-                       edits->shift_effects_recursive(oldposition /* startproject */, 
+                       edits->shift_effects_recursive(oldposition /* startproject */,
                                cut_length,
                                edit_autos);
                if(edit_autos)
-                       edits->shift_keyframes_recursive(oldposition /* startproject */, 
+                       edits->shift_keyframes_recursive(oldposition /* startproject */,
                                cut_length);
 
                for(Edit* current_edit = next; current_edit; current_edit = current_edit->next)
@@ -715,13 +725,17 @@ int Edit::shift_end_out(int edit_mode,
                                next->startproject += cut_length;
                                next->startsource += cut_length;
                                next->length -= cut_length;
-//printf("Edit::shift_end_out 2 %d\n", cut_length);
+//printf("Edit::shift_end_out %d cut_length=%d\n", __LINE__, cut_length);
                        }
                        else
                        {
+//printf("Edit::shift_end_out %d cut_length=%d next->length=%d\n", __LINE__, cut_length, next->length);
                                cut_length = next->length;
+                               next->startproject += next->length;
+                               next->startsource += next->length;
                                next->length = 0;
                                length += cut_length;
+//track->dump();
                        }
                }
                else
@@ -800,7 +814,7 @@ int Edit::select_handle(float view_start, float zoom_units, int cursor_x, int cu
        pixel2 = right;
        pixel1 = pixel2 - 10;
 
-// test right edit     
+// test right edit
        if(cursor_x >= pixel1 && cursor_x <= pixel2)
        {
                selection = right_unit;
@@ -809,3 +823,23 @@ int Edit::select_handle(float view_start, float zoom_units, int cursor_x, int cu
        return 0;
 }
 
+void Edit::get_title(char *title)
+{
+       if( user_title[0] ) {
+               strcpy(title, user_title);
+               return;
+       }
+       Indexable *idxbl = asset ? (Indexable*)asset : (Indexable*)nested_edl;
+       if( !idxbl ) {
+               title[0] = 0;
+               return;
+       }
+       FileSystem fs;
+       fs.extract_name(title, idxbl->path);
+       if( asset || track->data_type == TRACK_AUDIO ) {
+               char number[BCSTRLEN];
+               sprintf(number, " #%d", channel + 1);
+               strcat(title, number);
+       }
+}
+