clip fixes, ladspa build fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindowedit.C
index f4df668bf192ac8a55d30ba30cd457fc48cf663a..0c8ad1099c5d19e3c5cce7b741af4d8b8f9290ca 100644 (file)
@@ -34,6 +34,7 @@
 #include "bchash.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "filesystem.h"
 #include "filexml.h"
 #include "floatauto.h"
 #include "floatautos.h"
@@ -121,13 +122,7 @@ void MWindow::add_video_track_entry(Track *dst)
 
        restart_brender();
 
-       gui->update(1,
-               1,
-               0,
-               0,
-               1,
-               0,
-               0);
+       gui->update(1, 1, 0, 0, 1, 0, 0);
        gui->activate_timeline();
 //     gui->get_scrollbars(0);
 //     gui->canvas->draw();
@@ -135,10 +130,8 @@ void MWindow::add_video_track_entry(Track *dst)
 //     gui->cursor->draw(1);
 //     gui->canvas->flash();
 //     gui->canvas->activate();
-       cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                                                       CHANGE_EDL,
-                                                       edl,
-                                                       1);
+       cwindow->playback_engine->que->
+               send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
        save_backup();
 }
 
@@ -149,16 +142,17 @@ void MWindow::add_subttl_track_entry(Track *dst)
        undo->update_undo_after(_("add track"), LOAD_ALL);
 
        restart_brender();
+
+       gui->update(1, 1, 0, 0, 1, 0, 0);
+       gui->activate_timeline();
 //     gui->get_scrollbars(0);
 //     gui->canvas->draw();
 //     gui->patchbay->update();
 //     gui->cursor->draw(1);
 //     gui->canvas->flash();
 //     gui->canvas->activate();
-       cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                                                       CHANGE_EDL,
-                                                       edl,
-                                                       1);
+       cwindow->playback_engine->que->
+               send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
        save_backup();
 }
 
@@ -673,6 +667,7 @@ int MWindow::cut_default_keyframe()
        return 0;
 }
 
+
 void MWindow::delete_inpoint()
 {
        edl->local_session->unset_inpoint();
@@ -685,6 +680,7 @@ void MWindow::delete_outpoint()
        save_backup();
 }
 
+
 void MWindow::delete_track()
 {
        if (edl->tracks->last)
@@ -700,11 +696,10 @@ void MWindow::delete_tracks()
 
        restart_brender();
        update_plugin_states();
+
        gui->update(1, 1, 1, 0, 1, 0, 0);
-       cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                          CHANGE_EDL,
-                          edl,
-                          1);
+       cwindow->playback_engine->que->
+               send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
 }
 
 void MWindow::delete_track(Track *track)
@@ -715,18 +710,14 @@ void MWindow::delete_track(Track *track)
 
        restart_brender();
        update_plugin_states();
+
        gui->update(1, 1, 1, 0, 1, 0, 0);
-       cwindow->playback_engine->que->send_command(CURRENT_FRAME,
-                          CHANGE_EDL,
-                          edl,
-                          1);
+       cwindow->playback_engine->que->
+               send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1);
        save_backup();
 }
 
 
-
-
-
 // Insert data from clipboard
 void MWindow::insert(double position,
        FileXML *file,
@@ -1054,7 +1045,7 @@ void MWindow::move_edits(ArrayList<Edit*> *edits,
 void MWindow::move_effect(Plugin *plugin, Track *track, int64_t position)
 {
        undo->update_undo_before();
-       edl->tracks->move_effect(plugin, track, position); 
+       edl->tracks->move_effect(plugin, track, position);
        save_backup();
        undo->update_undo_after(_("paste effect"), LOAD_ALL);
 
@@ -2358,7 +2349,7 @@ void MWindow::splice(EDL *source)
        sync_parameters(CHANGE_EDL);
 }
 
-void MWindow::to_clip()
+void MWindow::to_clip(EDL *edl, const char *txt)
 {
        FileXML file;
        double start, end;
@@ -2367,36 +2358,57 @@ void MWindow::to_clip()
        start = edl->local_session->get_selectionstart();
        end = edl->local_session->get_selectionend();
 
-       if(EQUIV(end, start))
-       {
+       if(EQUIV(end, start)) {
                start = 0;
                end = edl->tracks->total_length();
        }
 
 // Don't copy all since we don't want the clips twice.
-       edl->copy(start,
-               end,
-               0,
-               0,
-               0,
-               &file,
-               "",
-               1);
-
+       edl->copy(start, end, 0, 0, 0, &file, "", 1);
 
        EDL *new_edl = new EDL(edl);
        new_edl->create_objects();
        new_edl->load_xml(&file, LOAD_ALL);
        sprintf(new_edl->local_session->clip_title, _("Clip %d"), session->clip_number++);
-       char string[BCTEXTLEN];
-       Units::totext(string,
-                       end - start,
+       char duration[BCTEXTLEN];
+       Units::totext(duration, end - start,
                        edl->session->time_format,
                        edl->session->sample_rate,
                        edl->session->frame_rate,
                        edl->session->frames_per_foot);
 
-       sprintf(new_edl->local_session->clip_notes, _("%s\nCreated from main window"), string);
+       const char *path = edl->path;
+       Track *track=edl->tracks->first;
+       for(; (!path || !*path) && track; track=track->next ) {
+               if( !track->record ) continue;
+               Edit *edit = track->edits->editof(start, PLAY_FORWARD, 0);
+               if( !edit ) continue;
+               Indexable *indexable = edit->get_source();
+               if( !indexable ) continue;
+               path = indexable->path;
+       }
+
+        time_t now;  time(&now);
+        struct tm *tm = localtime(&now);
+       char *cp = new_edl->local_session->clip_notes;
+       int n, sz = sizeof(new_edl->local_session->clip_notes)-1;
+       if( txt && *txt ) {
+               n = snprintf(cp, sz, "%s", txt);
+               cp += n;  sz -= n;
+       }
+       n = snprintf(cp, sz, 
+               "%02d/%02d/%02d %02d:%02d:%02d,  +%s\n",
+               tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, 
+               tm->tm_hour, tm->tm_min, tm->tm_sec, duration);
+       cp += n;  sz -= n;
+       if( path && *path ) {
+               FileSystem fs;
+               char title[BCTEXTLEN];
+               fs.extract_name(title, path);
+               n = snprintf(cp, sz, "%s", title);
+               cp += n;  sz -= n;
+       }
+       cp[n] = 0;
 
        new_edl->local_session->set_selectionstart(0);
        new_edl->local_session->set_selectionend(0);
@@ -2409,6 +2421,10 @@ void MWindow::to_clip()
        save_backup();
        gui->unlock_window();
 }
+void MWindow::to_clip(const char *txt)
+{
+       to_clip(edl, txt);
+}
 
 int MWindow::toggle_label(int is_mwindow)
 {
@@ -2456,6 +2472,8 @@ int MWindow::toggle_label(int is_mwindow)
                cwindow->gui->unlock_window();
        }
 
+       awindow->gui->async_update_assets();
+
        undo->update_undo_after(_("label"), LOAD_TIMEBAR);
        return 0;
 }