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(mwindow->preferences);
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");
1325 // *** CONTEXT_HELP ***
1326 context_help_set_keyword("Resources Window");
1329 AWindowGUI::~AWindowGUI()
1331 assets.remove_all_objects();
1332 folders.remove_all_objects();
1333 aeffects.remove_all_objects();
1334 veffects.remove_all_objects();
1335 atransitions.remove_all_objects();
1336 vtransitions.remove_all_objects();
1337 labellist.remove_all_objects();
1338 displayed_assets[1].remove_all_objects();
1340 delete new_folder_thread;
1341 delete modify_folder_thread;
1342 delete vicon_thread;
1347 delete remove_plugin;
1349 delete file_vframe; delete file_icon;
1350 delete folder_vframe; delete folder_icon;
1351 delete audio_vframe; delete audio_icon;
1352 delete video_vframe; delete video_icon;
1353 delete label_vframe; delete label_icon;
1354 delete clip_vframe; delete clip_icon;
1355 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1356 delete atransition_folder_vframe; delete atransition_folder_icon;
1357 delete veffect_folder_vframe; delete veffect_folder_icon;
1358 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1359 delete clip_folder_vframe; delete clip_folder_icon;
1360 delete label_folder_vframe; delete label_folder_icon;
1361 delete media_folder_vframe; delete media_folder_icon;
1362 delete proxy_folder_vframe; delete proxy_folder_icon;
1363 delete ladspa_vframe; delete ladspa_icon;
1364 delete ff_aud_vframe; delete ff_aud_icon;
1365 delete ff_vid_vframe; delete ff_vid_icon;
1366 delete atransition_vframe; delete atransition_icon;
1367 delete vtransition_vframe; delete vtransition_icon;
1368 delete aeffect_vframe; delete aeffect_icon;
1369 delete veffect_vframe; delete veffect_icon;
1373 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1375 return icon == file_icon ||
1376 icon == folder_icon ||
1377 icon == audio_icon ||
1378 icon == video_icon ||
1379 icon == clip_icon ||
1380 icon == label_icon ||
1381 icon == vtransition_icon ||
1382 icon == atransition_icon ||
1383 icon == veffect_icon ||
1384 icon == aeffect_icon ||
1385 icon == ladspa_icon ||
1386 icon == ff_aud_icon ||
1387 icon == ff_vid_icon ||
1388 icon == aeffect_folder_icon ||
1389 icon == veffect_folder_icon ||
1390 icon == atransition_folder_icon ||
1391 icon == vtransition_folder_icon ||
1392 icon == label_folder_icon ||
1393 icon == clip_folder_icon ||
1394 icon == media_folder_icon ||
1395 icon == proxy_folder_icon;
1398 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1400 char png_path[BCTEXTLEN];
1401 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1402 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1403 File::get_plugin_path(), plugin_icons, name);
1404 if( access(png_path, R_OK) ) return 0;
1405 return VFramePng::vframe_png(png_path,0,0);
1408 VFrame *AWindowGUI::get_picon(const char *name)
1410 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1412 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1413 snprintf(pp, ep-pp, "%s.png", name);
1414 unsigned char *data = mwindow->theme->get_image_data(png_name);
1415 if( data ) vframe = new VFramePng(data, 0.);
1420 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1422 vfrm = get_picon(fn);
1423 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1424 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1426 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1428 vfrm = get_picon(fn);
1429 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1430 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1432 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1434 vfrm = get_picon(fn);
1435 if( !vfrm ) vfrm = new VFramePng(png);
1436 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1439 void AWindowGUI::create_objects()
1441 int ys5 = yS(5), ys10 = yS(10);
1442 lock_window("AWindowGUI::create_objects");
1443 asset_titles[0] = C_("Title");
1444 asset_titles[1] = _("Comments");
1446 set_icon(mwindow->theme->get_image("awindow_icon"));
1448 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1449 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1450 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1451 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1452 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1454 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1455 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1456 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1457 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1458 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1459 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1460 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1461 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1463 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1464 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1465 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1466 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1467 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1468 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1469 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1470 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1472 theme_icon(clip_vframe, clip_icon, "clip_icon");
1473 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1474 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1475 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1476 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1478 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1479 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1480 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1481 folder_lock->lock("AWindowGUI::create_objects");
1482 // Mandatory folders
1483 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1484 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1485 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1486 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1487 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1488 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1489 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1490 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1492 create_label_folder();
1493 folder_lock->unlock();
1495 mwindow->theme->get_awindow_sizes(this);
1496 load_defaults(mwindow->defaults);
1497 new_folder_thread = new NewFolderThread(this);
1498 modify_folder_thread = new ModifyFolderThread(this);
1500 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1501 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1502 search_text = new AWindowSearchText(mwindow, this, x1, y1+ys5);
1503 search_text->create_objects();
1504 int dy = search_text->get_h() + ys10;
1506 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1508 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1509 asset_list->update_vicon_area();
1510 vicon_thread->start();
1511 vicon_audio = new AssetVIconAudio(this);
1513 add_subwindow(divider = new AWindowDivider(mwindow, this,
1514 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1515 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1517 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1519 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1520 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1521 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1522 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1523 for( int i=0; i<n; ++i ) {
1524 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1525 if( tw < nw ) tw = nw;
1527 int pw = BC_PopupMenu::calculate_w(xS(16), tw, 1);
1528 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1529 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1530 avicon_drawing->create_objects();
1531 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1532 add_tools->create_objects();
1533 fy += add_tools->get_h(); fh -= add_tools->get_h();
1534 add_subwindow(folder_list = new AWindowFolders(mwindow,
1535 this, fx, fy, fw, fh));
1537 folder_list->load_expanders();
1539 //int x = mwindow->theme->abuttons_x;
1540 //int y = mwindow->theme->abuttons_y;
1542 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1543 asset_menu->create_objects();
1544 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1545 clip_menu->create_objects();
1546 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1547 label_menu->create_objects();
1548 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1549 proxy_menu->create_objects();
1551 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1552 effectlist_menu->create_objects();
1553 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1554 assetlist_menu->create_objects();
1555 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1556 cliplist_menu->create_objects();
1557 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1558 labellist_menu->create_objects();
1559 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1560 proxylist_menu->create_objects();
1562 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1563 folderlist_menu->create_objects();
1565 create_custom_xatoms();
1569 int AWindowGUI::resize_event(int w, int h)
1571 mwindow->session->awindow_x = get_x();
1572 mwindow->session->awindow_y = get_y();
1573 mwindow->session->awindow_w = w;
1574 mwindow->session->awindow_h = h;
1576 mwindow->theme->get_awindow_sizes(this);
1577 mwindow->theme->draw_awindow_bg(this);
1578 reposition_objects();
1580 // int x = mwindow->theme->abuttons_x;
1581 // int y = mwindow->theme->abuttons_y;
1582 // new_bin->reposition_window(x, y);
1583 // x += new_bin->get_w();
1584 // delete_bin->reposition_window(x, y);
1585 // x += delete_bin->get_w();
1586 // rename_bin->reposition_window(x, y);
1587 // x += rename_bin->get_w();
1588 // delete_disk->reposition_window(x, y);
1589 // x += delete_disk->get_w();
1590 // delete_project->reposition_window(x, y);
1591 // x += delete_project->get_w();
1592 // info->reposition_window(x, y);
1593 // x += info->get_w();
1594 // redraw_index->reposition_window(x, y);
1595 // x += redraw_index->get_w();
1596 // paste->reposition_window(x, y);
1597 // x += paste->get_w();
1598 // append->reposition_window(x, y);
1599 // x += append->get_w();
1600 // view->reposition_window(x, y);
1602 BC_WindowBase::resize_event(w, h);
1603 asset_list->update_vicon_area();
1607 int AWindowGUI::translation_event()
1609 mwindow->session->awindow_x = get_x();
1610 mwindow->session->awindow_y = get_y();
1614 void AWindowGUI::reposition_objects()
1616 int ys5 = yS(5), ys10 = yS(10);
1617 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1618 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1619 search_text->reposition_window(x1, y1+ys5, w1);
1620 int dy = search_text->get_h() + ys10;
1622 asset_list->reposition_window(x1, y1, w1, h1);
1623 divider->reposition_window(
1624 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1625 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1626 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1627 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1628 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1629 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1630 fy += add_tools->get_h(); fh -= add_tools->get_h();
1631 folder_list->reposition_window(fx, fy, fw, fh);
1634 int AWindowGUI::save_defaults(BC_Hash *defaults)
1636 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1637 defaults->update("VICON_DRAWING", vicon_drawing);
1638 defaults->update("TIP_INFO", tip_info);
1642 int AWindowGUI::load_defaults(BC_Hash *defaults)
1644 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1645 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1646 tip_info = defaults->get("TIP_INFO", tip_info);
1650 int AWindowGUI::close_event()
1653 mwindow->session->show_awindow = 0;
1656 mwindow->gui->lock_window("AWindowGUI::close_event");
1657 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1658 mwindow->gui->unlock_window();
1660 lock_window("AWindowGUI::close_event");
1661 save_defaults(mwindow->defaults);
1662 mwindow->save_defaults();
1666 int AWindowGUI::start_vicon_drawing()
1668 if( play_off ) return stop_vicon_drawing();
1669 if( !vicon_thread->interrupted ) return 1;
1670 switch( vicon_drawing ) {
1671 case AVICON_FULL_PLAY: // all vicons, viewing, target
1673 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1674 if( vicon_thread->solo ) break;
1676 case AVICON_SRC_TARGET: // no vicons, no view, target
1677 case AVICON_NO_PLAY: // no vicons, no view, no target
1680 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1681 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1682 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1683 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1684 switch( mwindow->edl->session->assetlist_format ) {
1686 case ASSETS_ICONS_PACKED:
1687 case ASSETS_ICON_LIST:
1688 asset_list->update_vicon_area();
1689 vicon_thread->start_drawing();
1698 int AWindowGUI::stop_vicon_drawing(int wait)
1700 vicon_thread->stop_vicon_drawing(wait);
1705 VFrame *AssetPicon::get_vicon_frame()
1707 if( !vicon ) return 0;
1708 if( gui->vicon_thread->interrupted ) return 0;
1709 VFrame *frame = vicon->frame();
1710 if( !frame ) return 0;
1712 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1713 vicon_frame->transfer_from(frame);
1717 int AWindowGUI::cycle_assetlist_format()
1719 EDLSession *session = mwindow->edl->session;
1720 int format = ASSETS_TEXT;
1721 if( allow_iconlisting ) {
1722 switch( session->assetlist_format ) {
1724 format = ASSETS_ICONS;
1727 format = ASSETS_ICONS_PACKED;
1729 case ASSETS_ICONS_PACKED:
1730 format = ASSETS_ICON_LIST;
1732 case ASSETS_ICON_LIST:
1733 format = ASSETS_TEXT;
1737 stop_vicon_drawing();
1738 session->assetlist_format = format;
1739 asset_list->update_format(session->assetlist_format, 0);
1740 async_update_assets();
1741 start_vicon_drawing();
1745 void AWindowGUI::hide_tip_info()
1747 asset_list->hide_tooltip();
1751 AWindowRemovePluginGUI::
1752 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1753 int x, int y, PluginServer *plugin)
1754 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y,
1755 xS(500),yS(200), xS(50), yS(50),
1758 this->awindow = awindow;
1759 this->thread = thread;
1760 this->plugin = plugin;
1761 VFrame *vframe = plugin->get_picon();
1762 icon = vframe ? create_pixmap(vframe) : 0;
1763 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1764 // *** CONTEXT_HELP ***
1765 context_help_set_keyword("Delete Plugins to save Resources Space");
1768 AWindowRemovePluginGUI::
1769 ~AWindowRemovePluginGUI()
1771 if( !awindow->gui->protected_pixmap(icon) )
1773 plugin_list.remove_all();
1776 void AWindowRemovePluginGUI::create_objects()
1778 int xs10 = xS(10), xs20 = xS(20);
1779 int ys5 = yS(5), ys10 = yS(10);
1780 lock_window("AWindowRemovePluginGUI::create_objects");
1781 BC_Button *ok_button = new BC_OKButton(this);
1782 add_subwindow(ok_button);
1783 BC_Button *cancel_button = new BC_CancelButton(this);
1784 add_subwindow(cancel_button);
1785 int x = xs10, y = ys10;
1786 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1787 add_subwindow(title);
1788 y += title->get_h() + ys5;
1789 list = new BC_ListBox(x, y,
1790 get_w() - xs20, ok_button->get_y() - y - ys5, LISTBOX_TEXT, &plugin_list,
1791 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1792 add_subwindow(list);
1797 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1800 for( int i=0; i<folder.size(); ) {
1801 AssetPicon *picon = (AssetPicon *)folder[i];
1802 if( picon->plugin == plugin ) {
1803 folder.remove_object_number(i);
1812 void AWindowRemovePlugin::handle_close_event(int result)
1815 printf(_("remove %s\n"), plugin->path);
1816 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1817 ArrayList<BC_ListBoxItem*> *folder =
1818 plugin->audio ? plugin->transition ?
1819 &awindow->gui->atransitions :
1820 &awindow->gui->aeffects :
1821 plugin->video ? plugin->transition ?
1822 &awindow->gui->vtransitions :
1823 &awindow->gui->veffects :
1825 if( folder ) remove_plugin(plugin, *folder);
1826 MWindow *mwindow = awindow->mwindow;
1827 awindow->gui->unlock_window();
1828 char plugin_path[BCTEXTLEN];
1829 strcpy(plugin_path, plugin->path);
1830 mwindow->plugindb->remove(plugin);
1831 remove(plugin_path);
1832 char index_path[BCTEXTLEN];
1833 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1835 char picon_path[BCTEXTLEN];
1837 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1838 File::get_plugin_path());
1839 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1840 plugin->get_plugin_png_name(png_name);
1841 fs.update(picon_path);
1842 for( int i=0; i<fs.dir_list.total; ++i ) {
1843 char *fs_path = fs.dir_list[i]->path;
1844 if( !fs.is_dir(fs_path) ) continue;
1845 snprintf(png_path, sizeof(picon_path), "%s/%s",
1849 delete plugin; plugin = 0;
1850 awindow->gui->async_update_assets();
1854 AWindowRemovePlugin::
1855 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1858 this->awindow = awindow;
1859 this->plugin = plugin;
1862 AWindowRemovePlugin::
1863 ~AWindowRemovePlugin()
1868 BC_Window* AWindowRemovePlugin::new_gui()
1870 int x = awindow->gui->get_abs_cursor_x(0);
1871 int y = awindow->gui->get_abs_cursor_y(0);
1872 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1873 gui->create_objects();
1877 int AWindowGUI::keypress_event()
1879 char title[BCTEXTLEN];
1880 PluginServer* plugin = 0;
1881 switch( get_keypress() ) {
1889 tip_info = !tip_info ? 1 : 0;
1890 if( !tip_info ) hide_tip_info();
1893 if( !ctrl_down() && !shift_down() ) {
1894 assetlist_menu->load_file->handle_event();
1899 return cycle_assetlist_format();
1901 if( shift_down() && ctrl_down() ) {
1902 plugin = selected_plugin();
1903 if( !plugin ) break;
1904 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1906 remove_plugin->start();
1907 lock_window("AWindowGUI::keypress_event 1");
1911 if( shift_down() ) {
1912 mwindow->awindow->asset_remove->start();
1916 mwindow->remove_assets_from_project(1, 1, 1,
1917 mwindow->session->drag_assets,
1918 mwindow->session->drag_clips);
1919 lock_window("AWindowGUI::keypress_event 2");
1925 if( shift_down() && ctrl_down() ) {
1926 resend_event(mwindow->gui);
1931 // *** CONTEXT_HELP ***
1932 if( get_keypress() != 'h' || ! alt_down() ) return 0;
1933 if( ! is_tooltip_event_win() || ! cursor_inside() ) return 0;
1934 // If some plugin is selected, show its help
1935 // Otherwise show general help
1936 plugin = selected_plugin();
1938 strcpy(title, plugin->title);
1939 if( ! strcmp(title, "Overlay") ) {
1940 // "Overlay" plugin title is ambiguous
1941 if( plugin->audio ) strcat(title, " \\(Audio\\)");
1942 if( plugin->video ) strcat(title, " \\(Video\\)");
1944 if( plugin->is_ffmpeg() ) {
1945 // FFmpeg plugins can be audio or video
1947 strcpy(title, "FFmpeg Audio Plugins");
1949 strcpy(title, "FFmpeg Video Plugins");
1951 context_help_show(title);
1953 else context_help_show("Resources Window");
1959 int AWindowGUI::create_custom_xatoms()
1961 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1964 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1966 if( event->message_type == UpdateAssetsXAtom ) {
1973 void AWindowGUI::async_update_assets()
1976 event.message_type = UpdateAssetsXAtom;
1977 send_custom_xatom(&event);
1981 void AWindowGUI::update_folder_list()
1983 for( int i = 0; i < folders.total; i++ ) {
1984 AssetPicon *picon = (AssetPicon*)folders.values[i];
1988 // Search assets for folders
1989 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1990 BinFolder *bin_folder = mwindow->edl->folders[i];
1993 for( int j = 0; j < folders.total; j++ ) {
1994 AssetPicon *picon = (AssetPicon*)folders[j];
1995 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
2003 const char *title = bin_folder->title;
2004 int folder = bin_folder->awindow_folder;
2005 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
2006 picon->create_objects();
2007 folders.append(picon);
2011 // Delete unused non-persistent folders
2012 int do_autoplace = 0;
2013 for( int i=folders.total; --i>=0; ) {
2014 AssetPicon *picon = (AssetPicon*)folders.values[i];
2015 if( !picon->in_use && !picon->persistent ) {
2017 folders.remove_number(i);
2022 folder_list->set_autoplacement(&folders, 0, 1);
2025 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
2026 int do_audio, int do_video, int is_realtime, int is_transition)
2028 ArrayList<PluginServer*> plugin_list;
2029 // Get pointers to plugindb entries
2030 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
2033 for( int i = 0; i < plugin_list.total; i++ ) {
2034 PluginServer *server = plugin_list.values[i];
2035 int visible = plugin_visibility & (1<<server->dir_idx);
2036 if( !visible ) continue;
2037 // Create new listitem
2038 AssetPicon *picon = new AssetPicon(mwindow, this, server);
2039 picon->create_objects();
2040 output->append(picon);
2044 void AWindowGUI::create_label_folder()
2047 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
2048 AssetPicon *picon = new AssetPicon(mwindow, this, current);
2049 picon->create_objects();
2050 labellist.append(picon);
2055 void AWindowGUI::update_asset_list()
2057 ArrayList<AssetPicon *> new_assets;
2058 for( int i = 0; i < assets.total; i++ ) {
2059 AssetPicon *picon = (AssetPicon*)assets.values[i];
2063 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2064 // Synchronize EDL clips
2065 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2068 // Look for clip in existing listitems
2069 for( int j = 0; j < assets.total && !exists; j++ ) {
2070 AssetPicon *picon = (AssetPicon*)assets.values[j];
2072 if( picon->id == mwindow->edl->clips[i]->id ) {
2073 picon->edl = mwindow->edl->clips[i];
2074 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2080 // Create new listitem
2082 AssetPicon *picon = new AssetPicon(mwindow,
2083 this, mwindow->edl->clips[i]);
2084 new_assets.append(picon);
2088 // Synchronize EDL assets
2089 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2092 // Look for asset in existing listitems
2093 for( int j = 0; j < assets.total && !exists; j++ ) {
2094 AssetPicon *picon = (AssetPicon*)assets.values[j];
2096 if( picon->id == current->id ) {
2097 picon->indexable = current;
2103 // Create new listitem
2105 AssetPicon *picon = new AssetPicon(mwindow,
2107 new_assets.append(picon);
2108 if( current->width > ASSET_MAX_WIDTH || current->height > ASSET_MAX_HEIGHT ) {
2109 eprintf(_("Warning: %s\n"
2110 " dimensions %dx%d exceed asset maximum limits %dx%d\n"),
2111 current->path, current->width, current->height,
2112 ASSET_MAX_WIDTH, ASSET_MAX_HEIGHT);
2114 else if( mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
2115 int texture_limit = BC_DisplayInfo::get_gl_max_texture_size();
2116 if( texture_limit >= 0 &&
2117 (current->width >= texture_limit || current->height >= texture_limit) ) {
2118 eprintf(_("Warning: %s\n"
2119 " dimensions %dx%d exceed OpenGL texture limit %d\n"),
2120 current->path, current->width, current->height, texture_limit);
2126 // Synchronize nested EDLs
2127 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2129 EDL *nested_edl = mwindow->edl->nested_edls[i];
2131 // Look for asset in existing listitems
2132 for( int j=0; j<assets.total && !exists; ++j ) {
2133 AssetPicon *picon = (AssetPicon*)assets.values[j];
2135 if( picon->id == nested_edl->id ) {
2136 picon->indexable = nested_edl;
2142 // Create new listitem
2144 AssetPicon *picon = new AssetPicon(mwindow,
2145 this, (Indexable*)nested_edl);
2146 new_assets.append(picon);
2149 mwindow->gui->unlock_window();
2151 for( int i=0; i<new_assets.size(); ++i ) {
2152 AssetPicon *picon = new_assets[i];
2153 picon->create_objects();
2154 if( picon->indexable )
2155 picon->foldernum = AW_MEDIA_FOLDER;
2156 else if( picon->edl )
2157 picon->foldernum = AW_CLIP_FOLDER;
2158 assets.append(picon);
2161 mwindow->gui->lock_window();
2162 mwindow->gui->default_message();
2163 mwindow->gui->unlock_window();
2165 for( int i = assets.size() - 1; i >= 0; i-- ) {
2166 AssetPicon *picon = (AssetPicon*)assets.get(i);
2167 if( !picon->in_use ) {
2169 assets.remove_number(i);
2172 if( picon->indexable && picon->indexable->is_asset ) {
2173 Asset *asset = (Asset *)picon->indexable;
2175 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2176 picon->comments_rate = asset->get_frame_rate();
2177 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2178 picon->comments_type = asset->format == FILE_FFMPEG ?
2179 asset->vcodec : File::formattostr(asset->format);
2184 void AWindowGUI::update_picon(Indexable *indexable)
2187 for( int i = 0; i < assets.total; i++ ) {
2188 AssetPicon *picon = (AssetPicon*)assets.values[i];
2189 if( picon->indexable == indexable ||
2190 picon->edl == (EDL *)indexable ) {
2191 char name[BCTEXTLEN];
2193 fs.extract_name(name, indexable->path);
2194 picon->set_text(name);
2195 vicon = picon->vicon;
2200 stop_vicon_drawing();
2201 vicon->clear_images();
2202 vicon->reset(indexable->get_frame_rate());
2203 start_vicon_drawing();
2207 void AWindowGUI::sort_assets()
2209 folder_lock->lock("AWindowGUI::sort_assets");
2210 switch( mwindow->edl->session->awindow_folder ) {
2211 case AW_AEFFECT_FOLDER:
2212 sort_picons(&aeffects);
2214 case AW_VEFFECT_FOLDER:
2215 sort_picons(&veffects);
2217 case AW_ATRANSITION_FOLDER:
2218 sort_picons(&atransitions);
2220 case AW_VTRANSITION_FOLDER:
2221 sort_picons(&vtransitions);
2223 case AW_LABEL_FOLDER:
2224 sort_picons(&labellist);
2227 sort_picons(&assets);
2231 asset_list->update_format(asset_list->get_format(), 0);
2232 folder_lock->unlock();
2236 void AWindowGUI::sort_folders()
2238 folder_lock->lock("AWindowGUI::update_assets");
2239 // folder_list->collapse_recursive(&folders, 0);
2240 folder_list->set_autoplacement(&folders, 0, 1);
2241 sort_picons(&folders);
2242 folder_list->update_format(folder_list->get_format(), 0);
2243 folder_lock->unlock();
2247 EDL *AWindowGUI::collect_proxy(Asset *proxy_asset)
2249 char path[BCTEXTLEN];
2250 int proxy_scale = mwindow->edl->session->proxy_scale;
2251 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2252 Indexable *unproxy_idxbl =
2253 proxy_asset->proxy_edl ?
2254 (Indexable *) mwindow->edl->get_nested_edl(path) :
2255 (Indexable *) mwindow->edl->assets->get_asset(path);
2256 if( !unproxy_idxbl || !unproxy_idxbl->get_video_layers() ) return 0;
2257 // make a clip from proxy video tracks and unproxy audio tracks
2258 EDL *proxy_edl = new EDL(mwindow->edl);
2259 proxy_edl->create_objects();
2260 proxy_edl->set_path(proxy_asset->path);
2261 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2262 strcpy(proxy_edl->local_session->clip_title, path);
2263 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2264 proxy_edl->session->video_tracks = proxy_asset->layers;
2265 proxy_edl->session->audio_tracks = unproxy_idxbl->get_audio_channels();
2266 proxy_edl->create_default_tracks();
2267 double length = proxy_asset->frame_rate > 0 ?
2268 ( proxy_asset->video_length >= 0 ?
2269 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2270 ( proxy_edl->session->si_useduration ?
2271 proxy_edl->session->si_duration :
2272 1.0 / proxy_asset->frame_rate ) ) :
2273 1.0 / proxy_edl->session->frame_rate;
2274 Track *current = proxy_edl->tracks->first;
2275 for( int vtrack=0; current; current=NEXT ) {
2276 if( current->data_type != TRACK_VIDEO ) continue;
2277 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2279 int64_t samples = unproxy_idxbl->get_audio_samples();
2280 int sample_rate = unproxy_idxbl->get_sample_rate();
2281 length = sample_rate > 0 ? (double)samples / sample_rate : 0;
2282 current = proxy_edl->tracks->first;
2283 for( int atrack=0; current; current=NEXT ) {
2284 if( current->data_type != TRACK_AUDIO ) continue;
2285 Asset *asset = unproxy_idxbl->is_asset ? (Asset *)unproxy_idxbl : 0;
2286 EDL *nested_edl = unproxy_idxbl->is_asset ? 0 : (EDL *)unproxy_idxbl;
2287 current->insert_asset(asset, nested_edl, length, 0, atrack++);
2289 proxy_edl->folder_no = AW_PROXY_FOLDER;
2294 void AWindowGUI::collect_assets(int proxy)
2296 mwindow->session->drag_assets->remove_all();
2297 mwindow->session->drag_clips->remove_all();
2298 int i = 0; AssetPicon *result;
2299 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2300 Indexable *indexable = result->indexable;
2301 if( proxy && indexable && indexable->is_asset &&
2302 indexable->folder_no == AW_PROXY_FOLDER ) {
2303 EDL *drag_edl = collect_proxy((Asset*)indexable);
2304 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2308 mwindow->session->drag_assets->append(indexable);
2312 mwindow->session->drag_clips->append(result->edl);
2318 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2320 // Remove current pointers
2321 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2322 dst[0].remove_all();
2323 dst[1].remove_all_objects();
2325 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2326 int folder = mwindow->edl->session->awindow_folder;
2327 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2328 mwindow->edl->get_folder(folder);
2330 // Create new pointers
2331 for( int i = 0; i < src->total; i++ ) {
2332 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2333 picon = (AssetPicon*)src->values[i];
2334 picon->sort_key = -1;
2335 if( !visible && bin_folder ) {
2336 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2337 picon->indexable ? picon->indexable :
2338 picon->edl ? picon->edl->get_proxy_asset() : 0;
2340 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2341 if( picon->sort_key < 0 ) continue;
2345 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2347 if( !visible && picon->edl && picon->edl->folder_no == folder )
2349 if( visible && sub_items ) {
2350 if( !sub_items->matches(picon->get_text()) )
2354 const char *text = search_text->get_text();
2355 if( text && text[0] )
2356 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2358 if( visible && picon->vicon && picon->vicon->hidden )
2359 picon->vicon->hidden = 0;
2361 BC_ListBoxItem *item2, *item1;
2362 dst[0].append(item1 = picon);
2364 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2367 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2368 else if( picon->comments_time ) {
2369 char date_time[BCSTRLEN];
2370 struct tm stm; localtime_r(&picon->comments_time, &stm);
2371 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2372 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2373 stm.tm_hour, stm.tm_min, stm.tm_sec,
2374 picon->comments_rate, picon->comments_ffmt,
2375 picon->comments_type);
2376 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2379 dst[1].append(item2 = new BC_ListBoxItem(""));
2380 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2381 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2386 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2388 int done = 0, changed = 0;
2391 for( int i=0; i<src->total-1; ++i ) {
2392 AssetPicon *item1 = (AssetPicon *)src->values[i];
2393 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2394 double v = item2->sort_key - item1->sort_key;
2395 if( v > 0 ) continue;
2397 const char *cp1 = item1->get_text();
2398 const char *bp1 = strrchr(cp1, '/');
2399 if( bp1 ) cp1 = bp1 + 1;
2400 const char *cp2 = item2->get_text();
2401 const char *bp2 = strrchr(cp2, '/');
2402 if( bp2 ) cp2 = bp2 + 1;
2403 if( strcmp(cp2, cp1) >= 0 ) continue;
2405 src->values[i + 1] = item1;
2406 src->values[i] = item2;
2407 done = 0; changed = 1;
2411 for( int i=0; i<src->total; ++i ) {
2412 AssetPicon *item = (AssetPicon *)src->values[i];
2413 item->set_autoplace_icon(1);
2414 item->set_autoplace_text(1);
2419 void AWindowGUI::filter_displayed_assets()
2421 //allow_iconlisting = 1;
2422 asset_titles[0] = C_("Title");
2423 asset_titles[1] = _("Comments");
2424 AssetPicon *picon = 0;
2425 int selected_folder = mwindow->edl->session->awindow_folder;
2426 // Ensure the current folder icon is highlighted
2427 for( int i = 0; i < folders.total; i++ ) {
2428 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2429 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2430 folder_item->set_selected(selected);
2431 if( selected ) picon = folder_item;
2434 ArrayList<BC_ListBoxItem*> *src = &assets;
2435 switch( selected_folder ) {
2436 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2437 case AW_VEFFECT_FOLDER: src = &veffects; break;
2438 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2439 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2440 case AW_LABEL_FOLDER: src = &labellist;
2441 asset_titles[0] = _("Time Stamps");
2442 asset_titles[1] = C_("Title");
2443 //allow_iconlisting = 0;
2446 copy_picons(picon, src);
2450 void AWindowGUI::update_assets()
2452 stop_vicon_drawing();
2453 folder_lock->lock("AWindowGUI::update_assets");
2454 update_folder_list();
2455 update_asset_list();
2456 labellist.remove_all_objects();
2457 create_label_folder();
2459 if( displayed_folder != mwindow->edl->session->awindow_folder )
2460 search_text->clear();
2461 vicon_thread->hide_vicons();
2462 filter_displayed_assets();
2463 folder_lock->unlock();
2465 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2466 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2468 int folder_xposition = folder_list->get_xposition();
2469 int folder_yposition = folder_list->get_yposition();
2470 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2472 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2473 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2475 int asset_xposition = asset_list->get_xposition();
2476 int asset_yposition = asset_list->get_yposition();
2477 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2478 displayed_folder = mwindow->edl->session->awindow_folder;
2479 asset_xposition = asset_yposition = 0;
2481 asset_list->update(displayed_assets, asset_titles,
2482 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2483 asset_xposition, asset_yposition, -1, 0);
2484 asset_list->center_selection();
2487 start_vicon_drawing();
2491 void AWindowGUI::update_effects()
2493 aeffects.remove_all_objects();
2494 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2495 veffects.remove_all_objects();
2496 create_persistent_folder(&veffects, 0, 1, 1, 0);
2497 atransitions.remove_all_objects();
2498 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2499 vtransitions.remove_all_objects();
2500 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2503 int AWindowGUI::drag_motion()
2505 if( get_hidden() ) return 0;
2511 int AWindowGUI::drag_stop()
2513 if( get_hidden() ) return 0;
2517 Indexable* AWindowGUI::selected_asset()
2519 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2520 return picon ? picon->indexable : 0;
2523 PluginServer* AWindowGUI::selected_plugin()
2525 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2526 return picon ? picon->plugin : 0;
2529 AssetPicon* AWindowGUI::selected_folder()
2531 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2542 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2543 : BC_SubWindow(x, y, w, h)
2545 this->mwindow = mwindow;
2548 AWindowDivider::~AWindowDivider()
2552 int AWindowDivider::button_press_event()
2554 if( is_event_win() && cursor_inside() ) {
2555 mwindow->session->current_operation = DRAG_PARTITION;
2561 int AWindowDivider::cursor_motion_event()
2563 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2565 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2566 int fw = gui->get_relative_cursor_x();
2567 if( fw > wmax ) fw = wmax;
2568 if( fw < wmin ) fw = wmin;
2569 mwindow->session->afolders_w = fw;
2570 mwindow->theme->get_awindow_sizes(gui);
2571 gui->reposition_objects();
2577 int AWindowDivider::button_release_event()
2579 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2580 mwindow->session->current_operation = NO_OPERATION;
2591 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2592 : BC_ListBox(x, y, w, h,
2593 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2594 LISTBOX_ICONS : LISTBOX_TEXT,
2595 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2596 0, // Titles for columns. Set to 0 for no titles
2597 0, // width of each column
2598 1, // Total columns.
2599 0, // Pixel of top of window.
2600 0, // If this listbox is a popup window
2601 LISTBOX_SINGLE, // Select one item or multiple items
2602 ICON_TOP, // Position of icon relative to text of each item
2605 this->mwindow = mwindow;
2612 AWindowFolders::~AWindowFolders()
2616 int AWindowFolders::selection_changed()
2618 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2619 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2620 // prefer expanded entry
2621 AWindowFolderItem *item = item1 ? item1 : item0;
2622 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2623 item1->set_selected(0);
2630 AssetPicon *picon = item->get_picon();
2631 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2633 gui->stop_vicon_drawing();
2635 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2636 gui->folderlist_menu->update_titles();
2637 gui->folderlist_menu->activate_menu();
2640 mwindow->edl->session->awindow_folder = picon->foldernum;
2641 gui->asset_list->draw_background();
2642 gui->async_update_assets();
2644 gui->start_vicon_drawing();
2649 int AWindowFolders::button_press_event()
2651 gui->hide_tip_info();
2652 int result = BC_ListBox::button_press_event();
2655 if( get_buttonpress() == RIGHT_BUTTON &&
2656 is_event_win() && cursor_inside() ) {
2657 gui->folderlist_menu->update_titles();
2658 gui->folderlist_menu->activate_menu();
2666 int AWindowFolders::drag_stop()
2669 if( get_hidden() ) return 0;
2670 if( mwindow->session->current_operation == DRAG_ASSET &&
2671 gui->folder_list->cursor_above() ) { // check user folder
2672 int item_no = gui->folder_list->get_cursor_data_item_no();
2673 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2674 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2675 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2676 ArrayList<Indexable *> *drags = folder->is_clips ?
2677 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2678 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2679 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2681 mwindow->session->current_operation = ::NO_OPERATION;
2688 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2689 : AWindowFolderItem(text)
2691 this->parent = parent;
2694 int AWindowFolders::load_expanders()
2696 char expanders_path[BCTEXTLEN];
2697 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2698 FILE *fp = fopen(expanders_path, "r");
2700 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2701 File::get_cindat_path(), EXPANDERS_FILE);
2702 char *cp = strrchr(expanders_path,'.');
2703 if( cp ) strcpy(cp+1, mwindow->cin_lang);
2704 fp = fopen(expanders_path, "r");
2707 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2708 File::get_cindat_path(), EXPANDERS_FILE);
2709 fp = fopen(expanders_path, "r");
2712 const char tab = '\t';
2713 char line[BCTEXTLEN]; line[0] = 0;
2714 AWindowFolderItem *item = 0, *parent;
2715 AWindowFolderSubItems *sub_items = 0;
2717 while( fgets(line,sizeof(line),fp) ) {
2718 if( line[0] == '#' ) continue;
2719 int i = strlen(line);
2720 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2721 if( i == 0 ) continue;
2723 for( char *cp=line; *cp==tab; ++cp ) ++i;
2725 int i = gui->folders.size();
2727 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2728 if( !strcmp(folder->get_text(),_(line)) ) break;
2730 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2735 if( i > k+1 ) continue;
2737 if( line[i] != '-' && sub_items ) {
2738 sub_items->names.append(cstrdup(_(&line[i])));
2746 item = item->parent;
2749 parent = item->parent;
2751 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2752 if( !sublist ) sublist = parent->new_sublist(1);
2753 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2754 sublist->append(item = sub_items);
2761 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2762 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2763 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2764 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2765 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2767 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2768 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2769 mwindow->edl->session->asset_columns, // width of each column
2770 1, // Total columns.
2771 0, // Pixel of top of window.
2772 0, // If this listbox is a popup window
2773 LISTBOX_MULTIPLE, // Select one item or multiple items
2774 ICON_TOP, // Position of icon relative to text of each item
2775 -1) // Allow drags, require shift for scrolling
2777 this->mwindow = mwindow;
2779 this->info_tip = -1;
2781 set_scroll_stretch(1, 1);
2784 AWindowAssets::~AWindowAssets()
2788 int AWindowAssets::button_press_event()
2791 AssetVIconThread *avt = gui->vicon_thread;
2792 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2793 int dir = 1, button = get_buttonpress();
2795 case WHEEL_DOWN: dir = -1; // fall thru
2797 int x = get_cursor_x(), y = get_cursor_y();
2798 if( avt->cursor_inside(x, y) && avt->view_win )
2799 avt->zoom_scale(dir);
2804 int result = BC_ListBox::button_press_event();
2806 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2807 is_event_win() && cursor_inside() ) {
2808 BC_ListBox::deactivate_selection();
2809 int folder = mwindow->edl->session->awindow_folder;
2811 case AW_AEFFECT_FOLDER:
2812 case AW_VEFFECT_FOLDER:
2813 case AW_ATRANSITION_FOLDER:
2814 case AW_VTRANSITION_FOLDER:
2815 gui->effectlist_menu->update();
2816 gui->effectlist_menu->activate_menu();
2818 case AW_LABEL_FOLDER:
2819 gui->labellist_menu->update();
2820 gui->labellist_menu->activate_menu();
2822 case AW_CLIP_FOLDER:
2823 gui->cliplist_menu->update();
2824 gui->cliplist_menu->activate_menu();
2826 case AW_PROXY_FOLDER:
2827 gui->proxylist_menu->update();
2828 gui->proxylist_menu->activate_menu();
2831 case AW_MEDIA_FOLDER: {
2832 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2833 gui->assetlist_menu->update_titles(shots);
2834 gui->assetlist_menu->activate_menu();
2844 int AWindowAssets::handle_event()
2846 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2847 if( !asset_picon ) return 0;
2848 Indexable *picon_idxbl = asset_picon->indexable;
2849 EDL *picon_edl = asset_picon->edl;
2851 VWindow *vwindow = 0;
2852 switch( mwindow->edl->session->awindow_folder ) {
2853 case AW_AEFFECT_FOLDER:
2854 case AW_VEFFECT_FOLDER:
2855 case AW_ATRANSITION_FOLDER:
2856 case AW_VTRANSITION_FOLDER: return 1;
2857 case AW_PROXY_FOLDER:
2858 proxy = 1; // fall thru
2860 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2861 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2864 if( !vwindow || !vwindow->is_running() ) return 1;
2865 if( proxy && picon_idxbl && picon_idxbl->is_asset ) {
2866 picon_edl = gui->collect_proxy((Asset*)picon_idxbl);
2870 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2871 else if( picon_edl ) vwindow->change_source(picon_edl);
2875 int AWindowAssets::selection_changed()
2877 // Show popup window
2879 int folder = mwindow->edl->session->awindow_folder;
2880 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2881 (item = (AssetPicon*)get_selection(0, 0)) ) {
2883 case AW_AEFFECT_FOLDER:
2884 case AW_VEFFECT_FOLDER:
2885 case AW_ATRANSITION_FOLDER:
2886 case AW_VTRANSITION_FOLDER:
2887 gui->effectlist_menu->update();
2888 gui->effectlist_menu->activate_menu();
2890 case AW_LABEL_FOLDER:
2891 if( !item->label ) break;
2892 gui->label_menu->activate_menu();
2894 case AW_CLIP_FOLDER:
2895 if( !item->indexable && !item->edl ) break;
2896 gui->clip_menu->update();
2897 gui->clip_menu->activate_menu();
2899 case AW_PROXY_FOLDER:
2900 if( !item->indexable && !item->edl ) break;
2901 gui->proxy_menu->update();
2902 gui->proxy_menu->activate_menu();
2905 if( !item->indexable && !item->edl ) break;
2906 gui->asset_menu->update();
2907 gui->asset_menu->activate_menu();
2911 deactivate_selection();
2913 else if( get_button_down() && get_buttonpress() == LEFT_BUTTON &&
2914 get_double_click() ) {
2915 item = (AssetPicon*)get_selection(0, 0);
2918 case AW_LABEL_FOLDER:
2919 if( !item->label ) break;
2920 mwindow->set_position(item->label->position);
2925 else if( get_button_down() && !gui->play_off &&
2926 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2927 item = (AssetPicon*)get_selection(0, 0);
2928 if( item && !get_selection(0, 1) ) {
2930 case AW_MEDIA_FOLDER:
2931 case AW_PROXY_FOLDER:
2932 case AWINDOW_USER_FOLDERS:
2933 if( get_buttonpress() == LEFT_BUTTON ||
2934 get_buttonpress() == MIDDLE_BUTTON ) {
2935 AssetVIcon *vicon = 0;
2936 AssetVIconThread *avt = gui->vicon_thread;
2937 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2938 vicon = item->vicon;
2939 int draw_mode = !vicon ?
2941 get_buttonpress() == MIDDLE_BUTTON ?
2942 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2943 avt->set_view_popup(vicon, draw_mode);
2946 case AW_CLIP_FOLDER:
2947 if( get_buttonpress() == LEFT_BUTTON ) {
2948 AssetVIcon *vicon = 0;
2949 AssetVIconThread *avt = gui->vicon_thread;
2950 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2951 vicon = item->vicon;
2952 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2958 gui->vicon_thread->set_view_popup(0);
2959 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2960 gui->stop_vicon_drawing();
2966 void AWindowAssets::draw_background()
2968 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2969 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2970 set_font(LARGEFONT);
2971 int folder = mwindow->edl->session->awindow_folder;
2972 const char *title = mwindow->edl->get_folder_name(folder);
2973 draw_text(get_w() - get_text_width(LARGEFONT, title) - xS(4), yS(30),
2974 title, -1, get_bg_surface());
2977 int AWindowAssets::drag_start_event()
2979 gui->vicon_thread->set_view_popup(0);
2980 int collect_pluginservers = 0;
2981 int collect_assets = 0, proxy = 0;
2983 if( BC_ListBox::drag_start_event() ) {
2984 switch( mwindow->edl->session->awindow_folder ) {
2985 case AW_AEFFECT_FOLDER:
2986 mwindow->session->current_operation = DRAG_AEFFECT;
2987 collect_pluginservers = 1;
2989 case AW_VEFFECT_FOLDER:
2990 mwindow->session->current_operation = DRAG_VEFFECT;
2991 collect_pluginservers = 1;
2993 case AW_ATRANSITION_FOLDER:
2994 mwindow->session->current_operation = DRAG_ATRANSITION;
2995 collect_pluginservers = 1;
2997 case AW_VTRANSITION_FOLDER:
2998 mwindow->session->current_operation = DRAG_VTRANSITION;
2999 collect_pluginservers = 1;
3001 case AW_LABEL_FOLDER:
3004 case AW_PROXY_FOLDER:
3005 proxy = 1; // fall thru
3006 case AW_MEDIA_FOLDER:
3008 mwindow->session->current_operation = DRAG_ASSET;
3013 if( collect_pluginservers ) {
3015 mwindow->session->drag_pluginservers->remove_all();
3018 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
3019 if( !result ) break;
3021 mwindow->session->drag_pluginservers->append(result->plugin);
3025 if( collect_assets ) {
3026 gui->collect_assets(proxy);
3034 int AWindowAssets::drag_motion_event()
3036 BC_ListBox::drag_motion_event();
3039 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3040 mwindow->gui->drag_motion();
3041 mwindow->gui->unlock_window();
3043 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
3044 VWindow *vwindow = mwindow->vwindows.get(i);
3045 if( !vwindow->is_running() ) continue;
3046 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3047 vwindow->gui->drag_motion();
3048 vwindow->gui->unlock_window();
3051 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3052 mwindow->cwindow->gui->drag_motion();
3053 mwindow->cwindow->gui->unlock_window();
3055 lock_window("AWindowAssets::drag_motion_event");
3056 if( mwindow->session->current_operation == DRAG_ASSET &&
3057 gui->folder_list->cursor_above() ) { // highlight user folder
3058 BC_ListBoxItem *item = 0;
3059 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
3060 if( item_no >= 0 ) {
3061 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
3062 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
3065 item_no = gui->folder_list->item_to_index(&gui->folders, item);
3066 int folder_xposition = gui->folder_list->get_xposition();
3067 int folder_yposition = gui->folder_list->get_yposition();
3068 gui->folder_list->update(&gui->folders, 0, 0, 1,
3069 folder_xposition, folder_yposition, item_no, 0, 1);
3074 int AWindowAssets::drag_stop_event()
3078 result = gui->drag_stop();
3083 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3084 result = mwindow->gui->drag_stop();
3085 mwindow->gui->unlock_window();
3089 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
3090 VWindow *vwindow = mwindow->vwindows.get(i);
3091 if( !vwindow ) continue;
3092 if( !vwindow->is_running() ) continue;
3093 if( vwindow->gui->is_hidden() ) continue;
3094 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3095 if( vwindow->gui->cursor_above() &&
3096 vwindow->gui->get_cursor_over_window() ) {
3097 result = vwindow->gui->drag_stop();
3099 vwindow->gui->unlock_window();
3104 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3105 result = mwindow->cwindow->gui->drag_stop();
3106 mwindow->cwindow->gui->unlock_window();
3109 lock_window("AWindowAssets::drag_stop_event");
3111 result = gui->folder_list->drag_stop();
3116 get_drag_popup()->set_animation(0);
3118 BC_ListBox::drag_stop_event();
3119 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3120 mwindow->session->current_operation = ::NO_OPERATION;
3125 int AWindowAssets::column_resize_event()
3127 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3128 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3132 int AWindowAssets::cursor_enter_event()
3134 int ret = BC_ListBox::cursor_enter_event();
3135 switch( gui->vicon_drawing ) {
3136 case AVICON_FULL_PLAY:
3137 gui->start_vicon_drawing();
3139 case AVICON_MOUSE_OVER:
3140 case AVICON_SRC_TARGET:
3141 case AVICON_NO_PLAY:
3148 int AWindowAssets::cursor_leave_event()
3151 if( !is_event_win() ) return 0;
3152 if( !gui->vicon_thread->viewing )
3153 gui->stop_vicon_drawing();
3154 return BC_ListBox::cursor_leave_event();
3157 int AWindowAssets::focus_out_event()
3159 gui->stop_vicon_drawing();
3160 gui->vicon_thread->set_view_popup(0);
3161 return BC_ListBox::focus_out_event();
3164 void AWindowAssets::update_vicon_area()
3166 int x0 = 0, x1 = get_w();
3167 int y0 = get_title_h();
3169 if( is_highlighted() ) {
3170 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3171 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3173 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3176 int AWindowAssets::mouse_over_event(int no)
3178 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3179 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3180 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3181 switch( gui->vicon_drawing ) {
3182 case AVICON_FULL_PLAY:
3183 gui->vicon_thread->solo = 0;
3184 if( vicon && gui->vicon_thread->viewing )
3185 gui->vicon_thread->set_view_popup(vicon);
3187 case AVICON_MOUSE_OVER:
3189 gui->vicon_thread->solo = vicon;
3190 gui->start_vicon_drawing();
3192 case AVICON_SRC_TARGET:
3194 if( gui->vicon_thread->viewing )
3195 gui->vicon_thread->set_view_popup(vicon);
3197 case AVICON_NO_PLAY:
3201 if( no < 0 && info_tip >= 0 ) {
3204 if( gui->tip_info && no >= 0 &&
3205 info_tip != no && picon && picon->plugin ) {
3206 const char *info = picon->plugin->tip;
3207 if( !info ) info = _("No info available");
3208 show_tip_info(info, no);
3213 void AWindowAssets::show_tip_info(const char *info, int no)
3215 int tw = get_text_width(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3216 int th = get_text_height(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3217 int tx = get_w() - (tw + xS(28));
3218 int ty = get_h() - (th + yS(28));
3219 show_tooltip(info, tx, ty, tw, th);
3223 void AWindowAssets::hide_tip_info()
3229 // *** CONTEXT_HELP ***
3230 int AWindowAssets::keypress_event()
3233 char title[BCTEXTLEN];
3234 AssetPicon *picon = 0;
3235 PluginServer *plugin = 0;
3237 // printf("AWindowAssets::keypress_event: %d\n", get_keypress());
3239 // If not our context help keystroke, redispatch it
3240 // to the event handler of the base class
3241 if (get_keypress() != 'h' || ! alt_down() ||
3242 ! is_tooltip_event_win() || ! cursor_inside())
3243 return BC_ListBox::keypress_event();
3245 switch (mwindow->edl->session->awindow_folder) {
3247 case AW_AEFFECT_FOLDER:
3248 case AW_VEFFECT_FOLDER:
3249 case AW_ATRANSITION_FOLDER:
3250 case AW_VTRANSITION_FOLDER:
3251 // If plugin tips activated, show help for plugin under mouse
3252 // Otherwise show help for the selected plugin
3253 if (gui->tip_info) {
3254 item = BC_ListBox::get_highlighted_item();
3255 if (item >= 0 && item < gui->displayed_assets[0].size()) {
3256 picon = (AssetPicon *) gui->displayed_assets[0][item];
3257 if (picon) plugin = picon->plugin;
3260 else plugin = gui->selected_plugin();
3261 // If some plugin is highlighted or selected, show its help
3262 // Otherwise show more general help
3264 strcpy(title, plugin->title);
3265 if (! strcmp(title, "Overlay")) {
3266 // "Overlay" plugin title is ambiguous
3268 strcat(title, " \\(Audio\\)");
3270 strcat(title, " \\(Video\\)");
3272 if (plugin->is_ffmpeg()) {
3273 // FFmpeg plugins can be audio or video
3275 strcpy(title, "FFmpeg Audio Plugins");
3277 strcpy(title, "FFmpeg Video Plugins");
3279 context_help_show(title);
3283 switch (mwindow->edl->session->awindow_folder) {
3284 case AW_AEFFECT_FOLDER:
3285 context_help_show("Audio Effects");
3287 case AW_VEFFECT_FOLDER:
3288 context_help_show("Video Effects");
3290 case AW_ATRANSITION_FOLDER:
3291 context_help_show("Audio Transitions");
3293 case AW_VTRANSITION_FOLDER:
3294 context_help_show("Video Transitions");
3297 context_help_show("Resources Window");
3300 context_help_show("Resources Window");
3304 case AW_LABEL_FOLDER:
3305 context_help_show("Labels");
3308 case AW_CLIP_FOLDER:
3309 context_help_show("Nested Clips");
3312 case AW_PROXY_FOLDER:
3313 context_help_show("Proxy");
3317 context_help_show("Resources Window");
3321 context_help_show("Resources Window");
3326 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3327 : BC_TextBox(x, y, w, 1, "")
3329 this->search_text = search_text;
3332 int AWindowSearchTextBox::handle_event()
3334 return search_text->handle_event();
3337 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3339 this->mwindow = mwindow;
3345 void AWindowSearchText::create_objects()
3349 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3350 x1 += text_title->get_w() + xs10;
3351 int w1 = gui->get_w() - x1 - 2*xs10;
3352 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3355 int AWindowSearchText::handle_event()
3357 gui->async_update_assets();
3361 int AWindowSearchText::get_w()
3363 return text_box->get_w() + text_title->get_w() + xS(10);
3366 int AWindowSearchText::get_h()
3368 return bmax(text_box->get_h(),text_title->get_h());
3371 void AWindowSearchText::reposition_window(int x, int y, int w)
3375 text_title->reposition_window(x1, y1);
3376 x1 += text_title->get_w() + xs10;
3377 int w1 = gui->get_w() - x1 - 2*xs10;
3378 text_box->reposition_window(x1, y1, w1);
3381 const char *AWindowSearchText::get_text()
3383 return text_box->get_text();
3386 void AWindowSearchText::clear()
3388 text_box->update("");
3391 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3392 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3394 this->mwindow = mwindow;
3396 set_tooltip(_("Delete asset from disk"));
3399 int AWindowDeleteDisk::handle_event()
3404 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3405 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3407 this->mwindow = mwindow;
3409 set_tooltip(_("Delete asset from project"));
3412 int AWindowDeleteProject::handle_event()
3417 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3418 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3420 // this->mwindow = mwindow;
3422 // set_tooltip(_("Edit information on asset"));
3425 // int AWindowInfo::handle_event()
3427 // int cur_x, cur_y;
3428 // gui->get_abs_cursor(cur_x, cur_y, 0);
3429 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3433 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3434 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3436 this->mwindow = mwindow;
3438 set_tooltip(_("Redraw index"));
3441 int AWindowRedrawIndex::handle_event()
3446 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3447 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3449 this->mwindow = mwindow;
3451 set_tooltip(_("Paste asset on recordable tracks"));
3454 int AWindowPaste::handle_event()
3459 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3460 : BC_Button(x, y, mwindow->theme->appendasset_data)
3462 this->mwindow = mwindow;
3464 set_tooltip(_("Append asset in new tracks"));
3467 int AWindowAppend::handle_event()
3472 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3473 : BC_Button(x, y, mwindow->theme->viewasset_data)
3475 this->mwindow = mwindow;
3477 set_tooltip(_("View asset"));
3480 int AWindowView::handle_event()
3485 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3486 : BC_PopupMenu(x, y, title, -1, 0)
3488 this->mwindow = mwindow;
3492 void AddTools::create_objects()
3495 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3496 vis |= 1 << PLUGIN_FFMPEG_ID;
3497 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3498 vis |= 1 << PLUGIN_LADSPA_ID;
3500 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3501 vis |= 1 << PLUGIN_LV2_ID;
3503 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3504 PluginServer *plugin = MWindow::plugindb->get(i);
3505 if( !plugin->audio && !plugin->video ) continue;
3506 int idx = plugin->dir_idx;
3507 uint32_t msk = 1 << idx;
3508 if( (msk & vis) != 0 ) continue;
3510 char parent[BCTEXTLEN];
3511 strcpy(parent, plugin->path);
3512 char *bp = strrchr(parent, '/');
3513 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3514 if( !bp ) bp = parent; else ++bp;
3515 add_item(new AddPluginItem(this, bp, idx));
3520 // plugin_dirs list from toplevel makefile include plugin_defs
3525 N_("audio_transitions")
3532 N_("video_transitions")
3535 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3536 : BC_MenuItem(_(text))
3540 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3541 int chk = (msk & vis) ? 1 : 0;
3545 int AddPluginItem::handle_event()
3547 int chk = get_checked() ^ 1;
3549 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3550 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3551 menu->gui->update_effects();
3552 menu->gui->save_defaults(menu->mwindow->defaults);
3553 menu->gui->async_update_assets();
3557 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3560 this->avicon = avicon;
3564 int AVIconDrawingItem::handle_event()
3566 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3567 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3568 item->set_checked(id == i);
3570 AWindowGUI *agui = avicon->agui;
3572 avicon->set_text(get_text());
3573 agui->stop_vicon_drawing();
3574 agui->vicon_thread->set_view_popup(0);
3575 agui->vicon_thread->solo = 0;
3576 agui->vicon_drawing = id;
3577 agui->start_vicon_drawing();
3581 int AVIconDrawing::draw_face(int dx, int color)
3583 int ret = BC_PopupMenu::draw_face(dx, color);
3584 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3585 int lx = get_margin(), ly = get_h()/2;
3586 draw_line(lx,ly, get_w()-2*lx,ly);
3591 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3592 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3597 AVIconDrawing::~AVIconDrawing()
3601 void AVIconDrawing::create_objects()
3603 AVIconDrawingItem *item;
3604 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3605 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3606 item->set_checked(agui->vicon_drawing == i);
3610 int AVIconDrawing::button_press_event()
3612 if( !is_event_win() ) return 0;
3613 if( get_buttonpress() == MIDDLE_BUTTON ) {
3614 agui->play_off = !agui->play_off ? 1 : 0;
3617 agui->start_vicon_drawing();
3620 return BC_PopupMenu::button_press_event();
3623 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3624 : BC_MenuItem("","v",'v')
3626 this->mwindow = mwindow;
3630 int AWindowListFormat::handle_event()
3632 return gui->cycle_assetlist_format();
3635 void AWindowListFormat::update()
3637 EDLSession *session = mwindow->edl->session;
3638 const char *text = 0;
3639 switch( session->assetlist_format ) {
3641 text = _("Display icons");
3644 text = _("Display icons packed");
3646 case ASSETS_ICONS_PACKED:
3647 text = _("Display icon list");
3649 case ASSETS_ICON_LIST:
3650 text = _("Display text");
3656 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3657 : BC_MenuItem(_("Sort items"))
3659 this->mwindow = mwindow;
3663 int AWindowListSort::handle_event()
3669 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3672 this->select_used = select_used;
3673 this->action = action;
3676 int AssetSelectUsedItem::handle_event()
3678 MWindow *mwindow = select_used->mwindow;
3679 AWindowGUI *gui = select_used->gui;
3680 AWindowAssets *asset_list = gui->asset_list;
3681 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3686 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3690 asset_list->set_all_selected(data, 0);
3691 for( int i = 0; i < data->total; i++ ) {
3692 AssetPicon *picon = (AssetPicon*)data->values[i];
3693 Indexable *idxbl = picon->indexable ? picon->indexable :
3694 picon->edl ? picon->edl->get_proxy_asset() : 0;
3695 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3696 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3701 int asset_xposition = asset_list->get_xposition();
3702 int asset_yposition = asset_list->get_yposition();
3703 asset_list->update(gui->displayed_assets, gui->asset_titles,
3704 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3705 asset_xposition, asset_yposition, -1, 0);
3706 asset_list->center_selection();
3710 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3711 : BC_MenuItem(_("Select"))
3713 this->mwindow = mwindow;