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