remove old openjpeg which was upgrade awhile back
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / plugindialog.C
index 8e08d2f17313d3326f0cebb65f87b8f179a855c4..48f470e6efaa5888929399794fdfd4ec90ec80f3 100644 (file)
@@ -44,7 +44,7 @@ PluginDialogThread::PluginDialogThread(MWindow *mwindow)
  : BC_DialogThread()
 {
        this->mwindow = mwindow;
-       this->plugin = 0;
+       this->plugin_id = -1;
        this->plugin_type = PLUGIN_NONE;
 }
 
@@ -62,7 +62,6 @@ void PluginDialogThread::start_window(Track *track,
 //             mwindow->gui->lock_window("PluginDialogThread::start_window");
                this->track = track;
                this->data_type = data_type;
-               this->plugin = plugin;
                this->is_mainmenu = is_mainmenu;
                single_standalone = mwindow->edl->session->single_standalone;
 
@@ -71,6 +70,7 @@ void PluginDialogThread::start_window(Track *track,
                        plugin->calculate_title(plugin_title, 0);
                        this->shared_location = plugin->shared_location;
                        this->plugin_type = plugin->plugin_type;
+                       this->plugin_id = plugin->orig_id;
                }
                else
                {
@@ -78,6 +78,7 @@ void PluginDialogThread::start_window(Track *track,
                        this->shared_location.plugin = -1;
                        this->shared_location.module = -1;
                        this->plugin_type = PLUGIN_NONE;
+                       this->plugin_id = -1;
                }
 
                strcpy(this->window_title, title);
@@ -136,6 +137,18 @@ PluginDialog::PluginDialog(MWindow *mwindow,
        this->mwindow = mwindow;
        this->thread = thread;
        single_standalone = 0;
+// *** CONTEXT_HELP ***
+       switch( thread->data_type ) {
+       case TRACK_AUDIO:
+               context_help_set_keyword("Audio Effects");
+               break;
+       case TRACK_VIDEO:
+               context_help_set_keyword("Video Effects");
+               break;
+       default:
+               context_help_set_keyword("How to Use Plugins");
+               break;
+       }
 }
 
 PluginDialog::~PluginDialog()
@@ -413,7 +426,7 @@ void PluginDialog::clear_selection()
        selected_available = -1;
        selected_shared = -1;
        selected_modules = -1;
-       thread->plugin = 0;
+       thread->plugin_id = -1;
        thread->plugin_type = PLUGIN_NONE;
 }
 
@@ -434,8 +447,10 @@ void PluginDialog::apply()
 
 void PluginDialogThread::apply()
 {
-       if( mwindow->edl )
-               mwindow->edl->session->single_standalone = single_standalone;
+       Plugin *plugin = 0;
+       EDL *edl = mwindow->edl;
+       if( edl )
+               edl->session->single_standalone = single_standalone;
        if(plugin_type) {
                mwindow->gui->lock_window("PluginDialogThread::run 3");
                mwindow->undo->update_undo_before();
@@ -443,19 +458,20 @@ void PluginDialogThread::apply()
                        mwindow->insert_effect(plugin_title, &shared_location,
                                data_type, plugin_type, single_standalone);
                }
-               else {
-                       if( plugin ) {
-                               if( mwindow->edl->tracks->plugin_exists(plugin) ) {
-                                       plugin->change_plugin(plugin_title,
-                                               &shared_location, plugin_type);
-                               }
-                       }
-                       else {
-                               if( mwindow->edl->tracks->track_exists(track) ) {
-                                       mwindow->insert_effect(plugin_title, &shared_location,
-                                               track, 0, 0, 0, plugin_type);
-                               }
+               else if( (plugin=edl->tracks->plugin_exists(plugin_id)) != 0 ) {
+                       plugin->change_plugin(plugin_title,
+                                       &shared_location, plugin_type);
+               }
+               else if( edl->tracks->track_exists(track) ) {
+                       double start = edl->local_session->get_selectionstart(1);
+                       double end = edl->local_session->get_selectionend(1);
+                       if( start >= end ) {
+                               start = 0;
+                               end = track->get_length();
                        }
+                       double length = end - start;
+                       mwindow->insert_effect(plugin_title, &shared_location,
+                                       track, 0, start, length, plugin_type);
                }
 
                mwindow->save_backup();
@@ -466,7 +482,7 @@ void PluginDialogThread::apply()
                mwindow->gui->update(1, NORMAL_DRAW, 0, 0, 1, 0, 0);
                mwindow->gui->unlock_window();
        }
-       plugin = 0;
+       plugin_id = -1;
 }
 
 PluginDialogApply::PluginDialogApply(PluginDialog *dialog, int x, int y)
@@ -547,6 +563,67 @@ int PluginDialogNew::selection_changed()
        return 1;
 }
 
+// *** CONTEXT_HELP ***
+int PluginDialogNew::keypress_event()
+{
+       int item, plugin_no;
+       char title[BCTEXTLEN];
+       PluginServer *plugin = 0;
+
+//     printf("PluginDialogNew::keypress_event: %d\n", get_keypress());
+
+       // If not our context help keystroke, redispatch it
+       // to the event handler of the base class
+       if (get_keypress() != 'h' || ! alt_down() ||
+           ! is_tooltip_event_win() || ! cursor_inside())
+               return BC_ListBox::keypress_event();
+
+       // Try to show help for the plugin currently under mouse
+       item = get_highlighted_item();
+       if (item >= 0 && item < dialog->standalone_data.size()) {
+               plugin_no = ((PluginDialogListItem *)dialog->standalone_data[item])->item_no;
+               if (plugin_no >= 0 && plugin_no < dialog->plugindb.total)
+                       plugin = dialog->plugindb.values[plugin_no];
+       }
+
+       // If some plugin is highlighted, show its help
+       // Otherwise show more general help
+       if (plugin) {
+               strcpy(title, plugin->title);
+               if (! strcmp(title, "Overlay")) {
+                       // "Overlay" plugin title is ambiguous
+                       if (plugin->audio) strcat(title, " \\(Audio\\)");
+                       if (plugin->video) strcat(title, " \\(Video\\)");
+               }
+               if (plugin->is_ffmpeg()) {
+                       // FFmpeg plugins can be audio or video
+                       if (plugin->audio)
+                               strcpy(title, "FFmpeg Audio Plugins");
+                       if (plugin->video)
+                               strcpy(title, "FFmpeg Video Plugins");
+               }
+               context_help_show(title);
+               return 1;
+       }
+       else {
+               switch (dialog->thread->data_type) {
+               case TRACK_AUDIO:
+                       context_help_show("Audio Effects");
+                       return 1;
+               case TRACK_VIDEO:
+                       context_help_show("Video Effects");
+                       return 1;
+               default:
+                       context_help_show("How to Use Plugins");
+                       return 1;
+               }
+               context_help_show("How to Use Plugins");
+               return 1;
+       }
+       context_help_show("How to Use Plugins");
+       return 1;
+}
+
 // PluginDialogAttachNew::PluginDialogAttachNew(MWindow *mwindow, PluginDialog *dialog, int x, int y)
 //  : BC_GenericButton(x, y, _("Attach"))
 // {
@@ -584,6 +661,7 @@ PluginDialogShared::PluginDialogShared(PluginDialog *dialog,
  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, shared_data)
 {
        this->dialog = dialog;
+       context_help_set_keyword("Shared Effects and Shared Tracks");
 }
 PluginDialogShared::~PluginDialogShared() { }
 int PluginDialogShared::handle_event()
@@ -657,6 +735,7 @@ PluginDialogModules::PluginDialogModules(PluginDialog *dialog,
  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, module_data)
 {
        this->dialog = dialog;
+       context_help_set_keyword("Shared Effects and Shared Tracks");
 }
 PluginDialogModules::~PluginDialogModules() { }
 int PluginDialogModules::handle_event()
@@ -713,6 +792,7 @@ PluginDialogSingle::PluginDialogSingle(PluginDialog *dialog, int x, int y)
        _("Attach single standalone and share others"))
 {
        this->dialog = dialog;
+       context_help_set_keyword("Shared Effects and Shared Tracks");
 }
 
 int PluginDialogSingle::handle_event()