14e0ebfe3285981c28c53c47695769e837950b72
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / cwindowgui.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef CWINDOWGUI_H
23 #define CWINDOWGUI_H
24
25 #include "auto.inc"
26 #include "canvas.h"
27 #include "cpanel.inc"
28 #include "ctimebar.inc"
29 #include "cwindow.inc"
30 #include "cwindowtool.inc"
31 #include "editpanel.h"
32 #include "floatauto.inc"
33 #include "floatautos.inc"
34 #include "guicast.h"
35 #include "language.h"
36 #include "mainclock.inc"
37 #include "maskauto.inc"
38 #include "meterpanel.h"
39 #include "mwindow.inc"
40 #include "playtransport.h"
41 #include "thread.h"
42 #include "track.inc"
43 #include "zoompanel.h"
44
45 class CWindowZoom;
46 class CWindowSlider;
47 class CWindowReset;
48 class CWindowDestination;
49 class CWindowMeters;
50 class CWindowTransport;
51 class CWindowCanvas;
52 class CWindowEditing;
53
54
55 #define AUTO_ZOOM N_("Auto")
56
57 #define CROP_REFORMAT 0
58 #define CROP_RESIZE 1
59 #define CROP_SHRINK 2
60 #define CROP_MODES 3
61
62
63 class CWindowGUI : public BC_Window
64 {
65 public:
66         CWindowGUI(MWindow *mwindow, CWindow *cwindow);
67         ~CWindowGUI();
68
69         void create_objects();
70         int resize_event(int w, int h);
71         void update_canvas(int redraw=1);
72
73 // Events for the fullscreen canvas fall through to here.
74         int button_press_event();
75         int cursor_leave_event();
76         int cursor_enter_event();
77         int button_release_event();
78         int cursor_motion_event();
79
80         int close_event();
81         int keypress_event();
82         int translation_event();
83         void set_operation(int value);
84         void update_tool();
85         void drag_motion();
86         int drag_stop();
87         void draw_status(int flush);
88 // Zero out pointers to affected auto
89         void reset_affected();
90         void keyboard_zoomin();
91         void keyboard_zoomout();
92         void update_meters();
93         void stop_transport(const char *lock_msg);
94         void sync_parameters(int change_type, int redraw=0, int overlay=0);
95
96         MWindow *mwindow;
97         CWindow *cwindow;
98         const char *auto_zoom;
99         CWindowEditing *edit_panel;
100 //      APanel *automation_panel;
101         CPanel *composite_panel;
102         CWindowZoom *zoom_panel;
103         CWindowReset *reset;
104         CWindowTransport *transport;
105         CWindowCanvas *canvas;
106         CTimeBar *timebar;
107         BC_Pixmap *active;
108         BC_Pixmap *inactive;
109         VFrame *focus_frame;
110 //      MainClock *clock;
111
112
113         CWindowMeters *meters;
114
115
116         CWindowTool *tool_panel;
117
118 // Cursor motion modification being done
119         int current_operation;
120 // The pointers are only used for dragging.  Information for tool windows
121 // must be integers and recalculted for every keypress.
122 // Track being modified in canvas
123         Track *affected_track;
124 // Transformation keyframe being modified
125         FloatAuto *affected_x;
126         FloatAuto *affected_y;
127         FloatAuto *affected_z;
128 // Pointer to mask keyframe being modified in the EDL
129         MaskAuto *mask_keyframe;
130 // Copy of original value of mask keyframe for keyframe spanning
131         MaskAuto *orig_mask_keyframe;
132 // Mask point being modified
133         int affected_point;
134 // Scrollbar offsets during last button press relative to output
135         float x_offset, y_offset;
136 // Cursor location during the last button press relative to output
137 // and offset by scroll bars
138         float x_origin, y_origin;
139 // Crop handle being dragged
140         int crop_handle;
141 // If dragging crop translation
142         int crop_translate;
143 // Origin of crop handle during last button press
144         float crop_origin_x, crop_origin_y;
145 // Origin of all 4 crop points during last button press
146         float crop_origin_x1, crop_origin_y1;
147         float crop_origin_x2, crop_origin_y2;
148 // Center of last eyedrop drawing
149         int eyedrop_x, eyedrop_y;
150         int eyedrop_visible;
151
152         float ruler_origin_x, ruler_origin_y;
153         int ruler_handle;
154         int ruler_translate;
155
156 // Origin for camera and projector operations during last button press
157         float center_x, center_y, center_z;
158         float control_in_x, control_in_y, control_out_x, control_out_y;
159 // Must recalculate the origin when pressing shift.
160 // Switch toggle on and off to recalculate origin.
161         int translating_zoom;
162         int highlighted;
163 };
164
165
166 class CWindowEditing : public EditPanel
167 {
168 public:
169         CWindowEditing(MWindow *mwindow, CWindow *cwindow);
170         virtual ~CWindowEditing() {}
171
172         double get_position();
173         void set_position(double position);
174         void set_click_to_play(int v);
175
176         void panel_stop_transport();
177         void panel_toggle_label();
178         void panel_next_label(int cut);
179         void panel_prev_label(int cut);
180         void panel_prev_edit(int cut);
181         void panel_next_edit(int cut);
182         void panel_copy_selection();
183         void panel_overwrite_selection();
184         void panel_splice_selection();
185         void panel_set_inpoint();
186         void panel_set_outpoint();
187         void panel_unset_inoutpoint();
188         void panel_to_clip();
189         void panel_cut();
190         void panel_paste();
191         void panel_fit_selection();
192         void panel_fit_autos(int all);
193         void panel_set_editing_mode(int mode);
194         void panel_set_auto_keyframes(int v);
195         void panel_set_span_keyframes(int v);
196         void panel_set_labels_follow_edits(int v);
197
198         MWindow *mwindow;
199         CWindow *cwindow;
200 };
201
202
203 class CWindowMeters : public MeterPanel
204 {
205 public:
206         CWindowMeters(MWindow *mwindow, CWindowGUI *gui, int x, int y, int h);
207         virtual ~CWindowMeters();
208
209         int change_status_event(int new_status);
210
211         MWindow *mwindow;
212         CWindowGUI *gui;
213 };
214
215 class CWindowZoom : public ZoomPanel
216 {
217 public:
218         CWindowZoom(MWindow *mwindow, CWindowGUI *gui, int x, int y, int w);
219         virtual ~CWindowZoom();
220         int handle_event();
221         void update(double value);
222         MWindow *mwindow;
223         CWindowGUI *gui;
224 };
225
226
227 class CWindowSlider : public BC_PercentageSlider
228 {
229 public:
230         CWindowSlider(MWindow *mwindow, CWindow *cwindow, int x, int y, int pixels);
231         ~CWindowSlider();
232
233         int handle_event();
234         void set_position();
235         int increase_value();
236         int decrease_value();
237
238         MWindow *mwindow;
239         CWindow *cwindow;
240 };
241
242 class CWindowReset : public BC_Button
243 {
244 public:
245         CWindowReset(MWindow *mwindow, CWindowGUI *cwindow, int x, int y);
246         ~CWindowReset();
247         int handle_event();
248         CWindowGUI *cwindow;
249         MWindow *mwindow;
250 };
251
252 // class CWindowDestination : public BC_PopupTextBox
253 // {
254 // public:
255 //      CWindowDestination(MWindow *mwindow, CWindowGUI *cwindow, int x, int y);
256 //      ~CWindowDestination();
257 //      int handle_event();
258 //      CWindowGUI *cwindow;
259 //      MWindow *mwindow;
260 // };
261
262 class CWindowTransport : public PlayTransport
263 {
264 public:
265         CWindowTransport(MWindow *mwindow,
266                 CWindowGUI *gui, int x, int y);
267         bool use_mixers() { return true; }
268         EDL* get_edl();
269         void goto_start();
270         void goto_end();
271
272         CWindowGUI *gui;
273 };
274
275
276 class CWindowCanvas : public Canvas
277 {
278 public:
279         CWindowCanvas(MWindow *mwindow, CWindowGUI *gui);
280
281         void status_event();
282         void zoom_resize_window(float percentage);
283         void update_zoom(int x, int y, float zoom);
284         int get_xscroll();
285         int get_yscroll();
286         float get_zoom();
287         void zoom_auto();
288         int do_scroll(EDL *edl, float cursor_x, float cursor_y);
289         int do_eyedrop(int &rerender, int button_press, int draw);
290         int do_mask(int &redraw,
291                 int &rerender,
292                 int button_press,
293                 int cursor_motion,
294                 int draw);
295         int do_mask_focus();
296         void draw_refresh(int flash = 1);
297         int need_overlays();
298         void draw_overlays();
299         void draw_safe_regions();
300 // Cursor may have to be drawn
301         int cursor_leave_event();
302         int cursor_enter_event();
303         int cursor_motion_event();
304         int button_press_event();
305         int button_release_event();
306         int test_crop(int button_press, int &redraw);
307         int test_bezier(int button_press,
308                 int &redraw,
309                 int &redraw_canvas,
310                 int &rerender,
311                 int do_camera);
312         int do_ruler(int draw, int motion, int button_press, int button_release);
313         int test_zoom(int &redraw);
314         void create_keyframe(int do_camera);
315         void camera_keyframe();
316         void projector_keyframe();
317         void reset_keyframe(int do_camera);
318         void reset_camera();
319         void reset_projector();
320         void draw_crophandle(int x, int y);
321         int set_fullscreen(int on, int unlock);
322
323 // Draw the camera/projector overlay in different colors.
324         void draw_outlines(int do_camera);
325         void draw_crop();
326         void calculate_origin();
327         void toggle_controls();
328         int get_cwindow_controls();
329         int get_clear_color();
330
331         MWindow *mwindow;
332         CWindowGUI *gui;
333         float last_xscroll, last_yscroll;
334         float last_zoom;
335 };
336
337 #endif