load fn from resources, del kfrm speed update, svg exec cmd/file win fixes, undo...
authorGood Guy <good1.2guy@gmail.com>
Thu, 29 Mar 2018 02:26:16 +0000 (20:26 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 29 Mar 2018 02:26:16 +0000 (20:26 -0600)
cinelerra-5.1/cinelerra/assetpopup.C
cinelerra-5.1/cinelerra/assetpopup.h
cinelerra-5.1/cinelerra/assetpopup.inc
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/keyframepopup.C
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/plugins/svg/svg.C
cinelerra-5.1/plugins/svg/svgwin.C
cinelerra-5.1/plugins/svg/svgwin.h

index 15620af7a34c35f0f5d4950a445fe0dc5fbec782..026806a1c9eb3e6bddf15acdbc020e5da5246b93 100644 (file)
 #include "file.h"
 #include "filexml.h"
 #include "language.h"
+#include "loadfile.h"
 #include "localsession.h"
 #include "mainerror.h"
 #include "mainindexes.h"
+#include "mainmenu.h"
 #include "mainsession.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
@@ -420,6 +422,7 @@ AssetListMenu::~AssetListMenu()
 
 void AssetListMenu::create_objects()
 {
+       add_item(load_file = new AssetPopupLoadFile(mwindow, gui));
        add_item(format = new AWindowListFormat(mwindow, gui));
        add_item(new AWindowListSort(mwindow, gui));
        add_item(new AssetListCopy(mwindow, gui));
@@ -441,6 +444,23 @@ void AssetListMenu::create_objects()
        update_titles(shots_displayed = 1);
 }
 
+AssetPopupLoadFile::AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui)
+ : BC_MenuItem(_("Load files..."), "o", 'o')
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+}
+
+AssetPopupLoadFile::~AssetPopupLoadFile()
+{
+}
+
+int AssetPopupLoadFile::handle_event()
+{
+       mwindow->gui->mainmenu->load_file->thread->start();
+       return 1;
+}
+
 void AssetListMenu::update_titles(int shots)
 {
        format->update();
index 774d84259e2bf689617a6fc83c64841e6ae32ce6..0720d9d2b57d5143e546ed00121cbf5312fbaef1 100644 (file)
@@ -225,12 +225,25 @@ public:
 
        MWindow *mwindow;
        AWindowGUI *gui;
+       AssetPopupLoadFile *load_file;
        AWindowListFormat *format;
        AssetSnapshot *asset_snapshot;
        AssetGrabshot *asset_grabshot;
        int shots_displayed;
 };
 
+class AssetPopupLoadFile : public BC_MenuItem
+{
+public:
+       AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui);
+       ~AssetPopupLoadFile();
+
+       int handle_event();
+
+       MWindow *mwindow;
+       AWindowGUI *gui;
+};
+
 class AssetListCopy : public BC_MenuItem
 {
 public:
index a4e77eb17ee776529cbb16b10a3542c63ca50e22..ba60f99c3e0f9bbf1c78410e125690ef73448bec 100644 (file)
@@ -38,6 +38,7 @@ class AssetPopupSort;
 class AssetPopupBuildIndex;
 class AssetPopupView;
 class AssetPopupViewWindow;
+class AssetPopupLoadFile;
 class AssetPopupMixer;
 class AssetPopupPaste;
 class AssetMatchSize;
index 42672233ec775b5fe10e0273db3573e232c62f94..f49c67fb5da709cb365c436d876b68ce54f6b27a 100644 (file)
@@ -1308,6 +1308,12 @@ int AWindowGUI::keypress_event()
                        return 1;
                }
                break;
