X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fassetedit.C;h=e603ad8cabba5eaa0aad4fd5060c86252a70258a;hp=c58756358486fb25dfd1721c202844281f46b797;hb=refs%2Fheads%2Fmaster;hpb=3fc547b01e919d3044bacf2a78baddeaed04e3a0 diff --git a/cinelerra-5.1/cinelerra/assetedit.C b/cinelerra-5.1/cinelerra/assetedit.C index c5875635..18dde8ff 100644 --- a/cinelerra-5.1/cinelerra/assetedit.C +++ b/cinelerra-5.1/cinelerra/assetedit.C @@ -104,6 +104,14 @@ void AssetEdit::edit_asset(Indexable *indexable, int x, int y) void AssetEdit::handle_done_event(int result) { + if( !result && changed_params->timecode >= 0 ) { + double rate = indexable->get_frame_rate(); + changed_params->timecode = + atoi(window->tc_hrs->get_text()) * 3600 + + atoi(window->tc_mins->get_text()) * 60 + + atoi(window->tc_secs->get_text()) + + atoi(window->tc_rest->get_text()) / rate; + } } void AssetEdit::handle_close_event(int result) @@ -133,7 +141,7 @@ void AssetEdit::handle_close_event(int result) // Omit index status from copy since an index rebuild may have been // happening when new_asset was created but not be happening anymore. if( asset ) { - mwindow->remove_asset_from_caches(asset); + mwindow->remove_from_caches(asset); //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate()); asset->copy_from(changed_params, 0); //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits); @@ -159,7 +167,7 @@ void AssetEdit::handle_close_event(int result) indexable->path); remove_file(index_filename); indexable->index_state->index_status = INDEX_NOTTESTED; - mwindow->mainindexes->add_next_asset(0, indexable); + mwindow->mainindexes->add_indexable(indexable); mwindow->mainindexes->start_build(); } mwindow->gui->unlock_window(); @@ -187,23 +195,27 @@ BC_Window* AssetEdit::new_gui() int AssetEdit::window_height() { - int h = 128 + 64; - if( indexable->have_audio() ) h += 200; + int h = yS(128 + 64); + if( indexable->have_audio() ) h += yS(200); if( indexable->have_video() ) { - h += 210; + h += yS(160); if( indexable->is_asset ) { Asset *asset = (Asset *)indexable; if( File::can_scale_input(asset) ) - h += 42; + h += yS(42); + if( asset->timecode >= 0 ) + h += yS(32); } } - return h; + return yS(h); } +#define AEW_W xS(450) + AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit) : BC_Window(_(PROGRAM_NAME ": Asset Info"), - asset_edit->x - 450/2, asset_edit->y - asset_edit->window_height()/2, - 450, asset_edit->window_height(), 0, 0, 1) + asset_edit->x - AEW_W/2, asset_edit->y - asset_edit->window_height()/2, + AEW_W, asset_edit->window_height(), 0, 0, 1) { this->mwindow = mwindow; this->asset_edit = asset_edit; @@ -216,6 +228,8 @@ AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit) detail_dialog = 0; win_width = 0; win_height = 0; +// *** CONTEXT_HELP *** + context_help_set_keyword("Info Asset Details"); } @@ -235,14 +249,12 @@ AssetEditWindow::~AssetEditWindow() void AssetEditWindow::create_objects() { - int y = 10, x = 10, x1 = 10, x2 = 190; + int xpad10 = xS(10); + int ypad5 = yS(5), ypad10 = yS(10), ypad20 = yS(20), ypad30 = yS(30); + int y = ypad10, x = xpad10, x1 = xpad10, x2 = xS(190); char string[BCTEXTLEN]; - int vmargin; FileSystem fs; BC_Title *title; - BC_TextBox *textboxw; - BC_ListBox *listboxw; - Interlaceautofix *ilacefixoption_chkboxw; Asset *asset = 0; EDL *nested_edl = 0; @@ -251,23 +263,16 @@ void AssetEditWindow::create_objects() else nested_edl = (EDL*)asset_edit->indexable; - if( asset && asset->format == FILE_PCM ) - allow_edits = 1; - else - allow_edits = 0; - + allow_edits = asset && asset->format == FILE_PCM ? 1 : 0; + int vmargin = yS(allow_edits ? 30 : 20); lock_window("AssetEditWindow::create_objects"); - if( allow_edits ) - vmargin = 30; - else - vmargin = 20; add_subwindow(path_text = new AssetEditPathText(this, y)); add_subwindow(path_button = new AssetEditPath(mwindow, this, path_text, y, asset_edit->indexable->path, _(PROGRAM_NAME ": Asset path"), _("Select a file for this asset:"))); - y += 30; + y += yS(30); if( asset ) { add_subwindow(new BC_Title(x, y, _("File format:"))); @@ -276,7 +281,7 @@ void AssetEditWindow::create_objects() MEDIUMFONT, mwindow->theme->assetedit_color)); x = x1; - y += 20; + y += ypad20; int64_t bytes = fs.get_size(asset->path); add_subwindow(new BC_Title(x, y, _("Bytes:"))); @@ -287,15 +292,15 @@ void AssetEditWindow::create_objects() add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) { detail_dialog = new DetailAssetDialog(mwindow); - BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y); + BC_GenericButton *detail = new DetailAssetButton(this, x2+xS(120), y); add_subwindow(detail); } - y += 20; + y += ypad20; x = x1; double length = 0.; - y += 20; + y += ypad20; x = x1; if( asset->audio_length > 0 ) @@ -313,17 +318,17 @@ void AssetEditWindow::create_objects() Units::punctuate(string); add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); - y += 30; + y += ypad30; x = x1; } if( (asset && asset->audio_data) || nested_edl ) { add_subwindow(new BC_Bar(x, y, get_w() - x * 2)); - y += 5; + y += ypad5; add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED)); - y += 30; + y += ypad30; if( asset ) { if( asset->get_compression_text(1, 0) ) { @@ -353,7 +358,7 @@ void AssetEditWindow::create_objects() } else { add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); - y += 20; + y += ypad20; } x = x1; @@ -371,7 +376,7 @@ void AssetEditWindow::create_objects() add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); } - y += 30; + y += ypad30; x = x1; if( asset ) { @@ -407,15 +412,11 @@ void AssetEditWindow::create_objects() { x = x2; - add_subwindow(lohi = new AssetEditByteOrderLOHI(this, - asset->byte_order, - x, - y)); - x += 70; add_subwindow(hilo = new AssetEditByteOrderHILO(this, - !asset->byte_order, - x, - y)); + !asset->byte_order, x, y)); + x += xS(70); + add_subwindow(lohi = new AssetEditByteOrderLOHI(this, + asset->byte_order, x, y)); y += vmargin; } else { @@ -440,17 +441,17 @@ void AssetEditWindow::create_objects() add_subwindow(new BC_Title(x, y, _("Values are signed"))); } - y += 30; + y += ypad30; } } x = x1; if( (asset && asset->video_data) || nested_edl ) { add_subwindow(new BC_Bar(x, y, get_w() - x * 2)); - y += 5; + y += ypad5; add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED)); - y += 30; + y += ypad30; x = x1; @@ -474,14 +475,14 @@ void AssetEditWindow::create_objects() if( asset ) { BC_TextBox *framerate; add_subwindow(framerate = new AssetEditFRate(this, string, x, y)); - x += 105; + x += framerate->get_w(); add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y)); } else { add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); } - y += 30; + y += ypad30; x = x1; add_subwindow(new BC_Title(x, y, _("Width:"))); x = x2; @@ -496,17 +497,17 @@ void AssetEditWindow::create_objects() sprintf(string, "%d", asset_edit->changed_params->height); win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color); add_subwindow(win_height); - y += win_height->get_h() + 5; + y += win_height->get_h() + ypad5; if( asset && File::can_scale_input(asset) ) { - y += 5; + y += ypad5; x = x1; add_subwindow(new BC_Title(x, y, _("Actual width:"))); x = x2; sprintf(string, "%d", asset->actual_width); add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color)); - BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y); + BC_GenericButton *resize = new ResizeAssetButton(this, x+xS(64), y); add_subwindow(resize); y += vmargin; @@ -516,40 +517,45 @@ void AssetEditWindow::create_objects() sprintf(string, "%d", asset->actual_height); title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color); add_subwindow(title); - y += title->get_h() + 5; + y += title->get_h() + ypad5; + } + if( asset ) { + add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:"))); + ilacemode_to_text(string, asset->interlace_mode); + AssetEditILacemode *edit_ilace_mode; + add_subwindow(edit_ilace_mode = new AssetEditILacemode(this, string, x2, y, xS(160))); + add_subwindow(new AssetEditInterlacemodePulldown(mwindow, edit_ilace_mode, + &asset_edit->changed_params->interlace_mode, + (ArrayList*)&mwindow->interlace_asset_modes, + x2 + edit_ilace_mode->get_w(), y)); + y += title->get_h() + yS(15); } - - // -------------------- - add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:"))); - add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y)); - y += ilacefixoption_chkboxw->get_h() + 5; - // -------------------- - add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:"))); - add_subwindow(textboxw = new AssetEditILacemode(this, "", ILACE_ASSET_MODEDEFAULT, x2, y, 200)); - ilacefixoption_chkboxw->ilacemode_textbox = textboxw; - add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow, - textboxw, - &asset_edit->changed_params->interlace_mode, - (ArrayList*)&mwindow->interlace_asset_modes, - ilacefixoption_chkboxw, - x2 + textboxw->get_w(), - y)); - ilacefixoption_chkboxw->ilacemode_listbox = listboxw; - y += textboxw->get_h() + 5; - - // -------------------- - add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:"))); - add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", ILACE_FIXDEFAULT, x2, y, 200)); - ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw; - add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow, - textboxw, - &asset_edit->changed_params->interlace_fixmethod, - (ArrayList*)&mwindow->interlace_asset_fixmethods, - x2 + textboxw->get_w(), - y)); - ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw; - ilacefixoption_chkboxw->showhideotherwidgets(); - y += textboxw->get_h() + 5; + } + if( asset && asset->timecode >= 0 ) { + char text[BCSTRLEN], *tc = text; + Units::totext(tc, asset->timecode, TIME_HMSF, + asset->sample_rate, asset->frame_rate); + const char *hrs = tc; tc = strchr(tc, ':'); *tc++ = 0; + const char *mins = tc; tc = strchr(tc, ':'); *tc++ = 0; + const char *secs = tc; tc = strchr(tc, ':'); *tc++ = 0; + const char *rest = tc; + int padw = BC_Title::calculate_w(this, ":", MEDIUMFONT); + int fldw = BC_Title::calculate_w(this, "00", MEDIUMFONT) + 5; + int hdrw = fldw + padw; x = x2; + add_subwindow(title = new BC_Title(x, y, _("hour"), SMALLFONT)); x += hdrw; + add_subwindow(title = new BC_Title(x, y, _("min"), SMALLFONT)); x += hdrw; + add_subwindow(title = new BC_Title(x, y, _("sec"), SMALLFONT)); x += hdrw; + add_subwindow(title = new BC_Title(x, y, _("frms"), SMALLFONT)); + y += title->get_h() + xS(3); + add_subwindow(title = new BC_Title(x1, y, _("Time Code Start:"))); + add_subwindow(tc_hrs = new BC_TextBox(x=x2, y, fldw, 1, hrs)); + add_subwindow(new BC_Title(x += tc_hrs->get_w(), y, ":")); + add_subwindow(tc_mins = new BC_TextBox(x += padw, y, fldw, 1, mins)); + add_subwindow(new BC_Title(x += tc_mins->get_w(), y, ":")); + add_subwindow(tc_secs = new BC_TextBox(x += padw, y , fldw, 1, secs)); + add_subwindow(new BC_Title(x += tc_secs->get_w(), y, ":")); + add_subwindow(tc_rest = new BC_TextBox(x += 10, y, fldw, 1, rest)); + y += title->get_h() + ypad5; } add_subwindow(new BC_OKButton(this)); @@ -570,13 +576,8 @@ AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow, char *text, int x, int y) - : BC_TumbleTextBox(fwindow, - (int)atol(text), - (int)1, - (int)MAXCHANNELS, - x, - y, - 50) + : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1, + (int)MAXCHANNELS, x, y, xS(50)) { this->fwindow = fwindow; } @@ -589,7 +590,7 @@ int AssetEditChannels::handle_event() } AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y) - : BC_TextBox(x, y, 100, 1, text) + : BC_TextBox(x, y, xS(100), 1, text) { this->fwindow = fwindow; } @@ -602,7 +603,7 @@ int AssetEditRate::handle_event() } AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y) - : BC_TextBox(x, y, 100, 1, text) + : BC_TextBox(x, y, xS(100), 1, text) { this->fwindow = fwindow; } @@ -614,130 +615,25 @@ int AssetEditFRate::handle_event() return 1; } -Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y) - : BC_CheckBox(x, y, - fwindow->asset_edit->changed_params->interlace_autofixoption, - _("Automatically Fix Interlacing")) -{ - this->fwindow = fwindow; - this->mwindow = mwindow; -} - -Interlaceautofix::~Interlaceautofix() -{ -} - -int Interlaceautofix::handle_event() -{ - Asset *asset = fwindow->asset_edit->changed_params; - asset->interlace_autofixoption = get_value(); - showhideotherwidgets(); - return 1; -} - -void Interlaceautofix::showhideotherwidgets() -{ - int thevalue = get_value(); - - Asset *asset = fwindow->asset_edit->changed_params; - if( thevalue == ILACE_AUTOFIXOPTION_AUTO ) { - this->ilacemode_textbox->enable(); - this->ilacemode_listbox->enable(); - this->ilacefixmethod_textbox->disable(); - this->ilacefixmethod_listbox->disable(); - int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode); - ilacefixmethod_to_text(string, xx); - this->ilacefixmethod_textbox->update(string); - } - if( thevalue == ILACE_AUTOFIXOPTION_MANUAL ) { - this->ilacemode_textbox->disable(); - this->ilacemode_listbox->disable(); - this->ilacefixmethod_textbox->enable(); - this->ilacefixmethod_listbox->enable(); - ilacefixmethod_to_text(string, asset->interlace_fixmethod); - this->ilacefixmethod_textbox->update(string); - } -} - -InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value) - : BC_ListBoxItem(text) -{ - this->value = value; -} - -InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow, - BC_TextBox *output_text, int *output_value, - ArrayList *data, int x, int y) - : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1) -{ - this->mwindow = mwindow; - this->output_text = output_text; - this->output_value = output_value; - output_text->update(interlacefixmethod_to_text()); -} - -int InterlacefixmethodPulldown::handle_event() -{ - output_text->update(get_selection(0, 0)->get_text()); - *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value; - return 1; -} - -const char* InterlacefixmethodPulldown::interlacefixmethod_to_text() -{ - ilacefixmethod_to_text(this->string,*output_value); - return (this->string); -} -AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w) +AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int x, int y, int w) : BC_TextBox(x, y, w, 1, text) { this->fwindow = fwindow; - this->thedefault = thedefault; -} - -int AssetEditILaceautofixoption::handle_event() -{ - Asset *asset = fwindow->asset_edit->changed_params; - asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault); - return 1; -} - - -AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w) - : BC_TextBox(x, y, w, 1, text) -{ - this->fwindow = fwindow; - this->thedefault = thedefault; } int AssetEditILacemode::handle_event() { Asset *asset = fwindow->asset_edit->changed_params; - asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault); + asset->interlace_mode = ilacemode_from_text(get_text(), ILACE_ASSET_MODEDEFAULT); return 1; } AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow, - BC_TextBox *output_text, - int *output_value, - ArrayList *data, - Interlaceautofix *fixoption_chkboxw, - int x, - int y) - : BC_ListBox(x, - y, - 200, - 150, - LISTBOX_TEXT, - data, - 0, - 0, - 1, - 0, - 1) -{ - this->fixoption_chkbox = fixoption_chkboxw; + BC_TextBox *output_text, int *output_value, + ArrayList *data, int x, int y) + : BC_ListBox(x, y, xS(160), yS(80), LISTBOX_TEXT, data, 0, 0, 1, 0, 1) +{ this->mwindow = mwindow; this->output_text = output_text; this->output_value = output_value; @@ -748,7 +644,6 @@ int AssetEditInterlacemodePulldown::handle_event() { output_text->update(get_selection(0, 0)->get_text()); *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value; - fixoption_chkbox->showhideotherwidgets(); return 1; } @@ -758,22 +653,8 @@ char* AssetEditInterlacemodePulldown::interlacemode_to_text() return (this->string); } -AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w) - : BC_TextBox(x, y, w, 1, text) -{ - this->fwindow = fwindow; - this->thedefault = thedefault; -} - -int AssetEditILacefixmethod::handle_event() -{ - Asset *asset = fwindow->asset_edit->changed_params; - asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault); - return 1; -} - AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y) - : BC_TextBox(x, y, 100, 1, text) + : BC_TextBox(x, y, xS(100), 1, text) { this->fwindow = fwindow; } @@ -844,7 +725,7 @@ int AssetEditSigned::handle_event() AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y) - : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path) + : BC_TextBox(5, y, xS(300), 1, fwindow->asset_edit->changed_params->path) { this->fwindow = fwindow; } @@ -860,7 +741,7 @@ int AssetEditPathText::handle_event() AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow, BC_TextBox *textbox, int y, const char *text, const char *window_title, const char *window_caption) - : BrowseButton(mwindow->theme, fwindow, textbox, 310, y, text, + : BrowseButton(mwindow->theme, fwindow, textbox, yS(310), y, text, window_title, window_caption, 0) { this->fwindow = fwindow; @@ -887,10 +768,13 @@ int DetailAssetButton::handle_event() return 1; } +#define DTL_W xS(600) +#define DTL_H yS(500) + DetailAssetWindow::DetailAssetWindow(MWindow *mwindow, DetailAssetDialog *detail_dialog, Asset *asset) : BC_Window(_("Asset Detail"), - detail_dialog->x - 600/2, detail_dialog->y - 500/2, 600, 500) + detail_dialog->x - DTL_W/2, detail_dialog->y - DTL_H/2, DTL_W, DTL_H) { this->mwindow = mwindow; this->detail_dialog = detail_dialog; @@ -898,6 +782,8 @@ DetailAssetWindow::DetailAssetWindow(MWindow *mwindow, asset->add_user(); info[0] = 0; text = 0; +// *** CONTEXT_HELP *** + context_help_set_keyword("Info Asset Details"); } DetailAssetWindow::~DetailAssetWindow() @@ -920,7 +806,7 @@ DetailAssetDialog::~DetailAssetDialog() void DetailAssetWindow::create_objects() { - int y = 10, x = 10; + int y = yS(10), x = xS(10); char file_name[BCTEXTLEN]; int len = sizeof(info); strncpy(info,_("no info available"),len); @@ -937,7 +823,9 @@ void DetailAssetWindow::create_objects() } } lock_window("DetailAssetWindow::create_objects"); - text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len); + int text_h = get_h()-y - BC_OKButton::calculate_h() - yS(15); + int lines = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h); + text = new BC_ScrollTextBox(this, x, y, get_w()-xS(32), lines, info, -len); text->create_objects(); text->set_text_row(0); add_subwindow(new BC_OKButton(this)); show_window();