4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "assetedit.h"
25 #include "assetpopup.h"
26 #include "assetremove.h"
28 #include "audiodevice.h"
30 #include "awindowgui.h"
31 #include "bccmodels.h"
32 #include "bcsignals.h"
34 #include "binfolder.h"
39 #include "clippopup.h"
41 #include "cwindowgui.h"
46 #include "edlsession.h"
47 #include "effectlist.h"
49 #include "filesystem.h"
50 #include "folderlistmenu.h"
51 #include "indexable.h"
55 #include "labelpopup.h"
56 #include "localsession.h"
58 #include "mainsession.h"
59 #include "mwindowgui.h"
61 #include "preferences.h"
63 #include "proxypopup.h"
64 #include "renderengine.h"
69 #include "transportque.h"
73 #include "vwindowgui.h"
76 #include "data/lad_picon_png.h"
77 #include "data/ff_audio_png.h"
78 #include "data/ff_video_png.h"
85 const char *AWindowGUI::folder_names[] =
89 N_("Audio Transitions"),
90 N_("Video Transitions"),
98 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
99 : VIcon(w, h, framerate), Garbage("AssetVIcon")
102 this->length = length;
106 AssetVIcon::~AssetVIcon()
108 picon->gui->vicon_thread->del_vicon(this);
112 VFrame *AssetVIcon::frame()
114 Asset *asset = (Asset *)picon->indexable;
115 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
116 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
118 int sample_rate = asset->get_sample_rate();
119 int64_t audio_samples = asset->get_audio_samples();
120 double duration = (double)audio_samples / sample_rate;
121 picon->draw_hue_bar(temp, duration);
122 int secs = length / frame_rate + 0.5;
123 if( !secs ) secs = 1;
124 int bfrsz = VICON_SAMPLE_RATE;
125 int samples = audio_size/sizeof(vicon_audio_t);
126 double line_pos = (double)seq_no/(length-1);
127 int audio_pos = samples * line_pos * (secs-1)/secs;
128 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
129 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
130 double data[bfrsz], sample_scale = 1./mx;
131 int len = samples - audio_pos;
132 if( len > bfrsz ) len = bfrsz;
134 while( i < len ) data[i++] = *audio_data++ * sample_scale;
135 while( i < bfrsz ) data[i++] = 0;
136 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
137 int x = (w-1) * line_pos;
138 temp->pixel_rgb = RED;
139 temp->draw_line(x,0, x,h);
142 int vw = picon->gui->vicon_thread->vw;
143 int vh = picon->gui->vicon_thread->vh;
144 if( !asset->video_data ) {
146 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
151 if( seq_no >= images.size() ) {
152 MWindow *mwindow = picon->mwindow;
153 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
154 if( !file ) return 0;
155 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
156 delete temp; temp = 0;
159 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
160 int vicon_cmodel = BC_RGB8;
161 switch( mwindow->preferences->vicon_color_mode ) {
162 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
163 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
164 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
166 while( seq_no >= images.size() ) {
167 mwindow->video_cache->check_in(asset);
169 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
170 if( !file ) { usleep(1000); continue; }
172 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
173 file->set_video_position(pos,0);
174 if( file->read_frame(temp) ) temp->clear_frame();
175 add_image(temp, vw, vh, vicon_cmodel);
177 mwindow->video_cache->check_in(asset);
179 return *images[seq_no];
182 int64_t AssetVIcon::set_seq_no(int64_t no)
184 if( no >= length ) no = 0;
188 int AssetVIcon::get_vx()
190 BC_ListBox *lbox = picon->gui->asset_list;
191 return lbox->get_icon_x(picon);
193 int AssetVIcon::get_vy()
195 BC_ListBox *lbox = picon->gui->asset_list;
196 return lbox->get_icon_y(picon);
199 void AssetVIcon::load_audio()
201 MWindow *mwindow = picon->mwindow;
202 Asset *asset = (Asset *)picon->indexable;
203 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
204 int channels = asset->get_audio_channels();
205 if( channels > 2 ) channels = 2;
206 int sample_rate = asset->get_sample_rate();
207 int bfrsz = sample_rate;
208 Samples samples(bfrsz);
209 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
210 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
211 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
212 double sample_scale = (double)mx / channels;
213 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
214 while( audio_pos < audio_len ) {
215 int64_t pos = audio_pos * time_scale;
216 for( int ch=0; ch<channels; ++ch ) {
217 file->set_channel(ch);
218 file->set_audio_position(pos);
219 file->read_samples(&samples, bfrsz);
220 double *data = samples.get_data();
221 for( int64_t k=audio_pos; k<audio_len; ++k ) {
222 int i = k * time_scale - pos;
223 if( i >= bfrsz ) break;
224 int v = audio_data[k] + data[i] * sample_scale;
225 audio_data[k] = CLIP(v, -mx,mx);
228 audio_pos = (pos + bfrsz) / time_scale;
230 mwindow->audio_cache->check_in(asset);
234 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
238 audio = new AudioDevice(gui->mwindow);
242 AssetVIconAudio::~AssetVIconAudio()
247 void AssetVIconAudio::run()
250 int64_t bfrsz = VICON_SAMPLE_RATE;
251 MWindow *mwindow = gui->mwindow;
252 EDL *edl = mwindow->edl;
253 EDLSession *session = edl->session;
254 AudioOutConfig *aconfig = session->playback_config->aconfig;
255 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
256 audio->start_playback();
257 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
258 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
259 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
261 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
262 while( !interrupted ) {
263 int len = audio_len - audio_pos;
264 if( len <= 0 ) break;
265 if( len > bfrsz ) len = bfrsz;
267 for( int i=0; i<len; ++i,++k )
268 out0[i] = out1[i] = (double)audio_data[k] / mx;
270 audio->write_buffer(out, channels, len);
274 audio->set_last_buffer();
275 audio->stop_audio(interrupted ? 0 : 1);
279 void AssetVIconAudio::start(AssetVIcon *vicon)
281 if( running() ) return;
288 void AssetVIconAudio::stop(int wait)
290 if( running() && !interrupted ) {
292 audio->stop_audio(wait);
296 vicon->playing_audio = 0;
301 void AssetVIcon::start_audio()
303 if( playing_audio < 0 ) return;
304 picon->gui->vicon_audio->stop(0);
306 picon->gui->vicon_audio->start(this);
309 void AssetVIcon::stop_audio()
311 if( playing_audio > 0 )
312 picon->gui->vicon_audio->stop(0);
316 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
317 VFrame *frame, int x, int y, int w, int h)
318 : ViewPopup(vt, frame, x, y, w, h)
320 this->draw_mode = draw_mode;
321 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
324 AssetViewPopup::~AssetViewPopup()
328 int AssetViewPopup::button_press_event()
330 if( !is_event_win() ) return 0;
331 AssetVIconThread *avt = (AssetVIconThread *)vt;
332 if( !avt->vicon ) return 0;
334 int dir = 1, button = get_buttonpress();
336 case WHEEL_DOWN: dir = -1; // fall thru
337 case WHEEL_UP: return zoom_scale(dir);
344 if( draw_mode != ASSET_DRAW_MEDIA_MAP ) return 0;
345 int x = get_cursor_x(), y = get_cursor_y();
346 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
347 AssetPicon *picon = vicon->picon;
348 MWindow *mwindow = picon->mwindow;
349 EDL *edl = mwindow->edl;
353 picon->indexable ? picon->indexable :
354 picon->edl ? picon->edl : 0;
355 if( !idxbl ) return 0;
356 double sample_rate = idxbl->get_sample_rate();
357 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
358 idxbl->get_audio_samples() / sample_rate : 0;
359 double frame_rate = idxbl->get_frame_rate();
360 double video_length = frame_rate > 0 && idxbl->have_video() ?
361 idxbl->get_video_frames() / frame_rate : 0;
362 double idxbl_length = bmax(audio_length, video_length);
363 double pos = x * idxbl_length / get_w();
364 double start = 0, end = idxbl_length;
365 double lt = DBL_MAX, rt = DBL_MAX;
366 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
367 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
368 Indexable *indexable = (Indexable *)edit->asset;
369 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
370 if( !indexable ) continue;
371 if( indexable->id == idxbl->id ||
372 (!indexable->is_asset == !idxbl->is_asset &&
373 !strcmp(indexable->path, idxbl->path)) ) {
374 double start_pos = track->from_units(edit->startsource);
375 double end_pos = track->from_units(edit->startsource + edit->length);
376 double dlt = pos - start_pos, drt = end_pos - pos;
377 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
378 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
379 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
380 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
384 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
385 VWindow *vwindow = mwindow->get_viewer(1, 0);
386 vwindow->change_source(idxbl);
387 mwindow->gui->unlock_window();
388 EDL *vedl = vwindow->get_edl();
389 vedl->set_inpoint(start);
390 vedl->set_outpoint(end);
391 vedl->local_session->set_selectionstart(start);
392 vedl->local_session->set_selectionend(end);
393 vwindow->update_position(CHANGE_NONE, 0, 1, 0);
396 if( y >= get_h()-bar_h ) {
399 return cursor_motion_event();
401 picon->indexable ? picon->indexable :
402 picon->edl ? picon->edl : 0;
403 if( !idxbl ) return 0;
404 double total_length = mwindow->edl->tracks->total_length();
405 double pos = x * total_length / get_w();
406 double start = 0, end = total_length;
407 double lt = DBL_MAX, rt = DBL_MAX;
408 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
409 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
410 Indexable *indexable = (Indexable *)edit->asset;
411 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
412 if( !indexable ) continue;
413 if( indexable->id == idxbl->id ||
414 (!indexable->is_asset == !idxbl->is_asset &&
415 !strcmp(indexable->path, idxbl->path)) ) {
416 double start_pos = track->from_units(edit->startproject);
417 double end_pos = track->from_units(edit->startproject + edit->length);
418 double dlt = pos - start_pos, drt = end_pos - pos;
419 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
420 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
421 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
422 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
426 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
427 if( !shift_down() ) mwindow->select_point(!ctrl_down() ? pos : start);
428 edl->local_session->set_selectionstart(!ctrl_down() ? pos : start);
429 edl->local_session->set_selectionend(!ctrl_down() ? pos : !shift_down() ? start : end);
430 mwindow->zoom_sample(edl->local_session->zoom_sample);
431 mwindow->gui->unlock_window();
437 int AssetViewPopup::button_release_event()
439 if( !is_event_win() ) return 0;
444 int AssetViewPopup::cursor_motion_event()
446 if( !is_event_win() ) return 0;
447 AssetVIconThread *avt = (AssetVIconThread *)vt;
448 if( !avt->vicon || draw_mode != ASSET_DRAW_MEDIA_MAP ) return 0;
449 if( !get_button_down() || get_buttonpress() != 1 ||
450 ctrl_down() || alt_down() || shift_down() )
452 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
453 MWindow *mwindow = vicon->picon->mwindow;
454 EDL *edl = mwindow->edl;
456 int x = get_cursor_x();
457 double total_length = edl->tracks->total_length();
458 double pos = x * total_length / get_w();
459 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
460 mwindow->select_point(pos);
461 mwindow->zoom_sample(edl->local_session->zoom_sample);
462 mwindow->gui->unlock_window();
468 void AssetViewPopup::draw_vframe(VFrame *vframe)
470 if( draw_mode == ASSET_DRAW_IMAGE ) {
471 ViewPopup::draw_vframe(vframe);
475 draw_box(0,0,get_w(),get_h());
476 if( draw_mode != ASSET_DRAW_MEDIA_MAP )
479 int y2 = get_h()-bar_h;
480 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
481 AssetVIconThread *avt = (AssetVIconThread *)vt;
482 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
483 AssetPicon *picon = (AssetPicon *)vicon->picon;
485 picon->indexable ? picon->indexable :
486 picon->edl ? picon->edl : 0;
488 double sample_rate = idxbl->get_sample_rate();
489 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
490 idxbl->get_audio_samples() / sample_rate : 0;
491 double frame_rate = idxbl->get_frame_rate();
492 double video_length = frame_rate > 0 && idxbl->have_video() ?
493 idxbl->get_video_frames() / frame_rate : 0;
494 double idxbl_length = bmax(audio_length, video_length);
495 if( !idxbl_length ) idxbl_length = 1;
497 EDL *edl = picon->mwindow->edl;
498 double total_length = edl->tracks->total_length();
499 if( !total_length ) total_length = 1;
500 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
501 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
502 Indexable *indexable = (Indexable *)edit->asset;
503 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
504 if( !indexable ) continue;
505 if( indexable->id == idxbl->id ||
506 (!indexable->is_asset == !idxbl->is_asset &&
507 !strcmp(indexable->path, idxbl->path)) ) {
508 double pos1 = track->from_units(edit->startsource);
509 double pos2 = track->from_units(edit->startsource + edit->length);
510 double xscale = get_w() / idxbl_length;
511 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
513 draw_box(ex1,0, ex2-ex1,y1);
515 draw_line(ex1,0, ex1,y1);
516 draw_line(ex2,0, ex2,y1);
517 pos1 = track->from_units(edit->startproject);
518 pos2 = track->from_units(edit->startproject + edit->length);
519 xscale = get_w() / total_length;
520 int px1 = pos1 * xscale, px2 = pos2 * xscale;
522 draw_box(px1,y2, px2-px1,get_h()-y2);
524 draw_line(px1,y2, px1,get_h()-1);
525 draw_line(px2,y2, px2,get_h()-1);
528 draw_line(ex1,y1, px1,y2);
529 draw_line(ex2,y1, px2,y2);
536 AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list)
537 : VIconThread(asset_list,
538 asset_list->mwindow->preferences->vicon_size * 16/9,
539 asset_list->mwindow->preferences->vicon_size,
540 4*asset_list->mwindow->preferences->awindow_picon_h * 16/9,
541 4*asset_list->mwindow->preferences->awindow_picon_h)
543 draw_mode = ASSET_DRAW_IMAGE;
546 AssetVIconThread::~AssetVIconThread()
550 void AssetVIconThread::set_view_popup(AssetVIcon *vicon, int draw_mode)
553 this->draw_mode = draw_mode;
554 VIconThread::set_view_popup(vicon);
557 ViewPopup *AssetVIconThread::new_view_window(VFrame *frame)
559 BC_WindowBase *parent = wdw->get_parent();
560 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
561 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
562 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
563 int vx = viewing->get_vx(), rx = 0;
564 int vy = viewing->get_vy(), ry = 0;
565 wdw->get_root_coordinates(vx, vy, &rx, &ry);
566 rx += (rx >= cx ? -view_w : viewing->w);
567 ry += (ry >= cy ? -view_h : viewing->h);
568 AssetViewPopup *popup = new AssetViewPopup(this, draw_mode,
569 frame, rx, ry, view_w, view_h);
570 if( draw_mode == ASSET_DRAW_MEDIA_MAP )
571 vicon->playing_audio = -1;
572 wdw->set_active_subwindow(popup);
577 AWindowFolderItem::AWindowFolderItem()
583 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
584 : BC_ListBoxItem(text, color)
589 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
590 : BC_ListBoxItem(text, icon, color)
595 AssetPicon *AWindowFolderItem::get_picon()
597 AWindowFolderItem *item = this;
598 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
599 return (AssetPicon*)item;
602 int AWindowFolderSubItems::matches(const char *text)
604 int i = names.size();
605 while( --i >= 0 && strcmp(names[i], text) );
607 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
608 i = sublist ? sublist->size() : 0;
610 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
611 if( item->matches(text) ) break;
614 return i >= 0 ? 1 : 0;
618 AssetPicon::AssetPicon(MWindow *mwindow,
619 AWindowGUI *gui, Indexable *indexable)
620 : AWindowFolderItem()
623 this->mwindow = mwindow;
625 this->indexable = indexable;
626 indexable->add_user();
627 this->id = indexable->id;
630 AssetPicon::AssetPicon(MWindow *mwindow,
631 AWindowGUI *gui, EDL *edl)
632 : AWindowFolderItem()
635 this->mwindow = mwindow;
642 AssetPicon::AssetPicon(MWindow *mwindow,
643 AWindowGUI *gui, int folder, int persist)
644 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
645 folder>=0 && folder<AWINDOW_FOLDERS ?
646 gui->folder_icons[folder] : gui->folder_icon)
650 this->mwindow = mwindow;
652 persistent = persist;
655 AssetPicon::AssetPicon(MWindow *mwindow,
656 AWindowGUI *gui, int folder, const char *title)
657 : AWindowFolderItem(title, gui->folder_icon)
661 this->mwindow = mwindow;
666 AssetPicon::AssetPicon(MWindow *mwindow,
667 AWindowGUI *gui, PluginServer *plugin)
668 : AWindowFolderItem()
671 this->mwindow = mwindow;
673 this->plugin = plugin;
676 AssetPicon::AssetPicon(MWindow *mwindow,
677 AWindowGUI *gui, Label *label)
678 : AWindowFolderItem()
681 this->mwindow = mwindow;
689 AssetPicon::~AssetPicon()
691 if( vicon ) vicon->remove_user();
693 if( indexable ) indexable->remove_user();
694 if( edl ) edl->remove_user();
695 if( icon && !gui->protected_pixmap(icon) ) {
697 if( !plugin ) delete icon_vframe;
701 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
703 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
705 float h = 300 * t, s = 1., v = 1.;
706 float r, g, b; // duration, 0..1hr == hue red..magenta
707 HSV::hsv_to_rgb(r,g,b, h,s,v);
708 int ih = frame->get_h()/8, iw = frame->get_w();
709 int ir = r * 256; CLAMP(ir, 0,255);
710 int ig = g * 256; CLAMP(ig, 0,255);
711 int ib = b * 256; CLAMP(ib, 0,255);
712 unsigned char **rows = frame->get_rows();
713 for( int y=0; y<ih; ++y ) {
714 unsigned char *rp = rows[y];
715 for( int x=0; x<iw; rp+=3,++x ) {
716 rp[0] = ir; rp[1] = ig; rp[2] = ib;
721 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
722 int base_color, int line_color, int x, int y, int w, int h)
724 int h1 = h-1, h2 = h/2, iy = h2;
725 int rgb_color = frame->pixel_rgb;
726 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
727 double min = *dp, max = min;
728 x2 = (len * (ix+1))/w;
729 for( int i=x1; i<x2; ++i ) {
730 double value = *dp++;
731 if( value < min ) min = value;
732 if( value > max ) max = value;
734 int ctr = (min + max) / 2;
735 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
736 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
737 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
738 frame->pixel_rgb = line_color;
739 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
740 frame->pixel_rgb = base_color;
741 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
744 frame->pixel_rgb = rgb_color;
747 void AssetPicon::reset()
755 foldernum = AW_NO_FOLDER;
767 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
769 TransportCommand command;
770 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
771 command.get_edl()->copy_all(edl);
772 command.change_type = CHANGE_ALL;
773 command.realtime = 0;
774 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
775 render_engine->set_vcache(mwindow->video_cache);
776 render_engine->set_acache(mwindow->audio_cache);
777 render_engine->arm_command(&command);
779 void AssetPicon::close_render_engine()
781 delete render_engine; render_engine = 0;
783 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
785 if( !render_engine || !render_engine->vrender ) return;
786 render_engine->vrender->process_buffer(vfrm, pos, 0);
788 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
790 if( !render_engine || !render_engine->arender ) return;
791 render_engine->arender->process_buffer(samples, len, pos);
794 void AssetPicon::create_objects()
797 char name[BCTEXTLEN];
798 int pixmap_w, pixmap_h;
800 int picon_h = mwindow->preferences->awindow_picon_h;
801 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
804 fs.extract_name(name, indexable->path);
808 set_text(strcpy(name, edl->local_session->clip_title));
812 if( indexable && indexable->is_asset ) {
813 Asset *asset = (Asset*)indexable;
814 if( asset->video_data ) {
815 if( mwindow->preferences->use_thumbnails ) {
816 gui->unlock_window();
817 File *file = mwindow->video_cache->check_out(asset,
822 int height = asset->height > 0 ? asset->height : 1;
823 pixmap_w = pixmap_h * asset->width / height;
826 file->set_video_position(0, 0);
828 if( gui->temp_picon &&
829 (gui->temp_picon->get_w() != asset->width ||
830 gui->temp_picon->get_h() != asset->height) ) {
831 delete gui->temp_picon;
835 if( !gui->temp_picon ) {
836 gui->temp_picon = new VFrame(0, -1,
837 asset->width, asset->height,
840 { char string[BCTEXTLEN];
841 sprintf(string, _("Reading %s"), name);
842 mwindow->gui->lock_window("AssetPicon::create_objects");
843 mwindow->gui->show_message(string);
844 mwindow->gui->unlock_window(); }
845 file->read_frame(gui->temp_picon);
846 mwindow->video_cache->check_in(asset);
848 gui->lock_window("AssetPicon::create_objects 0");
849 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
850 icon->draw_vframe(gui->temp_picon,
851 0, 0, pixmap_w, pixmap_h, 0, 0);
852 icon_vframe = new VFrame(0,
853 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
854 icon_vframe->transfer_from(gui->temp_picon);
855 if( asset->folder_no == AW_MEDIA_FOLDER ) {
857 double framerate = asset->get_frame_rate();
858 if( !framerate ) framerate = VICON_RATE;
859 int64_t frames = asset->get_video_frames();
860 double secs = frames / framerate;
861 if( secs > 5 ) secs = 5;
862 int64_t length = secs * gui->vicon_thread->refresh_rate;
863 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
864 if( asset->audio_data && secs > 0 ) {
865 gui->unlock_window();
866 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
867 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
869 gui->lock_window("AssetPicon::create_objects 1");
871 gui->vicon_thread->add_vicon(vicon);
873 else if( asset->folder_no == AW_PROXY_FOLDER ) {
874 char unproxy_path[BCTEXTLEN];
875 int proxy_scale = mwindow->edl->session->proxy_scale;
876 if( !ProxyRender::from_proxy_path(unproxy_path, asset, proxy_scale) ) {
877 Asset *unproxy = mwindow->edl->assets->get_asset(unproxy_path);
879 int i = gui->assets.total;
881 AssetPicon *picon = (AssetPicon*)gui->assets[i];
882 if( picon->id == unproxy->id ) {
883 vicon = picon->vicon;
884 if( vicon ) vicon->add_user();
894 gui->lock_window("AssetPicon::create_objects 2");
895 icon = gui->video_icon;
896 icon_vframe = gui->video_vframe;
900 icon = gui->video_icon;
901 icon_vframe = gui->video_vframe;
905 if( asset->audio_data ) {
906 if( mwindow->preferences->use_thumbnails ) {
907 gui->unlock_window();
908 File *file = mwindow->audio_cache->check_out(asset,
912 pixmap_w = pixmap_h * 16/9;
913 icon_vframe = new VFrame(0,
914 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
915 icon_vframe->clear_frame();
916 { char string[BCTEXTLEN];
917 sprintf(string, _("Reading %s"), name);
918 mwindow->gui->lock_window("AssetPicon::create_objects 3");
919 mwindow->gui->show_message(string);
920 mwindow->gui->unlock_window(); }
921 int sample_rate = asset->get_sample_rate();
922 int channels = asset->get_audio_channels();
923 if( channels > 2 ) channels = 2;
924 int64_t audio_samples = asset->get_audio_samples();
925 double duration = (double)audio_samples / sample_rate;
926 draw_hue_bar(icon_vframe, duration);
927 int bfrsz = sample_rate;
928 Samples samples(bfrsz);
929 static int line_colors[2] = { GREEN, YELLOW };
930 static int base_colors[2] = { RED, PINK };
931 for( int i=channels; --i>=0; ) {
932 file->set_channel(i);
933 file->set_audio_position(0);
934 file->read_samples(&samples, bfrsz);
935 draw_wave(icon_vframe, samples.get_data(), bfrsz,
936 base_colors[i], line_colors[i]);
938 mwindow->audio_cache->check_in(asset);
939 if( asset->folder_no == AW_MEDIA_FOLDER ) {
940 double secs = duration;
941 if( secs > 5 ) secs = 5;
942 double refresh_rate = gui->vicon_thread->refresh_rate;
943 int64_t length = secs * refresh_rate;
944 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
945 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
946 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
948 gui->vicon_thread->add_vicon(vicon);
950 gui->lock_window("AssetPicon::create_objects 4");
951 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
952 icon->draw_vframe(icon_vframe,
953 0, 0, pixmap_w, pixmap_h, 0, 0);
956 gui->lock_window("AssetPicon::create_objects 5");
957 icon = gui->audio_icon;
958 icon_vframe = gui->audio_vframe;
962 icon = gui->audio_icon;
963 icon_vframe = gui->audio_vframe;
968 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
971 if( indexable && !indexable->is_asset ) {
972 icon = gui->video_icon;
973 icon_vframe = gui->video_vframe;
977 if( edl->tracks->playable_video_tracks() ) {
978 if( mwindow->preferences->use_thumbnails ) {
979 gui->unlock_window();
980 char clip_icon_path[BCTEXTLEN];
981 char *clip_icon = edl->local_session->clip_icon;
983 snprintf(clip_icon_path, sizeof(clip_icon_path),
984 "%s/%s", File::get_config_path(), clip_icon);
985 icon_vframe = VFramePng::vframe_png(clip_icon_path);
988 //printf("render clip: %s\n", name);
989 int edl_h = edl->get_h(), edl_w = edl->get_w();
990 int height = edl_h > 0 ? edl_h : 1;
991 int width = edl_w > 0 ? edl_w : 1;
992 int color_model = edl->session->color_model;
993 pixmap_w = pixmap_h * width / height;
995 if( gui->temp_picon &&
996 (gui->temp_picon->get_color_model() != color_model ||
997 gui->temp_picon->get_w() != width ||
998 gui->temp_picon->get_h() != height) ) {
999 delete gui->temp_picon; gui->temp_picon = 0;
1002 if( !gui->temp_picon ) {
1003 gui->temp_picon = new VFrame(0, -1,
1004 width, height, color_model, -1);
1006 char string[BCTEXTLEN];
1007 sprintf(string, _("Rendering %s"), name);
1008 mwindow->gui->lock_window("AssetPicon::create_objects");
1009 mwindow->gui->show_message(string);
1010 mwindow->gui->unlock_window();
1011 open_render_engine(edl, 0);
1012 render_video(0, gui->temp_picon);
1013 close_render_engine();
1014 icon_vframe = new VFrame(0,
1015 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1016 icon_vframe->transfer_from(gui->temp_picon);
1017 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1020 pixmap_w = icon_vframe->get_w();
1021 pixmap_h = icon_vframe->get_h();
1023 gui->lock_window("AssetPicon::create_objects 0");
1024 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1025 icon->draw_vframe(icon_vframe,
1026 0, 0, pixmap_w, pixmap_h, 0, 0);
1029 icon = gui->clip_icon;
1030 icon_vframe = gui->clip_vframe;
1034 if( edl->tracks->playable_audio_tracks() ) {
1035 if( mwindow->preferences->use_thumbnails ) {
1036 gui->unlock_window();
1037 char clip_icon_path[BCTEXTLEN];
1038 char *clip_icon = edl->local_session->clip_icon;
1039 if( clip_icon[0] ) {
1040 snprintf(clip_icon_path, sizeof(clip_icon_path),
1041 "%s/%s", File::get_config_path(), clip_icon);
1042 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1044 if( !icon_vframe ) {
1045 pixmap_w = pixmap_h * 16/9;
1046 icon_vframe = new VFrame(0,
1047 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1048 icon_vframe->clear_frame();
1049 char string[BCTEXTLEN];
1050 sprintf(string, _("Rendering %s"), name);
1051 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1052 mwindow->gui->show_message(string);
1053 mwindow->gui->unlock_window();
1054 int sample_rate = edl->get_sample_rate();
1055 int channels = edl->get_audio_channels();
1056 if( channels > 2 ) channels = 2;
1057 int64_t audio_samples = edl->get_audio_samples();
1058 double duration = (double)audio_samples / sample_rate;
1059 draw_hue_bar(icon_vframe, duration);
1060 Samples *samples[MAX_CHANNELS];
1061 int bfrsz = sample_rate;
1062 for( int i=0; i<MAX_CHANNELS; ++i )
1063 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1064 open_render_engine(edl, 1);
1065 render_audio(0, samples, bfrsz);
1066 close_render_engine();
1067 gui->lock_window("AssetPicon::create_objects 4");
1068 static int line_colors[2] = { GREEN, YELLOW };
1069 static int base_colors[2] = { RED, PINK };
1070 for( int i=channels; --i>=0; ) {
1071 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1072 base_colors[i], line_colors[i]);
1074 for( int i=0; i<channels; ++i ) delete samples[i];
1075 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1078 pixmap_w = icon_vframe->get_w();
1079 pixmap_h = icon_vframe->get_h();
1081 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1082 icon->draw_vframe(icon_vframe,
1083 0, 0, pixmap_w, pixmap_h, 0, 0);
1086 icon = gui->clip_icon;
1087 icon_vframe = gui->clip_vframe;
1093 strcpy(name, _(plugin->title));
1095 icon_vframe = plugin->get_picon();
1097 icon = gui->create_pixmap(icon_vframe);
1098 else if( plugin->audio ) {
1099 if( plugin->transition ) {
1100 icon = gui->atransition_icon;
1101 icon_vframe = gui->atransition_vframe;
1103 else if( plugin->is_ffmpeg() ) {
1104 icon = gui->ff_aud_icon;
1105 icon_vframe = gui->ff_aud_vframe;
1107 else if( plugin->is_ladspa() ) {
1108 icon = gui->ladspa_icon;
1109 icon_vframe = gui->ladspa_vframe;
1112 icon = gui->aeffect_icon;
1113 icon_vframe = gui->aeffect_vframe;
1116 else if( plugin->video ) {
1117 if( plugin->transition ) {
1118 icon = gui->vtransition_icon;
1119 icon_vframe = gui->vtransition_vframe;
1121 else if( plugin->is_ffmpeg() ) {
1122 icon = gui->ff_vid_icon;
1123 icon_vframe = gui->ff_vid_vframe;
1126 icon = gui->veffect_icon;
1127 icon_vframe = gui->veffect_vframe;
1135 mwindow->edl->session->time_format,
1136 mwindow->edl->session->sample_rate,
1137 mwindow->edl->session->frame_rate,
1138 mwindow->edl->session->frames_per_foot);
1140 icon = gui->label_icon;
1141 icon_vframe = gui->label_vframe;
1144 icon = gui->file_icon;
1145 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1148 set_icon_vframe(icon_vframe);
1151 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1152 : BC_Window(_(PROGRAM_NAME ": Resources"),
1153 mwindow->session->awindow_x, mwindow->session->awindow_y,
1154 mwindow->session->awindow_w, mwindow->session->awindow_h,
1157 this->mwindow = mwindow;
1158 this->awindow = awindow;
1160 file_vframe = 0; file_icon = 0;
1161 folder_vframe = 0; folder_icon = 0;
1162 audio_vframe = 0; audio_icon = 0;
1163 video_vframe = 0; video_icon = 0;
1164 label_vframe = 0; label_icon = 0;
1166 atransition_vframe = 0; atransition_icon = 0;
1167 vtransition_vframe = 0; vtransition_icon = 0;
1168 aeffect_vframe = 0; aeffect_icon = 0;
1169 ladspa_vframe = 0; ladspa_icon = 0;
1170 veffect_vframe = 0; veffect_icon = 0;
1171 ff_aud_vframe = 0; ff_aud_icon = 0;
1172 ff_vid_vframe = 0; ff_vid_icon = 0;
1174 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1175 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1176 clip_folder_vframe = 0; clip_folder_icon = 0;
1177 label_folder_vframe = 0; label_folder_icon = 0;
1178 media_folder_vframe = 0; media_folder_icon = 0;
1179 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1180 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1181 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1183 ladspa_vframe = 0; ladspa_icon = 0;
1184 ff_aud_vframe = 0; ff_aud_icon = 0;
1185 ff_vid_vframe = 0; ff_vid_icon = 0;
1187 clip_vframe = 0; clip_icon = 0;
1188 atransition_vframe = 0; atransition_icon = 0;
1189 vtransition_vframe = 0; vtransition_icon = 0;
1190 aeffect_vframe = 0; aeffect_icon = 0;
1191 veffect_vframe = 0; veffect_icon = 0;
1193 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1195 effectlist_menu = 0;
1200 folderlist_menu = 0;
1203 allow_iconlisting = 1;
1208 displayed_folder = AW_NO_FOLDER;
1209 new_folder_thread = 0;
1210 modify_folder_thread = 0;
1211 folder_lock = new Mutex("AWindowGUI::folder_lock");
1214 AWindowGUI::~AWindowGUI()
1216 assets.remove_all_objects();
1217 folders.remove_all_objects();
1218 aeffects.remove_all_objects();
1219 veffects.remove_all_objects();
1220 atransitions.remove_all_objects();
1221 vtransitions.remove_all_objects();
1222 labellist.remove_all_objects();
1223 displayed_assets[1].remove_all_objects();
1225 delete new_folder_thread;
1226 delete modify_folder_thread;
1227 delete vicon_thread;
1232 delete remove_plugin;
1234 delete file_vframe; delete file_icon;
1235 delete folder_vframe; delete folder_icon;
1236 delete audio_vframe; delete audio_icon;
1237 delete video_vframe; delete video_icon;
1238 delete label_vframe; delete label_icon;
1239 delete clip_vframe; delete clip_icon;
1240 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1241 delete atransition_folder_vframe; delete atransition_folder_icon;
1242 delete veffect_folder_vframe; delete veffect_folder_icon;
1243 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1244 delete clip_folder_vframe; delete clip_folder_icon;
1245 delete label_folder_vframe; delete label_folder_icon;
1246 delete media_folder_vframe; delete media_folder_icon;
1247 delete proxy_folder_vframe; delete proxy_folder_icon;
1248 delete ladspa_vframe; delete ladspa_icon;
1249 delete ff_aud_vframe; delete ff_aud_icon;
1250 delete ff_vid_vframe; delete ff_vid_icon;
1251 delete atransition_vframe; delete atransition_icon;
1252 delete vtransition_vframe; delete vtransition_icon;
1253 delete aeffect_vframe; delete aeffect_icon;
1254 delete veffect_vframe; delete veffect_icon;
1258 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1260 return icon == file_icon ||
1261 icon == folder_icon ||
1262 icon == audio_icon ||
1263 icon == video_icon ||
1264 icon == clip_icon ||
1265 icon == label_icon ||
1266 icon == vtransition_icon ||
1267 icon == atransition_icon ||
1268 icon == veffect_icon ||
1269 icon == aeffect_icon ||
1270 icon == ladspa_icon ||
1271 icon == ff_aud_icon ||
1272 icon == ff_vid_icon ||
1273 icon == aeffect_folder_icon ||
1274 icon == veffect_folder_icon ||
1275 icon == atransition_folder_icon ||
1276 icon == vtransition_folder_icon ||
1277 icon == label_folder_icon ||
1278 icon == clip_folder_icon ||
1279 icon == media_folder_icon ||
1280 icon == proxy_folder_icon;
1283 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1285 char png_path[BCTEXTLEN];
1286 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1287 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1288 File::get_plugin_path(), plugin_icons, name);
1289 if( access(png_path, R_OK) ) return 0;
1290 return VFramePng::vframe_png(png_path,0,0);
1293 VFrame *AWindowGUI::get_picon(const char *name)
1295 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1297 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1298 snprintf(pp, ep-pp, "%s.png", name);
1299 unsigned char *data = mwindow->theme->get_image_data(png_name);
1300 if( data ) vframe = new VFramePng(data, 0.);
1305 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1307 vfrm = get_picon(fn);
1308 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1309 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1311 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1313 vfrm = get_picon(fn);
1314 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1315 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1317 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1319 vfrm = get_picon(fn);
1320 if( !vfrm ) vfrm = new VFramePng(png);
1321 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1324 void AWindowGUI::create_objects()
1326 lock_window("AWindowGUI::create_objects");
1327 asset_titles[0] = C_("Title");
1328 asset_titles[1] = _("Comments");
1330 set_icon(mwindow->theme->get_image("awindow_icon"));
1332 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1333 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1334 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1335 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1336 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1338 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1339 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1340 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1341 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1342 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1343 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1344 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1345 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1347 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1348 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1349 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1350 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1351 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1352 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1353 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1354 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1356 theme_icon(clip_vframe, clip_icon, "clip_icon");
1357 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1358 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1359 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1360 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1362 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1363 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1364 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1365 folder_lock->lock("AWindowGUI::create_objects");
1366 // Mandatory folders
1367 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1368 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1369 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1370 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1371 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1372 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1373 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1374 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1376 create_label_folder();
1377 folder_lock->unlock();
1379 mwindow->theme->get_awindow_sizes(this);
1380 load_defaults(mwindow->defaults);
1381 new_folder_thread = new NewFolderThread(this);
1382 modify_folder_thread = new ModifyFolderThread(this);
1384 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1385 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1386 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1387 search_text->create_objects();
1388 int dy = search_text->get_h() + 10;
1390 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1392 vicon_thread = new AssetVIconThread(asset_list);
1393 asset_list->update_vicon_area();
1394 vicon_thread->start();
1395 vicon_audio = new AssetVIconAudio(this);
1397 add_subwindow(divider = new AWindowDivider(mwindow, this,
1398 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1399 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1401 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1403 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1404 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1405 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1406 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1407 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1408 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1409 add_tools->create_objects();
1410 fy += add_tools->get_h(); fh -= add_tools->get_h();
1411 add_subwindow(folder_list = new AWindowFolders(mwindow,
1412 this, fx, fy, fw, fh));
1414 folder_list->load_expanders();
1416 //int x = mwindow->theme->abuttons_x;
1417 //int y = mwindow->theme->abuttons_y;
1419 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1420 asset_menu->create_objects();
1421 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1422 clip_menu->create_objects();
1423 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1424 label_menu->create_objects();
1425 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1426 proxy_menu->create_objects();
1428 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1429 effectlist_menu->create_objects();
1430 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1431 assetlist_menu->create_objects();
1432 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1433 cliplist_menu->create_objects();
1434 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1435 labellist_menu->create_objects();
1436 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1437 proxylist_menu->create_objects();
1439 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1440 folderlist_menu->create_objects();
1442 create_custom_xatoms();
1446 int AWindowGUI::resize_event(int w, int h)
1448 mwindow->session->awindow_x = get_x();
1449 mwindow->session->awindow_y = get_y();
1450 mwindow->session->awindow_w = w;
1451 mwindow->session->awindow_h = h;
1453 mwindow->theme->get_awindow_sizes(this);
1454 mwindow->theme->draw_awindow_bg(this);
1455 reposition_objects();
1457 // int x = mwindow->theme->abuttons_x;
1458 // int y = mwindow->theme->abuttons_y;
1459 // new_bin->reposition_window(x, y);
1460 // x += new_bin->get_w();
1461 // delete_bin->reposition_window(x, y);
1462 // x += delete_bin->get_w();
1463 // rename_bin->reposition_window(x, y);
1464 // x += rename_bin->get_w();
1465 // delete_disk->reposition_window(x, y);
1466 // x += delete_disk->get_w();
1467 // delete_project->reposition_window(x, y);
1468 // x += delete_project->get_w();
1469 // info->reposition_window(x, y);
1470 // x += info->get_w();
1471 // redraw_index->reposition_window(x, y);
1472 // x += redraw_index->get_w();
1473 // paste->reposition_window(x, y);
1474 // x += paste->get_w();
1475 // append->reposition_window(x, y);
1476 // x += append->get_w();
1477 // view->reposition_window(x, y);
1479 BC_WindowBase::resize_event(w, h);
1480 asset_list->update_vicon_area();
1484 int AWindowGUI::translation_event()
1486 mwindow->session->awindow_x = get_x();
1487 mwindow->session->awindow_y = get_y();
1491 void AWindowGUI::reposition_objects()
1493 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1494 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1495 search_text->reposition_window(x1, y1+5, w1);
1496 int dy = search_text->get_h() + 10;
1498 asset_list->reposition_window(x1, y1, w1, h1);
1499 divider->reposition_window(
1500 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1501 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1502 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1503 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1504 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1505 avicon_drawing->reposition_window(fw-avicon_w, fy);
1506 fy += add_tools->get_h(); fh -= add_tools->get_h();
1507 folder_list->reposition_window(fx, fy, fw, fh);
1510 int AWindowGUI::save_defaults(BC_Hash *defaults)
1512 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1513 defaults->update("VICON_DRAWING", vicon_drawing);
1517 int AWindowGUI::load_defaults(BC_Hash *defaults)
1519 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1520 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1524 int AWindowGUI::close_event()
1527 mwindow->session->show_awindow = 0;
1530 mwindow->gui->lock_window("AWindowGUI::close_event");
1531 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1532 mwindow->gui->unlock_window();
1534 lock_window("AWindowGUI::close_event");
1535 save_defaults(mwindow->defaults);
1536 mwindow->save_defaults();
1540 void AWindowGUI::start_vicon_drawing()
1542 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1543 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1544 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1545 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1546 switch( mwindow->edl->session->assetlist_format ) {
1548 case ASSETS_ICONS_PACKED:
1549 case ASSETS_ICON_LIST:
1550 asset_list->update_vicon_area();
1551 vicon_thread->start_drawing();
1559 void AWindowGUI::stop_vicon_drawing()
1561 if( vicon_thread->interrupted ) return;
1562 vicon_thread->stop_drawing();
1565 VFrame *AssetPicon::get_vicon_frame()
1567 if( !vicon ) return 0;
1568 if( gui->vicon_thread->interrupted ) return 0;
1569 VFrame *frame = vicon->frame();
1570 if( !frame ) return 0;
1572 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1573 vicon_frame->transfer_from(frame);
1577 int AWindowGUI::cycle_assetlist_format()
1579 EDLSession *session = mwindow->edl->session;
1580 int format = ASSETS_TEXT;
1581 if( allow_iconlisting ) {
1582 switch( session->assetlist_format ) {
1584 format = ASSETS_ICONS;
1587 format = ASSETS_ICONS_PACKED;
1589 case ASSETS_ICONS_PACKED:
1590 format = ASSETS_ICON_LIST;
1592 case ASSETS_ICON_LIST:
1593 format = ASSETS_TEXT;
1597 stop_vicon_drawing();
1598 session->assetlist_format = format;
1599 asset_list->update_format(session->assetlist_format, 0);
1600 async_update_assets();
1601 start_vicon_drawing();
1605 AWindowRemovePluginGUI::
1606 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1607 int x, int y, PluginServer *plugin)
1608 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1610 this->awindow = awindow;
1611 this->thread = thread;
1612 this->plugin = plugin;
1613 VFrame *vframe = plugin->get_picon();
1614 icon = vframe ? create_pixmap(vframe) : 0;
1615 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1618 AWindowRemovePluginGUI::
1619 ~AWindowRemovePluginGUI()
1621 if( !awindow->gui->protected_pixmap(icon) )
1623 plugin_list.remove_all();
1626 void AWindowRemovePluginGUI::create_objects()
1628 lock_window("AWindowRemovePluginGUI::create_objects");
1629 BC_Button *ok_button = new BC_OKButton(this);
1630 add_subwindow(ok_button);
1631 BC_Button *cancel_button = new BC_CancelButton(this);
1632 add_subwindow(cancel_button);
1634 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1635 add_subwindow(title);
1636 y += title->get_h() + 5;
1637 list = new BC_ListBox(x, y,
1638 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1639 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1640 add_subwindow(list);
1645 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1648 for( int i=0; i<folder.size(); ) {
1649 AssetPicon *picon = (AssetPicon *)folder[i];
1650 if( picon->plugin == plugin ) {
1651 folder.remove_object_number(i);
1660 void AWindowRemovePlugin::handle_close_event(int result)
1663 printf(_("remove %s\n"), plugin->path);
1664 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1665 ArrayList<BC_ListBoxItem*> *folder =
1666 plugin->audio ? plugin->transition ?
1667 &awindow->gui->atransitions :
1668 &awindow->gui->aeffects :
1669 plugin->video ? plugin->transition ?
1670 &awindow->gui->vtransitions :
1671 &awindow->gui->veffects :
1673 if( folder ) remove_plugin(plugin, *folder);
1674 MWindow *mwindow = awindow->mwindow;
1675 awindow->gui->unlock_window();
1676 char plugin_path[BCTEXTLEN];
1677 strcpy(plugin_path, plugin->path);
1678 mwindow->plugindb->remove(plugin);
1679 remove(plugin_path);
1680 char index_path[BCTEXTLEN];
1681 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1683 char picon_path[BCTEXTLEN];
1685 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1686 File::get_plugin_path());
1687 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1688 plugin->get_plugin_png_name(png_name);
1689 fs.update(picon_path);
1690 for( int i=0; i<fs.dir_list.total; ++i ) {
1691 char *fs_path = fs.dir_list[i]->path;
1692 if( !fs.is_dir(fs_path) ) continue;
1693 snprintf(png_path, sizeof(picon_path), "%s/%s",
1697 delete plugin; plugin = 0;
1698 awindow->gui->async_update_assets();
1702 AWindowRemovePlugin::
1703 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1706 this->awindow = awindow;
1707 this->plugin = plugin;
1710 AWindowRemovePlugin::
1711 ~AWindowRemovePlugin()
1716 BC_Window* AWindowRemovePlugin::new_gui()
1718 int x = awindow->gui->get_abs_cursor_x(0);
1719 int y = awindow->gui->get_abs_cursor_y(0);
1720 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1721 gui->create_objects();
1725 int AWindowGUI::keypress_event()
1727 switch( get_keypress() ) {
1735 if( !ctrl_down() && !shift_down() ) {
1736 assetlist_menu->load_file->handle_event();
1741 return cycle_assetlist_format();
1743 if( shift_down() && ctrl_down() ) {
1744 PluginServer* plugin = selected_plugin();
1745 if( !plugin ) break;
1746 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1748 remove_plugin->start();
1749 lock_window("AWindowGUI::keypress_event 1");
1753 if( shift_down() ) {
1754 mwindow->awindow->asset_remove->start();
1758 mwindow->remove_assets_from_project(1, 1,
1759 mwindow->session->drag_assets,
1760 mwindow->session->drag_clips);
1761 lock_window("AWindowGUI::keypress_event 2");
1767 if( shift_down() && ctrl_down() ) {
1768 resend_event(mwindow->gui);
1778 int AWindowGUI::create_custom_xatoms()
1780 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1783 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1785 if( event->message_type == UpdateAssetsXAtom ) {
1792 void AWindowGUI::async_update_assets()
1795 event.message_type = UpdateAssetsXAtom;
1796 send_custom_xatom(&event);
1800 void AWindowGUI::update_folder_list()
1802 for( int i = 0; i < folders.total; i++ ) {
1803 AssetPicon *picon = (AssetPicon*)folders.values[i];
1807 // Search assets for folders
1808 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1809 BinFolder *bin_folder = mwindow->edl->folders[i];
1812 for( int j = 0; j < folders.total; j++ ) {
1813 AssetPicon *picon = (AssetPicon*)folders[j];
1814 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1822 const char *title = bin_folder->title;
1823 int folder = bin_folder->awindow_folder;
1824 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1825 picon->create_objects();
1826 folders.append(picon);
1830 // Delete unused non-persistent folders
1831 int do_autoplace = 0;
1832 for( int i=folders.total; --i>=0; ) {
1833 AssetPicon *picon = (AssetPicon*)folders.values[i];
1834 if( !picon->in_use && !picon->persistent ) {
1836 folders.remove_number(i);
1841 folder_list->set_autoplacement(&folders, 0, 1);
1844 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1845 int do_audio, int do_video, int is_realtime, int is_transition)
1847 ArrayList<PluginServer*> plugin_list;
1848 // Get pointers to plugindb entries
1849 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1852 for( int i = 0; i < plugin_list.total; i++ ) {
1853 PluginServer *server = plugin_list.values[i];
1854 int visible = plugin_visibility & (1<<server->dir_idx);
1855 if( !visible ) continue;
1856 // Create new listitem
1857 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1858 picon->create_objects();
1859 output->append(picon);
1863 void AWindowGUI::create_label_folder()
1866 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1867 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1868 picon->create_objects();
1869 labellist.append(picon);
1874 void AWindowGUI::update_asset_list()
1876 ArrayList<AssetPicon *> new_assets;
1877 for( int i = 0; i < assets.total; i++ ) {
1878 AssetPicon *picon = (AssetPicon*)assets.values[i];
1882 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1883 // Synchronize EDL clips
1884 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1887 // Look for clip in existing listitems
1888 for( int j = 0; j < assets.total && !exists; j++ ) {
1889 AssetPicon *picon = (AssetPicon*)assets.values[j];
1891 if( picon->id == mwindow->edl->clips[i]->id ) {
1892 picon->edl = mwindow->edl->clips[i];
1893 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1899 // Create new listitem
1901 AssetPicon *picon = new AssetPicon(mwindow,
1902 this, mwindow->edl->clips[i]);
1903 new_assets.append(picon);
1907 // Synchronize EDL assets
1908 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1911 // Look for asset in existing listitems
1912 for( int j = 0; j < assets.total && !exists; j++ ) {
1913 AssetPicon *picon = (AssetPicon*)assets.values[j];
1915 if( picon->id == current->id ) {
1916 picon->indexable = current;
1922 // Create new listitem
1924 AssetPicon *picon = new AssetPicon(mwindow,
1926 new_assets.append(picon);
1930 // Synchronize nested EDLs
1931 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1933 EDL *nested_edl = mwindow->edl->nested_edls[i];
1935 // Look for asset in existing listitems
1936 for( int j=0; j<assets.total && !exists; ++j ) {
1937 AssetPicon *picon = (AssetPicon*)assets.values[j];
1939 if( picon->id == nested_edl->id ) {
1940 picon->indexable = nested_edl;
1946 // Create new listitem
1948 AssetPicon *picon = new AssetPicon(mwindow,
1949 this, (Indexable*)nested_edl);
1950 new_assets.append(picon);
1953 mwindow->gui->unlock_window();
1955 for( int i=0; i<new_assets.size(); ++i ) {
1956 AssetPicon *picon = new_assets[i];
1957 picon->create_objects();
1958 if( picon->indexable )
1959 picon->foldernum = AW_MEDIA_FOLDER;
1960 else if( picon->edl )
1961 picon->foldernum = AW_CLIP_FOLDER;
1962 assets.append(picon);
1965 mwindow->gui->lock_window();
1966 mwindow->gui->default_message();
1967 mwindow->gui->unlock_window();
1969 for( int i = assets.size() - 1; i >= 0; i-- ) {
1970 AssetPicon *picon = (AssetPicon*)assets.get(i);
1971 if( !picon->in_use ) {
1973 assets.remove_number(i);
1976 if( picon->indexable && picon->indexable->is_asset ) {
1978 picon->comments_time = !stat(picon->indexable->path, &st) ?
1984 void AWindowGUI::update_picon(Indexable *indexable)
1987 for( int i = 0; i < assets.total; i++ ) {
1988 AssetPicon *picon = (AssetPicon*)assets.values[i];
1989 if( picon->indexable == indexable ||
1990 picon->edl == (EDL *)indexable ) {
1991 char name[BCTEXTLEN];
1993 fs.extract_name(name, indexable->path);
1994 picon->set_text(name);
1995 vicon = picon->vicon;
2000 stop_vicon_drawing();
2001 vicon->clear_images();
2002 vicon->reset(indexable->get_frame_rate());
2003 start_vicon_drawing();
2007 void AWindowGUI::sort_assets()
2009 folder_lock->lock("AWindowGUI::sort_assets");
2010 switch( mwindow->edl->session->awindow_folder ) {
2011 case AW_AEFFECT_FOLDER:
2012 sort_picons(&aeffects);
2014 case AW_VEFFECT_FOLDER:
2015 sort_picons(&veffects);
2017 case AW_ATRANSITION_FOLDER:
2018 sort_picons(&atransitions);
2020 case AW_VTRANSITION_FOLDER:
2021 sort_picons(&vtransitions);
2023 case AW_LABEL_FOLDER:
2024 sort_picons(&labellist);
2027 sort_picons(&assets);
2031 asset_list->update_format(asset_list->get_format(), 0);
2032 folder_lock->unlock();
2036 void AWindowGUI::sort_folders()
2038 folder_lock->lock("AWindowGUI::update_assets");
2039 // folder_list->collapse_recursive(&folders, 0);
2040 folder_list->set_autoplacement(&folders, 0, 1);
2041 sort_picons(&folders);
2042 folder_list->update_format(folder_list->get_format(), 0);
2043 folder_lock->unlock();
2047 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2049 Asset *proxy_asset = (Asset *)indexable;
2050 char path[BCTEXTLEN];
2051 int proxy_scale = mwindow->edl->session->proxy_scale;
2052 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2053 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2054 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2055 // make a clip from proxy video tracks and unproxy audio tracks
2056 EDL *proxy_edl = new EDL(mwindow->edl);
2057 proxy_edl->create_objects();
2058 proxy_edl->set_path(proxy_asset->path);
2059 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2060 strcpy(proxy_edl->local_session->clip_title, path);
2061 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2062 proxy_edl->session->video_tracks = proxy_asset->layers;
2063 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2064 proxy_edl->create_default_tracks();
2065 double length = proxy_asset->frame_rate > 0 ?
2066 ( proxy_asset->video_length >= 0 ?
2067 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2068 ( proxy_edl->session->si_useduration ?
2069 proxy_edl->session->si_duration :
2070 1.0 / proxy_asset->frame_rate ) ) :
2071 1.0 / proxy_edl->session->frame_rate;
2072 Track *current = proxy_edl->tracks->first;
2073 for( int vtrack=0; current; current=NEXT ) {
2074 if( current->data_type != TRACK_VIDEO ) continue;
2075 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2077 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2078 current = proxy_edl->tracks->first;
2079 for( int atrack=0; current; current=NEXT ) {
2080 if( current->data_type != TRACK_AUDIO ) continue;
2081 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2083 proxy_edl->folder_no = AW_PROXY_FOLDER;
2088 void AWindowGUI::collect_assets(int proxy)
2090 mwindow->session->drag_assets->remove_all();
2091 mwindow->session->drag_clips->remove_all();
2092 int i = 0; AssetPicon *result;
2093 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2094 Indexable *indexable = result->indexable;
2095 if( proxy && indexable && indexable->is_asset &&
2096 indexable->folder_no == AW_PROXY_FOLDER ) {
2097 EDL *drag_edl = collect_proxy(indexable);
2098 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2102 mwindow->session->drag_assets->append(indexable);
2106 mwindow->session->drag_clips->append(result->edl);
2112 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2114 // Remove current pointers
2115 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2116 dst[0].remove_all();
2117 dst[1].remove_all_objects();
2119 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2120 int folder = mwindow->edl->session->awindow_folder;
2121 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2122 mwindow->edl->get_folder(folder);
2124 // Create new pointers
2125 for( int i = 0; i < src->total; i++ ) {
2126 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2127 picon = (AssetPicon*)src->values[i];
2128 picon->sort_key = -1;
2129 if( !visible && bin_folder ) {
2130 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2131 picon->indexable ? picon->indexable :
2132 picon->edl ? picon->edl->get_proxy_asset() : 0;
2134 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2135 if( picon->sort_key < 0 ) continue;
2139 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2141 if( !visible && picon->edl && picon->edl->folder_no == folder )
2143 if( visible && sub_items ) {
2144 if( !sub_items->matches(picon->get_text()) )
2148 const char *text = search_text->get_text();
2149 if( text && text[0] )
2150 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2152 if( visible && picon->vicon && picon->vicon->hidden )
2153 picon->vicon->hidden = 0;
2155 BC_ListBoxItem *item2, *item1;
2156 dst[0].append(item1 = picon);
2158 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2161 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2162 else if( picon->comments_time ) {
2163 char date_time[BCSTRLEN];
2164 struct tm stm; localtime_r(&picon->comments_time, &stm);
2165 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2166 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2167 stm.tm_hour, stm.tm_min, stm.tm_sec);
2168 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2171 dst[1].append(item2 = new BC_ListBoxItem(""));
2172 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2173 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2178 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2180 int done = 0, changed = 0;
2183 for( int i=0; i<src->total-1; ++i ) {
2184 AssetPicon *item1 = (AssetPicon *)src->values[i];
2185 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2186 double v = item2->sort_key - item1->sort_key;
2187 if( v > 0 ) continue;
2189 const char *cp1 = item1->get_text();
2190 const char *bp1 = strrchr(cp1, '/');
2191 if( bp1 ) cp1 = bp1 + 1;
2192 const char *cp2 = item2->get_text();
2193 const char *bp2 = strrchr(cp2, '/');
2194 if( bp2 ) cp2 = bp2 + 1;
2195 if( strcmp(cp2, cp1) >= 0 ) continue;
2197 src->values[i + 1] = item1;
2198 src->values[i] = item2;
2199 done = 0; changed = 1;
2203 for( int i=0; i<src->total; ++i ) {
2204 AssetPicon *item = (AssetPicon *)src->values[i];
2205 item->set_autoplace_icon(1);
2206 item->set_autoplace_text(1);
2211 void AWindowGUI::filter_displayed_assets()
2213 //allow_iconlisting = 1;
2214 asset_titles[0] = C_("Title");
2215 asset_titles[1] = _("Comments");
2216 AssetPicon *picon = 0;
2217 int selected_folder = mwindow->edl->session->awindow_folder;
2218 // Ensure the current folder icon is highlighted
2219 for( int i = 0; i < folders.total; i++ ) {
2220 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2221 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2222 folder_item->set_selected(selected);
2223 if( selected ) picon = folder_item;
2226 ArrayList<BC_ListBoxItem*> *src = &assets;
2227 switch( selected_folder ) {
2228 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2229 case AW_VEFFECT_FOLDER: src = &veffects; break;
2230 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2231 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2232 case AW_LABEL_FOLDER: src = &labellist;
2233 asset_titles[0] = _("Time Stamps");
2234 asset_titles[1] = C_("Title");
2235 //allow_iconlisting = 0;
2238 copy_picons(picon, src);
2242 void AWindowGUI::update_assets()
2244 stop_vicon_drawing();
2245 folder_lock->lock("AWindowGUI::update_assets");
2246 update_folder_list();
2247 update_asset_list();
2248 labellist.remove_all_objects();
2249 create_label_folder();
2251 if( displayed_folder != mwindow->edl->session->awindow_folder )
2252 search_text->clear();
2253 vicon_thread->hide_vicons();
2254 filter_displayed_assets();
2255 folder_lock->unlock();
2257 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2258 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2260 int folder_xposition = folder_list->get_xposition();
2261 int folder_yposition = folder_list->get_yposition();
2262 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2264 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2265 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2267 int asset_xposition = asset_list->get_xposition();
2268 int asset_yposition = asset_list->get_yposition();
2269 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2270 displayed_folder = mwindow->edl->session->awindow_folder;
2271 asset_xposition = asset_yposition = 0;
2273 asset_list->update(displayed_assets, asset_titles,
2274 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2275 asset_xposition, asset_yposition, -1, 0);
2276 asset_list->center_selection();
2279 start_vicon_drawing();
2283 void AWindowGUI::update_effects()
2285 aeffects.remove_all_objects();
2286 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2287 veffects.remove_all_objects();
2288 create_persistent_folder(&veffects, 0, 1, 1, 0);
2289 atransitions.remove_all_objects();
2290 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2291 vtransitions.remove_all_objects();
2292 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2295 int AWindowGUI::drag_motion()
2297 if( get_hidden() ) return 0;
2303 int AWindowGUI::drag_stop()
2305 if( get_hidden() ) return 0;
2309 Indexable* AWindowGUI::selected_asset()
2311 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2312 return picon ? picon->indexable : 0;
2315 PluginServer* AWindowGUI::selected_plugin()
2317 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2318 return picon ? picon->plugin : 0;
2321 AssetPicon* AWindowGUI::selected_folder()
2323 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2334 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2335 : BC_SubWindow(x, y, w, h)
2337 this->mwindow = mwindow;
2340 AWindowDivider::~AWindowDivider()
2344 int AWindowDivider::button_press_event()
2346 if( is_event_win() && cursor_inside() ) {
2347 mwindow->session->current_operation = DRAG_PARTITION;
2353 int AWindowDivider::cursor_motion_event()
2355 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2357 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2358 int fw = gui->get_relative_cursor_x();
2359 if( fw > wmax ) fw = wmax;
2360 if( fw < wmin ) fw = wmin;
2361 mwindow->session->afolders_w = fw;
2362 mwindow->theme->get_awindow_sizes(gui);
2363 gui->reposition_objects();
2369 int AWindowDivider::button_release_event()
2371 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2372 mwindow->session->current_operation = NO_OPERATION;
2383 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2384 : BC_ListBox(x, y, w, h,
2385 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2386 LISTBOX_ICONS : LISTBOX_TEXT,
2387 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2388 0, // Titles for columns. Set to 0 for no titles
2389 0, // width of each column
2390 1, // Total columns.
2391 0, // Pixel of top of window.
2392 0, // If this listbox is a popup window
2393 LISTBOX_SINGLE, // Select one item or multiple items
2394 ICON_TOP, // Position of icon relative to text of each item
2397 this->mwindow = mwindow;
2404 AWindowFolders::~AWindowFolders()
2408 int AWindowFolders::selection_changed()
2410 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2411 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2412 // prefer expanded entry
2413 AWindowFolderItem *item = item1 ? item1 : item0;
2414 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2415 item1->set_selected(0);
2422 AssetPicon *picon = item->get_picon();
2423 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2425 gui->stop_vicon_drawing();
2427 if( get_button_down() && get_buttonpress() == 3 ) {
2428 gui->folderlist_menu->update_titles();
2429 gui->folderlist_menu->activate_menu();
2432 mwindow->edl->session->awindow_folder = picon->foldernum;
2433 gui->asset_list->draw_background();
2434 gui->async_update_assets();
2436 gui->start_vicon_drawing();
2441 int AWindowFolders::button_press_event()
2443 AssetVIconThread *avt = gui->vicon_thread;
2444 if( gui->asset_list->is_event_win() &&
2445 avt->viewing && avt->view_win ) {
2446 int dir = 1, button = get_buttonpress();
2448 case WHEEL_DOWN: dir = -1; // fall thru
2450 int x = get_cursor_x(), y = get_cursor_y();
2451 if( avt->cursor_inside(x, y) )
2452 return avt->view_win->zoom_scale(dir);
2457 int result = BC_ListBox::button_press_event();
2460 if( get_buttonpress() == RIGHT_BUTTON &&
2461 is_event_win() && cursor_inside() ) {
2462 gui->folderlist_menu->update_titles();
2463 gui->folderlist_menu->activate_menu();
2472 int AWindowFolders::drag_stop()
2475 if( get_hidden() ) return 0;
2476 if( mwindow->session->current_operation == DRAG_ASSET &&
2477 gui->folder_list->cursor_above() ) { // check user folder
2478 int item_no = gui->folder_list->get_cursor_data_item_no();
2479 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2480 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2481 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2482 ArrayList<Indexable *> *drags = folder->is_clips ?
2483 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2484 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2485 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2487 mwindow->session->current_operation = ::NO_OPERATION;
2494 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2495 : AWindowFolderItem(text)
2497 this->parent = parent;
2500 int AWindowFolders::load_expanders()
2502 char expanders_path[BCTEXTLEN];
2503 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2504 FILE *fp = fopen(expanders_path, "r");
2506 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2507 File::get_cindat_path(), EXPANDERS_FILE);
2508 fp = fopen(expanders_path, "r");
2512 const char tab = '\t';
2513 char line[BCTEXTLEN]; line[0] = 0;
2514 AWindowFolderItem *item = 0, *parent;
2515 AWindowFolderSubItems *sub_items = 0;
2517 while( fgets(line,sizeof(line),fp) ) {
2518 if( line[0] == '#' ) continue;
2519 int i = strlen(line);
2520 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2521 if( i == 0 ) continue;
2523 for( char *cp=line; *cp==tab; ++cp ) ++i;
2525 int i = gui->folders.size();
2527 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2528 if( !strcmp(folder->get_text(),_(line)) ) break;
2530 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2535 if( i > k+1 ) continue;
2537 if( line[i] != '-' && sub_items ) {
2538 sub_items->names.append(cstrdup(_(&line[i])));
2546 item = item->parent;
2549 parent = item->parent;
2551 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2552 if( !sublist ) sublist = parent->new_sublist(1);
2553 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2554 sublist->append(item = sub_items);
2561 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2562 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2563 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2564 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2565 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2567 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2568 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2569 mwindow->edl->session->asset_columns, // width of each column
2570 1, // Total columns.
2571 0, // Pixel of top of window.
2572 0, // If this listbox is a popup window
2573 LISTBOX_MULTIPLE, // Select one item or multiple items
2574 ICON_TOP, // Position of icon relative to text of each item
2575 -1) // Allow drags, require shift for scrolling
2577 this->mwindow = mwindow;
2580 set_scroll_stretch(1, 1);
2583 AWindowAssets::~AWindowAssets()
2587 int AWindowAssets::button_press_event()
2591 result = BC_ListBox::button_press_event();
2593 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2594 BC_ListBox::deactivate_selection();
2595 int folder = mwindow->edl->session->awindow_folder;
2597 case AW_AEFFECT_FOLDER:
2598 case AW_VEFFECT_FOLDER:
2599 case AW_ATRANSITION_FOLDER:
2600 case AW_VTRANSITION_FOLDER:
2601 gui->effectlist_menu->update();
2602 gui->effectlist_menu->activate_menu();
2604 case AW_LABEL_FOLDER:
2605 gui->labellist_menu->update();
2606 gui->labellist_menu->activate_menu();
2608 case AW_CLIP_FOLDER:
2609 gui->cliplist_menu->update();
2610 gui->cliplist_menu->activate_menu();
2612 case AW_PROXY_FOLDER:
2613 gui->proxylist_menu->update();
2614 gui->proxylist_menu->activate_menu();
2617 case AW_MEDIA_FOLDER: {
2618 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2619 gui->assetlist_menu->update_titles(shots);
2620 gui->assetlist_menu->activate_menu();
2630 int AWindowAssets::handle_event()
2632 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2633 if( !asset_picon ) return 0;
2634 Indexable *picon_idxbl = asset_picon->indexable;
2635 EDL *picon_edl = asset_picon->edl;
2637 VWindow *vwindow = 0;
2638 switch( mwindow->edl->session->awindow_folder ) {
2639 case AW_AEFFECT_FOLDER:
2640 case AW_VEFFECT_FOLDER:
2641 case AW_ATRANSITION_FOLDER:
2642 case AW_VTRANSITION_FOLDER: return 1;
2643 case AW_PROXY_FOLDER:
2644 proxy = 1; // fall thru
2646 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2647 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2650 if( !vwindow || !vwindow->is_running() ) return 1;
2651 if( proxy && picon_idxbl ) {
2652 picon_edl = gui->collect_proxy(picon_idxbl);
2656 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2657 else if( picon_edl ) vwindow->change_source(picon_edl);
2661 int AWindowAssets::selection_changed()
2663 // Show popup window
2665 if( get_button_down() && get_buttonpress() == 3 &&
2666 (item = (AssetPicon*)get_selection(0, 0)) ) {
2667 int folder = mwindow->edl->session->awindow_folder;
2669 case AW_AEFFECT_FOLDER:
2670 case AW_VEFFECT_FOLDER:
2671 case AW_ATRANSITION_FOLDER:
2672 case AW_VTRANSITION_FOLDER:
2673 gui->effectlist_menu->update();
2674 gui->effectlist_menu->activate_menu();
2676 case AW_LABEL_FOLDER:
2677 if( !item->label ) break;
2678 gui->label_menu->activate_menu();
2680 case AW_CLIP_FOLDER:
2681 if( !item->indexable && !item->edl ) break;
2682 gui->clip_menu->update();
2683 gui->clip_menu->activate_menu();
2685 case AW_PROXY_FOLDER:
2686 if( !item->indexable && !item->edl ) break;
2687 gui->proxy_menu->update();
2688 gui->proxy_menu->activate_menu();
2691 if( !item->indexable && !item->edl ) break;
2692 gui->asset_menu->update();
2693 gui->asset_menu->activate_menu();
2697 deactivate_selection();
2699 else if( gui->vicon_drawing && get_button_down() &&
2700 ( get_buttonpress() == 1 || get_buttonpress() == 2 ) &&
2701 ( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
2702 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
2703 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) &&
2704 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2705 AssetVIcon *vicon = 0;
2706 if( !gui->vicon_thread->vicon ) {
2707 vicon = item->vicon;
2709 int draw_mode = vicon && get_buttonpress() == 2 ?
2710 ASSET_DRAW_MEDIA_MAP : ASSET_DRAW_IMAGE;
2711 gui->vicon_thread->set_view_popup(vicon, draw_mode);
2716 void AWindowAssets::draw_background()
2718 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2719 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2720 set_font(LARGEFONT);
2721 int folder = mwindow->edl->session->awindow_folder;
2722 const char *title = mwindow->edl->get_folder_name(folder);
2723 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2724 title, -1, get_bg_surface());
2727 int AWindowAssets::drag_start_event()
2729 int collect_pluginservers = 0;
2730 int collect_assets = 0, proxy = 0;
2732 if( BC_ListBox::drag_start_event() ) {
2733 switch( mwindow->edl->session->awindow_folder ) {
2734 case AW_AEFFECT_FOLDER:
2735 mwindow->session->current_operation = DRAG_AEFFECT;
2736 collect_pluginservers = 1;
2738 case AW_VEFFECT_FOLDER:
2739 mwindow->session->current_operation = DRAG_VEFFECT;
2740 collect_pluginservers = 1;
2742 case AW_ATRANSITION_FOLDER:
2743 mwindow->session->current_operation = DRAG_ATRANSITION;
2744 collect_pluginservers = 1;
2746 case AW_VTRANSITION_FOLDER:
2747 mwindow->session->current_operation = DRAG_VTRANSITION;
2748 collect_pluginservers = 1;
2750 case AW_LABEL_FOLDER:
2753 case AW_PROXY_FOLDER:
2754 proxy = 1; // fall thru
2755 case AW_MEDIA_FOLDER:
2757 mwindow->session->current_operation = DRAG_ASSET;
2762 if( collect_pluginservers ) {
2764 mwindow->session->drag_pluginservers->remove_all();
2767 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2768 if( !result ) break;
2770 mwindow->session->drag_pluginservers->append(result->plugin);
2774 if( collect_assets ) {
2775 gui->collect_assets(proxy);
2783 int AWindowAssets::drag_motion_event()
2785 BC_ListBox::drag_motion_event();
2788 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2789 mwindow->gui->drag_motion();
2790 mwindow->gui->unlock_window();
2792 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2793 VWindow *vwindow = mwindow->vwindows.get(i);
2794 if( !vwindow->is_running() ) continue;
2795 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2796 vwindow->gui->drag_motion();
2797 vwindow->gui->unlock_window();
2800 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2801 mwindow->cwindow->gui->drag_motion();
2802 mwindow->cwindow->gui->unlock_window();
2804 lock_window("AWindowAssets::drag_motion_event");
2805 if( mwindow->session->current_operation == DRAG_ASSET &&
2806 gui->folder_list->cursor_above() ) { // highlight user folder
2807 BC_ListBoxItem *item = 0;
2808 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2809 if( item_no >= 0 ) {
2810 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2811 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2814 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2815 int folder_xposition = gui->folder_list->get_xposition();
2816 int folder_yposition = gui->folder_list->get_yposition();
2817 gui->folder_list->update(&gui->folders, 0, 0, 1,
2818 folder_xposition, folder_yposition, item_no, 0, 1);
2823 int AWindowAssets::drag_stop_event()
2827 result = gui->drag_stop();
2832 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2833 result = mwindow->gui->drag_stop();
2834 mwindow->gui->unlock_window();
2838 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2839 VWindow *vwindow = mwindow->vwindows.get(i);
2840 if( !vwindow ) continue;
2841 if( !vwindow->is_running() ) continue;
2842 if( vwindow->gui->is_hidden() ) continue;
2843 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2844 if( vwindow->gui->cursor_above() &&
2845 vwindow->gui->get_cursor_over_window() ) {
2846 result = vwindow->gui->drag_stop();
2848 vwindow->gui->unlock_window();
2853 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2854 result = mwindow->cwindow->gui->drag_stop();
2855 mwindow->cwindow->gui->unlock_window();
2858 lock_window("AWindowAssets::drag_stop_event");
2860 result = gui->folder_list->drag_stop();
2865 get_drag_popup()->set_animation(0);
2867 BC_ListBox::drag_stop_event();
2868 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2869 mwindow->session->current_operation = ::NO_OPERATION;
2874 int AWindowAssets::column_resize_event()
2876 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2877 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2881 int AWindowAssets::focus_in_event()
2883 int ret = BC_ListBox::focus_in_event();
2884 gui->start_vicon_drawing();
2888 int AWindowAssets::focus_out_event()
2890 gui->stop_vicon_drawing();
2891 return BC_ListBox::focus_out_event();
2894 void AWindowAssets::update_vicon_area()
2896 int x0 = 0, x1 = get_w();
2897 int y0 = get_title_h();
2899 if( is_highlighted() ) {
2900 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2901 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2903 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2906 int AWindowAssets::mouse_over_event(int no)
2908 if( gui->vicon_thread->viewing &&
2909 no >= 0 && no < gui->displayed_assets[0].size() ) {
2910 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2911 gui->vicon_thread->set_view_popup(picon->vicon);
2917 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2918 : BC_TextBox(x, y, w, 1, "")
2920 this->search_text = search_text;
2923 int AWindowSearchTextBox::handle_event()
2925 return search_text->handle_event();
2928 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2930 this->mwindow = mwindow;
2936 void AWindowSearchText::create_objects()
2938 int x1 = x, y1 = y, margin = 10;
2939 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2940 x1 += text_title->get_w() + margin;
2941 int w1 = gui->get_w() - x1 - 2*margin;
2942 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2945 int AWindowSearchText::handle_event()
2947 gui->async_update_assets();
2951 int AWindowSearchText::get_w()
2953 return text_box->get_w() + text_title->get_w() + 10;
2956 int AWindowSearchText::get_h()
2958 return bmax(text_box->get_h(),text_title->get_h());
2961 void AWindowSearchText::reposition_window(int x, int y, int w)
2963 int x1 = x, y1 = y, margin = 10;
2964 text_title->reposition_window(x1, y1);
2965 x1 += text_title->get_w() + margin;
2966 int w1 = gui->get_w() - x1 - 2*margin;
2967 text_box->reposition_window(x1, y1, w1);
2970 const char *AWindowSearchText::get_text()
2972 return text_box->get_text();
2975 void AWindowSearchText::clear()
2977 text_box->update("");
2980 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2981 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2983 this->mwindow = mwindow;
2985 set_tooltip(_("Delete asset from disk"));
2988 int AWindowDeleteDisk::handle_event()
2993 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2994 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2996 this->mwindow = mwindow;
2998 set_tooltip(_("Delete asset from project"));
3001 int AWindowDeleteProject::handle_event()
3006 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3007 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3009 // this->mwindow = mwindow;
3011 // set_tooltip(_("Edit information on asset"));
3014 // int AWindowInfo::handle_event()
3016 // int cur_x, cur_y;
3017 // gui->get_abs_cursor(cur_x, cur_y, 0);
3018 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3022 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3023 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3025 this->mwindow = mwindow;
3027 set_tooltip(_("Redraw index"));
3030 int AWindowRedrawIndex::handle_event()
3035 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3036 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3038 this->mwindow = mwindow;
3040 set_tooltip(_("Paste asset on recordable tracks"));
3043 int AWindowPaste::handle_event()
3048 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3049 : BC_Button(x, y, mwindow->theme->appendasset_data)
3051 this->mwindow = mwindow;
3053 set_tooltip(_("Append asset in new tracks"));
3056 int AWindowAppend::handle_event()
3061 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3062 : BC_Button(x, y, mwindow->theme->viewasset_data)
3064 this->mwindow = mwindow;
3066 set_tooltip(_("View asset"));
3069 int AWindowView::handle_event()
3074 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3075 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3077 this->mwindow = mwindow;
3081 void AddTools::create_objects()
3084 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3085 vis |= 1 << PLUGIN_FFMPEG_ID;
3086 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3087 vis |= 1 << PLUGIN_LADSPA_ID;
3089 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3090 vis |= 1 << PLUGIN_LV2_ID;
3092 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3093 PluginServer *plugin = MWindow::plugindb->get(i);
3094 if( !plugin->audio && !plugin->video ) continue;
3095 int idx = plugin->dir_idx;
3096 uint32_t msk = 1 << idx;
3097 if( (msk & vis) != 0 ) continue;
3099 char parent[BCTEXTLEN];
3100 strcpy(parent, plugin->path);
3101 char *bp = strrchr(parent, '/');
3102 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3103 if( !bp ) bp = parent; else ++bp;
3104 add_item(new AddPluginItem(this, bp, idx));
3109 // plugin_dirs list from toplevel makefile include plugin_defs
3114 N_("audio_transitions")
3121 N_("video_transitions")
3124 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3125 : BC_MenuItem(_(text))
3129 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3130 int chk = (msk & vis) ? 1 : 0;
3134 int AddPluginItem::handle_event()
3136 int chk = get_checked() ^ 1;
3138 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3139 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3140 menu->gui->update_effects();
3141 menu->gui->save_defaults(menu->mwindow->defaults);
3142 menu->gui->async_update_assets();
3146 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3147 : BC_Toggle(x, y, images, agui->vicon_drawing)
3150 set_tooltip(_("Preview"));
3153 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3155 int text_line = -1, toggle_x = -1, toggle_y = -1;
3156 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3157 BC_Toggle::calculate_extents(agui, images, 1,
3158 &text_line, ww, hh, &toggle_x, &toggle_y,
3159 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3162 AVIconDrawing::~AVIconDrawing()
3166 int AVIconDrawing::handle_event()
3168 agui->vicon_drawing = get_value();
3169 if( agui->vicon_drawing )
3170 agui->start_vicon_drawing();
3172 agui->stop_vicon_drawing();
3177 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3178 : BC_MenuItem("","v",'v')
3180 this->mwindow = mwindow;
3184 int AWindowListFormat::handle_event()
3186 return gui->cycle_assetlist_format();
3189 void AWindowListFormat::update()
3191 EDLSession *session = mwindow->edl->session;
3192 const char *text = 0;
3193 switch( session->assetlist_format ) {
3195 text = _("Display icons");
3198 text = _("Display icons packed");
3200 case ASSETS_ICONS_PACKED:
3201 text = _("Display icon list");
3203 case ASSETS_ICON_LIST:
3204 text = _("Display text");
3210 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3211 : BC_MenuItem(_("Sort items"))
3213 this->mwindow = mwindow;
3217 int AWindowListSort::handle_event()
3223 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3226 this->select_used = select_used;
3227 this->action = action;
3230 int AssetSelectUsedItem::handle_event()
3232 MWindow *mwindow = select_used->mwindow;
3233 AWindowGUI *gui = select_used->gui;
3234 AWindowAssets *asset_list = gui->asset_list;
3235 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3240 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3244 asset_list->set_all_selected(data, 0);
3245 for( int i = 0; i < data->total; i++ ) {
3246 AssetPicon *picon = (AssetPicon*)data->values[i];
3247 Indexable *idxbl = picon->indexable ? picon->indexable :
3248 picon->edl ? picon->edl->get_proxy_asset() : 0;
3249 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3250 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3255 int asset_xposition = asset_list->get_xposition();
3256 int asset_yposition = asset_list->get_yposition();
3257 asset_list->update(gui->displayed_assets, gui->asset_titles,
3258 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3259 asset_xposition, asset_yposition, -1, 0);
3260 asset_list->center_selection();
3264 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3265 : BC_MenuItem(_("Select"))
3267 this->mwindow = mwindow;