X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fbinfolder.C;h=32fd02aa82fb41a632de925d9d488b66619cb240;hb=c279e21fc2394a7908bbd1ba8c79b116fe9fb14a;hp=68f8cb0bc9be746844a0dae6ca15d591a8e481e5;hpb=2f7295c1067fb2935ddc215831431c2959782ee3;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/binfolder.C b/cinelerra-5.1/cinelerra/binfolder.C index 68f8cb0b..32fd02aa 100644 --- a/cinelerra-5.1/cinelerra/binfolder.C +++ b/cinelerra-5.1/cinelerra/binfolder.C @@ -27,6 +27,7 @@ #include "guicast.h" #include "indexable.h" #include "language.h" +#include "localsession.h" #include "mainerror.h" #include "mainsession.h" #include "mutex.h" @@ -276,9 +277,10 @@ double BinFolder::matches_indexable(Indexable *idxbl) } -BinFolder::BinFolder(int awindow_folder, const char *title) +BinFolder::BinFolder(int awindow_folder, int is_clips, const char *title) { this->awindow_folder = awindow_folder; + this->is_clips = is_clips; char *bp = this->title; int len = sizeof(this->title); while( --len>0 && *title ) *bp++ = *title++; @@ -294,6 +296,7 @@ void BinFolder::copy_from(BinFolder *that) { strcpy(title, that->title); awindow_folder = that->awindow_folder; + is_clips = that->is_clips; filters.copy_from(&that->filters); } @@ -306,6 +309,7 @@ void BinFolder::save_xml(FileXML *file) file->tag.set_title("FOLDER"); file->tag.set_property("TITLE", title); file->tag.set_property("AWINDOW_FOLDER", awindow_folder); + file->tag.set_property("IS_CLIPS", is_clips); file->append_tag(); file->append_newline(); for( int i=0; itag.get_property("TITLE", title); awindow_folder = file->tag.get_property("AWINDOW_FOLDER", -1); + is_clips = file->tag.get_property("IS_CLIPS", 0); filters.remove_all_objects(); int ret = 0; @@ -334,39 +339,52 @@ int BinFolder::load_xml(FileXML *file) return ret; } -void BinFolder::add_patterns(ArrayList *drag_assets) +int BinFolder::add_patterns(ArrayList *drag_idxbls) { - int n = drag_assets->size(); - if( n > 0 ) { - int len = 1; - for( int i=0; iget(i)->path) + 1; - char *pats = new char[len], *bp = pats; - const char *cp = drag_assets->get(0)->path; + int n = drag_idxbls->size(); + if( !n ) return 1; + Indexable *idxbl; + int len = 0; + for( int i=0; iget(i); + if( !idxbl->is_asset && + idxbl->awindow_folder == AW_PROXY_FOLDER ) + continue; + len += strlen(idxbl->get_title()) + 1; + } + if( !len ) return 1; + char *pats = new char[len+1], *bp = pats; + for( int i=0; iget(i); + if( !idxbl->is_asset && + idxbl->awindow_folder == AW_PROXY_FOLDER ) + continue; + if( i > 0 ) *bp++ = '\n'; + const char *cp = idxbl->get_title(); while( *cp ) *bp++ = *cp++; - for( int i=1; iget(i)->path; - while( *cp ) *bp++ = *cp++; - } - *bp = 0; -// new pattern filter - BinFolderFilter *filter = new BinFolderFilter(); - filter->update_enabled(FOLDER_ENABLED_OR); - filter->update_target(FOLDER_TARGET_PATTERNS); - filter->update_op(FOLDER_OP_MATCHES); - BinFolderTargetPatterns *patterns = (BinFolderTargetPatterns *)(filter->target); - patterns->update(pats); - filters.append(filter); } + *bp = 0; +// new pattern filter + BinFolderFilter *filter = new BinFolderFilter(); + filter->update_enabled(FOLDER_ENABLED_OR); + filter->update_target(FOLDER_TARGET_PATTERNS); + filter->update_op(FOLDER_OP_MATCHES); + BinFolderTargetPatterns *patterns = (BinFolderTargetPatterns *)(filter->target); + patterns->update(pats); + filters.append(filter); + return 0; } double BinFolders::matches_indexable(int folder, Indexable *idxbl) { int k = size(); - while( --k>=0 && get(k)->awindow_folder!=folder ); - return k < 0 ? 0 : get(k)->matches_indexable(idxbl); + BinFolder *bin_folder = 0; + while( --k>=0 && (bin_folder=get(k)) && bin_folder->awindow_folder!=folder ); + if( k < 0 ) return -1; + if( bin_folder->is_clips && idxbl->is_asset ) return -1; + if( !bin_folder->is_clips && !idxbl->is_asset ) return -1; + return bin_folder->matches_indexable(idxbl); } void BinFolders::save_xml(FileXML *file) @@ -388,7 +406,7 @@ int BinFolders::load_xml(FileXML *file) while( !(ret=file->read_tag()) ) { if( file->tag.title_is("/FOLDERS") ) break; if( file->tag.title_is("FOLDER") ) { - BinFolder *folder = new BinFolder(-1, "folder"); + BinFolder *folder = new BinFolder(-1, -1, "folder"); folder->load_xml(file); append(folder); } @@ -580,8 +598,9 @@ double BinFolderOp::compare(BinFolderTarget *target, Indexable *idxbl) char pattern[BCTEXTLEN], *bp = pattern, ch; while( *cp && (ch=*cp++)!='\n' ) *bp++ = ch; *bp = 0; - if( bp > pattern && - !FileSystem::test_filter(idxbl->path, pattern) ) + if( !pattern[0] ) continue; + const char *title = idxbl->get_title(); + if( !FileSystem::test_filter(title, pattern) ) v = 1; } break; } @@ -1655,9 +1674,10 @@ void NewFolderGUI::create_objects() lock_window("NewFolderGUI::create_objects"); int x = 10, y = 10; BC_Title *title; - add_subwindow(title = new BC_Title(x, y, _("Enter the name of the folder:"))); + add_subwindow(title = new BC_Title(x, y, _("Folder name:"))); y += title->get_h() + 5; - add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, _("Untitled"))); + const char *text = !thread->is_clips ? _("media bin") : _("clip bin"); + add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, text)); add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); show_window(); @@ -1674,6 +1694,7 @@ NewFolderThread::NewFolderThread(AWindowGUI *agui) : BC_DialogThread() { this->agui = agui; + is_clips = -1; } NewFolderThread::~NewFolderThread() @@ -1681,11 +1702,12 @@ NewFolderThread::~NewFolderThread() close_window(); } -void NewFolderThread::start(int x, int y, int w, int h) +void NewFolderThread::start(int x, int y, int w, int h, int is_clips) { close_window(); - wx = x; wy = y; - ww = w; wh = h; + this->is_clips = is_clips; + this->wx = x; this->wy = y; + this->ww = w; this->wh = h; Thread::start(); } @@ -1700,12 +1722,13 @@ void NewFolderThread::handle_done_event(int result) { if( !result ) { const char *text = window->get_text(); - agui->mwindow->new_folder(text); + agui->mwindow->new_folder(text, is_clips); } } void NewFolderThread::handle_close_event(int result) { + is_clips = -1; } ModifyFolderGUI::ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h) @@ -1740,10 +1763,15 @@ void ModifyFolderGUI::create_objects() lock_window("ModifyFolderGUI::create_objects"); modify_folder_xatom = create_xatom("CWINDOWGUI_UPDATE_FILTERS"); int x = 10, y = 10; - add_tool(new BC_Title(x, y, _("Enter the name of the folder:"))); - y += 20; + BC_Title *title; + add_subwindow(title = new BC_Title(x, y, _("Enter the name of the folder:"))); + const char *text = !thread->folder->is_clips ? _("Media") : _("Clips"); + int tw = BC_Title::calculate_w(this, text, LARGEFONT); + int x0 = get_w() - 50 - tw; + add_subwindow(text_title = new BC_Title(x0, y, text, LARGEFONT, YELLOW)); + y += title->get_h() + 10; add_subwindow(text_box = new BC_TextBox(x, y, 300, 1, thread->folder->title)); - y += 30; + y += text_box->get_h() + 10; int lh = get_h() - y - BC_OKButton::calculate_h() - 30; int lw = get_w() - x - 120; add_subwindow(folder_list = @@ -1766,6 +1794,9 @@ int ModifyFolderGUI::resize_event(int w, int h) MWindow *mwindow = thread->agui->mwindow; mwindow->session->bwindow_w = w; mwindow->session->bwindow_h = h; + int tx = text_title->get_x() + w - get_w(); + int ty = text_title->get_y(); + text_title->reposition_window(tx, ty); int lx = folder_list->get_x(); int ly = folder_list->get_y(); int lh = h - ly - BC_OKButton::calculate_h() - 30; @@ -1811,8 +1842,8 @@ void ModifyFolderThread::start(BinFolder *folder, int x, int y, int w, int h) this->original = folder; agui->mwindow->edl->add_user(); this->folder = new BinFolder(*folder); - wx = x; wy = y; - ww = w; wh = h; + this->wx = x; this->wy = y; + this->ww = w; this->wh = h; Thread::start(); }