tool tipinfo on effect plugins, updated plugin tipinfo, tweaks to layouts
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / effectlist.C
index 25e7c8c309a3c7c6d53a494c120178ffbc5adcb1..819c08b7d5608b1944dadf5a23e11393d08080cc 100644 (file)
 #include "clip.h"
 #include "cstrdup.h"
 #include "effectlist.h"
+#include "edl.h"
 #include "guicast.h"
 #include "language.h"
+#include "localsession.h"
 #include "mwindow.h"
 #include "pluginserver.h"
 
-EffectTipDialog::EffectTipDialog(MWindow *mwindow, AWindow *awindow)
- : BC_DialogThread()
-{
-       this->mwindow = mwindow;
-       this->awindow = awindow;
-       effect = 0;
-       text = 0;
-}
-
-EffectTipDialog::~EffectTipDialog()
-{
-       close_window();
-       delete [] effect;
-       delete [] text;
-}
-
-void EffectTipDialog::start(int x, int y, const char *effect, const char *text)
-{
-       close_window();
-       AWindowGUI *gui = awindow->gui;
-       char string[BCTEXTLEN];
-       sprintf(string, _("Effect info: %s"), _(effect));
-       int effect_w = BC_Title::calculate_w(gui, string);
-       int text_w = BC_Title::calculate_w(gui, text);
-       int text_h = BC_Title::calculate_h(gui, text);
-       this->w = bmax(text_w + 30, bmax(effect_w + 30, 120));
-       this->h = bmax(text_h + 100, 120);
-       this->x = x - this->w / 2;
-       this->y = y - this->h / 2;
-       delete [] this->effect;  this->effect = cstrdup(string);
-       delete [] this->text;    this->text = cstrdup(text);
-       BC_DialogThread::start();
-}
-
-BC_Window* EffectTipDialog::new_gui()
-{
-       AWindowGUI *gui = awindow->gui;
-       effect_gui = new EffectTipWindow(gui, this);
-       effect_gui->create_objects();
-       return effect_gui;
-};
-
-
-EffectTipWindow::EffectTipWindow(AWindowGUI *gui, EffectTipDialog *thread)
- : BC_Window(_(PROGRAM_NAME ": Effect Info"),
-       thread->x + thread->w/2, thread->y + thread->h/2,
-       thread->w, thread->h, thread->w, thread->h, 0, 0, 1)
-{
-       this->gui = gui;
-        this->thread = thread;
-}
-EffectTipWindow::~EffectTipWindow()
-{
-}
-
-void EffectTipWindow::create_objects()
-{
-       lock_window("EffectTipWindow::create_objects");
-       int x = 10, y = 10;
-       BC_Title *title;
-       add_subwindow(title = new BC_Title(x, y, thread->effect));
-       y += title->get_h() + 10;
-       add_subwindow(tip_text = new BC_Title(x+5, y, thread->text));
-       add_subwindow(new BC_OKButton(this));
-       show_window(1);
-       unlock_window();
-}
 
 EffectTipItem::EffectTipItem(AWindowGUI *gui)
- : BC_MenuItem(_("Info"))
+ : BC_MenuItem("","i",'i')
 {
        this->gui = gui;
+       update();
 }
 EffectTipItem::~EffectTipItem()
 {
 }
 
+
 int EffectTipItem::handle_event()
 {
-       AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
-       if( result && result->plugin ) {
-               const char *info = result->plugin->tip;
-               if( !info ) info = _("No info available");
-               int cur_x, cur_y;
-               gui->get_abs_cursor(cur_x, cur_y, 0);
-               gui->awindow->effect_tip->start(cur_x, cur_y,
-                       result->plugin->title, info);
-       }
+       int v = !gui->tip_info ? 1 : 0;
+       update(v);
        return 1;
 }
 
+void EffectTipItem::update(int v)
+{
+       if( v >= 0 ) gui->tip_info = v;
+       else v = gui->tip_info;
+       const char *text = v ?  _("Info off") : _("Info on");
+       set_text(text);
+}
+
 
 EffectListMenu::EffectListMenu(MWindow *mwindow, AWindowGUI *gui)
  : BC_PopupMenu(0, 0, 0, "", 0)
@@ -134,13 +72,14 @@ EffectListMenu:: ~EffectListMenu()
 
 void EffectListMenu::create_objects()
 {
-       add_item(new EffectTipItem(gui));
+       add_item(info = new EffectTipItem(gui));
        add_item(format = new AWindowListFormat(mwindow, gui));
        add_item(new AWindowListSort(mwindow, gui));
 }
 
 void EffectListMenu::update()
 {
+       info->update();
        format->update();
 }