4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "assetedit.h"
25 #include "assetpopup.h"
26 #include "assetremove.h"
28 #include "audiodevice.h"
30 #include "awindowgui.h"
31 #include "bccmodels.h"
33 #include "bcsignals.h"
35 #include "binfolder.h"
40 #include "clippopup.h"
42 #include "cwindowgui.h"
47 #include "edlsession.h"
48 #include "effectlist.h"
50 #include "filesystem.h"
51 #include "folderlistmenu.h"
52 #include "indexable.h"
56 #include "labelpopup.h"
57 #include "localsession.h"
58 #include "mainerror.h"
60 #include "mainsession.h"
61 #include "mwindowgui.h"
63 #include "preferences.h"
65 #include "proxypopup.h"
66 #include "renderengine.h"
71 #include "transportque.h"
75 #include "vwindowgui.h"
78 #include "data/lad_picon_png.h"
79 #include "data/ff_audio_png.h"
80 #include "data/ff_video_png.h"
87 const char *AWindowGUI::folder_names[] =
91 N_("Audio Transitions"),
92 N_("Video Transitions"),
99 const char *AVIconDrawing::avicon_names[] =
107 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
108 : VIcon(w, h, framerate), Garbage("AssetVIcon")
111 this->length = length;
116 AssetVIcon::~AssetVIcon()
118 if( picon->gui->vicon_thread->solo == this )
119 picon->gui->vicon_thread->solo = 0;
120 picon->gui->vicon_thread->del_vicon(this);
124 VFrame *AssetVIcon::frame()
126 if( broken ) return 0;
127 AssetVIconThread *avt = picon->gui->vicon_thread;
128 Indexable *idxbl = picon->indexable;
129 Asset *asset = idxbl && idxbl->is_asset ? (Asset *)idxbl : 0;
130 if( !asset ) return vframes()>0 ? (VFrame*)*images[0] : 0;
131 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
132 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
134 int sample_rate = asset->get_sample_rate();
135 int64_t audio_samples = asset->get_audio_samples();
136 double duration = (double)audio_samples / sample_rate;
137 picon->draw_hue_bar(temp, duration);
138 int secs = length / frame_rate + 0.5;
139 if( !secs ) secs = 1;
140 int bfrsz = VICON_SAMPLE_RATE;
141 int samples = audio_size/sizeof(vicon_audio_t);
142 double line_pos = (double)seq_no/(length-1);
143 int audio_pos = samples * line_pos * (secs-1)/secs;
144 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
145 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
146 double data[bfrsz], sample_scale = 1./mx;
147 int len = samples - audio_pos;
148 if( len > bfrsz ) len = bfrsz;
150 while( i < len ) data[i++] = *audio_data++ * sample_scale;
151 while( i < bfrsz ) data[i++] = 0;
152 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
153 int x = (w-1) * line_pos;
154 temp->pixel_rgb = RED;
155 temp->draw_line(x,0, x,h);
158 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
159 if( !asset->video_data ) {
161 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
166 if( seq_no >= images.size() ) {
167 MWindow *mwindow = picon->mwindow;
168 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
169 delete temp; temp = 0;
172 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
173 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
174 if( !file ) { broken = 1; return 0; }
176 while( file && seq_no >= images.size() && !avt->interrupted ) {
177 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
178 file->set_video_position(pos,0);
180 if( file->read_frame(temp) ) temp->clear_frame();
181 add_image(temp, vw, vh, vicon_cmodel);
182 mwindow->video_cache->check_in(asset);
183 if( timer.get_difference() > 500 ) return 0;
185 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
186 for( int retries=10; !file && --retries>=0; usleep(1000) ) {
187 if( avt->interrupted ) return 0;
188 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
190 if( !file ) return 0;
192 mwindow->video_cache->check_in(asset);
194 if( seq_no >= images.size() ) return 0;
195 return *images[seq_no];
198 int64_t AssetVIcon::set_seq_no(int64_t no)
200 if( no >= length ) no = 0;
204 int AssetVIcon::get_vx()
206 BC_ListBox *lbox = picon->gui->asset_list;
207 return lbox->get_icon_x(picon);
209 int AssetVIcon::get_vy()
211 BC_ListBox *lbox = picon->gui->asset_list;
212 return lbox->get_icon_y(picon);
215 void AssetVIcon::load_audio()
217 MWindow *mwindow = picon->mwindow;
218 Asset *asset = (Asset *)picon->indexable;
219 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
220 int channels = asset->get_audio_channels();
221 if( channels > 2 ) channels = 2;
222 int sample_rate = asset->get_sample_rate();
223 int bfrsz = sample_rate;
224 Samples samples(bfrsz);
225 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
226 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
227 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
228 double sample_scale = (double)mx / channels;
229 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
230 while( audio_pos < audio_len ) {
231 int64_t pos = audio_pos * time_scale;
232 for( int ch=0; ch<channels; ++ch ) {
233 file->set_channel(ch);
234 file->set_audio_position(pos);
235 file->read_samples(&samples, bfrsz);
236 double *data = samples.get_data();
237 for( int64_t k=audio_pos; k<audio_len; ++k ) {
238 int i = k * time_scale - pos;
239 if( i >= bfrsz ) break;
240 int v = audio_data[k] + data[i] * sample_scale;
241 audio_data[k] = CLIP(v, -mx,mx);
244 audio_pos = (pos + bfrsz) / time_scale;
246 mwindow->audio_cache->check_in(asset);
250 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
254 audio = new AudioDevice(gui->mwindow);
258 AssetVIconAudio::~AssetVIconAudio()
263 void AssetVIconAudio::run()
266 int64_t bfrsz = VICON_SAMPLE_RATE;
267 MWindow *mwindow = gui->mwindow;
268 EDL *edl = mwindow->edl;
269 EDLSession *session = edl->session;
270 AudioOutConfig *aconfig = session->playback_config->aconfig;
271 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
272 audio->start_playback();
273 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
274 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
275 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
277 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
278 while( !interrupted ) {
279 int len = audio_len - audio_pos;
280 if( len <= 0 ) break;
281 if( len > bfrsz ) len = bfrsz;
283 for( int i=0; i<len; ++i,++k )
284 out0[i] = out1[i] = (double)audio_data[k] / mx;
286 audio->write_buffer(out, channels, len);
290 audio->set_last_buffer();
291 audio->stop_audio(interrupted ? 0 : 1);
295 void AssetVIconAudio::start(AssetVIcon *vicon)
297 if( running() ) return;
299 double pos = vicon->length > 0 ? (double)vicon->seq_no/vicon->length : 0;
300 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
301 audio_pos = pos * audio_len;
306 void AssetVIconAudio::stop(int wait)
308 if( running() && !interrupted ) {
310 audio->stop_audio(wait);
314 vicon->playing_audio = 0;
319 void AssetVIcon::start_audio()
321 if( playing_audio < 0 ) return;
322 picon->gui->vicon_audio->stop(0);
324 picon->gui->vicon_audio->start(this);
327 void AssetVIcon::stop_audio()
329 if( playing_audio > 0 ) {
330 picon->gui->vicon_audio->stop(0);
335 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
336 int x, int y, int w, int h)
337 : ViewPopup(vt, x, y, w, h)
339 this->draw_mode = draw_mode;
340 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
344 AssetViewPopup::~AssetViewPopup()
348 int AssetViewPopup::reposition_window(int x, int y, int w, int h)
350 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
351 return ViewPopup::reposition_window(x, y, w, h);
354 int AssetViewPopup::button_press_event()
356 if( !is_event_win() ) return 0;
357 AssetVIconThread *avt = (AssetVIconThread *)vt;
358 if( !avt->vicon ) return 0;
361 switch( get_buttonpress() ) {
365 avt->set_view_popup(0);
368 dir = -1; // fall thru
370 switch( draw_mode ) {
371 case ASSET_VIEW_MEDIA:
372 case ASSET_VIEW_MEDIA_MAP:
373 avt->zoom_scale(dir);
380 int x = get_cursor_x(), y = get_cursor_y();
381 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
382 AssetPicon *picon = vicon->picon;
383 MWindow *mwindow = picon->mwindow;
384 EDL *edl = mwindow->edl;
386 if( y < get_h()/2 ) {
388 picon->indexable ? picon->indexable :
389 picon->edl ? picon->edl : 0;
390 if( !idxbl ) return 0;
391 double sample_rate = idxbl->get_sample_rate();
392 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
393 idxbl->get_audio_samples() / sample_rate : 0;
394 double frame_rate = idxbl->get_frame_rate();
395 double video_length = frame_rate > 0 && idxbl->have_video() ?
396 idxbl->get_video_frames() / frame_rate : 0;
397 double idxbl_length = bmax(audio_length, video_length);
398 double pos = x * idxbl_length / get_w();
399 double start = 0, end = idxbl_length;
400 double lt = DBL_MAX, rt = DBL_MAX;
401 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
402 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
403 Indexable *indexable = (Indexable *)edit->asset;
404 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
405 if( !indexable ) continue;
406 if( indexable->id == idxbl->id ||
407 (!indexable->is_asset == !idxbl->is_asset &&
408 !strcmp(indexable->path, idxbl->path)) ) {
409 double start_pos = track->from_units(edit->startsource);
410 double end_pos = track->from_units(edit->startsource + edit->length);
411 double dlt = pos - start_pos, drt = end_pos - pos;
412 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
413 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
414 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
415 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
419 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
420 VWindow *vwindow = mwindow->get_viewer(1, 0);
421 vwindow->change_source(idxbl);
422 mwindow->gui->unlock_window();
423 EDL *vedl = vwindow->get_edl();
424 vedl->set_inpoint(start);
425 vedl->set_outpoint(end);
426 vedl->local_session->set_selectionstart(start);
427 vedl->local_session->set_selectionend(start);
428 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
429 vwindow->update_position();
430 vwindow->gui->unlock_window();
435 if( !ctrl_down() && !shift_down() )
436 return cursor_motion_event();
438 picon->indexable ? picon->indexable :
439 picon->edl ? picon->edl : 0;
440 if( !idxbl ) return 0;
441 double total_length = mwindow->edl->tracks->total_length();
442 double pos = x * total_length / get_w();
443 double start = 0, end = total_length;
444 double lt = DBL_MAX, rt = DBL_MAX;
445 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
446 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
447 Indexable *indexable = (Indexable *)edit->asset;
448 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
449 if( !indexable ) continue;
450 if( indexable->id == idxbl->id ||
451 (!indexable->is_asset == !idxbl->is_asset &&
452 !strcmp(indexable->path, idxbl->path)) ) {
453 double start_pos = track->from_units(edit->startproject);
454 double end_pos = track->from_units(edit->startproject + edit->length);
455 double dlt = pos - start_pos, drt = end_pos - pos;
456 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
457 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
458 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
459 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
463 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
464 mwindow->select_point(start);
465 edl->local_session->set_selectionstart(start);
466 edl->local_session->set_selectionend(!shift_down() ? start : end);
467 mwindow->zoom_sample(edl->local_session->zoom_sample);
468 mwindow->gui->unlock_window();
474 int AssetViewPopup::button_release_event()
476 if( !is_event_win() ) return 0;
481 int AssetViewPopup::cursor_motion_event()
483 AssetVIconThread *avt = (AssetVIconThread *)vt;
484 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
485 if( vicon && dragging && is_event_win() &&
486 get_button_down() && get_buttonpress() == LEFT_BUTTON &&
487 !ctrl_down() && !alt_down() && !shift_down() ) {
488 switch( draw_mode ) {
489 case ASSET_VIEW_MEDIA_MAP:
490 case ASSET_VIEW_FULL:
491 MWindow *mwindow = vicon->picon->mwindow;
492 EDL *edl = mwindow->edl;
493 int x = get_cursor_x();
494 double total_length = edl->tracks->total_length();
495 double pos = x * total_length / get_w();
496 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
497 mwindow->select_point(pos);
498 mwindow->zoom_sample(edl->local_session->zoom_sample);
499 mwindow->gui->unlock_window();
506 void AssetViewPopup::draw_vframe(VFrame *vframe)
508 switch( draw_mode ) {
509 case ASSET_VIEW_MEDIA:
510 case ASSET_VIEW_ICON:
511 ViewPopup::draw_vframe(vframe);
512 case ASSET_VIEW_NONE:
515 case ASSET_VIEW_MEDIA_MAP:
516 case ASSET_VIEW_FULL:
520 draw_box(0,0,get_w(),get_h());
522 int y2 = get_h()-bar_h;
523 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
524 AssetVIconThread *avt = (AssetVIconThread *)vt;
525 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
526 AssetPicon *picon = (AssetPicon *)vicon->picon;
528 picon->indexable ? picon->indexable :
529 picon->edl ? picon->edl : 0;
531 double sample_rate = idxbl->get_sample_rate();
532 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
533 idxbl->get_audio_samples() / sample_rate : 0;
534 double frame_rate = idxbl->get_frame_rate();
535 double video_length = frame_rate > 0 && idxbl->have_video() ?
536 idxbl->get_video_frames() / frame_rate : 0;
537 double idxbl_length = bmax(audio_length, video_length);
538 if( !idxbl_length ) idxbl_length = 1;
540 EDL *edl = picon->mwindow->edl;
541 double total_length = edl->tracks->total_length();
542 if( !total_length ) total_length = 1;
543 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
544 if( !track->is_armed() ) continue;
545 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
546 Indexable *indexable = (Indexable *)edit->asset;
547 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
548 if( !indexable ) continue;
549 if( indexable->id == idxbl->id ||
550 (!indexable->is_asset == !idxbl->is_asset &&
551 !strcmp(indexable->path, idxbl->path)) ) {
552 double pos1 = track->from_units(edit->startsource);
553 double pos2 = track->from_units(edit->startsource + edit->length);
554 double xscale = get_w() / idxbl_length;
555 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
557 draw_box(ex1,0, ex2-ex1,y1);
559 draw_line(ex1,0, ex1,y1);
560 draw_line(ex2,0, ex2,y1);
561 pos1 = track->from_units(edit->startproject);
562 pos2 = track->from_units(edit->startproject + edit->length);
563 xscale = get_w() / total_length;
564 int px1 = pos1 * xscale, px2 = pos2 * xscale;
566 draw_box(px1,y2, px2-px1,get_h()-y2);
568 draw_line(px1,y2, px1,get_h()-1);
569 draw_line(px2,y2, px2,get_h()-1);
572 draw_line(ex1,y1, px1,y2);
573 draw_line(ex2,y1, px2,y2);
579 int AssetViewPopup::keypress_event()
582 AssetVIconThread *avt = (AssetVIconThread *)vt;
583 switch( avt->draw_mode ) {
584 case ASSET_VIEW_MEDIA_MAP:
585 switch( get_keypress() ) {
588 avt->draw_mode = ASSET_VIEW_FULL;
592 case ASSET_VIEW_FULL:
593 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
596 if( result ) // zero change for refresh
598 return ViewPopup::keypress_event();
602 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
603 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
604 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
607 draw_mode = ASSET_VIEW_NONE;
608 int vicon_cmodel = BC_RGB8;
609 switch( preferences->vicon_color_mode ) {
610 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
611 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
612 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
614 this->vicon_cmodel = vicon_cmodel;
617 AssetVIconThread::~AssetVIconThread()
621 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
623 gui->stop_vicon_drawing();
624 this->draw_mode = draw_mode;
626 gui->start_vicon_drawing();
629 void AssetVIconThread::set_view_popup(AssetVIcon *v)
631 if( !v ) draw_mode = ASSET_VIEW_NONE;
632 VIconThread::set_view_popup(v);
635 ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
637 BC_WindowBase *parent = wdw->get_parent();
638 int rx = 0, ry = 0, rw = 0, rh = 0;
639 if( draw_mode != ASSET_VIEW_FULL ) {
640 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
641 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
642 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
643 int vx = viewing->get_vx(), vy = viewing->get_vy();
644 wdw->get_root_coordinates(vx, vy, &rx, &ry);
645 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
646 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
647 rw = view_w; rh = view_h;
650 parent->get_fullscreen_geometry(rx, ry, rw, rh);
651 AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
653 av_popup->reposition_window(rx, ry, rw, rh);
655 av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
656 int playing_audio = gui->play_off ? -1 : 0;
657 if( !playing_audio ) {
658 switch( draw_mode ) {
659 case ASSET_VIEW_NONE:
660 case ASSET_VIEW_ICON:
661 case ASSET_VIEW_MEDIA_MAP:
662 case ASSET_VIEW_FULL:
665 case ASSET_VIEW_MEDIA:
666 switch( gui->vicon_drawing ) {
667 case AVICON_SRC_TARGET:
674 vicon->playing_audio = playing_audio;
675 wdw->set_active_subwindow(av_popup);
679 void AssetVIconThread::stop_vicon_drawing(int wait)
682 gui->lock_window("AssetVIconThread::stop_vicon_drawing");
683 gui->unlock_window();
687 AWindowFolderItem::AWindowFolderItem()
693 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
694 : BC_ListBoxItem(text, color)
699 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
700 : BC_ListBoxItem(text, icon, color)
705 AssetPicon *AWindowFolderItem::get_picon()
707 AWindowFolderItem *item = this;
708 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
709 return (AssetPicon*)item;
712 int AWindowFolderSubItems::matches(const char *text)
714 int i = names.size();
715 while( --i >= 0 && strcmp(names[i], text) );
717 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
718 i = sublist ? sublist->size() : 0;
720 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
721 if( item->matches(text) ) break;
724 return i >= 0 ? 1 : 0;
728 AssetPicon::AssetPicon(MWindow *mwindow,
729 AWindowGUI *gui, Indexable *indexable)
730 : AWindowFolderItem()
733 this->mwindow = mwindow;
735 this->indexable = indexable;
736 indexable->add_user();
737 this->id = indexable->id;
740 AssetPicon::AssetPicon(MWindow *mwindow,
741 AWindowGUI *gui, EDL *edl)
742 : AWindowFolderItem()
745 this->mwindow = mwindow;
752 AssetPicon::AssetPicon(MWindow *mwindow,
753 AWindowGUI *gui, int folder, int persist)
754 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
755 folder>=0 && folder<AWINDOW_FOLDERS ?
756 gui->folder_icons[folder] : gui->folder_icon)
760 this->mwindow = mwindow;
762 persistent = persist;
765 AssetPicon::AssetPicon(MWindow *mwindow,
766 AWindowGUI *gui, int folder, const char *title)
767 : AWindowFolderItem(title, gui->folder_icon)
771 this->mwindow = mwindow;
776 AssetPicon::AssetPicon(MWindow *mwindow,
777 AWindowGUI *gui, PluginServer *plugin)
778 : AWindowFolderItem()
781 this->mwindow = mwindow;
783 this->plugin = plugin;
786 AssetPicon::AssetPicon(MWindow *mwindow,
787 AWindowGUI *gui, Label *label)
788 : AWindowFolderItem()
791 this->mwindow = mwindow;
799 AssetPicon::~AssetPicon()
801 if( vicon ) vicon->remove_user();
803 if( indexable ) indexable->remove_user();
804 if( edl ) edl->remove_user();
805 if( icon && !gui->protected_pixmap(icon) ) {
807 if( !plugin ) delete icon_vframe;
811 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
813 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
815 float h = 300 * t, s = 1., v = 1.;
816 float r, g, b; // duration, 0..1hr == hue red..magenta
817 HSV::hsv_to_rgb(r,g,b, h,s,v);
818 int ih = frame->get_h()/8, iw = frame->get_w();
819 int ir = r * 256; CLAMP(ir, 0,255);
820 int ig = g * 256; CLAMP(ig, 0,255);
821 int ib = b * 256; CLAMP(ib, 0,255);
822 unsigned char **rows = frame->get_rows();
823 for( int y=0; y<ih; ++y ) {
824 unsigned char *rp = rows[y];
825 for( int x=0; x<iw; rp+=3,++x ) {
826 rp[0] = ir; rp[1] = ig; rp[2] = ib;
831 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
832 int base_color, int line_color, int x, int y, int w, int h)
834 int h1 = h-1, h2 = h/2, iy = h2;
835 int rgb_color = frame->pixel_rgb;
836 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
837 double min = *dp, max = min;
838 x2 = (len * (ix+1))/w;
839 for( int i=x1; i<x2; ++i ) {
840 double value = *dp++;
841 if( value < min ) min = value;
842 if( value > max ) max = value;
844 int ctr = (min + max) / 2;
845 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
846 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
847 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
848 frame->pixel_rgb = line_color;
849 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
850 frame->pixel_rgb = base_color;
851 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
854 frame->pixel_rgb = rgb_color;
857 void AssetPicon::reset()
865 foldernum = AW_NO_FOLDER;
880 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
882 TransportCommand command;
883 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
884 command.get_edl()->copy_all(edl);
885 command.change_type = CHANGE_ALL;
886 command.realtime = 0;
887 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
888 render_engine->set_vcache(mwindow->video_cache);
889 render_engine->set_acache(mwindow->audio_cache);
890 render_engine->arm_command(&command);
892 void AssetPicon::close_render_engine()
894 delete render_engine; render_engine = 0;
896 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
898 if( !render_engine || !render_engine->vrender ) return;
899 render_engine->vrender->process_buffer(vfrm, pos, 0);
901 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
903 if( !render_engine || !render_engine->arender ) return;
904 render_engine->arender->process_buffer(samples, len, pos);
907 void AssetPicon::create_objects()
910 char name[BCTEXTLEN];
911 int pixmap_w, pixmap_h;
913 int picon_h = mwindow->preferences->awindow_picon_h;
914 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
920 if( this->indexable ) {
922 if( this->indexable->is_asset ) {
923 asset = (Asset *)indexable;
924 if( asset->format == FILE_REF ) {
925 cp += sprintf(cp, "ref:");
926 set_color(get_color() ^ 0x5599CC);
930 edl = (EDL *)indexable;
931 cp += sprintf(cp, "edl:");
932 // set_color(get_color() ^ 0xCC9955);
934 fs.extract_name(cp, indexable->path);
937 else if( this->edl ) {
939 strcpy(name, edl->local_session->clip_title);
945 if( asset->video_data ) {
946 if( mwindow->preferences->use_thumbnails ) {
947 gui->unlock_window();
948 char string[BCTEXTLEN];
949 sprintf(string, _("Reading %s"), name);
950 mwindow->gui->lock_window("AssetPicon::create_objects");
951 mwindow->gui->show_message(string);
952 mwindow->gui->unlock_window();
953 File *file = mwindow->video_cache->check_out(asset,
958 int height = asset->height > 0 ? asset->height : 1;
959 pixmap_w = pixmap_h * asset->width / height;
962 file->set_video_position(0, 0);
964 if( gui->temp_picon &&
965 (gui->temp_picon->get_w() != asset->width ||
966 gui->temp_picon->get_h() != asset->height) ) {
967 delete gui->temp_picon;
971 if( !gui->temp_picon ) {
972 gui->temp_picon = new VFrame(0, -1,
973 asset->width, asset->height,
976 file->read_frame(gui->temp_picon);
977 mwindow->video_cache->check_in(asset);
979 gui->lock_window("AssetPicon::create_objects 0");
980 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
981 icon->draw_vframe(gui->temp_picon,
982 0, 0, pixmap_w, pixmap_h, 0, 0);
983 icon_vframe = new VFrame(0,
984 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
985 icon_vframe->transfer_from(gui->temp_picon);
986 if( asset->folder_no == AW_MEDIA_FOLDER ||
987 asset->folder_no == AW_PROXY_FOLDER ) {
989 double framerate = asset->get_frame_rate();
990 if( !framerate ) framerate = VICON_RATE;
991 int64_t frames = asset->get_video_frames();
992 double secs = frames / framerate;
993 if( secs > 5 ) secs = 5;
994 int64_t length = secs * gui->vicon_thread->refresh_rate;
995 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
996 if( asset->audio_data && secs > 0 ) {
997 gui->unlock_window();
998 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
999 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1000 vicon->load_audio();
1001 gui->lock_window("AssetPicon::create_objects 1");
1003 gui->vicon_thread->add_vicon(vicon);
1007 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1008 gui->lock_window("AssetPicon::create_objects 2");
1009 icon = gui->video_icon;
1010 icon_vframe = gui->video_vframe;
1014 icon = gui->video_icon;
1015 icon_vframe = gui->video_vframe;
1019 if( asset->audio_data ) {
1020 if( mwindow->preferences->use_thumbnails ) {
1021 gui->unlock_window();
1022 File *file = mwindow->audio_cache->check_out(asset,
1026 pixmap_w = pixmap_h * 16/9;
1027 icon_vframe = new VFrame(0,
1028 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1029 icon_vframe->clear_frame();
1030 { char string[BCTEXTLEN];
1031 sprintf(string, _("Reading %s"), name);
1032 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1033 mwindow->gui->show_message(string);
1034 mwindow->gui->unlock_window(); }
1035 int sample_rate = asset->get_sample_rate();
1036 int channels = asset->get_audio_channels();
1037 if( channels > 2 ) channels = 2;
1038 int64_t audio_samples = asset->get_audio_samples();
1039 double duration = (double)audio_samples / sample_rate;
1040 draw_hue_bar(icon_vframe, duration);
1041 int bfrsz = sample_rate;
1042 Samples samples(bfrsz);
1043 static int line_colors[2] = { GREEN, YELLOW };
1044 static int base_colors[2] = { RED, PINK };
1045 for( int i=channels; --i>=0; ) {
1046 file->set_channel(i);
1047 file->set_audio_position(0);
1048 file->read_samples(&samples, bfrsz);
1049 draw_wave(icon_vframe, samples.get_data(), bfrsz,
1050 base_colors[i], line_colors[i]);
1052 mwindow->audio_cache->check_in(asset);
1053 if( asset->folder_no == AW_MEDIA_FOLDER ) {
1054 double secs = duration;
1055 if( secs > 5 ) secs = 5;
1056 double refresh_rate = gui->vicon_thread->refresh_rate;
1057 int64_t length = secs * refresh_rate;
1058 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1059 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1060 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1061 vicon->load_audio();
1062 gui->vicon_thread->add_vicon(vicon);
1064 gui->lock_window("AssetPicon::create_objects 4");
1065 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1066 icon->draw_vframe(icon_vframe,
1067 0, 0, pixmap_w, pixmap_h, 0, 0);
1070 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1071 gui->lock_window("AssetPicon::create_objects 5");
1072 icon = gui->audio_icon;
1073 icon_vframe = gui->audio_vframe;
1077 icon = gui->audio_icon;
1078 icon_vframe = gui->audio_vframe;
1083 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1084 comments_rate = asset->get_frame_rate();
1085 comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
1086 comments_type = asset->format == FILE_FFMPEG ?
1087 asset->vcodec : File::formattostr(asset->format);
1090 if( edl->tracks->playable_video_tracks() ) {
1091 if( mwindow->preferences->use_thumbnails ) {
1092 gui->unlock_window();
1093 AssetVIconThread *avt = gui->vicon_thread;
1094 char clip_icon_path[BCTEXTLEN];
1095 char *clip_icon = edl->local_session->clip_icon;
1097 if( is_clip && clip_icon[0] ) {
1098 snprintf(clip_icon_path, sizeof(clip_icon_path),
1099 "%s/%s", File::get_config_path(), clip_icon);
1100 vframe = VFramePng::vframe_png(clip_icon_path);
1103 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1104 delete vframe; vframe = 0;
1106 int edl_h = edl->get_h(), edl_w = edl->get_w();
1107 int height = edl_h > 0 ? edl_h : 1;
1108 int width = edl_w > 0 ? edl_w : 1;
1109 int color_model = edl->session->color_model;
1111 //printf("render clip: %s\n", name);
1112 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1113 char string[BCTEXTLEN];
1114 sprintf(string, _("Rendering %s"), name);
1115 mwindow->gui->lock_window("AssetPicon::create_objects");
1116 mwindow->gui->show_message(string);
1117 mwindow->gui->unlock_window();
1118 open_render_engine(edl, 0);
1119 render_video(0, gui->temp_picon);
1120 close_render_engine();
1121 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1122 vframe->transfer_from(gui->temp_picon);
1123 if( this->edl && clip_icon[0] )
1124 vframe->write_png(clip_icon_path);
1126 pixmap_w = pixmap_h * width / height;
1127 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1128 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1129 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1130 icon_vframe->transfer_from(vframe);
1132 gui->lock_window("AssetPicon::create_objects 0");
1133 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1134 icon->draw_vframe(icon_vframe,
1135 0, 0, pixmap_w, pixmap_h, 0, 0);
1137 else if( is_clip ) {
1138 icon = gui->clip_icon;
1139 icon_vframe = gui->clip_vframe;
1142 icon = gui->video_icon;
1143 icon_vframe = gui->video_vframe;
1147 if( edl->tracks->playable_audio_tracks() ) {
1148 if( mwindow->preferences->use_thumbnails ) {
1149 gui->unlock_window();
1150 char clip_icon_path[BCTEXTLEN];
1151 char *clip_icon = edl->local_session->clip_icon;
1152 if( is_clip && clip_icon[0] ) {
1153 snprintf(clip_icon_path, sizeof(clip_icon_path),
1154 "%s/%s", File::get_config_path(), clip_icon);
1155 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1157 if( !icon_vframe ) {
1158 pixmap_w = pixmap_h * 16/9;
1159 icon_vframe = new VFrame(0,
1160 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1161 icon_vframe->clear_frame();
1162 char string[BCTEXTLEN];
1163 sprintf(string, _("Rendering %s"), name);
1164 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1165 mwindow->gui->show_message(string);
1166 mwindow->gui->unlock_window();
1167 int sample_rate = edl->get_sample_rate();
1168 int channels = edl->get_audio_channels();
1169 if( channels > 2 ) channels = 2;
1170 int64_t audio_samples = edl->get_audio_samples();
1171 double duration = (double)audio_samples / sample_rate;
1172 draw_hue_bar(icon_vframe, duration);
1173 Samples *samples[MAX_CHANNELS];
1174 int bfrsz = sample_rate;
1175 for( int i=0; i<MAX_CHANNELS; ++i )
1176 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1177 open_render_engine(edl, 1);
1178 render_audio(0, samples, bfrsz);
1179 close_render_engine();
1180 gui->lock_window("AssetPicon::create_objects 4");
1181 static int line_colors[2] = { GREEN, YELLOW };
1182 static int base_colors[2] = { RED, PINK };
1183 for( int i=channels; --i>=0; ) {
1184 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1185 base_colors[i], line_colors[i]);
1187 for( int i=0; i<channels; ++i ) delete samples[i];
1188 if( is_clip && clip_icon[0] )
1189 icon_vframe->write_png(clip_icon_path);
1192 pixmap_w = icon_vframe->get_w();
1193 pixmap_h = icon_vframe->get_h();
1195 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1196 icon->draw_vframe(icon_vframe,
1197 0, 0, pixmap_w, pixmap_h, 0, 0);
1199 else if( !indexable ) {
1200 icon = gui->clip_icon;
1201 icon_vframe = gui->clip_vframe;
1204 icon = gui->audio_icon;
1205 icon_vframe = gui->audio_vframe;
1210 strcpy(name, _(plugin->title));
1212 icon_vframe = plugin->get_picon();
1214 icon = gui->create_pixmap(icon_vframe);
1215 else if( plugin->audio ) {
1216 if( plugin->transition ) {
1217 icon = gui->atransition_icon;
1218 icon_vframe = gui->atransition_vframe;
1220 else if( plugin->is_ffmpeg() ) {
1221 icon = gui->ff_aud_icon;
1222 icon_vframe = gui->ff_aud_vframe;
1224 else if( plugin->is_ladspa() ) {
1225 icon = gui->ladspa_icon;
1226 icon_vframe = gui->ladspa_vframe;
1229 icon = gui->aeffect_icon;
1230 icon_vframe = gui->aeffect_vframe;
1233 else if( plugin->video ) {
1234 if( plugin->transition ) {
1235 icon = gui->vtransition_icon;
1236 icon_vframe = gui->vtransition_vframe;
1238 else if( plugin->is_ffmpeg() ) {
1239 icon = gui->ff_vid_icon;
1240 icon_vframe = gui->ff_vid_vframe;
1243 icon = gui->veffect_icon;
1244 icon_vframe = gui->veffect_vframe;
1251 mwindow->edl->session->time_format,
1252 mwindow->edl->session->sample_rate,
1253 mwindow->edl->session->frame_rate,
1254 mwindow->edl->session->frames_per_foot);
1256 icon = gui->label_icon;
1257 icon_vframe = gui->label_vframe;
1260 icon = gui->file_icon;
1261 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1264 set_icon_vframe(icon_vframe);
1267 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1268 : BC_Window(_(PROGRAM_NAME ": Resources"),
1269 mwindow->session->awindow_x, mwindow->session->awindow_y,
1270 mwindow->session->awindow_w, mwindow->session->awindow_h,
1271 xS(100), yS(100), 1, 1, 1)
1273 this->mwindow = mwindow;
1274 this->awindow = awindow;
1276 file_vframe = 0; file_icon = 0;
1277 folder_vframe = 0; folder_icon = 0;
1278 audio_vframe = 0; audio_icon = 0;
1279 video_vframe = 0; video_icon = 0;
1280 label_vframe = 0; label_icon = 0;
1282 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1283 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1284 clip_folder_vframe = 0; clip_folder_icon = 0;
1285 label_folder_vframe = 0; label_folder_icon = 0;
1286 media_folder_vframe = 0; media_folder_icon = 0;
1287 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1288 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1289 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1291 ladspa_vframe = 0; ladspa_icon = 0;
1292 ff_aud_vframe = 0; ff_aud_icon = 0;
1293 ff_vid_vframe = 0; ff_vid_icon = 0;
1295 clip_vframe = 0; clip_icon = 0;
1296 atransition_vframe = 0; atransition_icon = 0;
1297 vtransition_vframe = 0; vtransition_icon = 0;
1298 aeffect_vframe = 0; aeffect_icon = 0;
1299 veffect_vframe = 0; veffect_icon = 0;
1301 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1303 effectlist_menu = 0;
1308 folderlist_menu = 0;
1311 allow_iconlisting = 1;
1315 vicon_drawing = AVICON_FULL_PLAY;
1318 displayed_folder = AW_NO_FOLDER;
1319 new_folder_thread = 0;
1320 modify_folder_thread = 0;
1321 folder_lock = new Mutex("AWindowGUI::folder_lock");
1324 AWindowGUI::~AWindowGUI()
1326 assets.remove_all_objects();
1327 folders.remove_all_objects();
1328 aeffects.remove_all_objects();
1329 veffects.remove_all_objects();
1330 atransitions.remove_all_objects();
1331 vtransitions.remove_all_objects();
1332 labellist.remove_all_objects();
1333 displayed_assets[1].remove_all_objects();
1335 delete new_folder_thread;
1336 delete modify_folder_thread;
1337 delete vicon_thread;
1342 delete remove_plugin;
1344 delete file_vframe; delete file_icon;
1345 delete folder_vframe; delete folder_icon;
1346 delete audio_vframe; delete audio_icon;
1347 delete video_vframe; delete video_icon;
1348 delete label_vframe; delete label_icon;
1349 delete clip_vframe; delete clip_icon;
1350 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1351 delete atransition_folder_vframe; delete atransition_folder_icon;
1352 delete veffect_folder_vframe; delete veffect_folder_icon;
1353 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1354 delete clip_folder_vframe; delete clip_folder_icon;
1355 delete label_folder_vframe; delete label_folder_icon;
1356 delete media_folder_vframe; delete media_folder_icon;
1357 delete proxy_folder_vframe; delete proxy_folder_icon;
1358 delete ladspa_vframe; delete ladspa_icon;
1359 delete ff_aud_vframe; delete ff_aud_icon;
1360 delete ff_vid_vframe; delete ff_vid_icon;
1361 delete atransition_vframe; delete atransition_icon;
1362 delete vtransition_vframe; delete vtransition_icon;
1363 delete aeffect_vframe; delete aeffect_icon;
1364 delete veffect_vframe; delete veffect_icon;
1368 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1370 return icon == file_icon ||
1371 icon == folder_icon ||
1372 icon == audio_icon ||
1373 icon == video_icon ||
1374 icon == clip_icon ||
1375 icon == label_icon ||
1376 icon == vtransition_icon ||
1377 icon == atransition_icon ||
1378 icon == veffect_icon ||
1379 icon == aeffect_icon ||
1380 icon == ladspa_icon ||
1381 icon == ff_aud_icon ||
1382 icon == ff_vid_icon ||
1383 icon == aeffect_folder_icon ||
1384 icon == veffect_folder_icon ||
1385 icon == atransition_folder_icon ||
1386 icon == vtransition_folder_icon ||
1387 icon == label_folder_icon ||
1388 icon == clip_folder_icon ||
1389 icon == media_folder_icon ||
1390 icon == proxy_folder_icon;
1393 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1395 char png_path[BCTEXTLEN];
1396 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1397 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1398 File::get_plugin_path(), plugin_icons, name);
1399 if( access(png_path, R_OK) ) return 0;
1400 return VFramePng::vframe_png(png_path,0,0);
1403 VFrame *AWindowGUI::get_picon(const char *name)
1405 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1407 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1408 snprintf(pp, ep-pp, "%s.png", name);
1409 unsigned char *data = mwindow->theme->get_image_data(png_name);
1410 if( data ) vframe = new VFramePng(data, 0.);
1415 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1417 vfrm = get_picon(fn);
1418 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1419 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1421 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1423 vfrm = get_picon(fn);
1424 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1425 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1427 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1429 vfrm = get_picon(fn);
1430 if( !vfrm ) vfrm = new VFramePng(png);
1431 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1434 void AWindowGUI::create_objects()
1436 int ys5 = yS(5), ys10 = yS(10);
1437 lock_window("AWindowGUI::create_objects");
1438 asset_titles[0] = C_("Title");
1439 asset_titles[1] = _("Comments");
1441 set_icon(mwindow->theme->get_image("awindow_icon"));
1443 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1444 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1445 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1446 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1447 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1449 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1450 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1451 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1452 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1453 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1454 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1455 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1456 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1458 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1459 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1460 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1461 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1462 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1463 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1464 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1465 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1467 theme_icon(clip_vframe, clip_icon, "clip_icon");
1468 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1469 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1470 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1471 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1473 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1474 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1475 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1476 folder_lock->lock("AWindowGUI::create_objects");
1477 // Mandatory folders
1478 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1479 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1480 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1481 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1482 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1483 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1484 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1485 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1487 create_label_folder();
1488 folder_lock->unlock();
1490 mwindow->theme->get_awindow_sizes(this);
1491 load_defaults(mwindow->defaults);
1492 new_folder_thread = new NewFolderThread(this);
1493 modify_folder_thread = new ModifyFolderThread(this);
1495 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1496 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1497 search_text = new AWindowSearchText(mwindow, this, x1, y1+ys5);
1498 search_text->create_objects();
1499 int dy = search_text->get_h() + ys10;
1501 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1503 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1504 asset_list->update_vicon_area();
1505 vicon_thread->start();
1506 vicon_audio = new AssetVIconAudio(this);
1508 add_subwindow(divider = new AWindowDivider(mwindow, this,
1509 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1510 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1512 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1514 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1515 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1516 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1517 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1518 for( int i=0; i<n; ++i ) {
1519 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1520 if( tw < nw ) tw = nw;
1522 int pw = BC_PopupMenu::calculate_w(xS(16), tw, 1);
1523 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1524 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1525 avicon_drawing->create_objects();
1526 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1527 add_tools->create_objects();
1528 fy += add_tools->get_h(); fh -= add_tools->get_h();
1529 add_subwindow(folder_list = new AWindowFolders(mwindow,
1530 this, fx, fy, fw, fh));
1532 folder_list->load_expanders();
1534 //int x = mwindow->theme->abuttons_x;
1535 //int y = mwindow->theme->abuttons_y;
1537 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1538 asset_menu->create_objects();
1539 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1540 clip_menu->create_objects();
1541 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1542 label_menu->create_objects();
1543 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1544 proxy_menu->create_objects();
1546 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1547 effectlist_menu->create_objects();
1548 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1549 assetlist_menu->create_objects();
1550 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1551 cliplist_menu->create_objects();
1552 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1553 labellist_menu->create_objects();
1554 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1555 proxylist_menu->create_objects();
1557 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1558 folderlist_menu->create_objects();
1560 create_custom_xatoms();
1564 int AWindowGUI::resize_event(int w, int h)
1566 mwindow->session->awindow_x = get_x();
1567 mwindow->session->awindow_y = get_y();
1568 mwindow->session->awindow_w = w;
1569 mwindow->session->awindow_h = h;
1571 mwindow->theme->get_awindow_sizes(this);
1572 mwindow->theme->draw_awindow_bg(this);
1573 reposition_objects();
1575 // int x = mwindow->theme->abuttons_x;
1576 // int y = mwindow->theme->abuttons_y;
1577 // new_bin->reposition_window(x, y);
1578 // x += new_bin->get_w();
1579 // delete_bin->reposition_window(x, y);
1580 // x += delete_bin->get_w();
1581 // rename_bin->reposition_window(x, y);
1582 // x += rename_bin->get_w();
1583 // delete_disk->reposition_window(x, y);
1584 // x += delete_disk->get_w();
1585 // delete_project->reposition_window(x, y);
1586 // x += delete_project->get_w();
1587 // info->reposition_window(x, y);
1588 // x += info->get_w();
1589 // redraw_index->reposition_window(x, y);
1590 // x += redraw_index->get_w();
1591 // paste->reposition_window(x, y);
1592 // x += paste->get_w();
1593 // append->reposition_window(x, y);
1594 // x += append->get_w();
1595 // view->reposition_window(x, y);
1597 BC_WindowBase::resize_event(w, h);
1598 asset_list->update_vicon_area();
1602 int AWindowGUI::translation_event()
1604 mwindow->session->awindow_x = get_x();
1605 mwindow->session->awindow_y = get_y();
1609 void AWindowGUI::reposition_objects()
1611 int ys5 = yS(5), ys10 = yS(10);
1612 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1613 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1614 search_text->reposition_window(x1, y1+ys5, w1);
1615 int dy = search_text->get_h() + ys10;
1617 asset_list->reposition_window(x1, y1, w1, h1);
1618 divider->reposition_window(
1619 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1620 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1621 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1622 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1623 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1624 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1625 fy += add_tools->get_h(); fh -= add_tools->get_h();
1626 folder_list->reposition_window(fx, fy, fw, fh);
1629 int AWindowGUI::save_defaults(BC_Hash *defaults)
1631 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1632 defaults->update("VICON_DRAWING", vicon_drawing);
1633 defaults->update("TIP_INFO", tip_info);
1637 int AWindowGUI::load_defaults(BC_Hash *defaults)
1639 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1640 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1641 tip_info = defaults->get("TIP_INFO", tip_info);
1645 int AWindowGUI::close_event()
1648 mwindow->session->show_awindow = 0;
1651 mwindow->gui->lock_window("AWindowGUI::close_event");
1652 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1653 mwindow->gui->unlock_window();
1655 lock_window("AWindowGUI::close_event");
1656 save_defaults(mwindow->defaults);
1657 mwindow->save_defaults();
1661 int AWindowGUI::start_vicon_drawing()
1663 if( play_off ) return stop_vicon_drawing();
1664 if( !vicon_thread->interrupted ) return 1;
1665 switch( vicon_drawing ) {
1666 case AVICON_FULL_PLAY: // all vicons, viewing, target
1668 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1669 if( vicon_thread->solo ) break;
1671 case AVICON_SRC_TARGET: // no vicons, no view, target
1672 case AVICON_NO_PLAY: // no vicons, no view, no target
1675 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1676 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1677 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1678 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1679 switch( mwindow->edl->session->assetlist_format ) {
1681 case ASSETS_ICONS_PACKED:
1682 case ASSETS_ICON_LIST:
1683 asset_list->update_vicon_area();
1684 vicon_thread->start_drawing();
1693 int AWindowGUI::stop_vicon_drawing(int wait)
1695 vicon_thread->stop_vicon_drawing(wait);
1700 VFrame *AssetPicon::get_vicon_frame()
1702 if( !vicon ) return 0;
1703 if( gui->vicon_thread->interrupted ) return 0;
1704 VFrame *frame = vicon->frame();
1705 if( !frame ) return 0;
1707 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1708 vicon_frame->transfer_from(frame);
1712 int AWindowGUI::cycle_assetlist_format()
1714 EDLSession *session = mwindow->edl->session;
1715 int format = ASSETS_TEXT;
1716 if( allow_iconlisting ) {
1717 switch( session->assetlist_format ) {
1719 format = ASSETS_ICONS;
1722 format = ASSETS_ICONS_PACKED;
1724 case ASSETS_ICONS_PACKED:
1725 format = ASSETS_ICON_LIST;
1727 case ASSETS_ICON_LIST:
1728 format = ASSETS_TEXT;
1732 stop_vicon_drawing();
1733 session->assetlist_format = format;
1734 asset_list->update_format(session->assetlist_format, 0);
1735 async_update_assets();
1736 start_vicon_drawing();
1740 void AWindowGUI::hide_tip_info()
1742 asset_list->hide_tooltip();
1746 AWindowRemovePluginGUI::
1747 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1748 int x, int y, PluginServer *plugin)
1749 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y,
1750 xS(500),yS(200), xS(50), yS(50),
1753 this->awindow = awindow;
1754 this->thread = thread;
1755 this->plugin = plugin;
1756 VFrame *vframe = plugin->get_picon();
1757 icon = vframe ? create_pixmap(vframe) : 0;
1758 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1761 AWindowRemovePluginGUI::
1762 ~AWindowRemovePluginGUI()
1764 if( !awindow->gui->protected_pixmap(icon) )
1766 plugin_list.remove_all();
1769 void AWindowRemovePluginGUI::create_objects()
1771 int xs10 = xS(10), xs20 = xS(20);
1772 int ys5 = yS(5), ys10 = yS(10);
1773 lock_window("AWindowRemovePluginGUI::create_objects");
1774 BC_Button *ok_button = new BC_OKButton(this);
1775 add_subwindow(ok_button);
1776 BC_Button *cancel_button = new BC_CancelButton(this);
1777 add_subwindow(cancel_button);
1778 int x = xs10, y = ys10;
1779 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1780 add_subwindow(title);
1781 y += title->get_h() + ys5;
1782 list = new BC_ListBox(x, y,
1783 get_w() - xs20, ok_button->get_y() - y - ys5, LISTBOX_TEXT, &plugin_list,
1784 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1785 add_subwindow(list);
1790 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1793 for( int i=0; i<folder.size(); ) {
1794 AssetPicon *picon = (AssetPicon *)folder[i];
1795 if( picon->plugin == plugin ) {
1796 folder.remove_object_number(i);
1805 void AWindowRemovePlugin::handle_close_event(int result)
1808 printf(_("remove %s\n"), plugin->path);
1809 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1810 ArrayList<BC_ListBoxItem*> *folder =
1811 plugin->audio ? plugin->transition ?
1812 &awindow->gui->atransitions :
1813 &awindow->gui->aeffects :
1814 plugin->video ? plugin->transition ?
1815 &awindow->gui->vtransitions :
1816 &awindow->gui->veffects :
1818 if( folder ) remove_plugin(plugin, *folder);
1819 MWindow *mwindow = awindow->mwindow;
1820 awindow->gui->unlock_window();
1821 char plugin_path[BCTEXTLEN];
1822 strcpy(plugin_path, plugin->path);
1823 mwindow->plugindb->remove(plugin);
1824 remove(plugin_path);
1825 char index_path[BCTEXTLEN];
1826 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1828 char picon_path[BCTEXTLEN];
1830 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1831 File::get_plugin_path());
1832 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1833 plugin->get_plugin_png_name(png_name);
1834 fs.update(picon_path);
1835 for( int i=0; i<fs.dir_list.total; ++i ) {
1836 char *fs_path = fs.dir_list[i]->path;
1837 if( !fs.is_dir(fs_path) ) continue;
1838 snprintf(png_path, sizeof(picon_path), "%s/%s",
1842 delete plugin; plugin = 0;
1843 awindow->gui->async_update_assets();
1847 AWindowRemovePlugin::
1848 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1851 this->awindow = awindow;
1852 this->plugin = plugin;
1855 AWindowRemovePlugin::
1856 ~AWindowRemovePlugin()
1861 BC_Window* AWindowRemovePlugin::new_gui()
1863 int x = awindow->gui->get_abs_cursor_x(0);
1864 int y = awindow->gui->get_abs_cursor_y(0);
1865 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1866 gui->create_objects();
1870 int AWindowGUI::keypress_event()
1872 switch( get_keypress() ) {
1880 tip_info = !tip_info ? 1 : 0;
1881 if( !tip_info ) hide_tip_info();
1884 if( !ctrl_down() && !shift_down() ) {
1885 assetlist_menu->load_file->handle_event();
1890 return cycle_assetlist_format();
1892 if( shift_down() && ctrl_down() ) {
1893 PluginServer* plugin = selected_plugin();
1894 if( !plugin ) break;
1895 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1897 remove_plugin->start();
1898 lock_window("AWindowGUI::keypress_event 1");
1902 if( shift_down() ) {
1903 mwindow->awindow->asset_remove->start();
1907 mwindow->remove_assets_from_project(1, 1, 1,
1908 mwindow->session->drag_assets,
1909 mwindow->session->drag_clips);
1910 lock_window("AWindowGUI::keypress_event 2");
1916 if( shift_down() && ctrl_down() ) {
1917 resend_event(mwindow->gui);
1927 int AWindowGUI::create_custom_xatoms()
1929 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1932 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1934 if( event->message_type == UpdateAssetsXAtom ) {
1941 void AWindowGUI::async_update_assets()
1944 event.message_type = UpdateAssetsXAtom;
1945 send_custom_xatom(&event);
1949 void AWindowGUI::update_folder_list()
1951 for( int i = 0; i < folders.total; i++ ) {
1952 AssetPicon *picon = (AssetPicon*)folders.values[i];
1956 // Search assets for folders
1957 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1958 BinFolder *bin_folder = mwindow->edl->folders[i];
1961 for( int j = 0; j < folders.total; j++ ) {
1962 AssetPicon *picon = (AssetPicon*)folders[j];
1963 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1971 const char *title = bin_folder->title;
1972 int folder = bin_folder->awindow_folder;
1973 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1974 picon->create_objects();
1975 folders.append(picon);
1979 // Delete unused non-persistent folders
1980 int do_autoplace = 0;
1981 for( int i=folders.total; --i>=0; ) {
1982 AssetPicon *picon = (AssetPicon*)folders.values[i];
1983 if( !picon->in_use && !picon->persistent ) {
1985 folders.remove_number(i);
1990 folder_list->set_autoplacement(&folders, 0, 1);
1993 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1994 int do_audio, int do_video, int is_realtime, int is_transition)
1996 ArrayList<PluginServer*> plugin_list;
1997 // Get pointers to plugindb entries
1998 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
2001 for( int i = 0; i < plugin_list.total; i++ ) {
2002 PluginServer *server = plugin_list.values[i];
2003 int visible = plugin_visibility & (1<<server->dir_idx);
2004 if( !visible ) continue;
2005 // Create new listitem
2006 AssetPicon *picon = new AssetPicon(mwindow, this, server);
2007 picon->create_objects();
2008 output->append(picon);
2012 void AWindowGUI::create_label_folder()
2015 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
2016 AssetPicon *picon = new AssetPicon(mwindow, this, current);
2017 picon->create_objects();
2018 labellist.append(picon);
2023 void AWindowGUI::update_asset_list()
2025 ArrayList<AssetPicon *> new_assets;
2026 for( int i = 0; i < assets.total; i++ ) {
2027 AssetPicon *picon = (AssetPicon*)assets.values[i];
2031 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2032 // Synchronize EDL clips
2033 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2036 // Look for clip in existing listitems
2037 for( int j = 0; j < assets.total && !exists; j++ ) {
2038 AssetPicon *picon = (AssetPicon*)assets.values[j];
2040 if( picon->id == mwindow->edl->clips[i]->id ) {
2041 picon->edl = mwindow->edl->clips[i];
2042 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2048 // Create new listitem
2050 AssetPicon *picon = new AssetPicon(mwindow,
2051 this, mwindow->edl->clips[i]);
2052 new_assets.append(picon);
2056 // Synchronize EDL assets
2057 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2060 // Look for asset in existing listitems
2061 for( int j = 0; j < assets.total && !exists; j++ ) {
2062 AssetPicon *picon = (AssetPicon*)assets.values[j];
2064 if( picon->id == current->id ) {
2065 picon->indexable = current;
2071 // Create new listitem
2073 AssetPicon *picon = new AssetPicon(mwindow,
2075 new_assets.append(picon);
2079 // Synchronize nested EDLs
2080 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2082 EDL *nested_edl = mwindow->edl->nested_edls[i];
2084 // Look for asset in existing listitems
2085 for( int j=0; j<assets.total && !exists; ++j ) {
2086 AssetPicon *picon = (AssetPicon*)assets.values[j];
2088 if( picon->id == nested_edl->id ) {
2089 picon->indexable = nested_edl;
2095 // Create new listitem
2097 AssetPicon *picon = new AssetPicon(mwindow,
2098 this, (Indexable*)nested_edl);
2099 new_assets.append(picon);
2102 mwindow->gui->unlock_window();
2104 for( int i=0; i<new_assets.size(); ++i ) {
2105 AssetPicon *picon = new_assets[i];
2106 picon->create_objects();
2107 if( picon->indexable )
2108 picon->foldernum = AW_MEDIA_FOLDER;
2109 else if( picon->edl )
2110 picon->foldernum = AW_CLIP_FOLDER;
2111 assets.append(picon);
2114 mwindow->gui->lock_window();
2115 mwindow->gui->default_message();
2116 mwindow->gui->unlock_window();
2118 for( int i = assets.size() - 1; i >= 0; i-- ) {
2119 AssetPicon *picon = (AssetPicon*)assets.get(i);
2120 if( !picon->in_use ) {
2122 assets.remove_number(i);
2125 if( picon->indexable && picon->indexable->is_asset ) {
2126 Asset *asset = (Asset *)picon->indexable;
2128 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2129 picon->comments_rate = asset->get_frame_rate();
2130 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2131 picon->comments_type = asset->format == FILE_FFMPEG ?
2132 asset->vcodec : File::formattostr(asset->format);
2137 void AWindowGUI::update_picon(Indexable *indexable)
2140 for( int i = 0; i < assets.total; i++ ) {
2141 AssetPicon *picon = (AssetPicon*)assets.values[i];
2142 if( picon->indexable == indexable ||
2143 picon->edl == (EDL *)indexable ) {
2144 char name[BCTEXTLEN];
2146 fs.extract_name(name, indexable->path);
2147 picon->set_text(name);
2148 vicon = picon->vicon;
2153 stop_vicon_drawing();
2154 vicon->clear_images();
2155 vicon->reset(indexable->get_frame_rate());
2156 start_vicon_drawing();
2160 void AWindowGUI::sort_assets()
2162 folder_lock->lock("AWindowGUI::sort_assets");
2163 switch( mwindow->edl->session->awindow_folder ) {
2164 case AW_AEFFECT_FOLDER:
2165 sort_picons(&aeffects);
2167 case AW_VEFFECT_FOLDER:
2168 sort_picons(&veffects);
2170 case AW_ATRANSITION_FOLDER:
2171 sort_picons(&atransitions);
2173 case AW_VTRANSITION_FOLDER:
2174 sort_picons(&vtransitions);
2176 case AW_LABEL_FOLDER:
2177 sort_picons(&labellist);
2180 sort_picons(&assets);
2184 asset_list->update_format(asset_list->get_format(), 0);
2185 folder_lock->unlock();
2189 void AWindowGUI::sort_folders()
2191 folder_lock->lock("AWindowGUI::update_assets");
2192 // folder_list->collapse_recursive(&folders, 0);
2193 folder_list->set_autoplacement(&folders, 0, 1);
2194 sort_picons(&folders);
2195 folder_list->update_format(folder_list->get_format(), 0);
2196 folder_lock->unlock();
2200 EDL *AWindowGUI::collect_proxy(Asset *proxy_asset)
2202 char path[BCTEXTLEN];
2203 int proxy_scale = mwindow->edl->session->proxy_scale;
2204 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2205 Indexable *unproxy_idxbl =
2206 proxy_asset->proxy_edl ?
2207 (Indexable *) mwindow->edl->get_nested_edl(path) :
2208 (Indexable *) mwindow->edl->assets->get_asset(path);
2209 if( !unproxy_idxbl || !unproxy_idxbl->get_video_layers() ) return 0;
2210 // make a clip from proxy video tracks and unproxy audio tracks
2211 EDL *proxy_edl = new EDL(mwindow->edl);
2212 proxy_edl->create_objects();
2213 proxy_edl->set_path(proxy_asset->path);
2214 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2215 strcpy(proxy_edl->local_session->clip_title, path);
2216 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2217 proxy_edl->session->video_tracks = proxy_asset->layers;
2218 proxy_edl->session->audio_tracks = unproxy_idxbl->get_audio_channels();
2219 proxy_edl->create_default_tracks();
2220 double length = proxy_asset->frame_rate > 0 ?
2221 ( proxy_asset->video_length >= 0 ?
2222 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2223 ( proxy_edl->session->si_useduration ?
2224 proxy_edl->session->si_duration :
2225 1.0 / proxy_asset->frame_rate ) ) :
2226 1.0 / proxy_edl->session->frame_rate;
2227 Track *current = proxy_edl->tracks->first;
2228 for( int vtrack=0; current; current=NEXT ) {
2229 if( current->data_type != TRACK_VIDEO ) continue;
2230 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2232 int64_t samples = unproxy_idxbl->get_audio_samples();
2233 int sample_rate = unproxy_idxbl->get_sample_rate();
2234 length = sample_rate > 0 ? (double)samples / sample_rate : 0;
2235 current = proxy_edl->tracks->first;
2236 for( int atrack=0; current; current=NEXT ) {
2237 if( current->data_type != TRACK_AUDIO ) continue;
2238 Asset *asset = unproxy_idxbl->is_asset ? (Asset *)unproxy_idxbl : 0;
2239 EDL *nested_edl = unproxy_idxbl->is_asset ? 0 : (EDL *)unproxy_idxbl;
2240 current->insert_asset(asset, nested_edl, length, 0, atrack++);
2242 proxy_edl->folder_no = AW_PROXY_FOLDER;
2247 void AWindowGUI::collect_assets(int proxy)
2249 mwindow->session->drag_assets->remove_all();
2250 mwindow->session->drag_clips->remove_all();
2251 int i = 0; AssetPicon *result;
2252 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2253 Indexable *indexable = result->indexable;
2254 if( proxy && indexable && indexable->is_asset &&
2255 indexable->folder_no == AW_PROXY_FOLDER ) {
2256 EDL *drag_edl = collect_proxy((Asset*)indexable);
2257 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2261 mwindow->session->drag_assets->append(indexable);
2265 mwindow->session->drag_clips->append(result->edl);
2271 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2273 // Remove current pointers
2274 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2275 dst[0].remove_all();
2276 dst[1].remove_all_objects();
2278 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2279 int folder = mwindow->edl->session->awindow_folder;
2280 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2281 mwindow->edl->get_folder(folder);
2283 // Create new pointers
2284 for( int i = 0; i < src->total; i++ ) {
2285 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2286 picon = (AssetPicon*)src->values[i];
2287 picon->sort_key = -1;
2288 if( !visible && bin_folder ) {
2289 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2290 picon->indexable ? picon->indexable :
2291 picon->edl ? picon->edl->get_proxy_asset() : 0;
2293 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2294 if( picon->sort_key < 0 ) continue;
2298 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2300 if( !visible && picon->edl && picon->edl->folder_no == folder )
2302 if( visible && sub_items ) {
2303 if( !sub_items->matches(picon->get_text()) )
2307 const char *text = search_text->get_text();
2308 if( text && text[0] )
2309 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2311 if( visible && picon->vicon && picon->vicon->hidden )
2312 picon->vicon->hidden = 0;
2314 BC_ListBoxItem *item2, *item1;
2315 dst[0].append(item1 = picon);
2317 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2320 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2321 else if( picon->comments_time ) {
2322 char date_time[BCSTRLEN];
2323 struct tm stm; localtime_r(&picon->comments_time, &stm);
2324 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2325 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2326 stm.tm_hour, stm.tm_min, stm.tm_sec,
2327 picon->comments_rate, picon->comments_ffmt,
2328 picon->comments_type);
2329 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2332 dst[1].append(item2 = new BC_ListBoxItem(""));
2333 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2334 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2339 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2341 int done = 0, changed = 0;
2344 for( int i=0; i<src->total-1; ++i ) {
2345 AssetPicon *item1 = (AssetPicon *)src->values[i];
2346 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2347 double v = item2->sort_key - item1->sort_key;
2348 if( v > 0 ) continue;
2350 const char *cp1 = item1->get_text();
2351 const char *bp1 = strrchr(cp1, '/');
2352 if( bp1 ) cp1 = bp1 + 1;
2353 const char *cp2 = item2->get_text();
2354 const char *bp2 = strrchr(cp2, '/');
2355 if( bp2 ) cp2 = bp2 + 1;
2356 if( strcmp(cp2, cp1) >= 0 ) continue;
2358 src->values[i + 1] = item1;
2359 src->values[i] = item2;
2360 done = 0; changed = 1;
2364 for( int i=0; i<src->total; ++i ) {
2365 AssetPicon *item = (AssetPicon *)src->values[i];
2366 item->set_autoplace_icon(1);
2367 item->set_autoplace_text(1);
2372 void AWindowGUI::filter_displayed_assets()
2374 //allow_iconlisting = 1;
2375 asset_titles[0] = C_("Title");
2376 asset_titles[1] = _("Comments");
2377 AssetPicon *picon = 0;
2378 int selected_folder = mwindow->edl->session->awindow_folder;
2379 // Ensure the current folder icon is highlighted
2380 for( int i = 0; i < folders.total; i++ ) {
2381 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2382 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2383 folder_item->set_selected(selected);
2384 if( selected ) picon = folder_item;
2387 ArrayList<BC_ListBoxItem*> *src = &assets;
2388 switch( selected_folder ) {
2389 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2390 case AW_VEFFECT_FOLDER: src = &veffects; break;
2391 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2392 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2393 case AW_LABEL_FOLDER: src = &labellist;
2394 asset_titles[0] = _("Time Stamps");
2395 asset_titles[1] = C_("Title");
2396 //allow_iconlisting = 0;
2399 copy_picons(picon, src);
2403 void AWindowGUI::update_assets()
2405 stop_vicon_drawing();
2406 folder_lock->lock("AWindowGUI::update_assets");
2407 update_folder_list();
2408 update_asset_list();
2409 labellist.remove_all_objects();
2410 create_label_folder();
2412 if( displayed_folder != mwindow->edl->session->awindow_folder )
2413 search_text->clear();
2414 vicon_thread->hide_vicons();
2415 filter_displayed_assets();
2416 folder_lock->unlock();
2418 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2419 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2421 int folder_xposition = folder_list->get_xposition();
2422 int folder_yposition = folder_list->get_yposition();
2423 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2425 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2426 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2428 int asset_xposition = asset_list->get_xposition();
2429 int asset_yposition = asset_list->get_yposition();
2430 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2431 displayed_folder = mwindow->edl->session->awindow_folder;
2432 asset_xposition = asset_yposition = 0;
2434 asset_list->update(displayed_assets, asset_titles,
2435 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2436 asset_xposition, asset_yposition, -1, 0);
2437 asset_list->center_selection();
2440 start_vicon_drawing();
2444 void AWindowGUI::update_effects()
2446 aeffects.remove_all_objects();
2447 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2448 veffects.remove_all_objects();
2449 create_persistent_folder(&veffects, 0, 1, 1, 0);
2450 atransitions.remove_all_objects();
2451 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2452 vtransitions.remove_all_objects();
2453 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2456 int AWindowGUI::drag_motion()
2458 if( get_hidden() ) return 0;
2464 int AWindowGUI::drag_stop()
2466 if( get_hidden() ) return 0;
2470 Indexable* AWindowGUI::selected_asset()
2472 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2473 return picon ? picon->indexable : 0;
2476 PluginServer* AWindowGUI::selected_plugin()
2478 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2479 return picon ? picon->plugin : 0;
2482 AssetPicon* AWindowGUI::selected_folder()
2484 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2495 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2496 : BC_SubWindow(x, y, w, h)
2498 this->mwindow = mwindow;
2501 AWindowDivider::~AWindowDivider()
2505 int AWindowDivider::button_press_event()
2507 if( is_event_win() && cursor_inside() ) {
2508 mwindow->session->current_operation = DRAG_PARTITION;
2514 int AWindowDivider::cursor_motion_event()
2516 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2518 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2519 int fw = gui->get_relative_cursor_x();
2520 if( fw > wmax ) fw = wmax;
2521 if( fw < wmin ) fw = wmin;
2522 mwindow->session->afolders_w = fw;
2523 mwindow->theme->get_awindow_sizes(gui);
2524 gui->reposition_objects();
2530 int AWindowDivider::button_release_event()
2532 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2533 mwindow->session->current_operation = NO_OPERATION;
2544 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2545 : BC_ListBox(x, y, w, h,
2546 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2547 LISTBOX_ICONS : LISTBOX_TEXT,
2548 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2549 0, // Titles for columns. Set to 0 for no titles
2550 0, // width of each column
2551 1, // Total columns.
2552 0, // Pixel of top of window.
2553 0, // If this listbox is a popup window
2554 LISTBOX_SINGLE, // Select one item or multiple items
2555 ICON_TOP, // Position of icon relative to text of each item
2558 this->mwindow = mwindow;
2565 AWindowFolders::~AWindowFolders()
2569 int AWindowFolders::selection_changed()
2571 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2572 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2573 // prefer expanded entry
2574 AWindowFolderItem *item = item1 ? item1 : item0;
2575 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2576 item1->set_selected(0);
2583 AssetPicon *picon = item->get_picon();
2584 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2586 gui->stop_vicon_drawing();
2588 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2589 gui->folderlist_menu->update_titles();
2590 gui->folderlist_menu->activate_menu();
2593 mwindow->edl->session->awindow_folder = picon->foldernum;
2594 gui->asset_list->draw_background();
2595 gui->async_update_assets();
2597 gui->start_vicon_drawing();
2602 int AWindowFolders::button_press_event()
2604 gui->hide_tip_info();
2605 int result = BC_ListBox::button_press_event();
2608 if( get_buttonpress() == RIGHT_BUTTON &&
2609 is_event_win() && cursor_inside() ) {
2610 gui->folderlist_menu->update_titles();
2611 gui->folderlist_menu->activate_menu();
2619 int AWindowFolders::drag_stop()
2622 if( get_hidden() ) return 0;
2623 if( mwindow->session->current_operation == DRAG_ASSET &&
2624 gui->folder_list->cursor_above() ) { // check user folder
2625 int item_no = gui->folder_list->get_cursor_data_item_no();
2626 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2627 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2628 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2629 ArrayList<Indexable *> *drags = folder->is_clips ?
2630 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2631 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2632 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2634 mwindow->session->current_operation = ::NO_OPERATION;
2641 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2642 : AWindowFolderItem(text)
2644 this->parent = parent;
2647 int AWindowFolders::load_expanders()
2649 char expanders_path[BCTEXTLEN];
2650 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2651 FILE *fp = fopen(expanders_path, "r");
2653 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2654 File::get_cindat_path(), EXPANDERS_FILE);
2655 char *cp = strrchr(expanders_path,'.');
2656 if( cp ) strcpy(cp+1, mwindow->cin_lang);
2657 fp = fopen(expanders_path, "r");
2660 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2661 File::get_cindat_path(), EXPANDERS_FILE);
2662 fp = fopen(expanders_path, "r");
2665 const char tab = '\t';
2666 char line[BCTEXTLEN]; line[0] = 0;
2667 AWindowFolderItem *item = 0, *parent;
2668 AWindowFolderSubItems *sub_items = 0;
2670 while( fgets(line,sizeof(line),fp) ) {
2671 if( line[0] == '#' ) continue;
2672 int i = strlen(line);
2673 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2674 if( i == 0 ) continue;
2676 for( char *cp=line; *cp==tab; ++cp ) ++i;
2678 int i = gui->folders.size();
2680 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2681 if( !strcmp(folder->get_text(),_(line)) ) break;
2683 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2688 if( i > k+1 ) continue;
2690 if( line[i] != '-' && sub_items ) {
2691 sub_items->names.append(cstrdup(_(&line[i])));
2699 item = item->parent;
2702 parent = item->parent;
2704 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2705 if( !sublist ) sublist = parent->new_sublist(1);
2706 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2707 sublist->append(item = sub_items);
2714 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2715 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2716 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2717 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2718 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2720 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2721 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2722 mwindow->edl->session->asset_columns, // width of each column
2723 1, // Total columns.
2724 0, // Pixel of top of window.
2725 0, // If this listbox is a popup window
2726 LISTBOX_MULTIPLE, // Select one item or multiple items
2727 ICON_TOP, // Position of icon relative to text of each item
2728 -1) // Allow drags, require shift for scrolling
2730 this->mwindow = mwindow;
2732 this->info_tip = -1;
2734 set_scroll_stretch(1, 1);
2737 AWindowAssets::~AWindowAssets()
2741 int AWindowAssets::button_press_event()
2744 AssetVIconThread *avt = gui->vicon_thread;
2745 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2746 int dir = 1, button = get_buttonpress();
2748 case WHEEL_DOWN: dir = -1; // fall thru
2750 int x = get_cursor_x(), y = get_cursor_y();
2751 if( avt->cursor_inside(x, y) && avt->view_win )
2752 avt->zoom_scale(dir);
2757 int result = BC_ListBox::button_press_event();
2759 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2760 is_event_win() && cursor_inside() ) {
2761 BC_ListBox::deactivate_selection();
2762 int folder = mwindow->edl->session->awindow_folder;
2764 case AW_AEFFECT_FOLDER:
2765 case AW_VEFFECT_FOLDER:
2766 case AW_ATRANSITION_FOLDER:
2767 case AW_VTRANSITION_FOLDER:
2768 gui->effectlist_menu->update();
2769 gui->effectlist_menu->activate_menu();
2771 case AW_LABEL_FOLDER:
2772 gui->labellist_menu->update();
2773 gui->labellist_menu->activate_menu();
2775 case AW_CLIP_FOLDER:
2776 gui->cliplist_menu->update();
2777 gui->cliplist_menu->activate_menu();
2779 case AW_PROXY_FOLDER:
2780 gui->proxylist_menu->update();
2781 gui->proxylist_menu->activate_menu();
2784 case AW_MEDIA_FOLDER: {
2785 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2786 gui->assetlist_menu->update_titles(shots);
2787 gui->assetlist_menu->activate_menu();
2797 int AWindowAssets::handle_event()
2799 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2800 if( !asset_picon ) return 0;
2801 Indexable *picon_idxbl = asset_picon->indexable;
2802 EDL *picon_edl = asset_picon->edl;
2804 VWindow *vwindow = 0;
2805 switch( mwindow->edl->session->awindow_folder ) {
2806 case AW_AEFFECT_FOLDER:
2807 case AW_VEFFECT_FOLDER:
2808 case AW_ATRANSITION_FOLDER:
2809 case AW_VTRANSITION_FOLDER: return 1;
2810 case AW_PROXY_FOLDER:
2811 proxy = 1; // fall thru
2813 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2814 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2817 if( !vwindow || !vwindow->is_running() ) return 1;
2818 if( proxy && picon_idxbl && picon_idxbl->is_asset ) {
2819 picon_edl = gui->collect_proxy((Asset*)picon_idxbl);
2823 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2824 else if( picon_edl ) vwindow->change_source(picon_edl);
2828 int AWindowAssets::selection_changed()
2830 // Show popup window
2832 int folder = mwindow->edl->session->awindow_folder;
2833 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2834 (item = (AssetPicon*)get_selection(0, 0)) ) {
2836 case AW_AEFFECT_FOLDER:
2837 case AW_VEFFECT_FOLDER:
2838 case AW_ATRANSITION_FOLDER:
2839 case AW_VTRANSITION_FOLDER:
2840 gui->effectlist_menu->update();
2841 gui->effectlist_menu->activate_menu();
2843 case AW_LABEL_FOLDER:
2844 if( !item->label ) break;
2845 gui->label_menu->activate_menu();
2847 case AW_CLIP_FOLDER:
2848 if( !item->indexable && !item->edl ) break;
2849 gui->clip_menu->update();
2850 gui->clip_menu->activate_menu();
2852 case AW_PROXY_FOLDER:
2853 if( !item->indexable && !item->edl ) break;
2854 gui->proxy_menu->update();
2855 gui->proxy_menu->activate_menu();
2858 if( !item->indexable && !item->edl ) break;
2859 gui->asset_menu->update();
2860 gui->asset_menu->activate_menu();
2864 deactivate_selection();
2866 else if( get_button_down() && !gui->play_off &&
2867 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2868 item = (AssetPicon*)get_selection(0, 0);
2869 if( item && !get_selection(0, 1) ) {
2871 case AW_MEDIA_FOLDER:
2872 case AW_PROXY_FOLDER:
2873 case AWINDOW_USER_FOLDERS:
2874 if( get_buttonpress() == LEFT_BUTTON ||
2875 get_buttonpress() == MIDDLE_BUTTON ) {
2876 AssetVIcon *vicon = 0;
2877 AssetVIconThread *avt = gui->vicon_thread;
2878 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2879 vicon = item->vicon;
2880 int draw_mode = !vicon ?
2882 get_buttonpress() == MIDDLE_BUTTON ?
2883 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2884 avt->set_view_popup(vicon, draw_mode);
2887 case AW_CLIP_FOLDER:
2888 if( get_buttonpress() == LEFT_BUTTON ) {
2889 AssetVIcon *vicon = 0;
2890 AssetVIconThread *avt = gui->vicon_thread;
2891 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2892 vicon = item->vicon;
2893 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2899 gui->vicon_thread->set_view_popup(0);
2900 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2901 gui->stop_vicon_drawing();
2907 void AWindowAssets::draw_background()
2909 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2910 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2911 set_font(LARGEFONT);
2912 int folder = mwindow->edl->session->awindow_folder;
2913 const char *title = mwindow->edl->get_folder_name(folder);
2914 draw_text(get_w() - get_text_width(LARGEFONT, title) - xS(4), yS(30),
2915 title, -1, get_bg_surface());
2918 int AWindowAssets::drag_start_event()
2920 gui->vicon_thread->set_view_popup(0);
2921 int collect_pluginservers = 0;
2922 int collect_assets = 0, proxy = 0;
2924 if( BC_ListBox::drag_start_event() ) {
2925 switch( mwindow->edl->session->awindow_folder ) {
2926 case AW_AEFFECT_FOLDER:
2927 mwindow->session->current_operation = DRAG_AEFFECT;
2928 collect_pluginservers = 1;
2930 case AW_VEFFECT_FOLDER:
2931 mwindow->session->current_operation = DRAG_VEFFECT;
2932 collect_pluginservers = 1;
2934 case AW_ATRANSITION_FOLDER:
2935 mwindow->session->current_operation = DRAG_ATRANSITION;
2936 collect_pluginservers = 1;
2938 case AW_VTRANSITION_FOLDER:
2939 mwindow->session->current_operation = DRAG_VTRANSITION;
2940 collect_pluginservers = 1;
2942 case AW_LABEL_FOLDER:
2945 case AW_PROXY_FOLDER:
2946 proxy = 1; // fall thru
2947 case AW_MEDIA_FOLDER:
2949 mwindow->session->current_operation = DRAG_ASSET;
2954 if( collect_pluginservers ) {
2956 mwindow->session->drag_pluginservers->remove_all();
2959 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2960 if( !result ) break;
2962 mwindow->session->drag_pluginservers->append(result->plugin);
2966 if( collect_assets ) {
2967 gui->collect_assets(proxy);
2975 int AWindowAssets::drag_motion_event()
2977 BC_ListBox::drag_motion_event();
2980 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2981 mwindow->gui->drag_motion();
2982 mwindow->gui->unlock_window();
2984 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2985 VWindow *vwindow = mwindow->vwindows.get(i);
2986 if( !vwindow->is_running() ) continue;
2987 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2988 vwindow->gui->drag_motion();
2989 vwindow->gui->unlock_window();
2992 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2993 mwindow->cwindow->gui->drag_motion();
2994 mwindow->cwindow->gui->unlock_window();
2996 lock_window("AWindowAssets::drag_motion_event");
2997 if( mwindow->session->current_operation == DRAG_ASSET &&
2998 gui->folder_list->cursor_above() ) { // highlight user folder
2999 BC_ListBoxItem *item = 0;
3000 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
3001 if( item_no >= 0 ) {
3002 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
3003 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
3006 item_no = gui->folder_list->item_to_index(&gui->folders, item);
3007 int folder_xposition = gui->folder_list->get_xposition();
3008 int folder_yposition = gui->folder_list->get_yposition();
3009 gui->folder_list->update(&gui->folders, 0, 0, 1,
3010 folder_xposition, folder_yposition, item_no, 0, 1);
3015 int AWindowAssets::drag_stop_event()
3019 result = gui->drag_stop();
3024 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3025 result = mwindow->gui->drag_stop();
3026 mwindow->gui->unlock_window();
3030 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
3031 VWindow *vwindow = mwindow->vwindows.get(i);
3032 if( !vwindow ) continue;
3033 if( !vwindow->is_running() ) continue;
3034 if( vwindow->gui->is_hidden() ) continue;
3035 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3036 if( vwindow->gui->cursor_above() &&
3037 vwindow->gui->get_cursor_over_window() ) {
3038 result = vwindow->gui->drag_stop();
3040 vwindow->gui->unlock_window();
3045 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3046 result = mwindow->cwindow->gui->drag_stop();
3047 mwindow->cwindow->gui->unlock_window();
3050 lock_window("AWindowAssets::drag_stop_event");
3052 result = gui->folder_list->drag_stop();
3057 get_drag_popup()->set_animation(0);
3059 BC_ListBox::drag_stop_event();
3060 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3061 mwindow->session->current_operation = ::NO_OPERATION;
3066 int AWindowAssets::column_resize_event()
3068 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3069 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3073 int AWindowAssets::cursor_enter_event()
3075 int ret = BC_ListBox::cursor_enter_event();
3076 switch( gui->vicon_drawing ) {
3077 case AVICON_FULL_PLAY:
3078 gui->start_vicon_drawing();
3080 case AVICON_MOUSE_OVER:
3081 case AVICON_SRC_TARGET:
3082 case AVICON_NO_PLAY:
3089 int AWindowAssets::cursor_leave_event()
3092 if( !is_event_win() ) return 0;
3093 if( !gui->vicon_thread->viewing )
3094 gui->stop_vicon_drawing();
3095 return BC_ListBox::cursor_leave_event();
3098 int AWindowAssets::focus_out_event()
3100 gui->stop_vicon_drawing();
3101 gui->vicon_thread->set_view_popup(0);
3102 return BC_ListBox::focus_out_event();
3105 void AWindowAssets::update_vicon_area()
3107 int x0 = 0, x1 = get_w();
3108 int y0 = get_title_h();
3110 if( is_highlighted() ) {
3111 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3112 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3114 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3117 int AWindowAssets::mouse_over_event(int no)
3119 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3120 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3121 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3122 switch( gui->vicon_drawing ) {
3123 case AVICON_FULL_PLAY:
3124 gui->vicon_thread->solo = 0;
3125 if( vicon && gui->vicon_thread->viewing )
3126 gui->vicon_thread->set_view_popup(vicon);
3128 case AVICON_MOUSE_OVER:
3130 gui->vicon_thread->solo = vicon;
3131 gui->start_vicon_drawing();
3133 case AVICON_SRC_TARGET:
3135 if( gui->vicon_thread->viewing )
3136 gui->vicon_thread->set_view_popup(vicon);
3138 case AVICON_NO_PLAY:
3142 if( no < 0 && info_tip >= 0 ) {
3145 if( gui->tip_info && no >= 0 &&
3146 info_tip != no && picon && picon->plugin ) {
3147 const char *info = picon->plugin->tip;
3148 if( !info ) info = _("No info available");
3149 show_tip_info(info, no);
3154 void AWindowAssets::show_tip_info(const char *info, int no)
3156 int tw = get_text_width(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3157 int th = get_text_height(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3158 int tx = get_w() - (tw + xS(28));
3159 int ty = get_h() - (th + yS(28));
3160 show_tooltip(info, tx, ty, tw, th);
3164 void AWindowAssets::hide_tip_info()
3171 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3172 : BC_TextBox(x, y, w, 1, "")
3174 this->search_text = search_text;
3177 int AWindowSearchTextBox::handle_event()
3179 return search_text->handle_event();
3182 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3184 this->mwindow = mwindow;
3190 void AWindowSearchText::create_objects()
3194 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3195 x1 += text_title->get_w() + xs10;
3196 int w1 = gui->get_w() - x1 - 2*xs10;
3197 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3200 int AWindowSearchText::handle_event()
3202 gui->async_update_assets();
3206 int AWindowSearchText::get_w()
3208 return text_box->get_w() + text_title->get_w() + xS(10);
3211 int AWindowSearchText::get_h()
3213 return bmax(text_box->get_h(),text_title->get_h());
3216 void AWindowSearchText::reposition_window(int x, int y, int w)
3220 text_title->reposition_window(x1, y1);
3221 x1 += text_title->get_w() + xs10;
3222 int w1 = gui->get_w() - x1 - 2*xs10;
3223 text_box->reposition_window(x1, y1, w1);
3226 const char *AWindowSearchText::get_text()
3228 return text_box->get_text();
3231 void AWindowSearchText::clear()
3233 text_box->update("");
3236 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3237 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3239 this->mwindow = mwindow;
3241 set_tooltip(_("Delete asset from disk"));
3244 int AWindowDeleteDisk::handle_event()
3249 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3250 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3252 this->mwindow = mwindow;
3254 set_tooltip(_("Delete asset from project"));
3257 int AWindowDeleteProject::handle_event()
3262 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3263 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3265 // this->mwindow = mwindow;
3267 // set_tooltip(_("Edit information on asset"));
3270 // int AWindowInfo::handle_event()
3272 // int cur_x, cur_y;
3273 // gui->get_abs_cursor(cur_x, cur_y, 0);
3274 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3278 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3279 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3281 this->mwindow = mwindow;
3283 set_tooltip(_("Redraw index"));
3286 int AWindowRedrawIndex::handle_event()
3291 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3292 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3294 this->mwindow = mwindow;
3296 set_tooltip(_("Paste asset on recordable tracks"));
3299 int AWindowPaste::handle_event()
3304 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3305 : BC_Button(x, y, mwindow->theme->appendasset_data)
3307 this->mwindow = mwindow;
3309 set_tooltip(_("Append asset in new tracks"));
3312 int AWindowAppend::handle_event()
3317 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3318 : BC_Button(x, y, mwindow->theme->viewasset_data)
3320 this->mwindow = mwindow;
3322 set_tooltip(_("View asset"));
3325 int AWindowView::handle_event()
3330 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3331 : BC_PopupMenu(x, y, title, -1, 0)
3333 this->mwindow = mwindow;
3337 void AddTools::create_objects()
3340 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3341 vis |= 1 << PLUGIN_FFMPEG_ID;
3342 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3343 vis |= 1 << PLUGIN_LADSPA_ID;
3345 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3346 vis |= 1 << PLUGIN_LV2_ID;
3348 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3349 PluginServer *plugin = MWindow::plugindb->get(i);
3350 if( !plugin->audio && !plugin->video ) continue;
3351 int idx = plugin->dir_idx;
3352 uint32_t msk = 1 << idx;
3353 if( (msk & vis) != 0 ) continue;
3355 char parent[BCTEXTLEN];
3356 strcpy(parent, plugin->path);
3357 char *bp = strrchr(parent, '/');
3358 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3359 if( !bp ) bp = parent; else ++bp;
3360 add_item(new AddPluginItem(this, bp, idx));
3365 // plugin_dirs list from toplevel makefile include plugin_defs
3370 N_("audio_transitions")
3377 N_("video_transitions")
3380 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3381 : BC_MenuItem(_(text))
3385 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3386 int chk = (msk & vis) ? 1 : 0;
3390 int AddPluginItem::handle_event()
3392 int chk = get_checked() ^ 1;
3394 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3395 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3396 menu->gui->update_effects();
3397 menu->gui->save_defaults(menu->mwindow->defaults);
3398 menu->gui->async_update_assets();
3402 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3405 this->avicon = avicon;
3409 int AVIconDrawingItem::handle_event()
3411 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3412 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3413 item->set_checked(id == i);
3415 AWindowGUI *agui = avicon->agui;
3417 avicon->set_text(get_text());
3418 agui->stop_vicon_drawing();
3419 agui->vicon_thread->set_view_popup(0);
3420 agui->vicon_thread->solo = 0;
3421 agui->vicon_drawing = id;
3422 agui->start_vicon_drawing();
3426 int AVIconDrawing::draw_face(int dx, int color)
3428 int ret = BC_PopupMenu::draw_face(dx, color);
3429 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3430 int lx = get_margin(), ly = get_h()/2;
3431 draw_line(lx,ly, get_w()-2*lx,ly);
3436 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3437 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3442 AVIconDrawing::~AVIconDrawing()
3446 void AVIconDrawing::create_objects()
3448 AVIconDrawingItem *item;
3449 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3450 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3451 item->set_checked(agui->vicon_drawing == i);
3455 int AVIconDrawing::button_press_event()
3457 if( !is_event_win() ) return 0;
3458 if( get_buttonpress() == MIDDLE_BUTTON ) {
3459 agui->play_off = !agui->play_off ? 1 : 0;
3462 agui->start_vicon_drawing();
3465 return BC_PopupMenu::button_press_event();
3468 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3469 : BC_MenuItem("","v",'v')
3471 this->mwindow = mwindow;
3475 int AWindowListFormat::handle_event()
3477 return gui->cycle_assetlist_format();
3480 void AWindowListFormat::update()
3482 EDLSession *session = mwindow->edl->session;
3483 const char *text = 0;
3484 switch( session->assetlist_format ) {
3486 text = _("Display icons");
3489 text = _("Display icons packed");
3491 case ASSETS_ICONS_PACKED:
3492 text = _("Display icon list");
3494 case ASSETS_ICON_LIST:
3495 text = _("Display text");
3501 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3502 : BC_MenuItem(_("Sort items"))
3504 this->mwindow = mwindow;
3508 int AWindowListSort::handle_event()
3514 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3517 this->select_used = select_used;
3518 this->action = action;
3521 int AssetSelectUsedItem::handle_event()
3523 MWindow *mwindow = select_used->mwindow;
3524 AWindowGUI *gui = select_used->gui;
3525 AWindowAssets *asset_list = gui->asset_list;
3526 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3531 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3535 asset_list->set_all_selected(data, 0);
3536 for( int i = 0; i < data->total; i++ ) {
3537 AssetPicon *picon = (AssetPicon*)data->values[i];
3538 Indexable *idxbl = picon->indexable ? picon->indexable :
3539 picon->edl ? picon->edl->get_proxy_asset() : 0;
3540 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3541 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3546 int asset_xposition = asset_list->get_xposition();
3547 int asset_yposition = asset_list->get_yposition();
3548 asset_list->update(gui->displayed_assets, gui->asset_titles,
3549 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3550 asset_xposition, asset_yposition, -1, 0);
3551 asset_list->center_selection();
3555 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3556 : BC_MenuItem(_("Select"))
3558 this->mwindow = mwindow;