X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fcinelerra%2Feditpopup.C;h=f20f9b95850b317614290869e0740841e52461c0;hb=7e5a0760f40ff787cc3d93cb7768a901ebe52809;hp=2f130edecf8f4f3f08db2a5dd1de3b5f810c40c1;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/editpopup.C b/cinelerra-5.1/cinelerra/editpopup.C index 2f130ede..f20f9b95 100644 --- a/cinelerra-5.1/cinelerra/editpopup.C +++ b/cinelerra-5.1/cinelerra/editpopup.C @@ -2,26 +2,37 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ +#include "asset.h" +#include "assets.h" +#include "awindow.h" +#include "awindowgui.h" #include "edit.h" +#include "edits.h" #include "editpopup.h" +#include "edl.h" +#include "edlsession.h" +#include "file.h" +#include "keys.h" #include "language.h" +#include "localsession.h" +#include "mainerror.h" #include "mainsession.h" #include "mwindow.h" #include "mwindowgui.h" @@ -31,15 +42,10 @@ #include "tracks.h" #include "trackcanvas.h" - #include EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui) - : BC_PopupMenu(0, - 0, - 0, - "", - 0) + : BC_PopupMenu(0, 0, 0, "", 0) { this->mwindow = mwindow; this->gui = gui; @@ -56,8 +62,11 @@ 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)); + add_item(new EditPopupFindAsset(mwindow, this)); + add_item(new EditPopupTitle(mwindow, this)); + add_item(new EditPopupShow(mwindow, this)); resize_option = 0; + matchsize_option = 0; } int EditPopup::update(Track *track, Edit *edit) @@ -73,22 +82,13 @@ int EditPopup::update(Track *track, Edit *edit) else if(track->data_type == TRACK_AUDIO && resize_option) { - remove_item(resize_option); - remove_item(matchsize_option); - resize_option = 0; - matchsize_option = 0; + del_item(resize_option); resize_option = 0; + del_item(matchsize_option); matchsize_option = 0; } return 0; } - - - - - - - EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Attach effect...")) { @@ -105,10 +105,8 @@ EditAttachEffect::~EditAttachEffect() int EditAttachEffect::handle_event() { dialog_thread->start_window(popup->track, - 0, - _(PROGRAM_NAME ": Attach Effect"), - 0, - popup->track->data_type); + 0, _(PROGRAM_NAME ": Attach Effect"), + 0, popup->track->data_type); return 1; } @@ -146,8 +144,6 @@ int EditMoveTrackDown::handle_event() } - - EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Resize track...")) { @@ -167,10 +163,6 @@ int EditPopupResize::handle_event() } - - - - EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Match output size")) { @@ -188,11 +180,6 @@ int EditPopupMatchSize::handle_event() } - - - - - EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Delete track")) { @@ -206,10 +193,6 @@ int EditPopupDeleteTrack::handle_event() } - - - - EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Add track")) { @@ -233,9 +216,45 @@ 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) @@ -243,111 +262,247 @@ EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup) { this->mwindow = mwindow; this->popup = popup; - window = 0; + dialog_thread = new EditTitleDialogThread(this); } EditPopupTitle::~EditPopupTitle() { - delete popup; + delete dialog_thread; } 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; - - window = new EditPopupTitleWindow (mwindow, popup); - window->create_objects(); - result = window->run_window(); + if( popup->edit ) { + dialog_thread->close_window(); + int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2; + int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2; + dialog_thread->start(wx, wy); + } + return 1; +} +void EditTitleDialogThread::start(int wx, int wy) +{ + this->wx = wx; this->wy = wy; + BC_DialogThread::start(); +} - if(!result && edt) - { - strcpy(edt->user_title, window->title_text->get_text()); - } +EditTitleDialogThread::EditTitleDialogThread(EditPopupTitle *edit_title) +{ + this->edit_title = edit_title; + window = 0; +} +EditTitleDialogThread::~EditTitleDialogThread() +{ + close_window(); +} - delete window; - window = 0; - } +BC_Window* EditTitleDialogThread::new_gui() +{ + MWindow *mwindow = edit_title->mwindow; + EditPopup *popup = edit_title->popup; + window = new EditPopupTitleWindow(mwindow, popup, wx, wy); + window->create_objects(); + return window; +} - return 1; +void EditTitleDialogThread::handle_close_event(int result) +{ + window = 0; } +void EditTitleDialogThread::handle_done_event(int result) +{ + if( result ) return; + MWindow *mwindow = edit_title->mwindow; + EditPopup *popup = edit_title->popup; + strcpy(popup->edit->user_title, window->title_text->get_text()); + mwindow->gui->lock_window("EditTitleDialogThread::handle_done_event"); + mwindow->gui->draw_canvas(1, 0); + mwindow->gui->flash_canvas(1); + mwindow->gui->unlock_window(); +} -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) +EditPopupTitleWindow::EditPopupTitleWindow(MWindow *mwindow, + EditPopup *popup, int wx, int wy) + : BC_Window(_(PROGRAM_NAME ": Set edit title"), wx, wy, + 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); - } + strcpy(new_text, !popup->edit ? "" : popup->edit->user_title); } EditPopupTitleWindow::~EditPopupTitleWindow() { } -int EditPopupTitleWindow::close_event() -{ - set_done(1); - return 1; -} - void EditPopupTitleWindow::create_objects() { - int x = 5; - int y = 10; - - add_subwindow (new BC_Title (x, y, _("User title"))); - add_subwindow (title_text = new EditPopupTitleText (this, - mwindow, x, y + 20)); + lock_window("EditPopupTitleWindow::create_objects"); + int x = 10, y = 10; + add_subwindow(new BC_Title(x, y, _("User title:"))); + title_text = new EditPopupTitleText(this, mwindow, x+15, y+20, new_text); + 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 : "")) +EditPopupTitleText::EditPopupTitleText(EditPopupTitleWindow *window, + MWindow *mwindow, int x, int y, const char *text) + : BC_TextBox(x, y, 250, 1, text) { this->window = window; this->mwindow = mwindow; } -EditPopupTitleText::~EditPopupTitleText() -{ +EditPopupTitleText::~EditPopupTitleText() +{ } - + int EditPopupTitleText::handle_event() { + if( get_keypress() == RETURN ) + window->set_done(0); + return 1; +} + + +EditPopupShow::EditPopupShow(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Show edit")) +{ + this->mwindow = mwindow; + this->popup = popup; + dialog_thread = new EditShowDialogThread(this); +} + +EditPopupShow::~EditPopupShow() +{ + delete dialog_thread; +} + +int EditPopupShow::handle_event() +{ + if( popup->edit ) { + dialog_thread->close_window(); + int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2; + int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2; + dialog_thread->start(wx, wy); + } return 1; } +void EditShowDialogThread::start(int wx, int wy) +{ + this->wx = wx; this->wy = wy; + BC_DialogThread::start(); +} + +EditShowDialogThread::EditShowDialogThread(EditPopupShow *edit_show) +{ + this->edit_show = edit_show; + window = 0; +} +EditShowDialogThread::~EditShowDialogThread() +{ + close_window(); +} + +BC_Window* EditShowDialogThread::new_gui() +{ + MWindow *mwindow = edit_show->mwindow; + EditPopup *popup = edit_show->popup; + window = new EditPopupShowWindow(mwindow, popup, wx, wy); + window->create_objects(); + return window; +} + +void EditShowDialogThread::handle_close_event(int result) +{ + window = 0; +} + +EditPopupShowWindow::EditPopupShowWindow(MWindow *mwindow, + EditPopup *popup, int wx, int wy) + : BC_Window(_(PROGRAM_NAME ": Show edit"), wx, wy, + 300, 220, 300, 220, 0, 0, 1) +{ + this->mwindow = mwindow; + this->popup = popup; +} +EditPopupShowWindow::~EditPopupShowWindow() +{ +} + +void EditPopupShowWindow::create_objects() +{ + lock_window("EditPopupShowWindow::create_objects"); + int x = 10, y = 10; + BC_Title *title; + char text[BCTEXTLEN]; + Track *track = popup->track; + Edit *edit = popup->edit; + sprintf(text, _("Track %d:"), mwindow->edl->tracks->number_of(track)+1); + add_subwindow(title = new BC_Title(x, y, text)); + int x1 = x + title->get_w() + 10; + int tw = get_w() - x1 - 20; + truncate_text(text, track->title, tw); + add_subwindow(new BC_Title(x1, y, text)); + y += title->get_h() + 5; + sprintf(text, _("Edit %d:"), track->edits->number_of(edit)+1); + add_subwindow(title = new BC_Title(x, y, text)); + char edit_title[BCTEXTLEN]; + edit->get_title(edit_title); + truncate_text(text, edit_title, tw); + add_subwindow(new BC_Title(x1, y, text)); + y += title->get_h() + 5; + + EDLSession *session = mwindow->edl->session; + int time_format = session->time_format; + int sample_rate = session->sample_rate; + double frame_rate = session->frame_rate; + double frames_per_foot = session->frames_per_foot; + + double startsource = track->from_units(edit->startsource); + double startproject = track->from_units(edit->startproject); + double length = track->from_units(edit->length); + + char text_startsource[BCSTRLEN]; + char text_startproject[BCSTRLEN]; + char text_length[BCSTRLEN]; + sprintf(text, _("StartSource: %s\nStartProject: %s\nLength: %s\n"), + Units::totext(text_startsource, startsource, + time_format, sample_rate, frame_rate, frames_per_foot), + Units::totext(text_startproject, startproject, + time_format, sample_rate, frame_rate, frames_per_foot), + Units::totext(text_length, length, + time_format, sample_rate, frame_rate, frames_per_foot)); + show_text = new EditPopupShowText(this, mwindow, x+15, y+10, text); + add_subwindow(show_text); + add_tool(new BC_OKButton(this)); + show_window(); + flush(); + unlock_window(); +} +EditPopupShowText::EditPopupShowText(EditPopupShowWindow *window, + MWindow *mwindow, int x, int y, const char *text) + : BC_TextBox(x, y, 250, 4, text) +{ + this->window = window; + this->mwindow = mwindow; +} +EditPopupShowText::~EditPopupShowText() +{ +}