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)
- 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
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);
(MaskAuto*)autos->first : (MaskAuto*)NEXT;
}
#endif
- int total_buttons = sizeof(gui->mask_buttons)/sizeof(gui->mask_buttons[0]);
- for( int i=0; i<total_buttons; ++i )
- gui->mask_buttons[i]->update(i==k ? 1 : 0);
gui->update();
gui->update_preview();
}
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; i<total_buttons; ++i )
- gui->mask_buttons[i]->update(i==no ? 1 : 0);
gui->name->update(gui->name->mask_items[no]->get_text());
+ gui->update();
gui->update_preview();
return 1;
}
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; i<total_buttons; ++i )
- gui->mask_buttons[i]->update(i==k ? 1 : 0);
gui->name->update(gui->name->mask_items[k]->get_text());
+ gui->update();
gui->update_preview();
return 1;
}
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);
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; i<SUBMASKS; ++i ) {
+ int color = text_color;
+ if( keyframe ) {
+ SubMask *submask = keyframe->get_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)
{
}
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);
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; i<shbtns_total; ++i ) {
defaults->get(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();
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; i<file_probes.size(); ++i ) {
#include "bcwindowbase.h"
#include "bcdisplayinfo.h"
#include "bcdialog.h"
+#include "awindow.h"
+#include "awindowgui.h"
+#include "cstrdup.h"
+#include "indexable.h"
#include "language.h"
#include "mainerror.h"
+#include "mainsession.h"
#include "mwindow.h"
#include "shbtnprefs.h"
#include "preferences.h"
ShBtnRun::ShBtnRun(const char *nm, const char *cmds, int warn)
: Thread(0, 0, 1)
{
+ argv.set_array_delete();
strncpy(name, nm, sizeof(name)-1);
name[sizeof(name)-1] = 0;
strncpy(commands, cmds, sizeof(commands)-1);
commands[sizeof(commands)-1] = 0;
this->warn = warn;
- start();
+}
+ShBtnRun::~ShBtnRun()
+{
+ argv.remove_all_objects();
+}
+
+void ShBtnRun::add_arg(const char *v)
+{
+ argv.append(cstrdup(v));
}
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<Indexable*> &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; i<n; ++i ) {
+ Indexable *idxbl = args[i];
+ if( !idxbl->is_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)
{
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);
{
this->sb_window = sb_window;
warn = sb_window->sb_dialog->pref->warn;
+ run_script = sb_window->sb_dialog->pref->run_script;
}
ShBtnTextWindow::~ShBtnTextWindow()
{
}
+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");
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();
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();
}
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;
}
#ifndef __SHBTNPREFS_H__
#define __SHBTNPREFS_H__
+#include "arraylist.h"
#include "bcwindowbase.h"
#include "bcbutton.h"
#include "bcdialog.h"
int warn;
char name[BCSTRLEN];
char commands[BCTEXTLEN];
+ ArrayList<char *> 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();
};
public:
char name[BCSTRLEN];
char commands[BCTEXTLEN];
- int warn;
+ int warn, run_script;
void execute();
+ void execute(ArrayList<Indexable*> &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();
};
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:
BC_ScrollTextBox *cmd_text;
ShBtnEditWindow *sb_window;
ShBtnErrWarn *st_err_warn;
+ ShBtnRunScript *st_run_script;
int warn;
+ int run_script;
void create_objects();
#!/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