4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "assetedit.h"
25 #include "assetpopup.h"
26 #include "assetremove.h"
28 #include "audiodevice.h"
30 #include "awindowgui.h"
31 #include "bccmodels.h"
32 #include "bcsignals.h"
34 #include "binfolder.h"
39 #include "clippopup.h"
41 #include "cwindowgui.h"
46 #include "edlsession.h"
47 #include "effectlist.h"
49 #include "filesystem.h"
50 #include "folderlistmenu.h"
51 #include "indexable.h"
55 #include "labelpopup.h"
56 #include "localsession.h"
57 #include "mainerror.h"
59 #include "mainsession.h"
60 #include "mwindowgui.h"
62 #include "preferences.h"
64 #include "proxypopup.h"
65 #include "renderengine.h"
70 #include "transportque.h"
74 #include "vwindowgui.h"
77 #include "data/lad_picon_png.h"
78 #include "data/ff_audio_png.h"
79 #include "data/ff_video_png.h"
86 const char *AWindowGUI::folder_names[] =
90 N_("Audio Transitions"),
91 N_("Video Transitions"),
98 const char *AVIconDrawing::avicon_names[] =
106 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
107 : VIcon(w, h, framerate), Garbage("AssetVIcon")
110 this->length = length;
115 AssetVIcon::~AssetVIcon()
117 picon->gui->vicon_thread->del_vicon(this);
121 VFrame *AssetVIcon::frame()
123 if( broken ) return 0;
124 AssetVIconThread *avt = picon->gui->vicon_thread;
125 Indexable *idxbl = picon->indexable;
126 Asset *asset = idxbl && idxbl->is_asset ? (Asset *)idxbl : 0;
127 if( !asset ) return vframes()>0 ? (VFrame*)*images[0] : 0;
128 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
129 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
131 int sample_rate = asset->get_sample_rate();
132 int64_t audio_samples = asset->get_audio_samples();
133 double duration = (double)audio_samples / sample_rate;
134 picon->draw_hue_bar(temp, duration);
135 int secs = length / frame_rate + 0.5;
136 if( !secs ) secs = 1;
137 int bfrsz = VICON_SAMPLE_RATE;
138 int samples = audio_size/sizeof(vicon_audio_t);
139 double line_pos = (double)seq_no/(length-1);
140 int audio_pos = samples * line_pos * (secs-1)/secs;
141 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
142 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
143 double data[bfrsz], sample_scale = 1./mx;
144 int len = samples - audio_pos;
145 if( len > bfrsz ) len = bfrsz;
147 while( i < len ) data[i++] = *audio_data++ * sample_scale;
148 while( i < bfrsz ) data[i++] = 0;
149 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
150 int x = (w-1) * line_pos;
151 temp->pixel_rgb = RED;
152 temp->draw_line(x,0, x,h);
155 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
156 if( !asset->video_data ) {
158 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
163 if( seq_no >= images.size() ) {
164 MWindow *mwindow = picon->mwindow;
165 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
170 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
171 delete temp; temp = 0;
174 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
175 while( seq_no >= images.size() ) {
176 mwindow->video_cache->check_in(asset);
178 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
179 if( !file ) { usleep(1000); continue; }
181 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
182 file->set_video_position(pos,0);
183 if( file->read_frame(temp) ) temp->clear_frame();
184 add_image(temp, vw, vh, vicon_cmodel);
186 mwindow->video_cache->check_in(asset);
188 return *images[seq_no];
191 int64_t AssetVIcon::set_seq_no(int64_t no)
193 if( no >= length ) no = 0;
197 int AssetVIcon::get_vx()
199 BC_ListBox *lbox = picon->gui->asset_list;
200 return lbox->get_icon_x(picon);
202 int AssetVIcon::get_vy()
204 BC_ListBox *lbox = picon->gui->asset_list;
205 return lbox->get_icon_y(picon);
208 void AssetVIcon::load_audio()
210 MWindow *mwindow = picon->mwindow;
211 Asset *asset = (Asset *)picon->indexable;
212 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
213 int channels = asset->get_audio_channels();
214 if( channels > 2 ) channels = 2;
215 int sample_rate = asset->get_sample_rate();
216 int bfrsz = sample_rate;
217 Samples samples(bfrsz);
218 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
219 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
220 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
221 double sample_scale = (double)mx / channels;
222 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
223 while( audio_pos < audio_len ) {
224 int64_t pos = audio_pos * time_scale;
225 for( int ch=0; ch<channels; ++ch ) {
226 file->set_channel(ch);
227 file->set_audio_position(pos);
228 file->read_samples(&samples, bfrsz);
229 double *data = samples.get_data();
230 for( int64_t k=audio_pos; k<audio_len; ++k ) {
231 int i = k * time_scale - pos;
232 if( i >= bfrsz ) break;
233 int v = audio_data[k] + data[i] * sample_scale;
234 audio_data[k] = CLIP(v, -mx,mx);
237 audio_pos = (pos + bfrsz) / time_scale;
239 mwindow->audio_cache->check_in(asset);
243 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
247 audio = new AudioDevice(gui->mwindow);
251 AssetVIconAudio::~AssetVIconAudio()
256 void AssetVIconAudio::run()
259 int64_t bfrsz = VICON_SAMPLE_RATE;
260 MWindow *mwindow = gui->mwindow;
261 EDL *edl = mwindow->edl;
262 EDLSession *session = edl->session;
263 AudioOutConfig *aconfig = session->playback_config->aconfig;
264 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
265 audio->start_playback();
266 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
267 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
268 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
270 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
271 while( !interrupted ) {
272 int len = audio_len - audio_pos;
273 if( len <= 0 ) break;
274 if( len > bfrsz ) len = bfrsz;
276 for( int i=0; i<len; ++i,++k )
277 out0[i] = out1[i] = (double)audio_data[k] / mx;
279 audio->write_buffer(out, channels, len);
283 audio->set_last_buffer();
284 audio->stop_audio(interrupted ? 0 : 1);
288 void AssetVIconAudio::start(AssetVIcon *vicon)
290 if( running() ) return;
292 double pos = vicon->length > 0 ? (double)vicon->seq_no/vicon->length : 0;
293 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
294 audio_pos = pos * audio_len;
299 void AssetVIconAudio::stop(int wait)
301 if( running() && !interrupted ) {
303 audio->stop_audio(wait);
307 vicon->playing_audio = 0;
312 void AssetVIcon::start_audio()
314 if( playing_audio < 0 ) return;
315 picon->gui->vicon_audio->stop(0);
317 picon->gui->vicon_audio->start(this);
320 void AssetVIcon::stop_audio()
322 if( playing_audio > 0 ) {
323 picon->gui->vicon_audio->stop(0);
328 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
329 int x, int y, int w, int h)
330 : ViewPopup(vt, x, y, w, h)
332 this->draw_mode = draw_mode;
333 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
337 AssetViewPopup::~AssetViewPopup()
341 int AssetViewPopup::reposition_window(int x, int y, int w, int h)
343 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
344 return ViewPopup::reposition_window(x, y, w, h);
347 int AssetViewPopup::button_press_event()
349 if( !is_event_win() ) return 0;
350 AssetVIconThread *avt = (AssetVIconThread *)vt;
351 if( !avt->vicon ) return 0;
354 switch( get_buttonpress() ) {
358 avt->set_view_popup(0);
361 dir = -1; // fall thru
363 switch( draw_mode ) {
364 case ASSET_VIEW_MEDIA:
365 case ASSET_VIEW_MEDIA_MAP:
366 avt->zoom_scale(dir);
373 int x = get_cursor_x(), y = get_cursor_y();
374 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
375 AssetPicon *picon = vicon->picon;
376 MWindow *mwindow = picon->mwindow;
377 EDL *edl = mwindow->edl;
379 if( y < get_h()/2 ) {
381 picon->indexable ? picon->indexable :
382 picon->edl ? picon->edl : 0;
383 if( !idxbl ) return 0;
384 double sample_rate = idxbl->get_sample_rate();
385 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
386 idxbl->get_audio_samples() / sample_rate : 0;
387 double frame_rate = idxbl->get_frame_rate();
388 double video_length = frame_rate > 0 && idxbl->have_video() ?
389 idxbl->get_video_frames() / frame_rate : 0;
390 double idxbl_length = bmax(audio_length, video_length);
391 double pos = x * idxbl_length / get_w();
392 double start = 0, end = idxbl_length;
393 double lt = DBL_MAX, rt = DBL_MAX;
394 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
395 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
396 Indexable *indexable = (Indexable *)edit->asset;
397 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
398 if( !indexable ) continue;
399 if( indexable->id == idxbl->id ||
400 (!indexable->is_asset == !idxbl->is_asset &&
401 !strcmp(indexable->path, idxbl->path)) ) {
402 double start_pos = track->from_units(edit->startsource);
403 double end_pos = track->from_units(edit->startsource + edit->length);
404 double dlt = pos - start_pos, drt = end_pos - pos;
405 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
406 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
407 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
408 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
412 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
413 VWindow *vwindow = mwindow->get_viewer(1, 0);
414 vwindow->change_source(idxbl);
415 mwindow->gui->unlock_window();
416 EDL *vedl = vwindow->get_edl();
417 vedl->set_inpoint(start);
418 vedl->set_outpoint(end);
419 vedl->local_session->set_selectionstart(start);
420 vedl->local_session->set_selectionend(start);
421 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
422 vwindow->update_position();
423 vwindow->gui->unlock_window();
428 if( !ctrl_down() && !shift_down() )
429 return cursor_motion_event();
431 picon->indexable ? picon->indexable :
432 picon->edl ? picon->edl : 0;
433 if( !idxbl ) return 0;
434 double total_length = mwindow->edl->tracks->total_length();
435 double pos = x * total_length / get_w();
436 double start = 0, end = total_length;
437 double lt = DBL_MAX, rt = DBL_MAX;
438 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
439 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
440 Indexable *indexable = (Indexable *)edit->asset;
441 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
442 if( !indexable ) continue;
443 if( indexable->id == idxbl->id ||
444 (!indexable->is_asset == !idxbl->is_asset &&
445 !strcmp(indexable->path, idxbl->path)) ) {
446 double start_pos = track->from_units(edit->startproject);
447 double end_pos = track->from_units(edit->startproject + edit->length);
448 double dlt = pos - start_pos, drt = end_pos - pos;
449 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
450 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
451 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
452 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
456 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
457 mwindow->select_point(start);
458 edl->local_session->set_selectionstart(start);
459 edl->local_session->set_selectionend(!shift_down() ? start : end);
460 mwindow->zoom_sample(edl->local_session->zoom_sample);
461 mwindow->gui->unlock_window();
467 int AssetViewPopup::button_release_event()
469 if( !is_event_win() ) return 0;
474 int AssetViewPopup::cursor_motion_event()
476 AssetVIconThread *avt = (AssetVIconThread *)vt;
477 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
478 if( vicon && dragging && is_event_win() &&
479 get_button_down() && get_buttonpress() == LEFT_BUTTON &&
480 !ctrl_down() && !alt_down() && !shift_down() ) {
481 switch( draw_mode ) {
482 case ASSET_VIEW_MEDIA_MAP:
483 case ASSET_VIEW_FULL:
484 MWindow *mwindow = vicon->picon->mwindow;
485 EDL *edl = mwindow->edl;
486 int x = get_cursor_x();
487 double total_length = edl->tracks->total_length();
488 double pos = x * total_length / get_w();
489 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
490 mwindow->select_point(pos);
491 mwindow->zoom_sample(edl->local_session->zoom_sample);
492 mwindow->gui->unlock_window();
499 void AssetViewPopup::draw_vframe(VFrame *vframe)
501 switch( draw_mode ) {
502 case ASSET_VIEW_MEDIA:
503 case ASSET_VIEW_ICON:
504 ViewPopup::draw_vframe(vframe);
505 case ASSET_VIEW_NONE:
508 case ASSET_VIEW_MEDIA_MAP:
509 case ASSET_VIEW_FULL:
513 draw_box(0,0,get_w(),get_h());
515 int y2 = get_h()-bar_h;
516 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
517 AssetVIconThread *avt = (AssetVIconThread *)vt;
518 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
519 AssetPicon *picon = (AssetPicon *)vicon->picon;
521 picon->indexable ? picon->indexable :
522 picon->edl ? picon->edl : 0;
524 double sample_rate = idxbl->get_sample_rate();
525 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
526 idxbl->get_audio_samples() / sample_rate : 0;
527 double frame_rate = idxbl->get_frame_rate();
528 double video_length = frame_rate > 0 && idxbl->have_video() ?
529 idxbl->get_video_frames() / frame_rate : 0;
530 double idxbl_length = bmax(audio_length, video_length);
531 if( !idxbl_length ) idxbl_length = 1;
533 EDL *edl = picon->mwindow->edl;
534 double total_length = edl->tracks->total_length();
535 if( !total_length ) total_length = 1;
536 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
537 if( !track->record ) continue;
538 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
539 Indexable *indexable = (Indexable *)edit->asset;
540 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
541 if( !indexable ) continue;
542 if( indexable->id == idxbl->id ||
543 (!indexable->is_asset == !idxbl->is_asset &&
544 !strcmp(indexable->path, idxbl->path)) ) {
545 double pos1 = track->from_units(edit->startsource);
546 double pos2 = track->from_units(edit->startsource + edit->length);
547 double xscale = get_w() / idxbl_length;
548 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
550 draw_box(ex1,0, ex2-ex1,y1);
552 draw_line(ex1,0, ex1,y1);
553 draw_line(ex2,0, ex2,y1);
554 pos1 = track->from_units(edit->startproject);
555 pos2 = track->from_units(edit->startproject + edit->length);
556 xscale = get_w() / total_length;
557 int px1 = pos1 * xscale, px2 = pos2 * xscale;
559 draw_box(px1,y2, px2-px1,get_h()-y2);
561 draw_line(px1,y2, px1,get_h()-1);
562 draw_line(px2,y2, px2,get_h()-1);
565 draw_line(ex1,y1, px1,y2);
566 draw_line(ex2,y1, px2,y2);
572 int AssetViewPopup::keypress_event()
575 AssetVIconThread *avt = (AssetVIconThread *)vt;
576 switch( avt->draw_mode ) {
577 case ASSET_VIEW_MEDIA_MAP:
578 switch( get_keypress() ) {
581 avt->draw_mode = ASSET_VIEW_FULL;
585 case ASSET_VIEW_FULL:
586 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
589 if( result ) // zero change for refresh
591 return ViewPopup::keypress_event();
595 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
596 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
597 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
600 draw_mode = ASSET_VIEW_NONE;
601 int vicon_cmodel = BC_RGB8;
602 switch( preferences->vicon_color_mode ) {
603 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
604 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
605 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
607 this->vicon_cmodel = vicon_cmodel;
608 this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
611 AssetVIconThread::~AssetVIconThread()
616 void AssetVIconThread::drawing_started()
618 draw_lock->lock("AssetVIconThread::drawing_started");
621 void AssetVIconThread::drawing_stopped()
626 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
628 gui->stop_vicon_drawing();
629 this->draw_mode = draw_mode;
631 gui->start_vicon_drawing();
634 void AssetVIconThread::set_view_popup(AssetVIcon *v)
636 if( !v ) draw_mode = ASSET_VIEW_NONE;
637 VIconThread::set_view_popup(v);
640 ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
642 BC_WindowBase *parent = wdw->get_parent();
643 int rx = 0, ry = 0, rw = 0, rh = 0;
644 if( draw_mode != ASSET_VIEW_FULL ) {
645 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
646 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
647 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
648 int vx = viewing->get_vx(), vy = viewing->get_vy();
649 wdw->get_root_coordinates(vx, vy, &rx, &ry);
650 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
651 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
652 rw = view_w; rh = view_h;
655 parent->get_fullscreen_geometry(rx, ry, rw, rh);
656 AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
658 av_popup->reposition_window(rx, ry, rw, rh);
660 av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
661 int playing_audio = gui->play_off ? -1 : 0;
662 if( !playing_audio ) {
663 switch( draw_mode ) {
664 case ASSET_VIEW_NONE:
665 case ASSET_VIEW_ICON:
666 case ASSET_VIEW_MEDIA_MAP:
667 case ASSET_VIEW_FULL:
670 case ASSET_VIEW_MEDIA:
671 switch( gui->vicon_drawing ) {
672 case AVICON_SRC_TARGET:
679 vicon->playing_audio = playing_audio;
680 wdw->set_active_subwindow(av_popup);
684 void AssetVIconThread::close_view_popup()
687 drawing_started(); // waits for draw lock
692 AWindowFolderItem::AWindowFolderItem()
698 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
699 : BC_ListBoxItem(text, color)
704 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
705 : BC_ListBoxItem(text, icon, color)
710 AssetPicon *AWindowFolderItem::get_picon()
712 AWindowFolderItem *item = this;
713 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
714 return (AssetPicon*)item;
717 int AWindowFolderSubItems::matches(const char *text)
719 int i = names.size();
720 while( --i >= 0 && strcmp(names[i], text) );
722 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
723 i = sublist ? sublist->size() : 0;
725 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
726 if( item->matches(text) ) break;
729 return i >= 0 ? 1 : 0;
733 AssetPicon::AssetPicon(MWindow *mwindow,
734 AWindowGUI *gui, Indexable *indexable)
735 : AWindowFolderItem()
738 this->mwindow = mwindow;
740 this->indexable = indexable;
741 indexable->add_user();
742 this->id = indexable->id;
745 AssetPicon::AssetPicon(MWindow *mwindow,
746 AWindowGUI *gui, EDL *edl)
747 : AWindowFolderItem()
750 this->mwindow = mwindow;
757 AssetPicon::AssetPicon(MWindow *mwindow,
758 AWindowGUI *gui, int folder, int persist)
759 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
760 folder>=0 && folder<AWINDOW_FOLDERS ?
761 gui->folder_icons[folder] : gui->folder_icon)
765 this->mwindow = mwindow;
767 persistent = persist;
770 AssetPicon::AssetPicon(MWindow *mwindow,
771 AWindowGUI *gui, int folder, const char *title)
772 : AWindowFolderItem(title, gui->folder_icon)
776 this->mwindow = mwindow;
781 AssetPicon::AssetPicon(MWindow *mwindow,
782 AWindowGUI *gui, PluginServer *plugin)
783 : AWindowFolderItem()
786 this->mwindow = mwindow;
788 this->plugin = plugin;
791 AssetPicon::AssetPicon(MWindow *mwindow,
792 AWindowGUI *gui, Label *label)
793 : AWindowFolderItem()
796 this->mwindow = mwindow;
804 AssetPicon::~AssetPicon()
806 if( vicon ) vicon->remove_user();
808 if( indexable ) indexable->remove_user();
809 if( edl ) edl->remove_user();
810 if( icon && !gui->protected_pixmap(icon) ) {
812 if( !plugin ) delete icon_vframe;
816 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
818 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
820 float h = 300 * t, s = 1., v = 1.;
821 float r, g, b; // duration, 0..1hr == hue red..magenta
822 HSV::hsv_to_rgb(r,g,b, h,s,v);
823 int ih = frame->get_h()/8, iw = frame->get_w();
824 int ir = r * 256; CLAMP(ir, 0,255);
825 int ig = g * 256; CLAMP(ig, 0,255);
826 int ib = b * 256; CLAMP(ib, 0,255);
827 unsigned char **rows = frame->get_rows();
828 for( int y=0; y<ih; ++y ) {
829 unsigned char *rp = rows[y];
830 for( int x=0; x<iw; rp+=3,++x ) {
831 rp[0] = ir; rp[1] = ig; rp[2] = ib;
836 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
837 int base_color, int line_color, int x, int y, int w, int h)
839 int h1 = h-1, h2 = h/2, iy = h2;
840 int rgb_color = frame->pixel_rgb;
841 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
842 double min = *dp, max = min;
843 x2 = (len * (ix+1))/w;
844 for( int i=x1; i<x2; ++i ) {
845 double value = *dp++;
846 if( value < min ) min = value;
847 if( value > max ) max = value;
849 int ctr = (min + max) / 2;
850 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
851 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
852 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
853 frame->pixel_rgb = line_color;
854 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
855 frame->pixel_rgb = base_color;
856 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
859 frame->pixel_rgb = rgb_color;
862 void AssetPicon::reset()
870 foldernum = AW_NO_FOLDER;
885 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
887 TransportCommand command;
888 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
889 command.get_edl()->copy_all(edl);
890 command.change_type = CHANGE_ALL;
891 command.realtime = 0;
892 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
893 render_engine->set_vcache(mwindow->video_cache);
894 render_engine->set_acache(mwindow->audio_cache);
895 render_engine->arm_command(&command);
897 void AssetPicon::close_render_engine()
899 delete render_engine; render_engine = 0;
901 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
903 if( !render_engine || !render_engine->vrender ) return;
904 render_engine->vrender->process_buffer(vfrm, pos, 0);
906 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
908 if( !render_engine || !render_engine->arender ) return;
909 render_engine->arender->process_buffer(samples, len, pos);
912 void AssetPicon::create_objects()
915 char name[BCTEXTLEN];
916 int pixmap_w, pixmap_h;
918 int picon_h = mwindow->preferences->awindow_picon_h;
919 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
925 if( this->indexable ) {
927 if( this->indexable->is_asset ) {
928 asset = (Asset *)indexable;
929 if( asset->format == FILE_REF ) {
930 cp += sprintf(cp, "ref:");
931 set_color(get_color() ^ 0x5599CC);
935 edl = (EDL *)indexable;
936 cp += sprintf(cp, "edl:");
937 // set_color(get_color() ^ 0xCC9955);
939 fs.extract_name(cp, indexable->path);
942 else if( this->edl ) {
944 strcpy(name, edl->local_session->clip_title);
950 if( asset->video_data ) {
951 if( mwindow->preferences->use_thumbnails ) {
952 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 { char string[BCTEXTLEN];
977 sprintf(string, _("Reading %s"), name);
978 mwindow->gui->lock_window("AssetPicon::create_objects");
979 mwindow->gui->show_message(string);
980 mwindow->gui->unlock_window(); }
981 file->read_frame(gui->temp_picon);
982 mwindow->video_cache->check_in(asset);
984 gui->lock_window("AssetPicon::create_objects 0");
985 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
986 icon->draw_vframe(gui->temp_picon,
987 0, 0, pixmap_w, pixmap_h, 0, 0);
988 icon_vframe = new VFrame(0,
989 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
990 icon_vframe->transfer_from(gui->temp_picon);
991 if( asset->folder_no == AW_MEDIA_FOLDER ||
992 asset->folder_no == AW_PROXY_FOLDER ) {
994 double framerate = asset->get_frame_rate();
995 if( !framerate ) framerate = VICON_RATE;
996 int64_t frames = asset->get_video_frames();
997 double secs = frames / framerate;
998 if( secs > 5 ) secs = 5;
999 int64_t length = secs * gui->vicon_thread->refresh_rate;
1000 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
1001 if( asset->audio_data && secs > 0 ) {
1002 gui->unlock_window();
1003 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1004 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1005 vicon->load_audio();
1006 gui->lock_window("AssetPicon::create_objects 1");
1008 gui->vicon_thread->add_vicon(vicon);
1012 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1013 gui->lock_window("AssetPicon::create_objects 2");
1014 icon = gui->video_icon;
1015 icon_vframe = gui->video_vframe;
1019 icon = gui->video_icon;
1020 icon_vframe = gui->video_vframe;
1024 if( asset->audio_data ) {
1025 if( mwindow->preferences->use_thumbnails ) {
1026 gui->unlock_window();
1027 File *file = mwindow->audio_cache->check_out(asset,
1031 pixmap_w = pixmap_h * 16/9;
1032 icon_vframe = new VFrame(0,
1033 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1034 icon_vframe->clear_frame();
1035 { char string[BCTEXTLEN];
1036 sprintf(string, _("Reading %s"), name);
1037 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1038 mwindow->gui->show_message(string);
1039 mwindow->gui->unlock_window(); }
1040 int sample_rate = asset->get_sample_rate();
1041 int channels = asset->get_audio_channels();
1042 if( channels > 2 ) channels = 2;
1043 int64_t audio_samples = asset->get_audio_samples();
1044 double duration = (double)audio_samples / sample_rate;
1045 draw_hue_bar(icon_vframe, duration);
1046 int bfrsz = sample_rate;
1047 Samples samples(bfrsz);
1048 static int line_colors[2] = { GREEN, YELLOW };
1049 static int base_colors[2] = { RED, PINK };
1050 for( int i=channels; --i>=0; ) {
1051 file->set_channel(i);
1052 file->set_audio_position(0);
1053 file->read_samples(&samples, bfrsz);
1054 draw_wave(icon_vframe, samples.get_data(), bfrsz,
1055 base_colors[i], line_colors[i]);
1057 mwindow->audio_cache->check_in(asset);
1058 if( asset->folder_no == AW_MEDIA_FOLDER ) {
1059 double secs = duration;
1060 if( secs > 5 ) secs = 5;
1061 double refresh_rate = gui->vicon_thread->refresh_rate;
1062 int64_t length = secs * refresh_rate;
1063 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1064 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1065 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1066 vicon->load_audio();
1067 gui->vicon_thread->add_vicon(vicon);
1069 gui->lock_window("AssetPicon::create_objects 4");
1070 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1071 icon->draw_vframe(icon_vframe,
1072 0, 0, pixmap_w, pixmap_h, 0, 0);
1075 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1076 gui->lock_window("AssetPicon::create_objects 5");
1077 icon = gui->audio_icon;
1078 icon_vframe = gui->audio_vframe;
1082 icon = gui->audio_icon;
1083 icon_vframe = gui->audio_vframe;
1088 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1089 comments_rate = asset->get_frame_rate();
1090 comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
1091 comments_type = asset->format == FILE_FFMPEG ?
1092 asset->vcodec : File::formattostr(asset->format);
1095 if( edl->tracks->playable_video_tracks() ) {
1096 if( mwindow->preferences->use_thumbnails ) {
1097 gui->unlock_window();
1098 AssetVIconThread *avt = gui->vicon_thread;
1099 char clip_icon_path[BCTEXTLEN];
1100 char *clip_icon = edl->local_session->clip_icon;
1102 if( is_clip && clip_icon[0] ) {
1103 snprintf(clip_icon_path, sizeof(clip_icon_path),
1104 "%s/%s", File::get_config_path(), clip_icon);
1105 vframe = VFramePng::vframe_png(clip_icon_path);
1108 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1109 delete vframe; vframe = 0;
1111 int edl_h = edl->get_h(), edl_w = edl->get_w();
1112 int height = edl_h > 0 ? edl_h : 1;
1113 int width = edl_w > 0 ? edl_w : 1;
1114 int color_model = edl->session->color_model;
1116 //printf("render clip: %s\n", name);
1117 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1118 char string[BCTEXTLEN];
1119 sprintf(string, _("Rendering %s"), name);
1120 mwindow->gui->lock_window("AssetPicon::create_objects");
1121 mwindow->gui->show_message(string);
1122 mwindow->gui->unlock_window();
1123 open_render_engine(edl, 0);
1124 render_video(0, gui->temp_picon);
1125 close_render_engine();
1126 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1127 vframe->transfer_from(gui->temp_picon);
1128 if( this->edl && clip_icon[0] )
1129 vframe->write_png(clip_icon_path);
1131 pixmap_w = pixmap_h * width / height;
1132 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1133 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1134 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1135 icon_vframe->transfer_from(vframe);
1137 gui->lock_window("AssetPicon::create_objects 0");
1138 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1139 icon->draw_vframe(icon_vframe,
1140 0, 0, pixmap_w, pixmap_h, 0, 0);
1142 else if( is_clip ) {
1143 icon = gui->clip_icon;
1144 icon_vframe = gui->clip_vframe;
1147 icon = gui->video_icon;
1148 icon_vframe = gui->video_vframe;
1152 if( edl->tracks->playable_audio_tracks() ) {
1153 if( mwindow->preferences->use_thumbnails ) {
1154 gui->unlock_window();
1155 char clip_icon_path[BCTEXTLEN];
1156 char *clip_icon = edl->local_session->clip_icon;
1157 if( is_clip && clip_icon[0] ) {
1158 snprintf(clip_icon_path, sizeof(clip_icon_path),
1159 "%s/%s", File::get_config_path(), clip_icon);
1160 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1162 if( !icon_vframe ) {
1163 pixmap_w = pixmap_h * 16/9;
1164 icon_vframe = new VFrame(0,
1165 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1166 icon_vframe->clear_frame();
1167 char string[BCTEXTLEN];
1168 sprintf(string, _("Rendering %s"), name);
1169 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1170 mwindow->gui->show_message(string);
1171 mwindow->gui->unlock_window();
1172 int sample_rate = edl->get_sample_rate();
1173 int channels = edl->get_audio_channels();
1174 if( channels > 2 ) channels = 2;
1175 int64_t audio_samples = edl->get_audio_samples();
1176 double duration = (double)audio_samples / sample_rate;
1177 draw_hue_bar(icon_vframe, duration);
1178 Samples *samples[MAX_CHANNELS];
1179 int bfrsz = sample_rate;
1180 for( int i=0; i<MAX_CHANNELS; ++i )
1181 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1182 open_render_engine(edl, 1);
1183 render_audio(0, samples, bfrsz);
1184 close_render_engine();
1185 gui->lock_window("AssetPicon::create_objects 4");
1186 static int line_colors[2] = { GREEN, YELLOW };
1187 static int base_colors[2] = { RED, PINK };
1188 for( int i=channels; --i>=0; ) {
1189 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1190 base_colors[i], line_colors[i]);
1192 for( int i=0; i<channels; ++i ) delete samples[i];
1193 if( is_clip && clip_icon[0] )
1194 icon_vframe->write_png(clip_icon_path);
1197 pixmap_w = icon_vframe->get_w();
1198 pixmap_h = icon_vframe->get_h();
1200 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1201 icon->draw_vframe(icon_vframe,
1202 0, 0, pixmap_w, pixmap_h, 0, 0);
1204 else if( !indexable ) {
1205 icon = gui->clip_icon;
1206 icon_vframe = gui->clip_vframe;
1209 icon = gui->audio_icon;
1210 icon_vframe = gui->audio_vframe;
1215 strcpy(name, _(plugin->title));
1217 icon_vframe = plugin->get_picon();
1219 icon = gui->create_pixmap(icon_vframe);
1220 else if( plugin->audio ) {
1221 if( plugin->transition ) {
1222 icon = gui->atransition_icon;
1223 icon_vframe = gui->atransition_vframe;
1225 else if( plugin->is_ffmpeg() ) {
1226 icon = gui->ff_aud_icon;
1227 icon_vframe = gui->ff_aud_vframe;
1229 else if( plugin->is_ladspa() ) {
1230 icon = gui->ladspa_icon;
1231 icon_vframe = gui->ladspa_vframe;
1234 icon = gui->aeffect_icon;
1235 icon_vframe = gui->aeffect_vframe;
1238 else if( plugin->video ) {
1239 if( plugin->transition ) {
1240 icon = gui->vtransition_icon;
1241 icon_vframe = gui->vtransition_vframe;
1243 else if( plugin->is_ffmpeg() ) {
1244 icon = gui->ff_vid_icon;
1245 icon_vframe = gui->ff_vid_vframe;
1248 icon = gui->veffect_icon;
1249 icon_vframe = gui->veffect_vframe;
1256 mwindow->edl->session->time_format,
1257 mwindow->edl->session->sample_rate,
1258 mwindow->edl->session->frame_rate,
1259 mwindow->edl->session->frames_per_foot);
1261 icon = gui->label_icon;
1262 icon_vframe = gui->label_vframe;
1265 icon = gui->file_icon;
1266 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1269 set_icon_vframe(icon_vframe);
1272 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1273 : BC_Window(_(PROGRAM_NAME ": Resources"),
1274 mwindow->session->awindow_x, mwindow->session->awindow_y,
1275 mwindow->session->awindow_w, mwindow->session->awindow_h,
1276 xS(100), yS(100), 1, 1, 1)
1278 this->mwindow = mwindow;
1279 this->awindow = awindow;
1281 file_vframe = 0; file_icon = 0;
1282 folder_vframe = 0; folder_icon = 0;
1283 audio_vframe = 0; audio_icon = 0;
1284 video_vframe = 0; video_icon = 0;
1285 label_vframe = 0; label_icon = 0;
1287 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1288 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1289 clip_folder_vframe = 0; clip_folder_icon = 0;
1290 label_folder_vframe = 0; label_folder_icon = 0;
1291 media_folder_vframe = 0; media_folder_icon = 0;
1292 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1293 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1294 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1296 ladspa_vframe = 0; ladspa_icon = 0;
1297 ff_aud_vframe = 0; ff_aud_icon = 0;
1298 ff_vid_vframe = 0; ff_vid_icon = 0;
1300 clip_vframe = 0; clip_icon = 0;
1301 atransition_vframe = 0; atransition_icon = 0;
1302 vtransition_vframe = 0; vtransition_icon = 0;
1303 aeffect_vframe = 0; aeffect_icon = 0;
1304 veffect_vframe = 0; veffect_icon = 0;
1306 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1308 effectlist_menu = 0;
1313 folderlist_menu = 0;
1316 allow_iconlisting = 1;
1320 vicon_drawing = AVICON_FULL_PLAY;
1323 displayed_folder = AW_NO_FOLDER;
1324 new_folder_thread = 0;
1325 modify_folder_thread = 0;
1326 folder_lock = new Mutex("AWindowGUI::folder_lock");
1329 AWindowGUI::~AWindowGUI()
1331 assets.remove_all_objects();
1332 folders.remove_all_objects();
1333 aeffects.remove_all_objects();
1334 veffects.remove_all_objects();
1335 atransitions.remove_all_objects();
1336 vtransitions.remove_all_objects();
1337 labellist.remove_all_objects();
1338 displayed_assets[1].remove_all_objects();
1340 delete new_folder_thread;
1341 delete modify_folder_thread;
1342 delete vicon_thread;
1347 delete remove_plugin;
1349 delete file_vframe; delete file_icon;
1350 delete folder_vframe; delete folder_icon;
1351 delete audio_vframe; delete audio_icon;
1352 delete video_vframe; delete video_icon;
1353 delete label_vframe; delete label_icon;
1354 delete clip_vframe; delete clip_icon;
1355 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1356 delete atransition_folder_vframe; delete atransition_folder_icon;
1357 delete veffect_folder_vframe; delete veffect_folder_icon;
1358 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1359 delete clip_folder_vframe; delete clip_folder_icon;
1360 delete label_folder_vframe; delete label_folder_icon;
1361 delete media_folder_vframe; delete media_folder_icon;
1362 delete proxy_folder_vframe; delete proxy_folder_icon;
1363 delete ladspa_vframe; delete ladspa_icon;
1364 delete ff_aud_vframe; delete ff_aud_icon;
1365 delete ff_vid_vframe; delete ff_vid_icon;
1366 delete atransition_vframe; delete atransition_icon;
1367 delete vtransition_vframe; delete vtransition_icon;
1368 delete aeffect_vframe; delete aeffect_icon;
1369 delete veffect_vframe; delete veffect_icon;
1373 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1375 return icon == file_icon ||
1376 icon == folder_icon ||
1377 icon == audio_icon ||
1378 icon == video_icon ||
1379 icon == clip_icon ||
1380 icon == label_icon ||
1381 icon == vtransition_icon ||
1382 icon == atransition_icon ||
1383 icon == veffect_icon ||
1384 icon == aeffect_icon ||
1385 icon == ladspa_icon ||
1386 icon == ff_aud_icon ||
1387 icon == ff_vid_icon ||
1388 icon == aeffect_folder_icon ||
1389 icon == veffect_folder_icon ||
1390 icon == atransition_folder_icon ||
1391 icon == vtransition_folder_icon ||
1392 icon == label_folder_icon ||
1393 icon == clip_folder_icon ||
1394 icon == media_folder_icon ||
1395 icon == proxy_folder_icon;
1398 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1400 char png_path[BCTEXTLEN];
1401 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1402 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1403 File::get_plugin_path(), plugin_icons, name);
1404 if( access(png_path, R_OK) ) return 0;
1405 return VFramePng::vframe_png(png_path,0,0);
1408 VFrame *AWindowGUI::get_picon(const char *name)
1410 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1412 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1413 snprintf(pp, ep-pp, "%s.png", name);
1414 unsigned char *data = mwindow->theme->get_image_data(png_name);
1415 if( data ) vframe = new VFramePng(data, 0.);
1420 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1422 vfrm = get_picon(fn);
1423 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1424 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1426 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1428 vfrm = get_picon(fn);
1429 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1430 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1432 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1434 vfrm = get_picon(fn);
1435 if( !vfrm ) vfrm = new VFramePng(png);
1436 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1439 void AWindowGUI::create_objects()
1441 int ys5 = yS(5), ys10 = yS(10);
1442 lock_window("AWindowGUI::create_objects");
1443 asset_titles[0] = C_("Title");
1444 asset_titles[1] = _("Comments");
1446 set_icon(mwindow->theme->get_image("awindow_icon"));
1448 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1449 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1450 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1451 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1452 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1454 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1455 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1456 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1457 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1458 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1459 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1460 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1461 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1463 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1464 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1465 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1466 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1467 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1468 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1469 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1470 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1472 theme_icon(clip_vframe, clip_icon, "clip_icon");
1473 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1474 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1475 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1476 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1478 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1479 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1480 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1481 folder_lock->lock("AWindowGUI::create_objects");
1482 // Mandatory folders
1483 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1484 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1485 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1486 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1487 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1488 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1489 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1490 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1492 create_label_folder();
1493 folder_lock->unlock();
1495 mwindow->theme->get_awindow_sizes(this);
1496 load_defaults(mwindow->defaults);
1497 new_folder_thread = new NewFolderThread(this);
1498 modify_folder_thread = new ModifyFolderThread(this);
1500 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1501 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1502 search_text = new AWindowSearchText(mwindow, this, x1, y1+ys5);
1503 search_text->create_objects();
1504 int dy = search_text->get_h() + ys10;
1506 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1508 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1509 asset_list->update_vicon_area();
1510 vicon_thread->start();
1511 vicon_audio = new AssetVIconAudio(this);
1513 add_subwindow(divider = new AWindowDivider(mwindow, this,
1514 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1515 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1517 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1519 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1520 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1521 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1522 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1523 for( int i=0; i<n; ++i ) {
1524 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1525 if( tw < nw ) tw = nw;
1527 int pw = BC_PopupMenu::calculate_w(xS(16), tw, 1);
1528 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1529 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1530 avicon_drawing->create_objects();
1531 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1532 add_tools->create_objects();
1533 fy += add_tools->get_h(); fh -= add_tools->get_h();
1534 add_subwindow(folder_list = new AWindowFolders(mwindow,
1535 this, fx, fy, fw, fh));
1537 folder_list->load_expanders();
1539 //int x = mwindow->theme->abuttons_x;
1540 //int y = mwindow->theme->abuttons_y;
1542 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1543 asset_menu->create_objects();
1544 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1545 clip_menu->create_objects();
1546 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1547 label_menu->create_objects();
1548 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1549 proxy_menu->create_objects();
1551 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1552 effectlist_menu->create_objects();
1553 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1554 assetlist_menu->create_objects();
1555 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1556 cliplist_menu->create_objects();
1557 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1558 labellist_menu->create_objects();
1559 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1560 proxylist_menu->create_objects();
1562 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1563 folderlist_menu->create_objects();
1565 create_custom_xatoms();
1569 int AWindowGUI::resize_event(int w, int h)
1571 mwindow->session->awindow_x = get_x();
1572 mwindow->session->awindow_y = get_y();
1573 mwindow->session->awindow_w = w;
1574 mwindow->session->awindow_h = h;
1576 mwindow->theme->get_awindow_sizes(this);
1577 mwindow->theme->draw_awindow_bg(this);
1578 reposition_objects();
1580 // int x = mwindow->theme->abuttons_x;
1581 // int y = mwindow->theme->abuttons_y;
1582 // new_bin->reposition_window(x, y);
1583 // x += new_bin->get_w();
1584 // delete_bin->reposition_window(x, y);
1585 // x += delete_bin->get_w();
1586 // rename_bin->reposition_window(x, y);
1587 // x += rename_bin->get_w();
1588 // delete_disk->reposition_window(x, y);
1589 // x += delete_disk->get_w();
1590 // delete_project->reposition_window(x, y);
1591 // x += delete_project->get_w();
1592 // info->reposition_window(x, y);
1593 // x += info->get_w();
1594 // redraw_index->reposition_window(x, y);
1595 // x += redraw_index->get_w();
1596 // paste->reposition_window(x, y);
1597 // x += paste->get_w();
1598 // append->reposition_window(x, y);
1599 // x += append->get_w();
1600 // view->reposition_window(x, y);
1602 BC_WindowBase::resize_event(w, h);
1603 asset_list->update_vicon_area();
1607 int AWindowGUI::translation_event()
1609 mwindow->session->awindow_x = get_x();
1610 mwindow->session->awindow_y = get_y();
1614 void AWindowGUI::reposition_objects()
1616 int ys5 = yS(5), ys10 = yS(10);
1617 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1618 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1619 search_text->reposition_window(x1, y1+ys5, w1);
1620 int dy = search_text->get_h() + ys10;
1622 asset_list->reposition_window(x1, y1, w1, h1);
1623 divider->reposition_window(
1624 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1625 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1626 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1627 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1628 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1629 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1630 fy += add_tools->get_h(); fh -= add_tools->get_h();
1631 folder_list->reposition_window(fx, fy, fw, fh);
1634 int AWindowGUI::save_defaults(BC_Hash *defaults)
1636 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1637 defaults->update("VICON_DRAWING", vicon_drawing);
1638 defaults->update("TIP_INFO", tip_info);
1642 int AWindowGUI::load_defaults(BC_Hash *defaults)
1644 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1645 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1646 tip_info = defaults->get("TIP_INFO", tip_info);
1650 int AWindowGUI::close_event()
1653 mwindow->session->show_awindow = 0;
1656 mwindow->gui->lock_window("AWindowGUI::close_event");
1657 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1658 mwindow->gui->unlock_window();
1660 lock_window("AWindowGUI::close_event");
1661 save_defaults(mwindow->defaults);
1662 mwindow->save_defaults();
1666 int AWindowGUI::start_vicon_drawing()
1668 if( play_off ) return stop_vicon_drawing();
1669 if( !vicon_thread->interrupted ) return 1;
1670 switch( vicon_drawing ) {
1671 case AVICON_FULL_PLAY: // all vicons, viewing, target
1673 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1674 if( vicon_thread->solo ) break;
1676 case AVICON_SRC_TARGET: // no vicons, no view, target
1677 case AVICON_NO_PLAY: // no vicons, no view, no target
1680 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1681 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1682 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1683 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1684 switch( mwindow->edl->session->assetlist_format ) {
1686 case ASSETS_ICONS_PACKED:
1687 case ASSETS_ICON_LIST:
1688 asset_list->update_vicon_area();
1689 vicon_thread->start_drawing();
1698 int AWindowGUI::stop_vicon_drawing()
1700 if( !vicon_thread->interrupted )
1701 vicon_thread->stop_drawing();
1705 void AWindowGUI::close_view_popup()
1707 vicon_thread->close_view_popup();
1710 VFrame *AssetPicon::get_vicon_frame()
1712 if( !vicon ) return 0;
1713 if( gui->vicon_thread->interrupted ) return 0;
1714 VFrame *frame = vicon->frame();
1715 if( !frame ) return 0;
1717 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1718 vicon_frame->transfer_from(frame);
1722 int AWindowGUI::cycle_assetlist_format()
1724 EDLSession *session = mwindow->edl->session;
1725 int format = ASSETS_TEXT;
1726 if( allow_iconlisting ) {
1727 switch( session->assetlist_format ) {
1729 format = ASSETS_ICONS;
1732 format = ASSETS_ICONS_PACKED;
1734 case ASSETS_ICONS_PACKED:
1735 format = ASSETS_ICON_LIST;
1737 case ASSETS_ICON_LIST:
1738 format = ASSETS_TEXT;
1742 stop_vicon_drawing();
1743 session->assetlist_format = format;
1744 asset_list->update_format(session->assetlist_format, 0);
1745 async_update_assets();
1746 start_vicon_drawing();
1750 void AWindowGUI::hide_tip_info()
1752 asset_list->hide_tooltip();
1756 AWindowRemovePluginGUI::
1757 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1758 int x, int y, PluginServer *plugin)
1759 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y,
1760 xS(500),yS(200), xS(50), yS(50),
1763 this->awindow = awindow;
1764 this->thread = thread;
1765 this->plugin = plugin;
1766 VFrame *vframe = plugin->get_picon();
1767 icon = vframe ? create_pixmap(vframe) : 0;
1768 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1771 AWindowRemovePluginGUI::
1772 ~AWindowRemovePluginGUI()
1774 if( !awindow->gui->protected_pixmap(icon) )
1776 plugin_list.remove_all();
1779 void AWindowRemovePluginGUI::create_objects()
1781 int xs10 = xS(10), xs20 = xS(20);
1782 int ys5 = yS(5), ys10 = yS(10);
1783 lock_window("AWindowRemovePluginGUI::create_objects");
1784 BC_Button *ok_button = new BC_OKButton(this);
1785 add_subwindow(ok_button);
1786 BC_Button *cancel_button = new BC_CancelButton(this);
1787 add_subwindow(cancel_button);
1788 int x = xs10, y = ys10;
1789 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1790 add_subwindow(title);
1791 y += title->get_h() + ys5;
1792 list = new BC_ListBox(x, y,
1793 get_w() - xs20, ok_button->get_y() - y - ys5, LISTBOX_TEXT, &plugin_list,
1794 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1795 add_subwindow(list);
1800 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1803 for( int i=0; i<folder.size(); ) {
1804 AssetPicon *picon = (AssetPicon *)folder[i];
1805 if( picon->plugin == plugin ) {
1806 folder.remove_object_number(i);
1815 void AWindowRemovePlugin::handle_close_event(int result)
1818 printf(_("remove %s\n"), plugin->path);
1819 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1820 ArrayList<BC_ListBoxItem*> *folder =
1821 plugin->audio ? plugin->transition ?
1822 &awindow->gui->atransitions :
1823 &awindow->gui->aeffects :
1824 plugin->video ? plugin->transition ?
1825 &awindow->gui->vtransitions :
1826 &awindow->gui->veffects :
1828 if( folder ) remove_plugin(plugin, *folder);
1829 MWindow *mwindow = awindow->mwindow;
1830 awindow->gui->unlock_window();
1831 char plugin_path[BCTEXTLEN];
1832 strcpy(plugin_path, plugin->path);
1833 mwindow->plugindb->remove(plugin);
1834 remove(plugin_path);
1835 char index_path[BCTEXTLEN];
1836 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1838 char picon_path[BCTEXTLEN];
1840 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1841 File::get_plugin_path());
1842 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1843 plugin->get_plugin_png_name(png_name);
1844 fs.update(picon_path);
1845 for( int i=0; i<fs.dir_list.total; ++i ) {
1846 char *fs_path = fs.dir_list[i]->path;
1847 if( !fs.is_dir(fs_path) ) continue;
1848 snprintf(png_path, sizeof(picon_path), "%s/%s",
1852 delete plugin; plugin = 0;
1853 awindow->gui->async_update_assets();
1857 AWindowRemovePlugin::
1858 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1861 this->awindow = awindow;
1862 this->plugin = plugin;
1865 AWindowRemovePlugin::
1866 ~AWindowRemovePlugin()
1871 BC_Window* AWindowRemovePlugin::new_gui()
1873 int x = awindow->gui->get_abs_cursor_x(0);
1874 int y = awindow->gui->get_abs_cursor_y(0);
1875 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1876 gui->create_objects();
1880 int AWindowGUI::keypress_event()
1882 switch( get_keypress() ) {
1890 tip_info = !tip_info ? 1 : 0;
1891 if( !tip_info ) hide_tip_info();
1894 if( !ctrl_down() && !shift_down() ) {
1895 assetlist_menu->load_file->handle_event();
1900 return cycle_assetlist_format();
1902 if( shift_down() && ctrl_down() ) {
1903 PluginServer* plugin = selected_plugin();
1904 if( !plugin ) break;
1905 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1907 remove_plugin->start();
1908 lock_window("AWindowGUI::keypress_event 1");
1912 if( shift_down() ) {
1913 mwindow->awindow->asset_remove->start();
1917 mwindow->remove_assets_from_project(1, 1, 1,
1918 mwindow->session->drag_assets,
1919 mwindow->session->drag_clips);
1920 lock_window("AWindowGUI::keypress_event 2");
1926 if( shift_down() && ctrl_down() ) {
1927 resend_event(mwindow->gui);
1937 int AWindowGUI::create_custom_xatoms()
1939 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1942 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1944 if( event->message_type == UpdateAssetsXAtom ) {
1951 void AWindowGUI::async_update_assets()
1954 event.message_type = UpdateAssetsXAtom;
1955 send_custom_xatom(&event);
1959 void AWindowGUI::update_folder_list()
1961 for( int i = 0; i < folders.total; i++ ) {
1962 AssetPicon *picon = (AssetPicon*)folders.values[i];
1966 // Search assets for folders
1967 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1968 BinFolder *bin_folder = mwindow->edl->folders[i];
1971 for( int j = 0; j < folders.total; j++ ) {
1972 AssetPicon *picon = (AssetPicon*)folders[j];
1973 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1981 const char *title = bin_folder->title;
1982 int folder = bin_folder->awindow_folder;
1983 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1984 picon->create_objects();
1985 folders.append(picon);
1989 // Delete unused non-persistent folders
1990 int do_autoplace = 0;
1991 for( int i=folders.total; --i>=0; ) {
1992 AssetPicon *picon = (AssetPicon*)folders.values[i];
1993 if( !picon->in_use && !picon->persistent ) {
1995 folders.remove_number(i);
2000 folder_list->set_autoplacement(&folders, 0, 1);
2003 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
2004 int do_audio, int do_video, int is_realtime, int is_transition)
2006 ArrayList<PluginServer*> plugin_list;
2007 // Get pointers to plugindb entries
2008 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
2011 for( int i = 0; i < plugin_list.total; i++ ) {
2012 PluginServer *server = plugin_list.values[i];
2013 int visible = plugin_visibility & (1<<server->dir_idx);
2014 if( !visible ) continue;
2015 // Create new listitem
2016 AssetPicon *picon = new AssetPicon(mwindow, this, server);
2017 picon->create_objects();
2018 output->append(picon);
2022 void AWindowGUI::create_label_folder()
2025 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
2026 AssetPicon *picon = new AssetPicon(mwindow, this, current);
2027 picon->create_objects();
2028 labellist.append(picon);
2033 void AWindowGUI::update_asset_list()
2035 ArrayList<AssetPicon *> new_assets;
2036 for( int i = 0; i < assets.total; i++ ) {
2037 AssetPicon *picon = (AssetPicon*)assets.values[i];
2041 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2042 // Synchronize EDL clips
2043 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2046 // Look for clip in existing listitems
2047 for( int j = 0; j < assets.total && !exists; j++ ) {
2048 AssetPicon *picon = (AssetPicon*)assets.values[j];
2050 if( picon->id == mwindow->edl->clips[i]->id ) {
2051 picon->edl = mwindow->edl->clips[i];
2052 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2058 // Create new listitem
2060 AssetPicon *picon = new AssetPicon(mwindow,
2061 this, mwindow->edl->clips[i]);
2062 new_assets.append(picon);
2066 // Synchronize EDL assets
2067 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2070 // Look for asset in existing listitems
2071 for( int j = 0; j < assets.total && !exists; j++ ) {
2072 AssetPicon *picon = (AssetPicon*)assets.values[j];
2074 if( picon->id == current->id ) {
2075 picon->indexable = current;
2081 // Create new listitem
2083 AssetPicon *picon = new AssetPicon(mwindow,
2085 new_assets.append(picon);
2089 // Synchronize nested EDLs
2090 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2092 EDL *nested_edl = mwindow->edl->nested_edls[i];
2094 // Look for asset in existing listitems
2095 for( int j=0; j<assets.total && !exists; ++j ) {
2096 AssetPicon *picon = (AssetPicon*)assets.values[j];
2098 if( picon->id == nested_edl->id ) {
2099 picon->indexable = nested_edl;
2105 // Create new listitem
2107 AssetPicon *picon = new AssetPicon(mwindow,
2108 this, (Indexable*)nested_edl);
2109 new_assets.append(picon);
2112 mwindow->gui->unlock_window();
2114 for( int i=0; i<new_assets.size(); ++i ) {
2115 AssetPicon *picon = new_assets[i];
2116 picon->create_objects();
2117 if( picon->indexable )
2118 picon->foldernum = AW_MEDIA_FOLDER;
2119 else if( picon->edl )
2120 picon->foldernum = AW_CLIP_FOLDER;
2121 assets.append(picon);
2124 mwindow->gui->lock_window();
2125 mwindow->gui->default_message();
2126 mwindow->gui->unlock_window();
2128 for( int i = assets.size() - 1; i >= 0; i-- ) {
2129 AssetPicon *picon = (AssetPicon*)assets.get(i);
2130 if( !picon->in_use ) {
2132 assets.remove_number(i);
2135 if( picon->indexable && picon->indexable->is_asset ) {
2136 Asset *asset = (Asset *)picon->indexable;
2138 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2139 picon->comments_rate = asset->get_frame_rate();
2140 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2141 picon->comments_type = asset->format == FILE_FFMPEG ?
2142 asset->vcodec : File::formattostr(asset->format);
2147 void AWindowGUI::update_picon(Indexable *indexable)
2150 for( int i = 0; i < assets.total; i++ ) {
2151 AssetPicon *picon = (AssetPicon*)assets.values[i];
2152 if( picon->indexable == indexable ||
2153 picon->edl == (EDL *)indexable ) {
2154 char name[BCTEXTLEN];
2156 fs.extract_name(name, indexable->path);
2157 picon->set_text(name);
2158 vicon = picon->vicon;
2163 stop_vicon_drawing();
2164 vicon->clear_images();
2165 vicon->reset(indexable->get_frame_rate());
2166 start_vicon_drawing();
2170 void AWindowGUI::sort_assets()
2172 folder_lock->lock("AWindowGUI::sort_assets");
2173 switch( mwindow->edl->session->awindow_folder ) {
2174 case AW_AEFFECT_FOLDER:
2175 sort_picons(&aeffects);
2177 case AW_VEFFECT_FOLDER:
2178 sort_picons(&veffects);
2180 case AW_ATRANSITION_FOLDER:
2181 sort_picons(&atransitions);
2183 case AW_VTRANSITION_FOLDER:
2184 sort_picons(&vtransitions);
2186 case AW_LABEL_FOLDER:
2187 sort_picons(&labellist);
2190 sort_picons(&assets);
2194 asset_list->update_format(asset_list->get_format(), 0);
2195 folder_lock->unlock();
2199 void AWindowGUI::sort_folders()
2201 folder_lock->lock("AWindowGUI::update_assets");
2202 // folder_list->collapse_recursive(&folders, 0);
2203 folder_list->set_autoplacement(&folders, 0, 1);
2204 sort_picons(&folders);
2205 folder_list->update_format(folder_list->get_format(), 0);
2206 folder_lock->unlock();
2210 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2212 Asset *proxy_asset = (Asset *)indexable;
2213 char path[BCTEXTLEN];
2214 int proxy_scale = mwindow->edl->session->proxy_scale;
2215 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2216 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2217 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2218 // make a clip from proxy video tracks and unproxy audio tracks
2219 EDL *proxy_edl = new EDL(mwindow->edl);
2220 proxy_edl->create_objects();
2221 proxy_edl->set_path(proxy_asset->path);
2222 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2223 strcpy(proxy_edl->local_session->clip_title, path);
2224 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2225 proxy_edl->session->video_tracks = proxy_asset->layers;
2226 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2227 proxy_edl->create_default_tracks();
2228 double length = proxy_asset->frame_rate > 0 ?
2229 ( proxy_asset->video_length >= 0 ?
2230 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2231 ( proxy_edl->session->si_useduration ?
2232 proxy_edl->session->si_duration :
2233 1.0 / proxy_asset->frame_rate ) ) :
2234 1.0 / proxy_edl->session->frame_rate;
2235 Track *current = proxy_edl->tracks->first;
2236 for( int vtrack=0; current; current=NEXT ) {
2237 if( current->data_type != TRACK_VIDEO ) continue;
2238 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2240 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2241 current = proxy_edl->tracks->first;
2242 for( int atrack=0; current; current=NEXT ) {
2243 if( current->data_type != TRACK_AUDIO ) continue;
2244 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2246 proxy_edl->folder_no = AW_PROXY_FOLDER;
2251 void AWindowGUI::collect_assets(int proxy)
2253 mwindow->session->drag_assets->remove_all();
2254 mwindow->session->drag_clips->remove_all();
2255 int i = 0; AssetPicon *result;
2256 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2257 Indexable *indexable = result->indexable;
2258 if( proxy && indexable && indexable->is_asset &&
2259 indexable->folder_no == AW_PROXY_FOLDER ) {
2260 EDL *drag_edl = collect_proxy(indexable);
2261 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2265 mwindow->session->drag_assets->append(indexable);
2269 mwindow->session->drag_clips->append(result->edl);
2275 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2277 // Remove current pointers
2278 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2279 dst[0].remove_all();
2280 dst[1].remove_all_objects();
2282 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2283 int folder = mwindow->edl->session->awindow_folder;
2284 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2285 mwindow->edl->get_folder(folder);
2287 // Create new pointers
2288 for( int i = 0; i < src->total; i++ ) {
2289 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2290 picon = (AssetPicon*)src->values[i];
2291 picon->sort_key = -1;
2292 if( !visible && bin_folder ) {
2293 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2294 picon->indexable ? picon->indexable :
2295 picon->edl ? picon->edl->get_proxy_asset() : 0;
2297 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2298 if( picon->sort_key < 0 ) continue;
2302 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2304 if( !visible && picon->edl && picon->edl->folder_no == folder )
2306 if( visible && sub_items ) {
2307 if( !sub_items->matches(picon->get_text()) )
2311 const char *text = search_text->get_text();
2312 if( text && text[0] )
2313 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2315 if( visible && picon->vicon && picon->vicon->hidden )
2316 picon->vicon->hidden = 0;
2318 BC_ListBoxItem *item2, *item1;
2319 dst[0].append(item1 = picon);
2321 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2324 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2325 else if( picon->comments_time ) {
2326 char date_time[BCSTRLEN];
2327 struct tm stm; localtime_r(&picon->comments_time, &stm);
2328 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2329 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2330 stm.tm_hour, stm.tm_min, stm.tm_sec,
2331 picon->comments_rate, picon->comments_ffmt,
2332 picon->comments_type);
2333 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2336 dst[1].append(item2 = new BC_ListBoxItem(""));
2337 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2338 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2343 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2345 int done = 0, changed = 0;
2348 for( int i=0; i<src->total-1; ++i ) {
2349 AssetPicon *item1 = (AssetPicon *)src->values[i];
2350 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2351 double v = item2->sort_key - item1->sort_key;
2352 if( v > 0 ) continue;
2354 const char *cp1 = item1->get_text();
2355 const char *bp1 = strrchr(cp1, '/');
2356 if( bp1 ) cp1 = bp1 + 1;
2357 const char *cp2 = item2->get_text();
2358 const char *bp2 = strrchr(cp2, '/');
2359 if( bp2 ) cp2 = bp2 + 1;
2360 if( strcmp(cp2, cp1) >= 0 ) continue;
2362 src->values[i + 1] = item1;
2363 src->values[i] = item2;
2364 done = 0; changed = 1;
2368 for( int i=0; i<src->total; ++i ) {
2369 AssetPicon *item = (AssetPicon *)src->values[i];
2370 item->set_autoplace_icon(1);
2371 item->set_autoplace_text(1);
2376 void AWindowGUI::filter_displayed_assets()
2378 //allow_iconlisting = 1;
2379 asset_titles[0] = C_("Title");
2380 asset_titles[1] = _("Comments");
2381 AssetPicon *picon = 0;
2382 int selected_folder = mwindow->edl->session->awindow_folder;
2383 // Ensure the current folder icon is highlighted
2384 for( int i = 0; i < folders.total; i++ ) {
2385 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2386 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2387 folder_item->set_selected(selected);
2388 if( selected ) picon = folder_item;
2391 ArrayList<BC_ListBoxItem*> *src = &assets;
2392 switch( selected_folder ) {
2393 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2394 case AW_VEFFECT_FOLDER: src = &veffects; break;
2395 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2396 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2397 case AW_LABEL_FOLDER: src = &labellist;
2398 asset_titles[0] = _("Time Stamps");
2399 asset_titles[1] = C_("Title");
2400 //allow_iconlisting = 0;
2403 copy_picons(picon, src);
2407 void AWindowGUI::update_assets()
2409 stop_vicon_drawing();
2410 folder_lock->lock("AWindowGUI::update_assets");
2411 update_folder_list();
2412 update_asset_list();
2413 labellist.remove_all_objects();
2414 create_label_folder();
2416 if( displayed_folder != mwindow->edl->session->awindow_folder )
2417 search_text->clear();
2418 vicon_thread->hide_vicons();
2419 filter_displayed_assets();
2420 folder_lock->unlock();
2422 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2423 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2425 int folder_xposition = folder_list->get_xposition();
2426 int folder_yposition = folder_list->get_yposition();
2427 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2429 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2430 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2432 int asset_xposition = asset_list->get_xposition();
2433 int asset_yposition = asset_list->get_yposition();
2434 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2435 displayed_folder = mwindow->edl->session->awindow_folder;
2436 asset_xposition = asset_yposition = 0;
2438 asset_list->update(displayed_assets, asset_titles,
2439 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2440 asset_xposition, asset_yposition, -1, 0);
2441 asset_list->center_selection();
2444 start_vicon_drawing();
2448 void AWindowGUI::update_effects()
2450 aeffects.remove_all_objects();
2451 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2452 veffects.remove_all_objects();
2453 create_persistent_folder(&veffects, 0, 1, 1, 0);
2454 atransitions.remove_all_objects();
2455 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2456 vtransitions.remove_all_objects();
2457 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2460 int AWindowGUI::drag_motion()
2462 if( get_hidden() ) return 0;
2468 int AWindowGUI::drag_stop()
2470 if( get_hidden() ) return 0;
2474 Indexable* AWindowGUI::selected_asset()
2476 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2477 return picon ? picon->indexable : 0;
2480 PluginServer* AWindowGUI::selected_plugin()
2482 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2483 return picon ? picon->plugin : 0;
2486 AssetPicon* AWindowGUI::selected_folder()
2488 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2499 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2500 : BC_SubWindow(x, y, w, h)
2502 this->mwindow = mwindow;
2505 AWindowDivider::~AWindowDivider()
2509 int AWindowDivider::button_press_event()
2511 if( is_event_win() && cursor_inside() ) {
2512 mwindow->session->current_operation = DRAG_PARTITION;
2518 int AWindowDivider::cursor_motion_event()
2520 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2522 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2523 int fw = gui->get_relative_cursor_x();
2524 if( fw > wmax ) fw = wmax;
2525 if( fw < wmin ) fw = wmin;
2526 mwindow->session->afolders_w = fw;
2527 mwindow->theme->get_awindow_sizes(gui);
2528 gui->reposition_objects();
2534 int AWindowDivider::button_release_event()
2536 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2537 mwindow->session->current_operation = NO_OPERATION;
2548 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2549 : BC_ListBox(x, y, w, h,
2550 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2551 LISTBOX_ICONS : LISTBOX_TEXT,
2552 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2553 0, // Titles for columns. Set to 0 for no titles
2554 0, // width of each column
2555 1, // Total columns.
2556 0, // Pixel of top of window.
2557 0, // If this listbox is a popup window
2558 LISTBOX_SINGLE, // Select one item or multiple items
2559 ICON_TOP, // Position of icon relative to text of each item
2562 this->mwindow = mwindow;
2569 AWindowFolders::~AWindowFolders()
2573 int AWindowFolders::selection_changed()
2575 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2576 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2577 // prefer expanded entry
2578 AWindowFolderItem *item = item1 ? item1 : item0;
2579 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2580 item1->set_selected(0);
2587 AssetPicon *picon = item->get_picon();
2588 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2590 gui->stop_vicon_drawing();
2592 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2593 gui->folderlist_menu->update_titles();
2594 gui->folderlist_menu->activate_menu();
2597 mwindow->edl->session->awindow_folder = picon->foldernum;
2598 gui->asset_list->draw_background();
2599 gui->async_update_assets();
2601 gui->start_vicon_drawing();
2606 int AWindowFolders::button_press_event()
2608 gui->hide_tip_info();
2609 int result = BC_ListBox::button_press_event();
2612 if( get_buttonpress() == RIGHT_BUTTON &&
2613 is_event_win() && cursor_inside() ) {
2614 gui->folderlist_menu->update_titles();
2615 gui->folderlist_menu->activate_menu();
2623 int AWindowFolders::drag_stop()
2626 if( get_hidden() ) return 0;
2627 if( mwindow->session->current_operation == DRAG_ASSET &&
2628 gui->folder_list->cursor_above() ) { // check user folder
2629 int item_no = gui->folder_list->get_cursor_data_item_no();
2630 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2631 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2632 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2633 ArrayList<Indexable *> *drags = folder->is_clips ?
2634 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2635 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2636 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2638 mwindow->session->current_operation = ::NO_OPERATION;
2645 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2646 : AWindowFolderItem(text)
2648 this->parent = parent;
2651 int AWindowFolders::load_expanders()
2653 char expanders_path[BCTEXTLEN];
2654 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2655 FILE *fp = fopen(expanders_path, "r");
2657 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2658 File::get_cindat_path(), EXPANDERS_FILE);
2659 char *cp = strrchr(expanders_path,'.');
2660 if( cp ) strcpy(cp+1, mwindow->cin_lang);
2661 fp = fopen(expanders_path, "r");
2664 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2665 File::get_cindat_path(), EXPANDERS_FILE);
2666 fp = fopen(expanders_path, "r");
2669 const char tab = '\t';
2670 char line[BCTEXTLEN]; line[0] = 0;
2671 AWindowFolderItem *item = 0, *parent;
2672 AWindowFolderSubItems *sub_items = 0;
2674 while( fgets(line,sizeof(line),fp) ) {
2675 if( line[0] == '#' ) continue;
2676 int i = strlen(line);
2677 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2678 if( i == 0 ) continue;
2680 for( char *cp=line; *cp==tab; ++cp ) ++i;
2682 int i = gui->folders.size();
2684 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2685 if( !strcmp(folder->get_text(),_(line)) ) break;
2687 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2692 if( i > k+1 ) continue;
2694 if( line[i] != '-' && sub_items ) {
2695 sub_items->names.append(cstrdup(_(&line[i])));
2703 item = item->parent;
2706 parent = item->parent;
2708 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2709 if( !sublist ) sublist = parent->new_sublist(1);
2710 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2711 sublist->append(item = sub_items);
2718 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2719 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2720 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2721 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2722 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2724 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2725 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2726 mwindow->edl->session->asset_columns, // width of each column
2727 1, // Total columns.
2728 0, // Pixel of top of window.
2729 0, // If this listbox is a popup window
2730 LISTBOX_MULTIPLE, // Select one item or multiple items
2731 ICON_TOP, // Position of icon relative to text of each item
2732 -1) // Allow drags, require shift for scrolling
2734 this->mwindow = mwindow;
2736 this->info_tip = -1;
2738 set_scroll_stretch(1, 1);
2741 AWindowAssets::~AWindowAssets()
2745 int AWindowAssets::button_press_event()
2748 AssetVIconThread *avt = gui->vicon_thread;
2749 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2750 int dir = 1, button = get_buttonpress();
2752 case WHEEL_DOWN: dir = -1; // fall thru
2754 int x = get_cursor_x(), y = get_cursor_y();
2755 if( avt->cursor_inside(x, y) && avt->view_win )
2756 avt->zoom_scale(dir);
2761 int result = BC_ListBox::button_press_event();
2763 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2764 is_event_win() && cursor_inside() ) {
2765 BC_ListBox::deactivate_selection();
2766 int folder = mwindow->edl->session->awindow_folder;
2768 case AW_AEFFECT_FOLDER:
2769 case AW_VEFFECT_FOLDER:
2770 case AW_ATRANSITION_FOLDER:
2771 case AW_VTRANSITION_FOLDER:
2772 gui->effectlist_menu->update();
2773 gui->effectlist_menu->activate_menu();
2775 case AW_LABEL_FOLDER:
2776 gui->labellist_menu->update();
2777 gui->labellist_menu->activate_menu();
2779 case AW_CLIP_FOLDER:
2780 gui->cliplist_menu->update();
2781 gui->cliplist_menu->activate_menu();
2783 case AW_PROXY_FOLDER:
2784 gui->proxylist_menu->update();
2785 gui->proxylist_menu->activate_menu();
2788 case AW_MEDIA_FOLDER: {
2789 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2790 gui->assetlist_menu->update_titles(shots);
2791 gui->assetlist_menu->activate_menu();
2801 int AWindowAssets::handle_event()
2803 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2804 if( !asset_picon ) return 0;
2805 Indexable *picon_idxbl = asset_picon->indexable;
2806 EDL *picon_edl = asset_picon->edl;
2808 VWindow *vwindow = 0;
2809 switch( mwindow->edl->session->awindow_folder ) {
2810 case AW_AEFFECT_FOLDER:
2811 case AW_VEFFECT_FOLDER:
2812 case AW_ATRANSITION_FOLDER:
2813 case AW_VTRANSITION_FOLDER: return 1;
2814 case AW_PROXY_FOLDER:
2815 proxy = 1; // fall thru
2817 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2818 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2821 if( !vwindow || !vwindow->is_running() ) return 1;
2822 if( proxy && picon_idxbl ) {
2823 picon_edl = gui->collect_proxy(picon_idxbl);
2827 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2828 else if( picon_edl ) vwindow->change_source(picon_edl);
2832 int AWindowAssets::selection_changed()
2834 // Show popup window
2836 int folder = mwindow->edl->session->awindow_folder;
2837 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2838 (item = (AssetPicon*)get_selection(0, 0)) ) {
2840 case AW_AEFFECT_FOLDER:
2841 case AW_VEFFECT_FOLDER:
2842 case AW_ATRANSITION_FOLDER:
2843 case AW_VTRANSITION_FOLDER:
2844 gui->effectlist_menu->update();
2845 gui->effectlist_menu->activate_menu();
2847 case AW_LABEL_FOLDER:
2848 if( !item->label ) break;
2849 gui->label_menu->activate_menu();
2851 case AW_CLIP_FOLDER:
2852 if( !item->indexable && !item->edl ) break;
2853 gui->clip_menu->update();
2854 gui->clip_menu->activate_menu();
2856 case AW_PROXY_FOLDER:
2857 if( !item->indexable && !item->edl ) break;
2858 gui->proxy_menu->update();
2859 gui->proxy_menu->activate_menu();
2862 if( !item->indexable && !item->edl ) break;
2863 gui->asset_menu->update();
2864 gui->asset_menu->activate_menu();
2868 deactivate_selection();
2870 else if( get_button_down() && !gui->play_off &&
2871 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2872 item = (AssetPicon*)get_selection(0, 0);
2873 if( item && !get_selection(0, 1) ) {
2875 case AW_MEDIA_FOLDER:
2876 case AW_PROXY_FOLDER:
2877 case AWINDOW_USER_FOLDERS:
2878 if( get_buttonpress() == LEFT_BUTTON ||
2879 get_buttonpress() == MIDDLE_BUTTON ) {
2880 AssetVIcon *vicon = 0;
2881 AssetVIconThread *avt = gui->vicon_thread;
2882 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2883 vicon = item->vicon;
2884 int draw_mode = !vicon ?
2886 get_buttonpress() == MIDDLE_BUTTON ?
2887 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2888 avt->set_view_popup(vicon, draw_mode);
2891 case AW_CLIP_FOLDER:
2892 if( get_buttonpress() == LEFT_BUTTON ) {
2893 AssetVIcon *vicon = 0;
2894 AssetVIconThread *avt = gui->vicon_thread;
2895 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2896 vicon = item->vicon;
2897 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2903 gui->vicon_thread->set_view_popup(0);
2904 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2905 gui->stop_vicon_drawing();
2911 void AWindowAssets::draw_background()
2913 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2914 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2915 set_font(LARGEFONT);
2916 int folder = mwindow->edl->session->awindow_folder;
2917 const char *title = mwindow->edl->get_folder_name(folder);
2918 draw_text(get_w() - get_text_width(LARGEFONT, title) - xS(4), yS(30),
2919 title, -1, get_bg_surface());
2922 int AWindowAssets::drag_start_event()
2924 gui->vicon_thread->set_view_popup(0);
2925 int collect_pluginservers = 0;
2926 int collect_assets = 0, proxy = 0;
2928 if( BC_ListBox::drag_start_event() ) {
2929 switch( mwindow->edl->session->awindow_folder ) {
2930 case AW_AEFFECT_FOLDER:
2931 mwindow->session->current_operation = DRAG_AEFFECT;
2932 collect_pluginservers = 1;
2934 case AW_VEFFECT_FOLDER:
2935 mwindow->session->current_operation = DRAG_VEFFECT;
2936 collect_pluginservers = 1;
2938 case AW_ATRANSITION_FOLDER:
2939 mwindow->session->current_operation = DRAG_ATRANSITION;
2940 collect_pluginservers = 1;
2942 case AW_VTRANSITION_FOLDER:
2943 mwindow->session->current_operation = DRAG_VTRANSITION;
2944 collect_pluginservers = 1;
2946 case AW_LABEL_FOLDER:
2949 case AW_PROXY_FOLDER:
2950 proxy = 1; // fall thru
2951 case AW_MEDIA_FOLDER:
2953 mwindow->session->current_operation = DRAG_ASSET;
2958 if( collect_pluginservers ) {
2960 mwindow->session->drag_pluginservers->remove_all();
2963 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2964 if( !result ) break;
2966 mwindow->session->drag_pluginservers->append(result->plugin);
2970 if( collect_assets ) {
2971 gui->collect_assets(proxy);
2979 int AWindowAssets::drag_motion_event()
2981 BC_ListBox::drag_motion_event();
2984 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2985 mwindow->gui->drag_motion();
2986 mwindow->gui->unlock_window();
2988 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2989 VWindow *vwindow = mwindow->vwindows.get(i);
2990 if( !vwindow->is_running() ) continue;
2991 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2992 vwindow->gui->drag_motion();
2993 vwindow->gui->unlock_window();
2996 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2997 mwindow->cwindow->gui->drag_motion();
2998 mwindow->cwindow->gui->unlock_window();
3000 lock_window("AWindowAssets::drag_motion_event");
3001 if( mwindow->session->current_operation == DRAG_ASSET &&
3002 gui->folder_list->cursor_above() ) { // highlight user folder
3003 BC_ListBoxItem *item = 0;
3004 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
3005 if( item_no >= 0 ) {
3006 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
3007 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
3010 item_no = gui->folder_list->item_to_index(&gui->folders, item);
3011 int folder_xposition = gui->folder_list->get_xposition();
3012 int folder_yposition = gui->folder_list->get_yposition();
3013 gui->folder_list->update(&gui->folders, 0, 0, 1,
3014 folder_xposition, folder_yposition, item_no, 0, 1);
3019 int AWindowAssets::drag_stop_event()
3023 result = gui->drag_stop();
3028 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3029 result = mwindow->gui->drag_stop();
3030 mwindow->gui->unlock_window();
3034 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
3035 VWindow *vwindow = mwindow->vwindows.get(i);
3036 if( !vwindow ) continue;
3037 if( !vwindow->is_running() ) continue;
3038 if( vwindow->gui->is_hidden() ) continue;
3039 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3040 if( vwindow->gui->cursor_above() &&
3041 vwindow->gui->get_cursor_over_window() ) {
3042 result = vwindow->gui->drag_stop();
3044 vwindow->gui->unlock_window();
3049 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3050 result = mwindow->cwindow->gui->drag_stop();
3051 mwindow->cwindow->gui->unlock_window();
3054 lock_window("AWindowAssets::drag_stop_event");
3056 result = gui->folder_list->drag_stop();
3061 get_drag_popup()->set_animation(0);
3063 BC_ListBox::drag_stop_event();
3064 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3065 mwindow->session->current_operation = ::NO_OPERATION;
3070 int AWindowAssets::column_resize_event()
3072 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3073 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3077 int AWindowAssets::cursor_enter_event()
3079 int ret = BC_ListBox::cursor_enter_event();
3080 switch( gui->vicon_drawing ) {
3081 case AVICON_FULL_PLAY:
3082 gui->start_vicon_drawing();
3084 case AVICON_MOUSE_OVER:
3085 case AVICON_SRC_TARGET:
3086 case AVICON_NO_PLAY:
3093 int AWindowAssets::cursor_leave_event()
3096 if( !is_event_win() ) return 0;
3097 if( !gui->vicon_thread->viewing )
3098 gui->stop_vicon_drawing();
3099 return BC_ListBox::cursor_leave_event();
3102 int AWindowAssets::focus_out_event()
3104 gui->stop_vicon_drawing();
3105 gui->vicon_thread->set_view_popup(0);
3106 return BC_ListBox::focus_out_event();
3109 void AWindowAssets::update_vicon_area()
3111 int x0 = 0, x1 = get_w();
3112 int y0 = get_title_h();
3114 if( is_highlighted() ) {
3115 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3116 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3118 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3121 int AWindowAssets::mouse_over_event(int no)
3123 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3124 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3125 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3126 switch( gui->vicon_drawing ) {
3127 case AVICON_FULL_PLAY:
3128 gui->vicon_thread->solo = 0;
3129 if( vicon && gui->vicon_thread->viewing )
3130 gui->vicon_thread->set_view_popup(vicon);
3132 case AVICON_MOUSE_OVER:
3134 gui->vicon_thread->solo = vicon;
3135 gui->start_vicon_drawing();
3137 case AVICON_SRC_TARGET:
3139 if( gui->vicon_thread->viewing )
3140 gui->vicon_thread->set_view_popup(vicon);
3142 case AVICON_NO_PLAY:
3146 if( no < 0 && info_tip >= 0 ) {
3149 if( gui->tip_info && no >= 0 &&
3150 info_tip != no && picon && picon->plugin ) {
3151 const char *info = picon->plugin->tip;
3152 if( !info ) info = _("No info available");
3153 show_tip_info(info, no);
3158 void AWindowAssets::show_tip_info(const char *info, int no)
3160 int tw = get_text_width(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3161 int th = get_text_height(MEDIUMFONT, info) + TOOLTIP_MARGIN * 2;
3162 int tx = get_w() - (tw + xS(28));
3163 int ty = get_h() - (th + yS(28));
3164 show_tooltip(info, tx, ty, tw, th);
3168 void AWindowAssets::hide_tip_info()
3175 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3176 : BC_TextBox(x, y, w, 1, "")
3178 this->search_text = search_text;
3181 int AWindowSearchTextBox::handle_event()
3183 return search_text->handle_event();
3186 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3188 this->mwindow = mwindow;
3194 void AWindowSearchText::create_objects()
3198 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3199 x1 += text_title->get_w() + xs10;
3200 int w1 = gui->get_w() - x1 - 2*xs10;
3201 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3204 int AWindowSearchText::handle_event()
3206 gui->async_update_assets();
3210 int AWindowSearchText::get_w()
3212 return text_box->get_w() + text_title->get_w() + xS(10);
3215 int AWindowSearchText::get_h()
3217 return bmax(text_box->get_h(),text_title->get_h());
3220 void AWindowSearchText::reposition_window(int x, int y, int w)
3224 text_title->reposition_window(x1, y1);
3225 x1 += text_title->get_w() + xs10;
3226 int w1 = gui->get_w() - x1 - 2*xs10;
3227 text_box->reposition_window(x1, y1, w1);
3230 const char *AWindowSearchText::get_text()
3232 return text_box->get_text();
3235 void AWindowSearchText::clear()
3237 text_box->update("");
3240 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3241 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3243 this->mwindow = mwindow;
3245 set_tooltip(_("Delete asset from disk"));
3248 int AWindowDeleteDisk::handle_event()
3253 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3254 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3256 this->mwindow = mwindow;
3258 set_tooltip(_("Delete asset from project"));
3261 int AWindowDeleteProject::handle_event()
3266 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3267 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3269 // this->mwindow = mwindow;
3271 // set_tooltip(_("Edit information on asset"));
3274 // int AWindowInfo::handle_event()
3276 // int cur_x, cur_y;
3277 // gui->get_abs_cursor(cur_x, cur_y, 0);
3278 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3282 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3283 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3285 this->mwindow = mwindow;
3287 set_tooltip(_("Redraw index"));
3290 int AWindowRedrawIndex::handle_event()
3295 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3296 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3298 this->mwindow = mwindow;
3300 set_tooltip(_("Paste asset on recordable tracks"));
3303 int AWindowPaste::handle_event()
3308 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3309 : BC_Button(x, y, mwindow->theme->appendasset_data)
3311 this->mwindow = mwindow;
3313 set_tooltip(_("Append asset in new tracks"));
3316 int AWindowAppend::handle_event()
3321 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3322 : BC_Button(x, y, mwindow->theme->viewasset_data)
3324 this->mwindow = mwindow;
3326 set_tooltip(_("View asset"));
3329 int AWindowView::handle_event()
3334 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3335 : BC_PopupMenu(x, y, title, -1, 0)
3337 this->mwindow = mwindow;
3341 void AddTools::create_objects()
3344 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3345 vis |= 1 << PLUGIN_FFMPEG_ID;
3346 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3347 vis |= 1 << PLUGIN_LADSPA_ID;
3349 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3350 vis |= 1 << PLUGIN_LV2_ID;
3352 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3353 PluginServer *plugin = MWindow::plugindb->get(i);
3354 if( !plugin->audio && !plugin->video ) continue;
3355 int idx = plugin->dir_idx;
3356 uint32_t msk = 1 << idx;
3357 if( (msk & vis) != 0 ) continue;
3359 char parent[BCTEXTLEN];
3360 strcpy(parent, plugin->path);
3361 char *bp = strrchr(parent, '/');
3362 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3363 if( !bp ) bp = parent; else ++bp;
3364 add_item(new AddPluginItem(this, bp, idx));
3369 // plugin_dirs list from toplevel makefile include plugin_defs
3374 N_("audio_transitions")
3381 N_("video_transitions")
3384 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3385 : BC_MenuItem(_(text))
3389 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3390 int chk = (msk & vis) ? 1 : 0;
3394 int AddPluginItem::handle_event()
3396 int chk = get_checked() ^ 1;
3398 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3399 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3400 menu->gui->update_effects();
3401 menu->gui->save_defaults(menu->mwindow->defaults);
3402 menu->gui->async_update_assets();
3406 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3409 this->avicon = avicon;
3413 int AVIconDrawingItem::handle_event()
3415 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3416 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3417 item->set_checked(id == i);
3419 AWindowGUI *agui = avicon->agui;
3421 avicon->set_text(get_text());
3422 agui->stop_vicon_drawing();
3423 agui->vicon_thread->set_view_popup(0);
3424 agui->vicon_thread->solo = 0;
3425 agui->vicon_drawing = id;
3426 agui->start_vicon_drawing();
3430 int AVIconDrawing::draw_face(int dx, int color)
3432 int ret = BC_PopupMenu::draw_face(dx, color);
3433 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3434 int lx = get_margin(), ly = get_h()/2;
3435 draw_line(lx,ly, get_w()-2*lx,ly);
3440 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3441 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3446 AVIconDrawing::~AVIconDrawing()
3450 void AVIconDrawing::create_objects()
3452 AVIconDrawingItem *item;
3453 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3454 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3455 item->set_checked(agui->vicon_drawing == i);
3459 int AVIconDrawing::button_press_event()
3461 if( !is_event_win() ) return 0;
3462 if( get_buttonpress() == MIDDLE_BUTTON ) {
3463 agui->play_off = !agui->play_off ? 1 : 0;
3466 agui->start_vicon_drawing();
3469 return BC_PopupMenu::button_press_event();
3472 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3473 : BC_MenuItem("","v",'v')
3475 this->mwindow = mwindow;
3479 int AWindowListFormat::handle_event()
3481 return gui->cycle_assetlist_format();
3484 void AWindowListFormat::update()
3486 EDLSession *session = mwindow->edl->session;
3487 const char *text = 0;
3488 switch( session->assetlist_format ) {
3490 text = _("Display icons");
3493 text = _("Display icons packed");
3495 case ASSETS_ICONS_PACKED:
3496 text = _("Display icon list");
3498 case ASSETS_ICON_LIST:
3499 text = _("Display text");
3505 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3506 : BC_MenuItem(_("Sort items"))
3508 this->mwindow = mwindow;
3512 int AWindowListSort::handle_event()
3518 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3521 this->select_used = select_used;
3522 this->action = action;
3525 int AssetSelectUsedItem::handle_event()
3527 MWindow *mwindow = select_used->mwindow;
3528 AWindowGUI *gui = select_used->gui;
3529 AWindowAssets *asset_list = gui->asset_list;
3530 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3535 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3539 asset_list->set_all_selected(data, 0);
3540 for( int i = 0; i < data->total; i++ ) {
3541 AssetPicon *picon = (AssetPicon*)data->values[i];
3542 Indexable *idxbl = picon->indexable ? picon->indexable :
3543 picon->edl ? picon->edl->get_proxy_asset() : 0;
3544 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3545 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3550 int asset_xposition = asset_list->get_xposition();
3551 int asset_yposition = asset_list->get_yposition();
3552 asset_list->update(gui->displayed_assets, gui->asset_titles,
3553 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3554 asset_xposition, asset_yposition, -1, 0);
3555 asset_list->center_selection();
3559 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3560 : BC_MenuItem(_("Select"))
3562 this->mwindow = mwindow;