r999: maintainers added to README_en.
[cinelerra_cv/mob.git] / cinelerra / recordtransport.C
blob0e1064f08f77a713c31c398e2af2b5f40b0f37e8
1 #include "asset.h"
2 #include "file.h"
3 #include "language.h"
4 #include "mwindow.h"
5 #include "record.h"
6 #include "recordgui.h"
7 #include "recordtransport.h"
8 #include "theme.h"
9 #include "units.h"
12 RecordTransport::RecordTransport(MWindow *mwindow, 
13                 Record *record, 
14                 BC_WindowBase *window,
15                 int x,
16                 int y)
18         this->mwindow = mwindow;
19         this->record = record;
20         this->window = window;
21         this->x = x;
22         this->y = y;
25 int RecordTransport::create_objects()
27         int x = this->x, y = this->y;
29         window->add_subwindow(rewind_button = new RecordGUIRewind(mwindow, record, x, y));
30         x += rewind_button->get_w();
31 //      window->add_subwindow(back_button = new RecordGUIBack(mwindow, record, x, y));
32 //      x += back_button->get_w();
33 //      window->add_subwindow(duplex_button = new RecordGUIDuplex(mwindow, x, y));
34 //      x += duplex_button->get_w();
35         window->add_subwindow(record_button = new RecordGUIRec(mwindow, record, x, y));
36         x += record_button->get_w();
38         record_frame = 0;
39         if(record->default_asset->video_data)
40         {
41                 window->add_subwindow(
42                         record_frame = new RecordGUIRecFrame(mwindow, 
43                                 record, 
44                                 x, 
45                                 y));
46                 x += record_frame->get_w();
47         }
49 //      window->add_subwindow(play_button = new RecordGUIPlay(mwindow, x, y));
50 //      x += play_button->get_w();
51         window->add_subwindow(stop_button = new RecordGUIStop(mwindow, record, x, y));
52         x += stop_button->get_w();
53 //      window->add_subwindow(fwd_button = new RecordGUIFwd(mwindow, record, x, y));
54 //      x += fwd_button->get_w();
55 //      window->add_subwindow(end_button = new RecordGUIEnd(mwindow, record, x, y));
56 //      x += end_button->get_w();
57         x_end = x + 10;
58         return 0;
61 void RecordTransport::reposition_window(int x, int y)
63         this->x = x;
64         this->y = y;
65         rewind_button->reposition_window(x, y);
66         x += rewind_button->get_w();
67 //      duplex_button->reposition_window(x, y);
68 //      x += duplex_button->get_w();
69         record_button->reposition_window(x, y);
70         x += record_button->get_w();
72         if(record->default_asset->video_data)
73         {
74                 record_frame->reposition_window(x, y);
75                 x += record_frame->get_w();
76         }
78         stop_button->reposition_window(x, y);
79         x += stop_button->get_w();
80         x_end = x + 10;
83 int RecordTransport::get_h()
85         return rewind_button->get_h();
88 int RecordTransport::get_w()
90         return rewind_button->get_w() + 
91                 record_button->get_w() +
92                 (record_frame ? record_frame->get_w() : 0) +
93                 stop_button->get_w();
99 RecordTransport::~RecordTransport()
103 int RecordTransport::keypress_event()
105         if(window->get_keypress() == ' ')
106         {
107 //printf("RecordTransport::keypress_event 1\n");
108                 switch(record->capture_state)
109                 {
110                         case IS_RECORDING:
111                         case IS_PREVIEWING:
112                                 window->unlock_window();
113                                 record->stop_operation(1);
114                                 window->lock_window("RecordTransport::keypress_event 1");
115                                 break;
117                         default:
118                                 window->unlock_window();
119                                 record->start_recording(0, CONTEXT_INTERACTIVE);
120                                 window->lock_window("RecordTransport::keypress_event 2");
121                                 break;
122                 }
123 //printf("RecordTransport::keypress_event 2\n");
124                 return 1;
125         }
126         return 0;
130 RecordGUIRec::RecordGUIRec(MWindow *mwindow, Record *record, int x, int y)
131  : BC_Button(x, y, mwindow->theme->get_image_set("record"))
133         this->mwindow = mwindow;
134         this->record = record;
135         set_tooltip(_("Start interactive recording\nfrom current position"));
138 RecordGUIRec::~RecordGUIRec()
142 int RecordGUIRec::handle_event()
144         unlock_window();
145         record->start_recording(0, CONTEXT_INTERACTIVE);
146         lock_window("RecordGUIRec::handle_event");
147         return 1;
150 int RecordGUIRec::keypress_event()
152         return 0;
155 RecordGUIRecFrame::RecordGUIRecFrame(MWindow *mwindow, Record *record, int x, int y)
156  : BC_Button(x, y, mwindow->theme->get_image_set("recframe"))
158         this->record = record; 
159         set_tooltip(_("Record single frame"));
162 RecordGUIRecFrame::~RecordGUIRecFrame()
166 int RecordGUIRecFrame::handle_event()
168         unlock_window();
169         record->start_recording(0, CONTEXT_SINGLEFRAME);
170         lock_window("RecordGUIRecFrame::handle_event");
171         return 1;
174 int RecordGUIRecFrame::keypress_event()
176         return 0;
179 RecordGUIPlay::RecordGUIPlay(MWindow *mwindow, int x, int y)
180  : BC_Button(x, y, mwindow->theme->get_image_set("play"))
182 //      this->engine = engine; 
183         set_tooltip(_("Preview recording"));
186 RecordGUIPlay::~RecordGUIPlay()
190 int RecordGUIPlay::handle_event()
192         unlock_window();
193 //      engine->start_preview();
194         lock_window();
195         return 1;
198 int RecordGUIPlay::keypress_event()
200         return 0;
204 RecordGUIStop::RecordGUIStop(MWindow *mwindow, Record *record, int x, int y)
205  : BC_Button(x, y, mwindow->theme->get_image_set("stoprec"))
207         this->record = record; 
208         set_tooltip(_("Stop operation"));
211 RecordGUIStop::~RecordGUIStop()
215 int RecordGUIStop::handle_event()
217         unlock_window();
218         record->stop_operation(1);
219         lock_window("RecordGUIStop::handle_event");
220         return 1;
223 int RecordGUIStop::keypress_event()
225         return 0;
230 RecordGUIRewind::RecordGUIRewind(MWindow *mwindow, Record *record, int x, int y)
231  : BC_Button(x, y, mwindow->theme->get_image_set("rewind"))
233         this->record = record; 
234         set_tooltip(_("Start over"));
237 RecordGUIRewind::~RecordGUIRewind()
241 int RecordGUIRewind::handle_event()
243         if(!record->record_gui->startover_thread->running())
244                 record->record_gui->startover_thread->start();
245         return 1;
248 int RecordGUIRewind::keypress_event()
250         return 0;
255 RecordGUIBack::RecordGUIBack(MWindow *mwindow, Record *record, int x, int y)
256  : BC_Button(x, y, mwindow->theme->get_image_set("fastrev"))
258         this->record = record; 
259         set_tooltip(_("Fast rewind"));
262 RecordGUIBack::~RecordGUIBack()
266 int RecordGUIBack::handle_event()
268         return 1;
271 int RecordGUIBack::button_press()
273 //      unlock_window();
274 //      engine->stop_operation(1);
275 //      lock_window();
276 // 
277 //      engine->reset_current_delay();
278 //      set_repeat(engine->get_current_delay());
279 //      count = 0;
280         return 1;
283 int RecordGUIBack::button_release()
285         unset_repeat(repeat_id);
286 //      if(!count) engine->goto_prev_label();
287         return 1;
290 int RecordGUIBack::repeat_event()
292 return 0;
293 //      long jump;
294 //      count++;
295 // 
296 //      set_repeat(record->get_current_delay());
297 // 
298 //      jump = engine->current_position - record->get_samplerate();
299 // 
300 //      if(jump < 0) jump = 0;
301 //      engine->update_position(jump);
302 //      if(record->do_audio) engine->file->set_audio_position(engine->current_position, record->);
303 //      if(record->do_video) engine->file->set_video_position((long)(Units::toframes(engine->current_position, 
304 //              record->get_samplerate(), 
305 //              record->get_framerate())), 
306 //              record->get_framerate());
307         return 1;        // trap it
310 int RecordGUIBack::keypress_event()
312         return 0;
317 RecordGUIFwd::RecordGUIFwd(MWindow *mwindow, Record *record, int x, int y)
318  : BC_Button(x, y, mwindow->theme->get_image_set("fastfwd"))
320         this->engine = engine; 
321         this->record = record; 
322         set_tooltip(_("Fast forward"));
325 RecordGUIFwd::~RecordGUIFwd()
329 int RecordGUIFwd::handle_event()
331         return 1;
334 int RecordGUIFwd::button_press()
336 //      unlock_window();
337 //      engine->stop_operation(1);
338 //      lock_window();
339 // 
340 //      engine->reset_current_delay();
341 //      set_repeat(engine->get_current_delay());
342 //      count = 0;
343         return 1;
346 int RecordGUIFwd::button_release()
348         unset_repeat(repeat_id);
349 //      if(!count) engine->goto_next_label();
350         return 1;
353 int RecordGUIFwd::repeat_event()
355 return 0;
356 //      long jump;
357 //      
358 //      count++;
359 //      
360 //      set_repeat(engine->get_current_delay());
361 // 
362 //      jump = engine->current_position + engine->get_samplerate();
363 //      if(jump > engine->total_length) jump = engine->total_length;
364 //      engine->update_position(jump);
365 //      if(record->do_audio) engine->file->set_audio_position((long)engine->current_position);
366 //      if(record->do_video) engine->file->set_video_position((long)Units::toframes(engine->current_position, record->get_samplerate(), record->get_framerate()), record->get_framerate());
367 //      return 1;         // trap it
370 int RecordGUIFwd::keypress_event()
372         return 0;
377 RecordGUIEnd::RecordGUIEnd(MWindow *mwindow, Record *record, int x, int y)
378  : BC_Button(x, y, mwindow->theme->get_image_set("end"))
380         this->engine = engine; 
381         this->record = record; 
382         set_tooltip(_("Seek to end of recording"));
385 RecordGUIEnd::~RecordGUIEnd()
389 int RecordGUIEnd::handle_event()
391 //      if((record->do_audio && engine->file->get_audio_length() > 0) ||
392 //              (record->do_video && engine->file->get_video_length(record->get_frame_rate()) > 0))
393 //      {
394 //              unlock_window();
395 //              engine->stop_operation(1);
396 //              lock_window();
397 // 
398 //              engine->file->seek_end();
399 //              engine->update_position(engine->total_length);
400 //      }
401         return 1;
404 int RecordGUIEnd::keypress_event()
406         return 0;
409 // 
410 // RecordGUIDuplex::RecordGUIDuplex(MWindow *mwindow, int x, int y)
411 //  : BC_Button(x, y, mwindow->theme->duplex_data)
412 // { 
413 //      this->engine = engine; 
414 //      set_tooltip(_("Start full duplex recording"));
415 // }
416 // 
417 // RecordGUIDuplex::~RecordGUIDuplex()
418 // {
419 // }
420 //      
421 // int RecordGUIDuplex::handle_event()
422 // {
423 //      unlock_window();
424 // //   engine->start_saving(1);
425 //      lock_window();
426 //      return 1;
427 // }