From 8fe9a22b4600301fee74b27bd8e0c44f9d681079 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 27 May 2018 20:24:57 -0600 Subject: [PATCH] add lv2 autostart pref, add ffmpeg config pot/slider --- cinelerra-5.1/cinelerra/appearanceprefs.C | 19 +++- cinelerra-5.1/cinelerra/appearanceprefs.h | 9 +- cinelerra-5.1/cinelerra/appearanceprefs.inc | 2 + cinelerra-5.1/cinelerra/pluginfclient.C | 108 ++++++++++++++++++-- cinelerra-5.1/cinelerra/pluginfclient.h | 52 +++++++--- cinelerra-5.1/cinelerra/pluginlv2gui.C | 9 ++ cinelerra-5.1/cinelerra/preferences.C | 4 + cinelerra-5.1/cinelerra/preferences.h | 1 + 8 files changed, 182 insertions(+), 22 deletions(-) diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C index 15e61cdf..2f51f61f 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.C +++ b/cinelerra-5.1/cinelerra/appearanceprefs.C @@ -191,7 +191,12 @@ void AppearancePrefs::create_objects() y1 += displacement->get_h() + 5; add_subwindow(thumbnails = new ViewThumbnails(x1, y1, pwindow)); y1 += thumbnails->get_h() + 5; - add_subwindow(perpetual = new PerpetualSession(x1, y1, pwindow)); + PrefsAutostartLV2UI *autostart_lv2ui = new PrefsAutostartLV2UI(x1, y1,pwindow); + add_subwindow(autostart_lv2ui); + y1 += autostart_lv2ui->get_h() + 5; + PerpetualSession *perpetual = new PerpetualSession(x1, y1, pwindow); + add_subwindow(perpetual); + y1 += perpetual->get_h() + 5; if( y < y1 ) y = y1; } @@ -631,6 +636,18 @@ int YuvColorRangeItem::handle_event() } +PrefsAutostartLV2UI::PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow) + : BC_CheckBox(x, y, + pwindow->thread->preferences->autostart_lv2ui, _("Auto start lv2 gui")) +{ + this->pwindow = pwindow; +} +int PrefsAutostartLV2UI::handle_event() +{ + pwindow->thread->preferences->autostart_lv2ui = get_value(); + return 1; +} + PerpetualSession::PerpetualSession(int x, int y, PreferencesWindow *pwindow) : BC_CheckBox(x, y, pwindow->thread->preferences->perpetual_session, _("Perpetual session")) diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h index 392650cf..97584233 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.h +++ b/cinelerra-5.1/cinelerra/appearanceprefs.h @@ -49,7 +49,6 @@ public: ViewThumbnails *thumbnails; YuvColorSpace *yuv_color_space; YuvColorRange *yuv_color_range; - PerpetualSession *perpetual; }; @@ -298,6 +297,14 @@ public: int id; }; +class PrefsAutostartLV2UI : public BC_CheckBox +{ +public: + PrefsAutostartLV2UI(int x, int y, PreferencesWindow *pwindow); + int handle_event(); + PreferencesWindow *pwindow; +}; + class PerpetualSession : public BC_CheckBox { public: diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.inc b/cinelerra-5.1/cinelerra/appearanceprefs.inc index 128194ad..5d079cdc 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.inc +++ b/cinelerra-5.1/cinelerra/appearanceprefs.inc @@ -41,6 +41,7 @@ class UseWarnIndecies; class UseWarnVersion; class BD_WarnRoot; class PopupMenuBtnup; +class GrabFocusPolicy; class ActivateFocusPolicy; class DeactivateFocusPolicy; class ForwardRenderDisplacement; @@ -49,6 +50,7 @@ class YuvColorSpace; class YuvColorSpaceItem; class YuvColorRange; class YuvColorRangeItem; +class PrefsAutostartLV2UI; class PerpetualSession; #endif diff --git a/cinelerra-5.1/cinelerra/pluginfclient.C b/cinelerra-5.1/cinelerra/pluginfclient.C index 114d64e5..74c59f4f 100644 --- a/cinelerra-5.1/cinelerra/pluginfclient.C +++ b/cinelerra-5.1/cinelerra/pluginfclient.C @@ -224,12 +224,75 @@ PluginFClientApply:: int PluginFClientApply::handle_event() { - const char *text = fwin->text->get_text(); - if( text && fwin->selected ) { - fwin->selected->set(text); - fwin->selected->item_value->update(); - fwin->draw(); - fwin->ffmpeg->plugin->send_configure_change(); + return fwin->update(); +} + +PluginFClientPot::PluginFClientPot(PluginFClientWindow *fwin, int x, int y) + : BC_FPot(x, y, 0.f, 0.f, 0.f) +{ + this->fwin = fwin; +} + +int PluginFClient_Opt::get_range(float &fmn, float &fmx) +{ + switch( opt->type ) { + case AV_OPT_TYPE_INT: + case AV_OPT_TYPE_INT64: + case AV_OPT_TYPE_DOUBLE: + case AV_OPT_TYPE_FLOAT: break; + default: return 1; + } + const AVClass *filt_class = filter_class(); + if( !filt_class || !filt_class->option ) return 1; + AVOptionRanges *r = 0; + void *obj = &filt_class; + if( av_opt_query_ranges(&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) < 0 ) return 1; + int ret = 1; + if( r->nb_ranges == 1 ) { + fmn = r->range[0]->value_min; + fmx = r->range[0]->value_max; + ret = 0; + } + av_opt_freep_ranges(&r); + return ret; +} + +float PluginFClient_Opt::get_float() +{ + char val[BCTEXTLEN]; val[0] = 0; + get(val, sizeof(val)); + return atof(val); +} + +void PluginFClient_Opt::set_float(float v) +{ + char val[BCTEXTLEN]; val[0] = 0; + sprintf(val, "%f", v); + set(val); +} + +int PluginFClientPot::handle_event() +{ + if( fwin->selected ) { + fwin->selected->set_float(get_value()); + fwin->update_selected(); + return fwin->update(); + } + return 1; +} + +PluginFClientSlider::PluginFClientSlider(PluginFClientWindow *fwin, int x, int y) + : BC_FSlider(x, y, 0, fwin->get_w()-x-20, fwin->get_w()-x-20, 0.f, 0.f, 0.f) +{ + this->fwin = fwin; +} + +int PluginFClientSlider::handle_event() +{ + if( fwin->selected ) { + fwin->selected->set_float(get_value()); + fwin->update_selected(); + return fwin->update(); } return 1; } @@ -292,9 +355,33 @@ void PluginFClientWindow::update(PluginFClient_Opt *opt) if( opt ) opt->get(val, sizeof(val)); text->update(val); + float v = 0, fmn = 0, fmx = 0; + if( opt && !opt->get_range(fmn, fmx) ) v = atof(val); + float p = (fmx-fmn) / slider->get_w(); + slider->set_precision(p); + slider->update(slider->get_w(), v, fmn, fmx); + pot->set_precision(p); + pot->update(v, fmn, fmx); panel->update(); } +int PluginFClientWindow::update() +{ + const char *txt = text->get_text(); + if( txt && selected ) { + selected->set(txt); + selected->item_value->update(); + draw(); + ffmpeg->plugin->send_configure_change(); + } + return 1; +} + +void PluginFClientWindow::update_selected() +{ + update(selected); +} + int PluginFClient_OptPanel::selection_changed() { PluginFClient_Opt *opt = 0; @@ -479,6 +566,10 @@ void PluginFClientWindow::create_objects() add_subwindow(apply = new PluginFClientApply(this, x1, y)); add_subwindow(text = new PluginFClientText(this, x0, y, x1-x0 - 8)); y += title->get_h() + 10; + add_subwindow(pot = new PluginFClientPot(this, x, y)); + x1 = x + pot->get_w() + 10; + add_subwindow(slider = new PluginFClientSlider(this, x1, y+10)); + y += pot->get_h() + 10; panel_x = x; panel_y = y; panel_w = get_w()-10 - panel_x; @@ -507,12 +598,17 @@ int PluginFClientWindow::resize_event(int w, int h) int x0 = units->get_x() + units->get_w() + 8; int y0 = units->get_y(); text->reposition_window(x0,y0, x1-x0-8); + x1 = pot->get_x() + pot->get_w() + 10; + int w1 = w - slider->get_x() - 20; + slider->set_pointer_motion_range(w1); + slider->reposition_window(x1, slider->get_y(), w1, slider->get_h()); panel_w = get_w()-10 - panel_x; panel_h = get_h()-10 - panel_y; panel->reposition_window(panel_x,panel_y, panel_w, panel_h); return 1; } + PluginFClient::PluginFClient(PluginClient *plugin, const char *name) { this->plugin = plugin; diff --git a/cinelerra-5.1/cinelerra/pluginfclient.h b/cinelerra-5.1/cinelerra/pluginfclient.h index 4d63b697..8e2ffaa5 100644 --- a/cinelerra-5.1/cinelerra/pluginfclient.h +++ b/cinelerra-5.1/cinelerra/pluginfclient.h @@ -59,6 +59,10 @@ public: int ranges(char *rp); int units(ArrayList &opts); int units(char *rp); + int get_range(float &fmn, float &fmx); + float get_float(); + void set_float(float v); + const char *tip(); void *filter_config(); const AVClass *filter_class(); @@ -166,6 +170,22 @@ public: int handle_event(); }; +class PluginFClientPot : public BC_FPot +{ +public: + PluginFClientPot(PluginFClientWindow *fwin, int x, int y); + int handle_event(); + PluginFClientWindow *fwin; +}; + +class PluginFClientSlider : public BC_FSlider +{ +public: + PluginFClientSlider(PluginFClientWindow *fwin, int x, int y); + int handle_event(); + PluginFClientWindow *fwin; +}; + class PluginFClientWindow : public PluginClientWindow { public: @@ -174,19 +194,23 @@ public: void create_objects(); void update(PluginFClient_Opt *oip); + int update(); + void update_selected(); void draw(); int resize_event(int w, int h); - PluginFClient *ffmpeg; + PluginFClient *ffmpeg; PluginFClient_OptPanel *panel; - int panel_x, panel_y, panel_w, panel_h; + int panel_x, panel_y, panel_w, panel_h; BC_Title *type, *range; - PluginFClient_Opt *selected; + PluginFClient_Opt *selected; PluginFClientReset *reset; PluginFClientUnits *units; PluginFClientText *text; PluginFClientApply *apply; + PluginFClientPot *pot; + PluginFClientSlider *slider; }; class PluginFLogLevel { @@ -210,7 +234,7 @@ public: char title[BCSTRLEN]; PluginFClient(PluginClient *plugin, const char *name); - ~PluginFClient(); + ~PluginFClient(); static bool is_audio(const AVFilter *fp); static bool is_video(const AVFilter *fp); @@ -227,23 +251,23 @@ public: return plugin->edl_to_local(position); } - void update_gui(); + void update_gui(); char *to_upper(char *bp, const char *sp); void save_data(KeyFrame *keyframe); void read_data(KeyFrame *keyframe); - void render_gui(void *data, int size); + void render_gui(void *data, int size); int activate(); void reactivate(); - PluginFClientConfig curr_config; - PLUGIN_CLASS_MEMBERS(PluginFClientConfig) + PluginFClientConfig curr_config; + PLUGIN_CLASS_MEMBERS(PluginFClientConfig) }; class PluginFAClient : public PluginAClient, public PluginFClient { public: PluginFAClient(PluginServer *server, const char *name); - ~PluginFAClient(); + ~PluginFAClient(); const char *plugin_title() { return PluginFClient::plugin_title(); } PluginClientWindow *new_window() { return PluginFClient::new_window(); } int activate(); @@ -252,14 +276,14 @@ public: void save_data(KeyFrame *keyframe) { PluginFClient::save_data(keyframe); } void read_data(KeyFrame *keyframe) { PluginFClient::read_data(keyframe); } void update_gui() { PluginFClient::update_gui(); } - void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); } + void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); } int is_realtime() { return 1; } int is_multichannel() { return 1; } int uses_gui() { return 1; } int is_synthesis() { return 1; } - int get_inchannels(); - int get_outchannels(); + int get_inchannels(); + int get_outchannels(); int process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate); }; @@ -267,7 +291,7 @@ class PluginFVClient : public PluginVClient, public PluginFClient, public FFVide { public: PluginFVClient(PluginServer *server, const char *name); - ~PluginFVClient(); + ~PluginFVClient(); const char *plugin_title() { return PluginFClient::plugin_title(); } PluginClientWindow *new_window() { return PluginFClient::new_window(); } int activate(int width, int height, int color_model); @@ -276,7 +300,7 @@ public: void save_data(KeyFrame *keyframe) { PluginFClient::save_data(keyframe); } void read_data(KeyFrame *keyframe) { PluginFClient::read_data(keyframe); } void update_gui() { PluginFClient::update_gui(); } - void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); } + void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); } int is_realtime() { return 1; } int is_multichannel() { return 1; } diff --git a/cinelerra-5.1/cinelerra/pluginlv2gui.C b/cinelerra-5.1/cinelerra/pluginlv2gui.C index e8c4edb3..f6e3518f 100644 --- a/cinelerra-5.1/cinelerra/pluginlv2gui.C +++ b/cinelerra-5.1/cinelerra/pluginlv2gui.C @@ -29,6 +29,7 @@ #include "pluginlv2config.h" #include "pluginlv2gui.h" #include "pluginserver.h" +#include "preferences.h" #include "samples.h" #include @@ -242,6 +243,11 @@ void PluginLV2ClientWindow::create_objects() add_subwindow(panel); panel->update(); show_window(1); + + if( client->server->mwindow->preferences->autostart_lv2ui ) { + PluginLV2ParentUI *ui = get_ui(); + ui->show(); + } } int PluginLV2ClientWindow::resize_event(int w, int h) @@ -311,7 +317,10 @@ void PluginLV2ClientWindow::update(PluginLV2Client_Opt *opt) cp += sprintf(cp, " )"); float v = opt->get_value(); sprintf(val, "%f", v); + float p = (max-min) / slider->get_w(); + slider->set_precision(p); slider->update(slider->get_w(), v, min, max); + pot->set_precision(p); pot->update(v, min, max); } else { diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 4e13c584..e94a77fa 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -64,6 +64,7 @@ Preferences::Preferences() use_thumbnails = 1; keyframe_reticle = HAIRLINE_DRAGGING; perpetual_session = 0; + autostart_lv2ui = 0; trap_sigsegv = 1; trap_sigintr = 1; theme[0] = 0; @@ -188,6 +189,7 @@ void Preferences::copy_from(Preferences *that) cache_size = that->cache_size; project_smp = that->project_smp; force_uniprocessor = that->force_uniprocessor; + autostart_lv2ui = that->autostart_lv2ui; trap_sigsegv = that->trap_sigsegv; trap_sigintr = that->trap_sigintr; processors = that->processors; @@ -303,6 +305,7 @@ int Preferences::load_defaults(BC_Hash *defaults) index_count = defaults->get("INDEX_COUNT", index_count); keyframe_reticle = defaults->get("KEYFRAME_RETICLE", keyframe_reticle); perpetual_session = defaults->get("PERPETUAL_SESSION", perpetual_session); + autostart_lv2ui = defaults->get("AUTOSTART_LV2UI", autostart_lv2ui); trap_sigsegv = defaults->get("TRAP_SIGSEGV", trap_sigsegv); trap_sigintr = defaults->get("TRAP_SIGINTR", trap_sigintr); @@ -443,6 +446,7 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update("USE_THUMBNAILS", use_thumbnails); defaults->update("KEYFRAME_RETICLE", keyframe_reticle); defaults->update("PERPETUAL_SESSION", perpetual_session); + defaults->update("AUTOSTART_LV2UI", autostart_lv2ui); defaults->update("TRAP_SIGSEGV", trap_sigsegv); defaults->update("TRAP_SIGINTR", trap_sigintr); defaults->update("THEME", theme); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index aab5c810..8a7db357 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -92,6 +92,7 @@ public: int perpetual_session; int trap_sigsegv; int trap_sigintr; + int autostart_lv2ui; // Title of theme char theme[BCTEXTLEN]; // plugin icon set -- 2.26.2