+       case 'o':
+               if( !ctrl_down() && !shift_down() ) {
+                       assetlist_menu->load_file->handle_event();
+                       return 1;
+               }
+               break;
        case DELETE:
                if( shift_down() ) {
                        PluginServer* plugin = selected_plugin();
index 3813e744d49c997a9498c0ff48bf341b80362277..cef8b2701a62e2aaeaba0f724d493f3426242d65 100644 (file)
@@ -187,7 +187,9 @@ KeyframePopupDelete::~KeyframePopupDelete()
 int KeyframePopupDelete::handle_event()
 {
        mwindow->undo->update_undo_before(_("delete keyframe"), 0);
+       mwindow->speed_before();
        delete popup->keyframe_auto;
+       mwindow->speed_after(1);
        mwindow->undo->update_undo_after(_("delete keyframe"), LOAD_ALL);
 
        mwindow->save_backup();
index d69496dc7e9d99533bcbf83c982248ec17e698f1..065c1f9f08d475fe994aec06fb3a1f39de87cd04 100644 (file)
@@ -354,7 +354,9 @@ void MWindow::set_automation_mode(int mode)
        save_backup();
        char string[BCSTRLEN];
        sprintf(string,"set %s", FloatAuto::curve_name(mode));
-       undo->update_undo_after(string, LOAD_AUTOMATION);
+       undo->update_undo_after(string,
+               !changed_edl ? LOAD_AUTOMATION :
+                       LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
        update_gui(changed_edl);
 }
 
@@ -366,7 +368,9 @@ void MWindow::clear_automation()
                edl->local_session->get_selectionend());
        int changed_edl = speed_after(1);
        save_backup();
-       undo->update_undo_after(_("clear keyframes"), LOAD_AUTOMATION);
+       undo->update_undo_after(_("clear keyframes"),
+               !changed_edl ? LOAD_AUTOMATION :
+                       LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
        update_gui(changed_edl);
 }
 
@@ -377,7 +381,9 @@ int MWindow::clear_default_keyframe()
        edl->tracks->clear_default_keyframe();
        int changed_edl = speed_after(1);
        save_backup();
-       undo->update_undo_after(_("clear default keyframe"), LOAD_AUTOMATION);
+       undo->update_undo_after(_("clear default keyframe"),
+               !changed_edl ? LOAD_AUTOMATION :
+                       LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
        update_gui(changed_edl);
        return 0;
 }
@@ -604,7 +610,9 @@ int MWindow::cut_automation()
                edl->local_session->get_selectionend());
        int changed_edl = speed_after(1);
        save_backup();
-       undo->update_undo_after(_("cut keyframes"), LOAD_AUTOMATION);
+       undo->update_undo_after(_("cut keyframes"),
+               !changed_edl ? LOAD_AUTOMATION :
+                       LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
        update_gui(changed_edl);
        return 0;
 }
@@ -618,7 +626,9 @@ int MWindow::cut_default_keyframe()
        edl->tracks->clear_default_keyframe();
        int changed_edl = speed_after(1);
        save_backup();
-       undo->update_undo_after(_("cut default keyframe"), LOAD_AUTOMATION);
+       undo->update_undo_after(_("cut default keyframe"),
+               !changed_edl ? LOAD_AUTOMATION :
+                       LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
        update_gui(changed_edl);
        return 0;
 }
@@ -1241,7 +1251,7 @@ int MWindow::paste_automation()
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
                file.read_from_string(string);
-
+               delete [] string;
                double start = edl->local_session->get_selectionstart();
                double end = edl->local_session->get_selectionend();
                edl->tracks->clear_automation(start, end);
@@ -1249,8 +1259,9 @@ int MWindow::paste_automation()
                        edl->session->typeless_keyframes);
                int changed_edl = speed_after(1);
                save_backup();
-               undo->update_undo_after(_("paste keyframes"), LOAD_AUTOMATION);
-               delete [] string;
+               undo->update_undo_after(_("paste keyframes"),
+                       !changed_edl ? LOAD_AUTOMATION :
+                               LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
                update_gui(changed_edl);
        }
 
@@ -1268,14 +1279,16 @@ int MWindow::paste_default_keyframe()
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
                file.read_from_string(string);
+               delete [] string;
                double start = edl->local_session->get_selectionstart();
                edl->tracks->paste_automation(start, &file, 1, 0,
                        edl->session->typeless_keyframes);
 //             edl->tracks->paste_default_keyframe(&file);
-               undo->update_undo_after(_("paste default keyframe"), LOAD_AUTOMATION);
                int changed_edl = speed_after(1);
+               undo->update_undo_after(_("paste default keyframe"),
+                       !changed_edl ? LOAD_AUTOMATION :
+                               LOAD_AUTOMATION + LOAD_EDITS + LOAD_TIMEBAR);
                save_backup();
-               delete [] string;
                update_gui(changed_edl);
        }
 
