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
27 #include "mwindow.inc"
28 #include "videodevice.inc"
30 // Output for all X11 video
33 class CanvasFullScreen;
37 class CanvasFullScreenPopup;
38 class CanvasToggleControls;
40 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
44 Canvas(MWindow *mwindow,
45 BC_WindowBase *subwindow,
56 // Get dimensions given a zoom
57 void calculate_sizes(float aspect_ratio,
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);
69 void create_objects(EDL *edl);
70 void set_cursor(int cursor);
71 // Start video playback
75 // Start single frame processing. Causes the status indicator to update
79 void start_fullscreen();
80 void stop_fullscreen();
82 // Don't call from inside the canvas
87 // Processing or video playback changed.
88 virtual void status_event() {};
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 int need_overlays() { return 1; }
101 virtual void draw_overlays() { };
102 virtual void toggle_controls() { } ;
103 virtual int get_cwindow_controls() { return 0; };
104 virtual int get_fullscreen() { return 0; }
105 virtual void set_fullscreen(int value) { };
107 int cursor_leave_event_base(BC_WindowBase *caller);
108 int cursor_enter_event_base(BC_WindowBase *caller);
109 int button_press_event_base(BC_WindowBase *caller);
110 int keypress_event(BC_WindowBase *caller);
111 // Use menu different options for different windows
115 void use_auxwindow(BC_WindowBase *aux);
117 // Provide canvas dimensions since a BC_Bitmap containing obsolete dimensions
118 // is often the output being transferred to.
119 // This gets the input coordinates on the device output_frame
120 // and the corresponding output coordinates on the canvas.
121 // Must be floating point to support OpenGL.
122 void get_transfers(EDL *edl,
131 // passing -1 causes automatic size detection
134 void reposition_window(EDL *edl, int x, int y, int w, int h);
135 virtual void reset_translation() {};
136 virtual void close_source() {};
137 // Updates the stores
138 virtual void update_zoom(int x, int y, float zoom) {};
139 void check_boundaries(EDL *edl, int &x, int &y, float &zoom);
140 void update_scrollbars(int flush);
141 // Get scrollbar positions relative to output.
142 // No correction is done if output is smaller than canvas
143 virtual int get_xscroll() { return 0; };
144 virtual int get_yscroll() { return 0; };
145 virtual float get_zoom() { return 0; };
146 // Updates the refresh_frame
147 void update_refresh(VideoDevice *device, VFrame *output_frame);
148 // Redraws the refresh_frame
149 virtual void draw_refresh(int flush = 1) {};
150 virtual void clear(int flush=1);
152 // Get top left offset of canvas relative to output.
153 // Normally negative. Can be positive if output is smaller than canvas.
154 float get_x_offset(EDL *edl,
159 float get_y_offset(EDL *edl,
164 void get_zooms(EDL *edl,
172 // Convert coord from output to canvas position, including
173 // x and y scroll offsets
174 void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
175 // Convert coord from canvas to output position
176 void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
178 // Get dimensions of frame being sent to canvas
179 virtual int get_output_w(EDL *edl);
180 virtual int get_output_h(EDL *edl);
181 // Get if scrollbars exist
182 int scrollbars_exist();
183 // Get cursor locations relative to canvas and not offset by scrollbars
186 int get_buttonpress();
187 // Gets whatever video surface is enabled
188 BC_WindowBase* get_canvas();
190 // The owner of the canvas
191 BC_WindowBase *subwindow;
192 // Video surface if a subwindow
193 CanvasOutput *canvas_subwindow;
194 // Video surface if fullscreen
195 CanvasFullScreen *canvas_fullscreen;
196 CanvasXScroll *xscroll;
197 CanvasYScroll *yscroll;
198 CanvasPopup *canvas_menu;
199 CanvasFullScreenPopup *fullscreen_menu;
202 BC_WindowBase *canvas_auxwindow;
203 // Used in record monitor
204 int output_w, output_h;
205 // Last frame played is stored here in driver format for
207 VFrame *refresh_frame;
208 // Results from last get_scrollbars
213 // For cases where video is not enabled on the canvas but processing is
214 // occurring for a single frame, this causes the status to update.
216 // Cursor is inside video surface
228 void get_scrollbars(EDL *edl,
229 int &canvas_x, int &canvas_y, int &canvas_w, int &canvas_h);
234 class CanvasOutput : public BC_SubWindow
237 CanvasOutput(Canvas *canvas,
238 int x, int y, int w, int h);
241 int cursor_leave_event();
242 int cursor_enter_event();
243 int button_press_event();
244 int button_release_event();
245 int cursor_motion_event();
246 int keypress_event();
254 class CanvasFullScreen : public BC_FullScreen
257 CanvasFullScreen(Canvas *canvas, int w, int h);
266 class CanvasXScroll : public BC_ScrollBar
269 CanvasXScroll(EDL *edl,
284 class CanvasYScroll : public BC_ScrollBar
287 CanvasYScroll(EDL *edl,
303 class CanvasFullScreenPopup : public BC_PopupMenu
306 CanvasFullScreenPopup(Canvas *canvas);
308 void create_objects();
314 class CanvasSubWindowItem : public BC_MenuItem
317 CanvasSubWindowItem(Canvas *canvas);
322 class CanvasPopup : public BC_PopupMenu
325 CanvasPopup(Canvas *canvas);
328 void create_objects();
334 CanvasToggleControls *toggle_controls;
337 class CanvasPopupSize : public BC_MenuItem
340 CanvasPopupSize(Canvas *canvas, char *text, float percentage);
347 class CanvasPopupAuto : public BC_MenuItem
350 CanvasPopupAuto(Canvas *canvas);
355 class CanvasPopupResetCamera : public BC_MenuItem
358 CanvasPopupResetCamera(Canvas *canvas);
363 class CanvasPopupResetProjector : public BC_MenuItem
366 CanvasPopupResetProjector(Canvas *canvas);
371 class CanvasToggleControls : public BC_MenuItem
374 CanvasToggleControls(Canvas *canvas);
376 static char* calculate_text(int cwindow_controls);
380 class CanvasFullScreenItem : public BC_MenuItem
383 CanvasFullScreenItem(Canvas *canvas);
388 class CanvasPopupResetTranslation : public BC_MenuItem
391 CanvasPopupResetTranslation(Canvas *canvas);
397 class CanvasPopupRemoveSource : public BC_MenuItem
400 CanvasPopupRemoveSource(Canvas *canvas);