#include "guicast.h"
#include "indexable.h"
#include "language.h"
+#include "localsession.h"
#include "mainerror.h"
#include "mainsession.h"
#include "mutex.h"
const char *BinFolderOp::types[] = {
N_("Around"),
- N_("Eq"),
- N_("Ge"),
- N_("Gt"),
- N_("Ne"),
- N_("Le"),
- N_("Lt"),
+ N_("Eq =="),
+ N_("Ge >="),
+ N_("Gt > "),
+ N_("Ne !="),
+ N_("Le <="),
+ N_("Lt < "),
N_("Matches"),
};
struct tm ttm; memset(&ttm, 0, sizeof(ttm));
ttm.tm_year = year-1900; ttm.tm_mon = mon-1; ttm.tm_mday = day;
ttm.tm_hour = hour; ttm.tm_min = min; ttm.tm_sec = secs;
- ttm.tm_wday = ttm.tm_yday = 0; ttm.tm_isdst = daylight; /* tzset in main */
time_t t = mktime(&ttm);
return (int64_t)t;
}
}
-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++;
{
strcpy(title, that->title);
awindow_folder = that->awindow_folder;
+ is_clips = that->is_clips;
filters.copy_from(&that->filters);
}
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; i<filters.size(); ++i )
title[0] = 0;
file->tag.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;
return ret;
}
-void BinFolder::add_patterns(ArrayList<Indexable*> *drag_assets)
+int BinFolder::add_patterns(ArrayList<Indexable*> *drag_idxbls)
{
- int n = drag_assets->size();
- if( n > 0 ) {
- int len = 1;
- for( int i=0; i<n; ++i )
- len += strlen(drag_assets->get(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; i<n; ++i ) {
+ idxbl = drag_idxbls->get(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; i<n; ++i ) {
+ idxbl = drag_idxbls->get(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; i<n; ++i ) {
- *bp++ = '\n';
- cp = drag_assets->get(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)
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);
}
double BinFolderOp::around(double v, double a)
{
- if( type != FOLDER_OP_AROUND || a <= 0 ) return v;
- if( (v=fabs(v)) > a ) return -1;
- return v / a;
+ if( type != FOLDER_OP_AROUND ) return v;
+ v = fabs(v);
+ return a>0 ? v/a : v;
}
// string theory: Feynman, Einstein and Schrodinger string compare
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; }
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();
: BC_DialogThread()
{
this->agui = agui;
+ is_clips = -1;
}
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();
}
{
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)
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 =
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;
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();
}
target = 0;
}
-ModifyTargetGUI::ModifyTargetGUI(ModifyTargetThread *thread)
+ModifyTargetGUI::ModifyTargetGUI(ModifyTargetThread *thread, int allow_resize)
: BC_Window(_(PROGRAM_NAME ": Modify target"),
thread->wx, thread->wy, thread->ww, thread->wh,
- -1, -1, 0, 0, 1)
+ -1, -1, allow_resize, 0, 1)
{
this->thread = thread;
}
unlock_window();
}
+int ModifyTargetGUI::resize_event(int w, int h)
+{
+ return BC_WindowBase::resize_event(w, h);
+}
+
ModifyTargetPatternsGUI::ModifyTargetPatternsGUI(ModifyTargetThread *thread)
- : ModifyTargetGUI(thread)
+ : ModifyTargetGUI(thread, 1)
{
this->thread = thread;
scroll_text_box = 0;
+ text_rowsz = 0;
}
ModifyTargetPatternsGUI::~ModifyTargetPatternsGUI()
BinFolderTargetPatterns *target = (BinFolderTargetPatterns *)thread->target;
int x = 10, y = 10;
int text_font = MEDIUMFONT;
- int text_rowsz = get_text_ascent(text_font)+1 + get_text_descent(text_font)+1;
- int th = get_h() - BC_OKButton::calculate_h() - y - 10;
+ text_rowsz = get_text_ascent(text_font)+1 + get_text_descent(text_font)+1;
+ int th = get_h() - y - BC_OKButton::calculate_h() - 20;
int rows = th / text_rowsz;
- scroll_text_box = new BC_ScrollTextBox(this, x, y, get_w()-20, rows, target->text);
+ int text_len = strlen(target->text);
+ if( text_len < BCTEXTLEN ) text_len = BCTEXTLEN;
+ scroll_text_box = new BC_ScrollTextBox(this, x, y, get_w()-20, rows,
+ target->text, 2*text_len);
scroll_text_box->create_objects();
- add_subwindow(new BC_OKButton(this));
- add_subwindow(new BC_CancelButton(this));
+ add_subwindow(ok_button = new BC_OKButton(this));
+ add_subwindow(cancel_button = new BC_CancelButton(this));
show_window();
unlock_window();
}
+int ModifyTargetPatternsGUI::resize_event(int w, int h)
+{
+ int tx = scroll_text_box->get_x();
+ int ty = scroll_text_box->get_y();
+ int th = h - ty - BC_OKButton::calculate_h() - 20;
+ int tw = w - 20;
+ int rows = th / text_rowsz;
+ scroll_text_box->reposition_window(tx, ty, tw, rows);
+ ok_button->resize_event(w, h);
+ cancel_button->resize_event(w, h);
+ return 1;
+}
+
void ModifyTargetPatternsGUI::update()
{
BinFolderTargetPatterns *target = (BinFolderTargetPatterns *)thread->target;