Exciting new Alt/h help key provided by sge (Georgy) with many thanks!
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / menueffects.C
index d8dfdfab3499922996e53ea3c4c00832e7c077c2..fb16ab319781f529e3be61c1afc21b71d5db208c 100644 (file)
@@ -360,7 +360,9 @@ void MenuEffectThread::run()
                default_asset->height = mwindow->edl->session->output_h;
        }
 
-       int strategy = Render::get_strategy(mwindow->preferences->use_renderfarm, use_labels);
+       int range = File::is_image_render(default_asset->format) ?
+               RANGE_1FRAME : RANGE_SELECTION;
+       int strategy = Render::get_strategy(mwindow->preferences->use_renderfarm, use_labels, range);
 // Process the total length in fragments
        ArrayList<MenuEffectPacket*> packets;
        if(!result)
@@ -566,15 +568,11 @@ MenuEffectWindow::MenuEffectWindow(MWindow *mwindow,
        ArrayList<BC_ListBoxItem*> *plugin_list,
        Asset *asset)
  : BC_Window(_(PROGRAM_NAME ": Render effect"),
-               mwindow->gui->get_abs_cursor_x(1),
+               mwindow->gui->get_abs_cursor_x(1),
                mwindow->gui->get_abs_cursor_y(1) - mwindow->session->menueffect_h / 2,
                mwindow->session->menueffect_w,
                mwindow->session->menueffect_h,
-               580,
-               350,
-               1,
-               0,
-               1)
+               xS(580), yS(350), 1, 0, 1)
 {
        this->menueffects = menueffects;
        this->plugin_list = plugin_list;
@@ -583,6 +581,8 @@ MenuEffectWindow::MenuEffectWindow(MWindow *mwindow,
        file_title = 0;
        format_tools = 0;
        loadmode = 0;
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Rendered Effects");
 }
 
 MenuEffectWindow::~MenuEffectWindow()
@@ -607,11 +607,12 @@ void MenuEffectWindow::create_objects()
                add_subwindow(list_title = new BC_Title(mwindow->theme->menueffect_list_x,
                        mwindow->theme->menueffect_list_y,
                        _("Select an effect")));
+               int ys5 = yS(5);
                add_subwindow(list = new MenuEffectWindowList(this,
                        mwindow->theme->menueffect_list_x,
-                       mwindow->theme->menueffect_list_y + list_title->get_h() + 5,
+                       mwindow->theme->menueffect_list_y + list_title->get_h() + ys5,
                        mwindow->theme->menueffect_list_w,
-                       mwindow->theme->menueffect_list_h - list_title->get_h() - 5,
+                       mwindow->theme->menueffect_list_h - list_title->get_h() - ys5,
                        plugin_list));
        }
 
@@ -649,10 +650,11 @@ int MenuEffectWindow::resize_event(int w, int h)
        {
                list_title->reposition_window(mwindow->theme->menueffect_list_x,
                        mwindow->theme->menueffect_list_y);
+               int ys5 = yS(5);
                list->reposition_window(mwindow->theme->menueffect_list_x,
-                       mwindow->theme->menueffect_list_y + list_title->get_h() + 5,
+                       mwindow->theme->menueffect_list_y + list_title->get_h() + ys5,
                        mwindow->theme->menueffect_list_w,
-                       mwindow->theme->menueffect_list_h - list_title->get_h() - 5);
+                       mwindow->theme->menueffect_list_h - list_title->get_h() - ys5);
        }
 
        if(file_title) file_title->reposition_window(mwindow->theme->menueffect_file_x,
@@ -688,7 +690,7 @@ int MenuEffectWindowOK::keypress_event()
                handle_event();
                return 1;
        }
-       return 0;
+       return context_help_check_and_show();
 }
 
 MenuEffectWindowCancel::MenuEffectWindowCancel(MenuEffectWindow *window)
@@ -710,7 +712,7 @@ int MenuEffectWindowCancel::keypress_event()
                handle_event();
                return 1;
        }
