add new boxblur plugin, mods to videoscope, fix segv for menu btns kfrm-tweak/kfrm...
[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 "pluginclient.h"
30 #include "recordmonitor.inc"
31 #include "scopewindow.inc"
32 #include "theme.inc"
33
34 enum {
35         SCOPE_HISTOGRAM, SCOPE_HISTOGRAM_RGB,
36         SCOPE_WAVEFORM, SCOPE_WAVEFORM_RGB, SCOPE_WAVEFORM_PLY,
37         SCOPE_VECTORSCOPE,
38 };
39
40 // Number of divisions in histogram.
41 // 65536 + min and max range to speed up the tabulation
42 #define TOTAL_BINS 0x13333
43 #define HIST_SECTIONS 4
44 #define FLOAT_RANGE 1.2
45 // Minimum value in percentage
46 #define HISTOGRAM_MIN -10
47 #define FLOAT_MIN -0.1
48 // Maximum value in percentage
49 #define HISTOGRAM_MAX 110
50 #define FLOAT_MAX 1.1
51
52 #define MIN_SCOPE_W xS(640)
53 #define MIN_SCOPE_H yS(320)
54
55
56 #define WAVEFORM_DIVISIONS 12
57 #define VECTORSCOPE_DIVISIONS 11
58
59 class ScopePackage : public LoadPackage
60 {
61 public:
62         ScopePackage();
63         int row1, row2;
64 };
65
66
67 class ScopeUnit : public LoadClient
68 {
69 public:
70         ScopeUnit(ScopeGUI *gui, ScopeEngine *server);
71         void process_package(LoadPackage *package);
72         int bins[HIST_SECTIONS][TOTAL_BINS];
73         ScopeGUI *gui;
74 };
75
76 class ScopeEngine : public LoadServer
77 {
78 public:
79         ScopeEngine(ScopeGUI *gui, int cpus);
80         virtual ~ScopeEngine();
81         void init_packages();
82         LoadClient* new_client();
83         LoadPackage* new_package();
84         void process();
85         ScopeGUI *gui;
86 };
87
88 class ScopePanel : public BC_SubWindow
89 {
90 public:
91         ScopePanel(ScopeGUI *gui, int x, int y, int w, int h);
92         void create_objects();
93         virtual void update_point(int x, int y);
94         virtual void draw_point();
95         virtual void clear_point();
96         int button_press_event();
97         int cursor_motion_event();
98         int button_release_event();
99         int is_dragging;
100         ScopeGUI *gui;
101 };
102
103 class ScopeWaveform : public ScopePanel
104 {
105 public:
106         ScopeWaveform(ScopeGUI *gui, int x, int y, int w, int h);
107         virtual void update_point(int x, int y);
108         virtual void draw_point();
109         virtual void clear_point();
110         int drag_x;
111         int drag_y;
112 };
113
114
115 class ScopeVectorscope : public ScopePanel
116 {
117 public:
118         ScopeVectorscope(ScopeGUI *gui, int x, int y, int w, int h);
119         virtual void update_point(int x, int y);
120         virtual void draw_point();
121         virtual void clear_point();
122         int drag_radius;
123         float drag_angle;
124 };
125
126 class ScopeHistogram : public ScopePanel
127 {
128 public:
129         ScopeHistogram(ScopeGUI *gui, int x, int y, int w, int h);
130         void clear_point();
131         void update_point(int x, int y);
132         void draw_point();
133         void draw(int flash, int flush);
134         void draw_mode(int mode, int color, int y, int h);
135         int drag_x;
136 };
137
138
139 class ScopeScopesOn : public BC_MenuItem
140 {
141 public:
142         ScopeScopesOn(ScopeMenu *scope_menu, const char *text, int id);
143         int handle_event();
144
145         ScopeMenu *scope_menu;
146         int id;
147 };
148
149 class ScopeMenu : public BC_PopupMenu
150 {
151 public:
152         ScopeMenu(ScopeGUI *gui, int x, int y);
153         void create_objects();
154         void update_toggles();
155
156         ScopeGUI *gui;
157         ScopeScopesOn *hist_on;
158         ScopeScopesOn *hist_rgb_on;
159         ScopeScopesOn *wave_on;
160         ScopeScopesOn *wave_rgb_on;
161         ScopeScopesOn *wave_ply_on;
162         ScopeScopesOn *vect_on;
163 };
164
165
166 class ScopeGainReset : public BC_Button
167 {
168 public:
169         ScopeGainReset(ScopeGain *gain, int x, int y);
170         static int calculate_w(BC_Theme *theme);
171         int handle_event();
172
173         ScopeGain *gain;
174 };
175
176 class ScopeGainSlider : public BC_ISlider
177 {
178 public:
179         ScopeGainSlider(ScopeGain *gain, int x, int y, int w);
180
181         int handle_event();
182         ScopeGain *gain;
183 };
184
185 class ScopeGain
186 {
187 public:
188         ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value);
189         ~ScopeGain();
190         static int calculate_h();
191         void create_objects();
192         void reposition_window(int x, int y);
193         int handle_event();
194
195         ScopeGUI *gui;
196         int x, y, w, *value;
197         int reset_w;
198         ScopeGainReset *reset;
199         ScopeGainSlider *slider;
200
201         int get_x() { return x; }
202         int get_y() { return y; }
203         int get_w() { return w; }
204         int get_h() { return calculate_h(); }
205 };
206
207 class ScopeWaveSlider : public ScopeGain
208 {
209 public:
210         ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w);
211 };
212
213 class ScopeVectSlider : public ScopeGain
214 {
215 public:
216         ScopeVectSlider(ScopeGUI *gui, int x, int y, int w);
217 };
218
219
220 class ScopeSmooth : public BC_CheckBox
221 {
222 public:
223         ScopeSmooth(ScopeGUI *gui, int x, int y);
224         int handle_event();
225         ScopeGUI *gui;
226 };
227
228
229 class ScopeGUI : public PluginClientWindow
230 {
231 public:
232         ScopeGUI(Theme *theme, int x, int y, int w, int h, int cpus);
233         ScopeGUI(PluginClient *plugin, int w, int h);
234         virtual ~ScopeGUI();
235
236         void reset();
237         virtual void create_objects();
238         void create_panels();
239         virtual int resize_event(int w, int h);
240         virtual int translation_event();
241         virtual void update_scope() {}
242
243 // Called for user storage when toggles change
244         virtual void toggle_event();
245
246 // update toggles
247         void update_toggles();
248         void calculate_sizes(int w, int h);
249         void allocate_vframes();
250         void draw_overlays(int overlays, int borders, int flush);
251         void process(VFrame *output_frame);
252         void draw(int flash, int flush);
253         void clear_points(int flash);
254
255         Theme *theme;
256         VFrame *output_frame;
257         VFrame *data_frame, *temp_frame;
258         ScopeEngine *engine;
259         BoxBlur *box_blur;
260         VFrame *waveform_vframe;
261         VFrame *vector_vframe;
262         ScopeHistogram *histogram;
263         ScopeWaveform *waveform;
264         ScopeVectorscope *vectorscope;
265         ScopeMenu *scope_menu;
266         ScopeWaveSlider *wave_slider;
267         ScopeVectSlider *vect_slider;
268         ScopeSmooth *smooth;
269         BC_Title *value_text;
270
271         int x, y, w, h;
272         int vector_x, vector_y, vector_w, vector_h;
273         int wave_x, wave_y, wave_w, wave_h;
274         int hist_x, hist_y, hist_w, hist_h;
275
276         int cpus;
277         int use_hist, use_wave, use_vector;
278         int use_hist_parade, use_wave_parade;
279
280         int bins[HIST_SECTIONS][TOTAL_BINS];
281         int frame_w, use_smooth;
282         int use_wave_gain, use_vect_gain;
283 };
284
285 #endif