fix awdw solo vicon crash, fix nested clip for binfolders, open edit edl
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / scopewindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef SCOPEWINDOW_H
22 #define SCOPEWINDOW_H
23
24
25 #include "boxblur.inc"
26 #include "guicast.h"
27 #include "loadbalance.h"
28 #include "mwindow.h"
29 #include "overlayframe.inc"
30 #include "pluginclient.h"
31 #include "recordmonitor.inc"
32 #include "scopewindow.inc"
33 #include "theme.inc"
34
35 enum {
36         SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
37         SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
38         SCOPE_VECTORSCOPE, SCOPE_VECTORWHEEL,
39         SCOPE_SMOOTH, SCOPE_REFRESH, SCOPE_RELEASE,
40 };
41
42 // Number of divisions in histogram.
43 // 65536 + min and max range to speed up the tabulation
44 #define TOTAL_BINS 0x13333
45 #define HIST_SECTIONS 4
46 #define FLOAT_RANGE 1.2
47 // Minimum value in percentage
48 #define HISTOGRAM_MIN -10
49 #define FLOAT_MIN -0.1
50 // Maximum value in percentage
51 #define HISTOGRAM_MAX 110
52 #define FLOAT_MAX 1.1
53
54 #define MIN_SCOPE_W xS(320)
55 #define MIN_SCOPE_H yS(320)
56
57
58 #define WAVEFORM_DIVISIONS 12
59 #define VECTORSCOPE_DIVISIONS 11
60
61 class ScopePackage : public LoadPackage
62 {
63 public:
64         ScopePackage();
65         int row1, row2;
66 };
67
68
69 class ScopeUnit : public LoadClient
70 {
71 public:
72         ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
73         void process_package(LoadPackage *package);
74         int bins[HIST_SECTIONS][TOTAL_BINS];
75         ScopeGUI *gui;
76 };
77
78 class ScopeEngine : public LoadServer
79 {
80 public:
81         ScopeEngine(ScopeGUI *gui, int cpus);
82         virtual ~ScopeEngine();
83         void init_packages();
84         LoadClient* new_client();
85         LoadPackage* new_package();
86         void process();
87         ScopeGUI *gui;
88 };
89
90 class ScopePanel : public BC_SubWindow
91 {
92 public:
93         ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
94         void create_objects();
95         virtual void update_point(int x, int y);
96         virtual void draw_point();
97         virtual void clear_point();
98         int button_press_event();
99         int cursor_motion_event();
100         int button_release_event();
101         int is_dragging;
102         ScopeGUI *gui;
103 };
104
105 class ScopeWaveform : public ScopePanel
106 {
107 public:
108         ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
109         virtual void update_point(int x, int y);
110         virtual void draw_point();
111         virtual void clear_point();
112         int drag_x;
113         int drag_y;
114 };
115
116
117 class ScopeVectorscope : public ScopePanel
118 {
119 public:
120         ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
121         virtual void update_point(int x, int y);
122         virtual void draw_point();
123         virtual void clear_point();
124         void draw_point(float th, float r, int color);
125         void draw_radient(float th, float r1, float r2, int color);
126
127         int drag_radius;
128         float drag_angle;
129 };
130
131 class ScopeHistogram : public ScopePanel
132 {
133 public:
134         ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
135         void clear_point();
136         void update_point(int x, int y);
137         void draw_point();
138         void draw(int flash, int flush);
139         void draw_mode(int mode, int color, int y, int h);
140         int drag_x;
141 };
142
143
144 class ScopeScopesOn : public BC_MenuItem
145 {
146 public:
147         ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
148         int handle_event();
149
150         ScopeMenu *scope_menu;
151         int id;
152 };
153
154 class ScopeMenu : public BC_PopupMenu
155 {
156 public:
157         ScopeMenu(ScopeGUI *gui, int x, int y);
158         void create_objects();
159         void update_toggles();
160
161         ScopeGUI *gui;
162         ScopeScopesOn *hist_on;
163         ScopeScopesOn *hist_rgb_on;
164         ScopeScopesOn *wave_on;
165         ScopeScopesOn *wave_rgb_on;
166         ScopeScopesOn *wave_ply_on;
167         ScopeScopesOn *vect_on;
168         ScopeScopesOn *vect_wheel;
169 };
170
171 class ScopeSettingOn : public BC_MenuItem
172 {
173 public:
174         ScopeSettingOn(ScopeSettings *settings, const char *text, int id);
175         int handle_event();
176
177         ScopeSettings *settings;
178         int id;
179 };
180
181 class ScopeGratPaths : public ArrayList<const char *>
182 {
183 public:
184         ScopeGratPaths() { set_array_delete(); }
185         ~ScopeGratPaths() { remove_all_objects(); }
186 };
187
188 class ScopeGratItem : public BC_MenuItem
189 {
190 public:
191         ScopeGratItem(ScopeSettings *settings, const char *text, int idx);
192         int handle_event();
193
194         ScopeSettings *settings;
195         int idx;
196 };
197
198 class ScopeSettings : public BC_PopupMenu
199 {
200 public:
201         ScopeSettings(ScopeGUI *gui, int x, int y);
202         void create_objects();
203         void update_toggles();
204
205         ScopeGUI *gui;
206         ScopeSettingOn *smooth_on;
207         ScopeSettingOn *refresh_on;
208         ScopeSettingOn *release_on;
209 };
210
211
212 class ScopeGainReset : public BC_Button
213 {
214 public:
215         ScopeGainReset(ScopeGain *gain, int x, int y);
216         static int calculate_w(BC_Theme *theme);
217         int handle_event();
218
219         ScopeGain *gain;
220 };
221
222 class ScopeGainSlider : public BC_ISlider
223 {
224 public:
225         ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
226
227         int handle_event();
228         ScopeGain *gain;
229 };
230
231 class ScopeGain
232 {
233 public:
234         ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
235         ~ScopeGain();
236         static int calculate_h();
237         void create_objects();
238         void reposition_window(int x, int y);
239         int handle_event();
240
241         ScopeGUI *gui;
242         int x, y, w, *value;
243         int reset_w;
244         ScopeGainReset *reset;
245         ScopeGainSlider *slider;
246
247         int get_x() { return x; }
248         int get_y() { return y; }
249         int get_w() { return w; }
250         int get_h() { return calculate_h(); }
251 };
252
253 class ScopeWaveSlider : public ScopeGain
254 {
255 public:
256         ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
257 };
258
259 class ScopeVectSlider : public ScopeGain
260 {
261 public:
262         ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
263 };
264
265
266 class ScopeGUI : public PluginClientWindow
267 {
268 public:
269         ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
270         ScopeGUI(PluginClient *plugin, int w, int h);
271         virtual ~ScopeGUI();
272
273         void reset();
274         virtual void create_objects();
275         void create_panels();
276         virtual int resize_event(int w, int h);
277         virtual int translation_event();
278         virtual void update_scope() {}
279
280 // Called for user storage when toggles change
281         virtual void toggle_event();
282
283 // update toggles
284         void update_toggles();
285         void calculate_sizes(int w, int h);
286         void allocate_vframes();
287         void draw_overlays(int overlays, int borders, int flush);
288         void update_graticule(int idx);
289         void draw_colorwheel(VFrame *dst, int bg_color);
290         void draw_scope();
291         void process(VFrame *output_frame);
292         void draw(int flash, int flush);
293         void clear_points(int flash);
294
295         Theme *theme;
296         VFrame *output_frame;
297         VFrame *data_frame, *temp_frame;
298         ScopeEngine *engine;
299         BoxBlur *box_blur;
300         VFrame *waveform_vframe;
301         VFrame *vector_vframe;
302         VFrame *wheel_vframe;
303         ScopeHistogram *histogram;
304         ScopeWaveform *waveform;
305         ScopeVectorscope *vectorscope;
306         ScopeMenu *scope_menu;
307         ScopeWaveSlider *wave_slider;
308         ScopeVectSlider *vect_slider;
309         ScopeSettings *settings;
310         VFrame *grat_image;
311         OverlayFrame *overlay;
312
313         int x, y, w, h;
314         int vector_x, vector_y, vector_w, vector_h;
315         int vector_cx, vector_cy, radius;
316         int wave_x, wave_y, wave_w, wave_h;
317         int hist_x, hist_y, hist_w, hist_h;
318         int text_color, dark_color;
319
320         ScopeGratPaths grat_paths;
321         int grat_idx, use_graticule;
322
323         int cpus;
324         int use_hist, use_wave, use_vector;
325         int use_hist_parade, use_wave_parade;
326
327         int bins[HIST_SECTIONS][TOTAL_BINS];
328         int frame_w, use_smooth;
329         int use_refresh, use_release;
330         int use_wave_gain, use_vect_gain;
331 };
332
333 #endif