no longer need ffmpeg patch0 which was for Termux
[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  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #include "cplayback.h"
24 #include "cwindow.h"
25 #include "editpanel.h"
26 #include "edl.h"
27 #include "edlsession.h"
28 #include "filexml.h"
29 #include "keys.h"
30 #include "localsession.h"
31 #include "mbuttons.h"
32 #include "mainundo.h"
33 #include "mwindow.h"
34 #include "mwindowgui.h"
35 #include "playbackengine.h"
36 #include "playtransport.h"
37 #include "preferences.h"
38 #include "record.h"
39 #include "mainsession.h"
40 #include "theme.h"
41 #include "tracks.h"
42
43 MButtons::MButtons(MWindow *mwindow, MWindowGUI *gui)
44  : BC_SubWindow(mwindow->theme->mbuttons_x,
45         mwindow->theme->mbuttons_y,
46         mwindow->theme->mbuttons_w,
47         mwindow->theme->mbuttons_h)
48 {
49         this->gui = gui;
50         this->mwindow = mwindow;
51 // *** CONTEXT_HELP ***
52         context_help_set_keyword("Transport and Buttons Bar");
53 }
54
55 MButtons::~MButtons()
56 {
57         delete transport;
58         delete edit_panel;
59 }
60
61 void MButtons::create_objects()
62 {
63         int x = 3, y = 0;
64         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
65         transport = new MainTransport(mwindow, this, x, y);
66         transport->create_objects();
67         transport->set_engine(mwindow->cwindow->playback_engine);
68         x += transport->get_w();
69         x += mwindow->theme->mtransport_margin;
70
71         edit_panel = new MainEditing(mwindow, this, x, y);
72
73         edit_panel->create_objects();
74
75         x += edit_panel->get_w();
76         flash(0);
77 }
78
79 int MButtons::resize_event()
80 {
81         reposition_window(mwindow->theme->mbuttons_x,
82                 mwindow->theme->mbuttons_y,
83                 mwindow->theme->mbuttons_w,
84                 mwindow->theme->mbuttons_h);
85         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
86         flash(0);
87         return 1;
88 }
89
90 int MButtons::keypress_event()
91 {
92         int result = 0;
93
94         if(!result)
95         {
96                 result = transport->keypress_event();
97         }
98
99         if(!result)
100         {
101                 result = context_help_check_and_show();
102         }
103
104         return result;
105 }
106
107 void MButtons::update()
108 {
109         edit_panel->update();
110 }
111
112
113 MainTransport::MainTransport(MWindow *mwindow, MButtons *mbuttons, int x, int y)
114  : PlayTransport(mwindow, mbuttons, x, y)
115 {
116 }
117
118 void MainTransport::goto_start()
119 {
120         mwindow->gui->unlock_window();
121         handle_transport(REWIND, 1);
122         mwindow->gui->lock_window();
123         mwindow->goto_start();
124 }
125
126
127 void MainTransport::goto_end()
128 {
129         mwindow->gui->unlock_window();
130         handle_transport(GOTO_END, 1);
131         mwindow->gui->lock_window();
132         mwindow->goto_end();
133 }
134
135 MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y)
136  : EditPanel(mwindow, mbuttons, MWINDOW_ID, x, y,
137                 mwindow->edl->session->editing_mode,
138                 1, // use_editing_mode
139                 1, // use_keyframe
140                 0, // use_splice
141                 0, // use_overwrite
142                 1, // use_copy
143                 1, // use_paste
144                 1, // use_undo
145                 1, // use_fit
146                 1, // locklabels
147                 1, // use_labels
148                 1, // use_toclip
149                 0, // use_meters
150                 1, // use_cut
151                 mwindow->has_commercials(), // use_commerical
152                 1, // use_goto
153                 0, // use_clk2play
154                 0, // use_scope
155                 1, // use_gang_tracks
156                 1) // use_timecode
157 {
158         this->mwindow = mwindow;
159         this->mbuttons = mbuttons;
160 }
161
162 double MainEditing::get_position()
163 {
164         return mwindow->get_position();
165 }
166
167 void MainEditing::set_position(double position)
168 {
169         mwindow->set_position(position);
170 }
171
172 void MainEditing::set_click_to_play(int v)
173 {
174 // not used
175 }
176
177 void MainEditing::panel_stop_transport()
178 {
179         mwindow->gui->stop_transport("MainEditing::stop_transport");
180 }
181
182 void MainEditing::panel_toggle_label()
183 {
184         mwindow->toggle_label();
185 }
186
187 void MainEditing::panel_next_label(int cut)
188 {
189         int shift_down = mwindow->gui->shift_down();
190         panel_stop_transport();
191         if( cut )
192                 mwindow->cut_right_label();
193         else
194                 mwindow->next_label(shift_down);
195 }
196
197 void MainEditing::panel_prev_label(int cut)
198 {
199         int shift_down = mwindow->gui->shift_down();
200         panel_stop_transport();
201         if( cut )
202                 mwindow->cut_left_label();
203         else
204                 mwindow->prev_label(shift_down);
205 }
206
207 void MainEditing::panel_prev_edit(int cut)
208 {
209         int shift_down = subwindow->shift_down();
210         panel_stop_transport();
211         if( cut )
212                 mwindow->cut_left_edit();
213         else
214                 mwindow->prev_edit_handle(shift_down);
215 }
216
217 void MainEditing::panel_next_edit(int cut)
218 {
219         int shift_down = subwindow->shift_down();
220         panel_stop_transport();
221         if( cut )
222                 mwindow->cut_right_edit();
223         else
224                 mwindow->next_edit_handle(shift_down);
225 }
226
227 void MainEditing::panel_copy_selection()
228 {
229         mwindow->copy();
230 }
231
232 void MainEditing::panel_overwrite_selection() {} // not used
233 void MainEditing::panel_splice_selection() {} // not used
234
235 void MainEditing::panel_set_inpoint()
236 {
237         mwindow->set_inpoint();
238 }
239
240 void MainEditing::panel_set_outpoint()
241 {
242         mwindow->set_outpoint();
243 }
244
245 void MainEditing::panel_unset_inoutpoint()
246 {
247         mwindow->unset_inoutpoint();
248 }
249
250 void MainEditing::panel_to_clip()
251 {
252         MWindowGUI *gui = mwindow->gui;
253         gui->unlock_window();
254         mwindow->to_clip(mwindow->edl, _("main window: "), 0);
255         gui->lock_window("MainEditing::to_clip");
256 }
257
258
259 void MainEditing::panel_cut()
260 {
261          mwindow->cut();
262 }
263
264 void MainEditing::panel_paste()
265 {
266         mwindow->paste();
267 }
268
269 void MainEditing::panel_fit_selection()
270 {
271         mwindow->fit_selection();
272 }
273
274 void MainEditing::panel_fit_autos(int all)
275 {
276         mwindow->fit_autos(all);
277 }
278
279 void MainEditing::panel_set_editing_mode(int mode)
280 {
281         mwindow->set_editing_mode(mode);
282 }
283
284 void MainEditing::panel_set_auto_keyframes(int v)
285 {
286         mwindow->set_auto_keyframes(v);
287 }
288
289 void MainEditing::panel_set_span_keyframes(int v)
290 {
291         mwindow->set_span_keyframes(v);
292 }
293
294 void MainEditing::panel_set_labels_follow_edits(int v)
295 {
296         mwindow->set_labels_follow_edits(v);
297 }
298
299 void MainEditing::panel_set_gang_tracks(int v)
300 {
301         mwindow->set_gang_tracks(v);
302 }
303