4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
28 #include "mwindow.inc"
29 #include "videodevice.inc"
30 // Output for all X11 video
32 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
36 Canvas(MWindow *mwindow, BC_WindowBase *subwindow,
37 int x, int y, int w, int h,
38 int output_w, int output_h,
43 // Get dimensions given a zoom
44 void calculate_sizes(float aspect_ratio,
45 int output_w, int output_h, float zoom,
47 // Lock canvas pointer and window
48 BC_WindowBase *lock_canvas(const char *loc);
51 void create_objects(EDL *edl);
52 void set_cursor(int cursor);
53 // Start video playback
57 // Start single frame processing. Causes the status indicator to update
61 // Don't call from inside the canvas
64 // Processing or video playback changed.
65 virtual void status_event() {};
67 virtual void reset_camera() {}
68 virtual void reset_projector() {}
69 virtual void camera_keyframe() {}
70 virtual void projector_keyframe() {}
71 virtual void zoom_resize_window(float percentage) {}
72 virtual int cursor_leave_event() { return 0; }
73 virtual int cursor_enter_event() { return 0; }
74 virtual int button_release_event() { return 0; }
75 virtual int button_press_event();
76 virtual int cursor_motion_event() { return 0; }
77 virtual int need_overlays() { return 1; }
78 virtual void draw_overlays() {}
79 virtual void toggle_controls() {}
80 virtual int get_cwindow_controls() { return 0; }
81 virtual int get_fullscreen();
82 virtual int get_clear_color();
83 virtual int set_fullscreen(int on, int unlock);
85 int cursor_leave_event_base(BC_WindowBase *caller);
86 int cursor_enter_event_base(BC_WindowBase *caller);
87 int button_press_event_base(BC_WindowBase *caller);
88 int keypress_event(BC_WindowBase *caller);
89 void use_auxwindow(BC_WindowBase *aux);
91 // Provide canvas dimensions since a BC_Bitmap containing obsolete dimensions
92 // is often the output being transferred to.
93 // This gets the input coordinates on the device output_frame
94 // and the corresponding output coordinates on the canvas.
95 // Must be floating point to support OpenGL.
96 void get_transfers(EDL *edl,
105 // passing -1 causes automatic size detection
108 void update_geometry(EDL *edl, int x, int y, int w, int h);
109 void reposition_window(EDL *edl, int x, int y, int w, int h);
110 virtual void reset_translation() {};
111 virtual void close_source() {};
112 // Updates the stores
113 virtual void update_zoom(int x, int y, float zoom) {}
114 void check_boundaries(EDL *edl, int &x, int &y, float &zoom);
115 void clear_borders(EDL *edl);
116 void update_scrollbars(EDL *edl, int flush);
117 // Get scrollbar positions relative to output.
118 // No correction is done if output is smaller than canvas
119 virtual int get_xscroll() { return 0; }
120 virtual int get_yscroll() { return 0; }
121 virtual float get_zoom() { return 0; }
122 virtual float get_auto_zoom(EDL *edl);
123 virtual void zoom_auto();
124 // Updates the refresh_frame
125 void update_refresh(VideoDevice *device, VFrame *output_frame);
126 // Redraws the refresh_frame
127 virtual void draw_refresh(int flush = 1) {};
128 virtual void clear(int flash=1);
130 // Get top left offset of canvas relative to output.
131 // Normally negative. Can be positive if output is smaller than canvas.
132 float get_x_offset(EDL *edl, int single_channel, float zoom_x,
133 float conformed_w, float conformed_h);
134 float get_y_offset(EDL *edl, int single_channel, float zoom_y,
135 float conformed_w, float conformed_h);
137 void get_zooms(EDL *edl, int single_channel,
138 float &zoom_x, float &zoom_y,
139 float &conformed_w, float &conformed_h);
140 void set_zoom(EDL *edl, float zoom);
141 void set_zoom(EDL *edl, float zoom, float cx, float cy);
143 // Convert coord from output to canvas position, including
144 // x and y scroll offsets
145 void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
146 // Convert coord from canvas to output position
147 void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
149 // Get dimensions of frame being sent to canvas
150 virtual int get_output_w(EDL *edl);
151 virtual int get_output_h(EDL *edl);
152 // Get if scrollbars exist
153 int scrollbars_exist();
154 // Get cursor locations relative to canvas and not offset by scrollbars
157 int get_buttonpress();
158 // Gets whatever video surface is enabled
159 BC_WindowBase* get_canvas();
160 // draw_refresh, with/without locks
161 int refresh(int flush);
162 int redraw(int flush);
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;
176 BC_WindowBase *canvas_auxwindow;
177 // Used in record monitor
178 int output_w, output_h;
179 // Last frame played is stored here in driver format for
181 VFrame *refresh_frame;
182 // Results from last get_scrollbars
183 int w_needed, h_needed;
184 int w_visible, h_visible;
185 // For cases where video is not enabled on the canvas but processing is
186 // occurring for a single frame, this causes the status to update.
189 // Cursor is inside video surface
191 int view_x, view_y, view_w, view_h;
198 int get_scrollbars(EDL *edl);
199 void start_fullscreen();
200 void stop_fullscreen();
202 // Lock access to the canvas pointer.
203 Condition *canvas_lock;
207 class CanvasOutput : public BC_SubWindow
210 CanvasOutput(Canvas *canvas,
211 int x, int y, int w, int h);
214 int cursor_leave_event();
215 int cursor_enter_event();
216 int button_press_event();
217 int button_release_event();
218 int cursor_motion_event();
219 int keypress_event();
227 class CanvasFullScreen : public BC_FullScreen
230 CanvasFullScreen(Canvas *canvas, int w, int h);
239 class CanvasXScroll : public BC_ScrollBar
242 CanvasXScroll(EDL *edl,
257 class CanvasYScroll : public BC_ScrollBar
260 CanvasYScroll(EDL *edl,
276 class CanvasFullScreenPopup : public BC_PopupMenu
279 CanvasFullScreenPopup(Canvas *canvas);
281 void create_objects();
285 class CanvasSubWindowItem : public BC_MenuItem
288 CanvasSubWindowItem(Canvas *canvas);
293 class CanvasPopup : public BC_PopupMenu
296 CanvasPopup(Canvas *canvas);
299 void create_objects();
303 class CanvasZoomSize : public BC_MenuItem
306 CanvasZoomSize(Canvas *canvas);
311 class CanvasSizeSubMenu : public BC_SubMenu
314 CanvasSizeSubMenu(CanvasZoomSize *zoom_size);
316 CanvasZoomSize *zoom_size;
319 class CanvasPopupSize : public BC_MenuItem
322 CanvasPopupSize(Canvas *canvas, char *text, float percentage);
329 class CanvasPopupAuto : public BC_MenuItem
332 CanvasPopupAuto(Canvas *canvas);
337 class CanvasPopupResetCamera : public BC_MenuItem
340 CanvasPopupResetCamera(Canvas *canvas);
345 class CanvasPopupResetProjector : public BC_MenuItem
348 CanvasPopupResetProjector(Canvas *canvas);
353 class CanvasPopupCameraKeyframe : public BC_MenuItem
356 CanvasPopupCameraKeyframe(Canvas *canvas);
361 class CanvasPopupProjectorKeyframe : public BC_MenuItem
364 CanvasPopupProjectorKeyframe(Canvas *canvas);
369 class CanvasFullScreenItem : public BC_MenuItem
372 CanvasFullScreenItem(Canvas *canvas);
377 class CanvasPopupResetTranslation : public BC_MenuItem
380 CanvasPopupResetTranslation(Canvas *canvas);
385 class CanvasPopupRemoveSource : public BC_MenuItem
388 CanvasPopupRemoveSource(Canvas *canvas);