r668: Configure.in and autogen.sh cleanup based on ideas by giskard.
[cinelerra_cv.git] / cinelerra / canvas.h
blob74e195409b6ca80005b7c74b7c09e9e35121301f
1 #ifndef CANVAS_H
2 #define CANVAS_H
4 #include "edl.inc"
5 #include "guicast.h"
7 // Output for all X11 video
9 class CanvasOutput;
10 class CanvasXScroll;
11 class CanvasYScroll;
12 class CanvasPopup;
13 class CanvasToggleControls;
15 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
16 class Canvas
18 public:
19 Canvas(BC_WindowBase *subwindow,
20 int x,
21 int y,
22 int w,
23 int h,
24 int output_w,
25 int output_h,
26 int use_scrollbars,
27 int use_cwindow = 0,
28 int use_rwindow = 0,
29 int use_vwindow = 0); // Use menu different options for different windows
30 virtual ~Canvas();
32 void reset();
33 // Get dimensions given a zoom
34 void calculate_sizes(float aspect_ratio,
35 int output_w,
36 int output_h,
37 float zoom,
38 int &w,
39 int &h);
41 int create_objects(EDL *edl);
42 void set_cursor(int cursor);
43 // Start video playback
44 void start_video();
45 void stop_video();
47 // Start single frame processing. Causes the status indicator to update
48 void start_single();
49 void stop_single();
51 // Processing or video playback changed.
52 virtual void status_event() {};
55 virtual void reset_camera() {};
56 virtual void reset_projector() {};
57 virtual void zoom_resize_window(float percentage) {};
58 virtual int cursor_leave_event() { return 0; };
59 virtual int cursor_enter_event() { return 0; };
60 virtual int button_release_event() { return 0; };
61 virtual int button_press_event();
62 virtual int cursor_motion_event() { return 0; };
63 virtual void draw_overlays() { };
64 virtual void toggle_controls() { } ;
65 virtual int get_cwindow_controls() { return 0; };
66 // Provide canvas dimensions since a BC_Bitmap containing obsolete dimensions
67 // is often the output being transferred to
68 void get_transfers(EDL *edl, int &in_x,
69 int &in_y,
70 int &in_w,
71 int &in_h,
72 int &out_x,
73 int &out_y,
74 int &out_w,
75 int &out_h,
76 int canvas_w = -1,
77 int canvas_h = -1);
78 void reposition_window(EDL *edl, int x, int y, int w, int h);
79 virtual void reset_translation() {};
80 virtual void close_source() {};
81 // Updates the stores
82 virtual void update_zoom(int x, int y, float zoom) {};
83 void check_boundaries(EDL *edl, int &x, int &y, float &zoom);
84 void update_scrollbars();
85 // Get scrollbar positions relative to output.
86 // No correction is done if output is smaller than canvas
87 virtual int get_xscroll() { return 0; };
88 virtual int get_yscroll() { return 0; };
89 virtual float get_zoom() { return 0; };
90 // Redraws the image
91 virtual void draw_refresh() {};
93 // Get top left offset of canvas relative to output.
94 // Normally negative. Can be positive if output is smaller than canvas.
95 float get_x_offset(EDL *edl,
96 int single_channel,
97 float zoom_x,
98 float conformed_w,
99 float conformed_h);
100 float get_y_offset(EDL *edl,
101 int single_channel,
102 float zoom_y,
103 float conformed_w,
104 float conformed_h);
105 void get_zooms(EDL *edl,
106 int single_channel,
107 float &zoom_x,
108 float &zoom_y,
109 float &conformed_w,
110 float &conformed_h);
113 // Convert coord from output to canvas position, including
114 // x and y scroll offsets
115 void output_to_canvas(EDL *edl, int single_channel, float &x, float &y);
116 // Convert coord from canvas to output position
117 void canvas_to_output(EDL *edl, int single_channel, float &x, float &y);
119 // Get dimensions of frame being sent to canvas
120 virtual int get_output_w(EDL *edl);
121 virtual int get_output_h(EDL *edl);
122 // Get if scrollbars exist
123 int scrollbars_exist();
124 // Get cursor locations relative to canvas and not offset by scrollbars
125 int get_cursor_x();
126 int get_cursor_y();
127 int get_buttonpress();
129 BC_WindowBase *subwindow;
130 CanvasOutput *canvas;
131 CanvasXScroll *xscroll;
132 CanvasYScroll *yscroll;
133 CanvasPopup *canvas_menu;
134 int x, y, w, h;
135 int use_scrollbars;
136 int use_cwindow;
137 int use_rwindow;
138 int use_vwindow;
139 // Used in record monitor
140 int output_w, output_h;
141 // Store frame in native format after playback for refreshes
142 VFrame *refresh_frame;
143 // Results from last get_scrollbars
144 int w_needed;
145 int h_needed;
146 int w_visible;
147 int h_visible;
148 // For cases where video is not enabled on the canvas but processing is
149 // occurring for a single frame, this causes the status to update.
150 int is_processing;
152 private:
153 void get_scrollbars(EDL *edl,
154 int &canvas_x,
155 int &canvas_y,
156 int &canvas_w,
157 int &canvas_h);
161 class CanvasOutput : public BC_SubWindow
163 public:
164 CanvasOutput(EDL *edl,
165 Canvas *canvas,
166 int x,
167 int y,
168 int w,
169 int h);
170 ~CanvasOutput();
172 int handle_event();
173 int cursor_leave_event();
174 int cursor_enter_event();
175 int button_press_event();
176 int button_release_event();
177 int cursor_motion_event();
179 EDL *edl;
180 Canvas *canvas;
181 int cursor_inside;
184 class CanvasXScroll : public BC_ScrollBar
186 public:
187 CanvasXScroll(EDL *edl,
188 Canvas *canvas,
189 int x,
190 int y,
191 int length,
192 int position,
193 int handle_length,
194 int pixels);
195 ~CanvasXScroll();
197 int handle_event();
199 Canvas *canvas;
200 EDL *edl;
203 class CanvasYScroll : public BC_ScrollBar
205 public:
206 CanvasYScroll(EDL *edl,
207 Canvas *canvas,
208 int x,
209 int y,
210 int length,
211 int position,
212 int handle_length,
213 int pixels);
214 ~CanvasYScroll();
216 int handle_event();
218 Canvas *canvas;
219 EDL *edl;
222 class CanvasPopup : public BC_PopupMenu
224 public:
225 CanvasPopup(Canvas *canvas);
226 ~CanvasPopup();
228 void create_objects();
230 Canvas *canvas;
231 CanvasToggleControls *toggle_controls;
234 class CanvasPopupSize : public BC_MenuItem
236 public:
237 CanvasPopupSize(Canvas *canvas, char *text, float percentage);
238 ~CanvasPopupSize();
239 int handle_event();
240 Canvas *canvas;
241 float percentage;
244 class CanvasPopupResetCamera : public BC_MenuItem
246 public:
247 CanvasPopupResetCamera(Canvas *canvas);
248 int handle_event();
249 Canvas *canvas;
252 class CanvasPopupResetProjector : public BC_MenuItem
254 public:
255 CanvasPopupResetProjector(Canvas *canvas);
256 int handle_event();
257 Canvas *canvas;
260 class CanvasToggleControls : public BC_MenuItem
262 public:
263 CanvasToggleControls(Canvas *canvas);
264 int handle_event();
265 static char* calculate_text(int cwindow_controls);
266 Canvas *canvas;
269 class CanvasPopupResetTranslation : public BC_MenuItem
271 public:
272 CanvasPopupResetTranslation(Canvas *canvas);
273 int handle_event();
274 Canvas *canvas;
278 class CanvasPopupRemoveSource : public BC_MenuItem
280 public:
281 CanvasPopupRemoveSource(Canvas *canvas);
282 int handle_event();
283 Canvas *canvas;
290 #endif