4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "assetedit.h"
26 #include "assetpopup.h"
27 #include "assetremove.h"
29 #include "audiodevice.h"
31 #include "awindowgui.h"
32 #include "bccmodels.h"
33 #include "bcdisplayinfo.h"
35 #include "bcsignals.h"
37 #include "binfolder.h"
42 #include "clippopup.h"
44 #include "cwindowgui.h"
49 #include "edlsession.h"
50 #include "effectlist.h"
52 #include "filesystem.h"
53 #include "folderlistmenu.h"
54 #include "indexable.h"
58 #include "labelpopup.h"
59 #include "localsession.h"
60 #include "mainerror.h"
62 #include "mainsession.h"
63 #include "mwindowgui.h"
65 #include "preferences.h"
67 #include "proxypopup.h"
68 #include "renderengine.h"
73 #include "transportque.h"
77 #include "vwindowgui.h"
80 #include "data/lad_picon_png.h"
81 #include "data/ff_audio_png.h"
82 #include "data/ff_video_png.h"
89 const char *AWindowGUI::folder_names[] =
93 N_("Audio Transitions"),
94 N_("Video Transitions"),
101 const char *AVIconDrawing::avicon_names[] =
109 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
110 : VIcon(w, h, framerate), Garbage("AssetVIcon")
113 this->length = length;
118 AssetVIcon::~AssetVIcon()
120 if( picon->gui->vicon_thread->solo == this )
121 picon->gui->vicon_thread->solo = 0;
122 picon->gui->vicon_thread->del_vicon(this);
126 VFrame *AssetVIcon::frame()
128 if( broken ) return 0;
129 AssetVIconThread *avt = picon->gui->vicon_thread;
130 Indexable *idxbl = picon->indexable;
131 Asset *asset = idxbl && idxbl->is_asset ? (Asset *)idxbl : 0;
132 if( !asset ) return vframes()>0 ? images[0]->vfrm : 0;
133 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
134 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
136 int sample_rate = asset->get_sample_rate();
137 int64_t audio_samples = asset->get_audio_samples();
138 double duration = (double)audio_samples / sample_rate;
139 picon->draw_hue_bar(temp, duration);
140 int secs = length / frame_rate + 0.5;
141 if( !secs ) secs = 1;
142 int bfrsz = VICON_SAMPLE_RATE;
143 int samples = audio_size/sizeof(vicon_audio_t);
144 double line_pos = (double)seq_no/(length-1);
145 int audio_pos = samples * line_pos * (secs-1)/secs;
146 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
147 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
148 double data[bfrsz], sample_scale = 1./mx;
149 int len = samples - audio_pos;
150 if( len > bfrsz ) len = bfrsz;
152 while( i < len ) data[i++] = *audio_data++ * sample_scale;
153 while( i < bfrsz ) data[i++] = 0;
154 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
155 int x = (w-1) * line_pos;
156 temp->pixel_rgb = RED;
157 temp->draw_line(x,0, x,h);
160 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
161 if( !asset->video_data ) {
163 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
168 if( seq_no >= images.size() ) {
169 MWindow *mwindow = picon->mwindow;
170 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
171 delete temp; temp = 0;
174 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
175 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
176 if( !file ) { broken = 1; return 0; }
178 while( file && seq_no >= images.size() ) {
179 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
180 file->set_video_position(pos,0);
182 if( file->read_frame(temp) ) temp->clear_frame();
183 add_image(temp, vw, vh, vicon_cmodel);
184 if( seq_no < images.size() ) break;
185 mwindow->video_cache->check_in(asset);
186 if( timer.get_difference() > 500 ) return 0;
188 if( avt->interrupted ) return 0;
189 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
190 for( int retries=10; !file && --retries>=0; usleep(1000) ) {
191 if( avt->interrupted ) return 0;
192 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
194 if( !file ) return 0;
196 mwindow->video_cache->check_in(asset);
198 if( seq_no >= images.size() ) return 0;
199 return images[seq_no]->vfrm;
202 int64_t AssetVIcon::set_seq_no(int64_t no)
204 if( no >= length ) no = 0;
208 int AssetVIcon::get_vx()
210 BC_ListBox *lbox = picon->gui->asset_list;
211 return lbox->get_icon_x(picon);
213 int AssetVIcon::get_vy()
215 BC_ListBox *lbox = picon->gui->asset_list;
216 return lbox->get_icon_y(picon);
219 void AssetVIcon::load_audio()
221 MWindow *mwindow = picon->mwindow;
222 Asset *asset = (Asset *)picon->indexable;
223 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
224 int channels = asset->get_audio_channels();
225 if( channels > 2 ) channels = 2;
226 int sample_rate = asset->get_sample_rate();
227 int bfrsz = sample_rate;
228 Samples samples(bfrsz);
229 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
230 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
231 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
232 double sample_scale = (double)mx / channels;
233 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
234 while( audio_pos < audio_len ) {
235 int64_t pos = audio_pos * time_scale;
236 for( int ch=0; ch<channels; ++ch ) {
237 file->set_channel(ch);
238 file->set_audio_position(pos);
239 file->read_samples(&samples, bfrsz);
240 double *data = samples.get_data();
241 for( int64_t k=audio_pos; k<audio_len; ++k ) {
242 int i = k * time_scale - pos;
243 if( i >= bfrsz ) break;
244 int v = audio_data[k] + data[i] * sample_scale;
245 audio_data[k] = CLIP(v, -mx,mx);
248 audio_pos = (pos + bfrsz) / time_scale;
250 mwindow->audio_cache->check_in(asset);
254 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
258 audio = new AudioDevice(gui->mwindow);
262 AssetVIconAudio::~AssetVIconAudio()
267 void AssetVIconAudio::run()
270 int64_t bfrsz = VICON_SAMPLE_RATE;
271 MWindow *mwindow = gui->mwindow;
272 EDL *edl = mwindow->edl;
273 EDLSession *session = edl->session;
274 AudioOutConfig *aconfig = session->playback_config->aconfig;
275 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
276 audio->start_playback();
277 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
278 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
279 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
281 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
282 while( !interrupted ) {
283 int len = audio_len - audio_pos;
284 if( len <= 0 ) break;
285 if( len > bfrsz ) len = bfrsz;
287 for( int i=0; i<len; ++i,++k )
288 out0[i] = out1[i] = (double)audio_data[k] / mx;
290 audio->write_buffer(out, channels, len);
294 audio->set_last_buffer();
295 audio->stop_audio(interrupted ? 0 : 1);
299 void AssetVIconAudio::start(AssetVIcon *vicon)
301 if( running() ) return;
303 double pos = vicon->length > 0 ? (double)vicon->seq_no/vicon->length : 0;
304 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
305 audio_pos = pos * audio_len;
310 void AssetVIconAudio::stop(int wait)
312 if( running() && !interrupted ) {
314 audio->stop_audio(wait);
318 vicon->playing_audio = 0;
323 void AssetVIcon::start_audio()
325 if( playing_audio < 0 ) return;
326 picon->gui->vicon_audio->stop(0);
328 picon->gui->vicon_audio->start(this);
331 void AssetVIcon::stop_audio()
333 if( playing_audio > 0 ) {
334 picon->gui->vicon_audio->stop(0);
339 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
340 int x, int y, int w, int h)
341 : ViewPopup(vt, x, y, w, h)
343 this->draw_mode = draw_mode;
344 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
348 AssetViewPopup::~AssetViewPopup()
352 int AssetViewPopup::reposition_window(int x, int y, int w, int h)
354 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
355 return ViewPopup::reposition_window(x, y, w, h);
358 int AssetViewPopup::button_press_event()
360 if( !is_event_win() ) return 0;
361 AssetVIconThread *avt = (AssetVIconThread *)vt;
362 if( !avt->vicon ) return 0;
365 switch( get_buttonpress() ) {
369 avt->set_view_popup(0);
372 dir = -1; // fall thru
374 switch( draw_mode ) {
375 case ASSET_VIEW_MEDIA:
376 case ASSET_VIEW_MEDIA_MAP:
377 avt->zoom_scale(dir);
384 int x = get_cursor_x(), y = get_cursor_y();
385 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
386 AssetPicon *picon = vicon->picon;
387 MWindow *mwindow = picon->mwindow;
388 EDL *edl = mwindow->edl;
390 if( y < get_h()/2 ) {
392 picon->indexable ? picon->indexable :
393 picon->edl ? picon->edl : 0;
394 if( !idxbl ) return 0;
395 double sample_rate = idxbl->get_sample_rate();
396 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
397 idxbl->get_audio_samples() / sample_rate : 0;
398 double frame_rate = idxbl->get_frame_rate();
399 double video_length = frame_rate > 0 && idxbl->have_video() ?
400 idxbl->get_video_frames() / frame_rate : 0;
401 double idxbl_length = bmax(audio_length, video_length);
402 double pos = x * idxbl_length / get_w();
403 double start = 0, end = idxbl_length;
404 double lt = DBL_MAX, rt = DBL_MAX;
405 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
406 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
407 Indexable *indexable = (Indexable *)edit->asset;
408 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
409 if( !indexable ) continue;
410 if( indexable->id == idxbl->id ||
411 (!indexable->is_asset == !idxbl->is_asset &&
412 !strcmp(indexable->path, idxbl->path)) ) {
413 double start_pos = track->from_units(edit->startsource);
414 double end_pos = track->from_units(edit->startsource + edit->length);
415 double dlt = pos - start_pos, drt = end_pos - pos;
416 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
417 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
418 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
419 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
423 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
424 VWindow *vwindow = mwindow->get_viewer(1, 0);
425 vwindow->change_source(idxbl);
426 mwindow->gui->unlock_window();
427 EDL *vedl = vwindow->get_edl();
428 vedl->set_inpoint(start);
429 vedl->set_outpoint(end);
430 vedl->local_session->set_selectionstart(start);
431 vedl->local_session->set_selectionend(start);
432 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
433 vwindow->update_position();
434 vwindow->gui->unlock_window();
439 if( !ctrl_down() && !shift_down() )
440 return cursor_motion_event();
442 picon->indexable ? picon->indexable :
443 picon->edl ? picon->edl : 0;
444 if( !idxbl ) return 0;
445 double total_length = mwindow->edl->tracks->total_length();
446 double pos = x * total_length / get_w();
447 double start = 0, end = total_length;
448 double lt = DBL_MAX, rt = DBL_MAX;
449 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
450 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
451 Indexable *indexable = (Indexable *)edit->asset;
452 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
453 if( !indexable ) continue;
454 if( indexable->id == idxbl->id ||
455 (!indexable->is_asset == !idxbl->is_asset &&
456 !strcmp(indexable->path, idxbl->path)) ) {
457 double start_pos = track->from_units(edit->startproject);
458 double end_pos = track->from_units(edit->startproject + edit->length);
459 double dlt = pos - start_pos, drt = end_pos - pos;
460 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
461 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
462 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
463 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
467 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
468 mwindow->select_point(start);
469 edl->local_session->set_selectionstart(start);
470 edl->local_session->set_selectionend(!shift_down() ? start : end);
471 mwindow->zoom_sample(edl->local_session->zoom_sample);
472 mwindow->gui->unlock_window();
478 int AssetViewPopup::button_release_event()
480 if( !is_event_win() ) return 0;
485 int AssetViewPopup::cursor_motion_event()
487 AssetVIconThread *avt = (AssetVIconThread *)vt;
488 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
489 if( vicon && dragging && is_event_win() &&
490 get_button_down() && get_buttonpress() == LEFT_BUTTON &&
491 !ctrl_down() && !alt_down() && !shift_down() ) {
492 switch( draw_mode ) {
493 case ASSET_VIEW_MEDIA_MAP:
494 case ASSET_VIEW_FULL:
495 MWindow *mwindow = vicon->picon->mwindow;
496 EDL *edl = mwindow->edl;
497 int x = get_cursor_x();
498 double total_length = edl->tracks->total_length();
499 double pos = x * total_length / get_w();
500 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
501 mwindow->select_point(pos);
502 mwindow->zoom_sample(edl->local_session->zoom_sample);
503 mwindow->gui->unlock_window();
510 void AssetViewPopup::draw_vframe(VFrame *vframe)
512 switch( draw_mode ) {
513 case ASSET_VIEW_MEDIA:
514 case ASSET_VIEW_ICON:
515 ViewPopup::draw_vframe(vframe);
516 case ASSET_VIEW_NONE:
519 case ASSET_VIEW_MEDIA_MAP:
520 case ASSET_VIEW_FULL:
524 draw_box(0,0,get_w(),get_h());
526 int y2 = get_h()-bar_h;
527 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
528 AssetVIconThread *avt = (AssetVIconThread *)vt;
529 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
530 AssetPicon *picon = (AssetPicon *)vicon->picon;
532 picon->indexable ? picon->indexable :
533 picon->edl ? picon->edl : 0;
535 double sample_rate = idxbl->get_sample_rate();
536 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
537 idxbl->get_audio_samples() / sample_rate : 0;
538 double frame_rate = idxbl->get_frame_rate();
539 double video_length = frame_rate > 0 && idxbl->have_video() ?
540 idxbl->get_video_frames() / frame_rate : 0;
541 double idxbl_length = bmax(audio_length, video_length);
542 if( !idxbl_length ) idxbl_length = 1;
544 EDL *edl = picon->mwindow->edl;
545 double total_length = edl->tracks->total_length();
546 if( !total_length ) total_length = 1;
547 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
548 if( !track->is_armed() ) continue;
549 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
550 Indexable *indexable = (Indexable *)edit->asset;
551 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
552 if( !indexable ) continue;
553 if( indexable->id == idxbl->id ||
554 (!indexable->is_asset == !idxbl->is_asset &&
555 !strcmp(indexable->path, idxbl->path)) ) {
556 double pos1 = track->from_units(edit->startsource);
557 double pos2 = track->from_units(edit->startsource + edit->length);
558 double xscale = get_w() / idxbl_length;
559 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
561 draw_box(ex1,0, ex2-ex1,y1);
563 draw_line(ex1,0, ex1,y1);
564 draw_line(ex2,0, ex2,y1);
565 pos1 = track->from_units(edit->startproject);
566 pos2 = track->from_units(edit->startproject + edit->length);
567 xscale = get_w() / total_length;
568 int px1 = pos1 * xscale, px2 = pos2 * xscale;
570 draw_box(px1,y2, px2-px1,get_h()-y2);
572 draw_line(px1,y2, px1,get_h()-1);
573 draw_line(px2,y2, px2,get_h()-1);
576 draw_line(ex1,y1, px1,y2);
577 draw_line(ex2,y1, px2,y2);
583 int AssetViewPopup::keypress_event()
586 AssetVIconThread *avt = (AssetVIconThread *)vt;
587 switch( avt->draw_mode ) {
588 case ASSET_VIEW_MEDIA_MAP:
589 switch( get_keypress() ) {
592 avt->draw_mode = ASSET_VIEW_FULL;
596 case ASSET_VIEW_FULL:
597 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
600 if( result ) // zero change for refresh
602 return ViewPopup::keypress_event();
606 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
607 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
608 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
611 draw_mode = ASSET_VIEW_NONE;
612 int vicon_cmodel = BC_RGB8;
613 switch( preferences->vicon_color_mode ) {
614 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
615 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
616 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
618 this->vicon_cmodel = vicon_cmodel;
621 AssetVIconThread::~AssetVIconThread()
625 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
627 gui->stop_vicon_drawing();
628 this->draw_mode = draw_mode;
630 gui->start_vicon_drawing();
633 void AssetVIconThread::set_view_popup(AssetVIcon *v)
635 if( !v ) draw_mode = ASSET_VIEW_NONE;
636 VIconThread::set_view_popup(v);
639 ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
641 BC_WindowBase *parent = wdw->get_parent();
642 int rx = 0, ry = 0, rw = 0, rh = 0;
643 if( draw_mode != ASSET_VIEW_FULL ) {
644 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
645 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
646 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
647 int vx = viewing->get_vx(), vy = viewing->get_vy();
648 wdw->get_root_coordinates(vx, vy, &rx, &ry);
649 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
650 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
651 rw = view_w; rh = view_h;
654 parent->get_fullscreen_geometry(rx, ry, rw, rh);
655 AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
657 av_popup->reposition_window(rx, ry, rw, rh);
659 av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
660 int playing_audio = gui->play_off ? -1 : 0;
661 if( !playing_audio ) {
662 switch( draw_mode ) {
663 case ASSET_VIEW_NONE:
664 case ASSET_VIEW_ICON:
665 case ASSET_VIEW_MEDIA_MAP:
666 case ASSET_VIEW_FULL:
669 case ASSET_VIEW_MEDIA:
670 switch( gui->vicon_drawing ) {
671 case AVICON_SRC_TARGET:
678 vicon->playing_audio = playing_audio;
679 wdw->set_active_subwindow(av_popup);
683 void AssetVIconThread::stop_vicon_drawing(int wait)
686 gui->lock_window("AssetVIconThread::stop_vicon_drawing");
687 gui->unlock_window();
691 AWindowFolderItem::AWindowFolderItem()
697 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
698 : BC_ListBoxItem(text, color)
703 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
704 : BC_ListBoxItem(text, icon, color)
709 AssetPicon *AWindowFolderItem::get_picon()
711 AWindowFolderItem *item = this;
712 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
713 return (AssetPicon*)item;
716 int AWindowFolderSubItems::matches(const char *text)
718 int i = names.size();
719 while( --i >= 0 && strcmp(names[i], text) );
721 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
722 i = sublist ? sublist->size() : 0;
724 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
725 if( item->matches(text) ) break;
728 return i >= 0 ? 1 : 0;
732 AssetPicon::AssetPicon(MWindow *mwindow,
733 AWindowGUI *gui, Indexable *indexable)
734 : AWindowFolderItem()
737 this->mwindow = mwindow;
739 this->indexable = indexable;
740 indexable->add_user();
741 this->id = indexable->id;
744 AssetPicon::AssetPicon(MWindow *mwindow,
745 AWindowGUI *gui, EDL *edl)
746 : AWindowFolderItem()
749 this->mwindow = mwindow;
756 AssetPicon::AssetPicon(MWindow *mwindow,
757 AWindowGUI *gui, int folder, int persist)
758 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
759 folder>=0 && folder<AWINDOW_FOLDERS ?
760 gui->folder_icons[folder] : gui->folder_icon)
764 this->mwindow = mwindow;
766 persistent = persist;
769 AssetPicon::AssetPicon(MWindow *mwindow,
770 AWindowGUI *gui, int folder, const char *title)
771 : AWindowFolderItem(title, gui->folder_icon)
775 this->mwindow = mwindow;
780 AssetPicon::AssetPicon(MWindow *mwindow,
781 AWindowGUI *gui, PluginServer *plugin)
782 : AWindowFolderItem()
785 this->mwindow = mwindow;
787 this->plugin = plugin;
790 AssetPicon::AssetPicon(MWindow *mwindow,
791 AWindowGUI *gui, Label *label)
792 : AWindowFolderItem()
795 this->mwindow = mwindow;
803 AssetPicon::~AssetPicon()
805 if( vicon ) vicon->remove_user();
807 if( indexable ) indexable->remove_user();
808 if( edl ) edl->remove_user();
809 if( icon && !gui->protected_pixmap(icon) ) {
811 if( !plugin ) delete icon_vframe;
815 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
817 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
819 float h = 300 * t, s = 1., v = 1.;
820 float r, g, b; // duration, 0..1hr == hue red..magenta
821 HSV::hsv_to_rgb(r,g,b, h,s,v);
822 int ih = frame->get_h()/8, iw = frame->get_w();
823 int ir = r * 256; CLAMP(ir, 0,255);
824 int ig = g * 256; CLAMP(ig, 0,255);
825 int ib = b * 256; CLAMP(ib, 0,255);
826 unsigned char **rows = frame->get_rows();
827 for( int y=0; y<ih; ++y ) {
828 unsigned char *rp = rows[y];
829 for( int x=0; x<iw; rp+=3,++x ) {
830 rp[0] = ir; rp[1] = ig; rp[2] = ib;
835 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
836 int base_color, int line_color, int x, int y, int w, int h)
838 int h1 = h-1, h2 = h/2, iy = h2;
839 int rgb_color = frame->pixel_rgb;
840 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
841 double min = *dp, max = min;
842 x2 = (len * (ix+1))/w;
843 for( int i=x1; i<x2; ++i ) {
844 double value = *dp++;
845 if( value < min ) min = value;
846 if( value > max ) max = value;
848 int ctr = (min + max) / 2;
849 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
850 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
851 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
852 frame->pixel_rgb = line_color;
853 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
854 frame->pixel_rgb = base_color;
855 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
858 frame->pixel_rgb = rgb_color;
861 void AssetPicon::reset()
869 foldernum = AW_NO_FOLDER;
884 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
886 TransportCommand command(mwindow->preferences);
887 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
888 command.get_edl()->copy_all(edl);
889 command.change_type = CHANGE_ALL;
890 command.realtime = 0;
891 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
892 render_engine->set_vcache(mwindow->video_cache);
893 render_engine->set_acache(mwindow->audio_cache);
894 render_engine->arm_command(&command);
896 void AssetPicon::close_render_engine()
898 delete render_engine; render_engine = 0;
900 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
902 if( !render_engine || !render_engine->vrender ) return;
903 render_engine->vrender->process_buffer(vfrm, pos, 0);
905 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
907 if( !render_engine || !render_engine->arender ) return;
908 render_engine->arender->process_buffer(samples, len, pos);
911 void AssetPicon::create_objects()
914 char name[BCTEXTLEN];
915 int pixmap_w, pixmap_h;
917 int picon_h = mwindow->preferences->awindow_picon_h;
918 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
924 if( this->indexable ) {
926 if( this->indexable->is_asset ) {
927 asset = (Asset *)indexable;
928 if( asset->format == FILE_REF ) {
929 cp += sprintf(cp, "ref:");
930 set_color(get_color() ^ 0x5599CC);
934 edl = (EDL *)indexable;
935 cp += sprintf(cp, "edl:");
936 // set_color(get_color() ^ 0xCC9955);
938 fs.extract_name(cp, indexable->path);
941 else if( this->edl ) {
943 strcpy(name, edl->local_session->clip_title);
949 if( asset->video_data ) {
950 if( mwindow->preferences->use_thumbnails ) {
951 gui->unlock_window();
952 char string[BCTEXTLEN];
953 sprintf(string, _("Reading %s"), name);
954 mwindow->gui->lock_window("AssetPicon::create_objects");
955 mwindow->gui->show_message(string);
956 mwindow->gui->unlock_window();
957 File *file = mwindow->video_cache->check_out(asset,
962 int height = asset->height > 0 ? asset->height : 1;
963 pixmap_w = pixmap_h * asset->width / height;
966 file->set_video_position(0, 0);
968 if( gui->temp_picon &&
969 (gui->temp_picon->get_w() != asset->width ||
970 gui->temp_picon->get_h() != asset->height) ) {
971 delete gui->temp_picon;
975 if( !gui->temp_picon ) {
976 gui->temp_picon = new VFrame(0, -1,
977 asset->width, asset->height,
980 file->read_frame(gui->temp_picon);
981 mwindow->video_cache->check_in(asset);
983 gui->lock_window("AssetPicon::create_objects 0");
984 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
985 icon->draw_vframe(gui->temp_picon,
986 0, 0, pixmap_w, pixmap_h, 0, 0);
987 icon_vframe = new VFrame(0,
988 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
989 icon_vframe->transfer_from(gui->temp_picon);
990 if( asset->folder_no == AW_MEDIA_FOLDER ||
991 asset->folder_no == AW_PROXY_FOLDER ) {
993 double framerate = asset->get_frame_rate();
994 if( !framerate ) framerate = VICON_RATE;
995 int64_t frames = asset->get_video_frames();
996 double secs = frames / framerate;
997 if( secs > 5 ) secs = 5;
998 int64_t length = secs * gui->vicon_thread->refresh_rate;
999 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
1000 if( asset->audio_data && secs > 0 ) {
1001 gui->unlock_window();
1002 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1003 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1004 vicon->load_audio();
1005 gui->lock_window("AssetPicon::create_objects 1");
1007 gui->vicon_thread->add_vicon(vicon);
1011 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1012 gui->lock_window("AssetPicon::create_objects 2");
1013 icon = gui->video_icon;
1014 icon_vframe = gui->video_vframe;
1018 icon = gui->video_icon;
1019 icon_vframe = gui->video_vframe;
1023 if( asset->audio_data ) {
1024 if( mwindow->preferences->use_thumbnails ) {
1025 gui->unlock_window();
1026 File *file = mwindow->audio_cache->check_out(asset,
1030 pixmap_w = pixmap_h * 16/9;
1031 icon_vframe = new VFrame(0,
1032 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1033 icon_vframe->clear_frame();
1034 { char string[BCTEXTLEN];
1035 sprintf(string, _("Reading %s"), name);
1036 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1037 mwindow->gui->show_message(string);
1038 mwindow->gui->unlock_window(); }
1039 int sample_rate = asset->get_sample_rate();
1040 int channels = asset->get_audio_channels();
1041 if( channels > 2 ) channels = 2;
1042 int64_t audio_samples = asset->get_audio_samples();
1043 double duration = (double)audio_samples / sample_rate;
1044 draw_hue_bar(icon_vframe, duration);
1045 int bfrsz = sample_rate;
1046 Samples samples(bfrsz);
1047 static int line_colors[2] = { GREEN, YELLOW };
1048 static int base_colors[2] = { RED, PINK };
1049 for( int i=channels; --i>=0; ) {
1050 file->set_channel(i);
1051 file->set_audio_position(0);
1052 file->read_samples(&samples, bfrsz);
1053 draw_wave(icon_vframe, samples.get_data(), bfrsz,
1054 base_colors[i], line_colors[i]);
1056 mwindow->audio_cache->check_in(asset);
1057 if( asset->folder_no == AW_MEDIA_FOLDER ) {
1058 double secs = duration;
1059 if( secs > 5 ) secs = 5;
1060 double refresh_rate = gui->vicon_thread->refresh_rate;
1061 int64_t length = secs * refresh_rate;
1062 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1063 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1064 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1065 vicon->load_audio();
1066 gui->vicon_thread->add_vicon(vicon);
1068 gui->lock_window("AssetPicon::create_objects 4");
1069 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1070 icon->draw_vframe(icon_vframe,
1071 0, 0, pixmap_w, pixmap_h, 0, 0);
1074 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1075 gui->lock_window("AssetPicon::create_objects 5");
1076 icon = gui->audio_icon;
1077 icon_vframe = gui->audio_vframe;
1081 icon = gui->audio_icon;
1082 icon_vframe = gui->audio_vframe;
1087 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1088 comments_rate = asset->get_frame_rate();
1089 comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
1090 comments_type = asset->format == FILE_FFMPEG ?
1091 asset->vcodec : File::formattostr(asset->format);
1094 if( edl->tracks->playable_video_tracks() ) {
1095 if( mwindow->preferences->use_thumbnails ) {
1096 gui->unlock_window();
1097 AssetVIconThread *avt = gui->vicon_thread;
1098 char clip_icon_path[BCTEXTLEN];
1099 char *clip_icon = edl->local_session->clip_icon;
1101 if( is_clip && clip_icon[0] ) {
1102 snprintf(clip_icon_path, sizeof(clip_icon_path),
1103 "%s/%s", File::get_config_path(), clip_icon);
1104 vframe = VFramePng::vframe_png(clip_icon_path);
1107 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1108 delete vframe; vframe = 0;
1110 int edl_h = edl->get_h(), edl_w = edl->get_w();
1111 int height = edl_h > 0 ? edl_h : 1;
1112 int width = edl_w > 0 ? edl_w : 1;
1113 int color_model = edl->session->color_model;
1115 //printf("render clip: %s\n", name);
1116 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1117 char string[BCTEXTLEN];
1118 sprintf(string, _("Rendering %s"), name);
1119 mwindow->gui->lock_window("AssetPicon::create_objects");
1120 mwindow->gui->show_message(string);
1121 mwindow->gui->unlock_window();
1122 open_render_engine(edl, 0);
1123 render_video(0, gui->temp_picon);
1124 close_render_engine();
1125 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1126 vframe->transfer_from(gui->temp_picon);
1127 if( this->edl && clip_icon[0] )
1128 vframe->write_png(clip_icon_path);
1130 pixmap_w = pixmap_h * width / height;
1131 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1132 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1133 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1134 icon_vframe->transfer_from(vframe);
1136 gui->lock_window("AssetPicon::create_objects 0");
1137 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1138 icon->draw_vframe(icon_vframe,
1139 0, 0, pixmap_w, pixmap_h, 0, 0);
1141 else if( is_clip ) {
1142 icon = gui->clip_icon;
1143 icon_vframe = gui->clip_vframe;
1146 icon = gui->video_icon;
1147 icon_vframe = gui->video_vframe;
1151 if( edl->tracks->playable_audio_tracks() ) {
1152 if( mwindow->preferences->use_thumbnails ) {
1153 gui->unlock_window();
1154 char clip_icon_path[BCTEXTLEN];
1155 char *clip_icon = edl->local_session->clip_icon;
1156 if( is_clip && clip_icon[0] ) {
1157 snprintf(clip_icon_path, sizeof(clip_icon_path),
1158 "%s/%s", File::get_config_path(), clip_icon);
1159 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1161 if( !icon_vframe ) {
1162 pixmap_w = pixmap_h * 16/9;
1163 icon_vframe = new VFrame(0,
1164 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1165 icon_vframe->clear_frame();
1166 char string[BCTEXTLEN];
1167 sprintf(string, _("Rendering %s"), name);
1168 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1169 mwindow->gui->show_message(string);
1170 mwindow->gui->unlock_window();
1171 int sample_rate = edl->get_sample_rate();
1172 int channels = edl->get_audio_channels();
1173 if( channels > 2 ) channels = 2;
1174 int64_t audio_samples = edl->get_audio_samples();
1175 double duration = (double)audio_samples / sample_rate;
1176 draw_hue_bar(icon_vframe, duration);
1177 Samples *samples[MAX_CHANNELS];
1178 int bfrsz = sample_rate;
1179 for( int i=0; i<MAX_CHANNELS; ++i )
1180 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1181 open_render_engine(edl, 1);
1182 render_audio(0, samples, bfrsz);
1183 close_render_engine();
1184 gui->lock_window("AssetPicon::create_objects 4");
1185 static int line_colors[2] = { GREEN, YELLOW };
1186 static int base_colors[2] = { RED, PINK };
1187 for( int i=channels; --i>=0; ) {
1188 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1189 base_colors[i], line_colors[i]);
1191 for( int i=0; i<channels; ++i ) delete samples[i];
1192 if( is_clip && clip_icon[0] )
1193 icon_vframe->write_png(clip_icon_path);
1196 pixmap_w = icon_vframe->get_w();
1197 pixmap_h = icon_vframe->get_h();
1199 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1200 icon->draw_vframe(icon_vframe,
1201 0, 0, pixmap_w, pixmap_h, 0, 0);
1203 else if( !indexable ) {
1204 icon = gui->clip_icon;
1205 icon_vframe = gui->clip_vframe;
1208 icon = gui->audio_icon;
1209 icon_vframe = gui->audio_vframe;
1214 strcpy(name, _(plugin->title));
1216 icon_vframe = plugin->get_picon();
1218 icon = gui->create_pixmap(icon_vframe);
1219 else if( plugin->audio ) {
1220 if( plugin->transition ) {
1221 icon = gui->atransition_icon;
1222 icon_vframe = gui->atransition_vframe;
1224 else if( plugin->is_ffmpeg() ) {
1225 icon = gui->ff_aud_icon;
1226 icon_vframe = gui->ff_aud_vframe;
1228 else if( plugin->is_ladspa() ) {
1229 icon = gui->ladspa_icon;
1230 icon_vframe = gui->ladspa_vframe;
1233 icon = gui->aeffect_icon;
1234 icon_vframe = gui->aeffect_vframe;
1237 else if( plugin->video ) {
1238 if( plugin->transition ) {
1239 icon = gui->vtransition_icon;
1240 icon_vframe = gui->vtransition_vframe;
1242 else if( plugin->is_ffmpeg() ) {
1243 icon = gui->ff_vid_icon;
1244 icon_vframe = gui->ff_vid_vframe;
1247 icon = gui->veffect_icon;
1248 icon_vframe = gui->veffect_vframe;
1255 mwindow->edl->session->time_format,
1256 mwindow->edl->session->sample_rate,
1257 mwindow->edl->session->frame_rate,
1258 mwindow->edl->session->frames_per_foot);
1260 icon = gui->label_icon;
1261 icon_vframe = gui->label_vframe;
1264 icon = gui->file_icon;
1265 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1268 set_icon_vframe(icon_vframe);
1271 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1272 : BC_Window(_(PROGRAM_NAME ": Resources"),
1273 mwindow->session->awindow_x, mwindow->session->awindow_y,
1274 mwindow->session->awindow_w, mwindow->session->awindow_h,
1275 xS(100), yS(100), 1, 1, 1)
1277 this->mwindow = mwindow;
1278 this->awindow = awindow;
1280 file_vframe = 0; file_icon = 0;
1281 folder_vframe = 0; folder_icon = 0;
1282 audio_vframe = 0; audio_icon = 0;
1283 video_vframe = 0; video_icon = 0;
1284 label_vframe = 0; label_icon = 0;
1286 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1287 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1288 clip_folder_vframe = 0; clip_folder_icon = 0;
1289 label_folder_vframe = 0; label_folder_icon = 0;
1290 media_folder_vframe = 0; media_folder_icon = 0;
1291 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1292 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1293 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1295 ladspa_vframe = 0; ladspa_icon = 0;
1296 ff_aud_vframe = 0; ff_aud_icon = 0;
1297 ff_vid_vframe = 0; ff_vid_icon = 0;
1299 clip_vframe = 0; clip_icon = 0;
1300 atransition_vframe = 0; atransition_icon = 0;
1301 vtransition_vframe = 0; vtransition_icon = 0;
1302 aeffect_vframe = 0; aeffect_icon = 0;
1303 veffect_vframe = 0; veffect_icon = 0;
1305 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1307 effectlist_menu = 0;
1312 folderlist_menu = 0;
1315 allow_iconlisting = 1;
1319 vicon_drawing = AVICON_FULL_PLAY;
1322 displayed_folder = AW_NO_FOLDER;
1323 new_folder_thread = 0;
1324 modify_folder_thread = 0;
1325 folder_lock = new Mutex("AWindowGUI::folder_lock");
1326 // *** CONTEXT_HELP ***
1327 context_help_set_keyword("Resources Window");
1330 AWindowGUI::~AWindowGUI()
1332 assets.remove_all_objects();
1333 folders.remove_all_objects();
1334 aeffects.remove_all_objects();
1335 veffects.remove_all_objects();
1336 atransitions.remove_all_objects();
1337 vtransitions.remove_all_objects();
1338 labellist.remove_all_objects();
1339 displayed_assets[1].remove_all_objects();
1341 delete new_folder_thread;
1342 delete modify_folder_thread;
1343 delete vicon_thread;
1348 delete remove_plugin;
1350 delete file_vframe; delete file_icon;
1351 delete folder_vframe; delete folder_icon;
1352 delete audio_vframe; delete audio_icon;
1353 delete video_vframe; delete video_icon;
1354 delete label_vframe; delete label_icon;
1355 delete clip_vframe; delete clip_icon;
1356 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1357 delete atransition_folder_vframe; delete atransition_folder_icon;
1358 delete veffect_folder_vframe; delete veffect_folder_icon;
1359 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1360 delete clip_folder_vframe; delete clip_folder_icon;
1361 delete label_folder_vframe; delete label_folder_icon;
1362 delete media_folder_vframe; delete media_folder_icon;
1363 delete proxy_folder_vframe; delete proxy_folder_icon;
1364 delete ladspa_vframe; delete ladspa_icon;
1365 delete ff_aud_vframe; delete ff_aud_icon;
1366 delete ff_vid_vframe; delete ff_vid_icon;
1367 delete atransition_vframe; delete atransition_icon;
1368 delete vtransition_vframe; delete vtransition_icon;
1369 delete aeffect_vframe; delete aeffect_icon;
1370 delete veffect_vframe; delete veffect_icon;
1374 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1376 return icon == file_icon ||
1377 icon == folder_icon ||
1378 icon == audio_icon ||
1379 icon == video_icon ||
1380 icon == clip_icon ||
1381 icon == label_icon ||
1382 icon == vtransition_icon ||
1383 icon == atransition_icon ||
1384 icon == veffect_icon ||
1385 icon == aeffect_icon ||
1386 icon == ladspa_icon ||
1387 icon == ff_aud_icon ||
1388 icon == ff_vid_icon ||
1389 icon == aeffect_folder_icon ||
1390 icon == veffect_folder_icon ||
1391 icon == atransition_folder_icon ||
1392 icon == vtransition_folder_icon ||
1393 icon == label_folder_icon ||
1394 icon == clip_folder_icon ||
1395 icon == media_folder_icon ||
1396 icon == proxy_folder_icon;
1399 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1401 char png_path[BCTEXTLEN];
1402 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1403 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1404 File::get_plugin_path(), plugin_icons, name);
1405 if( access(png_path, R_OK) ) return 0;
1406 return VFramePng::vframe_png(png_path,0,0);
1409 VFrame *AWindowGUI::get_picon(const char *name)
1411 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1413 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1414 snprintf(pp, ep-pp, "%s.png", name);
1415 unsigned char *data = mwindow->theme->get_image_data(png_name);
1416 if( data ) vframe = new VFramePng(data, 0.);
1421 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1423 vfrm = get_picon(fn);
1424 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1425 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1427 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1429 vfrm = get_picon(fn);
1430 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1431 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1433 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1435 vfrm = get_picon(fn);
1436 if( !vfrm ) vfrm = new VFramePng(png);
1437 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1440 void AWindowGUI::create_objects()
1442 int ys5 = yS(5), ys10 = yS(10);
1443 lock_window("AWindowGUI::create_objects");
1444 asset_titles[0] = C_("Title");
1445 asset_titles[1] = _("Comments");
1447 set_icon(mwindow->theme->get_image("awindow_icon"));
1449 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1450 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1451 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1452 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1453 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1455 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1456 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1457 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1458 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1459 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1460 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1461 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1462 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1464 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1465 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1466 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1467 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1468 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1469 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1470 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1471 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1473 theme_icon(clip_vframe, clip_icon, "clip_icon");
1474 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1475 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1476 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1477 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1479 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1480 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1481 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1482 folder_lock->lock("AWindowGUI::create_objects");
1483 // Mandatory folders
1484 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1485 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1486 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1487 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1488 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1489 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1490 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1491 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1493 create_label_folder();
1494 folder_lock->unlock();
1496 mwindow->theme->get_awindow_sizes(this);
1497 load_defaults(mwindow->defaults);
1498 new_folder_thread = new NewFolderThread(this);
1499 modify_folder_thread = new ModifyFolderThread(this);
1501 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1502 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1503 search_text = new AWindowSearchText(mwindow, this, x1, y1+ys5);
1504 search_text->create_objects();
1505 int dy = search_text->get_h() + ys10;
1507 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1509 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1510 asset_list->update_vicon_area();
1511 vicon_thread->start();
1512 vicon_audio = new AssetVIconAudio(this);
1514 add_subwindow(divider = new AWindowDivider(mwindow, this,
1515 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1516 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1518 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1520 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1521 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1522 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1523 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1524 for( int i=0; i<n; ++i ) {
1525 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1526 if( tw < nw ) tw = nw;
1528 int pw = BC_PopupMenu::calculate_w(xS(16), tw, 1);
1529 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1530 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1531 avicon_drawing->create_objects();
1532 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1533 add_tools->create_objects();
1534 fy += add_tools->get_h(); fh -= add_tools->get_h();
1535 add_subwindow(folder_list = new AWindowFolders(mwindow,
1536 this, fx, fy, fw, fh));
1538 folder_list->load_expanders();
1540 //int x = mwindow->theme->abuttons_x;
1541 //int y = mwindow->theme->abuttons_y;
1543 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1544 asset_menu->create_objects();
1545 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1546 clip_menu->create_objects();
1547 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1548 label_menu->create_objects();
1549 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1550 proxy_menu->create_objects();
1552 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1553 effectlist_menu->create_objects();
1554 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1555 assetlist_menu->create_objects();
1556 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1557 cliplist_menu->create_objects();
1558 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1559 labellist_menu->create_objects();
1560 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1561 proxylist_menu->create_objects();
1563 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1564 folderlist_menu->create_objects();
1566 create_custom_xatoms();
1570 int AWindowGUI::resize_event(int w, int h)
1572 mwindow->session->awindow_x = get_x();
1573 mwindow->session->awindow_y = get_y();
1574 mwindow->session->awindow_w = w;
1575 mwindow->session->awindow_h = h;
1577 mwindow->theme->get_awindow_sizes(this);
1578 mwindow->theme->draw_awindow_bg(this);
1579 reposition_objects();
1581 // int x = mwindow->theme->abuttons_x;
1582 // int y = mwindow->theme->abuttons_y;
1583 // new_bin->reposition_window(x, y);
1584 // x += new_bin->get_w();
1585 // delete_bin->reposition_window(x, y);
1586 // x += delete_bin->get_w();
1587 // rename_bin->reposition_window(x, y);
1588 // x += rename_bin->get_w();
1589 // delete_disk->reposition_window(x, y);
1590 // x += delete_disk->get_w();
1591 // delete_project->reposition_window(x, y);
1592 // x += delete_project->get_w();
1593 // info->reposition_window(x, y);
1594 // x += info->get_w();
1595 // redraw_index->reposition_window(x, y);
1596 // x += redraw_index->get_w();
1597 // paste->reposition_window(x, y);
1598 // x += paste->get_w();
1599 // append->reposition_window(x, y);
1600 // x += append->get_w();
1601 // view->reposition_window(x, y);
1603 BC_WindowBase::resize_event(w, h);
1604 asset_list->update_vicon_area();
1608 int AWindowGUI::translation_event()
1610 mwindow->session->awindow_x = get_x();
1611 mwindow->session->awindow_y = get_y();
1615 void AWindowGUI::reposition_objects()
1617 int ys5 = yS(5), ys10 = yS(10);
1618 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1619 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1620 search_text->reposition_window(x1, y1+ys5, w1);
1621 int dy = search_text->get_h() + ys10;
1623 asset_list->reposition_window(x1, y1, w1, h1);
1624 divider->reposition_window(
1625 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1626 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1627 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1628 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1629 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1630 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1631 fy += add_tools->get_h(); fh -= add_tools->get_h();
1632 folder_list->reposition_window(fx, fy, fw, fh);
1635 int AWindowGUI::save_defaults(BC_Hash *defaults)
1637 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1638 defaults->update("VICON_DRAWING", vicon_drawing);
1639 defaults->update("TIP_INFO", tip_info);
1643 int AWindowGUI::load_defaults(BC_Hash *defaults)
1645 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1646 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1647 tip_info = defaults->get("TIP_INFO", tip_info);
1651 int AWindowGUI::close_event()
1654 mwindow->session->show_awindow = 0;
1657 mwindow->gui->lock_window("AWindowGUI::close_event");
1658 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1659 mwindow->gui->unlock_window();
1661 lock_window("AWindowGUI::close_event");
1662 save_defaults(mwindow->defaults);
1663 mwindow->save_defaults();
1667 int AWindowGUI::start_vicon_drawing()
1669 if( play_off ) return stop_vicon_drawing();
1670 if( !vicon_thread->interrupted ) return 1;
1671 switch( vicon_drawing ) {
1672 case AVICON_FULL_PLAY: // all vicons, viewing, target
1674 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1675 if( vicon_thread->solo ) break;
1677 case AVICON_SRC_TARGET: // no vicons, no view, target
1678 case AVICON_NO_PLAY: // no vicons, no view, no target
1681 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1682 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1683 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1684 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1685 switch( mwindow->edl->session->assetlist_format ) {
1687 case ASSETS_ICONS_PACKED:
1688 case ASSETS_ICON_LIST:
1689 asset_list->update_vicon_area();
1690 vicon_thread->start_drawing();
1699 int AWindowGUI::stop_vicon_drawing(int wait)
1701 vicon_thread->stop_vicon_drawing(wait);
1706 VFrame *AssetPicon::get_vicon_frame()
1708 if( !vicon ) return 0;
1709 if( gui->vicon_thread->interrupted ) return 0;
1710 VFrame *frame = vicon->frame();
1711 if( !frame ) return 0;
1713 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1714 vicon_frame->transfer_from(frame);
1718 int AWindowGUI::cycle_assetlist_format()
1720 EDLSession *session = mwindow->edl->session;
1721 int format = ASSETS_TEXT;
1722 if( allow_iconlisting ) {
1723 switch( session->assetlist_format ) {
1725 format = ASSETS_ICONS;
1728 format = ASSETS_ICONS_PACKED;
1730 case ASSETS_ICONS_PACKED:
1731 format = ASSETS_ICON_LIST;
1733 case ASSETS_ICON_LIST:
1734 format = ASSETS_TEXT;
1738 stop_vicon_drawing();
1739 session->assetlist_format = format;
1740 asset_list->update_format(session->assetlist_format, 0);
1741 async_update_assets();
1742 start_vicon_drawing();
1746 void AWindowGUI::hide_tip_info()
1748 asset_list->hide_tooltip();
1752 AWindowRemovePluginGUI::
1753 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1754 int x, int y, PluginServer *plugin)
1755 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y,
1756 xS(500),yS(200), xS(50), yS(50),
1759 this->awindow = awindow;
1760 this->thread = thread;
1761 this->plugin = plugin;
1762 VFrame *vframe = plugin->get_picon();
1763 icon = vframe ? create_pixmap(vframe) : 0;
1764 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1765 // *** CONTEXT_HELP ***
1766 context_help_set_keyword("Delete Plugins to save Resources Space");
1769 AWindowRemovePluginGUI::
1770 ~AWindowRemovePluginGUI()
1772 if( !awindow->gui->protected_pixmap(icon) )
1774 plugin_list.remove_all();
1777 void AWindowRemovePluginGUI::create_objects()
1779 int xs10 = xS(10), xs20 = xS(20);
1780 int ys5 = yS(5), ys10 = yS(10);
1781 lock_window("AWindowRemovePluginGUI::create_objects");
1782 BC_Button *ok_button = new BC_OKButton(this);
1783 add_subwindow(ok_button);
1784 BC_Button *cancel_button = new BC_CancelButton(this);
1785 add_subwindow(cancel_button);
1786 int x = xs10, y = ys10;
1787 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1788 add_subwindow(title);
1789 y += title->get_h() + ys5;
1790 list = new BC_ListBox(x, y,
1791 get_w() - xs20, ok_button->get_y() - y - ys5, LISTBOX_TEXT, &plugin_list,
1792 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1793 add_subwindow(list);
1798 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1801 for( int i=0; i<folder.size(); ) {
1802 AssetPicon *picon = (AssetPicon *)folder[i];
1803 if( picon->plugin == plugin ) {
1804 folder.remove_object_number(i);
1813 void AWindowRemovePlugin::handle_close_event(int result)
1816 printf(_("remove %s\n"), plugin->path);
1817 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1818 ArrayList<BC_ListBoxItem*> *folder =
1819 plugin->audio ? plugin->transition ?
1820 &awindow->gui->atransitions :
1821 &awindow->gui->aeffects :
1822 plugin->video ? plugin->transition ?
1823 &awindow->gui->vtransitions :
1824 &awindow->gui->veffects :
1826 if( folder ) remove_plugin(plugin, *folder);
1827 MWindow *mwindow = awindow->mwindow;
1828 awindow->gui->unlock_window();
1829 char plugin_path[BCTEXTLEN];
1830 strcpy(plugin_path, plugin->path);
1831 mwindow->plugindb->remove(plugin);
1832 remove(plugin_path);
1833 char index_path[BCTEXTLEN];
1834 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1836 char picon_path[BCTEXTLEN];
1838 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1839 File::get_plugin_path());
1840 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1841 plugin->get_plugin_png_name(png_name);
1842 fs.update(picon_path);
1843 for( int i=0; i<fs.dir_list.total; ++i ) {
1844 char *fs_path = fs.dir_list[i]->path;
1845 if( !fs.is_dir(fs_path) ) continue;
1846 snprintf(png_path, sizeof(picon_path), "%s/%s",
1850 delete plugin; plugin = 0;
1851 awindow->gui->async_update_assets();
1855 AWindowRemovePlugin::
1856 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1859 this->awindow = awindow;
1860 this->plugin = plugin;
1863 AWindowRemovePlugin::
1864 ~AWindowRemovePlugin()
1869 BC_Window* AWindowRemovePlugin::new_gui()
1871 int x = awindow->gui->get_abs_cursor_x(0);
1872 int y = awindow->gui->get_abs_cursor_y(0);
1873 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1874 gui->create_objects();
1878 int AWindowGUI::keypress_event()
1880 char title[BCTEXTLEN];
1881 PluginServer* plugin = 0;
1882 switch( get_keypress() ) {
1890 tip_info = !tip_info ? 1 : 0;
1891 if( !tip_info ) hide_tip_info();
1894 if( !ctrl_down() && !shift_down() ) {
1895 assetlist_menu->load_file->handle_event();
1900 return cycle_assetlist_format();
1902 if( shift_down() && ctrl_down() ) {
1903 plugin = selected_plugin();
1904 if( !plugin ) break;
1905 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1907 remove_plugin->start();
1908 lock_window("AWindowGUI::keypress_event 1");
1912 if( shift_down() ) {
1913 mwindow->awindow->asset_remove->start();
1917 mwindow->remove_assets_from_project(1, 1, 1,
1918 mwindow->session->drag_assets,
1919 mwindow->session->drag_clips);
1920 lock_window("AWindowGUI::keypress_event 2");
1926 if( shift_down() && ctrl_down() ) {
1927 resend_event(mwindow->gui);
1932 // *** CONTEXT_HELP ***
1933 if( get_keypress() != 'h' || ! alt_down() ) return 0;
1934 if( ! is_tooltip_event_win() || ! cursor_inside() ) return 0;
1935 // If some plugin is selected, show its help
1936 // Otherwise show general help
1937 plugin = selected_plugin();
1939 strcpy(title, plugin->title);
1940 if( ! strcmp(title, "Overlay") ) {
1941 // "Overlay" plugin title is ambiguous
1942 if( plugin->audio ) strcat(title, " \\(Audio\\)");
1943 if( plugin->video ) strcat(title, " \\(Video\\)");
1945 if( plugin->is_ffmpeg() ) {
1946 // FFmpeg plugins can be audio or video
1948 strcpy(title, "FFmpeg Audio Plugins");
1950 strcpy(title, "FFmpeg Video Plugins");
1952 context_help_show(title);
1954 else context_help_show("Resources Window");
1960 int AWindowGUI::create_custom_xatoms()
1962 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1965 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1967 if( event->message_type == UpdateAssetsXAtom ) {
1974 void AWindowGUI::async_update_assets()
1977 event.message_type = UpdateAssetsXAtom;
1978 send_custom_xatom(&event);
1982 void AWindowGUI::update_folder_list()
1984 for( int i = 0; i < folders.total; i++ ) {
1985 AssetPicon *picon = (AssetPicon*)folders.values[i];
1989 // Search assets for folders
1990 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1991 BinFolder *bin_folder = mwindow->edl->folders[i];
1994 for( int j = 0; j < folders.total; j++ ) {
1995 AssetPicon *picon = (AssetPicon*)folders[j];
1996 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
2004 const char *title = bin_folder->title;
2005 int folder = bin_folder->awindow_folder;
2006 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
2007 picon->create_objects();
2008 folders.append(picon);
2012 // Delete unused non-persistent folders
2013 int do_autoplace = 0;
2014 for( int i=folders.total; --i>=0; ) {
2015 AssetPicon *picon = (AssetPicon*)folders.values[i];
2016 if( !picon->in_use && !picon->persistent ) {
2018 folders.remove_number(i);
2023 folder_list->set_autoplacement(&folders, 0, 1);
2026 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
2027 int do_audio, int do_video, int is_realtime, int is_transition)
2029 ArrayList<PluginServer*> plugin_list;
2030 // Get pointers to plugindb entries
2031 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
2034 for( int i = 0; i < plugin_list.total; i++ ) {
2035 PluginServer *server = plugin_list.values[i];
2036 int visible = plugin_visibility & (1<<server->dir_idx);
2037 if( !visible ) continue;
2038 // Create new listitem
2039 AssetPicon *picon = new AssetPicon(mwindow, this, server);
2040 picon->create_objects();
2041 output->append(picon);
2045 void AWindowGUI::create_label_folder()
2048 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
2049 AssetPicon *picon = new AssetPicon(mwindow, this, current);
2050 picon->create_objects();
2051 labellist.append(picon);
2056 void AWindowGUI::update_asset_list()
2058 ArrayList<AssetPicon *> new_assets;
2059 for( int i = 0; i < assets.total; i++ ) {
2060 AssetPicon *picon = (AssetPicon*)assets.values[i];
2064 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2065 // Synchronize EDL clips
2066 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2069 // Look for clip in existing listitems
2070 for( int j = 0; j < assets.total && !exists; j++ ) {
2071 AssetPicon *picon = (AssetPicon*)assets.values[j];
2073 if( picon->id == mwindow->edl->clips[i]->id ) {
2074 picon->edl = mwindow->edl->clips[i];
2075 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2081 // Create new listitem
2083 AssetPicon *picon = new AssetPicon(mwindow,
2084 this, mwindow->edl->clips[i]);
2085 new_assets.append(picon);
2089 // Synchronize EDL assets
2090 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2093 // Look for asset in existing listitems
2094 for( int j = 0; j < assets.total && !exists; j++ ) {
2095 AssetPicon *picon = (AssetPicon*)assets.values[j];
2097 if( picon->id == current->id ) {
2098 picon->indexable = current;
2104 // Create new listitem
2106 AssetPicon *picon = new AssetPicon(mwindow,
2108 new_assets.append(picon);
2109 if( current->width > ASSET_MAX_WIDTH || current->height > ASSET_MAX_HEIGHT ) {
2110 eprintf(_("Warning: %s\n"
2111 " dimensions %dx%d exceed asset maximum limits %dx%d\n"),
2112 current->path, current->width, current->height,
2113 ASSET_MAX_WIDTH, ASSET_MAX_HEIGHT);
2115 else if( mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL ) {
2116 int texture_limit = BC_DisplayInfo::get_gl_max_texture_size();
2117 if( texture_limit >= 0 &&
2118 (current->width >= texture_limit || current->height >= texture_limit) ) {
2119 eprintf(_("Warning: %s\n"
2120 " dimensions %dx%d exceed OpenGL texture limit %d\n"),
2121 current->path, current->width, current->height, texture_limit);
2127 // Synchronize nested EDLs
2128 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2130 EDL *nested_edl = mwindow->edl->nested_edls[i];
2132 // Look for asset in existing listitems
2133 for( int j=0; j<assets.total && !exists; ++j ) {
2134 AssetPicon *picon = (AssetPicon*)assets.values[j];
2136 if( picon->id == nested_edl->id ) {
2137 picon->indexable = nested_edl;
2143 // Create new listitem
2145 AssetPicon *picon = new AssetPicon(mwindow,
2146 this, (Indexable*)nested_edl);
2147 new_assets.append(picon);
2150 mwindow->gui->unlock_window();
2152 for( int i=0; i<new_assets.size(); ++i ) {
2153 AssetPicon *picon = new_assets[i];
2154 picon->create_objects();
2155 if( picon->indexable )
2156 picon->foldernum = AW_MEDIA_FOLDER;
2157 else if( picon->edl )
2158 picon->foldernum = AW_CLIP_FOLDER;
2159 assets.append(picon);
2162 mwindow->gui->lock_window();
2163 mwindow->gui->default_message();
2164 mwindow->gui->unlock_window();
2166 for( int i = assets.size() - 1; i >= 0; i-- ) {
2167 AssetPicon *picon = (AssetPicon*)assets.get(i);
2168 if( !picon->in_use ) {
2170 assets.remove_number(i);
2173 if( picon->indexable && picon->indexable->is_asset ) {
2174 Asset *asset = (Asset *)picon->indexable;
2176 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2177 picon->comments_rate = asset->get_frame_rate();
2178 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2179 picon->comments_type = asset->format == FILE_FFMPEG ?
2180 asset->vcodec : File::formattostr(asset->format);
2185 void AWindowGUI::update_picon(Indexable *indexable)
2188 for( int i = 0; i < assets.total; i++ ) {
2189 AssetPicon *picon = (AssetPicon*)assets.values[i];
2190 if( picon->indexable == indexable ||
2191 picon->edl == (EDL *)indexable ) {
2192 char name[BCTEXTLEN];
2194 fs.extract_name(name, indexable->path);
2195 picon->set_text(name);
2196 vicon = picon->vicon;
2201 stop_vicon_drawing();
2202 vicon->clear_images();
2203 vicon->reset(indexable->get_frame_rate());
2204 start_vicon_drawing();
2208 void AWindowGUI::sort_assets()
2210 folder_lock->lock("AWindowGUI::sort_assets");
2211 switch( mwindow->edl->session->awindow_folder ) {
2212 case AW_AEFFECT_FOLDER:
2213 sort_picons(&aeffects);
2215 case AW_VEFFECT_FOLDER:
2216 sort_picons(&veffects);
2218 case AW_ATRANSITION_FOLDER:
2219 sort_picons(&atransitions);
2221 case AW_VTRANSITION_FOLDER:
2222 sort_picons(&vtransitions);
2224 case AW_LABEL_FOLDER:
2225 sort_picons(&labellist);
2228 sort_picons(&assets);
2232 asset_list->update_format(asset_list->get_format(), 0);
2233 folder_lock->unlock();
2237 void AWindowGUI::sort_folders()
2239 folder_lock->lock("AWindowGUI::update_assets");
2240 // folder_list->collapse_recursive(&folders, 0);
2241 folder_list->set_autoplacement(&folders, 0, 1);
2242 sort_picons(&folders);
2243 folder_list->update_format(folder_list->get_format(), 0);
2244 folder_lock->unlock();
2248 EDL *AWindowGUI::collect_proxy(Asset *proxy_asset)
2250 char path[BCTEXTLEN];
2251 int proxy_scale = mwindow->edl->session->proxy_scale;
2252 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2253 Indexable *unproxy_idxbl =
2254 proxy_asset->proxy_edl ?
2255 (Indexable *) mwindow->edl->get_nested_edl(path) :
2256 (Indexable *) mwindow->edl->assets->get_asset(path);
2257 if( !unproxy_idxbl || !unproxy_idxbl->get_video_layers() ) return 0;
2258 // make a clip from proxy video tracks and unproxy audio tracks
2259 EDL *proxy_edl = new EDL(mwindow->edl);
2260 proxy_edl->create_objects();
2261 proxy_edl->set_path(proxy_asset->path);
2262 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2263 strcpy(proxy_edl->local_session->clip_title, path);
2264 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2265 proxy_edl->session->video_tracks = proxy_asset->layers;
2266 proxy_edl->session->audio_tracks = unproxy_idxbl->get_audio_channels();
2267 proxy_edl->create_default_tracks();
2268 double length = proxy_asset->frame_rate > 0 ?
2269 ( proxy_asset->video_length >= 0 ?
2270 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2271 ( proxy_edl->session->si_useduration ?
2272 proxy_edl->session->si_duration :
2273 1.0 / proxy_asset->frame_rate ) ) :
2274 1.0 / proxy_edl->session->frame_rate;
2275 Track *current = proxy_edl->tracks->first;
2276 for( int vtrack=0; current; current=NEXT ) {
2277 if( current->data_type != TRACK_VIDEO ) continue;
2278 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2280 int64_t samples = unproxy_idxbl->get_audio_samples();
2281 int sample_rate = unproxy_idxbl->get_sample_rate();
2282 length = sample_rate > 0 ? (double)samples / sample_rate : 0;
2283 current = proxy_edl->tracks->first;
2284 for( int atrack=0; current; current=NEXT ) {
2285 if( current->data_type != TRACK_AUDIO ) continue;
2286 Asset *asset = unproxy_idxbl->is_asset ? (Asset *)unproxy_idxbl : 0;
2287 EDL *nested_edl = unproxy_idxbl->is_asset ? 0 : (EDL *)unproxy_idxbl;
2288 current->insert_asset(asset, nested_edl, length, 0, atrack++);
2290 proxy_edl->folder_no = AW_PROXY_FOLDER;
2295 void AWindowGUI::collect_assets(int proxy)
2297 mwindow->session->drag_assets->remove_all();
2298 mwindow->session->drag_clips->remove_all();
2299 int i = 0; AssetPicon *result;
2300 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2301 Indexable *indexable = result->indexable;
2302 if( proxy && indexable && indexable->is_asset &&
2303 indexable->folder_no == AW_PROXY_FOLDER ) {
2304 EDL *drag_edl = collect_proxy((Asset*)indexable);
2305 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2309 mwindow->session->drag_assets->append(indexable);
2313 mwindow->session->drag_clips->append(result->edl);
2319 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2321 // Remove current pointers
2322 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2323 dst[0].remove_all();
2324 dst[1].remove_all_objects();
2326 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2327 int folder = mwindow->edl->session->awindow_folder;
2328 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2329 mwindow->edl->get_folder(folder);
2331 // Create new pointers
2332 for( int i = 0; i < src->total; i++ ) {
2333 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2334 picon = (AssetPicon*)src->values[i];
2335 picon->sort_key = -1;
2336 if( !visible && bin_folder ) {
2337 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2338 picon->indexable ? picon->indexable :
2339 picon->edl ? picon->edl->get_proxy_asset() : 0;
2341 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2342 if( picon->sort_key < 0 ) continue;
2346 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2348 if( !visible && picon->edl && picon->edl->folder_no == folder )
2350 if( visible && sub_items ) {
2351 if( !sub_items->matches(picon->get_text()) )
2355 const char *text = search_text->get_text();
2356 if( text && text[0] )
2357 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2359 if( visible && picon->vicon && picon->vicon->hidden )
2360 picon->vicon->hidden = 0;
2362 BC_ListBoxItem *item2, *item1;
2363 dst[0].append(item1 = picon);
2365 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2368 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2369 else if( picon->comments_time ) {
2370 char date_time[BCSTRLEN];
2371 struct tm stm; localtime_r(&picon->comments_time, &stm);
2372 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2373 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2374 stm.tm_hour, stm.tm_min, stm.tm_sec,
2375 picon->comments_rate, picon->comments_ffmt,
2376 picon->comments_type);
2377 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2380 dst[1].append(item2 = new BC_ListBoxItem(""));
2381 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2382 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2387 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2389 int done = 0, changed = 0;
2392 for( int i=0; i<src->total-1; ++i ) {
2393 AssetPicon *item1 = (AssetPicon *)src->values[i];
2394 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2395 double v = item2->sort_key - item1->sort_key;
2396 if( v > 0 ) continue;
2398 const char *cp1 = item1->get_text();
2399 const char *bp1 = strrchr(cp1, '/');
2400 if( bp1 ) cp1 = bp1 + 1;
2401 const char *cp2 = item2->get_text();
2402 const char *bp2 = strrchr(cp2, '/');
2403 if( bp2 ) cp2 = bp2 + 1;
2404 if( strcmp(cp2, cp1) >= 0 ) continue;
2406 src->values[i + 1] = item1;
2407 src->values[i] = item2;
2408 done = 0; changed = 1;
2412 for( int i=0; i<src->total; ++i ) {
2413 AssetPicon *item = (AssetPicon *)src->values[i];
2414 item->set_autoplace_icon(1);
2415 item->set_autoplace_text(1);
2420 void AWindowGUI::filter_displayed_assets()
2422 //allow_iconlisting = 1;
2423 asset_titles[0] = C_("Title");
2424 asset_titles[1] = _("Comments");
2425 AssetPicon *picon = 0;
2426 int selected_folder = mwindow->edl->session->awindow_folder;
2427 // Ensure the current folder icon is highlighted
2428 for( int i = 0; i < folders.total; i++ ) {
2429 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2430 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2431 folder_item->set_selected(selected);
2432 if( selected ) picon = folder_item;
2435 ArrayList<BC_ListBoxItem*> *src = &assets;
2436 switch( selected_folder ) {
2437 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2438 case AW_VEFFECT_FOLDER: src = &veffects; break;
2439 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2440 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2441 case AW_LABEL_FOLDER: src = &labellist;
2442 asset_titles[0] = _("Time Stamps");
2443 asset_titles[1] = C_("Title");
2444 //allow_iconlisting = 0;
2447 copy_picons(picon, src);
2451 void AWindowGUI::update_assets()
2453 stop_vicon_drawing();
2454 folder_lock->lock("AWindowGUI::update_assets");
2455 update_folder_list();
2456 update_asset_list();
2457 labellist.remove_all_objects();
2458 create_label_folder();
2460 if( displayed_folder != mwindow->edl->session->awindow_folder )
2461 search_text->clear();
2462 vicon_thread->hide_vicons();
2463 filter_displayed_assets();
2464 folder_lock->unlock();
2466 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2467 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2469 int folder_xposition = folder_list->get_xposition();
2470 int folder_yposition = folder_list->get_yposition();
2471 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2473 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2474 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2476 int asset_xposition = asset_list->get_xposition();
2477 int asset_yposition = asset_list->get_yposition();
2478 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2479 displayed_folder = mwindow->edl->session->awindow_folder;
2480 asset_xposition = asset_yposition = 0;
2482 asset_list->update(displayed_assets, asset_titles,
2483 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2484 asset_xposition, asset_yposition, -1, 0);
2485 asset_list->center_selection();
2488 start_vicon_drawing();
2492 void AWindowGUI::update_effects()
2494 aeffects.remove_all_objects();
2495 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2496 veffects.remove_all_objects();
2497 create_persistent_folder(&veffects, 0, 1, 1, 0);
2498 atransitions.remove_all_objects();
2499 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2500 vtransitions.remove_all_objects();
2501 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2504 int AWindowGUI::drag_motion()
2506 if( get_hidden() ) return 0;
2512 int AWindowGUI::drag_stop()
2514 if( get_hidden() ) return 0;
2518 Indexable* AWindowGUI::selected_asset()
2520 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2521 return picon ? picon->indexable : 0;
2524 PluginServer* AWindowGUI::selected_plugin()
2526 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2527 return picon ? picon->plugin : 0;
2530 AssetPicon* AWindowGUI::selected_folder()
2532 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2543 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2544 : BC_SubWindow(x, y, w, h)
2546 this->mwindow = mwindow;
2549 AWindowDivider::~AWindowDivider()
2553 int AWindowDivider::button_press_event()
2555 if( is_event_win() && cursor_inside() ) {
2556 mwindow->session->current_operation = DRAG_PARTITION;
2562 int AWindowDivider::cursor_motion_event()
2564 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2566 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2567 int fw = gui->get_relative_cursor_x();
2568 if( fw > wmax ) fw = wmax;
2569 if( fw < wmin ) fw = wmin;
2570 mwindow->session->afolders_w = fw;
2571 mwindow->theme->get_awindow_sizes(gui);
2572 gui->reposition_objects();
2578 int AWindowDivider::button_release_event()
2580 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2581 mwindow->session->current_operation = NO_OPERATION;
2592 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2593 : BC_ListBox(x, y, w, h,
2594 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2595 LISTBOX_ICONS : LISTBOX_TEXT,
2596 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2597 0, // Titles for columns. Set to 0 for no titles
2598 0, // width of each column
2599 1, // Total columns.
2600 0, // Pixel of top of window.
2601 0, // If this listbox is a popup window
2602 LISTBOX_SINGLE, // Select one item or multiple items
2603 ICON_TOP, // Position of icon relative to text of each item
2606 this->mwindow = mwindow;
2613 AWindowFolders::~AWindowFolders()
2617 int AWindowFolders::selection_changed()
2619 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2620 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2621 // prefer expanded entry
2622 AWindowFolderItem *item = item1 ? item1 : item0;
2623 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2624 item1->set_selected(0);
2631 AssetPicon *picon = item->get_picon();
2632 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2634 gui->stop_vicon_drawing();
2636 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2637 gui->folderlist_menu->update_titles();
2638 gui->folderlist_menu->activate_menu();
2641 mwindow->edl->session->awindow_folder = picon->foldernum;
2642 gui->asset_list->draw_background();
2643 gui->async_update_assets();
2645 gui->start_vicon_drawing();
2650 int AWindowFolders::button_press_event()
2652 gui->hide_tip_info();
2653 int result = BC_ListBox::button_press_event();
2656 if( get_buttonpress() == RIGHT_BUTTON &&
2657 is_event_win() && cursor_inside() ) {
2658 gui->folderlist_menu->update_titles();
2659 gui->folderlist_menu->activate_menu();
2667 int AWindowFolders::drag_stop()
2670 if( get_hidden() ) return 0;
2671 if( mwindow->session->current_operation == DRAG_ASSET &&
2672 gui->folder_list->cursor_above() ) { // check user folder
2673 int item_no = gui->folder_list->get_cursor_data_item_no();
2674 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2675 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2676 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2677 ArrayList<Indexable *> *drags = folder->is_clips ?
2678 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2679 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2680 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2682 mwindow->session->current_operation = ::NO_OPERATION;
2689 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2690 : AWindowFolderItem(text)
2692 this->parent = parent;
2695 int AWindowFolders::load_expanders()
2697 char expanders_path[BCTEXTLEN];
2698 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2699 FILE *fp = fopen(expanders_path, "r");
2701 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2702 File::get_cindat_path(), EXPANDERS_FILE);
2703 char *cp = strrchr(expanders_path,'.');
2704 if( cp ) strcpy(cp+1, mwindow->cin_lang);
2705 fp = fopen(expanders_path, "r");
2708 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2709 File::get_cindat_path(), EXPANDERS_FILE);
2710 fp = fopen(expanders_path, "r");
2713 const char tab = '\t';
2714 char line[BCTEXTLEN]; line[0] = 0;
2715 AWindowFolderItem *item = 0, *parent;
2716 AWindowFolderSubItems *sub_items = 0;
2718 while( fgets(line,sizeof(line),fp) ) {
2719 if( line[0] == '#' ) continue;
2720 int i = strlen(line);
2721 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2722 if( i == 0 ) continue;
2724 for( char *cp=line; *cp==tab; ++cp ) ++i;
2726 int i = gui->folders.size();
2728 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2729 if( !strcmp(folder->get_text(),_(line)) ) break;
2731 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2736 if( i > k+1 ) continue;
2738 if( line[i] != '-' && sub_items ) {
2739 sub_items->names.append(cstrdup(_(&line[i])));
2747 item = item->parent;
2750 parent = item->parent;
2752 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2753 if( !sublist ) sublist = parent->new_sublist(1);
2754 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2755 sublist->append(item = sub_items);
2762 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2763 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2764 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2765 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2766 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2768 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2769 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2770 mwindow->edl->session->asset_columns, // width of each column
2771 1, // Total columns.
2772 0, // Pixel of top of window.
2773 0, // If this listbox is a popup window
2774 LISTBOX_MULTIPLE, // Select one item or multiple items
2775 ICON_TOP, // Position of icon relative to text of each item
2776 -1) // Allow drags, require shift for scrolling
2778 this->mwindow = mwindow;
2780 this->info_tip = -1;
2782 set_scroll_stretch(1, 1);
2785 AWindowAssets::~AWindowAssets()
2789 int AWindowAssets::button_press_event()
2792 AssetVIconThread *avt = gui->vicon_thread;
2793 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2794 int dir = 1, button = get_buttonpress();
2796 case WHEEL_DOWN: dir = -1; // fall thru
2798 int x = get_cursor_x(), y = get_cursor_y();
2799 if( avt->cursor_inside(x, y) && avt->view_win )
2800 avt->zoom_scale(dir);
2805 int result = BC_ListBox::button_press_event();
2807 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2808 is_event_win() && cursor_inside() ) {
2809 BC_ListBox::deactivate_selection();
2810 int folder = mwindow->edl->session->awindow_folder;
2812 case AW_AEFFECT_FOLDER:
2813 case AW_VEFFECT_FOLDER:
2814 case AW_ATRANSITION_FOLDER:
2815 case AW_VTRANSITION_FOLDER:
2816 gui->effectlist_menu->update();
2817 gui->effectlist_menu->activate_menu();
2819 case AW_LABEL_FOLDER:
2820 gui->labellist_menu->update();
2821 gui->labellist_menu->activate_menu();
2823 case AW_CLIP_FOLDER:
2824 gui->cliplist_menu->update();
2825 gui->cliplist_menu->activate_menu();
2827 case AW_PROXY_FOLDER:
2828 gui->proxylist_menu->update();
2829 gui->proxylist_menu->activate_menu();
2832 case AW_MEDIA_FOLDER: {
2833 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2834 gui->assetlist_menu->update_titles(shots);
2835 gui->assetlist_menu->activate_menu();
2845 int AWindowAssets::handle_event()
2847 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2848 if( !asset_picon ) return 0;
2849 Indexable *picon_idxbl = asset_picon->indexable;
2850 EDL *picon_edl = asset_picon->edl;
2852 VWindow *vwindow = 0;
2853 switch( mwindow->edl->session->awindow_folder ) {
2854 case AW_AEFFECT_FOLDER:
2855 case AW_VEFFECT_FOLDER:
2856 case AW_ATRANSITION_FOLDER:
2857 case AW_VTRANSITION_FOLDER: return 1;
2858 case AW_PROXY_FOLDER:
2859 proxy = 1; // fall thru
2861 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2862 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2865 if( !vwindow || !vwindow->is_running() ) return 1;
2866 if( proxy && picon_idxbl && picon_idxbl->is_asset ) {
2867 picon_edl = gui->collect_proxy((Asset*)picon_idxbl);
2871 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2872 else if( picon_edl ) vwindow->change_source(picon_edl);
2876 int AWindowAssets::selection_changed()
2878 // Show popup window
2880 int folder = mwindow->edl->session->awindow_folder;
2881 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2882 (item = (AssetPicon*)get_selection(0, 0)) ) {
2884 case AW_AEFFECT_FOLDER:
2885 case AW_VEFFECT_FOLDER:
2886 case AW_ATRANSITION_FOLDER:
2887 case AW_VTRANSITION_FOLDER:
2888 gui->effectlist_menu->update();
2889 gui->effectlist_menu->activate_menu();
2891 case AW_LABEL_FOLDER:
2892 if( !item->label ) break;
2893 gui->label_menu->activate_menu();
2895 case AW_CLIP_FOLDER:
2896 if( !item->indexable && !item->edl ) break;
2897 gui->clip_menu->update();
2898 gui->clip_menu->activate_menu();
2900 case AW_PROXY_FOLDER:
2901 if( !item->indexable && !item->edl ) break;
2902 gui->proxy_menu->update();
2903 gui->proxy_menu->activate_menu();
2906 if( !item->indexable && !item->edl ) break;
2907 gui->asset_menu->update();
2908 gui->asset_menu->activate_menu();
2912 deactivate_selection();
2914 else if( get_button_down() && get_buttonpress() == LEFT_BUTTON &&
2915 get_double_click() ) {
2916 item = (AssetPicon*)get_selection(0, 0);
2919 case AW_LABEL_FOLDER:
2920 if( !item->label ) break;
2921 mwindow->set_position(item->label->position);
2926 else if( get_button_down() && !gui->play_off &&
2927 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2928 item = (AssetPicon*)get_selection(0, 0);
2929 if( item && !get_selection(0, 1) ) {
2931 case AW_MEDIA_FOLDER:
2932 case AW_PROXY_FOLDER:
2933 case AWINDOW_USER_FOLDERS:
2934 if( get_buttonpress() == LEFT_BUTTON ||
2935 get_buttonpress() == MIDDLE_BUTTON ) {
2936 AssetVIcon *vicon = 0;
2937 AssetVIconThread *avt = gui->vicon_thread;
2938 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2939 vicon = item->vicon;
2940 int draw_mode = !vicon ?
2942 get_buttonpress() == MIDDLE_BUTTON ?
2943 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2944 avt->set_view_popup(vicon, draw_mode);
2947 case AW_CLIP_FOLDER:
2948 if( get_buttonpress() == LEFT_BUTTON ) {
2949 AssetVIcon *vicon = 0;
2950 AssetVIconThread *avt = gui->vicon_thread;
2951 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2952 vicon = item->vicon;
2953 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2959 gui->vicon_thread->set_view_popup(0);
2960 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2961 gui->stop_vicon_drawing();
2967 void AWindowAssets::draw_background()
2969 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2970 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2971 set_font(LARGEFONT);
2972 int folder = mwindow->edl->session->awindow_folder;
2973 const char *title = mwindow->edl->get_folder_name(folder);
2974 draw_text(get_w() - get_text_width(LARGEFONT, title) - xS(4), yS(30),
2975 title, -1, get_bg_surface());
2978 int AWindowAssets::drag_start_event()
2980 gui->vicon_thread->set_view_popup(0);
2981 int collect_pluginservers = 0;
2982 int collect_assets = 0, proxy = 0;
2984 if( BC_ListBox::drag_start_event() ) {
2985 switch( mwindow->edl->session->awindow_folder ) {
2986 case AW_AEFFECT_FOLDER:
2987 mwindow->session->current_operation = DRAG_AEFFECT;
2988 collect_pluginservers = 1;
2990 case AW_VEFFECT_FOLDER:
2991 mwindow->session->current_operation = DRAG_VEFFECT;
2992 collect_pluginservers = 1;
2994 case AW_ATRANSITION_FOLDER:
2995 mwindow->session->current_operation = DRAG_ATRANSITION;
2996 collect_pluginservers = 1;
2998 case AW_VTRANSITION_FOLDER:
2999 mwindow->session->current_operation = DRAG_VTRANSITION;
3000 collect_pluginservers = 1;
3002 case AW_LABEL_FOLDER:
3005 case AW_PROXY_FOLDER:
3006 proxy = 1; // fall thru
3007 case AW_MEDIA_FOLDER:
3009 mwindow->session->current_operation = DRAG_ASSET;
3014 if( collect_pluginservers ) {
3016 mwindow->session->drag_pluginservers->remove_all();
3019 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
3020 if( !result ) break;
3022 mwindow->session->drag_pluginservers->append(result->plugin);
3026 if( collect_assets ) {
3027 gui->collect_assets(proxy);
3035 int AWindowAssets::drag_motion_event()
3037 BC_ListBox::drag_motion_event();
3040 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3041 mwindow->gui->drag_motion();
3042 mwindow->gui->unlock_window();
3044 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
3045 VWindow *vwindow = mwindow->vwindows.get(i);
3046 if( !vwindow->is_running() ) continue;
3047 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3048 vwindow->gui->drag_motion();
3049 vwindow->gui->unlock_window();
3052 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
3053 mwindow->cwindow->gui->drag_motion();
3054 mwindow->cwindow->gui->unlock_window();
3056 lock_window("AWindowAssets::drag_motion_event");
3057 if( mwindow->session->current_operation == DRAG_ASSET &&
3058 gui->folder_list->cursor_above() ) { // highlight user folder
3059 BC_ListBoxItem *item = 0;
3060 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
3061 if( item_no >= 0 ) {
3062 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
3063 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
3066 item_no = gui->folder_list->item_to_index(&gui->folders, item);
3067 int folder_xposition = gui->folder_list->get_xposition();
3068 int folder_yposition = gui->folder_list->get_yposition();
3069 gui->folder_list->update(&gui->folders, 0, 0, 1,
3070 folder_xposition, folder_yposition, item_no, 0, 1);
3075 int AWindowAssets::drag_stop_event()
3079 result = gui->drag_stop();
3084 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3085 result = mwindow->gui->drag_stop();
3086 mwindow->gui->unlock_window();
3090 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
3091 VWindow *vwindow = mwindow->vwindows.get(i);
3092 if( !vwindow ) continue;
3093 if( !vwindow->is_running() ) continue;
3094 if( vwindow->gui->is_hidden() ) continue;
3095 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3096 if( vwindow->gui->cursor_above() &&
3097 vwindow->gui->get_cursor_over_window() ) {
3098 result = vwindow->gui->drag_stop();
3100 vwindow->gui->unlock_window();
3105 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3106 result = mwindow->cwindow->gui->drag_stop();
3107 mwindow->cwindow->gui->unlock_window();
3110 lock_window("AWindowAssets::drag_stop_event");
3112 result = gui->folder_list->drag_stop();
3117 get_drag_popup()->set_animation(0);
3119 BC_ListBox::drag_stop_event();
3120 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3121 mwindow->session->current_operation = ::NO_OPERATION;
3126 int AWindowAssets::column_resize_event()
3128 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3129 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3133 int AWindowAssets::cursor_enter_event()
3135 int ret = BC_ListBox::cursor_enter_event();
3136 switch( gui->vicon_drawing ) {
3137 case AVICON_FULL_PLAY:
3138 gui->start_vicon_drawing();
3140 case AVICON_MOUSE_OVER:
3141 case AVICON_SRC_TARGET:
3142 case AVICON_NO_PLAY:
3149 int AWindowAssets::cursor_leave_event()
3152 if( !is_event_win() ) return 0;
3153 if( !gui->vicon_thread->viewing )
3154 gui->stop_vicon_drawing();
3155 return BC_ListBox::cursor_leave_event();
3158 int AWindowAssets::focus_out_event()
3160 gui->stop_vicon_drawing();
3161 gui->vicon_thread->set_view_popup(0);
3162 return BC_ListBox::focus_out_event();
3165 void AWindowAssets::update_vicon_area()
3167 int x0 = 0, x1 = get_w();
3168 int y0 = get_title_h();
3170 if( is_highlighted() ) {
3171 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3172 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3174 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3177 int AWindowAssets::mouse_over_event(int no)
3179 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3180 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3181 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3182 switch( gui->vicon_drawing ) {
3183 case AVICON_FULL_PLAY:
3184 gui->vicon_thread->solo = 0;
3185 if( vicon && gui->vicon_thread->viewing )
3186 gui->vicon_thread->set_view_popup(vicon);
3188 case AVICON_MOUSE_OVER:
3190 gui->vicon_thread->solo = vicon;
3191 gui->start_vicon_drawing();
3193 case AVICON_SRC_TARGET:
3195 if( gui->vicon_thread->viewing )
3196 gui->vicon_thread->set_view_popup(vicon);
3198 case AVICON_NO_PLAY:
3202 if( no < 0 && info_tip >= 0 ) {
3205 if( gui->tip_info && no >= 0 &&
3206 info_tip != no && picon && picon->plugin ) {
3207 const char *info = picon->plugin->tip;
3208 if( !info ) info = _("No info available");
3209 show_tip_info(info, no);
3214 void AWindowAssets::show_tip_info(const char *info, int no)
3216 int tw = get_text_width(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3217 int th = get_text_height(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3218 int tx = get_w() - (tw + xS(28));
3219 int ty = get_h() - (th + yS(28));
3220 show_tooltip(info, tx, ty, tw, th);
3224 void AWindowAssets::hide_tip_info()
3230 // *** CONTEXT_HELP ***
3231 int AWindowAssets::keypress_event()
3234 char title[BCTEXTLEN];
3235 AssetPicon *picon = 0;
3236 PluginServer *plugin = 0;
3238 // printf("AWindowAssets::keypress_event: %d\n", get_keypress());
3240 // If not our context help keystroke, redispatch it
3241 // to the event handler of the base class
3242 if (get_keypress() != 'h' || ! alt_down() ||
3243 ! is_tooltip_event_win() || ! cursor_inside())
3244 return BC_ListBox::keypress_event();
3246 switch (mwindow->edl->session->awindow_folder) {
3248 case AW_AEFFECT_FOLDER:
3249 case AW_VEFFECT_FOLDER:
3250 case AW_ATRANSITION_FOLDER:
3251 case AW_VTRANSITION_FOLDER:
3252 // If plugin tips activated, show help for plugin under mouse
3253 // Otherwise show help for the selected plugin
3254 if (gui->tip_info) {
3255 item = BC_ListBox::get_highlighted_item();
3256 if (item >= 0 && item < gui->displayed_assets[0].size()) {
3257 picon = (AssetPicon *) gui->displayed_assets[0][item];
3258 if (picon) plugin = picon->plugin;
3261 else plugin = gui->selected_plugin();
3262 // If some plugin is highlighted or selected, show its help
3263 // Otherwise show more general help
3265 strcpy(title, plugin->title);
3266 if (! strcmp(title, "Overlay")) {
3267 // "Overlay" plugin title is ambiguous
3269 strcat(title, " \\(Audio\\)");
3271 strcat(title, " \\(Video\\)");
3273 if (plugin->is_ffmpeg()) {
3274 // FFmpeg plugins can be audio or video
3276 strcpy(title, "FFmpeg Audio Plugins");
3278 strcpy(title, "FFmpeg Video Plugins");
3280 context_help_show(title);
3284 switch (mwindow->edl->session->awindow_folder) {
3285 case AW_AEFFECT_FOLDER:
3286 context_help_show("Audio Effects");
3288 case AW_VEFFECT_FOLDER:
3289 context_help_show("Video Effects");
3291 case AW_ATRANSITION_FOLDER:
3292 context_help_show("Audio Transitions");
3294 case AW_VTRANSITION_FOLDER:
3295 context_help_show("Video Transitions");
3298 context_help_show("Resources Window");
3301 context_help_show("Resources Window");
3305 case AW_LABEL_FOLDER:
3306 context_help_show("Labels");
3309 case AW_CLIP_FOLDER:
3310 context_help_show("Nested Clips");
3313 case AW_PROXY_FOLDER:
3314 context_help_show("Proxy");
3318 context_help_show("Resources Window");
3322 context_help_show("Resources Window");
3327 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3328 : BC_TextBox(x, y, w, 1, "")
3330 this->search_text = search_text;
3333 int AWindowSearchTextBox::handle_event()
3335 return search_text->handle_event();
3338 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3340 this->mwindow = mwindow;
3346 void AWindowSearchText::create_objects()
3350 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3351 x1 += text_title->get_w() + xs10;
3352 int w1 = gui->get_w() - x1 - 2*xs10;
3353 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3356 int AWindowSearchText::handle_event()
3358 gui->async_update_assets();
3362 int AWindowSearchText::get_w()
3364 return text_box->get_w() + text_title->get_w() + xS(10);
3367 int AWindowSearchText::get_h()
3369 return bmax(text_box->get_h(),text_title->get_h());
3372 void AWindowSearchText::reposition_window(int x, int y, int w)
3376 text_title->reposition_window(x1, y1);
3377 x1 += text_title->get_w() + xs10;
3378 int w1 = gui->get_w() - x1 - 2*xs10;
3379 text_box->reposition_window(x1, y1, w1);
3382 const char *AWindowSearchText::get_text()
3384 return text_box->get_text();
3387 void AWindowSearchText::clear()
3389 text_box->update("");
3392 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3393 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3395 this->mwindow = mwindow;
3397 set_tooltip(_("Delete asset from disk"));
3400 int AWindowDeleteDisk::handle_event()
3405 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3406 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3408 this->mwindow = mwindow;
3410 set_tooltip(_("Delete asset from project"));
3413 int AWindowDeleteProject::handle_event()
3418 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3419 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3421 // this->mwindow = mwindow;
3423 // set_tooltip(_("Edit information on asset"));
3426 // int AWindowInfo::handle_event()
3428 // int cur_x, cur_y;
3429 // gui->get_abs_cursor(cur_x, cur_y, 0);
3430 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3434 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3435 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3437 this->mwindow = mwindow;
3439 set_tooltip(_("Redraw index"));
3442 int AWindowRedrawIndex::handle_event()
3447 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3448 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3450 this->mwindow = mwindow;
3452 set_tooltip(_("Paste asset on recordable tracks"));
3455 int AWindowPaste::handle_event()
3460 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3461 : BC_Button(x, y, mwindow->theme->appendasset_data)
3463 this->mwindow = mwindow;
3465 set_tooltip(_("Append asset in new tracks"));
3468 int AWindowAppend::handle_event()
3473 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3474 : BC_Button(x, y, mwindow->theme->viewasset_data)
3476 this->mwindow = mwindow;
3478 set_tooltip(_("View asset"));
3481 int AWindowView::handle_event()
3486 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3487 : BC_PopupMenu(x, y, title, -1, 0)
3489 this->mwindow = mwindow;
3493 void AddTools::create_objects()
3496 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3497 vis |= 1 << PLUGIN_FFMPEG_ID;
3498 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3499 vis |= 1 << PLUGIN_LADSPA_ID;
3501 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3502 vis |= 1 << PLUGIN_LV2_ID;
3504 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3505 PluginServer *plugin = MWindow::plugindb->get(i);
3506 if( !plugin->audio && !plugin->video ) continue;
3507 int idx = plugin->dir_idx;
3508 uint32_t msk = 1 << idx;
3509 if( (msk & vis) != 0 ) continue;
3511 char parent[BCTEXTLEN];
3512 strcpy(parent, plugin->path);
3513 char *bp = strrchr(parent, '/');
3514 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3515 if( !bp ) bp = parent; else ++bp;
3516 add_item(new AddPluginItem(this, bp, idx));
3521 // plugin_dirs list from toplevel makefile include plugin_defs
3526 N_("audio_transitions")
3533 N_("video_transitions")
3536 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3537 : BC_MenuItem(_(text))
3541 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3542 int chk = (msk & vis) ? 1 : 0;
3546 int AddPluginItem::handle_event()
3548 int chk = get_checked() ^ 1;
3550 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3551 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3552 menu->gui->update_effects();
3553 menu->gui->save_defaults(menu->mwindow->defaults);
3554 menu->gui->async_update_assets();
3558 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3561 this->avicon = avicon;
3565 int AVIconDrawingItem::handle_event()
3567 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3568 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3569 item->set_checked(id == i);
3571 AWindowGUI *agui = avicon->agui;
3573 avicon->set_text(get_text());
3574 agui->stop_vicon_drawing();
3575 agui->vicon_thread->set_view_popup(0);
3576 agui->vicon_thread->solo = 0;
3577 agui->vicon_drawing = id;
3578 agui->start_vicon_drawing();
3582 int AVIconDrawing::draw_face(int dx, int color)
3584 int ret = BC_PopupMenu::draw_face(dx, color);
3585 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3586 int lx = get_margin(), ly = get_h()/2;
3587 draw_line(lx,ly, get_w()-2*lx,ly);
3592 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3593 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3598 AVIconDrawing::~AVIconDrawing()
3602 void AVIconDrawing::create_objects()
3604 AVIconDrawingItem *item;
3605 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3606 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3607 item->set_checked(agui->vicon_drawing == i);
3611 int AVIconDrawing::button_press_event()
3613 if( !is_event_win() ) return 0;
3614 if( get_buttonpress() == MIDDLE_BUTTON ) {
3615 agui->play_off = !agui->play_off ? 1 : 0;
3618 agui->start_vicon_drawing();
3621 return BC_PopupMenu::button_press_event();
3624 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3625 : BC_MenuItem("","v",'v')
3627 this->mwindow = mwindow;
3631 int AWindowListFormat::handle_event()
3633 return gui->cycle_assetlist_format();
3636 void AWindowListFormat::update()
3638 EDLSession *session = mwindow->edl->session;
3639 const char *text = 0;
3640 switch( session->assetlist_format ) {
3642 text = _("Display icons");
3645 text = _("Display icons packed");
3647 case ASSETS_ICONS_PACKED:
3648 text = _("Display icon list");
3650 case ASSETS_ICON_LIST:
3651 text = _("Display text");
3657 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3658 : BC_MenuItem(_("Sort items"))
3660 this->mwindow = mwindow;
3664 int AWindowListSort::handle_event()
3670 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3673 this->select_used = select_used;
3674 this->action = action;
3677 int AssetSelectUsedItem::handle_event()
3679 MWindow *mwindow = select_used->mwindow;
3680 AWindowGUI *gui = select_used->gui;
3681 AWindowAssets *asset_list = gui->asset_list;
3682 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3687 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3691 asset_list->set_all_selected(data, 0);
3692 for( int i = 0; i < data->total; i++ ) {
3693 AssetPicon *picon = (AssetPicon*)data->values[i];
3694 Indexable *idxbl = picon->indexable ? picon->indexable :
3695 picon->edl ? picon->edl->get_proxy_asset() : 0;
3696 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3697 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3702 int asset_xposition = asset_list->get_xposition();
3703 int asset_yposition = asset_list->get_yposition();
3704 asset_list->update(gui->displayed_assets, gui->asset_titles,
3705 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3706 asset_xposition, asset_yposition, -1, 0);
3707 asset_list->center_selection();
3711 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3712 : BC_MenuItem(_("Select"))
3714 this->mwindow = mwindow;