remove whitespace at eol
[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 "cicolors.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 ColorThread
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 ColorThread
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
206         GradientMain *plugin;
207         BC_Title *angle_title;
208         GradientAngle *angle;
209         GradientInRadius *in_radius;
210         GradientOutRadius *out_radius;
211         GradientInColorButton *in_color;
212         GradientOutColorButton *out_color;
213         GradientInColorThread *in_color_thread;
214         GradientOutColorThread *out_color_thread;
215         GradientShape *shape;
216         BC_Title *shape_title;
217         GradientCenterX *center_x;
218         BC_Title *center_x_title;
219         BC_Title *center_y_title;
220         GradientCenterY *center_y;
221         GradientRate *rate;
222         int in_color_x, in_color_y;
223         int out_color_x, out_color_y;
224         int shape_x, shape_y;
225 };
226
227
228
229
230
231
232
233 class GradientMain : public PluginVClient
234 {
235 public:
236         GradientMain(PluginServer *server);
237         ~GradientMain();
238
239         int process_buffer(VFrame *frame,
240                 int64_t start_position,
241                 double frame_rate);
242         int is_realtime();
243         void save_data(KeyFrame *keyframe);
244         void read_data(KeyFrame *keyframe);
245         void update_gui();
246         int is_synthesis();
247         int handle_opengl();
248
249         PLUGIN_CLASS_MEMBERS(GradientConfig)
250
251         int need_reconfigure;
252
253         OverlayFrame *overlayer;
254         VFrame *gradient;
255         VFrame *input, *output;
256         GradientServer *engine;
257 };
258
259 class GradientPackage : public LoadPackage
260 {
261 public:
262         GradientPackage();
263         int y1;
264         int y2;
265 };
266
267 class GradientUnit : public LoadClient
268 {
269 public:
270         GradientUnit(GradientServer *server, GradientMain *plugin);
271         void process_package(LoadPackage *package);
272         GradientServer *server;
273         GradientMain *plugin;
274         YUV yuv;
275 };
276
277 class GradientServer : public LoadServer
278 {
279 public:
280         GradientServer(GradientMain *plugin, int total_clients, int total_packages);
281         void init_packages();
282         LoadClient* new_client();
283         LoadPackage* new_package();
284         GradientMain *plugin;
285 };
286
287
288
289 #endif