@@ -1785,7 +1798,7 @@ void MWindow::align_edits()
 
 void MWindow::set_edit_length(double length)
 {
-       gui->lock_window("MWindow::detach_transitions 1");
+       gui->lock_window("MWindow::set_edit_length 1");
 
        undo->update_undo_before();
        double start = edl->local_session->get_selectionstart();
@@ -1805,7 +1818,7 @@ void MWindow::set_edit_length(double length)
 
 void MWindow::set_transition_length(Transition *transition, double length)
 {
-       gui->lock_window("MWindow::detach_transitions 1");
+       gui->lock_window("MWindow::set_transition_length 1");
 
        undo->update_undo_before();
        //double start = edl->local_session->get_selectionstart();
@@ -1824,7 +1837,7 @@ void MWindow::set_transition_length(Transition *transition, double length)
 
 void MWindow::set_transition_length(double length)
 {
-       gui->lock_window("MWindow::detach_transitions 1");
+       gui->lock_window("MWindow::set_transition_length 2");
 
        undo->update_undo_before();
        double start = edl->local_session->get_selectionstart();
@@ -2042,9 +2055,9 @@ void MWindow::save_clip(EDL *new_edl, const char *txt)
                n = snprintf(cp, sz, "%s", txt);
                cp += n;  sz -= n;
        }
-       n = snprintf(cp, sz, 
+       n = snprintf(cp, sz,
                "%02d/%02d/%02d %02d:%02d:%02d,  +%s\n",
-               dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, 
+               dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
                dtm.tm_hour, dtm.tm_min, dtm.tm_sec, duration);
        cp += n;  sz -= n;
        if( path && *path ) {
index 89499d15c7bb9c4d5ae5c6308ba29f8248467125..96288bae32d81c209e7d4ac5667ee5a83482e8ea 100644 (file)
@@ -21,6 +21,7 @@
 #include "clip.h"
 #include "filexml.h"
 #include "language.h"
+#include "mainerror.h"
 #include "svg.h"
 #include "svgwin.h"
 #include "overlayframe.inc"
@@ -32,6 +33,8 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 
 REGISTER_PLUGIN(SvgMain)
@@ -53,6 +56,7 @@ int SvgConfig::equivalent(SvgConfig &that)
                EQUIV(out_w, that.out_w) &&
                EQUIV(out_h, that.out_h) &&
                !strcmp(svg_file, that.svg_file) &&
+               ms_time != 0 && that.ms_time != 0 &&
                ms_time == that.ms_time;
 }
 
@@ -147,6 +151,24 @@ void SvgMain::read_data(KeyFrame *keyframe)
        }
 }
 
+static int exec_command(char* const*argv)
+{
+        pid_t pid = vfork();
+        if( pid < 0 ) return -1;
+        if( pid > 0 ) {
+                int stat = 0;
+               waitpid(pid, &stat, 0);
+                if( stat ) {
+                        char msg[BCTEXTLEN];
+                        sprintf(msg, "%s: error exit status %d", argv[0], stat);
+                        MainError::show_error(msg);
+                }
+                return 0;
+       }
+        execvp(argv[0], &argv[0]);
+        return -1;
+}
+
 
 int SvgMain::process_realtime(VFrame *input, VFrame *output)
 {
@@ -158,7 +180,7 @@ int SvgMain::process_realtime(VFrame *input, VFrame *output)
        char last_svg_file[BCTEXTLEN];
        strcpy(last_svg_file, config.svg_file);
        int64_t last_ms_time = config.ms_time;
-       load_configuration();
+       need_reconfigure = load_configuration();
        if( last_dpi != config.dpi )
                need_export = 1;
        if( strcmp(last_svg_file, config.svg_file) ||
@@ -177,13 +199,22 @@ int SvgMain::process_realtime(VFrame *input, VFrame *output)
                        st_png.st_mtim.tv_sec*1000 + st_png.st_mtim.tv_nsec/1000000;
                int fd = ms_time < config.ms_time ? -1 : open(filename_png, O_RDWR);
                if( fd < 0 ) { // file does not exist, export it
-                       char command[BCTEXTLEN];
+                       char command[BCTEXTLEN], dpi[BCSTRLEN];
                        snprintf(command, sizeof(command),
                                "inkscape --without-gui --export-background=0x000000 "
                                "--export-background-opacity=0 -d %f %s --export-png=%s",
                                config.dpi, config.svg_file, filename_png);
                        printf(_("Running command %s\n"), command);
-                       system(command);
+                       snprintf(dpi, sizeof(dpi), "%f", config.dpi);
+                       snprintf(command, sizeof(command), "--export-png=%s",filename_png);
+                       char *const argv[] = {
+                               (char*)"inkscape",
+                               (char*)"--without-gui",
+                               (char*)"--export-background=0x000000",
+                                (char*)"--export-background-opacity=0",
+                               (char*)"-d", dpi, config.svg_file, command,
+                               0, };
+                       exec_command(argv);
                        // in order for lockf to work it has to be open for writing
                        fd = open(filename_png, O_RDWR);
                        if( fd < 0 )
index 9931a8ddc218c5fa3f86f05b3a6d0401ce9c1b04..d4011954ec7413df74d2d8fbd67d2f96b9077eb5 100644 (file)
@@ -22,6 +22,7 @@
 #include "svgwin.h"
 #include "filexml.h"
 #include "language.h"
+#include "mainerror.h"
 
 #include <string.h>
 #include <unistd.h>
@@ -29,6 +30,9 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
 #include <errno.h>
 
 #include "empty_svg.h"
@@ -105,6 +109,7 @@ void SvgWin::create_objects()
 
 int SvgWin::close_event()
 {
+       new_svg_button->stop();
        edit_svg_button->stop();
        set_done(1);
        return 1;
@@ -112,6 +117,7 @@ int SvgWin::close_event()
 
 int SvgWin::hide_window(int flush)
 {
+       new_svg_button->stop();
        edit_svg_button->stop();
        return BC_WindowBase::hide_window(flush);
 }
@@ -160,8 +166,14 @@ NewSvgButton::NewSvgButton(SvgMain *client, SvgWin *window, int x, int y)
 {
        this->client = client;
        this->window = window;
+       new_window = 0;
+}
+NewSvgButton::~NewSvgButton()
+{
+       stop();
 }
 
+
 int NewSvgButton::handle_event()
 {
        window->editing_lock.lock();
@@ -196,13 +208,13 @@ void NewSvgButton::run()
                        char *cp = getenv("HOME");
                        if( cp ) strncpy(directory, cp, sizeof(directory));
                }
-               NewSvgWindow *new_window = new NewSvgWindow(client, window, directory);
+               new_window = new NewSvgWindow(client, window, directory);
                new_window->create_objects();
                new_window->update_filter("*.svg");
                result = new_window->run_window();
                const char *filepath = new_window->get_path(0);
                strcpy(filename, filepath);
-               delete new_window;
+               delete new_window;  new_window = 0;
                if( result || !filepath || !*filepath ) {
                        window->editing_lock.lock();
                        window->editing = 0;
@@ -230,9 +242,7 @@ void NewSvgButton::run()
        } while(result);        // file doesn't exist so repeat
 
        strcpy(client->config.svg_file, filename);
-       struct stat st;
-       client->config.ms_time = stat(filename, &st) ? 0 :
-               st.st_mtim.tv_sec*1000 + st.st_mtim.tv_nsec/1000000;
+       client->config.ms_time = 0;
        window->update_gui(client->config);
        client->send_configure_change();
 
@@ -243,6 +253,14 @@ void NewSvgButton::run()
        return;
 }
 
+void NewSvgButton::stop()
+{
+       if( new_window ) {
+               new_window->set_done(1);
+       }
+       join();
+}
+
 EditSvgButton::EditSvgButton(SvgMain *client, SvgWin *window, int x, int y)
  : BC_GenericButton(x, y, _("Edit")), Thread(1)
 {
@@ -354,6 +372,24 @@ SvgInkscapeThread::~SvgInkscapeThread()
        join();
 }
 
+static int exec_command(char* const*argv)
+{
+        pid_t pid = vfork();
+        if( pid < 0 ) return -1;
+        if( pid > 0 ) {
+                int stat = 0;
+               waitpid(pid, &stat, 0);
+                if( stat ) {
+                        char msg[BCTEXTLEN];
+                        sprintf(msg, "%s: error exit status %d", argv[0], stat);
+                        MainError::show_error(msg);
+                }
+                return 0;
+       }
+        execvp(argv[0], &argv[0]);
+        return -1;
+}
+
 void SvgInkscapeThread::run()
 {
 // Runs the inkscape
@@ -361,9 +397,15 @@ void SvgInkscapeThread::run()
        snprintf(command, sizeof(command),
                "inkscape --with-gui %s", edit->client->config.svg_file);
        printf(_("Running external SVG editor: %s\n"), command);
+       char *const argv[] = {
+               (char*) "incscape",
+               (char*)"--with-gui",
+               edit->client->config.svg_file,
+               0,
+       };
 
        enable_cancel();
-       system(command);
+       exec_command(argv);
        printf(_("External SVG editor finished\n"));
        struct fifo_struct fifo_buf;
        fifo_buf.pid = getpid();
@@ -375,7 +417,6 @@ void SvgInkscapeThread::run()
 }
 
 
-
 NewSvgWindow::NewSvgWindow(SvgMain *client, SvgWin *window, char *init_directory)
  : BC_FileBox(0,
        BC_WindowBase::get_resources()->filebox_h / 2,
index 1e91af4ce1e020c92c9b58257438c66c22d9d5f0..136a3ef78527f31af11565e0737c7c3489febba0 100644 (file)
@@ -82,11 +82,14 @@ class NewSvgButton : public BC_GenericButton, public Thread
 {
 public:
        NewSvgButton(SvgMain *client, SvgWin *window, int x, int y);
+       ~NewSvgButton();
        int handle_event();
        void run();
+       void stop();
 
        SvgMain *client;
        SvgWin *window;
+       NewSvgWindow *new_window;
 };
 
 class EditSvgButton : public BC_GenericButton, public Thread