add missing GPL information in guicast program files
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginpopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "language.h"
23 #include "mainundo.h"
24 #include "mwindow.h"
25 #include "mwindowgui.h"
26 #include "plugin.h"
27 #include "plugindialog.h"
28 #include "pluginpopup.h"
29 //#include "presets.h"
30 //#include "presetsgui.h"
31 #include "track.h"
32
33
34
35 PluginPopup::PluginPopup(MWindow *mwindow, MWindowGUI *gui)
36  : BC_PopupMenu(0,
37                 0,
38                 0,
39                 "",
40                 0)
41 {
42         this->mwindow = mwindow;
43         this->gui = gui;
44         show = 0;
45         presets = 0;
46 #if 0
47         thread = new PresetsThread(mwindow);
48 #endif
49 }
50
51 PluginPopup::~PluginPopup()
52 {
53 }
54
55 void PluginPopup::create_objects()
56 {
57         add_item(change = new PluginPopupChange(mwindow, this));
58         add_item(detach = new PluginPopupDetach(mwindow, this));
59         add_item(new PluginPopupUp(mwindow, this));
60         add_item(new PluginPopupDown(mwindow, this));
61         add_item(on = new PluginPopupOn(mwindow, this));
62 }
63
64 int PluginPopup::update(Plugin *plugin)
65 {
66         if(show) remove_item(show);
67         if(presets) remove_item(presets);
68         show = 0;
69         presets = 0;
70
71         if(plugin->plugin_type == PLUGIN_STANDALONE)
72         {
73                 add_item(show = new PluginPopupShow(mwindow, this));
74                 add_item(presets = new PluginPresets(mwindow, this));
75                 show->set_checked(plugin->show);
76         }
77
78         on->set_checked(plugin->on);
79         this->plugin = plugin;
80         return 0;
81 }
82
83
84
85
86
87
88
89
90
91 PluginPopupChange::PluginPopupChange(MWindow *mwindow, PluginPopup *popup)
92  : BC_MenuItem(_("Change..."))
93 {
94         this->mwindow = mwindow;
95         this->popup = popup;
96         dialog_thread = new PluginDialogThread(mwindow);
97 }
98
99 PluginPopupChange::~PluginPopupChange()
100 {
101         delete dialog_thread;
102 }
103
104 int PluginPopupChange::handle_event()
105 {
106         dialog_thread->start_window(popup->plugin->track,
107                 popup->plugin,
108                 _(PROGRAM_NAME ": Change Effect"),
109                 0,
110                 popup->plugin->track->data_type);
111         return 1;
112 }
113
114
115
116
117
118
119
120
121 PluginPopupDetach::PluginPopupDetach(MWindow *mwindow, PluginPopup *popup)
122  : BC_MenuItem(_("Detach"))
123 {
124         this->mwindow = mwindow;
125         this->popup = popup;
126 }
127
128 PluginPopupDetach::~PluginPopupDetach()
129 {
130 }
131
132 int PluginPopupDetach::handle_event()
133 {
134         mwindow->undo->update_undo_before();
135         mwindow->hide_plugin(popup->plugin, 1);
136         mwindow->hide_keyframe_gui(popup->plugin);
137         popup->plugin->track->detach_effect(popup->plugin);
138         mwindow->save_backup();
139         mwindow->undo->update_undo_after(_("detach effect"), LOAD_ALL);
140
141
142         mwindow->gui->lock_window("PluginPopupDetach::handle_event");
143         mwindow->gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
144         mwindow->gui->unlock_window();
145         mwindow->restart_brender();
146         mwindow->sync_parameters(CHANGE_EDL);
147         return 1;
148 }
149
150
151
152
153
154
155
156 PluginPopupIn::PluginPopupIn(MWindow *mwindow, PluginPopup *popup)
157  : BC_MenuItem(_("Send"))
158 {
159         this->mwindow = mwindow;
160         this->popup = popup;
161 }
162
163 PluginPopupIn::~PluginPopupIn()
164 {
165 }
166
167 int PluginPopupIn::handle_event()
168 {
169         popup->plugin->in = !get_checked();
170         mwindow->sync_parameters(CHANGE_EDL);
171         return 1;
172 }
173
174
175
176
177
178 PluginPopupOut::PluginPopupOut(MWindow *mwindow, PluginPopup *popup)
179  : BC_MenuItem(_("Receive"))
180 {
181         this->mwindow = mwindow;
182         this->popup = popup;
183 }
184
185 PluginPopupOut::~PluginPopupOut()
186 {
187 }
188
189 int PluginPopupOut::handle_event()
190 {
191         popup->plugin->out = !get_checked();
192         mwindow->sync_parameters(CHANGE_EDL);
193         return 1;
194 }
195
196
197
198
199
200 PluginPopupShow::PluginPopupShow(MWindow *mwindow, PluginPopup *popup)
201  : BC_MenuItem(_("Show"))
202 {
203         this->mwindow = mwindow;
204         this->popup = popup;
205 }
206
207 PluginPopupShow::~PluginPopupShow()
208 {
209 }
210
211 int PluginPopupShow::handle_event()
212 {
213         mwindow->show_plugin(popup->plugin);
214         mwindow->gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
215         return 1;
216 }
217
218
219
220
221 PluginPopupOn::PluginPopupOn(MWindow *mwindow, PluginPopup *popup)
222  : BC_MenuItem(_("On"))
223 {
224         this->mwindow = mwindow;
225         this->popup = popup;
226 }
227
228 PluginPopupOn::~PluginPopupOn()
229 {
230 }
231
232 int PluginPopupOn::handle_event()
233 {
234         popup->plugin->on = !get_checked();
235         mwindow->gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
236         mwindow->restart_brender();
237         mwindow->sync_parameters(CHANGE_EDL);
238         return 1;
239 }
240
241
242 PluginPopupUp::PluginPopupUp(MWindow *mwindow, PluginPopup *popup)
243  : BC_MenuItem(_("Move up"))
244 {
245         this->mwindow = mwindow;
246         this->popup = popup;
247 }
248
249 int PluginPopupUp::handle_event()
250 {
251         mwindow->move_plugins_up(popup->plugin->plugin_set);
252         return 1;
253 }
254
255
256
257 PluginPopupDown::PluginPopupDown(MWindow *mwindow, PluginPopup *popup)
258  : BC_MenuItem(_("Move down"))
259 {
260         this->mwindow = mwindow;
261         this->popup = popup;
262 }
263
264 int PluginPopupDown::handle_event()
265 {
266         mwindow->move_plugins_down(popup->plugin->plugin_set);
267         return 1;
268 }
269
270
271
272 PluginPresets::PluginPresets(MWindow *mwindow, PluginPopup *popup)
273  : BC_MenuItem(_("Presets..."))
274 {
275         this->mwindow = mwindow;
276         this->popup = popup;
277 }
278
279 int PluginPresets::handle_event()
280 {
281         mwindow->show_keyframe_gui(popup->plugin);
282 #if 0
283         popup->thread->start_window(popup->plugin);
284 #endif
285         return 1;
286 }
287