4 * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "assetedit.h"
25 #include "awindowgui.h"
26 #include "bcprogressbox.h"
27 #include "bcsignals.h"
28 #include "bitspopup.h"
31 #include "cplayback.h"
34 #include "edlsession.h"
37 #include "fileffmpeg.h"
38 #include "filesystem.h"
39 #include "indexable.h"
40 #include "indexfile.h"
41 #include "indexstate.h"
43 #include "mainindexes.h"
45 #include "mwindowgui.h"
48 #include "preferences.h"
49 #include "resizetrackthread.h"
50 #include "removefile.h"
52 #include "transportque.h"
53 #include "interlacemodes.h"
55 #include "edlsession.h"
61 AssetEdit::AssetEdit(MWindow *mwindow)
64 this->mwindow = mwindow;
67 changed_params = new Asset;
72 AssetEdit::~AssetEdit()
75 changed_params->remove_user();
79 void AssetEdit::edit_asset(Indexable *indexable)
86 this->indexable = indexable;
87 this->indexable->add_user();
89 // Copy asset parameters into temporary storage for editing.
90 if(indexable->is_asset)
92 changed_params->copy_from((Asset*)indexable, 0);
96 EDL *nested_edl = (EDL*)indexable;
98 strcpy(changed_params->path, nested_edl->path);
99 changed_params->sample_rate = nested_edl->session->sample_rate;
100 changed_params->channels = nested_edl->session->audio_channels;
102 //printf("AssetEdit::edit_asset %d %f\n", __LINE__, nested_edl->session->frame_rate);
103 changed_params->frame_rate = nested_edl->session->frame_rate;
104 changed_params->width = nested_edl->session->output_w;
105 changed_params->height = nested_edl->session->output_h;
108 BC_DialogThread::start();
111 void AssetEdit::handle_close_event(int result)
119 if(indexable->is_asset)
121 asset = (Asset*)indexable;
122 if(!changed_params->equivalent(*asset, 1, 1))
127 nested_edl = (EDL*)indexable;
128 if(strcmp(changed_params->path, nested_edl->path)
130 // changed_params->sample_rate != nested_edl->session->sample_rate ||
131 // !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate)
135 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
139 mwindow->gui->lock_window();
140 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
142 // Omit index status from copy since an index rebuild may have been
143 // happening when new_asset was created but not be happening anymore.
146 mwindow->remove_asset_from_caches(asset);
147 //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
148 asset->copy_from(changed_params, 0);
149 //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
153 strcpy(nested_edl->path, changed_params->path);
154 // Other parameters can't be changed because they're defined in the other EDL
155 // nested_edl->session->frame_rate = changed_params->frame_rate;
156 // nested_edl->session->sample_rate = changed_params->sample_rate;
158 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
160 mwindow->gui->update(0,
167 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
169 // Start index rebuilding
170 if( (asset && asset->audio_data) || nested_edl)
172 char source_filename[BCTEXTLEN];
173 char index_filename[BCTEXTLEN];
174 IndexFile::get_index_filename(source_filename,
175 mwindow->preferences->index_directory,
178 remove_file(index_filename);
179 indexable->index_state->index_status = INDEX_NOTTESTED;
180 mwindow->mainindexes->add_next_asset(0, indexable);
181 mwindow->mainindexes->start_build();
183 mwindow->gui->unlock_window();
184 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
185 mwindow->awindow->gui->async_update_assets();
187 mwindow->restart_brender();
188 mwindow->sync_parameters(CHANGE_ALL);
189 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
193 this->indexable->remove_user();
195 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
198 BC_Window* AssetEdit::new_gui()
200 window = new AssetEditWindow(mwindow, this);
201 window->create_objects();
213 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
214 : BC_Window(_(PROGRAM_NAME ": Asset Info"),
215 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
216 mwindow->gui->get_abs_cursor_y(1) - (128 + 64 +
217 (!asset_edit->indexable->have_audio() ? 0 : 180) +
218 (!asset_edit->indexable->have_video() ? 0 : 350)) / 2,
220 (!asset_edit->indexable->have_audio() ? 0 : 180) +
221 (!asset_edit->indexable->have_video() ? 0 : 350)), 0, 0, 1)
223 this->mwindow = mwindow;
224 this->asset_edit = asset_edit;
238 AssetEditWindow::~AssetEditWindow()
240 lock_window("AssetEditWindow::~AssetEditWindow");
241 if(bitspopup) delete bitspopup;
242 if(detail_thread) delete detail_thread;
249 void AssetEditWindow::create_objects()
251 int y = 10, x = 10, x1 = 10, x2 = 160;
252 char string[BCTEXTLEN];
256 BC_TextBox *textboxw;
257 BC_ListBox *listboxw;
258 Interlaceautofix *ilacefixoption_chkboxw;
262 if(asset_edit->indexable->is_asset)
263 asset = (Asset*)asset_edit->indexable;
265 nested_edl = (EDL*)asset_edit->indexable;
267 if(asset && asset->format == FILE_PCM)
272 lock_window("AssetEditWindow::create_objects");
278 add_subwindow(path_text = new AssetEditPathText(this, y));
279 add_subwindow(path_button = new AssetEditPath(mwindow,
283 asset_edit->indexable->path,
284 _(PROGRAM_NAME ": Asset path"), _("Select a file for this asset:")));
289 add_subwindow(new BC_Title(x, y, _("File format:")));
291 add_subwindow(new BC_Title(x, y, File::formattostr(mwindow->plugindb,
294 mwindow->theme->assetedit_color));
298 int64_t bytes = fs.get_size(asset->path);
299 add_subwindow(new BC_Title(x, y, _("Bytes:")));
300 sprintf(string, "%jd", bytes);
301 Units::punctuate(string);
304 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
305 if(asset->format == FILE_MPEG || asset->format == FILE_FFMPEG)
307 detail_thread = new DetailAssetThread(mwindow);
308 BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y);
309 add_subwindow(detail);
319 if(asset->audio_length > 0)
320 length = (double)asset->audio_length / asset->sample_rate;
321 if(asset->video_length > 0)
322 length = MAX(length, (double)asset->video_length / asset->frame_rate);
324 if(!EQUIV(length, 0))
325 bitrate = (int64_t)(bytes * 8 / length);
328 add_subwindow(new BC_Title(x, y, _("Bitrate (bits/sec):")));
329 sprintf(string, "%jd", bitrate);
331 Units::punctuate(string);
332 add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
338 if((asset && asset->audio_data) || nested_edl)
340 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
343 add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
349 if(asset->get_compression_text(1, 0))
351 add_subwindow(new BC_Title(x, y, _("Compression:")));
353 add_subwindow(new BC_Title(x,
355 asset->get_compression_text(1, 0),
357 mwindow->theme->assetedit_color));
363 add_subwindow(new BC_Title(x, y, _("Channels:")));
364 sprintf(string, "%d", asset_edit->changed_params->channels);
369 BC_TumbleTextBox *textbox = new AssetEditChannels(this,
373 textbox->create_objects();
378 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
383 add_subwindow(new BC_Title(x, y, _("Sample rate:")));
384 sprintf(string, "%d", asset_edit->changed_params->sample_rate);
390 add_subwindow(textbox = new AssetEditRate(this, string, x, y));
391 x += textbox->get_w();
392 add_subwindow(new SampleRatePulldown(mwindow, textbox, x, y));
396 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
404 add_subwindow(new BC_Title(x, y, _("Bits:")));
408 bitspopup = new BitsPopup(this,
411 &asset_edit->changed_params->bits,
417 bitspopup->create_objects();
420 add_subwindow(new BC_Title(x, y, File::bitstostr(asset->bits), MEDIUMFONT, mwindow->theme->assetedit_color));
425 add_subwindow(new BC_Title(x, y, _("Header length:")));
426 sprintf(string, "%d", asset->header);
430 add_subwindow(new AssetEditHeader(this, string, x, y));
432 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
437 add_subwindow(new BC_Title(x, y, _("Byte order:")));
443 add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
448 add_subwindow(hilo = new AssetEditByteOrderHILO(this,
457 if(asset->byte_order)
458 add_subwindow(new BC_Title(x, y, _("Lo-Hi"), MEDIUMFONT, mwindow->theme->assetedit_color));
460 add_subwindow(new BC_Title(x, y, _("Hi-Lo"), MEDIUMFONT, mwindow->theme->assetedit_color));
468 // add_subwindow(new BC_Title(x, y, _("Values are signed:")));
469 add_subwindow(new AssetEditSigned(this, asset->signed_, x, y));
473 if(!asset->signed_ && asset->bits == 8)
474 add_subwindow(new BC_Title(x, y, _("Values are unsigned")));
476 add_subwindow(new BC_Title(x, y, _("Values are signed")));
484 if((asset && asset->video_data) || nested_edl)
486 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
489 add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
494 if(asset && asset->get_compression_text(0,1))
496 add_subwindow(new BC_Title(x, y, _("Compression:")));
498 add_subwindow(new BC_Title(x,
500 asset->get_compression_text(0,1),
502 mwindow->theme->assetedit_color));
507 add_subwindow(new BC_Title(x, y, _("Frame rate:")));
509 sprintf(string, "%.2f", asset_edit->changed_params->frame_rate);
511 //printf("AssetEditWindow::create_objects %d %f\n", __LINE__, asset_edit->changed_params->frame_rate);
514 BC_TextBox *framerate;
515 add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
517 add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
521 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
526 add_subwindow(new BC_Title(x, y, _("Width:")));
528 sprintf(string, "%d", asset_edit->changed_params->width);
529 win_width = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
530 add_subwindow(win_width);
534 add_subwindow(new BC_Title(x, y, _("Height:")));
536 sprintf(string, "%d", asset_edit->changed_params->height);
537 win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
538 add_subwindow(win_height);
539 y += win_height->get_h() + 5;
541 if(asset && (asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) )
545 add_subwindow(new BC_Title(x, y, _("Actual width:")));
547 sprintf(string, "%d", asset->actual_width);
548 add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
550 BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y);
551 add_subwindow(resize);
555 add_subwindow(new BC_Title(x, y, _("Actual height:")));
557 sprintf(string, "%d", asset->actual_height);
558 title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
559 add_subwindow(title);
560 y += title->get_h() + 5;
563 // --------------------
564 add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
565 add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
566 y += ilacefixoption_chkboxw->get_h() + 5;
567 // --------------------
568 add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
569 add_subwindow(textboxw = new AssetEditILacemode(this, "", BC_ILACE_ASSET_MODEDEFAULT, x2, y, 200));
570 ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
571 add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
573 &asset->interlace_mode,
574 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
575 ilacefixoption_chkboxw,
576 x2 + textboxw->get_w(),
578 ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
579 y += textboxw->get_h() + 5;
581 // --------------------
582 add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
583 add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", BC_ILACE_FIXDEFAULT, x2, y, 200));
584 ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
585 add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
587 &asset->interlace_fixmethod,
588 (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
589 x2 + textboxw->get_w(),
591 ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
592 ilacefixoption_chkboxw->showhideotherwidgets();
593 y += textboxw->get_h() + 5;
596 add_subwindow(new BC_Title(x, y, _("Reel Name:")));
598 add_subwindow(new AssetEditReelName(this, x, y));
602 add_subwindow(new BC_Title(x, y, _("Reel Number:")));
604 add_subwindow(new AssetEditReelNumber(this, x, y));
608 add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
611 // Calculate values to enter into textboxes
615 asset->tcstart / asset->frame_rate,
621 char *tc_minutes = strchr(tc, ':') + 1;
622 *(tc_minutes - 1) = 0;
623 char *tc_seconds = strchr(tc_minutes, ':') + 1;
624 *(tc_seconds - 1) = 0;
625 char *tc_rest = strchr(tc_seconds, ':') + 1;
628 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_hours), x, y,
629 (int) (asset->frame_rate * 60 * 60)));
631 add_subwindow(new BC_Title(x, y, ":"));
633 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_minutes), x, y,
634 (int) (asset->frame_rate * 60)));
636 add_subwindow(new BC_Title(x, y, ":"));
638 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_seconds), x, y,
639 (int) (asset->frame_rate)));
641 add_subwindow(new BC_Title(x, y, ":"));
643 add_subwindow(new AssetEditTCStartTextBox(this, atoi(tc_rest), x, y, 1));
649 add_subwindow(new BC_OKButton(this));
650 add_subwindow(new BC_CancelButton(this));
655 void AssetEditWindow::show_info_detail()
657 detail_thread->start((Asset*)asset_edit->indexable);
661 AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
665 : BC_TumbleTextBox(fwindow,
673 this->fwindow = fwindow;
676 int AssetEditChannels::handle_event()
678 Asset *asset = fwindow->asset_edit->changed_params;
679 asset->channels = atol(get_text());
683 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
684 : BC_TextBox(x, y, 100, 1, text)
686 this->fwindow = fwindow;
689 int AssetEditRate::handle_event()
691 Asset *asset = fwindow->asset_edit->changed_params;
692 asset->sample_rate = atol(get_text());
696 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
697 : BC_TextBox(x, y, 100, 1, text)
699 this->fwindow = fwindow;
702 int AssetEditFRate::handle_event()
704 Asset *asset = fwindow->asset_edit->changed_params;
705 asset->frame_rate = atof(get_text());
709 Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
711 ((Asset *)fwindow->asset_edit->indexable)->interlace_autofixoption,
712 _("Automatically Fix Interlacing"))
714 this->fwindow = fwindow;
715 this->mwindow = mwindow;
718 Interlaceautofix::~Interlaceautofix()
722 int Interlaceautofix::handle_event()
724 Asset *asset = (Asset *)fwindow->asset_edit->indexable;
725 asset->interlace_autofixoption = get_value();
726 showhideotherwidgets();
730 void Interlaceautofix::showhideotherwidgets()
732 int thevalue = get_value();
734 Asset *asset = (Asset *)fwindow->asset_edit->indexable;
735 if (thevalue == BC_ILACE_AUTOFIXOPTION_AUTO)
737 this->ilacemode_textbox->enable();
738 this->ilacemode_listbox->enable();
739 this->ilacefixmethod_textbox->disable();
740 this->ilacefixmethod_listbox->disable();
741 int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode);
742 ilacefixmethod_to_text(string,xx);
743 this->ilacefixmethod_textbox->update(string);
745 if (thevalue == BC_ILACE_AUTOFIXOPTION_MANUAL)
747 this->ilacemode_textbox->disable();
748 this->ilacemode_listbox->disable();
749 this->ilacefixmethod_textbox->enable();
750 this->ilacefixmethod_listbox->enable();
751 ilacefixmethod_to_text(string,asset->interlace_fixmethod);
752 this->ilacefixmethod_textbox->update(string);
756 InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value)
757 : BC_ListBoxItem(text)
762 InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
763 BC_TextBox *output_text, int *output_value,
764 ArrayList<BC_ListBoxItem*> *data, int x, int y)
765 : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
767 this->mwindow = mwindow;
768 this->output_text = output_text;
769 this->output_value = output_value;
770 output_text->update(interlacefixmethod_to_text());
773 int InterlacefixmethodPulldown::handle_event()
775 output_text->update(get_selection(0, 0)->get_text());
776 *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
780 const char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
782 ilacefixmethod_to_text(this->string,*output_value);
783 return (this->string);
786 AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
787 : BC_TextBox(x, y, w, 1, text)
789 this->fwindow = fwindow;
790 this->thedefault = thedefault;
793 int AssetEditILaceautofixoption::handle_event()
795 Asset *asset = (Asset *)fwindow->asset_edit->indexable;
796 asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
801 AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
802 : BC_TextBox(x, y, w, 1, text)
804 this->fwindow = fwindow;
805 this->thedefault = thedefault;
808 int AssetEditILacemode::handle_event()
810 Asset *asset = (Asset *)fwindow->asset_edit->indexable;
811 asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
815 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
816 BC_TextBox *output_text,
818 ArrayList<BC_ListBoxItem*> *data,
819 Interlaceautofix *fixoption_chkboxw,
834 this->fixoption_chkbox = fixoption_chkboxw;
835 this->mwindow = mwindow;
836 this->output_text = output_text;
837 this->output_value = output_value;
838 output_text->update(interlacemode_to_text());
841 int AssetEditInterlacemodePulldown::handle_event()
843 output_text->update(get_selection(0, 0)->get_text());
844 *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
845 fixoption_chkbox->showhideotherwidgets();
849 char* AssetEditInterlacemodePulldown::interlacemode_to_text()
851 ilacemode_to_text(this->string,*output_value);
852 return (this->string);
855 AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
856 : BC_TextBox(x, y, w, 1, text)
858 this->fwindow = fwindow;
859 this->thedefault = thedefault;
862 int AssetEditILacefixmethod::handle_event()
864 Asset *asset = fwindow->asset_edit->changed_params;
865 asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
869 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
870 : BC_TextBox(x, y, 100, 1, text)
872 this->fwindow = fwindow;
875 int AssetEditHeader::handle_event()
877 Asset *asset = fwindow->asset_edit->changed_params;
878 asset->header = atol(get_text());
882 AssetEditByteOrderLOHI::AssetEditByteOrderLOHI(AssetEditWindow *fwindow,
886 : BC_Radial(x, y, value, _("Lo-Hi"))
888 this->fwindow = fwindow;
891 int AssetEditByteOrderLOHI::handle_event()
893 Asset *asset = fwindow->asset_edit->changed_params;
894 asset->byte_order = 1;
895 fwindow->hilo->update(0);
900 AssetEditByteOrderHILO::AssetEditByteOrderHILO(AssetEditWindow *fwindow,
904 : BC_Radial(x, y, value, _("Hi-Lo"))
906 this->fwindow = fwindow;
909 int AssetEditByteOrderHILO::handle_event()
911 Asset *asset = fwindow->asset_edit->changed_params;
912 asset->byte_order = 0;
913 fwindow->lohi->update(0);
918 AssetEditSigned::AssetEditSigned(AssetEditWindow *fwindow,
922 : BC_CheckBox(x, y, value, _("Values are signed"))
924 this->fwindow = fwindow;
927 int AssetEditSigned::handle_event()
929 Asset *asset = fwindow->asset_edit->changed_params;
930 asset->signed_ = get_value();
940 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
941 : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path)
943 this->fwindow = fwindow;
945 AssetEditPathText::~AssetEditPathText()
948 int AssetEditPathText::handle_event()
950 strcpy(fwindow->asset_edit->changed_params->path, get_text());
954 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
955 BC_TextBox *textbox, int y, const char *text,
956 const char *window_title, const char *window_caption)
957 : BrowseButton(mwindow, fwindow, textbox, 310, y, text,
958 window_title, window_caption, 0)
960 this->fwindow = fwindow;
963 AssetEditPath::~AssetEditPath() {}
970 AssetEditFormat::AssetEditFormat(AssetEditWindow *fwindow, char* default_, int y)
971 : FormatPopup(fwindow->mwindow->plugindb, 90, y)
973 this->fwindow = fwindow;
975 AssetEditFormat::~AssetEditFormat()
978 int AssetEditFormat::handle_event()
980 Asset *asset = fwindow->asset_edit->changed_params;
981 asset->format = File::strtoformat(fwindow->mwindow->plugindb,
982 get_selection(0, 0)->get_text());
989 DetailAssetButton::DetailAssetButton(AssetEditWindow *fwindow, int x, int y)
990 : BC_GenericButton(x, y, _("Detail"))
992 this->fwindow = fwindow;
996 DetailAssetButton::~DetailAssetButton()
1000 int DetailAssetButton::handle_event()
1002 fwindow->show_info_detail();
1006 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow, Asset *asset)
1007 : BC_Window(_("Asset Detail"),
1008 mwindow->gui->get_abs_cursor_x(1) - 600/2,
1009 mwindow->gui->get_abs_cursor_y(1) - 500/2,
1012 this->mwindow = mwindow;
1013 this->asset = asset;
1019 DetailAssetWindow::~DetailAssetWindow()
1021 asset->remove_user();
1025 DetailAssetThread::DetailAssetThread(MWindow *mwindow)
1028 this->mwindow = mwindow;
1032 DetailAssetThread::~DetailAssetThread()
1037 void DetailAssetThread::stop()
1039 if( Thread::running() ) {
1040 dwindow->lock_window("DetailAssetThread::stop");
1041 dwindow->set_done(1);
1042 dwindow->unlock_window();
1047 void DetailAssetWindow::create_objects()
1050 char file_name[BCTEXTLEN];
1051 int len = sizeof(info);
1052 strncpy(info,_("no info available"),len);
1053 if( !mwindow->preferences->get_asset_file_path(asset, file_name) ) {
1054 switch( asset->format ) {
1056 FileMPEG::get_info(asset->path, file_name, &info[0],len);
1059 FileFFMPEG::get_info(asset->path, &info[0],len);
1063 lock_window("DetailAssetThread::create_objects");
1064 text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len);
1065 text->create_objects(); text->set_text_row(0);
1066 add_subwindow(new BC_OKButton(this));
1071 void DetailAssetThread::start(Asset *asset)
1075 dwindow = new DetailAssetWindow(mwindow, asset);
1079 void DetailAssetThread::run()
1081 // Get length from TOC
1082 dwindow->create_objects();
1083 dwindow->run_window();
1092 AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
1093 : BC_TextBox(x, y, 300, 1,
1094 ((Asset *)fwindow->asset_edit->indexable)->reel_name,
1097 this->fwindow = fwindow;
1099 AssetEditReelName::~AssetEditReelName()
1102 int AssetEditReelName::handle_event()
1104 Asset *asset = fwindow->asset_edit->changed_params;
1105 strcpy(asset->reel_name, get_text());
1113 AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
1114 : BC_TextBox(x, y, 200, 1, ((Asset *)fwindow->asset_edit->indexable)->reel_number)
1116 this->fwindow = fwindow;
1118 AssetEditReelNumber::~AssetEditReelNumber()
1121 int AssetEditReelNumber::handle_event()
1123 Asset *asset = fwindow->asset_edit->changed_params;
1124 asset->reel_number = atoi(get_text());
1132 AssetEditTCStartTextBox::AssetEditTCStartTextBox(AssetEditWindow *fwindow, int value, int x, int y, int multiplier)
1133 : BC_TextBox(x, y, 30, 1, value)
1135 this->fwindow = fwindow;
1136 this->multiplier = multiplier;
1139 AssetEditTCStartTextBox::~AssetEditTCStartTextBox()
1142 int AssetEditTCStartTextBox::handle_event()
1144 Asset *asset = fwindow->asset_edit->changed_params;
1145 asset->tcstart -= previous * multiplier;
1146 asset->tcstart += atoi(get_text()) * multiplier;
1147 previous = atoi(get_text());