4 #include "awindowgui.h"
5 #include "bcprogressbox.h"
12 #include "filesystem.h"
13 #include "indexfile.h"
15 #include "mainindexes.h"
17 #include "mwindowgui.h"
20 #include "preferences.h"
21 #include "transportque.h"
22 #include "interlacemodes.h"
24 #include "edlsession.h"
30 AssetEdit::AssetEdit(MWindow *mwindow)
33 this->mwindow = mwindow;
40 AssetEdit::~AssetEdit()
45 void AssetEdit::edit_asset(Asset *asset)
49 // Allow more than one window
56 int AssetEdit::set_asset(Asset *asset)
66 new_asset = new Asset(asset->path);
70 window = new AssetEditWindow(mwindow, this);
71 window->create_objects();
72 window->raise_window();
73 result = window->run_window();
77 if(!asset->equivalent(*new_asset, 1, 1))
79 mwindow->gui->lock_window();
80 // Omit index status from copy since an index rebuild may have been
81 // happening when new_asset was created but not be happening anymore.
82 asset->copy_from(new_asset, 0);
84 mwindow->gui->update(0,
92 // Start index rebuilding
95 char source_filename[BCTEXTLEN];
96 char index_filename[BCTEXTLEN];
97 IndexFile::get_index_filename(source_filename,
98 mwindow->preferences->index_directory,
101 remove(index_filename);
102 asset->index_status = INDEX_NOTTESTED;
103 mwindow->mainindexes->add_next_asset(0, asset);
104 mwindow->mainindexes->start_build();
106 mwindow->gui->unlock_window();
109 mwindow->awindow->gui->lock_window();
110 mwindow->awindow->gui->update_assets();
111 mwindow->awindow->gui->unlock_window();
113 mwindow->restart_brender();
114 mwindow->sync_parameters(CHANGE_ALL);
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;
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));
198 int64_t bytes = fs.get_size(asset->path);
199 add_subwindow(new BC_Title(x, y, _("Bytes:")));
200 sprintf(string, "%lld", bytes);
201 Units::punctuate(string);
204 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
209 if(asset->audio_length > 0)
210 length = (double)asset->audio_length / asset->sample_rate;
211 if(asset->video_length > 0)
212 length = MAX(length, (double)asset->video_length / asset->frame_rate);
214 if(!EQUIV(length, 0))
215 bitrate = (int64_t)(bytes * 8 / length);
218 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
219 sprintf(string, "%lld", bitrate);
221 Units::punctuate(string);
222 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
227 if(asset->audio_data)
229 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
232 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
236 if(asset->get_compression_text(1, 0))
238 add_subwindow(new BC_Title(x, y, _("Compression:")));
240 add_subwindow(new BC_Title(x,
242 asset->get_compression_text(1, 0),
244 mwindow->theme->edit_font_color));
249 add_subwindow(new BC_Title(x, y, _("Channels:")));
250 sprintf(string, "%d", asset->channels);
255 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
256 textbox->create_objects();
261 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
266 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
267 sprintf(string, "%d", asset->sample_rate);
274 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
275 x += textbox->get_w();
276 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
280 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
286 add_subwindow(new BC_Title(x, y, _("Bits:")));
290 bitspopup = new BitsPopup(this,
299 bitspopup->create_objects();
302 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->edit_font_color));
307 add_subwindow(new BC_Title(x, y, _("Header length:")));
308 sprintf(string, "%d", asset->header);
312 add_subwindow(new AssetEditHeader(this, string, x, y));
314 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
319 add_subwindow(new BC_Title(x, y, _("Byte order:")));
325 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
330 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
339 if(asset->byte_order)
340 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->edit_font_color));
342 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->edit_font_color));
350 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
351 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
355 if(!asset->signed_ && asset->bits == 8)
356 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
358 add_subwindow(new BC_Title(x, y, _("Values are signed")));
365 if(asset->video_data)
367 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
370 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
375 if(asset->get_compression_text(0,1))
377 add_subwindow(new BC_Title(x, y, _("Compression:")));
379 add_subwindow(new BC_Title(x,
381 asset->get_compression_text(0,1),
383 mwindow->theme->edit_font_color));
388 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
390 sprintf(string, "%.2f", asset->frame_rate);
391 BC_TextBox *framerate;
392 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
394 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
398 add_subwindow(new BC_Title(x, y, _("Width:")));
400 sprintf(string, "%d", asset->width);
401 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
405 add_subwindow(new BC_Title(x, y, _("Height:")));
407 sprintf(string, "%d", asset->height);
408 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
411 // --------------------
412 add_subwindow(titlew = new BC_Title(x1, y, _("Fix interlacing:")));
413 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
414 y += ilacefixoption_chkboxw->get_h() + 5;
416 // --------------------
417 add_subwindow(titlew = new BC_Title(x1, y, _("Asset's interlacing:")));
418 add_subwindow(textboxw = new AssetEditILacemode(this, "", BC_ILACE_ASSET_MODEDEFAULT, x2, y, 200));
419 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
420 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
422 &asset->interlace_mode,
423 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
424 ilacefixoption_chkboxw,
425 x2 + textboxw->get_w(),
427 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
428 y += textboxw->get_h() + 5;
430 // --------------------
431 add_subwindow(titlew = new BC_Title(x1, y, _("Interlace correction:")));
432 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", BC_ILACE_FIXDEFAULT, x2, y, 200));
433 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
434 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
436 &asset->interlace_fixmethod,
437 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
438 x2 + textboxw->get_w(),
440 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
441 ilacefixoption_chkboxw->showhideotherwidgets();
442 y += textboxw->get_h() + 5;
445 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
447 add_subwindow(new AssetEditReelName(this, x, y));
451 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
453 add_subwindow(new AssetEditReelNumber(this, x, y));
457 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
460 // Calculate values to enter into textboxes
464 asset->tcstart / asset->frame_rate,
473 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc), x, y,
474 (int) (asset->frame_rate * 60 * 60)));
476 add_subwindow(new BC_Title(x, y, ":"));
478 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 2), x, y,
479 (int) (asset->frame_rate * 60)));
481 add_subwindow(new BC_Title(x, y, ":"));
483 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 5), x, y,
484 (int) (asset->frame_rate)));
486 add_subwindow(new BC_Title(x, y, ":"));
488 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 8), x, y, 1));
494 add_subwindow(new BC_OKButton(this));
495 add_subwindow(new BC_CancelButton(this));
501 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
505 : BC_TumbleTextBox(fwindow,
513 this->fwindow = fwindow;
516 int AssetEditChannels::handle_event()
518 fwindow->asset->channels = atol(get_text());
522 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
523 : BC_TextBox(x, y, 100, 1, text)
525 this->fwindow = fwindow;
528 int AssetEditRate::handle_event()
530 fwindow->asset->sample_rate = atol(get_text());
534 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
535 : BC_TextBox(x, y, 100, 1, text)
537 this->fwindow = fwindow;
540 int AssetEditFRate::handle_event()
542 fwindow->asset->frame_rate = atof(get_text());
546 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
547 : BC_CheckBox(x, y, fwindow->asset->interlace_autofixoption, _("Automatically Fix Interlacing"))
549 this->fwindow = fwindow;
550 this->mwindow = mwindow;
553 Interlaceautofix::~Interlaceautofix()
557 int Interlaceautofix::handle_event()
559 fwindow->asset->interlace_autofixoption = get_value();
560 showhideotherwidgets();
564 void Interlaceautofix::showhideotherwidgets()
566 int thevalue = get_value();
568 if (thevalue == BC_ILACE_AUTOFIXOPTION_AUTO)
570 this->ilacemode_textbox->enable();
571 this->ilacemode_listbox->enable();
572 this->ilacefixmethod_textbox->disable();
573 this->ilacefixmethod_listbox->disable();
574 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,fwindow->asset->interlace_mode);
575 ilacefixmethod_to_text(string,xx);
576 this->ilacefixmethod_textbox->update(string);
578 if (thevalue == BC_ILACE_AUTOFIXOPTION_MANUAL)
580 this->ilacemode_textbox->disable();
581 this->ilacemode_listbox->disable();
582 this->ilacefixmethod_textbox->enable();
583 this->ilacefixmethod_listbox->enable();
584 ilacefixmethod_to_text(string,fwindow->asset->interlace_fixmethod);
585 this->ilacefixmethod_textbox->update(string);
589 InterlacefixmethodItem::InterlacefixmethodItem(char *text, int value)
590 : BC_ListBoxItem(text)
595 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
596 BC_TextBox *output_text,
598 ArrayList<BC_ListBoxItem*> *data,
613 char string[BCTEXTLEN];
615 this->mwindow = mwindow;
616 this->output_text = output_text;
617 this->output_value = output_value;
618 output_text->update(interlacefixmethod_to_text());
621 int InterlacefixmethodPulldown::handle_event()
623 output_text->update(get_selection(0, 0)->get_text());
624 *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
628 char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
630 ilacefixmethod_to_text(this->string,*output_value);
631 return (this->string);
634 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
635 : BC_TextBox(x, y, w, 1, text)
637 this->fwindow = fwindow;
638 this->thedefault = thedefault;
641 int AssetEditILaceautofixoption::handle_event()
643 fwindow->asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
648 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
649 : BC_TextBox(x, y, w, 1, text)
651 this->fwindow = fwindow;
652 this->thedefault = thedefault;
655 int AssetEditILacemode::handle_event()
657 fwindow->asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
661 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
662 BC_TextBox *output_text,
664 ArrayList<BC_ListBoxItem*> *data,
665 Interlaceautofix *fixoption_chkboxw,
680 char string[BCTEXTLEN];
681 this->fixoption_chkbox = fixoption_chkboxw;
682 this->mwindow = mwindow;
683 this->output_text = output_text;
684 this->output_value = output_value;
685 output_text->update(interlacemode_to_text());
688 int AssetEditInterlacemodePulldown::handle_event()
690 output_text->update(get_selection(0, 0)->get_text());
691 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
692 fixoption_chkbox->showhideotherwidgets();
696 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
698 ilacemode_to_text(this->string,*output_value);
699 return (this->string);
702 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
703 : BC_TextBox(x, y, w, 1, text)
705 this->fwindow = fwindow;
706 this->thedefault = thedefault;
709 int AssetEditILacefixmethod::handle_event()
711 fwindow->asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
715 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
716 : BC_TextBox(x, y, 100, 1, text)
718 this->fwindow = fwindow;
721 int AssetEditHeader::handle_event()
723 fwindow->asset->header = atol(get_text());
727 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
731 : BC_Radial(x, y, value, _("Lo-Hi"))
733 this->fwindow = fwindow;
736 int AssetEditByteOrderLOHI::handle_event()
738 fwindow->asset->byte_order = 1;
739 fwindow->hilo->update(0);
744 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
748 : BC_Radial(x, y, value, _("Hi-Lo"))
750 this->fwindow = fwindow;
753 int AssetEditByteOrderHILO::handle_event()
755 fwindow->asset->byte_order = 0;
756 fwindow->lohi->update(0);
761 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
765 : BC_CheckBox(x, y, value, _("Values are signed"))
767 this->fwindow = fwindow;
770 int AssetEditSigned::handle_event()
772 fwindow->asset->signed_ = get_value();
782 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
783 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
785 this->fwindow = fwindow;
787 AssetEditPathText::~AssetEditPathText()
790 int AssetEditPathText::handle_event()
792 strcpy(fwindow->asset->path, get_text());
796 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
797 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
799 this->fwindow = fwindow;
801 AssetEditPath::~AssetEditPath() {}
808 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
809 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
811 this->fwindow = fwindow;
813 AssetEditFormat::~AssetEditFormat()
816 int AssetEditFormat::handle_event()
818 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());
825 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
826 : BC_TextBox(x, y, 300, 1, fwindow->asset->reel_name)
828 this->fwindow = fwindow;
830 AssetEditReelName::~AssetEditReelName()
833 int AssetEditReelName::handle_event()
835 strcpy(fwindow->asset->reel_name, get_text());
842 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
843 : BC_TextBox(x, y, 200, 1, fwindow->asset->reel_number)
845 this->fwindow = fwindow;
847 AssetEditReelNumber::~AssetEditReelNumber()
850 int AssetEditReelNumber::handle_event()
852 char *text = get_text() + strlen(get_text()) - 1;
854 // Don't let user enter an invalid character -- only numbers here
861 fwindow->asset->reel_number = atoi(get_text());
868 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
869 : BC_TextBox(x, y, 30, 1, value)
871 this->fwindow = fwindow;
872 this->multiplier = multiplier;
875 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
878 int AssetEditTCStartTextBox::handle_event()
880 fwindow->asset->tcstart -= previous * multiplier;
881 fwindow->asset->tcstart += atoi(get_text()) * multiplier;
882 previous = atoi(get_text());