From: Good Guy Date: Thu, 29 Mar 2018 02:26:16 +0000 (-0600) Subject: load fn from resources, del kfrm speed update, svg exec cmd/file win fixes, undo... X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=bd0694fcee6080ec61e243ac6f278be5a48d564b;p=goodguy%2Fhistory.git load fn from resources, del kfrm speed update, svg exec cmd/file win fixes, undo tweaks --- diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index 15620af7..026806a1 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -39,9 +39,11 @@ #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(); diff --git a/cinelerra-5.1/cinelerra/assetpopup.h b/cinelerra-5.1/cinelerra/assetpopup.h index 774d8425..0720d9d2 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.h +++ b/cinelerra-5.1/cinelerra/assetpopup.h @@ -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: diff --git a/cinelerra-5.1/cinelerra/assetpopup.inc b/cinelerra-5.1/cinelerra/assetpopup.inc index a4e77eb1..ba60f99c 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.inc +++ b/cinelerra-5.1/cinelerra/assetpopup.inc @@ -38,6 +38,7 @@ class AssetPopupSort; class AssetPopupBuildIndex; class AssetPopupView; class AssetPopupViewWindow; +class AssetPopupLoadFile; class AssetPopupMixer; class AssetPopupPaste; class AssetMatchSize; diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 42672233..f49c67fb 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -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(); diff --git a/cinelerra-5.1/cinelerra/keyframepopup.C b/cinelerra-5.1/cinelerra/keyframepopup.C index 3813e744..cef8b270 100644 --- a/cinelerra-5.1/cinelerra/keyframepopup.C +++ b/cinelerra-5.1/cinelerra/keyframepopup.C @@ -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(); diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index d69496dc..065c1f9f 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -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 ) { diff --git a/cinelerra-5.1/plugins/svg/svg.C b/cinelerra-5.1/plugins/svg/svg.C index 89499d15..96288bae 100644 --- a/cinelerra-5.1/plugins/svg/svg.C +++ b/cinelerra-5.1/plugins/svg/svg.C @@ -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 #include #include +#include +#include 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 ) diff --git a/cinelerra-5.1/plugins/svg/svgwin.C b/cinelerra-5.1/plugins/svg/svgwin.C index 9931a8dd..d4011954 100644 --- a/cinelerra-5.1/plugins/svg/svgwin.C +++ b/cinelerra-5.1/plugins/svg/svgwin.C @@ -22,6 +22,7 @@ #include "svgwin.h" #include "filexml.h" #include "language.h" +#include "mainerror.h" #include #include @@ -29,6 +30,9 @@ #include #include #include +#include +#include + #include #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, diff --git a/cinelerra-5.1/plugins/svg/svgwin.h b/cinelerra-5.1/plugins/svg/svgwin.h index 1e91af4c..136a3ef7 100644 --- a/cinelerra-5.1/plugins/svg/svgwin.h +++ b/cinelerra-5.1/plugins/svg/svgwin.h @@ -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