r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / recordgui.C
blob4ed9c169a0bb4d211b4053b6a5f3efd2b183a384
1 #include "asset.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("RecordGUIMonitorVideo::handle_event");
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("RecordGUIMonitorAudio::handle_event");
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),
842                 TIME_HMS3)
844         this->mwindow = mwindow;
845         this->record = record;
847 int RecordStart::handle_event()
849         record->record_gui->update_batches();
850         return 1;
853 RecordDuration::RecordDuration(MWindow *mwindow, Record *record, int x, int y)
854  : TimeEntry(record->record_gui, 
855                 x, 
856                 y, 
857                 0, 
858                 &(record->get_editing_batch()->duration),
859                 TIME_HMS2)
861         this->mwindow = mwindow;
862         this->record = record;
864 int RecordDuration::handle_event()
866         record->record_gui->update_batches();
867         return 1;
870 RecordSource::RecordSource(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
871  : BC_PopupTextBox(gui, 
872         &gui->sources,
873         record->get_editing_batch()->get_source_text(),
874         x, 
875         y, 
876         200,
877         200)
879         this->mwindow = mwindow;
880         this->record = record;
881         this->gui = gui;
883 int RecordSource::handle_event()
885         record->set_channel(get_number());
886         return 1;
889 RecordMode::RecordMode(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
890  : BC_PopupTextBox(gui,
891         &gui->modes,
892         Batch::mode_to_text(record->get_editing_batch()->record_mode),
893         x,
894         y,
895         200,
896         100)
898         this->mwindow = mwindow;
899         this->record = record;
901 int RecordMode::handle_event()
903         record->get_editing_batch()->record_mode = Batch::text_to_mode(get_text());
904         record->record_gui->update_batches();
905         return 1;
908 RecordNews::RecordNews(MWindow *mwindow, Record *record, int x, int y)
909  : BC_TextBox(x, y, 200, 1, record->get_editing_batch()->news)
911         this->mwindow = mwindow;
912         this->record = record;
914 int RecordNews::handle_event()
916         return 1;
920 RecordGUINewBatch::RecordGUINewBatch(MWindow *mwindow, Record *record, int x, int y)
921  : BC_GenericButton(x, y, _("New"))
923         this->mwindow = mwindow;
924         this->record = record;
925         set_tooltip(_("Create new clip."));
927 int RecordGUINewBatch::handle_event()
929         record->new_batch();
930         record->record_gui->update_batches();
931         return 1;
935 RecordGUIDeleteBatch::RecordGUIDeleteBatch(MWindow *mwindow, Record *record, int x, int y)
936  : BC_GenericButton(x, y, _("Delete"))
938         this->mwindow = mwindow;
939         this->record = record;
940         set_tooltip(_("Delete clip."));
942 int RecordGUIDeleteBatch::handle_event()
944         record->delete_batch();
945         record->record_gui->update_batches();
946         return 1;
950 RecordGUIStartBatches::RecordGUIStartBatches(MWindow *mwindow, Record *record, int x, int y)
951  : BC_GenericButton(x, y, _("Start"))
953         this->mwindow = mwindow;
954         this->record = record;
955         set_tooltip(_("Start batch recording\nfrom the current position."));
957 int RecordGUIStartBatches::handle_event()
959         unlock_window();
960         record->start_recording(0, CONTEXT_BATCH);
961         lock_window("RecordGUIStartBatches::handle_event");
962         return 1;
966 RecordGUIStopbatches::RecordGUIStopbatches(MWindow *mwindow, Record *record, int x, int y)
967  : BC_GenericButton(x, y, _("Stop"))
969         this->mwindow = mwindow;
970         this->record = record;
972 int RecordGUIStopbatches::handle_event()
974         return 1;
978 RecordGUIActivateBatch::RecordGUIActivateBatch(MWindow *mwindow, Record *record, int x, int y)
979  : BC_GenericButton(x, y, _("Activate"))
981         this->mwindow = mwindow;
982         this->record = record;
983         set_tooltip(_("Make the highlighted\nclip active."));
985 int RecordGUIActivateBatch::handle_event()
987         record->activate_batch(record->editing_batch, 1);
988         return 1;
992 RecordGUILabel::RecordGUILabel(MWindow *mwindow, Record *record, int x, int y)
993  : BC_GenericButton(x, y, _("Label"))
995         this->mwindow = mwindow;
996         this->record = record;
997         set_underline(0);
1001 RecordGUILabel::~RecordGUILabel()
1005 int RecordGUILabel::handle_event()
1007         record->toggle_label();
1008         return 1;
1011 int RecordGUILabel::keypress_event()
1013         if(get_keypress() == 'l')
1014         {
1015                 handle_event();
1016                 return 1;
1017         }
1018         return 0;
1037 RecordCancelThread::RecordCancelThread(Record *record, RecordGUI *record_gui)
1038  : Thread()
1040         this->record = record;
1041         this->gui = record_gui;
1044 RecordCancelThread::~RecordCancelThread()
1046         if(Thread::running()) 
1047         {
1048                 window->lock_window("RecordCancelThread::~RecordCancelThread");
1049                 window->set_done(1);
1050                 window->unlock_window();
1051         }
1052         completion_lock.lock();
1053         completion_lock.unlock();
1057 void RecordCancelThread::run()
1059 //printf("RecordCancelThread::run 1\n");
1060         completion_lock.lock();
1061 //printf("RecordCancelThread::run 1\n");
1062         if(record->prompt_cancel)
1063         {
1064                 window = new QuestionWindow(record->mwindow);
1065                 window->create_objects(_("Quit without pasting into project?"), 0);
1066                 int result = window->run_window();
1067                 if(result == 2) gui->set_done(1);
1068                 delete window;
1069         }
1070         else
1071         {
1072                 gui->set_done(1);
1073         }
1074 //printf("RecordCancelThread::run 2\n");
1076         completion_lock.unlock();
1080 RecordStartoverThread::RecordStartoverThread(Record *record, RecordGUI *record_gui)
1081  : Thread()
1083         this->record = record;
1084         this->gui = record_gui;
1086 RecordStartoverThread::~RecordStartoverThread()
1088         if(Thread::running()) 
1089         {
1090                 window->lock_window("RecordStartoverThread::~RecordStartoverThread");
1091                 window->set_done(1);
1092                 window->unlock_window();
1093         }
1094         completion_lock.lock();
1095         completion_lock.unlock();
1098 void RecordStartoverThread::run()
1100         completion_lock.lock();
1101         window = new QuestionWindow(record->mwindow);
1102         window->create_objects(_("Rewind batch and overwrite?"), 0);
1103         int result = window->run_window();
1104         if(result == 2) record->start_over();
1105         delete window;
1106         completion_lock.unlock();
1142 int RecordGUI::set_translation(int x, int y, float z)
1144         record->video_x = x;
1145         record->video_y = y;
1146         record->video_zoom = z;
1148         //record->video_lock.lock();
1149 //      engine->vdevice->set_translation(x, y, z);
1150 //      engine->vdevice->set_latency_counter(record->get_video_buffersize() * 2);
1151         //record->video_lock.unlock();
1154 int RecordGUI::update_dropped_frames(long new_dropped)
1156         status_thread->update_dropped_frames(new_dropped);
1157         return 0;
1160 int RecordGUI::update_position(double new_position, double new_length) 
1162         status_thread->update_position(new_position, new_length);
1163         return 0;
1166 int RecordGUI::update_clipped_samples(long new_clipped)
1168         status_thread->update_clipped_samples(new_clipped);
1169         return 0;
1172 int RecordGUI::keypress_event()
1174         return record_transport->keypress_event();
1177 void RecordGUI::update_labels(double new_position)
1179         RecordLabel *prev, *next;
1180         char string[BCTEXTLEN];
1182         for(prev = record->get_current_batch()->labels->last; 
1183                 prev; 
1184                 prev = prev->previous)
1185         {
1186                 if(prev->position <= new_position) break;
1187         }
1189         for(next = record->get_current_batch()->labels->first; 
1190                 next; 
1191                 next = next->next)
1192         {
1193                 if(next->position > new_position) break;
1194         }
1196         if(prev)
1197                 update_title(prev_label_title, 
1198                         prev->position);
1199         else
1200                 update_title(prev_label_title, -1);
1202 //      if(next)
1203 //              update_title(next_label_title, (double)next->position / record->default_asset->sample_rate);
1204 //      else
1205 //              update_title(next_label_title, -1);
1210 int RecordGUI::update_total_length(double new_position) 
1212         total_length = new_position;
1213         update_title(total_length_title, new_position); 
1214         return 0;
1217 int RecordGUI::update_prev_label(long new_position) 
1219         update_title(prev_label_title, new_position);
1222 // int RecordGUI::update_next_label(long new_position) 
1223 // { 
1224 //      update_title(next_label_title, new_position); 
1225 // }
1226 // 
1227 int RecordGUI::update_title(BC_Title *title, double position)
1229         static char string[256];
1231         if(position > -1)
1232         {
1233                 Units::totext(string, 
1234                                 position, 
1235                                 mwindow->edl->session->time_format, 
1236                                 record->default_asset->sample_rate, 
1237                                 record->default_asset->frame_rate, 
1238                                 mwindow->edl->session->frames_per_foot);
1239         }
1240         else
1241         {
1242                 sprintf(string, "-");
1243         }
1244         lock_window("RecordGUI::update_title");
1245         title->update(string);
1246         unlock_window();
1249 int RecordGUI::update_duration_boxes()
1251         char string[1024];
1252 //      sprintf(string, "%d", engine->get_loop_hr());
1253 //      loop_hr->update(string);
1254 //      sprintf(string, "%d", engine->get_loop_min());
1255 //      loop_min->update(string);
1256 //      sprintf(string, "%d", engine->get_loop_sec());
1257 //      loop_sec->update(string);
1265 // ===================================== GUI
1271 // ================================================== modes
1273 RecordGUIModeMenu::RecordGUIModeMenu(int x, 
1274         int y, 
1275         int w, 
1276         char *text)
1277  : BC_PopupMenu(x, y, w, text)
1281 RecordGUIModeMenu::~RecordGUIModeMenu()
1283         delete linear;
1284         delete timed;
1285         delete loop;
1288 int RecordGUIModeMenu::add_items()
1290         add_item(linear = new RecordGUIMode(_("Untimed")));
1291         add_item(timed = new RecordGUIMode(_("Timed")));
1292 //      add_item(loop = new RecordGUIMode("_(Loop")));
1293         return 0;
1296 int RecordGUIModeMenu::handle_event()
1298 //      engine->set_record_mode(get_text());
1301 RecordGUIMode::RecordGUIMode(char *text)
1302  : BC_MenuItem(text)
1306 RecordGUIMode::~RecordGUIMode()
1310 int RecordGUIMode::handle_event()
1312         get_popup_menu()->set_text(get_text());
1313         get_popup_menu()->handle_event();
1314         return 1;
1321 RecordStatusThread::RecordStatusThread(MWindow *mwindow, RecordGUI *gui)
1322  : Thread()
1324         set_synchronous(1);
1325         this->mwindow = mwindow;
1326         this->gui = gui;
1327         new_dropped_frames = -1;
1328         new_position = -1;
1329         new_length = -1;
1330         new_clipped_samples = -1;
1331         input_lock.lock();
1332         done = 0;
1335 RecordStatusThread::~RecordStatusThread()
1337         if(Thread::running())
1338         {
1339                 done = 1;
1340                 input_lock.unlock();
1341                 Thread::join();
1342         }
1345 void RecordStatusThread::update_dropped_frames(long value)
1347         new_dropped_frames = value;
1348         input_lock.unlock();
1351 void RecordStatusThread::update_position(double new_position, double total_length)
1353         this->new_position = new_position;
1354         this->new_length = total_length;
1355         input_lock.unlock();
1358 void RecordStatusThread::update_clipped_samples(long new_clipped_samples)
1360         this->new_clipped_samples = new_clipped_samples;
1361         input_lock.unlock();
1364 void RecordStatusThread::run()
1366         while(!done)
1367         {
1368 //printf("RecordStatusThread::run 1\n");
1369                 input_lock.lock();
1370 //printf("RecordStatusThread::run 2\n");
1371                 if(new_dropped_frames >= 0)
1372                 {
1373                         char string[1024];
1374                         if(gui->total_dropped_frames != new_dropped_frames)
1375                         {
1376                                 gui->total_dropped_frames = new_dropped_frames;
1377                                 sprintf(string, "%d\n", gui->total_dropped_frames);
1378                                 gui->lock_window("RecordStatusThread::run 1");
1379                                 gui->frames_dropped->update(string);
1380                                 gui->unlock_window();
1381                         }
1382                 }
1383                 
1384                 if(new_position >= 0 || new_length >= 0)
1385                 {
1386                         gui->update_title(gui->position_title, new_position);
1387                         gui->update_title(gui->total_length_title, new_length); 
1388                         gui->update_labels(new_position);
1389                 }
1390                 
1391                 if(new_clipped_samples >= 0)
1392                 {
1393                         if(gui->total_clipped_samples != new_clipped_samples)
1394                         {
1395                                 char string[1024];
1396                                 gui->total_clipped_samples = new_clipped_samples;
1397                                 sprintf(string, "%d\n", gui->total_clipped_samples);
1398                                 gui->lock_window("RecordStatusThread::run 2");
1399                                 gui->samples_clipped->update(string);
1400                                 gui->unlock_window();
1401                         }
1402                 }
1404                 new_clipped_samples = -1;
1405                 new_dropped_frames = -1;
1406                 new_position = -1;
1407                 new_length = -1;
1408         }
1418 RecordGUIDCOffset::RecordGUIDCOffset(MWindow *mwindow, int y)
1419  : BC_Button(230, y, mwindow->theme->calibrate_data)
1423 RecordGUIDCOffset::~RecordGUIDCOffset() {}
1425 int RecordGUIDCOffset::handle_event()
1427 //      engine->calibrate_dc_offset();
1428         return 1;
1431 int RecordGUIDCOffset::keypress_event() { return 0; }
1433 RecordGUIDCOffsetText::RecordGUIDCOffsetText(char *text, int y, int number)
1434  : BC_TextBox(30, y+1, 67, 1, text, 0)
1436         this->number = number; 
1439 RecordGUIDCOffsetText::~RecordGUIDCOffsetText()
1442         
1443 int RecordGUIDCOffsetText::handle_event()
1445 //      if(!engine->is_previewing)
1446 //      {
1447 //              engine->calibrate_dc_offset(atol(get_text()), number);
1448 //      }
1449         return 1;
1452 RecordGUIReset::RecordGUIReset(MWindow *mwindow, RecordGUI *gui, int y)
1453  : BC_Button(400, y, mwindow->theme->over_button)
1454 { this->gui = gui; }
1456 RecordGUIReset::~RecordGUIReset() 
1460 int RecordGUIReset::handle_event()
1462 //      for(int i = 0; i < gui->engine->get_input_channels(); i++)
1463 //      {
1464 //              gui->meter[i]->reset_over();
1465 //      }
1466         return 1;
1469 RecordGUIResetTranslation::RecordGUIResetTranslation(MWindow *mwindow, RecordGUI *gui, int y)
1470  : BC_Button(250, y, mwindow->theme->reset_data)
1471 { this->gui = gui; }
1473 RecordGUIResetTranslation::~RecordGUIResetTranslation() 
1477 int RecordGUIResetTranslation::handle_event()
1479         gui->set_translation(0, 0, 1);
1480         return 1;
1487 RecordGUIOK::RecordGUIOK(MWindow *mwindow, int y)
1488  : BC_OKButton(50, y)
1492 RecordGUIOK::~RecordGUIOK()
1496 int RecordGUIOK::handle_event()
1498         unlock_window();
1499 //      engine->set_done(0);
1500         lock_window();
1501         return 1;