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 "bcdisplayinfo.h"
34 #include "bcsignals.h"
36 #include "binfolder.h"
41 #include "clippopup.h"
43 #include "cwindowgui.h"
48 #include "edlsession.h"
49 #include "effectlist.h"
51 #include "filesystem.h"
52 #include "folderlistmenu.h"
53 #include "indexable.h"
57 #include "labelpopup.h"
58 #include "localsession.h"
59 #include "mainerror.h"
61 #include "mainsession.h"
62 #include "mwindowgui.h"
64 #include "preferences.h"
66 #include "proxypopup.h"
67 #include "renderengine.h"
72 #include "transportque.h"
76 #include "vwindowgui.h"
79 #include "data/lad_picon_png.h"
80 #include "data/ff_audio_png.h"
81 #include "data/ff_video_png.h"
88 const char *AWindowGUI::folder_names[] =
92 N_("Audio Transitions"),
93 N_("Video Transitions"),
100 const char *AVIconDrawing::avicon_names[] =
108 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
109 : VIcon(w, h, framerate), Garbage("AssetVIcon")
112 this->length = length;
117 AssetVIcon::~AssetVIcon()
119 if( picon->gui->vicon_thread->solo == this )
120 picon->gui->vicon_thread->solo = 0;
121 picon->gui->vicon_thread->del_vicon(this);
125 VFrame *AssetVIcon::frame()
127 if( broken ) return 0;
128 AssetVIconThread *avt = picon->gui->vicon_thread;
129 Indexable *idxbl = picon->indexable;
130 Asset *asset = idxbl && idxbl->is_asset ? (Asset *)idxbl : 0;
131 if( !asset ) return vframes()>0 ? images[0]->vfrm : 0;
132 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
133 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
135 int sample_rate = asset->get_sample_rate();
136 int64_t audio_samples = asset->get_audio_samples();
137 double duration = (double)audio_samples / sample_rate;
138 picon->draw_hue_bar(temp, duration);
139 int secs = length / frame_rate + 0.5;
140 if( !secs ) secs = 1;
141 int bfrsz = VICON_SAMPLE_RATE;
142 int samples = audio_size/sizeof(vicon_audio_t);
143 double line_pos = (double)seq_no/(length-1);
144 int audio_pos = samples * line_pos * (secs-1)/secs;
145 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
146 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
147 double data[bfrsz], sample_scale = 1./mx;
148 int len = samples - audio_pos;
149 if( len > bfrsz ) len = bfrsz;
151 while( i < len ) data[i++] = *audio_data++ * sample_scale;
152 while( i < bfrsz ) data[i++] = 0;
153 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
154 int x = (w-1) * line_pos;
155 temp->pixel_rgb = RED;
156 temp->draw_line(x,0, x,h);
159 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
160 if( !asset->video_data ) {
162 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
167 if( seq_no >= images.size() ) {
168 MWindow *mwindow = picon->mwindow;
169 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
170 delete temp; temp = 0;
173 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
174 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
175 if( !file ) { broken = 1; return 0; }
177 while( file && seq_no >= images.size() ) {
178 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
179 file->set_video_position(pos,0);
181 if( file->read_frame(temp) ) temp->clear_frame();
182 add_image(temp, vw, vh, vicon_cmodel);
183 if( seq_no < images.size() ) break;
184 mwindow->video_cache->check_in(asset);
185 if( timer.get_difference() > 500 ) return 0;
187 if( avt->interrupted ) return 0;
188 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
189 for( int retries=10; !file && --retries>=0; usleep(1000) ) {
190 if( avt->interrupted ) return 0;
191 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
193 if( !file ) return 0;
195 mwindow->video_cache->check_in(asset);
197 if( seq_no >= images.size() ) return 0;
198 return images[seq_no]->vfrm;
201 int64_t AssetVIcon::set_seq_no(int64_t no)
203 if( no >= length ) no = 0;
207 int AssetVIcon::get_vx()
209 BC_ListBox *lbox = picon->gui->asset_list;
210 return lbox->get_icon_x(picon);
212 int AssetVIcon::get_vy()
214 BC_ListBox *lbox = picon->gui->asset_list;
215 return lbox->get_icon_y(picon);
218 void AssetVIcon::load_audio()
220 MWindow *mwindow = picon->mwindow;
221 Asset *asset = (Asset *)picon->indexable;
222 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
223 int channels = asset->get_audio_channels();
224 if( channels > 2 ) channels = 2;
225 int sample_rate = asset->get_sample_rate();
226 int bfrsz = sample_rate;
227 Samples samples(bfrsz);
228 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
229 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
230 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
231 double sample_scale = (double)mx / channels;
232 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
233 while( audio_pos < audio_len ) {
234 int64_t pos = audio_pos * time_scale;
235 for( int ch=0; ch<channels; ++ch ) {
236 file->set_channel(ch);
237 file->set_audio_position(pos);
238 file->read_samples(&samples, bfrsz);
239 double *data = samples.get_data();
240 for( int64_t k=audio_pos; k<audio_len; ++k ) {
241 int i = k * time_scale - pos;
242 if( i >= bfrsz ) break;
243 int v = audio_data[k] + data[i] * sample_scale;
244 audio_data[k] = CLIP(v, -mx,mx);
247 audio_pos = (pos + bfrsz) / time_scale;
249 mwindow->audio_cache->check_in(asset);
253 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
257 audio = new AudioDevice(gui->mwindow);
261 AssetVIconAudio::~AssetVIconAudio()
266 void AssetVIconAudio::run()
269 int64_t bfrsz = VICON_SAMPLE_RATE;
270 MWindow *mwindow = gui->mwindow;
271 EDL *edl = mwindow->edl;
272 EDLSession *session = edl->session;
273 AudioOutConfig *aconfig = session->playback_config->aconfig;
274 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
275 audio->start_playback();
276 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
277 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
278 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
280 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
281 while( !interrupted ) {
282 int len = audio_len - audio_pos;
283 if( len <= 0 ) break;
284 if( len > bfrsz ) len = bfrsz;
286 for( int i=0; i<len; ++i,++k )
287 out0[i] = out1[i] = (double)audio_data[k] / mx;
289 audio->write_buffer(out, channels, len);
293 audio->set_last_buffer();
294 audio->stop_audio(interrupted ? 0 : 1);
298 void AssetVIconAudio::start(AssetVIcon *vicon)
300 if( running() ) return;
302 double pos = vicon->length > 0 ? (double)vicon->seq_no/vicon->length : 0;
303 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
304 audio_pos = pos * audio_len;
309 void AssetVIconAudio::stop(int wait)
311 if( running() && !interrupted ) {
313 audio->stop_audio(wait);
317 vicon->playing_audio = 0;
322 void AssetVIcon::start_audio()
324 if( playing_audio < 0 ) return;
325 picon->gui->vicon_audio->stop(0);
327 picon->gui->vicon_audio->start(this);
330 void AssetVIcon::stop_audio()
332 if( playing_audio > 0 ) {
333 picon->gui->vicon_audio->stop(0);
338 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
339 int x, int y, int w, int h)
340 : ViewPopup(vt, x, y, w, h)
342 this->draw_mode = draw_mode;
343 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
347 AssetViewPopup::~AssetViewPopup()
351 int AssetViewPopup::reposition_window(int x, int y, int w, int h)
353 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
354 return ViewPopup::reposition_window(x, y, w, h);
357 int AssetViewPopup::button_press_event()
359 if( !is_event_win() ) return 0;
360 AssetVIconThread *avt = (AssetVIconThread *)vt;
361 if( !avt->vicon ) return 0;
364 switch( get_buttonpress() ) {
368 avt->set_view_popup(0);
371 dir = -1; // fall thru
373 switch( draw_mode ) {
374 case ASSET_VIEW_MEDIA:
375 case ASSET_VIEW_MEDIA_MAP:
376 avt->zoom_scale(dir);
383 int x = get_cursor_x(), y = get_cursor_y();
384 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
385 AssetPicon *picon = vicon->picon;
386 MWindow *mwindow = picon->mwindow;
387 EDL *edl = mwindow->edl;
389 if( y < get_h()/2 ) {
391 picon->indexable ? picon->indexable :
392 picon->edl ? picon->edl : 0;
393 if( !idxbl ) return 0;
394 double sample_rate = idxbl->get_sample_rate();
395 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
396 idxbl->get_audio_samples() / sample_rate : 0;
397 double frame_rate = idxbl->get_frame_rate();
398 double video_length = frame_rate > 0 && idxbl->have_video() ?
399 idxbl->get_video_frames() / frame_rate : 0;
400 double idxbl_length = bmax(audio_length, video_length);
401 double pos = x * idxbl_length / get_w();
402 double start = 0, end = idxbl_length;
403 double lt = DBL_MAX, rt = DBL_MAX;
404 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
405 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
406 Indexable *indexable = (Indexable *)edit->asset;
407 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
408 if( !indexable ) continue;
409 if( indexable->id == idxbl->id ||
410 (!indexable->is_asset == !idxbl->is_asset &&
411 !strcmp(indexable->path, idxbl->path)) ) {
412 double start_pos = track->from_units(edit->startsource);
413 double end_pos = track->from_units(edit->startsource + edit->length);
414 double dlt = pos - start_pos, drt = end_pos - pos;
415 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
416 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
417 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
418 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
422 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
423 VWindow *vwindow = mwindow->get_viewer(1, 0);
424 vwindow->change_source(idxbl);
425 mwindow->gui->unlock_window();
426 EDL *vedl = vwindow->get_edl();
427 vedl->set_inpoint(start);
428 vedl->set_outpoint(end);
429 vedl->local_session->set_selectionstart(start);
430 vedl->local_session->set_selectionend(start);
431 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
432 vwindow->update_position();
433 vwindow->gui->unlock_window();
438 if( !ctrl_down() && !shift_down() )
439 return cursor_motion_event();
441 picon->indexable ? picon->indexable :
442 picon->edl ? picon->edl : 0;
443 if( !idxbl ) return 0;
444 double total_length = mwindow->edl->tracks->total_length();
445 double pos = x * total_length / get_w();
446 double start = 0, end = total_length;
447 double lt = DBL_MAX, rt = DBL_MAX;
448 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
449 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
450 Indexable *indexable = (Indexable *)edit->asset;
451 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
452 if( !indexable ) continue;
453 if( indexable->id == idxbl->id ||
454 (!indexable->is_asset == !idxbl->is_asset &&
455 !strcmp(indexable->path, idxbl->path)) ) {
456 double start_pos = track->from_units(edit->startproject);
457 double end_pos = track->from_units(edit->startproject + edit->length);
458 double dlt = pos - start_pos, drt = end_pos - pos;
459 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
460 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
461 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
462 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
466 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
467 mwindow->select_point(start);
468 edl->local_session->set_selectionstart(start);
469 edl->local_session->set_selectionend(!shift_down() ? start : end);
470 mwindow->zoom_sample(edl->local_session->zoom_sample);
471 mwindow->gui->unlock_window();
477 int AssetViewPopup::button_release_event()
479 if( !is_event_win() ) return 0;
484 int AssetViewPopup::cursor_motion_event()
486 AssetVIconThread *avt = (AssetVIconThread *)vt;
487 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
488 if( vicon && dragging && is_event_win() &&
489 get_button_down() && get_buttonpress() == LEFT_BUTTON &&
490 !ctrl_down() && !alt_down() && !shift_down() ) {
491 switch( draw_mode ) {
492 case ASSET_VIEW_MEDIA_MAP:
493 case ASSET_VIEW_FULL:
494 MWindow *mwindow = vicon->picon->mwindow;
495 EDL *edl = mwindow->edl;
496 int x = get_cursor_x();
497 double total_length = edl->tracks->total_length();
498 double pos = x * total_length / get_w();
499 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
500 mwindow->select_point(pos);
501 mwindow->zoom_sample(edl->local_session->zoom_sample);
502 mwindow->gui->unlock_window();
509 void AssetViewPopup::draw_vframe(VFrame *vframe)
511 switch( draw_mode ) {
512 case ASSET_VIEW_MEDIA:
513 case ASSET_VIEW_ICON:
514 ViewPopup::draw_vframe(vframe);
515 case ASSET_VIEW_NONE:
518 case ASSET_VIEW_MEDIA_MAP:
519 case ASSET_VIEW_FULL:
523 draw_box(0,0,get_w(),get_h());
525 int y2 = get_h()-bar_h;
526 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
527 AssetVIconThread *avt = (AssetVIconThread *)vt;
528 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
529 AssetPicon *picon = (AssetPicon *)vicon->picon;
531 picon->indexable ? picon->indexable :
532 picon->edl ? picon->edl : 0;
534 double sample_rate = idxbl->get_sample_rate();
535 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
536 idxbl->get_audio_samples() / sample_rate : 0;
537 double frame_rate = idxbl->get_frame_rate();
538 double video_length = frame_rate > 0 && idxbl->have_video() ?
539 idxbl->get_video_frames() / frame_rate : 0;
540 double idxbl_length = bmax(audio_length, video_length);
541 if( !idxbl_length ) idxbl_length = 1;
543 EDL *edl = picon->mwindow->edl;
544 double total_length = edl->tracks->total_length();
545 if( !total_length ) total_length = 1;
546 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
547 if( !track->is_armed() ) continue;
548 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
549 Indexable *indexable = (Indexable *)edit->asset;
550 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
551 if( !indexable ) continue;
552 if( indexable->id == idxbl->id ||
553 (!indexable->is_asset == !idxbl->is_asset &&
554 !strcmp(indexable->path, idxbl->path)) ) {
555 double pos1 = track->from_units(edit->startsource);
556 double pos2 = track->from_units(edit->startsource + edit->length);
557 double xscale = get_w() / idxbl_length;
558 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
560 draw_box(ex1,0, ex2-ex1,y1);
562 draw_line(ex1,0, ex1,y1);
563 draw_line(ex2,0, ex2,y1);
564 pos1 = track->from_units(edit->startproject);
565 pos2 = track->from_units(edit->startproject + edit->length);
566 xscale = get_w() / total_length;
567 int px1 = pos1 * xscale, px2 = pos2 * xscale;
569 draw_box(px1,y2, px2-px1,get_h()-y2);
571 draw_line(px1,y2, px1,get_h()-1);
572 draw_line(px2,y2, px2,get_h()-1);
575 draw_line(ex1,y1, px1,y2);
576 draw_line(ex2,y1, px2,y2);
582 int AssetViewPopup::keypress_event()
585 AssetVIconThread *avt = (AssetVIconThread *)vt;
586 switch( avt->draw_mode ) {
587 case ASSET_VIEW_MEDIA_MAP:
588 switch( get_keypress() ) {
591 avt->draw_mode = ASSET_VIEW_FULL;
595 case ASSET_VIEW_FULL:
596 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
599 if( result ) // zero change for refresh
601 return ViewPopup::keypress_event();
605 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
606 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
607 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
610 draw_mode = ASSET_VIEW_NONE;
611 int vicon_cmodel = BC_RGB8;
612 switch( preferences->vicon_color_mode ) {
613 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
614 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
615 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
617 this->vicon_cmodel = vicon_cmodel;
620 AssetVIconThread::~AssetVIconThread()
624 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
626 gui->stop_vicon_drawing();
627 this->draw_mode = draw_mode;
629 gui->start_vicon_drawing();
632 void AssetVIconThread::set_view_popup(AssetVIcon *v)
634 if( !v ) draw_mode = ASSET_VIEW_NONE;
635 VIconThread::set_view_popup(v);
638 ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
640 BC_WindowBase *parent = wdw->get_parent();
641 int rx = 0, ry = 0, rw = 0, rh = 0;
642 if( draw_mode != ASSET_VIEW_FULL ) {
643 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
644 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
645 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
646 int vx = viewing->get_vx(), vy = viewing->get_vy();
647 wdw->get_root_coordinates(vx, vy, &rx, &ry);
648 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
649 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
650 rw = view_w; rh = view_h;
653 parent->get_fullscreen_geometry(rx, ry, rw, rh);
654 AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
656 av_popup->reposition_window(rx, ry, rw, rh);
658 av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
659 int playing_audio = gui->play_off ? -1 : 0;
660 if( !playing_audio ) {
661 switch( draw_mode ) {
662 case ASSET_VIEW_NONE:
663 case ASSET_VIEW_ICON:
664 case ASSET_VIEW_MEDIA_MAP:
665 case ASSET_VIEW_FULL:
668 case ASSET_VIEW_MEDIA:
669 switch( gui->vicon_drawing ) {
670 case AVICON_SRC_TARGET:
677 vicon->playing_audio = playing_audio;
678 wdw->set_active_subwindow(av_popup);
682 void AssetVIconThread::stop_vicon_drawing(int wait)
685 gui->lock_window("AssetVIconThread::stop_vicon_drawing");
686 gui->unlock_window();
690 AWindowFolderItem::AWindowFolderItem()
696 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
697 : BC_ListBoxItem(text, color)
702 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
703 : BC_ListBoxItem(text, icon, color)
708 AssetPicon *AWindowFolderItem::get_picon()
710 AWindowFolderItem *item = this;
711 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
712 return (AssetPicon*)item;
715 int AWindowFolderSubItems::matches(const char *text)
717 int i = names.size();
718 while( --i >= 0 && strcmp(names[i], text) );
720 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
721 i = sublist ? sublist->size() : 0;
723 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
724 if( item->matches(text) ) break;
727 return i >= 0 ? 1 : 0;
731 AssetPicon::AssetPicon(MWindow *mwindow,
732 AWindowGUI *gui, Indexable *indexable)
733 : AWindowFolderItem()
736 this->mwindow = mwindow;
738 this->indexable = indexable;
739 indexable->add_user();
740 this->id = indexable->id;
743 AssetPicon::AssetPicon(MWindow *mwindow,
744 AWindowGUI *gui, EDL *edl)
745 : AWindowFolderItem()
748 this->mwindow = mwindow;
755 AssetPicon::AssetPicon(MWindow *mwindow,
756 AWindowGUI *gui, int folder, int persist)
757 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
758 folder>=0 && folder<AWINDOW_FOLDERS ?
759 gui->folder_icons[folder] : gui->folder_icon)
763 this->mwindow = mwindow;
765 persistent = persist;
768 AssetPicon::AssetPicon(MWindow *mwindow,
769 AWindowGUI *gui, int folder, const char *title)
770 : AWindowFolderItem(title, gui->folder_icon)
774 this->mwindow = mwindow;
779 AssetPicon::AssetPicon(MWindow *mwindow,
780 AWindowGUI *gui, PluginServer *plugin)
781 : AWindowFolderItem()
784 this->mwindow = mwindow;
786 this->plugin = plugin;
789 AssetPicon::AssetPicon(MWindow *mwindow,
790 AWindowGUI *gui, Label *label)
791 : AWindowFolderItem()
794 this->mwindow = mwindow;
802 AssetPicon::~AssetPicon()
804 if( vicon ) vicon->remove_user();
806 if( indexable ) indexable->remove_user();
807 if( edl ) edl->remove_user();
808 if( icon && !gui->protected_pixmap(icon) ) {
810 if( !plugin ) delete icon_vframe;
814 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
816 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
818 float h = 300 * t, s = 1., v = 1.;
819 float r, g, b; // duration, 0..1hr == hue red..magenta
820 HSV::hsv_to_rgb(r,g,b, h,s,v);
821 int ih = frame->get_h()/8, iw = frame->get_w();
822 int ir = r * 256; CLAMP(ir, 0,255);
823 int ig = g * 256; CLAMP(ig, 0,255);
824 int ib = b * 256; CLAMP(ib, 0,255);
825 unsigned char **rows = frame->get_rows();
826 for( int y=0; y<ih; ++y ) {
827 unsigned char *rp = rows[y];
828 for( int x=0; x<iw; rp+=3,++x ) {
829 rp[0] = ir; rp[1] = ig; rp[2] = ib;
834 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
835 int base_color, int line_color, int x, int y, int w, int h)
837 int h1 = h-1, h2 = h/2, iy = h2;
838 int rgb_color = frame->pixel_rgb;
839 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
840 double min = *dp, max = min;
841 x2 = (len * (ix+1))/w;
842 for( int i=x1; i<x2; ++i ) {
843 double value = *dp++;
844 if( value < min ) min = value;
845 if( value > max ) max = value;
847 int ctr = (min + max) / 2;
848 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
849 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
850 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
851 frame->pixel_rgb = line_color;
852 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
853 frame->pixel_rgb = base_color;
854 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
857 frame->pixel_rgb = rgb_color;
860 void AssetPicon::reset()
868 foldernum = AW_NO_FOLDER;
883 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
885 TransportCommand command;
886 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
887 command.get_edl()->copy_all(edl);
888 command.change_type = CHANGE_ALL;
889 command.realtime = 0;
890 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
891 render_engine->set_vcache(mwindow->video_cache);
892 render_engine->set_acache(mwindow->audio_cache);
893 render_engine->arm_command(&command);
895 void AssetPicon::close_render_engine()
897 delete render_engine; render_engine = 0;
899 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
901 if( !render_engine || !render_engine->vrender ) return;
902 render_engine->vrender->process_buffer(vfrm, pos, 0);
904 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
906 if( !render_engine || !render_engine->arender ) return;
907 render_engine->arender->process_buffer(samples, len, pos);
910 void AssetPicon::create_objects()
913 char name[BCTEXTLEN];
914 int pixmap_w, pixmap_h;
916 int picon_h = mwindow->preferences->awindow_picon_h;
917 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
923 if( this->indexable ) {
925 if( this->indexable->is_asset ) {
926 asset = (Asset *)indexable;
927 if( asset->format == FILE_REF ) {
928 cp += sprintf(cp, "ref:");
929 set_color(get_color() ^ 0x5599CC);
933 edl = (EDL *)indexable;
934 cp += sprintf(cp, "edl:");
935 // set_color(get_color() ^ 0xCC9955);
937 fs.extract_name(cp, indexable->path);
940 else if( this->edl ) {
942 strcpy(name, edl->local_session->clip_title);
948 if( asset->video_data ) {
949 if( mwindow->preferences->use_thumbnails ) {
950 gui->unlock_window();
951 char string[BCTEXTLEN];
952 sprintf(string, _("Reading %s"), name);
953 mwindow->gui->lock_window("AssetPicon::create_objects");
954 mwindow->gui->show_message(string);
955 mwindow->gui->unlock_window();
956 File *file = mwindow->video_cache->check_out(asset,
961 int height = asset->height > 0 ? asset->height : 1;
962 pixmap_w = pixmap_h * asset->width / height;
965 file->set_video_position(0, 0);
967 if( gui->temp_picon &&
968 (gui->temp_picon->get_w() != asset->width ||
969 gui->temp_picon->get_h() != asset->height) ) {
970 delete gui->temp_picon;
974 if( !gui->temp_picon ) {
975 gui->temp_picon = new VFrame(0, -1,
976 asset->width, asset->height,
979 file->read_frame(gui->temp_picon);
980 mwindow->video_cache->check_in(asset);
982 gui->lock_window("AssetPicon::create_objects 0");
983 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
984 icon->draw_vframe(gui->temp_picon,
985 0, 0, pixmap_w, pixmap_h, 0, 0);
986 icon_vframe = new VFrame(0,
987 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
988 icon_vframe->transfer_from(gui->temp_picon);
989 if( asset->folder_no == AW_MEDIA_FOLDER ||
990 asset->folder_no == AW_PROXY_FOLDER ) {
992 double framerate = asset->get_frame_rate();
993 if( !framerate ) framerate = VICON_RATE;
994 int64_t frames = asset->get_video_frames();
995 double secs = frames / framerate;
996 if( secs > 5 ) secs = 5;
997 int64_t length = secs * gui->vicon_thread->refresh_rate;
998 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
999 if( asset->audio_data && secs > 0 ) {
1000 gui->unlock_window();
1001 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1002 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1003 vicon->load_audio();
1004 gui->lock_window("AssetPicon::create_objects 1");
1006 gui->vicon_thread->add_vicon(vicon);
1010 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1011 gui->lock_window("AssetPicon::create_objects 2");
1012 icon = gui->video_icon;
1013 icon_vframe = gui->video_vframe;
1017 icon = gui->video_icon;
1018 icon_vframe = gui->video_vframe;
1022 if( asset->audio_data ) {
1023 if( mwindow->preferences->use_thumbnails ) {
1024 gui->unlock_window();
1025 File *file = mwindow->audio_cache->check_out(asset,
1029 pixmap_w = pixmap_h * 16/9;
1030 icon_vframe = new VFrame(0,
1031 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1032 icon_vframe->clear_frame();
1033 { char string[BCTEXTLEN];
1034 sprintf(string, _("Reading %s"), name);
1035 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1036 mwindow->gui->show_message(string);
1037 mwindow->gui->unlock_window(); }
1038 int sample_rate = asset->get_sample_rate();
1039 int channels = asset->get_audio_channels();
1040 if( channels > 2 ) channels = 2;
1041 int64_t audio_samples = asset->get_audio_samples();
1042 double duration = (double)audio_samples / sample_rate;
1043 draw_hue_bar(icon_vframe, duration);
1044 int bfrsz = sample_rate;
1045 Samples samples(bfrsz);
1046 static int line_colors[2] = { GREEN, YELLOW };
1047 static int base_colors[2] = { RED, PINK };
1048 for( int i=channels; --i>=0; ) {
1049 file->set_channel(i);
1050 file->set_audio_position(0);
1051 file->read_samples(&samples, bfrsz);
1052 draw_wave(icon_vframe, samples.get_data(), bfrsz,
1053 base_colors[i], line_colors[i]);
1055 mwindow->audio_cache->check_in(asset);
1056 if( asset->folder_no == AW_MEDIA_FOLDER ) {
1057 double secs = duration;
1058 if( secs > 5 ) secs = 5;
1059 double refresh_rate = gui->vicon_thread->refresh_rate;
1060 int64_t length = secs * refresh_rate;
1061 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1062 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1063 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1064 vicon->load_audio();
1065 gui->vicon_thread->add_vicon(vicon);
1067 gui->lock_window("AssetPicon::create_objects 4");
1068 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1069 icon->draw_vframe(icon_vframe,
1070 0, 0, pixmap_w, pixmap_h, 0, 0);
1073 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1074 gui->lock_window("AssetPicon::create_objects 5");
1075 icon = gui->audio_icon;
1076 icon_vframe = gui->audio_vframe;
1080 icon = gui->audio_icon;
1081 icon_vframe = gui->audio_vframe;
1086 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1087 comments_rate = asset->get_frame_rate();
1088 comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
1089 comments_type = asset->format == FILE_FFMPEG ?
1090 asset->vcodec : File::formattostr(asset->format);
1093 if( edl->tracks->playable_video_tracks() ) {
1094 if( mwindow->preferences->use_thumbnails ) {
1095 gui->unlock_window();
1096 AssetVIconThread *avt = gui->vicon_thread;
1097 char clip_icon_path[BCTEXTLEN];
1098 char *clip_icon = edl->local_session->clip_icon;
1100 if( is_clip && clip_icon[0] ) {
1101 snprintf(clip_icon_path, sizeof(clip_icon_path),
1102 "%s/%s", File::get_config_path(), clip_icon);
1103 vframe = VFramePng::vframe_png(clip_icon_path);
1106 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1107 delete vframe; vframe = 0;
1109 int edl_h = edl->get_h(), edl_w = edl->get_w();
1110 int height = edl_h > 0 ? edl_h : 1;
1111 int width = edl_w > 0 ? edl_w : 1;
1112 int color_model = edl->session->color_model;
1114 //printf("render clip: %s\n", name);
1115 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1116 char string[BCTEXTLEN];
1117 sprintf(string, _("Rendering %s"), name);
1118 mwindow->gui->lock_window("AssetPicon::create_objects");
1119 mwindow->gui->show_message(string);
1120 mwindow->gui->unlock_window();
1121 open_render_engine(edl, 0);
1122 render_video(0, gui->temp_picon);
1123 close_render_engine();
1124 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1125 vframe->transfer_from(gui->temp_picon);
1126 if( this->edl && clip_icon[0] )
1127 vframe->write_png(clip_icon_path);
1129 pixmap_w = pixmap_h * width / height;
1130 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1131 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1132 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1133 icon_vframe->transfer_from(vframe);
1135 gui->lock_window("AssetPicon::create_objects 0");
1136 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1137 icon->draw_vframe(icon_vframe,
1138 0, 0, pixmap_w, pixmap_h, 0, 0);
1140 else if( is_clip ) {
1141 icon = gui->clip_icon;
1142 icon_vframe = gui->clip_vframe;
1145 icon = gui->video_icon;
1146 icon_vframe = gui->video_vframe;
1150 if( edl->tracks->playable_audio_tracks() ) {
1151 if( mwindow->preferences->use_thumbnails ) {
1152 gui->unlock_window();
1153 char clip_icon_path[BCTEXTLEN];
1154 char *clip_icon = edl->local_session->clip_icon;
1155 if( is_clip && clip_icon[0] ) {
1156 snprintf(clip_icon_path, sizeof(clip_icon_path),
1157 "%s/%s", File::get_config_path(), clip_icon);
1158 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1160 if( !icon_vframe ) {
1161 pixmap_w = pixmap_h * 16/9;
1162 icon_vframe = new VFrame(0,
1163 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1164 icon_vframe->clear_frame();
1165 char string[BCTEXTLEN];
1166 sprintf(string, _("Rendering %s"), name);
1167 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1168 mwindow->gui->show_message(string);
1169 mwindow->gui->unlock_window();
1170 int sample_rate = edl->get_sample_rate();
1171 int channels = edl->get_audio_channels();
1172 if( channels > 2 ) channels = 2;
1173 int64_t audio_samples = edl->get_audio_samples();
1174 double duration = (double)audio_samples / sample_rate;
1175 draw_hue_bar(icon_vframe, duration);
1176 Samples *samples[MAX_CHANNELS];
1177 int bfrsz = sample_rate;
1178 for( int i=0; i<MAX_CHANNELS; ++i )
1179 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1180 open_render_engine(edl, 1);
1181 render_audio(0, samples, bfrsz);
1182 close_render_engine();
1183 gui->lock_window("AssetPicon::create_objects 4");
1184 static int line_colors[2] = { GREEN, YELLOW };
1185 static int base_colors[2] = { RED, PINK };
1186 for( int i=channels; --i>=0; ) {
1187 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1188 base_colors[i], line_colors[i]);
1190 for( int i=0; i<channels; ++i ) delete samples[i];
1191 if( is_clip && clip_icon[0] )
1192 icon_vframe->write_png(clip_icon_path);
1195 pixmap_w = icon_vframe->get_w();
1196 pixmap_h = icon_vframe->get_h();
1198 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1199 icon->draw_vframe(icon_vframe,
1200 0, 0, pixmap_w, pixmap_h, 0, 0);
1202 else if( !indexable ) {
1203 icon = gui->clip_icon;
1204 icon_vframe = gui->clip_vframe;
1207 icon = gui->audio_icon;
1208 icon_vframe = gui->audio_vframe;
1213 strcpy(name, _(plugin->title));
1215 icon_vframe = plugin->get_picon();
1217 icon = gui->create_pixmap(icon_vframe);
1218 else if( plugin->audio ) {
1219 if( plugin->transition ) {
1220 icon = gui->atransition_icon;
1221 icon_vframe = gui->atransition_vframe;
1223 else if( plugin->is_ffmpeg() ) {
1224 icon = gui->ff_aud_icon;
1225 icon_vframe = gui->ff_aud_vframe;
1227 else if( plugin->is_ladspa() ) {
1228 icon = gui->ladspa_icon;
1229 icon_vframe = gui->ladspa_vframe;
1232 icon = gui->aeffect_icon;
1233 icon_vframe = gui->aeffect_vframe;
1236 else if( plugin->video ) {
1237 if( plugin->transition ) {
1238 icon = gui->vtransition_icon;
1239 icon_vframe = gui->vtransition_vframe;
1241 else if( plugin->is_ffmpeg() ) {
1242 icon = gui->ff_vid_icon;
1243 icon_vframe = gui->ff_vid_vframe;
1246 icon = gui->veffect_icon;
1247 icon_vframe = gui->veffect_vframe;
1254 mwindow->edl->session->time_format,
1255 mwindow->edl->session->sample_rate,
1256 mwindow->edl->session->frame_rate,
1257 mwindow->edl->session->frames_per_foot);
1259 icon = gui->label_icon;
1260 icon_vframe = gui->label_vframe;
1263 icon = gui->file_icon;
1264 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1267 set_icon_vframe(icon_vframe);
1270 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1271 : BC_Window(_(PROGRAM_NAME ": Resources"),
1272 mwindow->session->awindow_x, mwindow->session->awindow_y,
1273 mwindow->session->awindow_w, mwindow->session->awindow_h,
1274 xS(100), yS(100), 1, 1, 1)
1276 this->mwindow = mwindow;
1277 this->awindow = awindow;
1279 file_vframe = 0; file_icon = 0;
1280 folder_vframe = 0; folder_icon = 0;
1281 audio_vframe = 0; audio_icon = 0;
1282 video_vframe = 0; video_icon = 0;
1283 label_vframe = 0; label_icon = 0;
1285 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1286 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1287 clip_folder_vframe = 0; clip_folder_icon = 0;
1288 label_folder_vframe = 0; label_folder_icon = 0;
1289 media_folder_vframe = 0; media_folder_icon = 0;
1290 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1291 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1292 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1294 ladspa_vframe = 0; ladspa_icon = 0;
1295 ff_aud_vframe = 0; ff_aud_icon = 0;
1296 ff_vid_vframe = 0; ff_vid_icon = 0;
1298 clip_vframe = 0; clip_icon = 0;
1299 atransition_vframe = 0; atransition_icon = 0;
1300 vtransition_vframe = 0; vtransition_icon = 0;
1301 aeffect_vframe = 0; aeffect_icon = 0;
1302 veffect_vframe = 0; veffect_icon = 0;
1304 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1306 effectlist_menu = 0;
1311 folderlist_menu = 0;
1314 allow_iconlisting = 1;
1318 vicon_drawing = AVICON_FULL_PLAY;
1321 displayed_folder = AW_NO_FOLDER;
1322 new_folder_thread = 0;
1323 modify_folder_thread = 0;
1324 folder_lock = new Mutex("AWindowGUI::folder_lock");
1327 AWindowGUI::~AWindowGUI()
1329 assets.remove_all_objects();
1330 folders.remove_all_objects();
1331 aeffects.remove_all_objects();
1332 veffects.remove_all_objects();
1333 atransitions.remove_all_objects();
1334 vtransitions.remove_all_objects();
1335 labellist.remove_all_objects();
1336 displayed_assets[1].remove_all_objects();
1338 delete new_folder_thread;
1339 delete modify_folder_thread;
1340 delete vicon_thread;
1345 delete remove_plugin;
1347 delete file_vframe; delete file_icon;
1348 delete folder_vframe; delete folder_icon;
1349 delete audio_vframe; delete audio_icon;
1350 delete video_vframe; delete video_icon;
1351 delete label_vframe; delete label_icon;
1352 delete clip_vframe; delete clip_icon;
1353 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1354 delete atransition_folder_vframe; delete atransition_folder_icon;
1355 delete veffect_folder_vframe; delete veffect_folder_icon;
1356 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1357 delete clip_folder_vframe; delete clip_folder_icon;
1358 delete label_folder_vframe; delete label_folder_icon;
1359 delete media_folder_vframe; delete media_folder_icon;
1360 delete proxy_folder_vframe; delete proxy_folder_icon;
1361 delete ladspa_vframe; delete ladspa_icon;
1362 delete ff_aud_vframe; delete ff_aud_icon;
1363 delete ff_vid_vframe; delete ff_vid_icon;
1364 delete atransition_vframe; delete atransition_icon;
1365 delete vtransition_vframe; delete vtransition_icon;
1366 delete aeffect_vframe; delete aeffect_icon;
1367 delete veffect_vframe; delete veffect_icon;
1371 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1373 return icon == file_icon ||
1374 icon == folder_icon ||
1375 icon == audio_icon ||
1376 icon == video_icon ||
1377 icon == clip_icon ||
1378 icon == label_icon ||
1379 icon == vtransition_icon ||
1380 icon == atransition_icon ||
1381 icon == veffect_icon ||
1382 icon == aeffect_icon ||
1383 icon == ladspa_icon ||
1384 icon == ff_aud_icon ||
1385 icon == ff_vid_icon ||
1386 icon == aeffect_folder_icon ||
1387 icon == veffect_folder_icon ||
1388 icon == atransition_folder_icon ||
1389 icon == vtransition_folder_icon ||
1390 icon == label_folder_icon ||
1391 icon == clip_folder_icon ||
1392 icon == media_folder_icon ||
1393 icon == proxy_folder_icon;
1396 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1398 char png_path[BCTEXTLEN];
1399 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1400 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1401 File::get_plugin_path(), plugin_icons, name);
1402 if( access(png_path, R_OK) ) return 0;
1403 return VFramePng::vframe_png(png_path,0,0);
1406 VFrame *AWindowGUI::get_picon(const char *name)
1408 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1410 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1411 snprintf(pp, ep-pp, "%s.png", name);
1412 unsigned char *data = mwindow->theme->get_image_data(png_name);
1413 if( data ) vframe = new VFramePng(data, 0.);
1418 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1420 vfrm = get_picon(fn);
1421 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1422 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1424 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1426 vfrm = get_picon(fn);
1427 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1428 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1430 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1432 vfrm = get_picon(fn);
1433 if( !vfrm ) vfrm = new VFramePng(png);
1434 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1437 void AWindowGUI::create_objects()
1439 int ys5 = yS(5), ys10 = yS(10);
1440 lock_window("AWindowGUI::create_objects");
1441 asset_titles[0] = C_("Title");
1442 asset_titles[1] = _("Comments");
1444 set_icon(mwindow->theme->get_image("awindow_icon"));
1446 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1447 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1448 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1449 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1450 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1452 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1453 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1454 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1455 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1456 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1457 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1458 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1459 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1461 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1462 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1463 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1464 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1465 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1466 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1467 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1468 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1470 theme_icon(clip_vframe, clip_icon, "clip_icon");
1471 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1472 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1473 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1474 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1476 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1477 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1478 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1479 folder_lock->lock("AWindowGUI::create_objects");
1480 // Mandatory folders
1481 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1482 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1483 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1484 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1485 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1486 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1487 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1488 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1490 create_label_folder();
1491 folder_lock->unlock();
1493 mwindow->theme->get_awindow_sizes(this);
1494 load_defaults(mwindow->defaults);
1495 new_folder_thread = new NewFolderThread(this);
1496 modify_folder_thread = new ModifyFolderThread(this);
1498 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1499 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1500 search_text = new AWindowSearchText(mwindow, this, x1, y1+ys5);
1501 search_text->create_objects();
1502 int dy = search_text->get_h() + ys10;
1504 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1506 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1507 asset_list->update_vicon_area();
1508 vicon_thread->start();
1509 vicon_audio = new AssetVIconAudio(this);
1511 add_subwindow(divider = new AWindowDivider(mwindow, this,
1512 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1513 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1515 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1517 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1518 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1519 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1520 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1521 for( int i=0; i<n; ++i ) {
1522 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1523 if( tw < nw ) tw = nw;
1525 int pw = BC_PopupMenu::calculate_w(xS(16), tw, 1);
1526 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1527 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1528 avicon_drawing->create_objects();
1529 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1530 add_tools->create_objects();
1531 fy += add_tools->get_h(); fh -= add_tools->get_h();
1532 add_subwindow(folder_list = new AWindowFolders(mwindow,
1533 this, fx, fy, fw, fh));
1535 folder_list->load_expanders();
1537 //int x = mwindow->theme->abuttons_x;
1538 //int y = mwindow->theme->abuttons_y;
1540 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1541 asset_menu->create_objects();
1542 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1543 clip_menu->create_objects();
1544 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1545 label_menu->create_objects();
1546 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1547 proxy_menu->create_objects();
1549 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1550 effectlist_menu->create_objects();
1551 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1552 assetlist_menu->create_objects();
1553 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1554 cliplist_menu->create_objects();
1555 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1556 labellist_menu->create_objects();
1557 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1558 proxylist_menu->create_objects();
1560 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1561 folderlist_menu->create_objects();
1563 create_custom_xatoms();
1567 int AWindowGUI::resize_event(int w, int h)
1569 mwindow->session->awindow_x = get_x();
1570 mwindow->session->awindow_y = get_y();
1571 mwindow->session->awindow_w = w;
1572 mwindow->session->awindow_h = h;
1574 mwindow->theme->get_awindow_sizes(this);
1575 mwindow->theme->draw_awindow_bg(this);
1576 reposition_objects();
1578 // int x = mwindow->theme->abuttons_x;
1579 // int y = mwindow->theme->abuttons_y;
1580 // new_bin->reposition_window(x, y);
1581 // x += new_bin->get_w();
1582 // delete_bin->reposition_window(x, y);
1583 // x += delete_bin->get_w();
1584 // rename_bin->reposition_window(x, y);
1585 // x += rename_bin->get_w();
1586 // delete_disk->reposition_window(x, y);
1587 // x += delete_disk->get_w();
1588 // delete_project->reposition_window(x, y);
1589 // x += delete_project->get_w();
1590 // info->reposition_window(x, y);
1591 // x += info->get_w();
1592 // redraw_index->reposition_window(x, y);
1593 // x += redraw_index->get_w();
1594 // paste->reposition_window(x, y);
1595 // x += paste->get_w();
1596 // append->reposition_window(x, y);
1597 // x += append->get_w();
1598 // view->reposition_window(x, y);
1600 BC_WindowBase::resize_event(w, h);
1601 asset_list->update_vicon_area();
1605 int AWindowGUI::translation_event()
1607 mwindow->session->awindow_x = get_x();
1608 mwindow->session->awindow_y = get_y();
1612 void AWindowGUI::reposition_objects()
1614 int ys5 = yS(5), ys10 = yS(10);
1615 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1616 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1617 search_text->reposition_window(x1, y1+ys5, w1);
1618 int dy = search_text->get_h() + ys10;
1620 asset_list->reposition_window(x1, y1, w1, h1);
1621 divider->reposition_window(
1622 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1623 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1624 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1625 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1626 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1627 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1628 fy += add_tools->get_h(); fh -= add_tools->get_h();
1629 folder_list->reposition_window(fx, fy, fw, fh);
1632 int AWindowGUI::save_defaults(BC_Hash *defaults)
1634 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1635 defaults->update("VICON_DRAWING", vicon_drawing);
1636 defaults->update("TIP_INFO", tip_info);
1640 int AWindowGUI::load_defaults(BC_Hash *defaults)
1642 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1643 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1644 tip_info = defaults->get("TIP_INFO", tip_info);
1648 int AWindowGUI::close_event()
1651 mwindow->session->show_awindow = 0;
1654 mwindow->gui->lock_window("AWindowGUI::close_event");
1655 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1656 mwindow->gui->unlock_window();
1658 lock_window("AWindowGUI::close_event");
1659 save_defaults(mwindow->defaults);
1660 mwindow->save_defaults();
1664 int AWindowGUI::start_vicon_drawing()
1666 if( play_off ) return stop_vicon_drawing();
1667 if( !vicon_thread->interrupted ) return 1;
1668 switch( vicon_drawing ) {
1669 case AVICON_FULL_PLAY: // all vicons, viewing, target
1671 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1672 if( vicon_thread->solo ) break;
1674 case AVICON_SRC_TARGET: // no vicons, no view, target
1675 case AVICON_NO_PLAY: // no vicons, no view, no target
1678 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1679 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1680 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1681 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1682 switch( mwindow->edl->session->assetlist_format ) {
1684 case ASSETS_ICONS_PACKED:
1685 case ASSETS_ICON_LIST:
1686 asset_list->update_vicon_area();
1687 vicon_thread->start_drawing();
1696 int AWindowGUI::stop_vicon_drawing(int wait)
1698 vicon_thread->stop_vicon_drawing(wait);
1703 VFrame *AssetPicon::get_vicon_frame()
1705 if( !vicon ) return 0;
1706 if( gui->vicon_thread->interrupted ) return 0;
1707 VFrame *frame = vicon->frame();
1708 if( !frame ) return 0;
1710 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1711 vicon_frame->transfer_from(frame);
1715 int AWindowGUI::cycle_assetlist_format()
1717 EDLSession *session = mwindow->edl->session;
1718 int format = ASSETS_TEXT;
1719 if( allow_iconlisting ) {
1720 switch( session->assetlist_format ) {
1722 format = ASSETS_ICONS;
1725 format = ASSETS_ICONS_PACKED;
1727 case ASSETS_ICONS_PACKED:
1728 format = ASSETS_ICON_LIST;
1730 case ASSETS_ICON_LIST:
1731 format = ASSETS_TEXT;
1735 stop_vicon_drawing();
1736 session->assetlist_format = format;
1737 asset_list->update_format(session->assetlist_format, 0);
1738 async_update_assets();
1739 start_vicon_drawing();
1743 void AWindowGUI::hide_tip_info()
1745 asset_list->hide_tooltip();
1749 AWindowRemovePluginGUI::
1750 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1751 int x, int y, PluginServer *plugin)
1752 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y,
1753 xS(500),yS(200), xS(50), yS(50),
1756 this->awindow = awindow;
1757 this->thread = thread;
1758 this->plugin = plugin;
1759 VFrame *vframe = plugin->get_picon();
1760 icon = vframe ? create_pixmap(vframe) : 0;
1761 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1764 AWindowRemovePluginGUI::
1765 ~AWindowRemovePluginGUI()
1767 if( !awindow->gui->protected_pixmap(icon) )
1769 plugin_list.remove_all();
1772 void AWindowRemovePluginGUI::create_objects()
1774 int xs10 = xS(10), xs20 = xS(20);
1775 int ys5 = yS(5), ys10 = yS(10);
1776 lock_window("AWindowRemovePluginGUI::create_objects");
1777 BC_Button *ok_button = new BC_OKButton(this);
1778 add_subwindow(ok_button);
1779 BC_Button *cancel_button = new BC_CancelButton(this);
1780 add_subwindow(cancel_button);
1781 int x = xs10, y = ys10;
1782 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1783 add_subwindow(title);
1784 y += title->get_h() + ys5;
1785 list = new BC_ListBox(x, y,
1786 get_w() - xs20, ok_button->get_y() - y - ys5, LISTBOX_TEXT, &plugin_list,
1787 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1788 add_subwindow(list);
1793 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1796 for( int i=0; i<folder.size(); ) {
1797 AssetPicon *picon = (AssetPicon *)folder[i];
1798 if( picon->plugin == plugin ) {
1799 folder.remove_object_number(i);
1808 void AWindowRemovePlugin::handle_close_event(int result)
1811 printf(_("remove %s\n"), plugin->path);
1812 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1813 ArrayList<BC_ListBoxItem*> *folder =
1814 plugin->audio ? plugin->transition ?
1815 &awindow->gui->atransitions :
1816 &awindow->gui->aeffects :
1817 plugin->video ? plugin->transition ?
1818 &awindow->gui->vtransitions :
1819 &awindow->gui->veffects :
1821 if( folder ) remove_plugin(plugin, *folder);
1822 MWindow *mwindow = awindow->mwindow;
1823 awindow->gui->unlock_window();
1824 char plugin_path[BCTEXTLEN];
1825 strcpy(plugin_path, plugin->path);
1826 mwindow->plugindb->remove(plugin);
1827 remove(plugin_path);
1828 char index_path[BCTEXTLEN];
1829 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1831 char picon_path[BCTEXTLEN];
1833 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1834 File::get_plugin_path());
1835 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1836 plugin->get_plugin_png_name(png_name);
1837 fs.update(picon_path);
1838 for( int i=0; i<fs.dir_list.total; ++i ) {
1839 char *fs_path = fs.dir_list[i]->path;
1840 if( !fs.is_dir(fs_path) ) continue;
1841 snprintf(png_path, sizeof(picon_path), "%s/%s",
1845 delete plugin; plugin = 0;
1846 awindow->gui->async_update_assets();
1850 AWindowRemovePlugin::
1851 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1854 this->awindow = awindow;
1855 this->plugin = plugin;
1858 AWindowRemovePlugin::
1859 ~AWindowRemovePlugin()
1864 BC_Window* AWindowRemovePlugin::new_gui()
1866 int x = awindow->gui->get_abs_cursor_x(0);
1867 int y = awindow->gui->get_abs_cursor_y(0);
1868 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1869 gui->create_objects();
1873 int AWindowGUI::keypress_event()
1875 switch( get_keypress() ) {
1883 tip_info = !tip_info ? 1 : 0;
1884 if( !tip_info ) hide_tip_info();
1887 if( !ctrl_down() && !shift_down() ) {
1888 assetlist_menu->load_file->handle_event();
1893 return cycle_assetlist_format();
1895 if( shift_down() && ctrl_down() ) {
1896 PluginServer* plugin = selected_plugin();
1897 if( !plugin ) break;
1898 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1900 remove_plugin->start();
1901 lock_window("AWindowGUI::keypress_event 1");
1905 if( shift_down() ) {
1906 mwindow->awindow->asset_remove->start();
1910 mwindow->remove_assets_from_project(1, 1, 1,
1911 mwindow->session->drag_assets,
1912 mwindow->session->drag_clips);
1913 lock_window("AWindowGUI::keypress_event 2");
1919 if( shift_down() && ctrl_down() ) {
1920 resend_event(mwindow->gui);
1930 int AWindowGUI::create_custom_xatoms()
1932 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1935 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1937 if( event->message_type == UpdateAssetsXAtom ) {
1944 void AWindowGUI::async_update_assets()
1947 event.message_type = UpdateAssetsXAtom;
1948 send_custom_xatom(&event);
1952 void AWindowGUI::update_folder_list()
1954 for( int i = 0; i < folders.total; i++ ) {
1955 AssetPicon *picon = (AssetPicon*)folders.values[i];
1959 // Search assets for folders
1960 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1961 BinFolder *bin_folder = mwindow->edl->folders[i];
1964 for( int j = 0; j < folders.total; j++ ) {
1965 AssetPicon *picon = (AssetPicon*)folders[j];
1966 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1974 const char *title = bin_folder->title;
1975 int folder = bin_folder->awindow_folder;
1976 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1977 picon->create_objects();
1978 folders.append(picon);
1982 // Delete unused non-persistent folders
1983 int do_autoplace = 0;
1984 for( int i=folders.total; --i>=0; ) {
1985 AssetPicon *picon = (AssetPicon*)folders.values[i];
1986 if( !picon->in_use && !picon->persistent ) {
1988 folders.remove_number(i);
1993 folder_list->set_autoplacement(&folders, 0, 1);
1996 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1997 int do_audio, int do_video, int is_realtime, int is_transition)
1999 ArrayList<PluginServer*> plugin_list;
2000 // Get pointers to plugindb entries
2001 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
2004 for( int i = 0; i < plugin_list.total; i++ ) {
2005 PluginServer *server = plugin_list.values[i];
2006 int visible = plugin_visibility & (1<<server->dir_idx);
2007 if( !visible ) continue;
2008 // Create new listitem
2009 AssetPicon *picon = new AssetPicon(mwindow, this, server);
2010 picon->create_objects();
2011 output->append(picon);
2015 void AWindowGUI::create_label_folder()
2018 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
2019 AssetPicon *picon = new AssetPicon(mwindow, this, current);
2020 picon->create_objects();
2021 labellist.append(picon);
2026 void AWindowGUI::update_asset_list()
2028 ArrayList<AssetPicon *> new_assets;
2029 for( int i = 0; i < assets.total; i++ ) {
2030 AssetPicon *picon = (AssetPicon*)assets.values[i];
2034 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2035 // Synchronize EDL clips
2036 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2039 // Look for clip in existing listitems
2040 for( int j = 0; j < assets.total && !exists; j++ ) {
2041 AssetPicon *picon = (AssetPicon*)assets.values[j];
2043 if( picon->id == mwindow->edl->clips[i]->id ) {
2044 picon->edl = mwindow->edl->clips[i];
2045 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2051 // Create new listitem
2053 AssetPicon *picon = new AssetPicon(mwindow,
2054 this, mwindow->edl->clips[i]);
2055 new_assets.append(picon);
2059 // Synchronize EDL assets
2060 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2063 // Look for asset in existing listitems
2064 for( int j = 0; j < assets.total && !exists; j++ ) {
2065 AssetPicon *picon = (AssetPicon*)assets.values[j];
2067 if( picon->id == current->id ) {
2068 picon->indexable = current;
2074 // Create new listitem
2076 AssetPicon *picon = new AssetPicon(mwindow,
2078 new_assets.append(picon);
2079 if( current->width > ASSET_MAX_WIDTH || current->height > ASSET_MAX_HEIGHT ) {
2080 eprintf(_("Warning: %s\n"
2081 " dimensions %dx%d exceed asset maximum limits %dx%d\n"),
2082 current->path, current->width, current->height,
2083 ASSET_MAX_WIDTH, ASSET_MAX_HEIGHT);
2085 else if( mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
2086 int texture_limit = BC_DisplayInfo::get_gl_max_texture_size();
2087 if( texture_limit >= 0 &&
2088 (current->width >= texture_limit || current->height >= texture_limit) ) {
2089 eprintf(_("Warning: %s\n"
2090 " dimensions %dx%d exceed OpenGL texture limit %d\n"),
2091 current->path, current->width, current->height, texture_limit);
2097 // Synchronize nested EDLs
2098 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2100 EDL *nested_edl = mwindow->edl->nested_edls[i];
2102 // Look for asset in existing listitems
2103 for( int j=0; j<assets.total && !exists; ++j ) {
2104 AssetPicon *picon = (AssetPicon*)assets.values[j];
2106 if( picon->id == nested_edl->id ) {
2107 picon->indexable = nested_edl;
2113 // Create new listitem
2115 AssetPicon *picon = new AssetPicon(mwindow,
2116 this, (Indexable*)nested_edl);
2117 new_assets.append(picon);
2120 mwindow->gui->unlock_window();
2122 for( int i=0; i<new_assets.size(); ++i ) {
2123 AssetPicon *picon = new_assets[i];
2124 picon->create_objects();
2125 if( picon->indexable )
2126 picon->foldernum = AW_MEDIA_FOLDER;
2127 else if( picon->edl )
2128 picon->foldernum = AW_CLIP_FOLDER;
2129 assets.append(picon);
2132 mwindow->gui->lock_window();
2133 mwindow->gui->default_message();
2134 mwindow->gui->unlock_window();
2136 for( int i = assets.size() - 1; i >= 0; i-- ) {
2137 AssetPicon *picon = (AssetPicon*)assets.get(i);
2138 if( !picon->in_use ) {
2140 assets.remove_number(i);
2143 if( picon->indexable && picon->indexable->is_asset ) {
2144 Asset *asset = (Asset *)picon->indexable;
2146 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2147 picon->comments_rate = asset->get_frame_rate();
2148 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2149 picon->comments_type = asset->format == FILE_FFMPEG ?
2150 asset->vcodec : File::formattostr(asset->format);
2155 void AWindowGUI::update_picon(Indexable *indexable)
2158 for( int i = 0; i < assets.total; i++ ) {
2159 AssetPicon *picon = (AssetPicon*)assets.values[i];
2160 if( picon->indexable == indexable ||
2161 picon->edl == (EDL *)indexable ) {
2162 char name[BCTEXTLEN];
2164 fs.extract_name(name, indexable->path);
2165 picon->set_text(name);
2166 vicon = picon->vicon;
2171 stop_vicon_drawing();
2172 vicon->clear_images();
2173 vicon->reset(indexable->get_frame_rate());
2174 start_vicon_drawing();
2178 void AWindowGUI::sort_assets()
2180 folder_lock->lock("AWindowGUI::sort_assets");
2181 switch( mwindow->edl->session->awindow_folder ) {
2182 case AW_AEFFECT_FOLDER:
2183 sort_picons(&aeffects);
2185 case AW_VEFFECT_FOLDER:
2186 sort_picons(&veffects);
2188 case AW_ATRANSITION_FOLDER:
2189 sort_picons(&atransitions);
2191 case AW_VTRANSITION_FOLDER:
2192 sort_picons(&vtransitions);
2194 case AW_LABEL_FOLDER:
2195 sort_picons(&labellist);
2198 sort_picons(&assets);
2202 asset_list->update_format(asset_list->get_format(), 0);
2203 folder_lock->unlock();
2207 void AWindowGUI::sort_folders()
2209 folder_lock->lock("AWindowGUI::update_assets");
2210 // folder_list->collapse_recursive(&folders, 0);
2211 folder_list->set_autoplacement(&folders, 0, 1);
2212 sort_picons(&folders);
2213 folder_list->update_format(folder_list->get_format(), 0);
2214 folder_lock->unlock();
2218 EDL *AWindowGUI::collect_proxy(Asset *proxy_asset)
2220 char path[BCTEXTLEN];
2221 int proxy_scale = mwindow->edl->session->proxy_scale;
2222 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2223 Indexable *unproxy_idxbl =
2224 proxy_asset->proxy_edl ?
2225 (Indexable *) mwindow->edl->get_nested_edl(path) :
2226 (Indexable *) mwindow->edl->assets->get_asset(path);
2227 if( !unproxy_idxbl || !unproxy_idxbl->get_video_layers() ) return 0;
2228 // make a clip from proxy video tracks and unproxy audio tracks
2229 EDL *proxy_edl = new EDL(mwindow->edl);
2230 proxy_edl->create_objects();
2231 proxy_edl->set_path(proxy_asset->path);
2232 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2233 strcpy(proxy_edl->local_session->clip_title, path);
2234 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2235 proxy_edl->session->video_tracks = proxy_asset->layers;
2236 proxy_edl->session->audio_tracks = unproxy_idxbl->get_audio_channels();
2237 proxy_edl->create_default_tracks();
2238 double length = proxy_asset->frame_rate > 0 ?
2239 ( proxy_asset->video_length >= 0 ?
2240 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2241 ( proxy_edl->session->si_useduration ?
2242 proxy_edl->session->si_duration :
2243 1.0 / proxy_asset->frame_rate ) ) :
2244 1.0 / proxy_edl->session->frame_rate;
2245 Track *current = proxy_edl->tracks->first;
2246 for( int vtrack=0; current; current=NEXT ) {
2247 if( current->data_type != TRACK_VIDEO ) continue;
2248 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2250 int64_t samples = unproxy_idxbl->get_audio_samples();
2251 int sample_rate = unproxy_idxbl->get_sample_rate();
2252 length = sample_rate > 0 ? (double)samples / sample_rate : 0;
2253 current = proxy_edl->tracks->first;
2254 for( int atrack=0; current; current=NEXT ) {
2255 if( current->data_type != TRACK_AUDIO ) continue;
2256 Asset *asset = unproxy_idxbl->is_asset ? (Asset *)unproxy_idxbl : 0;
2257 EDL *nested_edl = unproxy_idxbl->is_asset ? 0 : (EDL *)unproxy_idxbl;
2258 current->insert_asset(asset, nested_edl, length, 0, atrack++);
2260 proxy_edl->folder_no = AW_PROXY_FOLDER;
2265 void AWindowGUI::collect_assets(int proxy)
2267 mwindow->session->drag_assets->remove_all();
2268 mwindow->session->drag_clips->remove_all();
2269 int i = 0; AssetPicon *result;
2270 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2271 Indexable *indexable = result->indexable;
2272 if( proxy && indexable && indexable->is_asset &&
2273 indexable->folder_no == AW_PROXY_FOLDER ) {
2274 EDL *drag_edl = collect_proxy((Asset*)indexable);
2275 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2279 mwindow->session->drag_assets->append(indexable);
2283 mwindow->session->drag_clips->append(result->edl);
2289 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2291 // Remove current pointers
2292 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2293 dst[0].remove_all();
2294 dst[1].remove_all_objects();
2296 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2297 int folder = mwindow->edl->session->awindow_folder;
2298 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2299 mwindow->edl->get_folder(folder);
2301 // Create new pointers
2302 for( int i = 0; i < src->total; i++ ) {
2303 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2304 picon = (AssetPicon*)src->values[i];
2305 picon->sort_key = -1;
2306 if( !visible && bin_folder ) {
2307 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2308 picon->indexable ? picon->indexable :
2309 picon->edl ? picon->edl->get_proxy_asset() : 0;
2311 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2312 if( picon->sort_key < 0 ) continue;
2316 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2318 if( !visible && picon->edl && picon->edl->folder_no == folder )
2320 if( visible && sub_items ) {
2321 if( !sub_items->matches(picon->get_text()) )
2325 const char *text = search_text->get_text();
2326 if( text && text[0] )
2327 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2329 if( visible && picon->vicon && picon->vicon->hidden )
2330 picon->vicon->hidden = 0;
2332 BC_ListBoxItem *item2, *item1;
2333 dst[0].append(item1 = picon);
2335 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2338 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2339 else if( picon->comments_time ) {
2340 char date_time[BCSTRLEN];
2341 struct tm stm; localtime_r(&picon->comments_time, &stm);
2342 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2343 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2344 stm.tm_hour, stm.tm_min, stm.tm_sec,
2345 picon->comments_rate, picon->comments_ffmt,
2346 picon->comments_type);
2347 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2350 dst[1].append(item2 = new BC_ListBoxItem(""));
2351 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2352 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2357 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2359 int done = 0, changed = 0;
2362 for( int i=0; i<src->total-1; ++i ) {
2363 AssetPicon *item1 = (AssetPicon *)src->values[i];
2364 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2365 double v = item2->sort_key - item1->sort_key;
2366 if( v > 0 ) continue;
2368 const char *cp1 = item1->get_text();
2369 const char *bp1 = strrchr(cp1, '/');
2370 if( bp1 ) cp1 = bp1 + 1;
2371 const char *cp2 = item2->get_text();
2372 const char *bp2 = strrchr(cp2, '/');
2373 if( bp2 ) cp2 = bp2 + 1;
2374 if( strcmp(cp2, cp1) >= 0 ) continue;
2376 src->values[i + 1] = item1;
2377 src->values[i] = item2;
2378 done = 0; changed = 1;
2382 for( int i=0; i<src->total; ++i ) {
2383 AssetPicon *item = (AssetPicon *)src->values[i];
2384 item->set_autoplace_icon(1);
2385 item->set_autoplace_text(1);
2390 void AWindowGUI::filter_displayed_assets()
2392 //allow_iconlisting = 1;
2393 asset_titles[0] = C_("Title");
2394 asset_titles[1] = _("Comments");
2395 AssetPicon *picon = 0;
2396 int selected_folder = mwindow->edl->session->awindow_folder;
2397 // Ensure the current folder icon is highlighted
2398 for( int i = 0; i < folders.total; i++ ) {
2399 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2400 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2401 folder_item->set_selected(selected);
2402 if( selected ) picon = folder_item;
2405 ArrayList<BC_ListBoxItem*> *src = &assets;
2406 switch( selected_folder ) {
2407 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2408 case AW_VEFFECT_FOLDER: src = &veffects; break;
2409 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2410 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2411 case AW_LABEL_FOLDER: src = &labellist;
2412 asset_titles[0] = _("Time Stamps");
2413 asset_titles[1] = C_("Title");
2414 //allow_iconlisting = 0;
2417 copy_picons(picon, src);
2421 void AWindowGUI::update_assets()
2423 stop_vicon_drawing();
2424 folder_lock->lock("AWindowGUI::update_assets");
2425 update_folder_list();
2426 update_asset_list();
2427 labellist.remove_all_objects();
2428 create_label_folder();
2430 if( displayed_folder != mwindow->edl->session->awindow_folder )
2431 search_text->clear();
2432 vicon_thread->hide_vicons();
2433 filter_displayed_assets();
2434 folder_lock->unlock();
2436 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2437 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2439 int folder_xposition = folder_list->get_xposition();
2440 int folder_yposition = folder_list->get_yposition();
2441 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2443 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2444 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2446 int asset_xposition = asset_list->get_xposition();
2447 int asset_yposition = asset_list->get_yposition();
2448 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2449 displayed_folder = mwindow->edl->session->awindow_folder;
2450 asset_xposition = asset_yposition = 0;
2452 asset_list->update(displayed_assets, asset_titles,
2453 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2454 asset_xposition, asset_yposition, -1, 0);
2455 asset_list->center_selection();
2458 start_vicon_drawing();
2462 void AWindowGUI::update_effects()
2464 aeffects.remove_all_objects();
2465 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2466 veffects.remove_all_objects();
2467 create_persistent_folder(&veffects, 0, 1, 1, 0);
2468 atransitions.remove_all_objects();
2469 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2470 vtransitions.remove_all_objects();
2471 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2474 int AWindowGUI::drag_motion()
2476 if( get_hidden() ) return 0;
2482 int AWindowGUI::drag_stop()
2484 if( get_hidden() ) return 0;
2488 Indexable* AWindowGUI::selected_asset()
2490 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2491 return picon ? picon->indexable : 0;
2494 PluginServer* AWindowGUI::selected_plugin()
2496 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2497 return picon ? picon->plugin : 0;
2500 AssetPicon* AWindowGUI::selected_folder()
2502 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2513 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2514 : BC_SubWindow(x, y, w, h)
2516 this->mwindow = mwindow;
2519 AWindowDivider::~AWindowDivider()
2523 int AWindowDivider::button_press_event()
2525 if( is_event_win() && cursor_inside() ) {
2526 mwindow->session->current_operation = DRAG_PARTITION;
2532 int AWindowDivider::cursor_motion_event()
2534 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2536 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2537 int fw = gui->get_relative_cursor_x();
2538 if( fw > wmax ) fw = wmax;
2539 if( fw < wmin ) fw = wmin;
2540 mwindow->session->afolders_w = fw;
2541 mwindow->theme->get_awindow_sizes(gui);
2542 gui->reposition_objects();
2548 int AWindowDivider::button_release_event()
2550 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2551 mwindow->session->current_operation = NO_OPERATION;
2562 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2563 : BC_ListBox(x, y, w, h,
2564 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2565 LISTBOX_ICONS : LISTBOX_TEXT,
2566 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2567 0, // Titles for columns. Set to 0 for no titles
2568 0, // width of each column
2569 1, // Total columns.
2570 0, // Pixel of top of window.
2571 0, // If this listbox is a popup window
2572 LISTBOX_SINGLE, // Select one item or multiple items
2573 ICON_TOP, // Position of icon relative to text of each item
2576 this->mwindow = mwindow;
2583 AWindowFolders::~AWindowFolders()
2587 int AWindowFolders::selection_changed()
2589 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2590 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2591 // prefer expanded entry
2592 AWindowFolderItem *item = item1 ? item1 : item0;
2593 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2594 item1->set_selected(0);
2601 AssetPicon *picon = item->get_picon();
2602 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2604 gui->stop_vicon_drawing();
2606 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2607 gui->folderlist_menu->update_titles();
2608 gui->folderlist_menu->activate_menu();
2611 mwindow->edl->session->awindow_folder = picon->foldernum;
2612 gui->asset_list->draw_background();
2613 gui->async_update_assets();
2615 gui->start_vicon_drawing();
2620 int AWindowFolders::button_press_event()
2622 gui->hide_tip_info();
2623 int result = BC_ListBox::button_press_event();
2626 if( get_buttonpress() == RIGHT_BUTTON &&
2627 is_event_win() && cursor_inside() ) {
2628 gui->folderlist_menu->update_titles();
2629 gui->folderlist_menu->activate_menu();
2637 int AWindowFolders::drag_stop()
2640 if( get_hidden() ) return 0;
2641 if( mwindow->session->current_operation == DRAG_ASSET &&
2642 gui->folder_list->cursor_above() ) { // check user folder
2643 int item_no = gui->folder_list->get_cursor_data_item_no();
2644 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2645 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2646 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2647 ArrayList<Indexable *> *drags = folder->is_clips ?
2648 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2649 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2650 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2652 mwindow->session->current_operation = ::NO_OPERATION;
2659 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2660 : AWindowFolderItem(text)
2662 this->parent = parent;
2665 int AWindowFolders::load_expanders()
2667 char expanders_path[BCTEXTLEN];
2668 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2669 FILE *fp = fopen(expanders_path, "r");
2671 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2672 File::get_cindat_path(), EXPANDERS_FILE);
2673 char *cp = strrchr(expanders_path,'.');
2674 if( cp ) strcpy(cp+1, mwindow->cin_lang);
2675 fp = fopen(expanders_path, "r");
2678 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2679 File::get_cindat_path(), EXPANDERS_FILE);
2680 fp = fopen(expanders_path, "r");
2683 const char tab = '\t';
2684 char line[BCTEXTLEN]; line[0] = 0;
2685 AWindowFolderItem *item = 0, *parent;
2686 AWindowFolderSubItems *sub_items = 0;
2688 while( fgets(line,sizeof(line),fp) ) {
2689 if( line[0] == '#' ) continue;
2690 int i = strlen(line);
2691 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2692 if( i == 0 ) continue;
2694 for( char *cp=line; *cp==tab; ++cp ) ++i;
2696 int i = gui->folders.size();
2698 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2699 if( !strcmp(folder->get_text(),_(line)) ) break;
2701 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2706 if( i > k+1 ) continue;
2708 if( line[i] != '-' && sub_items ) {
2709 sub_items->names.append(cstrdup(_(&line[i])));
2717 item = item->parent;
2720 parent = item->parent;
2722 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2723 if( !sublist ) sublist = parent->new_sublist(1);
2724 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2725 sublist->append(item = sub_items);
2732 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2733 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2734 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2735 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2736 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2738 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2739 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2740 mwindow->edl->session->asset_columns, // width of each column
2741 1, // Total columns.
2742 0, // Pixel of top of window.
2743 0, // If this listbox is a popup window
2744 LISTBOX_MULTIPLE, // Select one item or multiple items
2745 ICON_TOP, // Position of icon relative to text of each item
2746 -1) // Allow drags, require shift for scrolling
2748 this->mwindow = mwindow;
2750 this->info_tip = -1;
2752 set_scroll_stretch(1, 1);
2755 AWindowAssets::~AWindowAssets()
2759 int AWindowAssets::button_press_event()
2762 AssetVIconThread *avt = gui->vicon_thread;
2763 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2764 int dir = 1, button = get_buttonpress();
2766 case WHEEL_DOWN: dir = -1; // fall thru
2768 int x = get_cursor_x(), y = get_cursor_y();
2769 if( avt->cursor_inside(x, y) && avt->view_win )
2770 avt->zoom_scale(dir);
2775 int result = BC_ListBox::button_press_event();
2777 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2778 is_event_win() && cursor_inside() ) {
2779 BC_ListBox::deactivate_selection();
2780 int folder = mwindow->edl->session->awindow_folder;
2782 case AW_AEFFECT_FOLDER:
2783 case AW_VEFFECT_FOLDER:
2784 case AW_ATRANSITION_FOLDER:
2785 case AW_VTRANSITION_FOLDER:
2786 gui->effectlist_menu->update();
2787 gui->effectlist_menu->activate_menu();
2789 case AW_LABEL_FOLDER:
2790 gui->labellist_menu->update();
2791 gui->labellist_menu->activate_menu();
2793 case AW_CLIP_FOLDER:
2794 gui->cliplist_menu->update();
2795 gui->cliplist_menu->activate_menu();
2797 case AW_PROXY_FOLDER:
2798 gui->proxylist_menu->update();
2799 gui->proxylist_menu->activate_menu();
2802 case AW_MEDIA_FOLDER: {
2803 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2804 gui->assetlist_menu->update_titles(shots);
2805 gui->assetlist_menu->activate_menu();
2815 int AWindowAssets::handle_event()
2817 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2818 if( !asset_picon ) return 0;
2819 Indexable *picon_idxbl = asset_picon->indexable;
2820 EDL *picon_edl = asset_picon->edl;
2822 VWindow *vwindow = 0;
2823 switch( mwindow->edl->session->awindow_folder ) {
2824 case AW_AEFFECT_FOLDER:
2825 case AW_VEFFECT_FOLDER:
2826 case AW_ATRANSITION_FOLDER:
2827 case AW_VTRANSITION_FOLDER: return 1;
2828 case AW_PROXY_FOLDER:
2829 proxy = 1; // fall thru
2831 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2832 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2835 if( !vwindow || !vwindow->is_running() ) return 1;
2836 if( proxy && picon_idxbl && picon_idxbl->is_asset ) {
2837 picon_edl = gui->collect_proxy((Asset*)picon_idxbl);
2841 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2842 else if( picon_edl ) vwindow->change_source(picon_edl);
2846 int AWindowAssets::selection_changed()
2848 // Show popup window
2850 int folder = mwindow->edl->session->awindow_folder;
2851 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2852 (item = (AssetPicon*)get_selection(0, 0)) ) {
2854 case AW_AEFFECT_FOLDER:
2855 case AW_VEFFECT_FOLDER:
2856 case AW_ATRANSITION_FOLDER:
2857 case AW_VTRANSITION_FOLDER:
2858 gui->effectlist_menu->update();
2859 gui->effectlist_menu->activate_menu();
2861 case AW_LABEL_FOLDER:
2862 if( !item->label ) break;
2863 gui->label_menu->activate_menu();
2865 case AW_CLIP_FOLDER:
2866 if( !item->indexable && !item->edl ) break;
2867 gui->clip_menu->update();
2868 gui->clip_menu->activate_menu();
2870 case AW_PROXY_FOLDER:
2871 if( !item->indexable && !item->edl ) break;
2872 gui->proxy_menu->update();
2873 gui->proxy_menu->activate_menu();
2876 if( !item->indexable && !item->edl ) break;
2877 gui->asset_menu->update();
2878 gui->asset_menu->activate_menu();
2882 deactivate_selection();
2884 else if( get_button_down() && get_buttonpress() == LEFT_BUTTON &&
2885 get_double_click() ) {
2886 item = (AssetPicon*)get_selection(0, 0);
2889 case AW_LABEL_FOLDER:
2890 if( !item->label ) break;
2891 mwindow->set_position(item->label->position);
2896 else if( get_button_down() && !gui->play_off &&
2897 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2898 item = (AssetPicon*)get_selection(0, 0);
2899 if( item && !get_selection(0, 1) ) {
2901 case AW_MEDIA_FOLDER:
2902 case AW_PROXY_FOLDER:
2903 case AWINDOW_USER_FOLDERS:
2904 if( get_buttonpress() == LEFT_BUTTON ||
2905 get_buttonpress() == MIDDLE_BUTTON ) {
2906 AssetVIcon *vicon = 0;
2907 AssetVIconThread *avt = gui->vicon_thread;
2908 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2909 vicon = item->vicon;
2910 int draw_mode = !vicon ?
2912 get_buttonpress() == MIDDLE_BUTTON ?
2913 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2914 avt->set_view_popup(vicon, draw_mode);
2917 case AW_CLIP_FOLDER:
2918 if( get_buttonpress() == LEFT_BUTTON ) {
2919 AssetVIcon *vicon = 0;
2920 AssetVIconThread *avt = gui->vicon_thread;
2921 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2922 vicon = item->vicon;
2923 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2929 gui->vicon_thread->set_view_popup(0);
2930 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2931 gui->stop_vicon_drawing();
2937 void AWindowAssets::draw_background()
2939 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2940 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2941 set_font(LARGEFONT);
2942 int folder = mwindow->edl->session->awindow_folder;
2943 const char *title = mwindow->edl->get_folder_name(folder);
2944 draw_text(get_w() - get_text_width(LARGEFONT, title) - xS(4), yS(30),
2945 title, -1, get_bg_surface());
2948 int AWindowAssets::drag_start_event()
2950 gui->vicon_thread->set_view_popup(0);
2951 int collect_pluginservers = 0;
2952 int collect_assets = 0, proxy = 0;
2954 if( BC_ListBox::drag_start_event() ) {
2955 switch( mwindow->edl->session->awindow_folder ) {
2956 case AW_AEFFECT_FOLDER:
2957 mwindow->session->current_operation = DRAG_AEFFECT;
2958 collect_pluginservers = 1;
2960 case AW_VEFFECT_FOLDER:
2961 mwindow->session->current_operation = DRAG_VEFFECT;
2962 collect_pluginservers = 1;
2964 case AW_ATRANSITION_FOLDER:
2965 mwindow->session->current_operation = DRAG_ATRANSITION;
2966 collect_pluginservers = 1;
2968 case AW_VTRANSITION_FOLDER:
2969 mwindow->session->current_operation = DRAG_VTRANSITION;
2970 collect_pluginservers = 1;
2972 case AW_LABEL_FOLDER:
2975 case AW_PROXY_FOLDER:
2976 proxy = 1; // fall thru
2977 case AW_MEDIA_FOLDER:
2979 mwindow->session->current_operation = DRAG_ASSET;
2984 if( collect_pluginservers ) {
2986 mwindow->session->drag_pluginservers->remove_all();
2989 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2990 if( !result ) break;
2992 mwindow->session->drag_pluginservers->append(result->plugin);
2996 if( collect_assets ) {
2997 gui->collect_assets(proxy);
3005 int AWindowAssets::drag_motion_event()
3007 BC_ListBox::drag_motion_event();
3010 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3011 mwindow->gui->drag_motion();
3012 mwindow->gui->unlock_window();
3014 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
3015 VWindow *vwindow = mwindow->vwindows.get(i);
3016 if( !vwindow->is_running() ) continue;
3017 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3018 vwindow->gui->drag_motion();
3019 vwindow->gui->unlock_window();
3022 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3023 mwindow->cwindow->gui->drag_motion();
3024 mwindow->cwindow->gui->unlock_window();
3026 lock_window("AWindowAssets::drag_motion_event");
3027 if( mwindow->session->current_operation == DRAG_ASSET &&
3028 gui->folder_list->cursor_above() ) { // highlight user folder
3029 BC_ListBoxItem *item = 0;
3030 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
3031 if( item_no >= 0 ) {
3032 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
3033 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
3036 item_no = gui->folder_list->item_to_index(&gui->folders, item);
3037 int folder_xposition = gui->folder_list->get_xposition();
3038 int folder_yposition = gui->folder_list->get_yposition();
3039 gui->folder_list->update(&gui->folders, 0, 0, 1,
3040 folder_xposition, folder_yposition, item_no, 0, 1);
3045 int AWindowAssets::drag_stop_event()
3049 result = gui->drag_stop();
3054 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3055 result = mwindow->gui->drag_stop();
3056 mwindow->gui->unlock_window();
3060 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
3061 VWindow *vwindow = mwindow->vwindows.get(i);
3062 if( !vwindow ) continue;
3063 if( !vwindow->is_running() ) continue;
3064 if( vwindow->gui->is_hidden() ) continue;
3065 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3066 if( vwindow->gui->cursor_above() &&
3067 vwindow->gui->get_cursor_over_window() ) {
3068 result = vwindow->gui->drag_stop();
3070 vwindow->gui->unlock_window();
3075 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3076 result = mwindow->cwindow->gui->drag_stop();
3077 mwindow->cwindow->gui->unlock_window();
3080 lock_window("AWindowAssets::drag_stop_event");
3082 result = gui->folder_list->drag_stop();
3087 get_drag_popup()->set_animation(0);
3089 BC_ListBox::drag_stop_event();
3090 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3091 mwindow->session->current_operation = ::NO_OPERATION;
3096 int AWindowAssets::column_resize_event()
3098 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3099 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3103 int AWindowAssets::cursor_enter_event()
3105 int ret = BC_ListBox::cursor_enter_event();
3106 switch( gui->vicon_drawing ) {
3107 case AVICON_FULL_PLAY:
3108 gui->start_vicon_drawing();
3110 case AVICON_MOUSE_OVER:
3111 case AVICON_SRC_TARGET:
3112 case AVICON_NO_PLAY:
3119 int AWindowAssets::cursor_leave_event()
3122 if( !is_event_win() ) return 0;
3123 if( !gui->vicon_thread->viewing )
3124 gui->stop_vicon_drawing();
3125 return BC_ListBox::cursor_leave_event();
3128 int AWindowAssets::focus_out_event()
3130 gui->stop_vicon_drawing();
3131 gui->vicon_thread->set_view_popup(0);
3132 return BC_ListBox::focus_out_event();
3135 void AWindowAssets::update_vicon_area()
3137 int x0 = 0, x1 = get_w();
3138 int y0 = get_title_h();
3140 if( is_highlighted() ) {
3141 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3142 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3144 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3147 int AWindowAssets::mouse_over_event(int no)
3149 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3150 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3151 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3152 switch( gui->vicon_drawing ) {
3153 case AVICON_FULL_PLAY:
3154 gui->vicon_thread->solo = 0;
3155 if( vicon && gui->vicon_thread->viewing )
3156 gui->vicon_thread->set_view_popup(vicon);
3158 case AVICON_MOUSE_OVER:
3160 gui->vicon_thread->solo = vicon;
3161 gui->start_vicon_drawing();
3163 case AVICON_SRC_TARGET:
3165 if( gui->vicon_thread->viewing )
3166 gui->vicon_thread->set_view_popup(vicon);
3168 case AVICON_NO_PLAY:
3172 if( no < 0 && info_tip >= 0 ) {
3175 if( gui->tip_info && no >= 0 &&
3176 info_tip != no && picon && picon->plugin ) {
3177 const char *info = picon->plugin->tip;
3178 if( !info ) info = _("No info available");
3179 show_tip_info(info, no);
3184 void AWindowAssets::show_tip_info(const char *info, int no)
3186 int tw = get_text_width(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3187 int th = get_text_height(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3188 int tx = get_w() - (tw + xS(28));
3189 int ty = get_h() - (th + yS(28));
3190 show_tooltip(info, tx, ty, tw, th);
3194 void AWindowAssets::hide_tip_info()
3201 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3202 : BC_TextBox(x, y, w, 1, "")
3204 this->search_text = search_text;
3207 int AWindowSearchTextBox::handle_event()
3209 return search_text->handle_event();
3212 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3214 this->mwindow = mwindow;
3220 void AWindowSearchText::create_objects()
3224 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3225 x1 += text_title->get_w() + xs10;
3226 int w1 = gui->get_w() - x1 - 2*xs10;
3227 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3230 int AWindowSearchText::handle_event()
3232 gui->async_update_assets();
3236 int AWindowSearchText::get_w()
3238 return text_box->get_w() + text_title->get_w() + xS(10);
3241 int AWindowSearchText::get_h()
3243 return bmax(text_box->get_h(),text_title->get_h());
3246 void AWindowSearchText::reposition_window(int x, int y, int w)
3250 text_title->reposition_window(x1, y1);
3251 x1 += text_title->get_w() + xs10;
3252 int w1 = gui->get_w() - x1 - 2*xs10;
3253 text_box->reposition_window(x1, y1, w1);
3256 const char *AWindowSearchText::get_text()
3258 return text_box->get_text();
3261 void AWindowSearchText::clear()
3263 text_box->update("");
3266 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3267 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3269 this->mwindow = mwindow;
3271 set_tooltip(_("Delete asset from disk"));
3274 int AWindowDeleteDisk::handle_event()
3279 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3280 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3282 this->mwindow = mwindow;
3284 set_tooltip(_("Delete asset from project"));
3287 int AWindowDeleteProject::handle_event()
3292 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3293 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3295 // this->mwindow = mwindow;
3297 // set_tooltip(_("Edit information on asset"));
3300 // int AWindowInfo::handle_event()
3302 // int cur_x, cur_y;
3303 // gui->get_abs_cursor(cur_x, cur_y, 0);
3304 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3308 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3309 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3311 this->mwindow = mwindow;
3313 set_tooltip(_("Redraw index"));
3316 int AWindowRedrawIndex::handle_event()
3321 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3322 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3324 this->mwindow = mwindow;
3326 set_tooltip(_("Paste asset on recordable tracks"));
3329 int AWindowPaste::handle_event()
3334 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3335 : BC_Button(x, y, mwindow->theme->appendasset_data)
3337 this->mwindow = mwindow;
3339 set_tooltip(_("Append asset in new tracks"));
3342 int AWindowAppend::handle_event()
3347 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3348 : BC_Button(x, y, mwindow->theme->viewasset_data)
3350 this->mwindow = mwindow;
3352 set_tooltip(_("View asset"));
3355 int AWindowView::handle_event()
3360 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3361 : BC_PopupMenu(x, y, title, -1, 0)
3363 this->mwindow = mwindow;
3367 void AddTools::create_objects()
3370 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3371 vis |= 1 << PLUGIN_FFMPEG_ID;
3372 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3373 vis |= 1 << PLUGIN_LADSPA_ID;
3375 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3376 vis |= 1 << PLUGIN_LV2_ID;
3378 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3379 PluginServer *plugin = MWindow::plugindb->get(i);
3380 if( !plugin->audio && !plugin->video ) continue;
3381 int idx = plugin->dir_idx;
3382 uint32_t msk = 1 << idx;
3383 if( (msk & vis) != 0 ) continue;
3385 char parent[BCTEXTLEN];
3386 strcpy(parent, plugin->path);
3387 char *bp = strrchr(parent, '/');
3388 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3389 if( !bp ) bp = parent; else ++bp;
3390 add_item(new AddPluginItem(this, bp, idx));
3395 // plugin_dirs list from toplevel makefile include plugin_defs
3400 N_("audio_transitions")
3407 N_("video_transitions")
3410 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3411 : BC_MenuItem(_(text))
3415 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3416 int chk = (msk & vis) ? 1 : 0;
3420 int AddPluginItem::handle_event()
3422 int chk = get_checked() ^ 1;
3424 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3425 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3426 menu->gui->update_effects();
3427 menu->gui->save_defaults(menu->mwindow->defaults);
3428 menu->gui->async_update_assets();
3432 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3435 this->avicon = avicon;
3439 int AVIconDrawingItem::handle_event()
3441 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3442 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3443 item->set_checked(id == i);
3445 AWindowGUI *agui = avicon->agui;
3447 avicon->set_text(get_text());
3448 agui->stop_vicon_drawing();
3449 agui->vicon_thread->set_view_popup(0);
3450 agui->vicon_thread->solo = 0;
3451 agui->vicon_drawing = id;
3452 agui->start_vicon_drawing();
3456 int AVIconDrawing::draw_face(int dx, int color)
3458 int ret = BC_PopupMenu::draw_face(dx, color);
3459 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3460 int lx = get_margin(), ly = get_h()/2;
3461 draw_line(lx,ly, get_w()-2*lx,ly);
3466 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3467 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3472 AVIconDrawing::~AVIconDrawing()
3476 void AVIconDrawing::create_objects()
3478 AVIconDrawingItem *item;
3479 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3480 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3481 item->set_checked(agui->vicon_drawing == i);
3485 int AVIconDrawing::button_press_event()
3487 if( !is_event_win() ) return 0;
3488 if( get_buttonpress() == MIDDLE_BUTTON ) {
3489 agui->play_off = !agui->play_off ? 1 : 0;
3492 agui->start_vicon_drawing();
3495 return BC_PopupMenu::button_press_event();
3498 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3499 : BC_MenuItem("","v",'v')
3501 this->mwindow = mwindow;
3505 int AWindowListFormat::handle_event()
3507 return gui->cycle_assetlist_format();
3510 void AWindowListFormat::update()
3512 EDLSession *session = mwindow->edl->session;
3513 const char *text = 0;
3514 switch( session->assetlist_format ) {
3516 text = _("Display icons");
3519 text = _("Display icons packed");
3521 case ASSETS_ICONS_PACKED:
3522 text = _("Display icon list");
3524 case ASSETS_ICON_LIST:
3525 text = _("Display text");
3531 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3532 : BC_MenuItem(_("Sort items"))
3534 this->mwindow = mwindow;
3538 int AWindowListSort::handle_event()
3544 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3547 this->select_used = select_used;
3548 this->action = action;
3551 int AssetSelectUsedItem::handle_event()
3553 MWindow *mwindow = select_used->mwindow;
3554 AWindowGUI *gui = select_used->gui;
3555 AWindowAssets *asset_list = gui->asset_list;
3556 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3561 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3565 asset_list->set_all_selected(data, 0);
3566 for( int i = 0; i < data->total; i++ ) {
3567 AssetPicon *picon = (AssetPicon*)data->values[i];
3568 Indexable *idxbl = picon->indexable ? picon->indexable :
3569 picon->edl ? picon->edl->get_proxy_asset() : 0;
3570 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3571 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3576 int asset_xposition = asset_list->get_xposition();
3577 int asset_yposition = asset_list->get_yposition();
3578 asset_list->update(gui->displayed_assets, gui->asset_titles,
3579 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3580 asset_xposition, asset_yposition, -1, 0);
3581 asset_list->center_selection();
3585 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3586 : BC_MenuItem(_("Select"))
3588 this->mwindow = mwindow;