refresh frame fix, dblclk proxy viewer fix, vicon refresh fix for awdw resize, fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / canvas.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 CANVAS_H
23 #define CANVAS_H
24
25 #include "edl.inc"
26 #include "guicast.h"
27 #include "mwindow.inc"
28 #include "videodevice.inc"
29
30 // Output for all X11 video
31
32 class CanvasOutput;
33 class CanvasFullScreen;
34 class CanvasXScroll;
35 class CanvasYScroll;
36 class CanvasPopup;
37 class CanvasFullScreenPopup;
38 class CanvasToggleControls;
39
40 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
41 class Canvas
42 {
43 public:
44         Canvas(MWindow *mwindow,
45                 BC_WindowBase *subwindow,
46                 int x,
47                 int y,
48                 int w,
49                 int h,
50                 int output_w,
51                 int output_h,
52                 int use_scrollbars);
53         virtual ~Canvas();
54
55         void reset();
56 // Get dimensions given a zoom
57         void calculate_sizes(float aspect_ratio,
58                 int output_w,
59                 int output_h,
60                 float zoom,
61                 int &w,
62                 int &h);
63 // Lock access to the canvas pointer.
64 // Must be called before get_canvas or locking the canvas.
65         void lock_canvas(const char *location);
66         void unlock_canvas();
67         int is_locked();
68
69         void create_objects(EDL *edl);
70         void set_cursor(int cursor);
71 // Start video playback
72         void start_video();
73         void stop_video();
74
75 // Start single frame processing.  Causes the status indicator to update
76         void start_single();
77         void stop_single();
78
79         void start_fullscreen();
80         void stop_fullscreen();
81
82 // Don't call from inside the canvas
83         void create_canvas();
84
85
86
87 // Processing or video playback changed.
88         virtual void status_event() {};
89
90
91         virtual void reset_camera() {};
92         virtual void reset_projector() {};
93         virtual void zoom_resize_window(float percentage) {};
94         virtual void zoom_auto() {};
95         virtual int cursor_leave_event() { return 0; };
96         virtual int cursor_enter_event() { return 0; };
97         virtual int button_release_event() { return 0; };
98         virtual int button_press_event();
99         virtual int cursor_motion_event() { return 0; };
100         virtual void draw_overlays() { };
101         virtual void toggle_controls() { } ;
102         virtual int get_cwindow_controls() { return 0; };
103         virtual int get_fullscreen() { return 0; }
104         virtual void set_fullscreen(int value) { };
105
106         int cursor_leave_event_base(BC_WindowBase *caller);
107         int cursor_enter_event_base(BC_WindowBase *caller);
108         int button_press_event_base(BC_WindowBase *caller);
109         int keypress_event(BC_WindowBase *caller);
110 // Use menu different options for different windows
111         void use_cwindow();
112         void use_rwindow();
113         void use_vwindow();
114         void use_auxwindow(BC_WindowBase *aux);
115
116 // Provide canvas dimensions since a BC_Bitmap containing obsolete dimensions
117 // is often the output being transferred to.
118 // This gets the input coordinates on the device output_frame
119 // and the corresponding output coordinates on the canvas.
120 // Must be floating point to support OpenGL.
121         void get_transfers(EDL *edl,
122                 float &output_x1,
123                 float &output_y1,
124                 float &output_x2,
125                 float &output_y2,
126                 float &canvas_x1,
127                 float &canvas_y1,
128                 float &canvas_x2,
129                 float &canvas_y2,
130 // passing -1 causes automatic size detection
131                 int canvas_w = -1,
132                 int canvas_h = -1);
133         void reposition_window(EDL *edl, int x, int y, int w, int h);
134         virtual void reset_translation() {};
135         virtual void close_source() {};
136 // Updates the stores
137         virtual void update_zoom(int x, int y, float zoom) {};
138         void check_boundaries(EDL *edl, int &x, int &y, float &zoom);
139         void update_scrollbars(int flush);
140 // Get scrollbar positions relative to output.
141 // No correction is done if output is smaller than canvas
142         virtual int get_xscroll() { return 0; };
143         virtual int get_yscroll() { return 0; };
144         virtual float get_zoom() { return 0; };
145 // Updates the refresh_frame
146         void update_refresh(VideoDevice *device, VFrame *output_frame);
147 // Redraws the refresh_frame
148         virtual void draw_refresh(int flush = 1) {};
149         virtual void clear(int flush=1);
150
151 // Get top left offset of canvas relative to output.
152 // Normally negative.  Can be positive if output is smaller than canvas.
153         float get_x_offset(EDL *edl,
154                 int single_channel,
155                 float zoom_x,
156                 float conformed_w,
157                 float conformed_h);
158         float get_y_offset(EDL *edl,
159                 int single_channel,
160                 float zoom_y,
161                 float conformed_w,
162                 float conformed_h);
163         void get_zooms(EDL *edl,
164                 int single_channel,
165                 float &zoom_x,
166                 float &zoom_y,
167                 float &conformed_w,
168                 float &conformed_h);
169
170
171 // Convert coord from output to canvas position, including
172 // x and y scroll offsets
173         void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
174 // Convert coord from canvas to output position
175         void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
176
177 // Get dimensions of frame being sent to canvas
178         virtual int get_output_w(EDL *edl);
179         virtual int get_output_h(EDL *edl);
180 // Get if scrollbars exist
181         int scrollbars_exist();
182 // Get cursor locations relative to canvas and not offset by scrollbars
183         int get_cursor_x();
184         int get_cursor_y();
185         int get_buttonpress();
186 // Gets whatever video surface is enabled
187         BC_WindowBase* get_canvas();
188
189 // The owner of the canvas
190         BC_WindowBase *subwindow;
191 // Video surface if a subwindow
192         CanvasOutput *canvas_subwindow;
193 // Video surface if fullscreen
194         CanvasFullScreen *canvas_fullscreen;
195         CanvasXScroll *xscroll;
196         CanvasYScroll *yscroll;
197         CanvasPopup *canvas_menu;
198         CanvasFullScreenPopup *fullscreen_menu;
199         int x, y, w, h;
200         int use_scrollbars;
201         BC_WindowBase *canvas_auxwindow;
202 // Used in record monitor
203         int output_w, output_h;
204 // Last frame played is stored here in driver format for
205 // refreshes.
206         VFrame *refresh_frame;
207 // Results from last get_scrollbars
208         int w_needed;
209         int h_needed;
210         int w_visible;
211         int h_visible;
212 // For cases where video is not enabled on the canvas but processing is
213 // occurring for a single frame, this causes the status to update.
214         int is_processing;
215 // Cursor is inside video surface
216         int cursor_inside;
217         int view_x;
218         int view_y;
219         int view_w;
220         int view_h;
221         int scr_w0;
222         int root_w, root_h;
223
224         MWindow *mwindow;
225
226 private:
227         void get_scrollbars(EDL *edl,
228                 int &canvas_x,
229                 int &canvas_y,
230                 int &canvas_w,
231                 int &canvas_h);
232         Mutex *canvas_lock;
233 };
234
235
236 class CanvasOutput : public BC_SubWindow
237 {
238 public:
239         CanvasOutput(Canvas *canvas,
240         int x,
241         int y,
242         int w,
243         int h);
244         ~CanvasOutput();
245
246         int cursor_leave_event();
247         int cursor_enter_event();
248         int button_press_event();
249         int button_release_event();
250         int cursor_motion_event();
251         int keypress_event();
252
253         Canvas *canvas;
254 };
255
256
257
258
259 class CanvasFullScreen : public BC_FullScreen
260 {
261 public:
262         CanvasFullScreen(Canvas *canvas,
263         int w,
264         int h);
265         ~CanvasFullScreen();
266
267         Canvas *canvas;
268 };
269
270
271
272
273 class CanvasXScroll : public BC_ScrollBar
274 {
275 public:
276         CanvasXScroll(EDL *edl,
277                 Canvas *canvas,
278                 int x,
279                 int y,
280                 int length,
281                 int position,
282                 int handle_length,
283                 int pixels);
284         ~CanvasXScroll();
285
286         int handle_event();
287         Canvas *canvas;
288         EDL *edl;
289 };
290
291 class CanvasYScroll : public BC_ScrollBar
292 {
293 public:
294         CanvasYScroll(EDL *edl,
295                 Canvas *canvas,
296                 int x,
297                 int y,
298                 int length,
299                 int position,
300                 int handle_length,
301                 int pixels);
302         ~CanvasYScroll();
303
304         int handle_event();
305
306         Canvas *canvas;
307         EDL *edl;
308 };
309
310 class CanvasFullScreenPopup : public BC_PopupMenu
311 {
312 public:
313         CanvasFullScreenPopup(Canvas *canvas);
314
315         void create_objects();
316         void use_cwindow();
317
318         Canvas *canvas;
319 };
320
321 class CanvasSubWindowItem : public BC_MenuItem
322 {
323 public:
324         CanvasSubWindowItem(Canvas *canvas);
325         int handle_event();
326         Canvas *canvas;
327 };
328
329 class CanvasPopup : public BC_PopupMenu
330 {
331 public:
332         CanvasPopup(Canvas *canvas);
333         ~CanvasPopup();
334
335         void create_objects();
336         void use_cwindow();
337         void use_rwindow();
338         void use_vwindow();
339
340         Canvas *canvas;
341         CanvasToggleControls *toggle_controls;
342 };
343
344 class CanvasPopupSize : public BC_MenuItem
345 {
346 public:
347         CanvasPopupSize(Canvas *canvas, char *text, float percentage);
348         ~CanvasPopupSize();
349         int handle_event();
350         Canvas *canvas;
351         float percentage;
352 };
353
354 class CanvasPopupAuto : public BC_MenuItem
355 {
356 public:
357         CanvasPopupAuto(Canvas *canvas);
358         int handle_event();
359         Canvas *canvas;
360 };
361
362 class CanvasPopupResetCamera : public BC_MenuItem
363 {
364 public:
365         CanvasPopupResetCamera(Canvas *canvas);
366         int handle_event();
367         Canvas *canvas;
368 };
369
370 class CanvasPopupResetProjector : public BC_MenuItem
371 {
372 public:
373         CanvasPopupResetProjector(Canvas *canvas);
374         int handle_event();
375         Canvas *canvas;
376 };
377
378 class CanvasToggleControls : public BC_MenuItem
379 {
380 public:
381         CanvasToggleControls(Canvas *canvas);
382         int handle_event();
383         static char* calculate_text(int cwindow_controls);
384         Canvas *canvas;
385 };
386
387 class CanvasFullScreenItem : public BC_MenuItem
388 {
389 public:
390         CanvasFullScreenItem(Canvas *canvas);
391         int handle_event();
392         Canvas *canvas;
393 };
394
395 class CanvasPopupResetTranslation : public BC_MenuItem
396 {
397 public:
398         CanvasPopupResetTranslation(Canvas *canvas);
399         int handle_event();
400         Canvas *canvas;
401 };
402
403
404 class CanvasPopupRemoveSource : public BC_MenuItem
405 {
406 public:
407         CanvasPopupRemoveSource(Canvas *canvas);
408         int handle_event();
409         Canvas *canvas;
410 };
411
412
413
414
415
416 #endif