r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / recordgui.C
blob7a369eadd3fab059788ef8887dcff3d8d3bb4539
1 #include "assets.h"
2 #include "batch.h"
3 #include "browsebutton.h"
4 #include "channelpicker.h"
5 #include "defaults.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "file.h"
9 #include "filemov.h"
10 #include "filesystem.h"
11 #include "keys.h"
12 #include "loadmode.h"
13 #include "mwindow.h"
14 #include "mwindowgui.h"
15 #include "preferences.h"
16 #include "question.h"
17 #include "recconfirmdelete.h"
18 #include "recordgui.h"
19 #include "record.h"
20 #include "recordlabel.h"
21 #include "recordmonitor.h"
22 #include "recordtransport.h"
23 #include "recordvideo.h"
24 #include "mainsession.h"
25 #include "theme.h"
26 #include "units.h"
27 #include "videodevice.h"
29 #include <time.h>
32 #include <libintl.h>
33 #define _(String) gettext(String)
34 #define gettext_noop(String) String
35 #define N_(String) gettext_noop (String)
38 RecordGUI::RecordGUI(MWindow *mwindow, Record *record)
39  : BC_Window(PROGRAM_NAME ": Recording", 
40         mwindow->session->rwindow_x, 
41         mwindow->session->rwindow_y, 
42         mwindow->session->rwindow_w, 
43         mwindow->session->rwindow_h,
44         10,
45         10,
46         1,
47         0,
48         1)
50         this->mwindow = mwindow;
51         this->record = record;
54 RecordGUI::~RecordGUI()
56 //      delete batch_number;
57 //printf("RecordGUI::~RecordGUI 1\n");
58         delete status_thread;
59 //printf("RecordGUI::~RecordGUI 1\n");
60         delete batch_source;
61 //printf("RecordGUI::~RecordGUI 1\n");
62         delete batch_mode;
63 //printf("RecordGUI::~RecordGUI 1\n");
64         delete startover_thread;
65 //printf("RecordGUI::~RecordGUI 1\n");
66         delete cancel_thread;
67 //printf("RecordGUI::~RecordGUI 1\n");
68         delete batch_start;
69 //printf("RecordGUI::~RecordGUI 1\n");
70         delete batch_duration;
71 //printf("RecordGUI::~RecordGUI 1\n");
72         delete load_mode;
73 //printf("RecordGUI::~RecordGUI 2\n");
77 char* RecordGUI::batch_titles[] = 
79         N_("On"),
80         N_("Path"),
81         N_("News"),
82         N_("Start time"),
83         N_("Duration"),
84         N_("Source"),
85         N_("Mode")
88 void RecordGUI::load_defaults()
90         static int default_columnwidth[] =
91         {
92                 30,
93                 200,
94                 100,
95                 100,
96                 100,
97                 100,
98                 70
99         };
101         char string[BCTEXTLEN];
102         for(int i = 0; i < BATCH_COLUMNS; i++)
103         {
104                 sprintf(string, "BATCH_COLUMNWIDTH_%d", i);
105                 column_widths[i] = mwindow->defaults->get(string, default_columnwidth[i]);
106         }
109 void RecordGUI::save_defaults()
111         char string[BCTEXTLEN];
112         for(int i = 0; i < BATCH_COLUMNS; i++)
113         {
114                 sprintf(string, "BATCH_COLUMNWIDTH_%d", i);
115                 mwindow->defaults->update(string, column_widths[i]);
116         }
120 int RecordGUI::create_objects()
122         char string[BCTEXTLEN];
123         flash_color = RED;
125         status_thread = new RecordStatusThread(mwindow, this);
126         status_thread->start();
127         set_icon(mwindow->theme->record_icon);
129         mwindow->theme->get_recordgui_sizes(this, get_w(), get_h());
130 //printf("RecordGUI::create_objects 1\n");
131         mwindow->theme->draw_rwindow_bg(this);
134         monitor_video = 0;
135         monitor_audio = 0;
136         total_dropped_frames = 0;
137         batch_list = 0;
138         update_batches();
139         modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_INFINITE)));
140         modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_TIMED)));
141 //      modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_LOOP)));
142 //      modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_SCENETOSCENE)));
143         total_length = 0;
145 // Status
146         int x = mwindow->theme->recordgui_status_x;
147         int y = mwindow->theme->recordgui_status_y;
148         int x1 = mwindow->theme->recordgui_status_x2;
150         add_subwindow(new BC_Title(x, y, _("Format:")));
151         add_subwindow(new BC_Title(x1, 
152                 y, 
153                 File::formattostr(mwindow->plugindb, 
154                         record->default_asset->format), 
155                 MEDIUMFONT, 
156                 mwindow->theme->recordgui_fixed_color));
158         if(record->default_asset->audio_data)
159         {
160                 y += 20;
161                 add_subwindow(new BC_Title(x, y, _("Audio compression:")));
162                 add_subwindow(new BC_Title(x1, 
163                         y, 
164                         File::bitstostr(record->default_asset->bits), 
165                         MEDIUMFONT, 
166                         mwindow->theme->recordgui_fixed_color));
168                 y += 20;
169                 add_subwindow(new BC_Title(x, y, _("Samplerate:")));
170                 sprintf(string, "%d", record->default_asset->sample_rate);
171                 add_subwindow(new BC_Title(x1, 
172                         y, 
173                         string, 
174                         MEDIUMFONT, 
175                         mwindow->theme->recordgui_fixed_color));
177                 y += 20;
178                 add_subwindow(new BC_Title(x, y, _("Clipped samples:")));
179                 add_subwindow(samples_clipped = new BC_Title(x1, 
180                         y, 
181                         "0", 
182                         MEDIUMFONT, 
183                         mwindow->theme->recordgui_variable_color));
184         }
186         if(record->default_asset->video_data)
187         {
188                 y += 20;
189                 add_subwindow(new BC_Title(x, y, _("Video compression:")));
190                 add_subwindow(new BC_Title(x1, 
191                         y, 
192                         FileMOV::compressiontostr(record->default_asset->vcodec), 
193                         MEDIUMFONT, 
194                         mwindow->theme->recordgui_fixed_color));
195         
196                 y += 20;
197                 add_subwindow(new BC_Title(x, y, _("Framerate:")));
198                 sprintf(string, "%0.2f", record->default_asset->frame_rate);
199                 add_subwindow(new BC_Title(x1, 
200                         y, 
201                         string, 
202                         MEDIUMFONT, 
203                         mwindow->theme->recordgui_fixed_color));
204         
205                 y += 20;
206                 add_subwindow(new BC_Title(x, y, _("Frames behind:")));
207                 add_subwindow(frames_dropped = new BC_Title(x1, 
208                         y, 
209                         "0", 
210                         MEDIUMFONT, 
211                         mwindow->theme->recordgui_variable_color));
212         }
214         y += 20;
215         add_subwindow(new BC_Title(x, y, _("Position:")));
216         add_subwindow(position_title = new BC_Title(x1, 
217                 y, 
218                 "", 
219                 MEDIUMFONT, 
220                 mwindow->theme->recordgui_variable_color));
221         
222         y += 20;
223         add_subwindow(new BC_Title(x, y, _("End:")));
224         add_subwindow(total_length_title = new BC_Title(x1, 
225                 y, 
226                 "", 
227                 MEDIUMFONT, 
228                 mwindow->theme->recordgui_variable_color));
230         y += 20;
231         add_subwindow(new BC_Title(x, y, _("Prev label:")));
232         add_subwindow(prev_label_title = new BC_Title(x1, 
233                 y, 
234                 _("None"), 
235                 MEDIUMFONT, 
236                 mwindow->theme->recordgui_variable_color));
237         
238 //      y += 20;
239 //      add_subwindow(new BC_Title(x, y, _("Next label:")));
240 //      add_subwindow(next_label_title = new BC_Title(x1, 
241 //              y, 
242 //              _("None"), 
243 //              MEDIUMFONT, 
244 //              mwindow->theme->recordgui_variable_color));
245 // 
246 // Curent batch
247         x = mwindow->theme->recordgui_batch_x;
248         y = mwindow->theme->recordgui_batch_y;
249         x1 = mwindow->theme->recordgui_batchcaption_x;
251         add_subwindow(batch_path_title = new BC_Title(x, y, _("Path:")));
252         add_subwindow(batch_path = new RecordPath(mwindow, record, x1, y));
253         add_subwindow(batch_browse = new BrowseButton(mwindow, 
254                 this, 
255                 batch_path, 
256                 batch_path->get_x() + batch_path->get_w(), 
257                 y,
258                 record->default_asset->path,
259                 PROGRAM_NAME ": Record path",
260                 _("Select a file to record to:"),
261                 0));
263         y += 30;
264         add_subwindow(batch_start_title = new BC_Title(x, y, _("Start time:")));
265         batch_start = new RecordStart(mwindow, record, x1, y);
266         batch_start->create_objects();
268         y += 30;
269         add_subwindow(batch_duration_title = new BC_Title(x, y, _("Duration time:")));
270         batch_duration = new RecordDuration(mwindow, record, x1, y);
271         batch_duration->create_objects();
273         y += 30;
274         add_subwindow(batch_source_title = new BC_Title(x, y, _("Source:")));
275         batch_source = new RecordSource(mwindow, record, this, x1, y);
276         batch_source->create_objects();
277         y += 30;
278         add_subwindow(batch_mode_title = new BC_Title(x, y, _("Mode:")));
279         batch_mode = new RecordMode(mwindow, record, this, x1, y);
280         batch_mode->create_objects();
281         y += 30;
283         add_subwindow(transport_title = 
284                 new BC_Title(mwindow->theme->recordgui_transport_x, 
285                         mwindow->theme->recordgui_transport_y, _("Transport:")));
286         record_transport = new RecordTransport(mwindow, 
287                 record, 
288                 this, 
289                 x1,
290                 mwindow->theme->recordgui_transport_y + 5);
291         record_transport->create_objects();
293         x = mwindow->theme->recordgui_buttons_x;
294         y = mwindow->theme->recordgui_buttons_y;
295         add_subwindow(new_batch = new RecordGUINewBatch(mwindow, record, x, y));
296         x += new_batch->get_w() + 5;
297         add_subwindow(delete_batch = new RecordGUIDeleteBatch(mwindow, record, x, y));
298         x += delete_batch->get_w() + 5;
299         add_subwindow(start_batches = new RecordGUIStartBatches(mwindow, record, x, y));
300         x += start_batches->get_w() + 5;
301         add_subwindow(activate_batch = new RecordGUIActivateBatch(mwindow, record, x, y));
302         x += activate_batch->get_w() + 5;
303         add_subwindow(label_button = new RecordGUILabel(mwindow, record, x, y));
305         x = mwindow->theme->recordgui_options_x;
306         y = mwindow->theme->recordgui_options_y;
308         if(record->default_asset->video_data) 
309         {
310                 add_subwindow(fill_frames = new RecordGUIFillFrames(mwindow, record, x, y));
311                 x += fill_frames->get_w() + 5;
312                 add_subwindow(monitor_video = new RecordGUIMonitorVideo(mwindow, record, x, y));
313                 x += monitor_video->get_w() + 5;
314         }
316         if(record->default_asset->audio_data) 
317                 add_subwindow(monitor_audio = new RecordGUIMonitorAudio(mwindow, record, x, y));
319 // Batches
320         add_subwindow(batch_list = new RecordGUIBatches(record, 
321                 this, 
322                 mwindow->theme->recordgui_batches_x, 
323                 mwindow->theme->recordgui_batches_y,
324                 mwindow->theme->recordgui_batches_w,
325                 mwindow->theme->recordgui_batches_h));
327 // Controls
328         load_mode = new LoadMode(mwindow,
329                 this, 
330                 mwindow->theme->recordgui_loadmode_x, 
331                 mwindow->theme->recordgui_loadmode_y, 
332                 &record->load_mode, 
333                 1);
334         load_mode->create_objects();
336         y = mwindow->theme->recordgui_controls_y;
337         x = mwindow->theme->recordgui_controls_x;
338         add_subwindow(save = new RecordGUISave(record, this, x, y));
340         x = get_w() - 90;
341         cancel_thread = new RecordCancelThread(record, this);
342         add_subwindow(cancel = new RecordGUICancel(record, this, x, y));
344         startover_thread = new RecordStartoverThread(record, this);
346 //printf("RecordGUI::create_objects 2\n");
347         return 0;
350 void RecordGUI::flash_batch()
352         if(record->current_batch < batches[0].total)
353         {
354                 if(flash_color == GREEN)
355                         flash_color = RED;
356                 else
357                         flash_color = GREEN;
359 //printf("RecordGUI::flash_batch %x\n", flash_color);
361                 for(int i = 0; i < BATCH_COLUMNS; i++)
362                 {
363                         BC_ListBoxItem *batch = batches[i].values[record->current_batch];
364                         batch->set_color(flash_color);
365                 }
366                 batch_list->update(batches,
367                         batch_titles,
368                         column_widths,
369                         BATCH_COLUMNS,
370                         batch_list->get_yposition(),
371                         batch_list->get_xposition(),
372                         batch_list->get_highlighted_item());
374                 batch_list->flush();
375         }
378 void RecordGUI::update_batches()
380         char string[BCTEXTLEN], string2[BCTEXTLEN];
381         FileSystem fs;
383         int selection_number = batch_list ? batch_list->get_selection_number(0, 0) : -1;
384         for(int j = 0; j < BATCH_COLUMNS; j++)
385         {
386                 batches[j].remove_all_objects();
387         }
389         for(int i = 0; i < record->batches.total; i++)
390         {
391                 Batch *batch = record->batches.values[i];
392                 int color = (i == record->current_batch) ? RED : BLACK;
393                 if(batch->waiting && time(0) & 0x1) color = GREEN;
395                 batches[0].append(new BC_ListBoxItem((char*)(batch->enabled ? "X" : " "), color));
396                 batches[1].append(new BC_ListBoxItem(batch->get_current_asset()->path, color));
397                 sprintf(string, "%s", batch->news);
398                 batches[2].append(new BC_ListBoxItem(string, RED));
399                 Units::totext(string2, 
400                                 batch->start_time, 
401                                 TIME_HMS, 
402                                 record->default_asset->sample_rate,
403                                 record->default_asset->frame_rate, 
404                                 mwindow->edl->session->frames_per_foot);
405                 sprintf(string, "%s %s", TimeEntry::day_table[batch->start_day], string2);
407                 batches[3].append(new BC_ListBoxItem(string, color));
408                 Units::totext(string, 
409                                 batch->duration, 
410                                 TIME_HMS, 
411                                 record->default_asset->sample_rate,
412                                 record->default_asset->frame_rate, 
413                                 mwindow->edl->session->frames_per_foot);
414                 batches[4].append(new BC_ListBoxItem(string, color));
415                 record->source_to_text(string, batch);
416                 batches[5].append(new BC_ListBoxItem(string, color));
417                 sprintf(string, "%s", Batch::mode_to_text(batch->record_mode));
418                 batches[6].append(new BC_ListBoxItem(string, color));
419                 
420                 if(i == selection_number)
421                 {
422                         for(int j = 0; j < BATCH_COLUMNS; j++)
423                         {
424                                 batches[j].values[i]->set_selected(1);
425                         }
426                 }
427         }
429         if(batch_list)
430         {
431                 batch_list->update(batches,
432                         batch_titles,
433                         column_widths,
434                         BATCH_COLUMNS,
435                         batch_list->get_yposition(),
436                         batch_list->get_xposition(),
437                         record->editing_batch,
438                         1);
439         }
440         flush();
443 void RecordGUI::update_batch_sources()
445 //printf("RecordGUI::update_batch_sources 1\n");
446         if(record->record_monitor->window->channel_picker)
447                 batch_source->update_list(&record->record_monitor->window->channel_picker->channel_listitems);
448 //printf("RecordGUI::update_batch_sources 2\n");
451 int RecordGUI::translation_event()
453         mwindow->session->rwindow_x = get_x();
454         mwindow->session->rwindow_y = get_y();
455         return 0;
459 int RecordGUI::resize_event(int w, int h)
461         int x, y, x1;
463         mwindow->session->rwindow_x = get_x();
464         mwindow->session->rwindow_y = get_y();
465         mwindow->session->rwindow_w = w;
466         mwindow->session->rwindow_h = h;
467         mwindow->theme->get_recordgui_sizes(this, w, h);
468         mwindow->theme->draw_rwindow_bg(this);
472         x = mwindow->theme->recordgui_batch_x;
473         y = mwindow->theme->recordgui_batch_y;
474         x1 = mwindow->theme->recordgui_batchcaption_x;
476         batch_path_title->reposition_window(x, y);
477         batch_path->reposition_window(x1, y);
478         batch_browse->reposition_window(batch_path->get_x() + batch_path->get_w(), 
479                 y);
480         y += 30;
481         batch_start_title->reposition_window(x, y);
482         batch_start->reposition_window(x1, y);
483         y += 30;
484         batch_duration_title->reposition_window(x, y);
485         batch_duration->reposition_window(x1, y);
486         y += 30;
487         batch_source_title->reposition_window(x, y);
488         batch_source->reposition_window(x1, y);
489         y += 30;
490         batch_mode_title->reposition_window(x, y);
491         batch_mode->reposition_window(x1, y);
492         
493         transport_title->reposition_window(mwindow->theme->recordgui_transport_x, 
494                 mwindow->theme->recordgui_transport_y);
495         record_transport->reposition_window(mwindow->theme->recordgui_batchcaption_x,
496                 mwindow->theme->recordgui_transport_y + 5);
497         
498         x = mwindow->theme->recordgui_buttons_x;
499         y = mwindow->theme->recordgui_buttons_y;
500         new_batch->reposition_window(x, y);
501         x += new_batch->get_w() + 5;
502         delete_batch->reposition_window(x, y);
503         x += delete_batch->get_w() + 5;
504         start_batches->reposition_window(x, y);
505         x += start_batches->get_w() + 5;
506         activate_batch->reposition_window(x, y);
507         x += activate_batch->get_w() + 5;
508         label_button->reposition_window(x, y);
511         batch_list->reposition_window(mwindow->theme->recordgui_batches_x, 
512                 mwindow->theme->recordgui_batches_y,
513                 mwindow->theme->recordgui_batches_w,
514                 mwindow->theme->recordgui_batches_h);
516         load_mode->reposition_window(mwindow->theme->recordgui_loadmode_x,
517                 mwindow->theme->recordgui_loadmode_y);
519         x = mwindow->theme->recordgui_controls_x;
520         y = mwindow->theme->recordgui_controls_y;
522         save->reposition_window(x, y);
524         x = w - 90;
525         cancel->reposition_window(x, y);
527         flash();
528         return 1;
531 void RecordGUI::update_batch_tools()
533 //printf("RecordGUI::update_batch_tools 1\n");
534         char string[BCTEXTLEN];
535         Batch *batch = record->get_editing_batch();
536         batch_path->update(batch->get_current_asset()->path);
538 // File is open in editing batch
539 //      if(record->current_batch == record->editing_batch && record->file)
540 //              batch_path->disable();
541 //      else
542 //              batch_path->enable();
544         batch_start->update(&batch->start_day, &batch->start_time);
545         batch_duration->update(0, &batch->duration);
546         batch_source->update(batch->get_source_text());
547         batch_mode->update(Batch::mode_to_text(batch->record_mode));
548         flush();
552 RecordGUIBatches::RecordGUIBatches(Record *record, RecordGUI *gui, int x, int y, int w, int h)
553  : BC_ListBox(x, 
554                 y, 
555                 w, 
556                 h,
557                 LISTBOX_TEXT,                   // Display text list or icons
558                 gui->batches,               // Each column has an ArrayList of BC_ListBoxItems.
559                 gui->batch_titles,             // Titles for columns.  Set to 0 for no titles
560                 gui->column_widths,                // width of each column
561                 BATCH_COLUMNS,                      // Total columns.
562                 0,                    // Pixel of top of window.
563                 0,                        // If this listbox is a popup window
564                 LISTBOX_SINGLE,  // Select one item or multiple items
565                 ICON_LEFT,        // Position of icon relative to text of each item
566                 1)           // Allow dragging
568         this->record = record;
569         this->gui = gui;
570         dragging_item = 0;
573 // Do nothing for double clicks to protect active batch
574 int RecordGUIBatches::handle_event()
576         return 1;
579 int RecordGUIBatches::selection_changed()
581         if(get_selection_number(0, 0) >= 0)
582         {
583                 int i = get_selection_number(0, 0);
584                 record->change_editing_batch(get_selection_number(0, 0));
585                 if(get_cursor_x() < gui->column_widths[0])
586                 {
587                         record->batches.values[i]->enabled = 
588                                 !record->batches.values[i]->enabled;
589                         gui->update_batches();
590                 }
591         }
592         return 1;
595 int RecordGUIBatches::column_resize_event()
597         for(int i = 0; i < BATCH_COLUMNS; i++)
598         {
599                 gui->column_widths[i] = get_column_width(i);
600         }
601         return 1;
604 int RecordGUIBatches::drag_start_event()
606         if(BC_ListBox::drag_start_event())
607         {
608                 dragging_item = 1;
609                 return 1;
610         }
612         return 0;
615 int RecordGUIBatches::drag_motion_event()
617         if(BC_ListBox::drag_motion_event())
618         {
619                 return 1;
620         }
621         return 0;
624 int RecordGUIBatches::drag_stop_event()
626         if(dragging_item)
627         {
628                 int src = record->editing_batch;
629                 int dst = get_highlighted_item();
630                 Batch *src_item = record->batches.values[src];
631                 if(dst < 0) dst = record->batches.total;
633                 for(int i = src; i < record->batches.total - 1; i++)
634                 {
635                         record->batches.values[i] = record->batches.values[i + 1];
636                 }
637                 if(dst > src) dst--;
638                 
639                 for(int i = record->batches.total - 1; i > dst; i--)
640                 {
641                         record->batches.values[i] = record->batches.values[i - 1];
642                 }
643                 record->batches.values[dst] = src_item;
645                 BC_ListBox::drag_stop_event();
647                 dragging_item = 0;
648                 gui->update_batches();
649         }
662 RecordGUISave::RecordGUISave(Record *record, RecordGUI *record_gui, int x, int y)
663  : BC_GenericButton(x, y, _("Close"))
665         set_tooltip(_("Save the recording and quit."));
666         this->record = record;
667         this->gui = record_gui;
670 int RecordGUISave::handle_event()
672         gui->set_done(0);
673         return 1;
676 int RecordGUISave::keypress_event()
678 //      if(get_keypress() == RETURN)
679 //      {
680 //              handle_event();
681 //              return 1;
682 //      }
684         return 0;
687 RecordGUICancel::RecordGUICancel(Record *record, RecordGUI *record_gui, int x, int y)
688  : BC_GenericButton(x, y, _("Cancel"))
690         set_tooltip(_("Quit without pasting into project."));
691         this->record = record;
692         this->gui = record_gui;
695 int RecordGUICancel::handle_event()
697         if(!gui->cancel_thread->running())
698                 gui->cancel_thread->start();
699         return 1;
702 int RecordGUICancel::keypress_event()
704         if(get_keypress() == ESC)
705         {
706                 handle_event();
707                 return 1;
708         }
710         return 0;
713 RecordGUIStartOver::RecordGUIStartOver(Record *record, RecordGUI *record_gui, int x, int y)
714  : BC_GenericButton(x, y, _("Start Over"))
716         set_tooltip(_("Rewind the current file and erase."));
717         this->record = record;
718         this->gui = record_gui;
720 RecordGUIStartOver::~RecordGUIStartOver()
724 int RecordGUIStartOver::handle_event()
726         if(!gui->startover_thread->running())
727                 gui->startover_thread->start();
728         return 1;
731 RecordGUIFillFrames::RecordGUIFillFrames(MWindow *mwindow, Record *record, int x, int y)
732  : BC_CheckBox(x, y, record->fill_frames, _("Fill frames"))
734         this->mwindow = mwindow;
735         this->record = record;
736         set_tooltip(_("Write extra frames when behind."));
739 int RecordGUIFillFrames::handle_event()
741 // Video capture constitutively, just like audio, but only flash on screen if 1
742         record->fill_frames = get_value();
743         return 1;
746 RecordGUIMonitorVideo::RecordGUIMonitorVideo(MWindow *mwindow, Record *record, int x, int y)
747  : BC_CheckBox(x, y, record->monitor_video, _("Monitor video"))
749         this->mwindow = mwindow;
750         this->record = record;
753 int RecordGUIMonitorVideo::handle_event()
755 // Video capture constitutively, just like audio, but only flash on screen if 1
756         record->monitor_video = get_value();
757         if(record->monitor_video)
758         {
759                 record->record_monitor->window->lock_window();
760                 record->record_monitor->window->show_window();
761                 record->record_monitor->window->raise_window();
762                 record->record_monitor->window->flush();
763                 record->record_monitor->window->unlock_window();
764                 record->video_window_open = 1;
765         }
766         return 1;
770 RecordGUIMonitorAudio::RecordGUIMonitorAudio(MWindow *mwindow, Record *record, int x, int y)
771  : BC_CheckBox(x, y, record->monitor_audio, _("Monitor audio"))
773         this->mwindow = mwindow;
774         this->record = record;
777 int RecordGUIMonitorAudio::handle_event()
779         record->monitor_audio = get_value();
780         if(record->monitor_audio)
781         {
782                 record->record_monitor->window->lock_window();
783                 record->record_monitor->window->show_window();
784                 record->record_monitor->window->raise_window();
785                 record->record_monitor->window->flush();
786                 record->record_monitor->window->unlock_window();
787                 record->video_window_open = 1;
788         }
789         return 1;
792 RecordBatch::RecordBatch(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
793  : BC_PopupTextBox(gui, 
794                 &gui->batch_numbers,
795                 gui->batch_numbers.values[record->editing_batch]->get_text(),
796                 x, 
797                 y, 
798                 100,
799                 200)
801         this->gui = gui;
802         this->mwindow = mwindow;
803         this->record = record;
805 int RecordBatch::handle_event()
807         return 1;
810 RecordPath::RecordPath(MWindow *mwindow, Record *record, int x, int y)
811  : BC_TextBox(x, y, 200, 1, record->get_editing_batch()->get_current_asset()->path)
813         this->mwindow = mwindow;
814         this->record = record;
816 int RecordPath::handle_event()
818         strcpy(record->get_editing_batch()->assets.values[0]->path, get_text());
819         record->get_editing_batch()->calculate_news();
820         record->record_gui->update_batches();
821         return 1;
824 RecordStartType::RecordStartType(MWindow *mwindow, Record *record, int x, int y)
825  : BC_CheckBox(x, y, record->get_editing_batch()->start_type, _("Offset"))
827         this->mwindow = mwindow;
828         this->record = record;
830 int RecordStartType::handle_event()
832         return 1;
836 RecordStart::RecordStart(MWindow *mwindow, Record *record, int x, int y)
837  : TimeEntry(record->record_gui, 
838                 x, 
839                 y, 
840                 &(record->get_editing_batch()->start_day), 
841                 &(record->get_editing_batch()->start_time))
843         this->mwindow = mwindow;
844         this->record = record;
846 int RecordStart::handle_event()
848         record->record_gui->update_batches();
849         return 1;
852 RecordDuration::RecordDuration(MWindow *mwindow, Record *record, int x, int y)
853  : TimeEntry(record->record_gui, 
854                 x, 
855                 y, 
856                 0, 
857                 &(record->get_editing_batch()->duration))
859         this->mwindow = mwindow;
860         this->record = record;
862 int RecordDuration::handle_event()
864         record->record_gui->update_batches();
865         return 1;
868 RecordSource::RecordSource(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
869  : BC_PopupTextBox(gui, 
870         &gui->sources,
871         record->get_editing_batch()->get_source_text(),
872         x, 
873         y, 
874         200,
875         200)
877         this->mwindow = mwindow;
878         this->record = record;
879         this->gui = gui;
881 int RecordSource::handle_event()
883         record->set_channel(get_number());
884         return 1;
887 RecordMode::RecordMode(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
888  : BC_PopupTextBox(gui,
889         &gui->modes,
890         Batch::mode_to_text(record->get_editing_batch()->record_mode),
891         x,
892         y,
893         200,
894         100)
896         this->mwindow = mwindow;
897         this->record = record;
899 int RecordMode::handle_event()
901         record->get_editing_batch()->record_mode = Batch::text_to_mode(get_text());
902         record->record_gui->update_batches();
903         return 1;
906 RecordNews::RecordNews(MWindow *mwindow, Record *record, int x, int y)
907  : BC_TextBox(x, y, 200, 1, record->get_editing_batch()->news)
909         this->mwindow = mwindow;
910         this->record = record;
912 int RecordNews::handle_event()
914         return 1;
918 RecordGUINewBatch::RecordGUINewBatch(MWindow *mwindow, Record *record, int x, int y)
919  : BC_GenericButton(x, y, _("New"))
921         this->mwindow = mwindow;
922         this->record = record;
923         set_tooltip(_("Create new clip."));
925 int RecordGUINewBatch::handle_event()
927         record->new_batch();
928         record->record_gui->update_batches();
929         return 1;
933 RecordGUIDeleteBatch::RecordGUIDeleteBatch(MWindow *mwindow, Record *record, int x, int y)
934  : BC_GenericButton(x, y, _("Delete"))
936         this->mwindow = mwindow;
937         this->record = record;
938         set_tooltip(_("Delete clip."));
940 int RecordGUIDeleteBatch::handle_event()
942         record->delete_batch();
943         record->record_gui->update_batches();
944         return 1;
948 RecordGUIStartBatches::RecordGUIStartBatches(MWindow *mwindow, Record *record, int x, int y)
949  : BC_GenericButton(x, y, _("Start"))
951         this->mwindow = mwindow;
952         this->record = record;
953         set_tooltip(_("Start batch recording\nfrom the current position."));
955 int RecordGUIStartBatches::handle_event()
957         unlock_window();
958         record->start_recording(0, CONTEXT_BATCH);
959         lock_window();
960         return 1;
964 RecordGUIStopbatches::RecordGUIStopbatches(MWindow *mwindow, Record *record, int x, int y)
965  : BC_GenericButton(x, y, _("Stop"))
967         this->mwindow = mwindow;
968         this->record = record;
970 int RecordGUIStopbatches::handle_event()
972         return 1;
976 RecordGUIActivateBatch::RecordGUIActivateBatch(MWindow *mwindow, Record *record, int x, int y)
977  : BC_GenericButton(x, y, _("Activate"))
979         this->mwindow = mwindow;
980         this->record = record;
981         set_tooltip(_("Make the highlighted\nclip active."));
983 int RecordGUIActivateBatch::handle_event()
985         record->activate_batch(record->editing_batch, 1);
986         return 1;
990 RecordGUILabel::RecordGUILabel(MWindow *mwindow, Record *record, int x, int y)
991  : BC_GenericButton(x, y, _("Label"))
993         this->mwindow = mwindow;
994         this->record = record;
995         set_underline(0);
999 RecordGUILabel::~RecordGUILabel()
1003 int RecordGUILabel::handle_event()
1005         record->toggle_label();
1006         return 1;
1009 int RecordGUILabel::keypress_event()
1011         if(get_keypress() == 'l')
1012         {
1013                 handle_event();
1014                 return 1;
1015         }
1016         return 0;
1035 RecordCancelThread::RecordCancelThread(Record *record, RecordGUI *record_gui)
1036  : Thread()
1038         this->record = record;
1039         this->gui = record_gui;
1042 RecordCancelThread::~RecordCancelThread()
1044         if(Thread::running()) 
1045         {
1046                 window->lock_window();
1047                 window->set_done(1);
1048                 window->unlock_window();
1049         }
1050         completion_lock.lock();
1051         completion_lock.unlock();
1055 void RecordCancelThread::run()
1057 //printf("RecordCancelThread::run 1\n");
1058         completion_lock.lock();
1059 //printf("RecordCancelThread::run 1\n");
1060         if(record->prompt_cancel)
1061         {
1062                 window = new QuestionWindow(record->mwindow);
1063                 window->create_objects(_("Quit without pasting into project?"), 0);
1064                 int result = window->run_window();
1065                 if(result == 2) gui->set_done(1);
1066                 delete window;
1067         }
1068         else
1069         {
1070                 gui->set_done(1);
1071         }
1072 //printf("RecordCancelThread::run 2\n");
1074         completion_lock.unlock();
1078 RecordStartoverThread::RecordStartoverThread(Record *record, RecordGUI *record_gui)
1079  : Thread()
1081         this->record = record;
1082         this->gui = record_gui;
1084 RecordStartoverThread::~RecordStartoverThread()
1086         if(Thread::running()) 
1087         {
1088                 window->lock_window();
1089                 window->set_done(1);
1090                 window->unlock_window();
1091         }
1092         completion_lock.lock();
1093         completion_lock.unlock();
1096 void RecordStartoverThread::run()
1098         completion_lock.lock();
1099         window = new QuestionWindow(record->mwindow);
1100         window->create_objects(_("Rewind batch and overwrite?"), 0);
1101         int result = window->run_window();
1102         if(result == 2) record->start_over();
1103         delete window;
1104         completion_lock.unlock();
1140 int RecordGUI::set_translation(int x, int y, float z)
1142         record->video_x = x;
1143         record->video_y = y;
1144         record->video_zoom = z;
1146         //record->video_lock.lock();
1147 //      engine->vdevice->set_translation(x, y, z);
1148 //      engine->vdevice->set_latency_counter(record->get_video_buffersize() * 2);
1149         //record->video_lock.unlock();
1152 int RecordGUI::update_dropped_frames(long new_dropped)
1154         status_thread->update_dropped_frames(new_dropped);
1155         return 0;
1158 int RecordGUI::update_position(double new_position, double new_length) 
1160         status_thread->update_position(new_position, new_length);
1161         return 0;
1164 int RecordGUI::update_clipped_samples(long new_clipped)
1166         status_thread->update_clipped_samples(new_clipped);
1167         return 0;
1170 int RecordGUI::keypress_event()
1172         return record_transport->keypress_event();
1175 void RecordGUI::update_labels(double new_position)
1177         RecordLabel *prev, *next;
1178         char string[BCTEXTLEN];
1180         for(prev = record->get_current_batch()->labels->last; 
1181                 prev; 
1182                 prev = prev->previous)
1183         {
1184                 if(prev->position <= new_position) break;
1185         }
1187         for(next = record->get_current_batch()->labels->first; 
1188                 next; 
1189                 next = next->next)
1190         {
1191                 if(next->position > new_position) break;
1192         }
1194         if(prev)
1195                 update_title(prev_label_title, 
1196                         prev->position);
1197         else
1198                 update_title(prev_label_title, -1);
1200 //      if(next)
1201 //              update_title(next_label_title, (double)next->position / record->default_asset->sample_rate);
1202 //      else
1203 //              update_title(next_label_title, -1);
1208 int RecordGUI::update_total_length(double new_position) 
1210         total_length = new_position;
1211         update_title(total_length_title, new_position); 
1212         return 0;
1215 int RecordGUI::update_prev_label(long new_position) 
1217         update_title(prev_label_title, new_position);
1220 // int RecordGUI::update_next_label(long new_position) 
1221 // { 
1222 //      update_title(next_label_title, new_position); 
1223 // }
1224 // 
1225 int RecordGUI::update_title(BC_Title *title, double position)
1227         static char string[256];
1229         if(position > -1)
1230         {
1231                 Units::totext(string, 
1232                                 position, 
1233                                 mwindow->edl->session->time_format, 
1234                                 record->default_asset->sample_rate, 
1235                                 record->default_asset->frame_rate, 
1236                                 mwindow->edl->session->frames_per_foot);
1237         }
1238         else
1239         {
1240                 sprintf(string, "-");
1241         }
1242         lock_window();
1243         title->update(string);
1244         unlock_window();
1247 int RecordGUI::update_duration_boxes()
1249         char string[1024];
1250 //      sprintf(string, "%d", engine->get_loop_hr());
1251 //      loop_hr->update(string);
1252 //      sprintf(string, "%d", engine->get_loop_min());
1253 //      loop_min->update(string);
1254 //      sprintf(string, "%d", engine->get_loop_sec());
1255 //      loop_sec->update(string);
1263 // ===================================== GUI
1269 // ================================================== modes
1271 RecordGUIModeMenu::RecordGUIModeMenu(int x, 
1272         int y, 
1273         int w, 
1274         char *text)
1275  : BC_PopupMenu(x, y, w, text)
1279 RecordGUIModeMenu::~RecordGUIModeMenu()
1281         delete linear;
1282         delete timed;
1283         delete loop;
1286 int RecordGUIModeMenu::add_items()
1288         add_item(linear = new RecordGUIMode(_("Untimed")));
1289         add_item(timed = new RecordGUIMode(_("Timed")));
1290 //      add_item(loop = new RecordGUIMode("_(Loop")));
1291         return 0;
1294 int RecordGUIModeMenu::handle_event()
1296 //      engine->set_record_mode(get_text());
1299 RecordGUIMode::RecordGUIMode(char *text)
1300  : BC_MenuItem(text)
1304 RecordGUIMode::~RecordGUIMode()
1308 int RecordGUIMode::handle_event()
1310         get_popup_menu()->set_text(get_text());
1311         get_popup_menu()->handle_event();
1312         return 1;
1319 RecordStatusThread::RecordStatusThread(MWindow *mwindow, RecordGUI *gui)
1320  : Thread()
1322         set_synchronous(1);
1323         this->mwindow = mwindow;
1324         this->gui = gui;
1325         new_dropped_frames = -1;
1326         new_position = -1;
1327         new_length = -1;
1328         new_clipped_samples = -1;
1329         input_lock.lock();
1330         done = 0;
1333 RecordStatusThread::~RecordStatusThread()
1335         if(Thread::running())
1336         {
1337                 done = 1;
1338                 input_lock.unlock();
1339                 Thread::join();
1340         }
1343 void RecordStatusThread::update_dropped_frames(long value)
1345         new_dropped_frames = value;
1346         input_lock.unlock();
1349 void RecordStatusThread::update_position(double new_position, double total_length)
1351         this->new_position = new_position;
1352         this->new_length = total_length;
1353         input_lock.unlock();
1356 void RecordStatusThread::update_clipped_samples(long new_clipped_samples)
1358         this->new_clipped_samples = new_clipped_samples;
1359         input_lock.unlock();
1362 void RecordStatusThread::run()
1364         while(!done)
1365         {
1366 //printf("RecordStatusThread::run 1\n");
1367                 input_lock.lock();
1368 //printf("RecordStatusThread::run 2\n");
1369                 if(new_dropped_frames >= 0)
1370                 {
1371                         char string[1024];
1372                         if(gui->total_dropped_frames != new_dropped_frames)
1373                         {
1374                                 gui->total_dropped_frames = new_dropped_frames;
1375                                 sprintf(string, "%d\n", gui->total_dropped_frames);
1376                                 gui->lock_window();
1377                                 gui->frames_dropped->update(string);
1378                                 gui->unlock_window();
1379                         }
1380                 }
1381                 
1382                 if(new_position >= 0 || new_length >= 0)
1383                 {
1384                         gui->update_title(gui->position_title, new_position);
1385                         gui->update_title(gui->total_length_title, new_length); 
1386                         gui->update_labels(new_position);
1387                 }
1388                 
1389                 if(new_clipped_samples >= 0)
1390                 {
1391                         if(gui->total_clipped_samples != new_clipped_samples)
1392                         {
1393                                 char string[1024];
1394                                 gui->total_clipped_samples = new_clipped_samples;
1395                                 sprintf(string, "%d\n", gui->total_clipped_samples);
1396                                 gui->lock_window();
1397                                 gui->samples_clipped->update(string);
1398                                 gui->unlock_window();
1399                         }
1400                 }
1402                 new_clipped_samples = -1;
1403                 new_dropped_frames = -1;
1404                 new_position = -1;
1405                 new_length = -1;
1406         }
1416 RecordGUIDCOffset::RecordGUIDCOffset(MWindow *mwindow, int y)
1417  : BC_Button(230, y, mwindow->theme->calibrate_data)
1421 RecordGUIDCOffset::~RecordGUIDCOffset() {}
1423 int RecordGUIDCOffset::handle_event()
1425 //      engine->calibrate_dc_offset();
1426         return 1;
1429 int RecordGUIDCOffset::keypress_event() { return 0; }
1431 RecordGUIDCOffsetText::RecordGUIDCOffsetText(char *text, int y, int number)
1432  : BC_TextBox(30, y+1, 67, 1, text, 0)
1434         this->number = number; 
1437 RecordGUIDCOffsetText::~RecordGUIDCOffsetText()
1440         
1441 int RecordGUIDCOffsetText::handle_event()
1443 //      if(!engine->is_previewing)
1444 //      {
1445 //              engine->calibrate_dc_offset(atol(get_text()), number);
1446 //      }
1447         return 1;
1450 RecordGUIReset::RecordGUIReset(MWindow *mwindow, RecordGUI *gui, int y)
1451  : BC_Button(400, y, mwindow->theme->over_button)
1452 { this->gui = gui; }
1454 RecordGUIReset::~RecordGUIReset() 
1458 int RecordGUIReset::handle_event()
1460 //      for(int i = 0; i < gui->engine->get_input_channels(); i++)
1461 //      {
1462 //              gui->meter[i]->reset_over();
1463 //      }
1464         return 1;
1467 RecordGUIResetTranslation::RecordGUIResetTranslation(MWindow *mwindow, RecordGUI *gui, int y)
1468  : BC_Button(250, y, mwindow->theme->reset_data)
1469 { this->gui = gui; }
1471 RecordGUIResetTranslation::~RecordGUIResetTranslation() 
1475 int RecordGUIResetTranslation::handle_event()
1477         gui->set_translation(0, 0, 1);
1478         return 1;
1485 RecordGUIOK::RecordGUIOK(MWindow *mwindow, int y)
1486  : BC_OKButton(50, y)
1490 RecordGUIOK::~RecordGUIOK()
1494 int RecordGUIOK::handle_event()
1496         unlock_window();
1497 //      engine->set_done(0);
1498         lock_window();
1499         return 1;