camera zoom fix, upgrade giflib, configure.ac ix86 probe tweaks, any python
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / effectlist.C
1 /*
2  * CINELERRA
3  * Copyright (C) 2006 Pierre Dumuid
4  * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "awindow.h"
23 #include "awindowgui.h"
24 #include "clip.h"
25 #include "cstrdup.h"
26 #include "effectlist.h"
27 #include "guicast.h"
28 #include "language.h"
29 #include "mwindow.h"
30 #include "pluginserver.h"
31
32 EffectTipDialog::EffectTipDialog(MWindow *mwindow, AWindow *awindow)
33  : BC_DialogThread()
34 {
35         this->mwindow = mwindow;
36         this->awindow = awindow;
37         effect = 0;
38         text = 0;
39 }
40
41 EffectTipDialog::~EffectTipDialog()
42 {
43         close_window();
44         delete [] effect;
45         delete [] text;
46 }
47
48 void EffectTipDialog::start(int x, int y, const char *effect, const char *text)
49 {
50         close_window();
51         AWindowGUI *gui = awindow->gui;
52         char string[BCTEXTLEN];
53         sprintf(string, _("Effect info: %s"), _(effect));
54         int effect_w = BC_Title::calculate_w(gui, string);
55         int text_w = BC_Title::calculate_w(gui, text);
56         int text_h = BC_Title::calculate_h(gui, text);
57         this->w = bmax(text_w + 30, bmax(effect_w + 30, 120));
58         this->h = bmax(text_h + 100, 120);
59         this->x = x - this->w / 2;
60         this->y = y - this->h / 2;
61         delete [] this->effect;  this->effect = cstrdup(string);
62         delete [] this->text;    this->text = cstrdup(text);
63         BC_DialogThread::start();
64 }
65
66 BC_Window* EffectTipDialog::new_gui()
67 {
68         AWindowGUI *gui = awindow->gui;
69         effect_gui = new EffectTipWindow(gui, this);
70         effect_gui->create_objects();
71         return effect_gui;
72 };
73
74
75 EffectTipWindow::EffectTipWindow(AWindowGUI *gui, EffectTipDialog *thread)
76  : BC_Window(_(PROGRAM_NAME ": Effect Info"),
77         thread->x + thread->w/2, thread->y + thread->h/2,
78         thread->w, thread->h, thread->w, thread->h, 0, 0, 1)
79 {
80         this->gui = gui;
81         this->thread = thread;
82 }
83 EffectTipWindow::~EffectTipWindow()
84 {
85 }
86
87 void EffectTipWindow::create_objects()
88 {
89         lock_window("EffectTipWindow::create_objects");
90         int x = 10, y = 10;
91         BC_Title *title;
92         add_subwindow(title = new BC_Title(x, y, thread->effect));
93         y += title->get_h() + 10;
94         add_subwindow(tip_text = new BC_Title(x+5, y, thread->text));
95         add_subwindow(new BC_OKButton(this));
96         show_window(1);
97         unlock_window();
98 }
99
100 EffectTipItem::EffectTipItem(AWindowGUI *gui)
101  : BC_MenuItem(_("Info"))
102 {
103         this->gui = gui;
104 }
105 EffectTipItem::~EffectTipItem()
106 {
107 }
108
109 int EffectTipItem::handle_event()
110 {
111         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
112         if( result && result->plugin ) {
113                 const char *info = result->plugin->tip;
114                 if( !info ) info = _("No info available");
115                 int cur_x, cur_y;
116                 gui->get_abs_cursor(cur_x, cur_y, 0);
117                 gui->awindow->effect_tip->start(cur_x, cur_y,
118                         result->plugin->title, info);
119         }
120         return 1;
121 }
122
123
124 EffectListMenu::EffectListMenu(MWindow *mwindow, AWindowGUI *gui)
125  : BC_PopupMenu(0, 0, 0, "", 0)
126 {
127         this->mwindow = mwindow;
128         this->gui = gui;
129 }
130
131 EffectListMenu:: ~EffectListMenu()
132 {
133 }
134
135 void EffectListMenu::create_objects()
136 {
137         add_item(new EffectTipItem(gui));
138         add_item(format = new AWindowListFormat(mwindow, gui));
139         add_item(new AWindowListSort(mwindow, gui));
140 }
141
142 void EffectListMenu::update()
143 {
144         format->update();
145 }
146