From f7444a58936e4ab8fa7e7062281567cbc74e175f Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 30 May 2019 17:00:41 -0600 Subject: [PATCH] add mask color radio btn sel, fix del all mask btn, fix mask dflt kfrm draw name, mod shell cmd add cmd.sh+args, add render_mux.log --- cinelerra-5.1/cinelerra/autos.C | 14 ++---- cinelerra-5.1/cinelerra/autos.h | 2 +- cinelerra-5.1/cinelerra/cwindowgui.C | 3 +- cinelerra-5.1/cinelerra/cwindowtool.C | 34 +++++++------ cinelerra-5.1/cinelerra/cwindowtool.h | 1 + cinelerra-5.1/cinelerra/preferences.C | 14 ++++-- cinelerra-5.1/cinelerra/shbtnprefs.C | 69 ++++++++++++++++++++++++--- cinelerra-5.1/cinelerra/shbtnprefs.h | 22 +++++++-- cinelerra-5.1/doc/RenderMux.sh | 2 + 9 files changed, 120 insertions(+), 41 deletions(-) diff --git a/cinelerra-5.1/cinelerra/autos.C b/cinelerra-5.1/cinelerra/autos.C index cb5a1bd2..73e89a91 100644 --- a/cinelerra-5.1/cinelerra/autos.C +++ b/cinelerra-5.1/cinelerra/autos.C @@ -397,17 +397,11 @@ Auto* Autos::insert_auto(int64_t position, Auto *templ) return result; } -int Autos::clear_all() +void Autos::clear_all() { - Auto *current_, *current; - - for(current = first; current; current = current_) - { - current_ = NEXT; - remove(current); - } - append_auto(); - return 0; + while( last ) delete last; + delete default_auto; + create_objects(); } int Autos::insert(int64_t start, int64_t end) diff --git a/cinelerra-5.1/cinelerra/autos.h b/cinelerra-5.1/cinelerra/autos.h index 2e841bfd..ee53f63a 100644 --- a/cinelerra-5.1/cinelerra/autos.h +++ b/cinelerra-5.1/cinelerra/autos.h @@ -116,7 +116,7 @@ public: - int clear_all(); + void clear_all(); int insert(int64_t start, int64_t end); int paste_silence(int64_t start, int64_t end); // Copy for keyframe clipboard & drag & drop diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 58b1cbb3..0ee1d675 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -1749,8 +1749,7 @@ int CWindowCanvas::do_mask(int &redraw, int &rerender, if( draw_boundary ) { char mask_label[BCSTRLEN]; int k = mwindow->edl->session->cwindow_mask; - if( !prev_mask || prev_mask->is_default || - k < 0 || k >= prev_mask->masks.size() ) + if( !prev_mask || k < 0 || k >= prev_mask->masks.size() ) sprintf(mask_label, "%d", k); else sprintf(mask_label, "%s", prev_mask->masks[k]->name); diff --git a/cinelerra-5.1/cinelerra/cwindowtool.C b/cinelerra-5.1/cinelerra/cwindowtool.C index c38daafb..2ef53fa9 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.C +++ b/cinelerra-5.1/cinelerra/cwindowtool.C @@ -1527,9 +1527,6 @@ int CWindowMaskName::handle_event() (MaskAuto*)autos->first : (MaskAuto*)NEXT; } #endif - int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]); - for( int i=0; imask_buttons[i]->update(i==k ? 1 : 0); gui->update(); gui->update_preview(); } @@ -1565,10 +1562,8 @@ CWindowMaskButton::~CWindowMaskButton() int CWindowMaskButton::handle_event() { mwindow->edl->session->cwindow_mask = no; - int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]); - for( int i=0; imask_buttons[i]->update(i==no ? 1 : 0); gui->name->update(gui->name->mask_items[no]->get_text()); + gui->update(); gui->update_preview(); return 1; } @@ -1601,10 +1596,8 @@ int CWindowMaskThumbler::do_event(int dir) if( (k+=dir) >= SUBMASKS ) k = 0; else if( k < 0 ) k = SUBMASKS-1; mwindow->edl->session->cwindow_mask = k; - int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]); - for( int i=0; imask_buttons[i]->update(i==k ? 1 : 0); gui->name->update(gui->name->mask_items[k]->get_text()); + gui->update(); gui->update_preview(); return 1; } @@ -2406,6 +2399,7 @@ void CWindowMaskGUI::update() if(mask) { int k = mwindow->edl->session->cwindow_mask; + update_buttons(keyframe, k); feather->update(autos->get_feather(position_i, k, PLAY_FORWARD)); fade->update(autos->get_fader(position_i, k, PLAY_FORWARD)); apply_before_plugins->update(keyframe->apply_before_plugins); @@ -2483,12 +2477,24 @@ void CWindowMaskGUI::set_focused(int v, float cx, float cy) focus->update(focused = v); } +void CWindowMaskGUI::update_buttons(MaskAuto *keyframe, int k) +{ + int text_color = get_resources()->default_text_color; + int high_color = get_resources()->button_highlighted; + for( int i=0; iget_submask(i); + if( submask && submask->points.size() ) + color = high_color; + } + mask_blabels[i]->set_color(color); + mask_buttons[i]->update(i==k ? 1 : 0); + } +} + CWindowRulerGUI::CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread) - : CWindowToolGUI(mwindow, - thread, - _(PROGRAM_NAME ": Ruler"), - 320, - 240) + : CWindowToolGUI(mwindow, thread, _(PROGRAM_NAME ": Ruler"), 320, 240) { } diff --git a/cinelerra-5.1/cinelerra/cwindowtool.h b/cinelerra-5.1/cinelerra/cwindowtool.h index db0b32b7..e6922e4b 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.h +++ b/cinelerra-5.1/cinelerra/cwindowtool.h @@ -359,6 +359,7 @@ public: void create_objects(); void update(); void set_focused(int v, float cx, float cy); + void update_buttons(MaskAuto *keyframe, int k); void handle_event(); void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe, SubMask* &mask, MaskPoint* &point, int create_it); diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index f4ccda6a..8ead6cdc 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -405,10 +405,10 @@ int Preferences::load_defaults(BC_Hash *defaults) shbtn_prefs.remove_all_objects(); int shbtns_total = defaults->get("SHBTNS_TOTAL", -1); if( shbtns_total < 0 ) { - shbtn_prefs.append(new ShBtnPref(_("Current Manual"), "$CIN_BROWSER https://cinelerra-gg.org/download/CinelerraGG_manual.pdf", 0)); - shbtn_prefs.append(new ShBtnPref(_("Setting Shell Commands"), "$CIN_BROWSER file://$CIN_DAT/doc/ShellCmds.html", 0)); - shbtn_prefs.append(new ShBtnPref(_("Shortcuts"), "$CIN_BROWSER file://$CIN_DAT/doc/shortcuts.html", 0)); - shbtn_prefs.append(new ShBtnPref(_("RenderMux"), "$CIN_DAT/doc/RenderMux.sh",0)); + shbtn_prefs.append(new ShBtnPref(_("Current Manual"), "$CIN_BROWSER https://cinelerra-gg.org/download/CinelerraGG_manual.pdf")); + shbtn_prefs.append(new ShBtnPref(_("Setting Shell Commands"), "$CIN_BROWSER file://$CIN_DAT/doc/ShellCmds.html")); + shbtn_prefs.append(new ShBtnPref(_("Shortcuts"), "$CIN_BROWSER file://$CIN_DAT/doc/shortcuts.html")); + shbtn_prefs.append(new ShBtnPref(_("RenderMux"), "$CIN_DAT/doc/RenderMux.sh")); shbtns_total = 0; } for( int i=0; iget(string, commands); sprintf(string, "SHBTN%d_WARN", i); int warn = defaults->get(string, 0); - shbtn_prefs.append(new ShBtnPref(name, commands, warn)); + sprintf(string, "SHBTN%d_RUN_SCRIPT", i); + int run_script = defaults->get(string, 0); + shbtn_prefs.append(new ShBtnPref(name, commands, warn, run_script)); } file_probes.remove_all_objects(); @@ -536,6 +538,8 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update(string, pref->commands); sprintf(string, "SHBTN%d_WARN", i); defaults->update(string, pref->warn); + sprintf(string, "SHBTN%d_RUN_SCRIPT", i); + defaults->update(string, pref->run_script); } defaults->update("FILE_PROBE_TOTAL", file_probes.size()); for( int i=0; iwarn = warn; - start(); +} +ShBtnRun::~ShBtnRun() +{ + argv.remove_all_objects(); +} + +void ShBtnRun::add_arg(const char *v) +{ + argv.append(cstrdup(v)); } void ShBtnRun::run() @@ -38,24 +52,44 @@ void ShBtnRun::run() } return; } - char *const argv[4] = { (char*) "/bin/bash", (char*) "-c", commands, 0 }; + argv.append(0); execvp(argv[0], &argv[0]); } -ShBtnPref::ShBtnPref(const char *nm, const char *cmds, int warn) +ShBtnPref::ShBtnPref(const char *nm, const char *cmds, int warn, int run_script) { strncpy(name, nm, sizeof(name)); strncpy(commands, cmds, sizeof(commands)); this->warn = warn; + this->run_script = run_script; } ShBtnPref::~ShBtnPref() { } +void ShBtnPref::execute(ArrayList &args) +{ +// thread async+autodelete, no explicit delete + ShBtnRun *job = new ShBtnRun(name, commands, warn); + job->add_arg("/bin/bash"); + job->add_arg(commands); + int n = args.size(); + for( int i=0; iis_asset ) continue; + job->add_arg(idxbl->path); + } + job->start(); +} + void ShBtnPref::execute() { - new ShBtnRun(name, commands, warn); + ShBtnRun *job = new ShBtnRun(name, commands, warn); + job->add_arg("/bin/bash"); + job->add_arg("-c"); + job->add_arg(commands); + job->start(); } ShBtnEditDialog::ShBtnEditDialog(PreferencesWindow *pwindow) @@ -122,7 +156,7 @@ int ShBtnAddButton::handle_event() { Preferences *preferences = sb_window->shbtn_edit->pwindow->thread->preferences; - ShBtnPref *pref = new ShBtnPref(_("new"), "", 0); + ShBtnPref *pref = new ShBtnPref(_("new"), "", 0, 0); preferences->shbtn_prefs.append(pref); sb_window->list_update(); return sb_window->start_edit(pref); @@ -182,6 +216,7 @@ ShBtnTextWindow::ShBtnTextWindow(ShBtnEditWindow *sb_window, int x, int y) { this->sb_window = sb_window; warn = sb_window->sb_dialog->pref->warn; + run_script = sb_window->sb_dialog->pref->run_script; } ShBtnTextWindow::~ShBtnTextWindow() @@ -198,6 +233,16 @@ ShBtnErrWarn::~ShBtnErrWarn() { } +ShBtnRunScript::ShBtnRunScript(ShBtnTextWindow *st_window, int x, int y) + : BC_CheckBox(x, y, &st_window->run_script, _("run /path/script.sh + argvs")) +{ + this->st_window = st_window; +} + +ShBtnRunScript::~ShBtnRunScript() +{ +} + void ShBtnTextWindow::create_objects() { lock_window("ShBtnTextWindow::create_objects"); @@ -215,6 +260,8 @@ void ShBtnTextWindow::create_objects() cmd_text->create_objects(); y += cmd_text->get_h() + 16; add_subwindow(st_err_warn = new ShBtnErrWarn(this, x1, y)); + x1 += st_err_warn->get_w() + 20; + add_subwindow(st_run_script = new ShBtnRunScript(this, x1, y)); y = get_h() - ShBtnTextOK::calculate_h() - 10; add_subwindow(new ShBtnTextOK(this, x, y)); show_window(); @@ -237,6 +284,7 @@ int ShBtnTextOK::handle_event() strcpy(pref->name, st_window->cmd_name->get_text()); strcpy(pref->commands, st_window->cmd_text->get_text()); pref->warn = st_window->warn; + pref->run_script = st_window->run_script; return BC_OKButton::handle_event(); } @@ -331,7 +379,16 @@ MainShBtnItem::MainShBtnItem(MainShBtns *shbtns, ShBtnPref *pref) int MainShBtnItem::handle_event() { - pref->execute(); + MWindow *mwindow = shbtns->mwindow; + if( pref->run_script ) { + AWindowGUI *agui = mwindow->awindow->gui; + agui->lock_window("MainShBtnItem::handle_event"); + mwindow->awindow->gui->collect_assets(); + pref->execute(*mwindow->session->drag_assets); + agui->unlock_window(); + } + else + pref->execute(); return 1; } diff --git a/cinelerra-5.1/cinelerra/shbtnprefs.h b/cinelerra-5.1/cinelerra/shbtnprefs.h index 3005d78c..36022205 100644 --- a/cinelerra-5.1/cinelerra/shbtnprefs.h +++ b/cinelerra-5.1/cinelerra/shbtnprefs.h @@ -1,6 +1,7 @@ #ifndef __SHBTNPREFS_H__ #define __SHBTNPREFS_H__ +#include "arraylist.h" #include "bcwindowbase.h" #include "bcbutton.h" #include "bcdialog.h" @@ -18,8 +19,11 @@ public: int warn; char name[BCSTRLEN]; char commands[BCTEXTLEN]; + ArrayList argv; + void add_arg(const char *v); - ShBtnRun(const char *name, const char *cmds, int warn=0); + ShBtnRun(const char *name, const char *cmds, int warn); + ~ShBtnRun(); void run(); }; @@ -28,10 +32,11 @@ class ShBtnPref public: char name[BCSTRLEN]; char commands[BCTEXTLEN]; - int warn; + int warn, run_script; void execute(); + void execute(ArrayList &args); - ShBtnPref(const char *nm, const char *cmds, int warn); + ShBtnPref(const char *nm, const char *cmds, int warn=0, int run_script=0); ~ShBtnPref(); }; @@ -111,6 +116,15 @@ public: ShBtnTextWindow *st_window; }; +class ShBtnRunScript : public BC_CheckBox +{ +public: + ShBtnRunScript(ShBtnTextWindow *st_window, int x, int y); + ~ShBtnRunScript(); + + ShBtnTextWindow *st_window; +}; + class ShBtnTextWindow : public BC_Window { public: @@ -118,7 +132,9 @@ public: BC_ScrollTextBox *cmd_text; ShBtnEditWindow *sb_window; ShBtnErrWarn *st_err_warn; + ShBtnRunScript *st_run_script; int warn; + int run_script; void create_objects(); diff --git a/cinelerra-5.1/doc/RenderMux.sh b/cinelerra-5.1/doc/RenderMux.sh index d109bd63..ee5e6b85 100755 --- a/cinelerra-5.1/doc/RenderMux.sh +++ b/cinelerra-5.1/doc/RenderMux.sh @@ -1,3 +1,5 @@ #!/bin/bash +exec >& /tmp/render_mux.log +echo == $0 $@ # Render output mux-ed into a single file ffmpeg -f concat -safe 0 -i <(for f in "$CIN_RENDER"0*; do echo "file '$f'"; done) -c copy -y $CIN_RENDER -- 2.26.2