expand vaapi render formats and add shortcut
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mbuttons.C
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 #include "cplayback.h"
23 #include "cwindow.h"
24 #include "editpanel.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "filexml.h"
28 #include "keys.h"
29 #include "localsession.h"
30 #include "mbuttons.h"
31 #include "mainundo.h"
32 #include "mwindow.h"
33 #include "mwindowgui.h"
34 #include "playbackengine.h"
35 #include "playtransport.h"
36 #include "preferences.h"
37 #include "record.h"
38 #include "mainsession.h"
39 #include "theme.h"
40 #include "tracks.h"
41
42 MButtons::MButtons(MWindow *mwindow, MWindowGUI *gui)
43  : BC_SubWindow(mwindow->theme->mbuttons_x,
44         mwindow->theme->mbuttons_y,
45         mwindow->theme->mbuttons_w,
46         mwindow->theme->mbuttons_h)
47 {
48         this->gui = gui;
49         this->mwindow = mwindow;
50 // *** CONTEXT_HELP ***
51         context_help_set_keyword("Transport and Buttons Bar");
52 }
53
54 MButtons::~MButtons()
55 {
56         delete transport;
57         delete edit_panel;
58 }
59
60 void MButtons::create_objects()
61 {
62         int x = 3, y = 0;
63         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
64         transport = new MainTransport(mwindow, this, x, y);
65         transport->create_objects();
66         transport->set_engine(mwindow->cwindow->playback_engine);
67         x += transport->get_w();
68         x += mwindow->theme->mtransport_margin;
69
70         edit_panel = new MainEditing(mwindow, this, x, y);
71
72         edit_panel->create_objects();
73
74         x += edit_panel->get_w();
75         flash(0);
76 }
77
78 int MButtons::resize_event()
79 {
80         reposition_window(mwindow->theme->mbuttons_x,
81                 mwindow->theme->mbuttons_y,
82                 mwindow->theme->mbuttons_w,
83                 mwindow->theme->mbuttons_h);
84         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
85         flash(0);
86         return 1;
87 }
88
89 int MButtons::keypress_event()
90 {
91         int result = 0;
92
93         if(!result)
94         {
95                 result = transport->keypress_event();
96         }
97
98         if(!result)
99         {
100                 result = context_help_check_and_show();
101         }
102
103         return result;
104 }
105
106 void MButtons::update()
107 {
108         edit_panel->update();
109 }
110
111
112 MainTransport::MainTransport(MWindow *mwindow, MButtons *mbuttons, int x, int y)
113  : PlayTransport(mwindow, mbuttons, x, y)
114 {
115 }
116
117 void MainTransport::goto_start()
118 {
119         mwindow->gui->unlock_window();
120         handle_transport(REWIND, 1);
121         mwindow->gui->lock_window();
122         mwindow->goto_start();
123 }
124
125
126 void MainTransport::goto_end()
127 {
128         mwindow->gui->unlock_window();
129         handle_transport(GOTO_END, 1);
130         mwindow->gui->lock_window();
131         mwindow->goto_end();
132 }
133
134 MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y)
135  : EditPanel(mwindow, mbuttons, MWINDOW_ID, x, y,
136                 mwindow->edl->session->editing_mode,
137                 1, // use_editing_mode
138                 1, // use_keyframe
139                 0, // use_splice
140                 0, // use_overwrite
141                 1, // use_copy
142                 1, // use_paste
143                 1, // use_undo
144                 1, // use_fit
145                 1, // locklabels
146                 1, // use_labels
147                 1, // use_toclip
148                 0, // use_meters
149                 1, // use_cut
150                 mwindow->has_commercials(), // use_commerical
151                 1, // use_goto
152                 0, // use_clk2play
153                 0, // use_scope
154                 1, // use_gang_tracks
155                 1) // use_timecode
156 {
157         this->mwindow = mwindow;
158         this->mbuttons = mbuttons;
159 }
160
161 double MainEditing::get_position()
162 {
163         return mwindow->get_position();
164 }
165
166 void MainEditing::set_position(double position)
167 {
168         mwindow->set_position(position);
169 }
170
171 void MainEditing::set_click_to_play(int v)
172 {
173 // not used
174 }
175
176 void MainEditing::panel_stop_transport()
177 {
178         mwindow->gui->stop_transport("MainEditing::stop_transport");
179 }
180
181 void MainEditing::panel_toggle_label()
182 {
183         mwindow->toggle_label();
184 }
185
186 void MainEditing::panel_next_label(int cut)
187 {
188         int shift_down = mwindow->gui->shift_down();
189         panel_stop_transport();
190         if( cut )
191                 mwindow->cut_right_label();
192         else
193                 mwindow->next_label(shift_down);
194 }
195
196 void MainEditing::panel_prev_label(int cut)
197 {
198         int shift_down = mwindow->gui->shift_down();
199         panel_stop_transport();
200         if( cut )
201                 mwindow->cut_left_label();
202         else
203                 mwindow->prev_label(shift_down);
204 }
205
206 void MainEditing::panel_prev_edit(int cut)
207 {
208         int shift_down = subwindow->shift_down();
209         panel_stop_transport();
210         if( cut )
211                 mwindow->cut_left_edit();
212         else
213                 mwindow->prev_edit_handle(shift_down);
214 }
215
216 void MainEditing::panel_next_edit(int cut)
217 {
218         int shift_down = subwindow->shift_down();
219         panel_stop_transport();
220         if( cut )
221                 mwindow->cut_right_edit();
222         else
223                 mwindow->next_edit_handle(shift_down);
224 }
225
226 void MainEditing::panel_copy_selection()
227 {
228         mwindow->copy();
229 }
230
231 void MainEditing::panel_overwrite_selection() {} // not used
232 void MainEditing::panel_splice_selection() {} // not used
233
234 void MainEditing::panel_set_inpoint()
235 {
236         mwindow->set_inpoint();
237 }
238
239 void MainEditing::panel_set_outpoint()
240 {
241         mwindow->set_outpoint();
242 }
243
244 void MainEditing::panel_unset_inoutpoint()
245 {
246         mwindow->unset_inoutpoint();
247 }
248
249 void MainEditing::panel_to_clip()
250 {
251         MWindowGUI *gui = mwindow->gui;
252         gui->unlock_window();
253         mwindow->to_clip(mwindow->edl, _("main window: "), 0);
254         gui->lock_window("MainEditing::to_clip");
255 }
256
257
258 void MainEditing::panel_cut()
259 {
260          mwindow->cut();
261 }
262
263 void MainEditing::panel_paste()
264 {
265         mwindow->paste();
266 }
267
268 void MainEditing::panel_fit_selection()
269 {
270         mwindow->fit_selection();
271 }
272
273 void MainEditing::panel_fit_autos(int all)
274 {
275         mwindow->fit_autos(all);
276 }
277
278 void MainEditing::panel_set_editing_mode(int mode)
279 {
280         mwindow->set_editing_mode(mode);
281 }
282
283 void MainEditing::panel_set_auto_keyframes(int v)
284 {
285         mwindow->set_auto_keyframes(v);
286 }
287
288 void MainEditing::panel_set_span_keyframes(int v)
289 {
290         mwindow->set_span_keyframes(v);
291 }
292
293 void MainEditing::panel_set_labels_follow_edits(int v)
294 {
295         mwindow->set_labels_follow_edits(v);
296 }
297
298 void MainEditing::panel_set_gang_tracks(int v)
299 {
300         mwindow->set_gang_tracks(v);
301 }
302