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 virtual int scope_on() { return 0; }
131 virtual void draw_scope(VFrame *frame, int refresh) {}
132 void process_scope(VideoDevice *video, VFrame *frame);
134 // Get top left offset of canvas relative to output.
135 // Normally negative. Can be positive if output is smaller than canvas.
136 float get_x_offset(EDL *edl, int single_channel, float zoom_x,
137 float conformed_w, float conformed_h);
138 float get_y_offset(EDL *edl, int single_channel, float zoom_y,
139 float conformed_w, float conformed_h);
141 void get_zooms(EDL *edl, int single_channel,
142 float &zoom_x, float &zoom_y,
143 float &conformed_w, float &conformed_h);
144 void set_zoom(EDL *edl, float zoom);
145 void set_zoom(EDL *edl, float zoom, float cx, float cy);
147 // Convert coord from output to canvas position, including
148 // x and y scroll offsets
149 void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
150 // Convert coord from canvas to output position
151 void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
153 // Get dimensions of frame being sent to canvas
154 virtual int get_output_w(EDL *edl);
155 virtual int get_output_h(EDL *edl);
156 // Get if scrollbars exist
157 int scrollbars_exist();
158 // Get cursor locations relative to canvas and not offset by scrollbars
161 int get_buttonpress();
162 // Gets whatever video surface is enabled
163 BC_WindowBase* get_canvas();
164 // draw_refresh, with/without locks
165 int refresh(int flush);
166 int redraw(int flush);
168 // The owner of the canvas
169 BC_WindowBase *subwindow;
170 // Video surface if a subwindow
171 CanvasOutput *canvas_subwindow;
172 // Video surface if fullscreen
173 CanvasFullScreen *canvas_fullscreen;
174 CanvasXScroll *xscroll;
175 CanvasYScroll *yscroll;
176 CanvasPopup *canvas_menu;
177 CanvasFullScreenPopup *fullscreen_menu;
180 BC_WindowBase *canvas_auxwindow;
181 // Used in record monitor
182 int output_w, output_h;
183 // Last frame played is stored here in driver format for
185 VFrame *refresh_frame;
186 // Results from last get_scrollbars
187 int w_needed, h_needed;
188 int w_visible, 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.
193 // Cursor is inside video surface
195 int view_x, view_y, view_w, view_h;
202 int get_scrollbars(EDL *edl);
203 void start_fullscreen();
204 void stop_fullscreen();
206 // Lock access to the canvas pointer.
207 Condition *canvas_lock;
211 class CanvasOutput : public BC_SubWindow
214 CanvasOutput(Canvas *canvas,
215 int x, int y, int w, int h);
218 int cursor_leave_event();
219 int cursor_enter_event();
220 int button_press_event();
221 int button_release_event();
222 int cursor_motion_event();
223 int keypress_event();
231 class CanvasFullScreen : public BC_FullScreen
234 CanvasFullScreen(Canvas *canvas, int w, int h);
243 class CanvasXScroll : public BC_ScrollBar
246 CanvasXScroll(EDL *edl,
261 class CanvasYScroll : public BC_ScrollBar
264 CanvasYScroll(EDL *edl,
280 class CanvasFullScreenPopup : public BC_PopupMenu
283 CanvasFullScreenPopup(Canvas *canvas);
285 void create_objects();
289 class CanvasSubWindowItem : public BC_MenuItem
292 CanvasSubWindowItem(Canvas *canvas);
297 class CanvasPopup : public BC_PopupMenu
300 CanvasPopup(Canvas *canvas);
303 void create_objects();
307 class CanvasZoomSize : public BC_MenuItem
310 CanvasZoomSize(Canvas *canvas);
315 class CanvasSizeSubMenu : public BC_SubMenu
318 CanvasSizeSubMenu(CanvasZoomSize *zoom_size);
320 CanvasZoomSize *zoom_size;
323 class CanvasPopupSize : public BC_MenuItem
326 CanvasPopupSize(Canvas *canvas, char *text, float percentage);
333 class CanvasPopupAuto : public BC_MenuItem
336 CanvasPopupAuto(Canvas *canvas);
341 class CanvasPopupResetCamera : public BC_MenuItem
344 CanvasPopupResetCamera(Canvas *canvas);
349 class CanvasPopupResetProjector : public BC_MenuItem
352 CanvasPopupResetProjector(Canvas *canvas);
357 class CanvasPopupCameraKeyframe : public BC_MenuItem
360 CanvasPopupCameraKeyframe(Canvas *canvas);
365 class CanvasPopupProjectorKeyframe : public BC_MenuItem
368 CanvasPopupProjectorKeyframe(Canvas *canvas);
373 class CanvasFullScreenItem : public BC_MenuItem
376 CanvasFullScreenItem(Canvas *canvas);
381 class CanvasPopupResetTranslation : public BC_MenuItem
384 CanvasPopupResetTranslation(Canvas *canvas);
389 class CanvasPopupRemoveSource : public BC_MenuItem
392 CanvasPopupRemoveSource(Canvas *canvas);