fff91679888410a53ea1e2c548498bdb7b8d5f85
[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(), 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         ffmpeg_toggle->reposition_window(get_w()-30, 0);
87         flash(0);
88         return 0;
89 }
90
91 int MButtons::keypress_event()
92 {
93         int result = 0;
94
95         if(!result)
96         {
97                 result = transport->keypress_event();
98         }
99
100         return result;
101 }
102
103 void MButtons::update()
104 {
105         edit_panel->update();
106 }
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 MainTransport::MainTransport(MWindow *mwindow, MButtons *mbuttons, int x, int y)
124  : PlayTransport(mwindow, mbuttons, x, y)
125 {
126 }
127
128 void MainTransport::goto_start()
129 {
130         mwindow->gui->unlock_window();
131         handle_transport(REWIND, 1);
132         mwindow->gui->lock_window();
133         mwindow->goto_start();
134 }
135
136
137 void MainTransport::goto_end()
138 {
139         mwindow->gui->unlock_window();
140         handle_transport(GOTO_END, 1);
141         mwindow->gui->lock_window();
142         mwindow->goto_end();
143 }
144
145 MainEditing::MainEditing(MWindow *mwindow, MButtons *mbuttons, int x, int y)
146  : EditPanel(mwindow, 
147                 mbuttons, 
148                 x, 
149                 y,
150                 mwindow->edl->session->editing_mode,
151                 1,
152                 1,
153                 0, 
154                 0, 
155                 1, 
156                 1,
157                 1,
158                 1,
159                 1,
160                 1,
161                 1,
162                 1,
163                 0,
164                 1,
165                 1,
166                 mwindow->has_commercials())
167 {
168         this->mwindow = mwindow;
169         this->mbuttons = mbuttons;
170 }
171
172
173 #include "data/ff_checked_png.h"
174 #include "data/ff_down_png.h"
175 #include "data/ff_checkedhi_png.h"
176 #include "data/ff_up_png.h"
177 #include "data/ff_hi_png.h"
178
179 static VFrame *ff_images[] = {
180         new VFrame(ff_up_png),
181         new VFrame(ff_hi_png),
182         new VFrame(ff_checked_png),
183         new VFrame(ff_down_png),
184         new VFrame(ff_checkedhi_png)
185 };
186
187 MainFFMpegToggle::MainFFMpegToggle(MWindow *mwindow, MButtons *mbuttons, int x, int y)
188  : BC_Toggle(x - ff_images[0]->get_w(), y, &ff_images[0],
189                 mwindow->preferences->ffmpeg_early_probe)
190 {
191         this->mwindow = mwindow;
192         this->mbuttons = mbuttons;
193         set_tooltip(_("FFMpeg early probe"));
194 }
195
196 MainFFMpegToggle::~MainFFMpegToggle()
197 {
198 }
199
200 int MainFFMpegToggle::handle_event()
201 {
202         mwindow->preferences->ffmpeg_early_probe = get_value();
203         mwindow->show_warning(&mwindow->preferences->warn_indecies,
204                 _("Changing the base codecs may require rebuilding indecies."));
205         return 1;
206 }
207