-       return 0;
+       return context_help_check_and_show();
 }
 
 MenuEffectWindowList::MenuEffectWindowList(MenuEffectWindow *window,
@@ -719,12 +721,7 @@ MenuEffectWindowList::MenuEffectWindowList(MenuEffectWindow *window,
        int w,
        int h,
        ArrayList<BC_ListBoxItem*> *plugin_list)
- : BC_ListBox(x,
-               y,
-               w,
-               h,
-               LISTBOX_TEXT,
-               plugin_list)
+ : BC_ListBox(x, y, w, h, LISTBOX_TEXT, plugin_list)
 {
        this->window = window;
 }
@@ -736,31 +733,83 @@ int MenuEffectWindowList::handle_event()
        return 1;
 }
 
+// *** CONTEXT_HELP ***
+int MenuEffectWindowList::keypress_event()
+{
+       int item;
+       char title[BCTEXTLEN];
+
+//     printf("MenuEffectWindowList::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
+       title[0] = '\0';
+       item = get_highlighted_item();
+       if (item >= 0 && item < window->plugin_list->total)
+               strcpy(title, window->plugin_list->values[item]->get_text());
+
+       // If some plugin is highlighted, show its help
+       // Otherwise show more general help
+       if (title[0]) {
+               if (! strcmp(title, "Overlay")) {
+                       // "Overlay" plugin title is ambiguous
+                       if (window->asset->audio_data)
+                               strcat(title, " \\(Audio\\)");
+                       if (window->asset->video_data)
+                               strcat(title, " \\(Video\\)");
+               }
+               if (! strncmp(title, "F_", 2)) {
+                       // FFmpeg plugins can be audio or video
+                       if (window->asset->audio_data)
+                               strcpy(title, "FFmpeg Audio Plugins");
+                       if (window->asset->video_data)
+                               strcpy(title, "FFmpeg Video Plugins");
+               }
+               context_help_show(title);
+               return 1;
+       }
+       else {
+               context_help_show("Rendered Effects");
+               return 1;
+       }
+       context_help_show("Rendered Effects");
+       return 1;
+}
+
 #define PROMPT_TEXT _("Set up effect panel and hit \"OK\"")
+#define MEP_W xS(260)
+#define MEP_H yS(100)
 
 MenuEffectPrompt::MenuEffectPrompt(MWindow *mwindow)
  : BC_Window(_(PROGRAM_NAME ": Effect Prompt"),
-               mwindow->gui->get_abs_cursor_x(1) - 260 / 2,
-               mwindow->gui->get_abs_cursor_y(1) - 300,
-               MenuEffectPrompt::calculate_w(mwindow->gui),
+               mwindow->gui->get_abs_cursor_x(1) - MEP_W/2,
+               mwindow->gui->get_abs_cursor_y(1) - MEP_H/2,
+               MenuEffectPrompt::calculate_w(mwindow->gui),
                MenuEffectPrompt::calculate_h(mwindow->gui),
                MenuEffectPrompt::calculate_w(mwindow->gui),
                MenuEffectPrompt::calculate_h(mwindow->gui),
                0, 0, 1)
 {
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Rendered Effects");
 }
 
 int MenuEffectPrompt::calculate_w(BC_WindowBase *gui)
 {
-       int w = BC_Title::calculate_w(gui, PROMPT_TEXT) + 10;
-       w = MAX(w, BC_OKButton::calculate_w() + BC_CancelButton::calculate_w() + 30);
+       int w = BC_Title::calculate_w(gui, PROMPT_TEXT) + xS(10);
+       w = MAX(w, BC_OKButton::calculate_w() + BC_CancelButton::calculate_w() + xS(30));
        return w;
 }
 
 int MenuEffectPrompt::calculate_h(BC_WindowBase *gui)
 {
        int h = BC_Title::calculate_h(gui, PROMPT_TEXT);
-       h += BC_OKButton::calculate_h() + 30;
+       h += BC_OKButton::calculate_h() + yS(30);
        return h;
 }
 
@@ -768,7 +817,7 @@ int MenuEffectPrompt::calculate_h(BC_WindowBase *gui)
 void MenuEffectPrompt::create_objects()
 {
        lock_window("MenuEffectPrompt::create_objects");
-       int x = 10, y = 10;
+       int x = xS(10), y = yS(10);
        BC_Title *title;
        add_subwindow(title = new BC_Title(x, y, PROMPT_TEXT));
        add_subwindow(new BC_OKButton(this));