Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

recordgui.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "batch.h"
00003 #include "bcsignals.h"
00004 #include "browsebutton.h"
00005 #include "channelpicker.h"
00006 #include "clip.h"
00007 #include "condition.h"
00008 #include "defaults.h"
00009 #include "edl.h"
00010 #include "edlsession.h"
00011 #include "file.h"
00012 #include "filemov.h"
00013 #include "filesystem.h"
00014 #include "keys.h"
00015 #include "language.h"
00016 #include "loadmode.h"
00017 #include "mwindow.h"
00018 #include "mwindowgui.h"
00019 #include "preferences.h"
00020 #include "question.h"
00021 #include "recconfirmdelete.h"
00022 #include "recordgui.h"
00023 #include "record.h"
00024 #include "recordlabel.h"
00025 #include "recordmonitor.h"
00026 #include "recordtransport.h"
00027 #include "recordvideo.h"
00028 #include "mainsession.h"
00029 #include "theme.h"
00030 #include "units.h"
00031 #include "videodevice.h"
00032 
00033 #include <time.h>
00034 
00035 
00036 
00037 
00038 RecordGUI::RecordGUI(MWindow *mwindow, Record *record)
00039  : BC_Window(PROGRAM_NAME ": Recording", 
00040         mwindow->session->rwindow_x, 
00041         mwindow->session->rwindow_y, 
00042         mwindow->session->rwindow_w, 
00043         mwindow->session->rwindow_h,
00044         10,
00045         10,
00046         1,
00047         0,
00048         1)
00049 {
00050         this->mwindow = mwindow;
00051         this->record = record;
00052 }
00053 
00054 RecordGUI::~RecordGUI()
00055 {
00056 TRACE("RecordGUI::~RecordGUI 1");
00057         delete status_thread;
00058         delete batch_source;
00059         delete batch_mode;
00060         delete startover_thread;
00061         delete cancel_thread;
00062         delete batch_start;
00063         delete batch_duration;
00064         delete load_mode;
00065 TRACE("RecordGUI::~RecordGUI 2");
00066 }
00067 
00068 
00069 char* RecordGUI::batch_titles[] = 
00070 {
00071         N_("On"),
00072         N_("Path"),
00073         N_("News"),
00074         N_("Start time"),
00075         N_("Duration"),
00076         N_("Source"),
00077         N_("Mode")
00078 };
00079 
00080 void RecordGUI::load_defaults()
00081 {
00082         static int default_columnwidth[] =
00083         {
00084                 30,
00085                 200,
00086                 100,
00087                 100,
00088                 100,
00089                 100,
00090                 70
00091         };
00092 
00093         char string[BCTEXTLEN];
00094         for(int i = 0; i < BATCH_COLUMNS; i++)
00095         {
00096                 sprintf(string, "BATCH_COLUMNWIDTH_%d", i);
00097                 column_widths[i] = mwindow->defaults->get(string, default_columnwidth[i]);
00098         }
00099 }
00100 
00101 void RecordGUI::save_defaults()
00102 {
00103         char string[BCTEXTLEN];
00104         for(int i = 0; i < BATCH_COLUMNS; i++)
00105         {
00106                 sprintf(string, "BATCH_COLUMNWIDTH_%d", i);
00107                 mwindow->defaults->update(string, column_widths[i]);
00108         }
00109 }
00110 
00111 
00112 int RecordGUI::create_objects()
00113 {
00114         char string[BCTEXTLEN];
00115         flash_color = RED;
00116 
00117         status_thread = new RecordStatusThread(mwindow, this);
00118         status_thread->start();
00119         set_icon(mwindow->theme->get_image("record_icon"));
00120 
00121         mwindow->theme->get_recordgui_sizes(this, get_w(), get_h());
00122 //printf("RecordGUI::create_objects 1\n");
00123         mwindow->theme->draw_rwindow_bg(this);
00124 
00125 
00126         monitor_video = 0;
00127         monitor_audio = 0;
00128         total_dropped_frames = 0;
00129         batch_list = 0;
00130         update_batches();
00131         modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_INFINITE)));
00132         modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_TIMED)));
00133 //      modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_LOOP)));
00134 //      modes.append(new BC_ListBoxItem(Batch::mode_to_text(RECORD_SCENETOSCENE)));
00135 
00136         int x = 10;
00137         int y = 10;
00138         int x1 = 0;
00139         BC_Title *title;
00140         int pad = MAX(BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1), 
00141                 BC_Title::calculate_h(this, "X")) + 5;
00142         int button_y = 0;
00143 
00144 // Curent batch
00145         add_subwindow(title = new BC_Title(x, y, _("Path:")));
00146         x1 = MAX(title->get_w(), x1);
00147         y += pad;
00148         add_subwindow(title = new BC_Title(x, y, _("Start time:")));
00149         x1 = MAX(title->get_w(), x1);
00150         y += pad;
00151         add_subwindow(title = new BC_Title(x, y, _("Duration time:")));
00152         x1 = MAX(title->get_w(), x1);
00153         y += pad;
00154         add_subwindow(title = new BC_Title(x, y, _("Source:")));
00155         x1 = MAX(title->get_w(), x1);
00156         y += pad;
00157         add_subwindow(title = new BC_Title(x, y, _("Mode:")));
00158         x1 = MAX(title->get_w(), x1);
00159         y += pad;
00160         add_subwindow(title = new BC_Title(x, y, _("Transport:")));
00161         x1 = MAX(title->get_w(), x1);
00162         y += pad;
00163 
00164         button_y = MAX(y, button_y);
00165 
00166 
00167 
00168         int x2 = 0;
00169         y = 10;
00170         x = x1 + 20;
00171         add_subwindow(batch_path = new RecordPath(mwindow, record, x, y));
00172         add_subwindow(batch_browse = new BrowseButton(mwindow, 
00173                 this, 
00174                 batch_path, 
00175                 batch_path->get_x() + batch_path->get_w(), 
00176                 y,
00177                 record->default_asset->path,
00178                 PROGRAM_NAME ": Record path",
00179                 _("Select a file to record to:"),
00180                 0));
00181         x2 = MAX(x2, batch_path->get_w() + batch_browse->get_w());
00182         y += pad;
00183         batch_start = new RecordStart(mwindow, record, x, y);
00184         batch_start->create_objects();
00185         x2 = MAX(x2, batch_start->get_w());
00186         y += pad;
00187         batch_duration = new RecordDuration(mwindow, record, x, y);
00188         batch_duration->create_objects();
00189         x2 = MAX(x2, batch_duration->get_w());
00190         y += pad;
00191         batch_source = new RecordSource(mwindow, record, this, x, y);
00192         batch_source->create_objects();
00193         x2 = MAX(x2, batch_source->get_w());
00194         y += pad;
00195         batch_mode = new RecordMode(mwindow, record, this, x, y);
00196         batch_mode->create_objects();
00197         x2 = MAX(x2, batch_mode->get_w());
00198         y += pad;
00199         record_transport = new RecordTransport(mwindow, 
00200                 record, 
00201                 this, 
00202                 x,
00203                 y);
00204         record_transport->create_objects();
00205         x2 = MAX(x2, record_transport->get_w());
00206 
00207 
00208 
00209 
00210 // Compression settings
00211         x = x2 + x1 + 30;
00212         y = 10;
00213         int x3 = 0;
00214         pad = BC_Title::calculate_h(this, "X") + 5;
00215         add_subwindow(title = new BC_Title(x, y, _("Format:")));
00216         x3 = MAX(title->get_w(), x3);
00217         y += pad;
00218 
00219         if(record->default_asset->audio_data)
00220         {
00221                 add_subwindow(title = new BC_Title(x, y, _("Audio compression:")));
00222                 x3 = MAX(title->get_w(), x3);
00223                 y += pad;
00224                 add_subwindow(title = new BC_Title(x, y, _("Samplerate:")));
00225                 x3 = MAX(title->get_w(), x3);
00226                 y += pad;
00227                 add_subwindow(title = new BC_Title(x, y, _("Clipped samples:")));
00228                 x3 = MAX(title->get_w(), x3);
00229                 y += pad;
00230         }
00231 
00232         if(record->default_asset->video_data)
00233         {
00234                 add_subwindow(title = new BC_Title(x, y, _("Video compression:")));
00235                 x3 = MAX(title->get_w(), x3);
00236                 y += pad;
00237                 add_subwindow(title = new BC_Title(x, y, _("Framerate:")));
00238                 x3 = MAX(title->get_w(), x3);
00239                 y += pad;
00240                 add_subwindow(title = new BC_Title(x, y, _("Frames behind:")));
00241                 x3 = MAX(title->get_w(), x3);
00242                 y += pad;
00243         }
00244 
00245         add_subwindow(title = new BC_Title(x, y, _("Position:")));
00246         x3 = MAX(title->get_w(), x3);
00247         y += pad;
00248         add_subwindow(title = new BC_Title(x, y, _("Prev label:")));
00249         x3 = MAX(title->get_w(), x3);
00250         y += pad;
00251 
00252         button_y = MAX(y, button_y);
00253         y = 10;
00254         x = x3 + x2 + x1 + 40;
00255 
00256         add_subwindow(new BC_Title(x, 
00257                 y, 
00258                 File::formattostr(mwindow->plugindb, 
00259                         record->default_asset->format), 
00260                 MEDIUMFONT, 
00261                 mwindow->theme->recordgui_fixed_color));
00262         y += pad;
00263 
00264         if(record->default_asset->audio_data)
00265         {
00266                 add_subwindow(new BC_Title(x, 
00267                         y, 
00268                         File::bitstostr(record->default_asset->bits), 
00269                         MEDIUMFONT, 
00270                         mwindow->theme->recordgui_fixed_color));
00271 
00272                 y += pad;
00273                 sprintf(string, "%d", record->default_asset->sample_rate);
00274                 add_subwindow(new BC_Title(x, 
00275                         y, 
00276                         string, 
00277                         MEDIUMFONT, 
00278                         mwindow->theme->recordgui_fixed_color));
00279 
00280                 y += pad;
00281                 add_subwindow(samples_clipped = new BC_Title(x, 
00282                         y, 
00283                         "0", 
00284                         MEDIUMFONT, 
00285                         mwindow->theme->recordgui_variable_color));
00286                 y += pad;
00287         }
00288 
00289         if(record->default_asset->video_data)
00290         {
00291                 add_subwindow(new BC_Title(x, 
00292                         y, 
00293                         FileMOV::compressiontostr(record->default_asset->vcodec), 
00294                         MEDIUMFONT, 
00295                         mwindow->theme->recordgui_fixed_color));
00296         
00297                 y += pad;
00298                 sprintf(string, "%0.2f", record->default_asset->frame_rate);
00299                 add_subwindow(new BC_Title(x, 
00300                         y, 
00301                         string, 
00302                         MEDIUMFONT, 
00303                         mwindow->theme->recordgui_fixed_color));
00304         
00305                 y += pad;
00306                 add_subwindow(frames_dropped = new BC_Title(x, 
00307                         y, 
00308                         "0", 
00309                         MEDIUMFONT, 
00310                         mwindow->theme->recordgui_variable_color));
00311                 y += pad;
00312         }
00313 
00314         add_subwindow(position_title = new BC_Title(x, 
00315                 y, 
00316                 "", 
00317                 MEDIUMFONT, 
00318                 mwindow->theme->recordgui_variable_color));
00319 
00320         y += pad;
00321         add_subwindow(prev_label_title = new BC_Title(x, 
00322                 y, 
00323                 _("None"), 
00324                 MEDIUMFONT, 
00325                 mwindow->theme->recordgui_variable_color));
00326 
00327         y += pad + 10;
00328         button_y = MAX(y, button_y);
00329         
00330         
00331         
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 // Buttons
00340         x = 10;
00341         y = button_y;
00342 
00343 
00344         add_subwindow(title = new BC_Title(x,y, _("Batches:")));
00345         x += title->get_w() + 5;
00346         add_subwindow(activate_batch = new RecordGUIActivateBatch(mwindow, record, x, y));
00347         x += activate_batch->get_w();
00348         add_subwindow(start_batches = new RecordGUIStartBatches(mwindow, record, x, y));
00349         x += start_batches->get_w();
00350         add_subwindow(delete_batch = new RecordGUIDeleteBatch(mwindow, record, x, y));
00351         x += delete_batch->get_w();
00352         add_subwindow(new_batch = new RecordGUINewBatch(mwindow, record, x, y));
00353         x += new_batch->get_w();
00354         add_subwindow(label_button = new RecordGUILabel(mwindow, record, x, y));
00355 
00356 
00357 
00358         x = 10;
00359         y += MAX(label_button->get_h(), record_transport->get_h()) + 5;
00360 
00361         fill_frames = 0;
00362         monitor_video = 0;
00363         monitor_audio = 0;
00364         if(record->default_asset->video_data) 
00365         {
00366                 add_subwindow(fill_frames = new RecordGUIFillFrames(mwindow, record, x, y));
00367                 x += fill_frames->get_w() + 5;
00368                 add_subwindow(monitor_video = new RecordGUIMonitorVideo(mwindow, record, x, y));
00369                 x += monitor_video->get_w() + 5;
00370         }
00371 
00372         if(record->default_asset->audio_data) 
00373                 add_subwindow(monitor_audio = new RecordGUIMonitorAudio(mwindow, record, x, y));
00374 
00375 // Batches
00376         x = 10;
00377         y += 5;
00378         if(fill_frames) y += fill_frames->get_h();
00379         else
00380         if(monitor_audio) y += monitor_audio->get_h();
00381 
00382         int bottom_margin = MAX(BC_OKButton::calculate_h(), 
00383                 LoadMode::calculate_h(this)) + 5;
00384 
00385 
00386         add_subwindow(batch_list = new RecordGUIBatches(record, 
00387                 this, 
00388                 x, 
00389                 y,
00390                 get_w() - 20,
00391                 get_h() - y - bottom_margin - 10));
00392         y += batch_list->get_h() + 5;
00393 
00394 // Controls
00395         load_mode = new LoadMode(mwindow,
00396                 this, 
00397                 get_w() / 2 - mwindow->theme->loadmode_w / 2, 
00398                 y, 
00399                 &record->load_mode, 
00400                 1);
00401         load_mode->create_objects();
00402         y += load_mode->get_h() + 5;
00403 
00404         add_subwindow(new BC_OKButton(this));
00405 
00406         cancel_thread = new RecordCancelThread(record, this);
00407         add_subwindow(new RecordGUISave(record, this));
00408         add_subwindow(new RecordGUICancel(record, this));
00409 
00410         startover_thread = new RecordStartoverThread(record, this);
00411 
00412         return 0;
00413 }
00414 
00415 void RecordGUI::flash_batch()
00416 {
00417         if(record->current_batch < batches[0].total)
00418         {
00419                 if(flash_color == GREEN)
00420                         flash_color = RED;
00421                 else
00422                         flash_color = GREEN;
00423 
00424 //printf("RecordGUI::flash_batch %x\n", flash_color);
00425 
00426                 for(int i = 0; i < BATCH_COLUMNS; i++)
00427                 {
00428                         BC_ListBoxItem *batch = batches[i].values[record->current_batch];
00429                         batch->set_color(flash_color);
00430                 }
00431                 batch_list->update(batches,
00432                         batch_titles,
00433                         column_widths,
00434                         BATCH_COLUMNS,
00435                         batch_list->get_yposition(),
00436                         batch_list->get_xposition(),
00437                         batch_list->get_highlighted_item());
00438 
00439                 batch_list->flush();
00440         }
00441 }
00442 
00443 void RecordGUI::update_batches()
00444 {
00445         char string[BCTEXTLEN], string2[BCTEXTLEN];
00446         FileSystem fs;
00447 
00448         int selection_number = batch_list ? batch_list->get_selection_number(0, 0) : -1;
00449         for(int j = 0; j < BATCH_COLUMNS; j++)
00450         {
00451                 batches[j].remove_all_objects();
00452         }
00453 
00454         for(int i = 0; i < record->batches.total; i++)
00455         {
00456                 Batch *batch = record->batches.values[i];
00457                 int color = (i == record->current_batch) ? RED : BLACK;
00458                 if(batch->waiting && time(0) & 0x1) color = GREEN;
00459 
00460                 batches[0].append(new BC_ListBoxItem((char*)(batch->enabled ? "X" : " "), color));
00461                 batches[1].append(new BC_ListBoxItem(batch->get_current_asset()->path, color));
00462                 sprintf(string, "%s", batch->news);
00463                 batches[2].append(new BC_ListBoxItem(string, RED));
00464                 Units::totext(string2, 
00465                                 batch->start_time, 
00466                                 TIME_HMS, 
00467                                 record->default_asset->sample_rate,
00468                                 record->default_asset->frame_rate, 
00469                                 mwindow->edl->session->frames_per_foot);
00470                 sprintf(string, "%s %s", TimeEntry::day_table[batch->start_day], string2);
00471 
00472                 batches[3].append(new BC_ListBoxItem(string, color));
00473                 Units::totext(string, 
00474                                 batch->duration, 
00475                                 TIME_HMS, 
00476                                 record->default_asset->sample_rate,
00477                                 record->default_asset->frame_rate, 
00478                                 mwindow->edl->session->frames_per_foot);
00479                 batches[4].append(new BC_ListBoxItem(string, color));
00480                 record->source_to_text(string, batch);
00481                 batches[5].append(new BC_ListBoxItem(string, color));
00482                 sprintf(string, "%s", Batch::mode_to_text(batch->record_mode));
00483                 batches[6].append(new BC_ListBoxItem(string, color));
00484                 
00485                 if(i == selection_number)
00486                 {
00487                         for(int j = 0; j < BATCH_COLUMNS; j++)
00488                         {
00489                                 batches[j].values[i]->set_selected(1);
00490                         }
00491                 }
00492         }
00493 
00494         if(batch_list)
00495         {
00496                 batch_list->update(batches,
00497                         batch_titles,
00498                         column_widths,
00499                         BATCH_COLUMNS,
00500                         batch_list->get_yposition(),
00501                         batch_list->get_xposition(),
00502                         record->editing_batch,
00503                         1);
00504         }
00505         flush();
00506 }
00507 
00508 void RecordGUI::update_batch_sources()
00509 {
00510 //printf("RecordGUI::update_batch_sources 1\n");
00511         if(record->record_monitor->window->channel_picker)
00512                 batch_source->update_list(
00513                         &record->record_monitor->window->channel_picker->channel_listitems);
00514 //printf("RecordGUI::update_batch_sources 2\n");
00515 }
00516 
00517 int RecordGUI::translation_event()
00518 {
00519         mwindow->session->rwindow_x = get_x();
00520         mwindow->session->rwindow_y = get_y();
00521         return 0;
00522 }
00523 
00524 
00525 int RecordGUI::resize_event(int w, int h)
00526 {
00527         int x, y, x1;
00528 
00529 // Recompute batch list based on previous extents
00530         int bottom_margin = mwindow->session->rwindow_h - 
00531                 batch_list->get_y() - 
00532                 batch_list->get_h();
00533         int mode_margin = mwindow->session->rwindow_h - load_mode->get_y();
00534         mwindow->session->rwindow_x = get_x();
00535         mwindow->session->rwindow_y = get_y();
00536         mwindow->session->rwindow_w = w;
00537         mwindow->session->rwindow_h = h;
00538         mwindow->theme->get_recordgui_sizes(this, w, h);
00539         mwindow->theme->draw_rwindow_bg(this);
00540 
00541 
00542         int new_h = mwindow->session->rwindow_h - bottom_margin - batch_list->get_y();
00543         if(new_h < 10) new_h = 10;
00544         batch_list->reposition_window(batch_list->get_x(), 
00545                 batch_list->get_y(),
00546                 mwindow->session->rwindow_w - 20,
00547                 mwindow->session->rwindow_h - bottom_margin - batch_list->get_y());
00548 
00549 
00550         load_mode->reposition_window(mwindow->session->rwindow_w / 2 - 
00551                         mwindow->theme->loadmode_w / 2,
00552                 mwindow->session->rwindow_h - mode_margin);
00553 
00554         flash();
00555         return 1;
00556 }
00557 
00558 void RecordGUI::update_batch_tools()
00559 {
00560 //printf("RecordGUI::update_batch_tools 1\n");
00561         char string[BCTEXTLEN];
00562         Batch *batch = record->get_editing_batch();
00563         batch_path->update(batch->get_current_asset()->path);
00564 
00565 // File is open in editing batch
00566 //      if(record->current_batch == record->editing_batch && record->file)
00567 //              batch_path->disable();
00568 //      else
00569 //              batch_path->enable();
00570 
00571         batch_start->update(&batch->start_day, &batch->start_time);
00572         batch_duration->update(0, &batch->duration);
00573         batch_source->update(batch->get_source_text());
00574         batch_mode->update(Batch::mode_to_text(batch->record_mode));
00575         flush();
00576 }
00577 
00578 
00579 RecordGUIBatches::RecordGUIBatches(Record *record, RecordGUI *gui, int x, int y, int w, int h)
00580  : BC_ListBox(x, 
00581                 y, 
00582                 w, 
00583                 h,
00584                 LISTBOX_TEXT,                   // Display text list or icons
00585                 gui->batches,               // Each column has an ArrayList of BC_ListBoxItems.
00586                 gui->batch_titles,             // Titles for columns.  Set to 0 for no titles
00587                 gui->column_widths,                // width of each column
00588                 BATCH_COLUMNS,                      // Total columns.
00589                 0,                    // Pixel of top of window.
00590                 0,                        // If this listbox is a popup window
00591                 LISTBOX_SINGLE,  // Select one item or multiple items
00592                 ICON_LEFT,        // Position of icon relative to text of each item
00593                 1)           // Allow dragging
00594 {
00595         this->record = record;
00596         this->gui = gui;
00597         dragging_item = 0;
00598 }
00599 
00600 // Do nothing for double clicks to protect active batch
00601 int RecordGUIBatches::handle_event()
00602 {
00603         return 1;
00604 }
00605 
00606 int RecordGUIBatches::selection_changed()
00607 {
00608         if(get_selection_number(0, 0) >= 0)
00609         {
00610                 int i = get_selection_number(0, 0);
00611                 record->change_editing_batch(get_selection_number(0, 0));
00612                 if(get_cursor_x() < gui->column_widths[0])
00613                 {
00614                         record->batches.values[i]->enabled = 
00615                                 !record->batches.values[i]->enabled;
00616                         gui->update_batches();
00617                 }
00618         }
00619         return 1;
00620 }
00621 
00622 int RecordGUIBatches::column_resize_event()
00623 {
00624         for(int i = 0; i < BATCH_COLUMNS; i++)
00625         {
00626                 gui->column_widths[i] = get_column_width(i);
00627         }
00628         return 1;
00629 }
00630 
00631 int RecordGUIBatches::drag_start_event()
00632 {
00633         if(BC_ListBox::drag_start_event())
00634         {
00635                 dragging_item = 1;
00636                 return 1;
00637         }
00638 
00639         return 0;
00640 }
00641 
00642 int RecordGUIBatches::drag_motion_event()
00643 {
00644         if(BC_ListBox::drag_motion_event())
00645         {
00646                 return 1;
00647         }
00648         return 0;
00649 }
00650 
00651 int RecordGUIBatches::drag_stop_event()
00652 {
00653         if(dragging_item)
00654         {
00655                 int src = record->editing_batch;
00656                 int dst = get_highlighted_item();
00657                 Batch *src_item = record->batches.values[src];
00658                 if(dst < 0) dst = record->batches.total;
00659 
00660                 for(int i = src; i < record->batches.total - 1; i++)
00661                 {
00662                         record->batches.values[i] = record->batches.values[i + 1];
00663                 }
00664                 if(dst > src) dst--;
00665                 
00666                 for(int i = record->batches.total - 1; i > dst; i--)
00667                 {
00668                         record->batches.values[i] = record->batches.values[i - 1];
00669                 }
00670                 record->batches.values[dst] = src_item;
00671 
00672                 BC_ListBox::drag_stop_event();
00673 
00674                 dragging_item = 0;
00675                 gui->update_batches();
00676         }
00677 
00678 }
00679 
00680 
00681 
00682 
00683 
00684 
00685 
00686 
00687 
00688 
00689 RecordGUISave::RecordGUISave(Record *record, 
00690         RecordGUI *record_gui)
00691  : BC_Button(10, 
00692         record_gui->get_h() - BC_WindowBase::get_resources()->ok_images[0]->get_h() - 10, 
00693         BC_WindowBase::get_resources()->ok_images)
00694 {
00695         set_tooltip(_("Save the recording and quit."));
00696         this->record = record;
00697         this->gui = record_gui;
00698 }
00699 
00700 int RecordGUISave::handle_event()
00701 {
00702         gui->set_done(0);
00703         return 1;
00704 }
00705 
00706 int RecordGUISave::keypress_event()
00707 {
00708 //      if(get_keypress() == RETURN)
00709 //      {
00710 //              handle_event();
00711 //              return 1;
00712 //      }
00713 
00714         return 0;
00715 }
00716 
00717 RecordGUICancel::RecordGUICancel(Record *record, 
00718         RecordGUI *record_gui)
00719  : BC_Button(record_gui->get_w() - BC_WindowBase::get_resources()->cancel_images[0]->get_w() - 10, 
00720         record_gui->get_h() - BC_WindowBase::get_resources()->cancel_images[0]->get_h() - 10, 
00721         BC_WindowBase::get_resources()->cancel_images)
00722 {
00723         set_tooltip(_("Quit without pasting into project."));
00724         this->record = record;
00725         this->gui = record_gui;
00726 }
00727 
00728 int RecordGUICancel::handle_event()
00729 {
00730         if(!gui->cancel_thread->running())
00731                 gui->cancel_thread->start();
00732         return 1;
00733 }
00734 
00735 int RecordGUICancel::keypress_event()
00736 {
00737         if(get_keypress() == ESC)
00738         {
00739                 handle_event();
00740                 return 1;
00741         }
00742 
00743         return 0;
00744 }
00745 
00746 RecordGUIStartOver::RecordGUIStartOver(Record *record, RecordGUI *record_gui, int x, int y)
00747  : BC_GenericButton(x, y, _("Start Over"))
00748 {
00749         set_tooltip(_("Rewind the current file and erase."));
00750         this->record = record;
00751         this->gui = record_gui;
00752 }
00753 RecordGUIStartOver::~RecordGUIStartOver()
00754 {
00755 }
00756 
00757 int RecordGUIStartOver::handle_event()
00758 {
00759         if(!gui->startover_thread->running())
00760                 gui->startover_thread->start();
00761         return 1;
00762 }
00763 
00764 RecordGUIFillFrames::RecordGUIFillFrames(MWindow *mwindow, Record *record, int x, int y)
00765  : BC_CheckBox(x, y, record->fill_frames, _("Fill frames"))
00766 {
00767         this->mwindow = mwindow;
00768         this->record = record;
00769         set_tooltip(_("Write extra frames when behind."));
00770 }
00771 
00772 int RecordGUIFillFrames::handle_event()
00773 {
00774 // Video capture constitutively, just like audio, but only flash on screen if 1
00775         record->fill_frames = get_value();
00776         return 1;
00777 }
00778 
00779 RecordGUIMonitorVideo::RecordGUIMonitorVideo(MWindow *mwindow, Record *record, int x, int y)
00780  : BC_CheckBox(x, y, record->monitor_video, _("Monitor video"))
00781 {
00782         this->mwindow = mwindow;
00783         this->record = record;
00784 }
00785 
00786 int RecordGUIMonitorVideo::handle_event()
00787 {
00788 // Video capture constitutively, just like audio, but only flash on screen if 1
00789         record->monitor_video = get_value();
00790         if(record->monitor_video)
00791         {
00792                 unlock_window();
00793 
00794 
00795                 record->record_monitor->window->lock_window("RecordGUIMonitorVideo::handle_event");
00796                 record->record_monitor->window->show_window();
00797                 record->record_monitor->window->raise_window();
00798                 record->record_monitor->window->flush();
00799                 record->record_monitor->window->unlock_window();
00800 
00801                 lock_window("RecordGUIMonitorVideo::handle_event");
00802                 record->video_window_open = 1;
00803         }
00804         return 1;
00805 }
00806 
00807 
00808 RecordGUIMonitorAudio::RecordGUIMonitorAudio(MWindow *mwindow, Record *record, int x, int y)
00809  : BC_CheckBox(x, y, record->monitor_audio, _("Monitor audio"))
00810 {
00811         this->mwindow = mwindow;
00812         this->record = record;
00813 }
00814 
00815 int RecordGUIMonitorAudio::handle_event()
00816 {
00817         record->monitor_audio = get_value();
00818         if(record->monitor_audio)
00819         {
00820                 unlock_window();
00821 
00822 
00823                 record->record_monitor->window->lock_window("RecordGUIMonitorAudio::handle_event");
00824                 record->record_monitor->window->show_window();
00825                 record->record_monitor->window->raise_window();
00826                 record->record_monitor->window->flush();
00827                 record->record_monitor->window->unlock_window();
00828 
00829 
00830                 lock_window("RecordGUIMonitorVideo::handle_event");
00831                 record->video_window_open = 1;
00832         }
00833         return 1;
00834 }
00835 
00836 RecordBatch::RecordBatch(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
00837  : BC_PopupTextBox(gui, 
00838                 &gui->batch_numbers,
00839                 gui->batch_numbers.values[record->editing_batch]->get_text(),
00840                 x, 
00841                 y, 
00842                 100,
00843                 200)
00844 {
00845         this->gui = gui;
00846         this->mwindow = mwindow;
00847         this->record = record;
00848 }
00849 int RecordBatch::handle_event()
00850 {
00851         return 1;
00852 }
00853 
00854 RecordPath::RecordPath(MWindow *mwindow, Record *record, int x, int y)
00855  : BC_TextBox(x, y, 200, 1, record->get_editing_batch()->get_current_asset()->path)
00856 {
00857         this->mwindow = mwindow;
00858         this->record = record;
00859 }
00860 int RecordPath::handle_event()
00861 {
00862         strcpy(record->get_editing_batch()->assets.values[0]->path, get_text());
00863         record->get_editing_batch()->calculate_news();
00864         record->record_gui->update_batches();
00865         return 1;
00866 }
00867 
00868 RecordStartType::RecordStartType(MWindow *mwindow, Record *record, int x, int y)
00869  : BC_CheckBox(x, y, record->get_editing_batch()->start_type, _("Offset"))
00870 {
00871         this->mwindow = mwindow;
00872         this->record = record;
00873 }
00874 int RecordStartType::handle_event()
00875 {
00876         return 1;
00877 }
00878 
00879 
00880 RecordStart::RecordStart(MWindow *mwindow, Record *record, int x, int y)
00881  : TimeEntry(record->record_gui, 
00882                 x, 
00883                 y, 
00884                 &(record->get_editing_batch()->start_day), 
00885                 &(record->get_editing_batch()->start_time),
00886                 TIME_HMS3)
00887 {
00888         this->mwindow = mwindow;
00889         this->record = record;
00890 }
00891 int RecordStart::handle_event()
00892 {
00893         record->record_gui->update_batches();
00894         return 1;
00895 }
00896 
00897 RecordDuration::RecordDuration(MWindow *mwindow, Record *record, int x, int y)
00898  : TimeEntry(record->record_gui, 
00899                 x, 
00900                 y, 
00901                 0, 
00902                 &(record->get_editing_batch()->duration),
00903                 TIME_HMS2)
00904 {
00905         this->mwindow = mwindow;
00906         this->record = record;
00907 }
00908 int RecordDuration::handle_event()
00909 {
00910         record->record_gui->update_batches();
00911         return 1;
00912 }
00913 
00914 RecordSource::RecordSource(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
00915  : BC_PopupTextBox(gui, 
00916         &gui->sources,
00917         record->get_editing_batch()->get_source_text(),
00918         x, 
00919         y, 
00920         200,
00921         200)
00922 {
00923         this->mwindow = mwindow;
00924         this->record = record;
00925         this->gui = gui;
00926 }
00927 int RecordSource::handle_event()
00928 {
00929         record->set_channel(get_number());
00930         return 1;
00931 }
00932 
00933 RecordMode::RecordMode(MWindow *mwindow, Record *record, RecordGUI *gui, int x, int y)
00934  : BC_PopupTextBox(gui,
00935         &gui->modes,
00936         Batch::mode_to_text(record->get_editing_batch()->record_mode),
00937         x,
00938         y,
00939         200,
00940         100)
00941 {
00942         this->mwindow = mwindow;
00943         this->record = record;
00944 }
00945 int RecordMode::handle_event()
00946 {
00947         record->get_editing_batch()->record_mode = Batch::text_to_mode(get_text());
00948         record->record_gui->update_batches();
00949         return 1;
00950 }
00951 
00952 RecordNews::RecordNews(MWindow *mwindow, Record *record, int x, int y)
00953  : BC_TextBox(x, y, 200, 1, record->get_editing_batch()->news)
00954 {
00955         this->mwindow = mwindow;
00956         this->record = record;
00957 }
00958 int RecordNews::handle_event()
00959 {
00960         return 1;
00961 }
00962 
00963 
00964 RecordGUINewBatch::RecordGUINewBatch(MWindow *mwindow, Record *record, int x, int y)
00965  : BC_GenericButton(x, y, _("New"))
00966 {
00967         this->mwindow = mwindow;
00968         this->record = record;
00969         set_tooltip(_("Create new clip."));
00970 }
00971 int RecordGUINewBatch::handle_event()
00972 {
00973         record->new_batch();
00974         record->record_gui->update_batches();
00975         return 1;
00976 }
00977 
00978 
00979 RecordGUIDeleteBatch::RecordGUIDeleteBatch(MWindow *mwindow, Record *record, int x, int y)
00980  : BC_GenericButton(x, y, _("Delete"))
00981 {
00982         this->mwindow = mwindow;
00983         this->record = record;
00984         set_tooltip(_("Delete clip."));
00985 }
00986 int RecordGUIDeleteBatch::handle_event()
00987 {
00988         record->delete_batch();
00989         record->record_gui->update_batches();
00990         return 1;
00991 }
00992 
00993 
00994 RecordGUIStartBatches::RecordGUIStartBatches(MWindow *mwindow, Record *record, int x, int y)
00995  : BC_GenericButton(x, y, _("Start"))
00996 {
00997         this->mwindow = mwindow;
00998         this->record = record;
00999         set_tooltip(_("Start batch recording\nfrom the current position."));
01000 }
01001 int RecordGUIStartBatches::handle_event()
01002 {
01003         unlock_window();
01004         record->start_recording(0, CONTEXT_BATCH);
01005         lock_window("RecordGUIStartBatches::handle_event");
01006         return 1;
01007 }
01008 
01009 
01010 RecordGUIStopbatches::RecordGUIStopbatches(MWindow *mwindow, Record *record, int x, int y)
01011  : BC_GenericButton(x, y, _("Stop"))
01012 {
01013         this->mwindow = mwindow;
01014         this->record = record;
01015 }
01016 int RecordGUIStopbatches::handle_event()
01017 {
01018         return 1;
01019 }
01020 
01021 
01022 RecordGUIActivateBatch::RecordGUIActivateBatch(MWindow *mwindow, Record *record, int x, int y)
01023  : BC_GenericButton(x, y, _("Activate"))
01024 {
01025         this->mwindow = mwindow;
01026         this->record = record;
01027         set_tooltip(_("Make the highlighted\nclip active."));
01028 }
01029 int RecordGUIActivateBatch::handle_event()
01030 {
01031         record->activate_batch(record->editing_batch, 1);
01032         return 1;
01033 }
01034 
01035 
01036 RecordGUILabel::RecordGUILabel(MWindow *mwindow, Record *record, int x, int y)
01037  : BC_GenericButton(x, y, _("Label"))
01038 { 
01039         this->mwindow = mwindow;
01040         this->record = record;
01041         set_underline(0);
01042 }
01043 
01044 
01045 RecordGUILabel::~RecordGUILabel()
01046 {
01047 }
01048 
01049 int RecordGUILabel::handle_event()
01050 {
01051         record->toggle_label();
01052         return 1;
01053 }
01054 
01055 int RecordGUILabel::keypress_event()
01056 {
01057         if(get_keypress() == 'l')
01058         {
01059                 handle_event();
01060                 return 1;
01061         }
01062         return 0;
01063 }
01064 
01065 
01066 
01067 
01068 
01069 
01070 
01071 
01072 
01073 
01074 
01075 
01076 
01077 
01078 
01079 
01080 
01081 RecordCancelThread::RecordCancelThread(Record *record, RecordGUI *record_gui)
01082  : Thread(1, 0, 0)
01083 {
01084         this->record = record;
01085         this->gui = record_gui;
01086 }
01087 
01088 RecordCancelThread::~RecordCancelThread()
01089 {
01090         if(Thread::running()) 
01091         {
01092                 window->lock_window("RecordCancelThread::~RecordCancelThread");
01093                 window->set_done(1);
01094                 window->unlock_window();
01095                 Thread::join();
01096         }
01097 }
01098 
01099 
01100 void RecordCancelThread::run()
01101 {
01102         if(record->prompt_cancel)
01103         {
01104                 window = new QuestionWindow(record->mwindow);
01105                 window->create_objects(_("Quit without pasting into project?"), 0);
01106                 int result = window->run_window();
01107                 if(result == 2) gui->set_done(1);
01108                 delete window;
01109         }
01110         else
01111         {
01112                 gui->set_done(1);
01113         }
01114 }
01115 
01116 
01117 RecordStartoverThread::RecordStartoverThread(Record *record, RecordGUI *record_gui)
01118  : Thread(1, 0, 0)
01119 {
01120         this->record = record;
01121         this->gui = record_gui;
01122 }
01123 RecordStartoverThread::~RecordStartoverThread()
01124 {
01125         if(Thread::running()) 
01126         {
01127                 window->lock_window("RecordStartoverThread::~RecordStartoverThread");
01128                 window->set_done(1);
01129                 window->unlock_window();
01130                 Thread::join();
01131         }
01132 }
01133 
01134 void RecordStartoverThread::run()
01135 {
01136         window = new QuestionWindow(record->mwindow);
01137         window->create_objects(_("Rewind batch and overwrite?"), 0);
01138         int result = window->run_window();
01139         if(result == 2) record->start_over();
01140         delete window;
01141 }
01142 
01143 
01144 
01145 
01146 
01147 
01148 
01149 
01150 
01151 
01152 
01153 
01154 
01155 
01156 
01157 
01158 
01159 
01160 
01161 
01162 
01163 
01164 
01165 
01166 
01167 
01168 
01169 
01170 
01171 
01172 
01173 
01174 
01175 
01176 int RecordGUI::set_translation(int x, int y, float z)
01177 {
01178         record->video_x = x;
01179         record->video_y = y;
01180         record->video_zoom = z;
01181 }
01182 
01183 int RecordGUI::update_dropped_frames(long new_dropped)
01184 {
01185         status_thread->update_dropped_frames(new_dropped);
01186         return 0;
01187 }
01188 
01189 int RecordGUI::update_position(double new_position) 
01190 { 
01191         status_thread->update_position(new_position);
01192         return 0;
01193 }
01194 
01195 int RecordGUI::update_clipped_samples(long new_clipped)
01196 {
01197         status_thread->update_clipped_samples(new_clipped);
01198         return 0;
01199 }
01200 
01201 int RecordGUI::keypress_event()
01202 {
01203         return record_transport->keypress_event();
01204 }
01205 
01206 void RecordGUI::update_labels(double new_position)
01207 {
01208         RecordLabel *prev, *next;
01209         char string[BCTEXTLEN];
01210 
01211         for(prev = record->get_current_batch()->labels->last; 
01212                 prev; 
01213                 prev = prev->previous)
01214         {
01215                 if(prev->position <= new_position) break;
01216         }
01217 
01218         for(next = record->get_current_batch()->labels->first; 
01219                 next; 
01220                 next = next->next)
01221         {
01222                 if(next->position > new_position) break;
01223         }
01224 
01225         if(prev)
01226                 update_title(prev_label_title, 
01227                         prev->position);
01228         else
01229                 update_title(prev_label_title, -1);
01230 
01231 //      if(next)
01232 //              update_title(next_label_title, (double)next->position / record->default_asset->sample_rate);
01233 //      else
01234 //              update_title(next_label_title, -1);
01235 }
01236 
01237 
01238 
01239 int RecordGUI::update_prev_label(long new_position) 
01240 { 
01241         update_title(prev_label_title, new_position);
01242 }
01243 
01244 // int RecordGUI::update_next_label(long new_position) 
01245 // { 
01246 //      update_title(next_label_title, new_position); 
01247 // }
01248 // 
01249 int RecordGUI::update_title(BC_Title *title, double position)
01250 {
01251         static char string[256];
01252 
01253         if(position > -1)
01254         {
01255                 Units::totext(string, 
01256                                 position, 
01257                                 mwindow->edl->session->time_format, 
01258                                 record->default_asset->sample_rate, 
01259                                 record->default_asset->frame_rate, 
01260                                 mwindow->edl->session->frames_per_foot);
01261         }
01262         else
01263         {
01264                 sprintf(string, "-");
01265         }
01266         lock_window("RecordGUI::update_title");
01267         title->update(string);
01268         unlock_window();
01269 }
01270 
01271 int RecordGUI::update_duration_boxes()
01272 {
01273         char string[1024];
01274 //      sprintf(string, "%d", engine->get_loop_hr());
01275 //      loop_hr->update(string);
01276 //      sprintf(string, "%d", engine->get_loop_min());
01277 //      loop_min->update(string);
01278 //      sprintf(string, "%d", engine->get_loop_sec());
01279 //      loop_sec->update(string);
01280 }
01281 
01282 
01283 
01284 
01285 
01286 
01287 // ===================================== GUI
01288 
01289 
01290 
01291 
01292 
01293 // ================================================== modes
01294 
01295 RecordGUIModeMenu::RecordGUIModeMenu(int x, 
01296         int y, 
01297         int w, 
01298         char *text)
01299  : BC_PopupMenu(x, y, w, text)
01300 { 
01301 }
01302 
01303 RecordGUIModeMenu::~RecordGUIModeMenu()
01304 {
01305         delete linear;
01306         delete timed;
01307         delete loop;
01308 }
01309 
01310 int RecordGUIModeMenu::add_items()
01311 {
01312         add_item(linear = new RecordGUIMode(_("Untimed")));
01313         add_item(timed = new RecordGUIMode(_("Timed")));
01314 //      add_item(loop = new RecordGUIMode("_(Loop")));
01315         return 0;
01316 }
01317 
01318 int RecordGUIModeMenu::handle_event()
01319 {
01320 //      engine->set_record_mode(get_text());
01321 }
01322 
01323 RecordGUIMode::RecordGUIMode(char *text)
01324  : BC_MenuItem(text)
01325 {
01326 }
01327 
01328 RecordGUIMode::~RecordGUIMode()
01329 {
01330 }
01331 
01332 int RecordGUIMode::handle_event()
01333 {
01334         get_popup_menu()->set_text(get_text());
01335         get_popup_menu()->handle_event();
01336         return 1;
01337 }
01338 
01339 
01340 
01341 
01342 
01343 RecordStatusThread::RecordStatusThread(MWindow *mwindow, RecordGUI *gui)
01344  : Thread(1, 0, 0)
01345 {
01346         this->mwindow = mwindow;
01347         this->gui = gui;
01348         new_dropped_frames = -1;
01349         new_position = -1;
01350         new_clipped_samples = -1;
01351         input_lock = new Condition(0, "RecordStatusThread::input_lock");
01352         done = 0;
01353 }
01354 
01355 RecordStatusThread::~RecordStatusThread()
01356 {
01357         if(Thread::running())
01358         {
01359                 done = 1;
01360                 input_lock->unlock();
01361                 Thread::join();
01362         }
01363 }
01364 
01365 void RecordStatusThread::update_dropped_frames(long value)
01366 {
01367         new_dropped_frames = value;
01368         input_lock->unlock();
01369 }
01370 
01371 void RecordStatusThread::update_position(double new_position)
01372 {
01373         this->new_position = new_position;
01374         input_lock->unlock();
01375 }
01376 
01377 void RecordStatusThread::update_clipped_samples(long new_clipped_samples)
01378 {
01379         this->new_clipped_samples = new_clipped_samples;
01380         input_lock->unlock();
01381 }
01382 
01383 void RecordStatusThread::run()
01384 {
01385         while(!done)
01386         {
01387                 input_lock->lock("RecordStatusThread::run");
01388                 if(new_dropped_frames >= 0)
01389                 {
01390                         char string[1024];
01391                         if(gui->total_dropped_frames != new_dropped_frames)
01392                         {
01393                                 gui->total_dropped_frames = new_dropped_frames;
01394                                 sprintf(string, "%d\n", gui->total_dropped_frames);
01395                                 gui->lock_window("RecordStatusThread::run 1");
01396                                 gui->frames_dropped->update(string);
01397                                 gui->unlock_window();
01398                         }
01399                 }
01400                 
01401                 if(new_position >= 0)
01402                 {
01403                         gui->update_title(gui->position_title, new_position);
01404                         gui->update_labels(new_position);
01405                 }
01406                 
01407                 if(new_clipped_samples >= 0)
01408                 {
01409                         if(gui->total_clipped_samples != new_clipped_samples)
01410                         {
01411                                 char string[1024];
01412                                 gui->total_clipped_samples = new_clipped_samples;
01413                                 sprintf(string, "%d\n", gui->total_clipped_samples);
01414                                 gui->lock_window("RecordStatusThread::run 2");
01415                                 gui->samples_clipped->update(string);
01416                                 gui->unlock_window();
01417                         }
01418                 }
01419 
01420                 new_clipped_samples = -1;
01421                 new_dropped_frames = -1;
01422                 new_position = -1;
01423         }
01424 }
01425 
01426 
01427 
01428 
01429 
01430 
01431 
01432 
01433 RecordGUIDCOffset::RecordGUIDCOffset(MWindow *mwindow, int y)
01434  : BC_Button(230, y, mwindow->theme->calibrate_data)
01435 {
01436 }
01437 
01438 RecordGUIDCOffset::~RecordGUIDCOffset() {}
01439 
01440 int RecordGUIDCOffset::handle_event()
01441 {
01442 //      engine->calibrate_dc_offset();
01443         return 1;
01444 }
01445 
01446 int RecordGUIDCOffset::keypress_event() { return 0; }
01447 
01448 RecordGUIDCOffsetText::RecordGUIDCOffsetText(char *text, int y, int number)
01449  : BC_TextBox(30, y+1, 67, 1, text, 0)
01450 { 
01451         this->number = number; 
01452 }
01453 
01454 RecordGUIDCOffsetText::~RecordGUIDCOffsetText()
01455 {
01456 }
01457         
01458 int RecordGUIDCOffsetText::handle_event()
01459 {
01460 //      if(!engine->is_previewing)
01461 //      {
01462 //              engine->calibrate_dc_offset(atol(get_text()), number);
01463 //      }
01464         return 1;
01465 }
01466 
01467 RecordGUIReset::RecordGUIReset(MWindow *mwindow, RecordGUI *gui, int y)
01468  : BC_Button(400, y, mwindow->theme->over_button)
01469 { this->gui = gui; }
01470 
01471 RecordGUIReset::~RecordGUIReset() 
01472 {
01473 }
01474 
01475 int RecordGUIReset::handle_event()
01476 {
01477 //      for(int i = 0; i < gui->engine->get_input_channels(); i++)
01478 //      {
01479 //              gui->meter[i]->reset_over();
01480 //      }
01481         return 1;
01482 }
01483 
01484 RecordGUIResetTranslation::RecordGUIResetTranslation(MWindow *mwindow, RecordGUI *gui, int y)
01485  : BC_Button(250, y, mwindow->theme->reset_data)
01486 { this->gui = gui; }
01487 
01488 RecordGUIResetTranslation::~RecordGUIResetTranslation() 
01489 {
01490 }
01491 
01492 int RecordGUIResetTranslation::handle_event()
01493 {
01494         gui->set_translation(0, 0, 1);
01495         return 1;
01496 }
01497 
01498 
01499 
01500 
01501 
01502 RecordGUIOK::RecordGUIOK(MWindow *mwindow, int y)
01503  : BC_OKButton(50, y)
01504 {
01505 }
01506 
01507 RecordGUIOK::~RecordGUIOK()
01508 {
01509 }
01510 
01511 int RecordGUIOK::handle_event()
01512 {
01513         unlock_window();
01514 //      engine->set_done(0);
01515         lock_window();
01516         return 1;
01517 }

Generated on Sun Jan 8 13:38:59 2006 for Cinelerra-svn by  doxygen 1.4.4