clipedit remove vs delete
[goodguy/history.git] / cinelerra-5.0 / 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 "bcsignals.h"
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 }
52
53 MButtons::~MButtons()
54 {
55         delete transport;
56         delete edit_panel;
57 }
58
59 void MButtons::create_objects()
60 {
61         int x = 3, y = 0;
62         draw_top_background(get_parent(), 0, 0, get_w(), get_h());
63         transport = new MainTransport(mwindow, this, x, y);
64         transport->create_objects();
65         transport->set_engine(mwindow->cwindow->playback_engine);
66         x += transport->get_w();
67         x += mwindow->theme->mtransport_margin;
68
69         edit_panel = new MainEditing(mwindow, this, x, y);
70
71         edit_panel->create_objects();
72         
73         x += edit_panel->get_w();
74         ffmpeg_toggle = new MainFFMpegToggle(mwindow, this, get_w()-30, 0);
75         add_subwindow(ffmpeg_toggle);
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 0;
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         return result;
100 }
101
102 void MButtons::update()
103 {
104         edit_panel->update();
105 }
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 MainTransport::MainTransport(MWindow *mwindow, MButtons *mbuttons, int x, int y)
123  : PlayTransport(mwindow, mbuttons, x, y)
124 {
125 }
126
127 void MainTransport::goto_start()
128 {
129         mwindow->gui->unlock_window();
130         handle_transport(REWIND, 1);
131         mwindow->gui->lock_window();
132         mwindow->goto_start();
133 }
134
135
136 void MainTransport::goto_end()
137 {
138         mwindow->gui->unlock_window();
139         handle_transport(GOTO_END, 1);
140         mwindow->gui->lock_window();
141         mwindow->goto_end();
142 }
143
144 MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y)
145  : EditPanel(mwindow, 
146                 mbuttons, 
147                 x, 
148                 y,
149                 mwindow->edl->session->editing_mode,
150                 1,
151                 1,
152                 0, 
153                 0, 
154                 1, 
155                 1,
156                 1,
157                 1,
158                 1,
159                 1,
160                 1,
161                 1,
162                 0,
163                 1,
164                 1,
165                 mwindow->has_commercials())
166 {
167         this->mwindow = mwindow;
168         this->mbuttons = mbuttons;
169 }
170
171
172 #include "data/ff_checked_png.h"
173 #include "data/ff_down_png.h"
174 #include "data/ff_checkedhi_png.h"
175 #include "data/ff_up_png.h"
176 #include "data/ff_hi_png.h"
177
178 static VFrame *ff_images[] = {
179         new VFrame(ff_up_png),
180         new VFrame(ff_hi_png),
181         new VFrame(ff_checked_png),
182         new VFrame(ff_down_png),
183         new VFrame(ff_checkedhi_png)
184 };
185
186 MainFFMpegToggle::MainFFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
187  : BC_Toggle(x - ff_images[0]->get_w(), y, &ff_images[0],
188                 mwindow->preferences->ffmpeg_early_probe)
189 {
190         this->mwindow = mwindow;
191         this->mbuttons = mbuttons;
192         set_tooltip("FFMpeg early probe");
193 }
194
195 MainFFMpegToggle::~MainFFMpegToggle()
196 {
197 }
198
199 int MainFFMpegToggle::handle_event()
200 {
201         mwindow->preferences->ffmpeg_early_probe = get_value();
202         mwindow->show_warning(&mwindow->preferences->warn_indecies,
203                 "Changing the base codecs may require rebuilding indecies.");
204         return 1;
205 }
206