merged hv7 mod
[goodguy/history.git] / cinelerra-5.1 / plugins / gradient / gradient.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 GRADIENT_H
23 #define GRADIENT_H
24
25 class GradientMain;
26 class GradientEngine;
27 class GradientThread;
28 class GradientWindow;
29 class GradientServer;
30
31
32 #define MAXRADIUS 10000
33
34 #include "colorpicker.h"
35 #include "bchash.inc"
36 #include "filexml.inc"
37 #include "guicast.h"
38 #include "loadbalance.h"
39 #include "overlayframe.inc"
40 #include "bccolors.h"
41 #include "pluginvclient.h"
42 #include "thread.h"
43 #include "vframe.inc"
44
45 class GradientConfig
46 {
47 public:
48         GradientConfig();
49
50         int equivalent(GradientConfig &that);
51         void copy_from(GradientConfig &that);
52         void interpolate(GradientConfig &prev,
53                 GradientConfig &next,
54                 long prev_frame,
55                 long next_frame,
56                 long current_frame);
57 // Int to hex triplet conversion
58         int get_in_color();
59         int get_out_color();
60
61 // LINEAR or RADIAL
62         int shape;
63 // LINEAR or LOG or SQUARE
64         int rate;
65         enum
66         {
67                 LINEAR,
68                 RADIAL,
69                 LOG,
70                 SQUARE
71         };
72
73
74         double center_x;
75         double center_y;
76         double angle;
77         double in_radius;
78         double out_radius;
79         int in_r, in_g, in_b, in_a;
80         int out_r, out_g, out_b, out_a;
81 };
82
83
84 class GradientShape : public BC_PopupMenu
85 {
86 public:
87         GradientShape(GradientMain *plugin,
88                 GradientWindow *gui,
89                 int x,
90                 int y);
91         void create_objects();
92         static char* to_text(int shape);
93         static int from_text(char *text);
94         int handle_event();
95         GradientMain *plugin;
96         GradientWindow *gui;
97 };
98
99
100 class GradientRate : public BC_PopupMenu
101 {
102 public:
103         GradientRate(GradientMain *plugin,
104                 int x,
105                 int y);
106         void create_objects();
107         static char* to_text(int shape);
108         static int from_text(char *text);
109         int handle_event();
110         GradientMain *plugin;
111         GradientWindow *gui;
112 };
113
114 class GradientCenterX : public BC_FPot
115 {
116 public:
117         GradientCenterX(GradientMain *plugin, int x, int y);
118         int handle_event();
119         GradientMain *plugin;
120 };
121
122 class GradientCenterY : public BC_FPot
123 {
124 public:
125         GradientCenterY(GradientMain *plugin, int x, int y);
126         int handle_event();
127         GradientMain *plugin;
128 };
129
130 class GradientAngle : public BC_FPot
131 {
132 public:
133         GradientAngle(GradientMain *plugin, int x, int y);
134         int handle_event();
135         GradientMain *plugin;
136 };
137
138 class GradientInRadius : public BC_FSlider
139 {
140 public:
141         GradientInRadius(GradientMain *plugin, int x, int y);
142         int handle_event();
143         GradientMain *plugin;
144 };
145
146 class GradientOutRadius : public BC_FSlider
147 {
148 public:
149         GradientOutRadius(GradientMain *plugin, int x, int y);
150         int handle_event();
151         GradientMain *plugin;
152 };
153
154 class GradientInColorButton : public BC_GenericButton
155 {
156 public:
157         GradientInColorButton(GradientMain *plugin, GradientWindow *window, int x, int y);
158         int handle_event();
159         GradientMain *plugin;
160         GradientWindow *window;
161 };
162
163
164 class GradientOutColorButton : public BC_GenericButton
165 {
166 public:
167         GradientOutColorButton(GradientMain *plugin, GradientWindow *window, int x, int y);
168         int handle_event();
169         GradientMain *plugin;
170         GradientWindow *window;
171 };
172
173
174 class GradientInColorThread : public ColorPicker
175 {
176 public:
177         GradientInColorThread(GradientMain *plugin, GradientWindow *window);
178         virtual int handle_new_color(int output, int alpha);
179         GradientMain *plugin;
180         GradientWindow *window;
181 };
182
183
184 class GradientOutColorThread : public ColorPicker
185 {
186 public:
187         GradientOutColorThread(GradientMain *plugin, GradientWindow *window);
188         virtual int handle_new_color(int output, int alpha);
189         GradientMain *plugin;
190         GradientWindow *window;
191 };
192
193
194
195 class GradientWindow : public PluginClientWindow
196 {
197 public:
198         GradientWindow(GradientMain *plugin);
199         ~GradientWindow();
200
201         void create_objects();
202         void update_in_color();
203         void update_out_color();
204         void update_shape();
205         void done_event(int result);
206
207         GradientMain *plugin;
208         BC_Title *angle_title;
209         GradientAngle *angle;
210         GradientInRadius *in_radius;
211         GradientOutRadius *out_radius;
212         GradientInColorButton *in_color;
213         GradientOutColorButton *out_color;
214         GradientInColorThread *in_color_thread;
215         GradientOutColorThread *out_color_thread;
216         GradientShape *shape;
217         BC_Title *shape_title;
218         GradientCenterX *center_x;
219         BC_Title *center_x_title;
220         BC_Title *center_y_title;
221         GradientCenterY *center_y;
222         GradientRate *rate;
223         int in_color_x, in_color_y;
224         int out_color_x, out_color_y;
225         int shape_x, shape_y;
226 };
227
228
229
230
231
232
233
234 class GradientMain : public PluginVClient
235 {
236 public:
237         GradientMain(PluginServer *server);
238         ~GradientMain();
239
240         int process_buffer(VFrame *frame,
241                 int64_t start_position,
242                 double frame_rate);
243         int is_realtime();
244         void save_data(KeyFrame *keyframe);
245         void read_data(KeyFrame *keyframe);
246         void update_gui();
247         int is_synthesis();
248         int handle_opengl();
249
250         PLUGIN_CLASS_MEMBERS(GradientConfig)
251
252         int need_reconfigure;
253
254         OverlayFrame *overlayer;
255         VFrame *gradient;
256         VFrame *input, *output;
257         GradientServer *engine;
258 };
259
260 class GradientPackage : public LoadPackage
261 {
262 public:
263         GradientPackage();
264         int y1;
265         int y2;
266 };
267
268 class GradientUnit : public LoadClient
269 {
270 public:
271         GradientUnit(GradientServer *server, GradientMain *plugin);
272         void process_package(LoadPackage *package);
273         GradientServer *server;
274         GradientMain *plugin;
275         YUV yuv;
276 };
277
278 class GradientServer : public LoadServer
279 {
280 public:
281         GradientServer(GradientMain *plugin, int total_clients, int total_packages);
282         void init_packages();
283         LoadClient* new_client();
284         LoadPackage* new_package();
285         GradientMain *plugin;
286 };
287
288
289
290 #endif