mask tweaks, focus follows centroid, gradient/colorpicker rework, no hard edges in...
[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 ColorBoxButton
156 {
157 public:
158         GradientInColorButton(GradientMain *plugin, GradientWindow *gui,
159                 int x, int y, int color, int alpha);
160         ~GradientInColorButton();
161
162         int handle_new_color(int color, int alpha);
163         void handle_done_event(int result);
164
165         GradientMain *plugin;
166         GradientWindow *gui;
167         VFrame *vframes[3];
168 };
169
170 class GradientOutColorButton : public ColorBoxButton
171 {
172 public:
173         GradientOutColorButton(GradientMain *plugin, GradientWindow *gui,
174                 int x, int y, int color, int alpha);
175         ~GradientOutColorButton();
176
177         int handle_new_color(int color, int alpha);
178         void handle_done_event(int result);
179
180         GradientMain *plugin;
181         GradientWindow *gui;
182         VFrame *vframes[3];
183 };
184
185 class GradientReset : public BC_GenericButton
186 {
187 public:
188         GradientReset(GradientMain *plugin, GradientWindow *window, int x, int y);
189         int handle_event();
190         GradientMain *plugin;
191         GradientWindow *window;
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_gui();
203         void update_shape();
204         void done_event(int result);
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         GradientReset *reset;
214         GradientShape *shape;
215         BC_Title *shape_title;
216         GradientCenterX *center_x;
217         BC_Title *center_x_title;
218         BC_Title *center_y_title;
219         GradientCenterY *center_y;
220         GradientRate *rate;
221         int shape_x, shape_y;
222 };
223
224
225 class GradientMain : public PluginVClient
226 {
227 public:
228         GradientMain(PluginServer *server);
229         ~GradientMain();
230
231         int process_buffer(VFrame *frame,
232                 int64_t start_position,
233                 double frame_rate);
234         int is_realtime();
235         void save_data(KeyFrame *keyframe);
236         void read_data(KeyFrame *keyframe);
237         void update_gui();
238         int is_synthesis();
239         int handle_opengl();
240
241         PLUGIN_CLASS_MEMBERS(GradientConfig)
242
243         int need_reconfigure;
244
245         OverlayFrame *overlayer;
246         VFrame *gradient;
247         VFrame *input, *output;
248         GradientServer *engine;
249         float gradient_size;
250         uint8_t *table;
251         int table_size;
252 };
253
254 class GradientPackage : public LoadPackage
255 {
256 public:
257         GradientPackage();
258         int y1;
259         int y2;
260 };
261
262 class GradientUnit : public LoadClient
263 {
264 public:
265         GradientUnit(GradientServer *server, GradientMain *plugin);
266         void process_package(LoadPackage *package);
267         GradientServer *server;
268         GradientMain *plugin;
269 };
270
271 class GradientServer : public LoadServer
272 {
273 public:
274         GradientServer(GradientMain *plugin, int total_clients, int total_packages);
275         void init_packages();
276         LoadClient* new_client();
277         LoadPackage* new_package();
278         GradientMain *plugin;
279 };
280
281
282
283 #endif