license header for review
[cinelerra_cv/ct.git] / cinelerra / canvas.h
blob9f98f256bba854a8c553d339854f9c32ee82df91
1 #ifndef CANVAS_H
2 #define CANVAS_H
4 #include "edl.inc"
5 #include "guicast.h"
6 #include "mwindow.inc"
8 // Output for all X11 video
10 class CanvasOutput;
11 class CanvasFullScreen;
12 class CanvasXScroll;
13 class CanvasYScroll;
14 class CanvasPopup;
15 class CanvasFullScreenPopup;
16 class CanvasToggleControls;
18 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
19 class Canvas
21 public:
22 Canvas(MWindow *mwindow,
23 BC_WindowBase *subwindow,
24 int x,
25 int y,
26 int w,
27 int h,
28 int output_w,
29 int output_h,
30 int use_scrollbars,
31 int use_cwindow = 0,
32 int use_rwindow = 0,
33 int use_vwindow = 0); // Use menu different options for different windows
34 virtual ~Canvas();
36 void reset();
37 // Get dimensions given a zoom
38 void calculate_sizes(float aspect_ratio,
39 int output_w,
40 int output_h,
41 float zoom,
42 int &w,
43 int &h);
44 // Lock access to the canvas pointer.
45 // Must be called before get_canvas or locking the canvas.
46 void lock_canvas(char *location);
47 void unlock_canvas();
48 int is_locked();
50 int create_objects(EDL *edl);
51 void set_cursor(int cursor);
52 // Start video playback
53 void start_video();
54 void stop_video();
56 // Start single frame processing. Causes the status indicator to update
57 void start_single();
58 void stop_single();
60 void start_fullscreen();
61 void stop_fullscreen();
63 // Don't call from inside the canvas
64 void create_canvas();
68 // Processing or video playback changed.
69 virtual void status_event() {};
72 virtual void reset_camera() {};
73 virtual void reset_projector() {};
74 virtual void zoom_resize_window(float percentage) {};
75 virtual void zoom_auto() {};
76 virtual int cursor_leave_event() { return 0; };
77 virtual int cursor_enter_event() { return 0; };
78 virtual int button_release_event() { return 0; };
79 virtual int button_press_event();
80 virtual int cursor_motion_event() { return 0; };
81 virtual void draw_overlays() { };
82 virtual void toggle_controls() { } ;
83 virtual int get_cwindow_controls() { return 0; };
84 virtual int get_fullscreen() { return 0; }
85 virtual void set_fullscreen(int value) { };
87 int cursor_leave_event_base(BC_WindowBase *caller);
88 int cursor_enter_event_base(BC_WindowBase *caller);
89 int button_press_event_base(BC_WindowBase *caller);
90 int keypress_event(BC_WindowBase *caller);
94 // Provide canvas dimensions since a BC_Bitmap containing obsolete dimensions
95 // is often the output being transferred to.
96 // This gets the input coordinates on the device output_frame
97 // and the corresponding output coordinates on the canvas.
98 // Must be floating point to support OpenGL.
99 void get_transfers(EDL *edl,
100 float &output_x1,
101 float &output_y1,
102 float &output_x2,
103 float &output_y2,
104 float &canvas_x1,
105 float &canvas_y1,
106 float &canvas_x2,
107 float &canvas_y2,
108 // passing -1 causes automatic size detection
109 int canvas_w = -1,
110 int canvas_h = -1);
111 void reposition_window(EDL *edl, int x, int y, int w, int h);
112 virtual void reset_translation() {};
113 virtual void close_source() {};
114 // Updates the stores
115 virtual void update_zoom(int x, int y, float zoom) {};
116 void check_boundaries(EDL *edl, int &x, int &y, float &zoom);
117 void update_scrollbars();
118 // Get scrollbar positions relative to output.
119 // No correction is done if output is smaller than canvas
120 virtual int get_xscroll() { return 0; };
121 virtual int get_yscroll() { return 0; };
122 virtual float get_zoom() { return 0; };
123 // Redraws the image
124 virtual void draw_refresh() {};
126 // Get top left offset of canvas relative to output.
127 // Normally negative. Can be positive if output is smaller than canvas.
128 float get_x_offset(EDL *edl,
129 int single_channel,
130 float zoom_x,
131 float conformed_w,
132 float conformed_h);
133 float get_y_offset(EDL *edl,
134 int single_channel,
135 float zoom_y,
136 float conformed_w,
137 float conformed_h);
138 void get_zooms(EDL *edl,
139 int single_channel,
140 float &zoom_x,
141 float &zoom_y,
142 float &conformed_w,
143 float &conformed_h);
146 // Convert coord from output to canvas position, including
147 // x and y scroll offsets
148 void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
149 // Convert coord from canvas to output position
150 void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
152 // Get dimensions of frame being sent to canvas
153 virtual int get_output_w(EDL *edl);
154 virtual int get_output_h(EDL *edl);
155 // Get if scrollbars exist
156 int scrollbars_exist();
157 // Get cursor locations relative to canvas and not offset by scrollbars
158 int get_cursor_x();
159 int get_cursor_y();
160 int get_buttonpress();
161 // Gets whatever video surface is enabled
162 BC_WindowBase* get_canvas();
164 // The owner of the canvas
165 BC_WindowBase *subwindow;
166 // Video surface if a subwindow
167 CanvasOutput *canvas_subwindow;
168 // Video surface if fullscreen
169 CanvasFullScreen *canvas_fullscreen;
170 CanvasXScroll *xscroll;
171 CanvasYScroll *yscroll;
172 CanvasPopup *canvas_menu;
173 CanvasFullScreenPopup *fullscreen_menu;
174 int x, y, w, h;
175 int use_scrollbars;
176 int use_cwindow;
177 int use_rwindow;
178 int use_vwindow;
179 // Used in record monitor
180 int output_w, output_h;
181 // Last frame played is stored here in driver format for
182 // refreshes.
183 VFrame *refresh_frame;
184 // Results from last get_scrollbars
185 int w_needed;
186 int h_needed;
187 int w_visible;
188 int h_visible;
189 // For cases where video is not enabled on the canvas but processing is
190 // occurring for a single frame, this causes the status to update.
191 int is_processing;
192 // Cursor is inside video surface
193 int cursor_inside;
194 int view_x;
195 int view_y;
196 int view_w;
197 int view_h;
198 int root_w;
199 int root_h;
201 MWindow *mwindow;
203 private:
204 void get_scrollbars(EDL *edl,
205 int &canvas_x,
206 int &canvas_y,
207 int &canvas_w,
208 int &canvas_h);
209 Mutex *canvas_lock;
213 class CanvasOutput : public BC_SubWindow
215 public:
216 CanvasOutput(Canvas *canvas,
217 int x,
218 int y,
219 int w,
220 int h);
221 ~CanvasOutput();
223 int cursor_leave_event();
224 int cursor_enter_event();
225 int button_press_event();
226 int button_release_event();
227 int cursor_motion_event();
228 int keypress_event();
230 Canvas *canvas;
236 class CanvasFullScreen : public BC_FullScreen
238 public:
239 CanvasFullScreen(Canvas *canvas,
240 int w,
241 int h);
242 ~CanvasFullScreen();
244 Canvas *canvas;
250 class CanvasXScroll : public BC_ScrollBar
252 public:
253 CanvasXScroll(EDL *edl,
254 Canvas *canvas,
255 int x,
256 int y,
257 int length,
258 int position,
259 int handle_length,
260 int pixels);
261 ~CanvasXScroll();
263 int handle_event();
264 Canvas *canvas;
265 EDL *edl;
268 class CanvasYScroll : public BC_ScrollBar
270 public:
271 CanvasYScroll(EDL *edl,
272 Canvas *canvas,
273 int x,
274 int y,
275 int length,
276 int position,
277 int handle_length,
278 int pixels);
279 ~CanvasYScroll();
281 int handle_event();
283 Canvas *canvas;
284 EDL *edl;
287 class CanvasFullScreenPopup : public BC_PopupMenu
289 public:
290 CanvasFullScreenPopup(Canvas *canvas);
292 void create_objects();
294 Canvas *canvas;
297 class CanvasSubWindowItem : public BC_MenuItem
299 public:
300 CanvasSubWindowItem(Canvas *canvas);
301 int handle_event();
302 Canvas *canvas;
305 class CanvasPopup : public BC_PopupMenu
307 public:
308 CanvasPopup(Canvas *canvas);
309 ~CanvasPopup();
311 void create_objects();
313 Canvas *canvas;
314 CanvasToggleControls *toggle_controls;
317 class CanvasPopupSize : public BC_MenuItem
319 public:
320 CanvasPopupSize(Canvas *canvas, char *text, float percentage);
321 ~CanvasPopupSize();
322 int handle_event();
323 Canvas *canvas;
324 float percentage;
327 class CanvasPopupAuto : public BC_MenuItem
329 public:
330 CanvasPopupAuto(Canvas *canvas);
331 int handle_event();
332 Canvas *canvas;
335 class CanvasPopupResetCamera : public BC_MenuItem
337 public:
338 CanvasPopupResetCamera(Canvas *canvas);
339 int handle_event();
340 Canvas *canvas;
343 class CanvasPopupResetProjector : public BC_MenuItem
345 public:
346 CanvasPopupResetProjector(Canvas *canvas);
347 int handle_event();
348 Canvas *canvas;
351 class CanvasToggleControls : public BC_MenuItem
353 public:
354 CanvasToggleControls(Canvas *canvas);
355 int handle_event();
356 static char* calculate_text(int cwindow_controls);
357 Canvas *canvas;
360 class CanvasFullScreenItem : public BC_MenuItem
362 public:
363 CanvasFullScreenItem(Canvas *canvas);
364 int handle_event();
365 Canvas *canvas;
368 class CanvasPopupResetTranslation : public BC_MenuItem
370 public:
371 CanvasPopupResetTranslation(Canvas *canvas);
372 int handle_event();
373 Canvas *canvas;
377 class CanvasPopupRemoveSource : public BC_MenuItem
379 public:
380 CanvasPopupRemoveSource(Canvas *canvas);
381 int handle_event();
382 Canvas *canvas;
389 #endif
391 // Local Variables:
392 // mode: C++
393 // c-file-style: "linux"
394 // End: