4 #include "awindowgui.h"
5 #include "bcprogressbox.h"
13 #include "filesystem.h"
14 #include "indexfile.h"
16 #include "mainindexes.h"
18 #include "mwindowgui.h"
21 #include "preferences.h"
22 #include "transportque.h"
23 #include "interlacemodes.h"
25 #include "edlsession.h"
31 AssetEdit::AssetEdit(MWindow *mwindow)
34 this->mwindow = mwindow;
41 AssetEdit::~AssetEdit()
46 void AssetEdit::edit_asset(Asset *asset)
50 // Allow more than one window
57 int AssetEdit::set_asset(Asset *asset)
67 new_asset = new Asset(asset->path);
71 window = new AssetEditWindow(mwindow, this);
72 window->create_objects();
73 window->raise_window();
74 result = window->run_window();
78 if(!asset->equivalent(*new_asset, 1, 1))
80 mwindow->gui->lock_window();
81 mwindow->remove_asset_from_caches(asset);
82 // Omit index status from copy since an index rebuild may have been
83 // happening when new_asset was created but not be happening anymore.
84 asset->copy_from(new_asset, 0);
86 mwindow->gui->update(0,
94 // Start index rebuilding
97 char source_filename[BCTEXTLEN];
98 char index_filename[BCTEXTLEN];
99 IndexFile::get_index_filename(source_filename,
100 mwindow->preferences->index_directory,
103 remove(index_filename);
104 asset->index_status = INDEX_NOTTESTED;
105 mwindow->mainindexes->add_next_asset(0, asset);
106 mwindow->mainindexes->start_build();
108 mwindow->gui->unlock_window();
111 mwindow->awindow->gui->async_update_assets();
113 mwindow->restart_brender();
114 mwindow->sync_parameters(CHANGE_ALL);
118 Garbage::delete_object(new_asset);
131 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
132 : BC_Window(PROGRAM_NAME ": Asset Info",
133 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
134 mwindow->gui->get_abs_cursor_y(1) - 550 / 2,
143 this->mwindow = mwindow;
144 this->asset_edit = asset_edit;
145 this->asset = asset_edit->new_asset;
147 if(asset->format == FILE_PCM)
157 AssetEditWindow::~AssetEditWindow()
159 if(bitspopup) delete bitspopup;
165 int AssetEditWindow::create_objects()
167 int y = 10, x = 10, x1 = 10, x2 = 160;
168 char string[BCTEXTLEN];
170 int hmargin1 = 180, hmargin2 = 290;
173 BC_TextBox *textboxw;
174 BC_CheckBox *chkboxw;
175 BC_ListBox *listboxw;
176 Interlaceautofix *ilacefixoption_chkboxw;
183 add_subwindow(path_text = new AssetEditPathText(this, y));
184 add_subwindow(path_button = new AssetEditPath(mwindow,
189 PROGRAM_NAME ": Asset path", _("Select a file for this asset:")));
192 add_subwindow(new BC_Title(x, y, _("File format:")));
194 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb, asset->format), MEDIUMFONT, mwindow->theme->edit_font_color));
199 int subtitle_tracks = 0;
200 if(asset->format == FILE_MPEG &&
203 // Get length from TOC
204 FileMPEG::get_info(asset, &bytes, &subtitle_tracks);
208 bytes = fs.get_size(asset->path);
210 add_subwindow(new BC_Title(x, y, _("Bytes:")));
211 sprintf(string, "%lld", bytes);
212 Units::punctuate(string);
215 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
220 if(asset->audio_length > 0)
221 length = (double)asset->audio_length / asset->sample_rate;
222 if(asset->video_length > 0)
223 length = MAX(length, (double)asset->video_length / asset->frame_rate);
225 if(!EQUIV(length, 0))
226 bitrate = (int64_t)(bytes * 8 / length);
229 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
230 sprintf(string, "%lld", bitrate);
232 Units::punctuate(string);
233 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
238 if(asset->audio_data)
240 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
243 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
247 if(asset->get_compression_text(1, 0))
249 add_subwindow(new BC_Title(x, y, _("Compression:")));
251 add_subwindow(new BC_Title(x,
253 asset->get_compression_text(1, 0),
255 mwindow->theme->edit_font_color));
260 add_subwindow(new BC_Title(x, y, _("Channels:")));
261 sprintf(string, "%d", asset->channels);
266 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
267 textbox->create_objects();
272 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
277 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
278 sprintf(string, "%d", asset->sample_rate);
285 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
286 x += textbox->get_w();
287 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
291 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
297 add_subwindow(new BC_Title(x, y, _("Bits:")));
301 bitspopup = new BitsPopup(this,
310 bitspopup->create_objects();
313 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->edit_font_color));
318 add_subwindow(new BC_Title(x, y, _("Header length:")));
319 sprintf(string, "%d", asset->header);
323 add_subwindow(new AssetEditHeader(this, string, x, y));
325 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
330 add_subwindow(new BC_Title(x, y, _("Byte order:")));
336 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
341 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
350 if(asset->byte_order)
351 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->edit_font_color));
353 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->edit_font_color));
361 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
362 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
366 if(!asset->signed_ && asset->bits == 8)
367 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
369 add_subwindow(new BC_Title(x, y, _("Values are signed")));
376 if(asset->video_data)
378 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
381 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
386 if(asset->get_compression_text(0,1))
388 add_subwindow(new BC_Title(x, y, _("Compression:")));
390 add_subwindow(new BC_Title(x,
392 asset->get_compression_text(0,1),
394 mwindow->theme->edit_font_color));
399 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
401 sprintf(string, "%.2f", asset->frame_rate);
402 BC_TextBox *framerate;
403 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
405 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
409 add_subwindow(new BC_Title(x, y, _("Width:")));
411 sprintf(string, "%d", asset->width);
412 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
416 add_subwindow(new BC_Title(x, y, _("Height:")));
418 sprintf(string, "%d", asset->height);
419 add_subwindow(title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
420 y += title->get_h() + 5;
422 if(asset->format == FILE_MPEG)
425 add_subwindow(new BC_Title(x, y, _("Subtitle tracks:")));
427 sprintf(string, "%d", subtitle_tracks);
428 add_subwindow(title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
429 y += title->get_h() + 5;
432 // --------------------
433 add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
434 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
435 y += ilacefixoption_chkboxw->get_h() + 5;
437 // --------------------
438 add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
439 add_subwindow(textboxw = new AssetEditILacemode(this, "", BC_ILACE_ASSET_MODEDEFAULT, x2, y, 200));
440 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
441 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
443 &asset->interlace_mode,
444 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
445 ilacefixoption_chkboxw,
446 x2 + textboxw->get_w(),
448 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
449 y += textboxw->get_h() + 5;
451 // --------------------
452 add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
453 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", BC_ILACE_FIXDEFAULT, x2, y, 200));
454 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
455 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
457 &asset->interlace_fixmethod,
458 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
459 x2 + textboxw->get_w(),
461 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
462 ilacefixoption_chkboxw->showhideotherwidgets();
463 y += textboxw->get_h() + 5;
466 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
468 add_subwindow(new AssetEditReelName(this, x, y));
472 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
474 add_subwindow(new AssetEditReelNumber(this, x, y));
478 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
481 // Calculate values to enter into textboxes
485 asset->tcstart / asset->frame_rate,
491 char *tc_minutes = strchr(tc, ':') + 1;
492 *(tc_minutes - 1) = 0;
493 char *tc_seconds = strchr(tc_minutes, ':') + 1;
494 *(tc_seconds - 1) = 0;
495 char *tc_rest = strchr(tc_seconds, ':') + 1;
498 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_hours), x, y,
499 (int) (asset->frame_rate * 60 * 60)));
501 add_subwindow(new BC_Title(x, y, ":"));
503 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_minutes), x, y,
504 (int) (asset->frame_rate * 60)));
506 add_subwindow(new BC_Title(x, y, ":"));
508 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_seconds), x, y,
509 (int) (asset->frame_rate)));
511 add_subwindow(new BC_Title(x, y, ":"));
513 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_rest), x, y, 1));
519 add_subwindow(new BC_OKButton(this));
520 add_subwindow(new BC_CancelButton(this));
526 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
530 : BC_TumbleTextBox(fwindow,
538 this->fwindow = fwindow;
541 int AssetEditChannels::handle_event()
543 fwindow->asset->channels = atol(get_text());
547 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
548 : BC_TextBox(x, y, 100, 1, text)
550 this->fwindow = fwindow;
553 int AssetEditRate::handle_event()
555 fwindow->asset->sample_rate = atol(get_text());
559 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
560 : BC_TextBox(x, y, 100, 1, text)
562 this->fwindow = fwindow;
565 int AssetEditFRate::handle_event()
567 fwindow->asset->frame_rate = atof(get_text());
571 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
572 : BC_CheckBox(x, y, fwindow->asset->interlace_autofixoption, _("Automatically Fix Interlacing"))
574 this->fwindow = fwindow;
575 this->mwindow = mwindow;
578 Interlaceautofix::~Interlaceautofix()
582 int Interlaceautofix::handle_event()
584 fwindow->asset->interlace_autofixoption = get_value();
585 showhideotherwidgets();
589 void Interlaceautofix::showhideotherwidgets()
591 int thevalue = get_value();
593 if (thevalue == BC_ILACE_AUTOFIXOPTION_AUTO)
595 this->ilacemode_textbox->enable();
596 this->ilacemode_listbox->enable();
597 this->ilacefixmethod_textbox->disable();
598 this->ilacefixmethod_listbox->disable();
599 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,fwindow->asset->interlace_mode);
600 ilacefixmethod_to_text(string,xx);
601 this->ilacefixmethod_textbox->update(string);
603 if (thevalue == BC_ILACE_AUTOFIXOPTION_MANUAL)
605 this->ilacemode_textbox->disable();
606 this->ilacemode_listbox->disable();
607 this->ilacefixmethod_textbox->enable();
608 this->ilacefixmethod_listbox->enable();
609 ilacefixmethod_to_text(string,fwindow->asset->interlace_fixmethod);
610 this->ilacefixmethod_textbox->update(string);
614 InterlacefixmethodItem::InterlacefixmethodItem(char *text, int value)
615 : BC_ListBoxItem(text)
620 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
621 BC_TextBox *output_text,
623 ArrayList<BC_ListBoxItem*> *data,
638 char string[BCTEXTLEN];
640 this->mwindow = mwindow;
641 this->output_text = output_text;
642 this->output_value = output_value;
643 output_text->update(interlacefixmethod_to_text());
646 int InterlacefixmethodPulldown::handle_event()
648 output_text->update(get_selection(0, 0)->get_text());
649 *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
653 char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
655 ilacefixmethod_to_text(this->string,*output_value);
656 return (this->string);
659 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
660 : BC_TextBox(x, y, w, 1, text)
662 this->fwindow = fwindow;
663 this->thedefault = thedefault;
666 int AssetEditILaceautofixoption::handle_event()
668 fwindow->asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
673 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
674 : BC_TextBox(x, y, w, 1, text)
676 this->fwindow = fwindow;
677 this->thedefault = thedefault;
680 int AssetEditILacemode::handle_event()
682 fwindow->asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
686 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
687 BC_TextBox *output_text,
689 ArrayList<BC_ListBoxItem*> *data,
690 Interlaceautofix *fixoption_chkboxw,
705 char string[BCTEXTLEN];
706 this->fixoption_chkbox = fixoption_chkboxw;
707 this->mwindow = mwindow;
708 this->output_text = output_text;
709 this->output_value = output_value;
710 output_text->update(interlacemode_to_text());
713 int AssetEditInterlacemodePulldown::handle_event()
715 output_text->update(get_selection(0, 0)->get_text());
716 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
717 fixoption_chkbox->showhideotherwidgets();
721 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
723 ilacemode_to_text(this->string,*output_value);
724 return (this->string);
727 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
728 : BC_TextBox(x, y, w, 1, text)
730 this->fwindow = fwindow;
731 this->thedefault = thedefault;
734 int AssetEditILacefixmethod::handle_event()
736 fwindow->asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
740 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
741 : BC_TextBox(x, y, 100, 1, text)
743 this->fwindow = fwindow;
746 int AssetEditHeader::handle_event()
748 fwindow->asset->header = atol(get_text());
752 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
756 : BC_Radial(x, y, value, _("Lo-Hi"))
758 this->fwindow = fwindow;
761 int AssetEditByteOrderLOHI::handle_event()
763 fwindow->asset->byte_order = 1;
764 fwindow->hilo->update(0);
769 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
773 : BC_Radial(x, y, value, _("Hi-Lo"))
775 this->fwindow = fwindow;
778 int AssetEditByteOrderHILO::handle_event()
780 fwindow->asset->byte_order = 0;
781 fwindow->lohi->update(0);
786 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
790 : BC_CheckBox(x, y, value, _("Values are signed"))
792 this->fwindow = fwindow;
795 int AssetEditSigned::handle_event()
797 fwindow->asset->signed_ = get_value();
807 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
808 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
810 this->fwindow = fwindow;
812 AssetEditPathText::~AssetEditPathText()
815 int AssetEditPathText::handle_event()
817 strcpy(fwindow->asset->path, get_text());
821 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
822 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
824 this->fwindow = fwindow;
826 AssetEditPath::~AssetEditPath() {}
833 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
834 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
836 this->fwindow = fwindow;
838 AssetEditFormat::~AssetEditFormat()
841 int AssetEditFormat::handle_event()
843 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());
850 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
851 : BC_TextBox(x, y, 300, 1, fwindow->asset->reel_name)
853 this->fwindow = fwindow;
855 AssetEditReelName::~AssetEditReelName()
858 int AssetEditReelName::handle_event()
860 strcpy(fwindow->asset->reel_name, get_text());
867 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
868 : BC_TextBox(x, y, 200, 1, fwindow->asset->reel_number)
870 this->fwindow = fwindow;
872 AssetEditReelNumber::~AssetEditReelNumber()
875 int AssetEditReelNumber::handle_event()
877 char *text = get_text() + strlen(get_text()) - 1;
879 // Don't let user enter an invalid character -- only numbers here
886 fwindow->asset->reel_number = atoi(get_text());
893 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
894 : BC_TextBox(x, y, 30, 1, value)
896 this->fwindow = fwindow;
897 this->multiplier = multiplier;
900 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
903 int AssetEditTCStartTextBox::handle_event()
905 fwindow->asset->tcstart -= previous * multiplier;
906 fwindow->asset->tcstart += atoi(get_text()) * multiplier;
907 previous = atoi(get_text());