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