f9f67c59bccfd7bc64b32499d3a6c9df4c945a32
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / shapewipe / shapewipe.h
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 #ifndef SHAPEWIPE_H
23 #define SHAPEWIPE_H
24
25 class ShapeWipeConfig;
26 class ShapeWipeMain;
27 class ShapeWipeWindow;
28 class ShapeWipeW2B;
29 class ShapeWipeB2W;
30 class ShapeWipeTumble;
31 class ShapeWipeFeather;
32 class ShapeWipeFSlider;
33 class ShapeWipeReset;
34 class ShapeWipeShape;
35 class ShapeWipePreserveAspectRatio;
36 class ShapePackage;
37 class ShapeUnit;
38 class ShapeEngine;
39
40 #include "overlayframe.inc"
41 #include "pluginvclient.h"
42 #include "vframe.inc"
43
44 class ShapeWipeW2B : public BC_Radial
45 {
46 public:
47         ShapeWipeW2B(ShapeWipeMain *plugin,
48                 ShapeWipeWindow *window,
49                 int x,
50                 int y);
51         int handle_event();
52         ShapeWipeMain *plugin;
53         ShapeWipeWindow *window;
54 };
55
56 class ShapeWipeB2W : public BC_Radial
57 {
58 public:
59         ShapeWipeB2W(ShapeWipeMain *plugin,
60                 ShapeWipeWindow *window,
61                 int x,
62                 int y);
63         int handle_event();
64         ShapeWipeMain *plugin;
65         ShapeWipeWindow *window;
66 };
67
68
69 class ShapeWipeTumble : public BC_Tumbler
70 {
71 public:
72         ShapeWipeTumble(ShapeWipeMain *client,
73                 ShapeWipeWindow *window,
74                 int x,
75                 int y);
76
77         int handle_up_event();
78         int handle_down_event();
79
80         ShapeWipeMain *client;
81         ShapeWipeWindow *window;
82 };
83
84 class ShapeWipeFeather : public BC_TumbleTextBox
85 {
86 public:
87         ShapeWipeFeather(ShapeWipeMain *client,
88                 ShapeWipeWindow *window, int x, int y);
89         int handle_event();
90
91         ShapeWipeMain *client;
92         ShapeWipeWindow *window;
93 };
94
95 class ShapeWipeFSlider : public BC_FSlider
96 {
97 public:
98         ShapeWipeFSlider(ShapeWipeMain *client,
99                 ShapeWipeWindow *window, int x, int y, int w);
100         int handle_event();
101
102         ShapeWipeMain *client;
103         ShapeWipeWindow *window;
104 };
105
106 class ShapeWipeReset : public BC_Button
107 {
108 public:
109         ShapeWipeReset(ShapeWipeMain *client,
110                 ShapeWipeWindow *window, int x, int y);
111         int handle_event();
112         static int calculate_w(ShapeWipeMain *client);
113
114         ShapeWipeMain *client;
115         ShapeWipeWindow *window;
116 };
117
118 class ShapeWipeShape : public BC_PopupTextBox
119 {
120 public:
121         ShapeWipeShape(ShapeWipeMain *client, ShapeWipeWindow *window,
122                 int x, int y, int text_w, int list_h);
123         int handle_event();
124         ShapeWipeMain *client;
125         ShapeWipeWindow *window;
126 };
127
128 class ShapeWipePreserveAspectRatio : public BC_CheckBox
129 {
130 public:
131         ShapeWipePreserveAspectRatio(ShapeWipeMain *plugin,
132                 ShapeWipeWindow *window,
133                 int x,
134                 int y);
135         int handle_event();
136         ShapeWipeMain *plugin;
137         ShapeWipeWindow *window;
138 };
139
140
141 class ShapeWipeWindow : public PluginClientWindow
142 {
143 public:
144         ShapeWipeWindow(ShapeWipeMain *plugin);
145         ~ShapeWipeWindow();
146         void create_objects();
147         void next_shape();
148         void prev_shape();
149
150         ShapeWipeMain *plugin;
151         ShapeWipeW2B *left;
152         ShapeWipeB2W *right;
153         ShapeWipeTumble *shape_tumbler;
154         ShapeWipeShape *shape_text;
155         ShapeWipeFeather *shape_feather;
156         ShapeWipeFSlider *shape_fslider;
157         ShapeWipeReset *shape_reset;
158         ArrayList<BC_ListBoxItem*> shapes;
159 };
160
161 class ShapeWipeConfig
162 {
163 public:
164         ShapeWipeConfig();
165         ~ShapeWipeConfig();
166         void read_xml(KeyFrame *keyframe);
167         void save_xml(KeyFrame *keyframe);
168
169         int direction;
170         float feather;
171         int preserve_aspect;
172         char shape_name[BCTEXTLEN];
173 };
174
175 class ShapeWipeMain : public PluginVClient
176 {
177 public:
178         ShapeWipeMain(PluginServer *server);
179         ~ShapeWipeMain();
180
181         PLUGIN_CLASS_MEMBERS(ShapeWipeConfig)
182         int process_realtime(VFrame *input, VFrame *output);
183         int uses_gui();
184         int is_transition();
185         void read_data(KeyFrame *keyframe);
186         void save_data(KeyFrame *keyframe);
187
188         int read_pattern_image(char *shape_name,
189                 int new_frame_width, int new_frame_height);
190         void reset_pattern_image();
191         void init_shapes();
192
193         VFrame *input, *output;
194         ShapeEngine *engine;
195         ArrayList<char*> shape_paths;
196         ArrayList<char*> shape_titles;
197
198         int shapes_initialized;
199         int threshold;
200         char current_filename[BCTEXTLEN];
201         char current_name[BCTEXTLEN];
202         unsigned char **pattern_image;
203         unsigned char min_value;
204         unsigned char max_value;
205         int frame_width;
206         int frame_height;
207         int preserve_aspect;
208         int last_preserve_aspect;
209 };
210
211
212 class ShapePackage : public LoadPackage
213 {
214 public:
215         ShapePackage();
216         int y1, y2;
217 };
218
219 class ShapeUnit : public LoadClient
220 {
221 public:
222         ShapeUnit(ShapeEngine *server);
223         ~ShapeUnit();
224         void process_package(LoadPackage *package);
225         ShapeEngine *server;
226         unsigned char threshold;
227 };
228
229 class ShapeEngine : public LoadServer
230 {
231 public:
232         ShapeEngine(ShapeWipeMain *plugin,
233                 int total_clients, int total_packages);
234         ~ShapeEngine();
235
236         void init_packages();
237         LoadClient *new_client();
238         LoadPackage *new_package();
239         ShapeWipeMain *plugin;
240 };
241
242 #endif