r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / recordtransport.C
blob8fb86b2c3621041c3881dbd37f807c58d2389549
1 #include "assets.h"
2 #include "file.h"
3 #include "mwindow.h"
4 #include "record.h"
5 #include "recordgui.h"
6 #include "recordtransport.h"
7 #include "theme.h"
8 #include "units.h"
10 #include <libintl.h>
11 #define _(String) gettext(String)
12 #define gettext_noop(String) String
13 #define N_(String) gettext_noop (String)
16 RecordTransport::RecordTransport(MWindow *mwindow, 
17                 Record *record, 
18                 BC_WindowBase *window,
19                 int x,
20                 int y)
22         this->mwindow = mwindow;
23         this->record = record;
24         this->window = window;
25         this->x = x;
26         this->y = y;
29 int RecordTransport::create_objects()
31         int x = this->x, y = this->y;
33         window->add_subwindow(rewind_button = new RecordGUIRewind(mwindow, record, x, y));
34         x += rewind_button->get_w();
35 //      window->add_subwindow(back_button = new RecordGUIBack(mwindow, record, x, y));
36 //      x += back_button->get_w();
37 //      window->add_subwindow(duplex_button = new RecordGUIDuplex(mwindow, x, y));
38 //      x += duplex_button->get_w();
39         window->add_subwindow(record_button = new RecordGUIRec(mwindow, record, x, y));
40         x += record_button->get_w();
42         if(record->default_asset->video_data)
43         {
44                 window->add_subwindow(
45                         record_frame = new RecordGUIRecFrame(mwindow, 
46                                 record, 
47                                 x, 
48                                 y));
49                 x += record_frame->get_w();
50         }
52 //      window->add_subwindow(play_button = new RecordGUIPlay(mwindow, x, y));
53 //      x += play_button->get_w();
54         window->add_subwindow(stop_button = new RecordGUIStop(mwindow, record, x, y));
55         x += stop_button->get_w();
56 //      window->add_subwindow(fwd_button = new RecordGUIFwd(mwindow, record, x, y));
57 //      x += fwd_button->get_w();
58 //      window->add_subwindow(end_button = new RecordGUIEnd(mwindow, record, x, y));
59 //      x += end_button->get_w();
60         x_end = x + 10;
61         return 0;
64 void RecordTransport::reposition_window(int x, int y)
66         this->x = x;
67         this->y = y;
68         rewind_button->reposition_window(x, y);
69         x += rewind_button->get_w();
70 //      duplex_button->reposition_window(x, y);
71 //      x += duplex_button->get_w();
72         record_button->reposition_window(x, y);
73         x += record_button->get_w();
75         if(record->default_asset->video_data)
76         {
77                 record_frame->reposition_window(x, y);
78                 x += record_frame->get_w();
79         }
81         stop_button->reposition_window(x, y);
82         x += stop_button->get_w();
83         x_end = x + 10;
92 RecordTransport::~RecordTransport()
96 int RecordTransport::keypress_event()
98         if(window->get_keypress() == ' ')
99         {
100 //printf("RecordTransport::keypress_event 1\n");
101                 switch(record->capture_state)
102                 {
103                         case IS_RECORDING:
104                         case IS_PREVIEWING:
105                                 window->unlock_window();
106                                 record->stop_operation(1);
107                                 window->lock_window();
108                                 break;
110                         default:
111                                 window->unlock_window();
112                                 record->start_recording(0, CONTEXT_INTERACTIVE);
113                                 window->lock_window();
114                                 break;
115                 }
116 //printf("RecordTransport::keypress_event 2\n");
117                 return 1;
118         }
119         return 0;
123 RecordGUIRec::RecordGUIRec(MWindow *mwindow, Record *record, int x, int y)
124  : BC_Button(x, y, mwindow->theme->rec_data)
126         this->mwindow = mwindow;
127         this->record = record;
128         set_tooltip(_("Start interactive recording\nfrom current position"));
131 RecordGUIRec::~RecordGUIRec()
135 int RecordGUIRec::handle_event()
137         unlock_window();
138         record->start_recording(0, CONTEXT_INTERACTIVE);
139         lock_window();
140         return 1;
143 int RecordGUIRec::keypress_event()
145         return 0;
148 RecordGUIRecFrame::RecordGUIRecFrame(MWindow *mwindow, Record *record, int x, int y)
149  : BC_Button(x, y, mwindow->theme->recframe_data)
151         this->record = record; 
152         set_tooltip(_("Record single frame"));
155 RecordGUIRecFrame::~RecordGUIRecFrame()
159 int RecordGUIRecFrame::handle_event()
161         unlock_window();
162         record->start_recording(0, CONTEXT_SINGLEFRAME);
163         lock_window();
164         return 1;
167 int RecordGUIRecFrame::keypress_event()
169         return 0;
172 RecordGUIPlay::RecordGUIPlay(MWindow *mwindow, int x, int y)
173  : BC_Button(x, y, mwindow->theme->forward_data)
175 //      this->engine = engine; 
176         set_tooltip(_("Preview recording"));
179 RecordGUIPlay::~RecordGUIPlay()
183 int RecordGUIPlay::handle_event()
185         unlock_window();
186 //      engine->start_preview();
187         lock_window();
188         return 1;
191 int RecordGUIPlay::keypress_event()
193         return 0;
197 RecordGUIStop::RecordGUIStop(MWindow *mwindow, Record *record, int x, int y)
198  : BC_Button(x, y, mwindow->theme->stoprec_data)
200         this->record = record; 
201         set_tooltip(_("Stop operation"));
204 RecordGUIStop::~RecordGUIStop()
208 int RecordGUIStop::handle_event()
210         unlock_window();
211         record->stop_operation(1);
212         lock_window();
213         return 1;
216 int RecordGUIStop::keypress_event()
218         return 0;
223 RecordGUIRewind::RecordGUIRewind(MWindow *mwindow, Record *record, int x, int y)
224  : BC_Button(x, y, mwindow->theme->rewind_data)
226         this->record = record; 
229 RecordGUIRewind::~RecordGUIRewind()
233 int RecordGUIRewind::handle_event()
235         if(!record->record_gui->startover_thread->running())
236                 record->record_gui->startover_thread->start();
237         return 1;
240 int RecordGUIRewind::keypress_event()
242         return 0;
247 RecordGUIBack::RecordGUIBack(MWindow *mwindow, Record *record, int x, int y)
248  : BC_Button(x, y, mwindow->theme->fastrev_data)
250         this->record = record; 
251         set_tooltip(_("Fast rewind"));
254 RecordGUIBack::~RecordGUIBack()
258 int RecordGUIBack::handle_event()
260         return 1;
263 int RecordGUIBack::button_press()
265 //      unlock_window();
266 //      engine->stop_operation(1);
267 //      lock_window();
268 // 
269 //      engine->reset_current_delay();
270 //      set_repeat(engine->get_current_delay());
271 //      count = 0;
272         return 1;
275 int RecordGUIBack::button_release()
277         unset_repeat(repeat_id);
278 //      if(!count) engine->goto_prev_label();
279         return 1;
282 int RecordGUIBack::repeat_event()
284 return 0;
285 //      long jump;
286 //      count++;
287 // 
288 //      set_repeat(record->get_current_delay());
289 // 
290 //      jump = engine->current_position - record->get_samplerate();
291 // 
292 //      if(jump < 0) jump = 0;
293 //      engine->update_position(jump);
294 //      if(record->do_audio) engine->file->set_audio_position(engine->current_position, record->);
295 //      if(record->do_video) engine->file->set_video_position((long)(Units::toframes(engine->current_position, 
296 //              record->get_samplerate(), 
297 //              record->get_framerate())), 
298 //              record->get_framerate());
299         return 1;        // trap it
302 int RecordGUIBack::keypress_event()
304         return 0;
309 RecordGUIFwd::RecordGUIFwd(MWindow *mwindow, Record *record, int x, int y)
310  : BC_Button(x, y, mwindow->theme->fastfwd_data)
312         this->engine = engine; 
313         this->record = record; 
314         set_tooltip(_("Fast forward"));
317 RecordGUIFwd::~RecordGUIFwd()
321 int RecordGUIFwd::handle_event()
323         return 1;
326 int RecordGUIFwd::button_press()
328 //      unlock_window();
329 //      engine->stop_operation(1);
330 //      lock_window();
331 // 
332 //      engine->reset_current_delay();
333 //      set_repeat(engine->get_current_delay());
334 //      count = 0;
335         return 1;
338 int RecordGUIFwd::button_release()
340         unset_repeat(repeat_id);
341 //      if(!count) engine->goto_next_label();
342         return 1;
345 int RecordGUIFwd::repeat_event()
347 return 0;
348 //      long jump;
349 //      
350 //      count++;
351 //      
352 //      set_repeat(engine->get_current_delay());
353 // 
354 //      jump = engine->current_position + engine->get_samplerate();
355 //      if(jump > engine->total_length) jump = engine->total_length;
356 //      engine->update_position(jump);
357 //      if(record->do_audio) engine->file->set_audio_position((long)engine->current_position);
358 //      if(record->do_video) engine->file->set_video_position((long)Units::toframes(engine->current_position, record->get_samplerate(), record->get_framerate()), record->get_framerate());
359 //      return 1;         // trap it
362 int RecordGUIFwd::keypress_event()
364         return 0;
369 RecordGUIEnd::RecordGUIEnd(MWindow *mwindow, Record *record, int x, int y)
370  : BC_Button(x, y, mwindow->theme->end_data)
372         this->engine = engine; 
373         this->record = record; 
374         set_tooltip(_("Seek to end of recording"));
377 RecordGUIEnd::~RecordGUIEnd()
381 int RecordGUIEnd::handle_event()
383 //      if((record->do_audio && engine->file->get_audio_length() > 0) ||
384 //              (record->do_video && engine->file->get_video_length(record->get_frame_rate()) > 0))
385 //      {
386 //              unlock_window();
387 //              engine->stop_operation(1);
388 //              lock_window();
389 // 
390 //              engine->file->seek_end();
391 //              engine->update_position(engine->total_length);
392 //      }
393         return 1;
396 int RecordGUIEnd::keypress_event()
398         return 0;
401 // 
402 // RecordGUIDuplex::RecordGUIDuplex(MWindow *mwindow, int x, int y)
403 //  : BC_Button(x, y, mwindow->theme->duplex_data)
404 // { 
405 //      this->engine = engine; 
406 //      set_tooltip(_("Start full duplex recording"));
407 // }
408 // 
409 // RecordGUIDuplex::~RecordGUIDuplex()
410 // {
411 // }
412 //      
413 // int RecordGUIDuplex::handle_event()
414 // {
415 //      unlock_window();
416 // //   engine->start_saving(1);
417 //      lock_window();
418 //      return 1;
419 // }