X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Feditpopup.C;h=5fcd8152485f90d156c90d0d3a25b8790055c9d4;hb=b30123c9534e8df8da1694d40396d86396bf1c08;hp=df0be8dc2cec579bb268b44956386c24c6fb6367;hpb=564227981f9c1b021445fa0352b75c7670172912;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/editpopup.C b/cinelerra-5.1/cinelerra/editpopup.C index df0be8dc..5fcd8152 100644 --- a/cinelerra-5.1/cinelerra/editpopup.C +++ b/cinelerra-5.1/cinelerra/editpopup.C @@ -25,10 +25,10 @@ #include "awindowgui.h" #include "edit.h" #include "editpopup.h" -#include "cache.h" #include "edl.h" #include "edlsession.h" #include "file.h" +#include "keys.h" #include "language.h" #include "localsession.h" #include "mainerror.h" @@ -36,15 +36,10 @@ #include "mwindow.h" #include "mwindowgui.h" #include "plugindialog.h" -#include "preferences.h" -#include "renderengine.h" #include "resizetrackthread.h" #include "track.h" #include "tracks.h" #include "trackcanvas.h" -#include "transportque.h" -#include "vframe.h" -#include "vrender.h" #include @@ -66,14 +61,8 @@ void EditPopup::create_objects() add_item(new EditMoveTrackDown(mwindow, this)); add_item(new EditPopupDeleteTrack(mwindow, this)); add_item(new EditPopupAddTrack(mwindow, this)); -// add_item(new EditPopupTitle(mwindow, this)); - EditSnapshot *edit_snapshot; - SnapshotSubMenu *snapshot_submenu; - add_item(edit_snapshot = new EditSnapshot(mwindow, this)); - edit_snapshot->add_submenu(snapshot_submenu = new SnapshotSubMenu(edit_snapshot)); - snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("png"), SNAPSHOT_PNG)); - snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("jpeg"), SNAPSHOT_JPEG)); - snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("tiff"), SNAPSHOT_TIFF)); + add_item(new EditPopupFindAsset(mwindow, this)); + add_item(new EditPopupTitle(mwindow, this)); resize_option = 0; matchsize_option = 0; } @@ -98,13 +87,6 @@ int EditPopup::update(Track *track, Edit *edit) } - - - - - - - EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Attach effect...")) { @@ -232,6 +214,46 @@ int EditPopupAddTrack::handle_event() return 1; } +EditPopupFindAsset::EditPopupFindAsset(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Find in Resources")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +int EditPopupFindAsset::handle_event() +{ + Edit *edit = popup->edit; + if( edit ) { + Indexable *idxbl = (Indexable *)edit->asset; + if( !idxbl ) idxbl = (Indexable *)edit->nested_edl; + if( idxbl ) { + AWindowGUI *agui = mwindow->awindow->gui; + agui->lock_window("EditPopupFindAsset::handle_event"); + AssetPicon *picon = 0; + for( int i=0, n=agui->assets.size(); iassets[i]; + int found = ap->indexable && ( idxbl == ap->indexable || + !strcmp(idxbl->path, ap->indexable->path) ); + if( found && !picon ) picon = ap; + ap->set_selected(found); + } + if( picon ) { + int selected_folder = picon->indexable->awindow_folder; + mwindow->edl->session->awindow_folder = selected_folder; + for( int i=0,n=agui->folders.size(); ifolders[i]; + int selected = folder_item->foldernum == selected_folder ? 1 : 0; + folder_item->set_selected(selected); + } + } + agui->unlock_window(); + agui->async_update_assets(); + } + } + return 1; +} + EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("User title...")) @@ -243,32 +265,21 @@ EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup) EditPopupTitle::~EditPopupTitle() { - delete popup; } int EditPopupTitle::handle_event() { int result; - - Track *trc = mwindow->session->track_highlighted; - - if (trc && trc->record) - { - Edit *edt = mwindow->session->edit_highlighted; - if(!edt) return 1; - + if( popup->edit ) { window = new EditPopupTitleWindow (mwindow, popup); window->create_objects(); result = window->run_window(); - - - if(!result && edt) - { - strcpy(edt->user_title, window->title_text->get_text()); + if( !result && popup->edit ) { + strcpy(popup->edit->user_title, window->title_text->get_text()); + mwindow->gui->draw_canvas(1, 0); + mwindow->gui->flash_canvas(1); } - - delete window; - window = 0; + delete window; window = 0; } return 1; @@ -279,20 +290,12 @@ EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup) : BC_Window (_(PROGRAM_NAME ": Set edit title"), mwindow->gui->get_abs_cursor_x(0) - 400 / 2, mwindow->gui->get_abs_cursor_y(0) - 500 / 2, - 300, - 100, - 300, - 100, - 0, - 0, - 1) + 300, 130, 300, 130, 0, 0, 1) { this->mwindow = mwindow; this->popup = popup; - this->edt = this->mwindow->session->edit_highlighted; - if(this->edt) - { - strcpy(new_text, this->edt->user_title); + if( popup->edit ) { + strcpy(new_text, popup->edit->user_title); } } @@ -308,24 +311,26 @@ int EditPopupTitleWindow::close_event() void EditPopupTitleWindow::create_objects() { - int x = 5; + lock_window("EditPopupTitleWindow::create_objects"); + int x = 10; int y = 10; - - add_subwindow (new BC_Title (x, y, _("User title"))); - add_subwindow (title_text = new EditPopupTitleText (this, - mwindow, x, y + 20)); + add_subwindow (new BC_Title (x, y, _("User title:"))); + title_text = new EditPopupTitleText (this, mwindow, x+15, y+20, + popup->edit ? popup->edit->user_title : ""); + add_subwindow(title_text); add_tool(new BC_OKButton(this)); add_tool(new BC_CancelButton(this)); show_window(); flush(); + unlock_window(); } EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window, - MWindow *mwindow, int x, int y) - : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : "")) + MWindow *mwindow, int x, int y, const char *text) + : BC_TextBox(x, y, 250, 1, text) { this->window = window; this->mwindow = mwindow; @@ -337,120 +342,8 @@ EditPopupTitleText::~EditPopupTitleText() int EditPopupTitleText::handle_event() { - return 1; -} - - - -EditSnapshot::EditSnapshot(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Snapshot...")) -{ - this->mwindow = mwindow; - this->popup = popup; -} - -EditSnapshot::~EditSnapshot() -{ -} - -SnapshotSubMenu::SnapshotSubMenu(EditSnapshot *edit_snapshot) -{ - this->edit_snapshot = edit_snapshot; -} - -SnapshotSubMenu::~SnapshotSubMenu() -{ -} - -SnapshotMenuItem::SnapshotMenuItem(SnapshotSubMenu *submenu, const char *text, int mode) - : BC_MenuItem(text) -{ - this->submenu = submenu; - this->mode = mode; -} - -SnapshotMenuItem::~SnapshotMenuItem() -{ -} - -int SnapshotMenuItem::handle_event() -{ - MWindow *mwindow = submenu->edit_snapshot->mwindow; - EDL *edl = mwindow->edl; - if( !edl->have_video() ) return 1; - - Preferences *preferences = mwindow->preferences; - char filename[BCTEXTLEN]; - static const char *exts[] = { "png", "jpg", "tif" }; - time_t tt; time(&tt); - struct tm tm; localtime_r(&tt,&tm); - snprintf(filename,sizeof(filename),"%s/snap_%04d%02d%02d-%02d%02d%02d.%s", - preferences->snapshot_path, 1900+tm.tm_year,1+tm.tm_mon,tm.tm_mday, - tm.tm_hour,tm.tm_min,tm.tm_sec, exts[mode]); - int fw = edl->get_w(), fh = edl->get_h(); - int fcolor_model = edl->session->color_model; - - Asset *asset = new Asset(filename); - switch( mode ) { - case SNAPSHOT_PNG: - asset->format = FILE_PNG; - asset->png_use_alpha = 1; - break; - case SNAPSHOT_JPEG: - asset->format = FILE_JPEG; - asset->jpeg_quality = 90; - break; - case SNAPSHOT_TIFF: - asset->format = FILE_TIFF; - asset->tiff_cmodel = 0; - asset->tiff_compression = 0; - break; - } - asset->width = fw; - asset->height = fh; - asset->audio_data = 0; - asset->video_data = 1; - asset->video_length = 1; - asset->layers = 1; - - File file; - int processors = preferences->project_smp + 1; - if( processors > 8 ) processors = 8; - file.set_processors(processors); - int ret = file.open_file(preferences, asset, 0, 1); - if( !ret ) { - file.start_video_thread(1, fcolor_model, - processors > 1 ? 2 : 1, 0); - VFrame ***frames = file.get_video_buffer(); - VFrame *frame = frames[0][0]; - TransportCommand command; - //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME; - command.command = CURRENT_FRAME; - command.get_edl()->copy_all(edl); - command.change_type = CHANGE_ALL; - command.realtime = 0; - - RenderEngine render_engine(0, preferences, 0, 0); - CICache video_cache(preferences); - render_engine.set_vcache(&video_cache); - render_engine.arm_command(&command); - - double position = edl->local_session->get_selectionstart(1); - int64_t source_position = (int64_t)(position * edl->get_frame_rate()); - int ret = render_engine.vrender->process_buffer(frame, source_position, 0); - if( !ret ) - ret = file.write_video_buffer(1); - file.close_file(); - } - if( !ret ) { - asset->awindow_folder = AW_MEDIA_FOLDER; - mwindow->edl->assets->append(asset); - mwindow->awindow->gui->async_update_assets(); - } - else { - eprintf("snapshot render failed"); - asset->remove_user(); - } + if( get_keypress() == RETURN ) + window->set_done(0); return 1; }