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 result = window->run_window();
76 if(!asset->equivalent(*new_asset, 1, 1))
78 mwindow->gui->lock_window();
79 // Omit index status from copy since an index rebuild may have been
80 // happening when new_asset was created but not be happening anymore.
81 asset->copy_from(new_asset, 0);
83 mwindow->gui->update(0,
91 // Start index rebuilding
94 char source_filename[BCTEXTLEN];
95 char index_filename[BCTEXTLEN];
96 IndexFile::get_index_filename(source_filename,
97 mwindow->preferences->index_directory,
100 remove(index_filename);
101 asset->index_status = INDEX_NOTTESTED;
102 mwindow->mainindexes->add_next_asset(0, asset);
103 mwindow->mainindexes->start_build();
105 mwindow->gui->unlock_window();
108 mwindow->awindow->gui->lock_window();
109 mwindow->awindow->gui->update_assets();
110 mwindow->awindow->gui->unlock_window();
112 mwindow->restart_brender();
113 mwindow->sync_parameters(CHANGE_ALL);
130 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
131 : BC_Window(PROGRAM_NAME ": Asset Info",
132 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
133 mwindow->gui->get_abs_cursor_y(1) - 550 / 2,
142 this->mwindow = mwindow;
143 this->asset_edit = asset_edit;
144 this->asset = asset_edit->new_asset;
146 if(asset->format == FILE_PCM)
156 AssetEditWindow::~AssetEditWindow()
158 if(bitspopup) delete bitspopup;
164 int AssetEditWindow::create_objects()
166 int y = 10, x = 10, x1 = 10, x2 = 160;
169 int hmargin1 = 180, hmargin2 = 290;
172 BC_TextBox *textboxw;
173 BC_CheckBox *chkboxw;
174 BC_ListBox *listboxw;
175 Interlaceautofix *ilacefixoption_chkboxw;
182 add_subwindow(path_text = new AssetEditPathText(this, y));
183 add_subwindow(path_button = new AssetEditPath(mwindow,
188 PROGRAM_NAME ": Asset path", _("Select a file for this asset:")));
191 add_subwindow(new BC_Title(x, y, _("File format:")));
193 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb, asset->format), MEDIUMFONT, mwindow->theme->edit_font_color));
197 int64_t bytes = fs.get_size(asset->path);
198 add_subwindow(new BC_Title(x, y, _("Bytes:")));
199 sprintf(string, "%lld", bytes);
200 Units::punctuate(string);
203 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
208 if(asset->audio_length > 0)
209 length = (double)asset->audio_length / asset->sample_rate;
210 if(asset->video_length > 0)
211 length = MAX(length, (double)asset->video_length / asset->frame_rate);
213 if(!EQUIV(length, 0))
214 bitrate = (int64_t)(bytes * 8 / length);
217 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
218 sprintf(string, "%lld", bitrate);
220 Units::punctuate(string);
221 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
226 if(asset->audio_data)
228 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
231 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
235 if(asset->get_compression_text(1, 0))
237 add_subwindow(new BC_Title(x, y, _("Compression:")));
239 add_subwindow(new BC_Title(x,
241 asset->get_compression_text(1, 0),
243 mwindow->theme->edit_font_color));
248 add_subwindow(new BC_Title(x, y, _("Channels:")));
249 sprintf(string, "%d", asset->channels);
254 BC_TumbleTextBox *textbox = new AssetEditChannels(this, string, x, y);
255 textbox->create_objects();
260 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
265 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
266 sprintf(string, "%d", asset->sample_rate);
273 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
274 x += textbox->get_w();
275 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
279 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
285 add_subwindow(new BC_Title(x, y, _("Bits:")));
289 bitspopup = new BitsPopup(this,
298 bitspopup->create_objects();
301 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->edit_font_color));
306 add_subwindow(new BC_Title(x, y, _("Header length:")));
307 sprintf(string, "%d", asset->header);
311 add_subwindow(new AssetEditHeader(this, string, x, y));
313 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
318 add_subwindow(new BC_Title(x, y, _("Byte order:")));
324 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
329 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
338 if(asset->byte_order)
339 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->edit_font_color));
341 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->edit_font_color));
349 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
350 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
354 if(!asset->signed_ && asset->bits == 8)
355 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
357 add_subwindow(new BC_Title(x, y, _("Values are signed")));
364 if(asset->video_data)
366 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
369 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
374 if(asset->get_compression_text(0,1))
376 add_subwindow(new BC_Title(x, y, _("Compression:")));
378 add_subwindow(new BC_Title(x,
380 asset->get_compression_text(0,1),
382 mwindow->theme->edit_font_color));
387 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
389 sprintf(string, "%.2f", asset->frame_rate);
390 BC_TextBox *framerate;
391 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
393 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
397 add_subwindow(new BC_Title(x, y, _("Width:")));
399 sprintf(string, "%d", asset->width);
400 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
404 add_subwindow(new BC_Title(x, y, _("Height:")));
406 sprintf(string, "%d", asset->height);
407 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->edit_font_color));
410 // --------------------
411 add_subwindow(titlew = new BC_Title(x1, y, _("Fix interlacing:")));
412 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
413 y += ilacefixoption_chkboxw->get_h() + 5;
415 // --------------------
416 add_subwindow(titlew = new BC_Title(x1, y, _("Asset's interlacing:")));
417 add_subwindow(textboxw = new AssetEditILacemode(this, "", BC_ILACE_ASSET_MODEDEFAULT, x2, y, 200));
418 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
419 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
421 &asset->interlace_mode,
422 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
423 ilacefixoption_chkboxw,
424 x2 + textboxw->get_w(),
426 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
427 y += textboxw->get_h() + 5;
429 // --------------------
430 add_subwindow(titlew = new BC_Title(x1, y, _("Interlace correction:")));
431 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", BC_ILACE_FIXDEFAULT, x2, y, 200));
432 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
433 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
435 &asset->interlace_fixmethod,
436 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
437 x2 + textboxw->get_w(),
439 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
440 ilacefixoption_chkboxw->showhideotherwidgets();
441 y += textboxw->get_h() + 5;
444 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
446 add_subwindow(new AssetEditReelName(this, x, y));
450 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
452 add_subwindow(new AssetEditReelNumber(this, x, y));
456 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
459 // Calculate values to enter into textboxes
463 asset->tcstart / asset->frame_rate,
472 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc), x, y,
473 (int) (asset->frame_rate * 60 * 60)));
475 add_subwindow(new BC_Title(x, y, ":"));
477 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 2), x, y,
478 (int) (asset->frame_rate * 60)));
480 add_subwindow(new BC_Title(x, y, ":"));
482 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 5), x, y,
483 (int) (asset->frame_rate)));
485 add_subwindow(new BC_Title(x, y, ":"));
487 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc + 8), x, y, 1));
493 add_subwindow(new BC_OKButton(this));
494 add_subwindow(new BC_CancelButton(this));
500 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
504 : BC_TumbleTextBox(fwindow,
512 this->fwindow = fwindow;
515 int AssetEditChannels::handle_event()
517 fwindow->asset->channels = atol(get_text());
521 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
522 : BC_TextBox(x, y, 100, 1, text)
524 this->fwindow = fwindow;
527 int AssetEditRate::handle_event()
529 fwindow->asset->sample_rate = atol(get_text());
533 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
534 : BC_TextBox(x, y, 100, 1, text)
536 this->fwindow = fwindow;
539 int AssetEditFRate::handle_event()
541 fwindow->asset->frame_rate = atof(get_text());
545 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
546 : BC_CheckBox(x, y, fwindow->asset->interlace_autofixoption, _("Automatically Fix Interlacing"))
548 this->fwindow = fwindow;
549 this->mwindow = mwindow;
552 Interlaceautofix::~Interlaceautofix()
556 int Interlaceautofix::handle_event()
558 fwindow->asset->interlace_autofixoption = get_value();
559 showhideotherwidgets();
563 void Interlaceautofix::showhideotherwidgets()
565 int thevalue = get_value();
567 if (thevalue == BC_ILACE_AUTOFIXOPTION_AUTO)
569 this->ilacemode_textbox->enable();
570 this->ilacemode_listbox->enable();
571 this->ilacefixmethod_textbox->disable();
572 this->ilacefixmethod_listbox->disable();
573 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,fwindow->asset->interlace_mode);
574 ilacefixmethod_to_text(string,xx);
575 this->ilacefixmethod_textbox->update(string);
577 if (thevalue == BC_ILACE_AUTOFIXOPTION_MANUAL)
579 this->ilacemode_textbox->disable();
580 this->ilacemode_listbox->disable();
581 this->ilacefixmethod_textbox->enable();
582 this->ilacefixmethod_listbox->enable();
583 ilacefixmethod_to_text(string,fwindow->asset->interlace_fixmethod);
584 this->ilacefixmethod_textbox->update(string);
588 InterlacefixmethodItem::InterlacefixmethodItem(char *text, int value)
589 : BC_ListBoxItem(text)
594 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
595 BC_TextBox *output_text,
597 ArrayList<BC_ListBoxItem*> *data,
612 char string[BCTEXTLEN];
614 this->mwindow = mwindow;
615 this->output_text = output_text;
616 this->output_value = output_value;
617 output_text->update(interlacefixmethod_to_text());
620 int InterlacefixmethodPulldown::handle_event()
622 output_text->update(get_selection(0, 0)->get_text());
623 *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
627 char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
629 ilacefixmethod_to_text(this->string,*output_value);
630 return (this->string);
633 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
634 : BC_TextBox(x, y, w, 1, text)
636 this->fwindow = fwindow;
637 this->thedefault = thedefault;
640 int AssetEditILaceautofixoption::handle_event()
642 fwindow->asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
647 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
648 : BC_TextBox(x, y, w, 1, text)
650 this->fwindow = fwindow;
651 this->thedefault = thedefault;
654 int AssetEditILacemode::handle_event()
656 fwindow->asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
660 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
661 BC_TextBox *output_text,
663 ArrayList<BC_ListBoxItem*> *data,
664 Interlaceautofix *fixoption_chkboxw,
679 char string[BCTEXTLEN];
680 this->fixoption_chkbox = fixoption_chkboxw;
681 this->mwindow = mwindow;
682 this->output_text = output_text;
683 this->output_value = output_value;
684 output_text->update(interlacemode_to_text());
687 int AssetEditInterlacemodePulldown::handle_event()
689 output_text->update(get_selection(0, 0)->get_text());
690 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
691 fixoption_chkbox->showhideotherwidgets();
695 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
697 ilacemode_to_text(this->string,*output_value);
698 return (this->string);
701 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
702 : BC_TextBox(x, y, w, 1, text)
704 this->fwindow = fwindow;
705 this->thedefault = thedefault;
708 int AssetEditILacefixmethod::handle_event()
710 fwindow->asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
714 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
715 : BC_TextBox(x, y, 100, 1, text)
717 this->fwindow = fwindow;
720 int AssetEditHeader::handle_event()
722 fwindow->asset->header = atol(get_text());
726 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
730 : BC_Radial(x, y, value, _("Lo-Hi"))
732 this->fwindow = fwindow;
735 int AssetEditByteOrderLOHI::handle_event()
737 fwindow->asset->byte_order = 1;
738 fwindow->hilo->update(0);
743 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
747 : BC_Radial(x, y, value, _("Hi-Lo"))
749 this->fwindow = fwindow;
752 int AssetEditByteOrderHILO::handle_event()
754 fwindow->asset->byte_order = 0;
755 fwindow->lohi->update(0);
760 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
764 : BC_CheckBox(x, y, value, _("Values are signed"))
766 this->fwindow = fwindow;
769 int AssetEditSigned::handle_event()
771 fwindow->asset->signed_ = get_value();
781 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
782 : BC_TextBox(5, y, 300, 1, fwindow->asset->path)
784 this->fwindow = fwindow;
786 AssetEditPathText::~AssetEditPathText()
789 int AssetEditPathText::handle_event()
791 strcpy(fwindow->asset->path, get_text());
795 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, char *text, char *window_title, char *window_caption)
796 : BrowseButton(mwindow, fwindow, textbox, 310, y, text, window_title, window_caption, 0)
798 this->fwindow = fwindow;
800 AssetEditPath::~AssetEditPath() {}
807 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
808 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
810 this->fwindow = fwindow;
812 AssetEditFormat::~AssetEditFormat()
815 int AssetEditFormat::handle_event()
817 fwindow->asset->format = File::strtoformat(fwindow->mwindow->plugindb, get_selection(0, 0)->get_text());
824 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
825 : BC_TextBox(x, y, 300, 1, fwindow->asset->reel_name)
827 this->fwindow = fwindow;
829 AssetEditReelName::~AssetEditReelName()
832 int AssetEditReelName::handle_event()
834 strcpy(fwindow->asset->reel_name, get_text());
841 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
842 : BC_TextBox(x, y, 200, 1, fwindow->asset->reel_number)
844 this->fwindow = fwindow;
846 AssetEditReelNumber::~AssetEditReelNumber()
849 int AssetEditReelNumber::handle_event()
851 char *text = get_text() + strlen(get_text()) - 1;
853 // Don't let user enter an invalid character -- only numbers here
860 fwindow->asset->reel_number = atoi(get_text());
867 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
868 : BC_TextBox(x, y, 30, 1, value)
870 this->fwindow = fwindow;
871 this->multiplier = multiplier;
874 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
877 int AssetEditTCStartTextBox::handle_event()
879 fwindow->asset->tcstart -= previous * multiplier;
880 fwindow->asset->tcstart += atoi(get_text()) * multiplier;
881 previous = atoi(get_text());