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;
114 AssetVIcon::~AssetVIcon()
116 picon->gui->vicon_thread->del_vicon(this);
120 VFrame *AssetVIcon::frame()
122 AssetVIconThread *avt = picon->gui->vicon_thread;
123 Asset *asset = (Asset *)picon->indexable;
124 if( !asset ) return vframes()>0 ? (VFrame*)*images[0] : 0;
125 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
126 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
128 int sample_rate = asset->get_sample_rate();
129 int64_t audio_samples = asset->get_audio_samples();
130 double duration = (double)audio_samples / sample_rate;
131 picon->draw_hue_bar(temp, duration);
132 int secs = length / frame_rate + 0.5;
133 if( !secs ) secs = 1;
134 int bfrsz = VICON_SAMPLE_RATE;
135 int samples = audio_size/sizeof(vicon_audio_t);
136 double line_pos = (double)seq_no/(length-1);
137 int audio_pos = samples * line_pos * (secs-1)/secs;
138 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
139 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
140 double data[bfrsz], sample_scale = 1./mx;
141 int len = samples - audio_pos;
142 if( len > bfrsz ) len = bfrsz;
144 while( i < len ) data[i++] = *audio_data++ * sample_scale;
145 while( i < bfrsz ) data[i++] = 0;
146 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
147 int x = (w-1) * line_pos;
148 temp->pixel_rgb = RED;
149 temp->draw_line(x,0, x,h);
152 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
153 if( !asset->video_data ) {
155 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
160 if( seq_no >= images.size() ) {
161 MWindow *mwindow = picon->mwindow;
162 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
163 if( !file ) return 0;
164 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
165 delete temp; temp = 0;
168 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
169 while( seq_no >= images.size() ) {
170 mwindow->video_cache->check_in(asset);
172 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
173 if( !file ) { usleep(1000); continue; }
175 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
176 file->set_video_position(pos,0);
177 if( file->read_frame(temp) ) temp->clear_frame();
178 add_image(temp, vw, vh, vicon_cmodel);
180 mwindow->video_cache->check_in(asset);
182 return *images[seq_no];
185 int64_t AssetVIcon::set_seq_no(int64_t no)
187 if( no >= length ) no = 0;
191 int AssetVIcon::get_vx()
193 BC_ListBox *lbox = picon->gui->asset_list;
194 return lbox->get_icon_x(picon);
196 int AssetVIcon::get_vy()
198 BC_ListBox *lbox = picon->gui->asset_list;
199 return lbox->get_icon_y(picon);
202 void AssetVIcon::load_audio()
204 MWindow *mwindow = picon->mwindow;
205 Asset *asset = (Asset *)picon->indexable;
206 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
207 int channels = asset->get_audio_channels();
208 if( channels > 2 ) channels = 2;
209 int sample_rate = asset->get_sample_rate();
210 int bfrsz = sample_rate;
211 Samples samples(bfrsz);
212 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
213 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
214 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
215 double sample_scale = (double)mx / channels;
216 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
217 while( audio_pos < audio_len ) {
218 int64_t pos = audio_pos * time_scale;
219 for( int ch=0; ch<channels; ++ch ) {
220 file->set_channel(ch);
221 file->set_audio_position(pos);
222 file->read_samples(&samples, bfrsz);
223 double *data = samples.get_data();
224 for( int64_t k=audio_pos; k<audio_len; ++k ) {
225 int i = k * time_scale - pos;
226 if( i >= bfrsz ) break;
227 int v = audio_data[k] + data[i] * sample_scale;
228 audio_data[k] = CLIP(v, -mx,mx);
231 audio_pos = (pos + bfrsz) / time_scale;
233 mwindow->audio_cache->check_in(asset);
237 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
241 audio = new AudioDevice(gui->mwindow);
245 AssetVIconAudio::~AssetVIconAudio()
250 void AssetVIconAudio::run()
253 int64_t bfrsz = VICON_SAMPLE_RATE;
254 MWindow *mwindow = gui->mwindow;
255 EDL *edl = mwindow->edl;
256 EDLSession *session = edl->session;
257 AudioOutConfig *aconfig = session->playback_config->aconfig;
258 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
259 audio->start_playback();
260 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
261 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
262 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
264 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
265 while( !interrupted ) {
266 int len = audio_len - audio_pos;
267 if( len <= 0 ) break;
268 if( len > bfrsz ) len = bfrsz;
270 for( int i=0; i<len; ++i,++k )
271 out0[i] = out1[i] = (double)audio_data[k] / mx;
273 audio->write_buffer(out, channels, len);
277 audio->set_last_buffer();
278 audio->stop_audio(interrupted ? 0 : 1);
282 void AssetVIconAudio::start(AssetVIcon *vicon)
284 if( running() ) return;
286 double pos = vicon->length > 0 ? (double)vicon->seq_no/vicon->length : 0;
287 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
288 audio_pos = pos * audio_len;
293 void AssetVIconAudio::stop(int wait)
295 if( running() && !interrupted ) {
297 audio->stop_audio(wait);
301 vicon->playing_audio = 0;
306 void AssetVIcon::start_audio()
308 if( playing_audio < 0 ) return;
309 picon->gui->vicon_audio->stop(0);
311 picon->gui->vicon_audio->start(this);
314 void AssetVIcon::stop_audio()
316 if( playing_audio > 0 ) {
317 picon->gui->vicon_audio->stop(0);
322 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
323 int x, int y, int w, int h)
324 : ViewPopup(vt, x, y, w, h)
326 this->draw_mode = draw_mode;
327 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
331 AssetViewPopup::~AssetViewPopup()
335 int AssetViewPopup::reposition_window(int x, int y, int w, int h)
337 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
338 return ViewPopup::reposition_window(x, y, w, h);
341 int AssetViewPopup::button_press_event()
343 if( !is_event_win() ) return 0;
344 AssetVIconThread *avt = (AssetVIconThread *)vt;
345 if( !avt->vicon ) return 0;
348 switch( get_buttonpress() ) {
352 avt->set_view_popup(0);
355 dir = -1; // fall thru
357 switch( draw_mode ) {
358 case ASSET_VIEW_MEDIA:
359 case ASSET_VIEW_MEDIA_MAP:
360 avt->zoom_scale(dir);
367 int x = get_cursor_x(), y = get_cursor_y();
368 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
369 AssetPicon *picon = vicon->picon;
370 MWindow *mwindow = picon->mwindow;
371 EDL *edl = mwindow->edl;
373 if( y < get_h()/2 ) {
375 picon->indexable ? picon->indexable :
376 picon->edl ? picon->edl : 0;
377 if( !idxbl ) return 0;
378 double sample_rate = idxbl->get_sample_rate();
379 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
380 idxbl->get_audio_samples() / sample_rate : 0;
381 double frame_rate = idxbl->get_frame_rate();
382 double video_length = frame_rate > 0 && idxbl->have_video() ?
383 idxbl->get_video_frames() / frame_rate : 0;
384 double idxbl_length = bmax(audio_length, video_length);
385 double pos = x * idxbl_length / get_w();
386 double start = 0, end = idxbl_length;
387 double lt = DBL_MAX, rt = DBL_MAX;
388 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
389 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
390 Indexable *indexable = (Indexable *)edit->asset;
391 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
392 if( !indexable ) continue;
393 if( indexable->id == idxbl->id ||
394 (!indexable->is_asset == !idxbl->is_asset &&
395 !strcmp(indexable->path, idxbl->path)) ) {
396 double start_pos = track->from_units(edit->startsource);
397 double end_pos = track->from_units(edit->startsource + edit->length);
398 double dlt = pos - start_pos, drt = end_pos - pos;
399 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
400 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
401 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
402 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
406 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
407 VWindow *vwindow = mwindow->get_viewer(1, 0);
408 vwindow->change_source(idxbl);
409 mwindow->gui->unlock_window();
410 EDL *vedl = vwindow->get_edl();
411 vedl->set_inpoint(start);
412 vedl->set_outpoint(end);
413 vedl->local_session->set_selectionstart(start);
414 vedl->local_session->set_selectionend(start);
415 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
416 vwindow->update_position();
417 vwindow->gui->unlock_window();
422 if( !ctrl_down() && !shift_down() )
423 return cursor_motion_event();
425 picon->indexable ? picon->indexable :
426 picon->edl ? picon->edl : 0;
427 if( !idxbl ) return 0;
428 double total_length = mwindow->edl->tracks->total_length();
429 double pos = x * total_length / get_w();
430 double start = 0, end = total_length;
431 double lt = DBL_MAX, rt = DBL_MAX;
432 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
433 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
434 Indexable *indexable = (Indexable *)edit->asset;
435 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
436 if( !indexable ) continue;
437 if( indexable->id == idxbl->id ||
438 (!indexable->is_asset == !idxbl->is_asset &&
439 !strcmp(indexable->path, idxbl->path)) ) {
440 double start_pos = track->from_units(edit->startproject);
441 double end_pos = track->from_units(edit->startproject + edit->length);
442 double dlt = pos - start_pos, drt = end_pos - pos;
443 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
444 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
445 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
446 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
450 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
451 mwindow->select_point(start);
452 edl->local_session->set_selectionstart(start);
453 edl->local_session->set_selectionend(!shift_down() ? start : end);
454 mwindow->zoom_sample(edl->local_session->zoom_sample);
455 mwindow->gui->unlock_window();
461 int AssetViewPopup::button_release_event()
463 if( !is_event_win() ) return 0;
468 int AssetViewPopup::cursor_motion_event()
470 AssetVIconThread *avt = (AssetVIconThread *)vt;
471 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
472 if( vicon && dragging && is_event_win() &&
473 get_button_down() && get_buttonpress() == LEFT_BUTTON &&
474 !ctrl_down() && !alt_down() && !shift_down() ) {
475 switch( draw_mode ) {
476 case ASSET_VIEW_MEDIA_MAP:
477 case ASSET_VIEW_FULL:
478 MWindow *mwindow = vicon->picon->mwindow;
479 EDL *edl = mwindow->edl;
480 int x = get_cursor_x();
481 double total_length = edl->tracks->total_length();
482 double pos = x * total_length / get_w();
483 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
484 mwindow->select_point(pos);
485 mwindow->zoom_sample(edl->local_session->zoom_sample);
486 mwindow->gui->unlock_window();
493 void AssetViewPopup::draw_vframe(VFrame *vframe)
495 switch( draw_mode ) {
496 case ASSET_VIEW_MEDIA:
497 case ASSET_VIEW_ICON:
498 ViewPopup::draw_vframe(vframe);
499 case ASSET_VIEW_NONE:
502 case ASSET_VIEW_MEDIA_MAP:
503 case ASSET_VIEW_FULL:
507 draw_box(0,0,get_w(),get_h());
509 int y2 = get_h()-bar_h;
510 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
511 AssetVIconThread *avt = (AssetVIconThread *)vt;
512 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
513 AssetPicon *picon = (AssetPicon *)vicon->picon;
515 picon->indexable ? picon->indexable :
516 picon->edl ? picon->edl : 0;
518 double sample_rate = idxbl->get_sample_rate();
519 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
520 idxbl->get_audio_samples() / sample_rate : 0;
521 double frame_rate = idxbl->get_frame_rate();
522 double video_length = frame_rate > 0 && idxbl->have_video() ?
523 idxbl->get_video_frames() / frame_rate : 0;
524 double idxbl_length = bmax(audio_length, video_length);
525 if( !idxbl_length ) idxbl_length = 1;
527 EDL *edl = picon->mwindow->edl;
528 double total_length = edl->tracks->total_length();
529 if( !total_length ) total_length = 1;
530 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
531 if( !track->record ) continue;
532 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
533 Indexable *indexable = (Indexable *)edit->asset;
534 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
535 if( !indexable ) continue;
536 if( indexable->id == idxbl->id ||
537 (!indexable->is_asset == !idxbl->is_asset &&
538 !strcmp(indexable->path, idxbl->path)) ) {
539 double pos1 = track->from_units(edit->startsource);
540 double pos2 = track->from_units(edit->startsource + edit->length);
541 double xscale = get_w() / idxbl_length;
542 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
544 draw_box(ex1,0, ex2-ex1,y1);
546 draw_line(ex1,0, ex1,y1);
547 draw_line(ex2,0, ex2,y1);
548 pos1 = track->from_units(edit->startproject);
549 pos2 = track->from_units(edit->startproject + edit->length);
550 xscale = get_w() / total_length;
551 int px1 = pos1 * xscale, px2 = pos2 * xscale;
553 draw_box(px1,y2, px2-px1,get_h()-y2);
555 draw_line(px1,y2, px1,get_h()-1);
556 draw_line(px2,y2, px2,get_h()-1);
559 draw_line(ex1,y1, px1,y2);
560 draw_line(ex2,y1, px2,y2);
566 int AssetViewPopup::keypress_event()
569 AssetVIconThread *avt = (AssetVIconThread *)vt;
570 switch( avt->draw_mode ) {
571 case ASSET_VIEW_MEDIA_MAP:
572 switch( get_keypress() ) {
575 avt->draw_mode = ASSET_VIEW_FULL;
579 case ASSET_VIEW_FULL:
580 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
583 if( result ) // zero change for refresh
585 return ViewPopup::keypress_event();
589 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
590 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
591 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
594 draw_mode = ASSET_VIEW_NONE;
595 int vicon_cmodel = BC_RGB8;
596 switch( preferences->vicon_color_mode ) {
597 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
598 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
599 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
601 this->vicon_cmodel = vicon_cmodel;
602 this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
605 AssetVIconThread::~AssetVIconThread()
610 void AssetVIconThread::drawing_started()
612 draw_lock->lock("AssetVIconThread::drawing_started");
615 void AssetVIconThread::drawing_stopped()
620 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
622 gui->stop_vicon_drawing();
623 this->draw_mode = draw_mode;
625 gui->start_vicon_drawing();
628 void AssetVIconThread::set_view_popup(AssetVIcon *v)
630 if( !v ) draw_mode = ASSET_VIEW_NONE;
631 VIconThread::set_view_popup(v);
634 ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
636 BC_WindowBase *parent = wdw->get_parent();
637 int rx = 0, ry = 0, rw = 0, rh = 0;
638 if( draw_mode != ASSET_VIEW_FULL ) {
639 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
640 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
641 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
642 int vx = viewing->get_vx(), vy = viewing->get_vy();
643 wdw->get_root_coordinates(vx, vy, &rx, &ry);
644 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
645 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
646 rw = view_w; rh = view_h;
649 parent->get_fullscreen_geometry(rx, ry, rw, rh);
650 AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
652 av_popup->reposition_window(rx, ry, rw, rh);
654 av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
655 int playing_audio = gui->play_off ? -1 : 0;
656 if( !playing_audio ) {
657 switch( draw_mode ) {
658 case ASSET_VIEW_NONE:
659 case ASSET_VIEW_ICON:
660 case ASSET_VIEW_MEDIA_MAP:
661 case ASSET_VIEW_FULL:
664 case ASSET_VIEW_MEDIA:
665 switch( gui->vicon_drawing ) {
666 case AVICON_SRC_TARGET:
673 vicon->playing_audio = playing_audio;
674 wdw->set_active_subwindow(av_popup);
678 void AssetVIconThread::close_view_popup()
681 drawing_started(); // waits for draw lock
686 AWindowFolderItem::AWindowFolderItem()
692 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
693 : BC_ListBoxItem(text, color)
698 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
699 : BC_ListBoxItem(text, icon, color)
704 AssetPicon *AWindowFolderItem::get_picon()
706 AWindowFolderItem *item = this;
707 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
708 return (AssetPicon*)item;
711 int AWindowFolderSubItems::matches(const char *text)
713 int i = names.size();
714 while( --i >= 0 && strcmp(names[i], text) );
716 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
717 i = sublist ? sublist->size() : 0;
719 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
720 if( item->matches(text) ) break;
723 return i >= 0 ? 1 : 0;
727 AssetPicon::AssetPicon(MWindow *mwindow,
728 AWindowGUI *gui, Indexable *indexable)
729 : AWindowFolderItem()
732 this->mwindow = mwindow;
734 this->indexable = indexable;
735 indexable->add_user();
736 this->id = indexable->id;
739 AssetPicon::AssetPicon(MWindow *mwindow,
740 AWindowGUI *gui, EDL *edl)
741 : AWindowFolderItem()
744 this->mwindow = mwindow;
751 AssetPicon::AssetPicon(MWindow *mwindow,
752 AWindowGUI *gui, int folder, int persist)
753 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
754 folder>=0 && folder<AWINDOW_FOLDERS ?
755 gui->folder_icons[folder] : gui->folder_icon)
759 this->mwindow = mwindow;
761 persistent = persist;
764 AssetPicon::AssetPicon(MWindow *mwindow,
765 AWindowGUI *gui, int folder, const char *title)
766 : AWindowFolderItem(title, gui->folder_icon)
770 this->mwindow = mwindow;
775 AssetPicon::AssetPicon(MWindow *mwindow,
776 AWindowGUI *gui, PluginServer *plugin)
777 : AWindowFolderItem()
780 this->mwindow = mwindow;
782 this->plugin = plugin;
785 AssetPicon::AssetPicon(MWindow *mwindow,
786 AWindowGUI *gui, Label *label)
787 : AWindowFolderItem()
790 this->mwindow = mwindow;
798 AssetPicon::~AssetPicon()
800 if( vicon ) vicon->remove_user();
802 if( indexable ) indexable->remove_user();
803 if( edl ) edl->remove_user();
804 if( icon && !gui->protected_pixmap(icon) ) {
806 if( !plugin ) delete icon_vframe;
810 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
812 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
814 float h = 300 * t, s = 1., v = 1.;
815 float r, g, b; // duration, 0..1hr == hue red..magenta
816 HSV::hsv_to_rgb(r,g,b, h,s,v);
817 int ih = frame->get_h()/8, iw = frame->get_w();
818 int ir = r * 256; CLAMP(ir, 0,255);
819 int ig = g * 256; CLAMP(ig, 0,255);
820 int ib = b * 256; CLAMP(ib, 0,255);
821 unsigned char **rows = frame->get_rows();
822 for( int y=0; y<ih; ++y ) {
823 unsigned char *rp = rows[y];
824 for( int x=0; x<iw; rp+=3,++x ) {
825 rp[0] = ir; rp[1] = ig; rp[2] = ib;
830 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
831 int base_color, int line_color, int x, int y, int w, int h)
833 int h1 = h-1, h2 = h/2, iy = h2;
834 int rgb_color = frame->pixel_rgb;
835 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
836 double min = *dp, max = min;
837 x2 = (len * (ix+1))/w;
838 for( int i=x1; i<x2; ++i ) {
839 double value = *dp++;
840 if( value < min ) min = value;
841 if( value > max ) max = value;
843 int ctr = (min + max) / 2;
844 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
845 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
846 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
847 frame->pixel_rgb = line_color;
848 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
849 frame->pixel_rgb = base_color;
850 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
853 frame->pixel_rgb = rgb_color;
856 void AssetPicon::reset()
864 foldernum = AW_NO_FOLDER;
879 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
881 TransportCommand command;
882 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
883 command.get_edl()->copy_all(edl);
884 command.change_type = CHANGE_ALL;
885 command.realtime = 0;
886 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
887 render_engine->set_vcache(mwindow->video_cache);
888 render_engine->set_acache(mwindow->audio_cache);
889 render_engine->arm_command(&command);
891 void AssetPicon::close_render_engine()
893 delete render_engine; render_engine = 0;
895 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
897 if( !render_engine || !render_engine->vrender ) return;
898 render_engine->vrender->process_buffer(vfrm, pos, 0);
900 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
902 if( !render_engine || !render_engine->arender ) return;
903 render_engine->arender->process_buffer(samples, len, pos);
906 void AssetPicon::create_objects()
909 char name[BCTEXTLEN];
910 int pixmap_w, pixmap_h;
912 int picon_h = mwindow->preferences->awindow_picon_h;
913 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
919 if( this->indexable ) {
920 fs.extract_name(name, indexable->path);
922 if( this->indexable->is_asset )
923 asset = (Asset *)indexable;
925 edl = (EDL *)indexable;
927 else if( this->edl ) {
929 set_text(strcpy(name, edl->local_session->clip_title));
935 if( asset->video_data ) {
936 if( mwindow->preferences->use_thumbnails ) {
937 gui->unlock_window();
938 File *file = mwindow->video_cache->check_out(asset,
943 int height = asset->height > 0 ? asset->height : 1;
944 pixmap_w = pixmap_h * asset->width / height;
947 file->set_video_position(0, 0);
949 if( gui->temp_picon &&
950 (gui->temp_picon->get_w() != asset->width ||
951 gui->temp_picon->get_h() != asset->height) ) {
952 delete gui->temp_picon;
956 if( !gui->temp_picon ) {
957 gui->temp_picon = new VFrame(0, -1,
958 asset->width, asset->height,
961 { char string[BCTEXTLEN];
962 sprintf(string, _("Reading %s"), name);
963 mwindow->gui->lock_window("AssetPicon::create_objects");
964 mwindow->gui->show_message(string);
965 mwindow->gui->unlock_window(); }
966 file->read_frame(gui->temp_picon);
967 mwindow->video_cache->check_in(asset);
969 gui->lock_window("AssetPicon::create_objects 0");
970 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
971 icon->draw_vframe(gui->temp_picon,
972 0, 0, pixmap_w, pixmap_h, 0, 0);
973 icon_vframe = new VFrame(0,
974 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
975 icon_vframe->transfer_from(gui->temp_picon);
976 if( asset->folder_no == AW_MEDIA_FOLDER ||
977 asset->folder_no == AW_PROXY_FOLDER ) {
979 double framerate = asset->get_frame_rate();
980 if( !framerate ) framerate = VICON_RATE;
981 int64_t frames = asset->get_video_frames();
982 double secs = frames / framerate;
983 if( secs > 5 ) secs = 5;
984 int64_t length = secs * gui->vicon_thread->refresh_rate;
985 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
986 if( asset->audio_data && secs > 0 ) {
987 gui->unlock_window();
988 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
989 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
991 gui->lock_window("AssetPicon::create_objects 1");
993 gui->vicon_thread->add_vicon(vicon);
997 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
998 gui->lock_window("AssetPicon::create_objects 2");
999 icon = gui->video_icon;
1000 icon_vframe = gui->video_vframe;
1004 icon = gui->video_icon;
1005 icon_vframe = gui->video_vframe;
1009 if( asset->audio_data ) {
1010 if( mwindow->preferences->use_thumbnails ) {
1011 gui->unlock_window();
1012 File *file = mwindow->audio_cache->check_out(asset,
1016 pixmap_w = pixmap_h * 16/9;
1017 icon_vframe = new VFrame(0,
1018 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1019 icon_vframe->clear_frame();
1020 { char string[BCTEXTLEN];
1021 sprintf(string, _("Reading %s"), name);
1022 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1023 mwindow->gui->show_message(string);
1024 mwindow->gui->unlock_window(); }
1025 int sample_rate = asset->get_sample_rate();
1026 int channels = asset->get_audio_channels();
1027 if( channels > 2 ) channels = 2;
1028 int64_t audio_samples = asset->get_audio_samples();
1029 double duration = (double)audio_samples / sample_rate;
1030 draw_hue_bar(icon_vframe, duration);
1031 int bfrsz = sample_rate;
1032 Samples samples(bfrsz);
1033 static int line_colors[2] = { GREEN, YELLOW };
1034 static int base_colors[2] = { RED, PINK };
1035 for( int i=channels; --i>=0; ) {
1036 file->set_channel(i);
1037 file->set_audio_position(0);
1038 file->read_samples(&samples, bfrsz);
1039 draw_wave(icon_vframe, samples.get_data(), bfrsz,
1040 base_colors[i], line_colors[i]);
1042 mwindow->audio_cache->check_in(asset);
1043 if( asset->folder_no == AW_MEDIA_FOLDER ) {
1044 double secs = duration;
1045 if( secs > 5 ) secs = 5;
1046 double refresh_rate = gui->vicon_thread->refresh_rate;
1047 int64_t length = secs * refresh_rate;
1048 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1049 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1050 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1051 vicon->load_audio();
1052 gui->vicon_thread->add_vicon(vicon);
1054 gui->lock_window("AssetPicon::create_objects 4");
1055 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1056 icon->draw_vframe(icon_vframe,
1057 0, 0, pixmap_w, pixmap_h, 0, 0);
1060 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1061 gui->lock_window("AssetPicon::create_objects 5");
1062 icon = gui->audio_icon;
1063 icon_vframe = gui->audio_vframe;
1067 icon = gui->audio_icon;
1068 icon_vframe = gui->audio_vframe;
1073 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1074 comments_rate = asset->get_frame_rate();
1075 comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
1076 comments_type = asset->format == FILE_FFMPEG ?
1077 asset->vcodec : File::formattostr(asset->format);
1080 if( edl->tracks->playable_video_tracks() ) {
1081 if( mwindow->preferences->use_thumbnails ) {
1082 gui->unlock_window();
1083 AssetVIconThread *avt = gui->vicon_thread;
1084 char clip_icon_path[BCTEXTLEN];
1085 char *clip_icon = edl->local_session->clip_icon;
1087 if( is_clip && clip_icon[0] ) {
1088 snprintf(clip_icon_path, sizeof(clip_icon_path),
1089 "%s/%s", File::get_config_path(), clip_icon);
1090 vframe = VFramePng::vframe_png(clip_icon_path);
1093 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1094 delete vframe; vframe = 0;
1096 int edl_h = edl->get_h(), edl_w = edl->get_w();
1097 int height = edl_h > 0 ? edl_h : 1;
1098 int width = edl_w > 0 ? edl_w : 1;
1099 int color_model = edl->session->color_model;
1101 //printf("render clip: %s\n", name);
1102 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1103 char string[BCTEXTLEN];
1104 sprintf(string, _("Rendering %s"), name);
1105 mwindow->gui->lock_window("AssetPicon::create_objects");
1106 mwindow->gui->show_message(string);
1107 mwindow->gui->unlock_window();
1108 open_render_engine(edl, 0);
1109 render_video(0, gui->temp_picon);
1110 close_render_engine();
1111 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1112 vframe->transfer_from(gui->temp_picon);
1113 if( this->edl && clip_icon[0] )
1114 vframe->write_png(clip_icon_path);
1116 pixmap_w = pixmap_h * width / height;
1117 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1118 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1119 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1120 icon_vframe->transfer_from(vframe);
1122 gui->lock_window("AssetPicon::create_objects 0");
1123 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1124 icon->draw_vframe(icon_vframe,
1125 0, 0, pixmap_w, pixmap_h, 0, 0);
1127 else if( is_clip ) {
1128 icon = gui->clip_icon;
1129 icon_vframe = gui->clip_vframe;
1132 icon = gui->video_icon;
1133 icon_vframe = gui->video_vframe;
1137 if( edl->tracks->playable_audio_tracks() ) {
1138 if( mwindow->preferences->use_thumbnails ) {
1139 gui->unlock_window();
1140 char clip_icon_path[BCTEXTLEN];
1141 char *clip_icon = edl->local_session->clip_icon;
1142 if( is_clip && clip_icon[0] ) {
1143 snprintf(clip_icon_path, sizeof(clip_icon_path),
1144 "%s/%s", File::get_config_path(), clip_icon);
1145 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1147 if( !icon_vframe ) {
1148 pixmap_w = pixmap_h * 16/9;
1149 icon_vframe = new VFrame(0,
1150 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1151 icon_vframe->clear_frame();
1152 char string[BCTEXTLEN];
1153 sprintf(string, _("Rendering %s"), name);
1154 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1155 mwindow->gui->show_message(string);
1156 mwindow->gui->unlock_window();
1157 int sample_rate = edl->get_sample_rate();
1158 int channels = edl->get_audio_channels();
1159 if( channels > 2 ) channels = 2;
1160 int64_t audio_samples = edl->get_audio_samples();
1161 double duration = (double)audio_samples / sample_rate;
1162 draw_hue_bar(icon_vframe, duration);
1163 Samples *samples[MAX_CHANNELS];
1164 int bfrsz = sample_rate;
1165 for( int i=0; i<MAX_CHANNELS; ++i )
1166 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1167 open_render_engine(edl, 1);
1168 render_audio(0, samples, bfrsz);
1169 close_render_engine();
1170 gui->lock_window("AssetPicon::create_objects 4");
1171 static int line_colors[2] = { GREEN, YELLOW };
1172 static int base_colors[2] = { RED, PINK };
1173 for( int i=channels; --i>=0; ) {
1174 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1175 base_colors[i], line_colors[i]);
1177 for( int i=0; i<channels; ++i ) delete samples[i];
1178 if( is_clip && clip_icon[0] )
1179 icon_vframe->write_png(clip_icon_path);
1182 pixmap_w = icon_vframe->get_w();
1183 pixmap_h = icon_vframe->get_h();
1185 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1186 icon->draw_vframe(icon_vframe,
1187 0, 0, pixmap_w, pixmap_h, 0, 0);
1189 else if( !indexable ) {
1190 icon = gui->clip_icon;
1191 icon_vframe = gui->clip_vframe;
1194 icon = gui->audio_icon;
1195 icon_vframe = gui->audio_vframe;
1200 strcpy(name, _(plugin->title));
1202 icon_vframe = plugin->get_picon();
1204 icon = gui->create_pixmap(icon_vframe);
1205 else if( plugin->audio ) {
1206 if( plugin->transition ) {
1207 icon = gui->atransition_icon;
1208 icon_vframe = gui->atransition_vframe;
1210 else if( plugin->is_ffmpeg() ) {
1211 icon = gui->ff_aud_icon;
1212 icon_vframe = gui->ff_aud_vframe;
1214 else if( plugin->is_ladspa() ) {
1215 icon = gui->ladspa_icon;
1216 icon_vframe = gui->ladspa_vframe;
1219 icon = gui->aeffect_icon;
1220 icon_vframe = gui->aeffect_vframe;
1223 else if( plugin->video ) {
1224 if( plugin->transition ) {
1225 icon = gui->vtransition_icon;
1226 icon_vframe = gui->vtransition_vframe;
1228 else if( plugin->is_ffmpeg() ) {
1229 icon = gui->ff_vid_icon;
1230 icon_vframe = gui->ff_vid_vframe;
1233 icon = gui->veffect_icon;
1234 icon_vframe = gui->veffect_vframe;
1241 mwindow->edl->session->time_format,
1242 mwindow->edl->session->sample_rate,
1243 mwindow->edl->session->frame_rate,
1244 mwindow->edl->session->frames_per_foot);
1246 icon = gui->label_icon;
1247 icon_vframe = gui->label_vframe;
1250 icon = gui->file_icon;
1251 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1254 set_icon_vframe(icon_vframe);
1257 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1258 : BC_Window(_(PROGRAM_NAME ": Resources"),
1259 mwindow->session->awindow_x, mwindow->session->awindow_y,
1260 mwindow->session->awindow_w, mwindow->session->awindow_h,
1263 this->mwindow = mwindow;
1264 this->awindow = awindow;
1266 file_vframe = 0; file_icon = 0;
1267 folder_vframe = 0; folder_icon = 0;
1268 audio_vframe = 0; audio_icon = 0;
1269 video_vframe = 0; video_icon = 0;
1270 label_vframe = 0; label_icon = 0;
1272 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1273 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1274 clip_folder_vframe = 0; clip_folder_icon = 0;
1275 label_folder_vframe = 0; label_folder_icon = 0;
1276 media_folder_vframe = 0; media_folder_icon = 0;
1277 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1278 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1279 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1281 ladspa_vframe = 0; ladspa_icon = 0;
1282 ff_aud_vframe = 0; ff_aud_icon = 0;
1283 ff_vid_vframe = 0; ff_vid_icon = 0;
1285 clip_vframe = 0; clip_icon = 0;
1286 atransition_vframe = 0; atransition_icon = 0;
1287 vtransition_vframe = 0; vtransition_icon = 0;
1288 aeffect_vframe = 0; aeffect_icon = 0;
1289 veffect_vframe = 0; veffect_icon = 0;
1291 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1293 effectlist_menu = 0;
1298 folderlist_menu = 0;
1301 allow_iconlisting = 1;
1305 vicon_drawing = AVICON_FULL_PLAY;
1307 displayed_folder = AW_NO_FOLDER;
1308 new_folder_thread = 0;
1309 modify_folder_thread = 0;
1310 folder_lock = new Mutex("AWindowGUI::folder_lock");
1313 AWindowGUI::~AWindowGUI()
1315 assets.remove_all_objects();
1316 folders.remove_all_objects();
1317 aeffects.remove_all_objects();
1318 veffects.remove_all_objects();
1319 atransitions.remove_all_objects();
1320 vtransitions.remove_all_objects();
1321 labellist.remove_all_objects();
1322 displayed_assets[1].remove_all_objects();
1324 delete new_folder_thread;
1325 delete modify_folder_thread;
1326 delete vicon_thread;
1331 delete remove_plugin;
1333 delete file_vframe; delete file_icon;
1334 delete folder_vframe; delete folder_icon;
1335 delete audio_vframe; delete audio_icon;
1336 delete video_vframe; delete video_icon;
1337 delete label_vframe; delete label_icon;
1338 delete clip_vframe; delete clip_icon;
1339 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1340 delete atransition_folder_vframe; delete atransition_folder_icon;
1341 delete veffect_folder_vframe; delete veffect_folder_icon;
1342 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1343 delete clip_folder_vframe; delete clip_folder_icon;
1344 delete label_folder_vframe; delete label_folder_icon;
1345 delete media_folder_vframe; delete media_folder_icon;
1346 delete proxy_folder_vframe; delete proxy_folder_icon;
1347 delete ladspa_vframe; delete ladspa_icon;
1348 delete ff_aud_vframe; delete ff_aud_icon;
1349 delete ff_vid_vframe; delete ff_vid_icon;
1350 delete atransition_vframe; delete atransition_icon;
1351 delete vtransition_vframe; delete vtransition_icon;
1352 delete aeffect_vframe; delete aeffect_icon;
1353 delete veffect_vframe; delete veffect_icon;
1357 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1359 return icon == file_icon ||
1360 icon == folder_icon ||
1361 icon == audio_icon ||
1362 icon == video_icon ||
1363 icon == clip_icon ||
1364 icon == label_icon ||
1365 icon == vtransition_icon ||
1366 icon == atransition_icon ||
1367 icon == veffect_icon ||
1368 icon == aeffect_icon ||
1369 icon == ladspa_icon ||
1370 icon == ff_aud_icon ||
1371 icon == ff_vid_icon ||
1372 icon == aeffect_folder_icon ||
1373 icon == veffect_folder_icon ||
1374 icon == atransition_folder_icon ||
1375 icon == vtransition_folder_icon ||
1376 icon == label_folder_icon ||
1377 icon == clip_folder_icon ||
1378 icon == media_folder_icon ||
1379 icon == proxy_folder_icon;
1382 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1384 char png_path[BCTEXTLEN];
1385 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1386 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1387 File::get_plugin_path(), plugin_icons, name);
1388 if( access(png_path, R_OK) ) return 0;
1389 return VFramePng::vframe_png(png_path,0,0);
1392 VFrame *AWindowGUI::get_picon(const char *name)
1394 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1396 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1397 snprintf(pp, ep-pp, "%s.png", name);
1398 unsigned char *data = mwindow->theme->get_image_data(png_name);
1399 if( data ) vframe = new VFramePng(data, 0.);
1404 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1406 vfrm = get_picon(fn);
1407 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1408 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1410 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1412 vfrm = get_picon(fn);
1413 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1414 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1416 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1418 vfrm = get_picon(fn);
1419 if( !vfrm ) vfrm = new VFramePng(png);
1420 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1423 void AWindowGUI::create_objects()
1425 lock_window("AWindowGUI::create_objects");
1426 asset_titles[0] = C_("Title");
1427 asset_titles[1] = _("Comments");
1429 set_icon(mwindow->theme->get_image("awindow_icon"));
1431 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1432 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1433 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1434 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1435 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1437 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1438 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1439 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1440 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1441 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1442 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1443 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1444 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1446 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1447 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1448 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1449 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1450 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1451 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1452 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1453 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1455 theme_icon(clip_vframe, clip_icon, "clip_icon");
1456 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1457 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1458 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1459 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1461 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1462 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1463 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1464 folder_lock->lock("AWindowGUI::create_objects");
1465 // Mandatory folders
1466 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1467 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1468 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1469 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1470 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1471 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1472 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1473 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1475 create_label_folder();
1476 folder_lock->unlock();
1478 mwindow->theme->get_awindow_sizes(this);
1479 load_defaults(mwindow->defaults);
1480 new_folder_thread = new NewFolderThread(this);
1481 modify_folder_thread = new ModifyFolderThread(this);
1483 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1484 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1485 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1486 search_text->create_objects();
1487 int dy = search_text->get_h() + 10;
1489 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1491 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1492 asset_list->update_vicon_area();
1493 vicon_thread->start();
1494 vicon_audio = new AssetVIconAudio(this);
1496 add_subwindow(divider = new AWindowDivider(mwindow, this,
1497 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1498 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1500 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1502 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1503 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1504 int n = sizeof(AVIconDrawing::avicon_names)/sizeof(AVIconDrawing::avicon_names[0]);
1505 int tw = 0; const char **av_names = AVIconDrawing::avicon_names;
1506 for( int i=0; i<n; ++i ) {
1507 int nw = get_text_width(MEDIUMFONT, _(av_names[i]));
1508 if( tw < nw ) tw = nw;
1510 int pw = BC_PopupMenu::calculate_w(16, tw, 1);
1511 const char *text = _(AVIconDrawing::avicon_names[vicon_drawing]);
1512 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw, fy, pw, text));
1513 avicon_drawing->create_objects();
1514 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1515 add_tools->create_objects();
1516 fy += add_tools->get_h(); fh -= add_tools->get_h();
1517 add_subwindow(folder_list = new AWindowFolders(mwindow,
1518 this, fx, fy, fw, fh));
1520 folder_list->load_expanders();
1522 //int x = mwindow->theme->abuttons_x;
1523 //int y = mwindow->theme->abuttons_y;
1525 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1526 asset_menu->create_objects();
1527 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1528 clip_menu->create_objects();
1529 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1530 label_menu->create_objects();
1531 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1532 proxy_menu->create_objects();
1534 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1535 effectlist_menu->create_objects();
1536 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1537 assetlist_menu->create_objects();
1538 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1539 cliplist_menu->create_objects();
1540 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1541 labellist_menu->create_objects();
1542 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1543 proxylist_menu->create_objects();
1545 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1546 folderlist_menu->create_objects();
1548 create_custom_xatoms();
1552 int AWindowGUI::resize_event(int w, int h)
1554 mwindow->session->awindow_x = get_x();
1555 mwindow->session->awindow_y = get_y();
1556 mwindow->session->awindow_w = w;
1557 mwindow->session->awindow_h = h;
1559 mwindow->theme->get_awindow_sizes(this);
1560 mwindow->theme->draw_awindow_bg(this);
1561 reposition_objects();
1563 // int x = mwindow->theme->abuttons_x;
1564 // int y = mwindow->theme->abuttons_y;
1565 // new_bin->reposition_window(x, y);
1566 // x += new_bin->get_w();
1567 // delete_bin->reposition_window(x, y);
1568 // x += delete_bin->get_w();
1569 // rename_bin->reposition_window(x, y);
1570 // x += rename_bin->get_w();
1571 // delete_disk->reposition_window(x, y);
1572 // x += delete_disk->get_w();
1573 // delete_project->reposition_window(x, y);
1574 // x += delete_project->get_w();
1575 // info->reposition_window(x, y);
1576 // x += info->get_w();
1577 // redraw_index->reposition_window(x, y);
1578 // x += redraw_index->get_w();
1579 // paste->reposition_window(x, y);
1580 // x += paste->get_w();
1581 // append->reposition_window(x, y);
1582 // x += append->get_w();
1583 // view->reposition_window(x, y);
1585 BC_WindowBase::resize_event(w, h);
1586 asset_list->update_vicon_area();
1590 int AWindowGUI::translation_event()
1592 mwindow->session->awindow_x = get_x();
1593 mwindow->session->awindow_y = get_y();
1597 void AWindowGUI::reposition_objects()
1599 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1600 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1601 search_text->reposition_window(x1, y1+5, w1);
1602 int dy = search_text->get_h() + 10;
1604 asset_list->reposition_window(x1, y1, w1, h1);
1605 divider->reposition_window(
1606 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1607 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1608 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1609 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1610 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1611 avicon_drawing->reposition_window(fw-avicon_drawing->get_w(), fy);
1612 fy += add_tools->get_h(); fh -= add_tools->get_h();
1613 folder_list->reposition_window(fx, fy, fw, fh);
1616 int AWindowGUI::save_defaults(BC_Hash *defaults)
1618 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1619 defaults->update("VICON_DRAWING", vicon_drawing);
1623 int AWindowGUI::load_defaults(BC_Hash *defaults)
1625 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1626 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1630 int AWindowGUI::close_event()
1633 mwindow->session->show_awindow = 0;
1636 mwindow->gui->lock_window("AWindowGUI::close_event");
1637 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1638 mwindow->gui->unlock_window();
1640 lock_window("AWindowGUI::close_event");
1641 save_defaults(mwindow->defaults);
1642 mwindow->save_defaults();
1646 int AWindowGUI::start_vicon_drawing()
1648 if( play_off ) return stop_vicon_drawing();
1649 if( !vicon_thread->interrupted ) return 1;
1650 switch( vicon_drawing ) {
1651 case AVICON_FULL_PLAY: // all vicons, viewing, target
1653 case AVICON_MOUSE_OVER: // one vicon, viewing, target
1654 if( vicon_thread->solo ) break;
1656 case AVICON_SRC_TARGET: // no vicons, no view, target
1657 case AVICON_NO_PLAY: // no vicons, no view, no target
1660 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1661 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1662 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1663 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1664 switch( mwindow->edl->session->assetlist_format ) {
1666 case ASSETS_ICONS_PACKED:
1667 case ASSETS_ICON_LIST:
1668 asset_list->update_vicon_area();
1669 vicon_thread->start_drawing();
1678 int AWindowGUI::stop_vicon_drawing()
1680 if( !vicon_thread->interrupted )
1681 vicon_thread->stop_drawing();
1685 void AWindowGUI::close_view_popup()
1687 vicon_thread->close_view_popup();
1690 VFrame *AssetPicon::get_vicon_frame()
1692 if( !vicon ) return 0;
1693 if( gui->vicon_thread->interrupted ) return 0;
1694 VFrame *frame = vicon->frame();
1695 if( !frame ) return 0;
1697 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1698 vicon_frame->transfer_from(frame);
1702 int AWindowGUI::cycle_assetlist_format()
1704 EDLSession *session = mwindow->edl->session;
1705 int format = ASSETS_TEXT;
1706 if( allow_iconlisting ) {
1707 switch( session->assetlist_format ) {
1709 format = ASSETS_ICONS;
1712 format = ASSETS_ICONS_PACKED;
1714 case ASSETS_ICONS_PACKED:
1715 format = ASSETS_ICON_LIST;
1717 case ASSETS_ICON_LIST:
1718 format = ASSETS_TEXT;
1722 stop_vicon_drawing();
1723 session->assetlist_format = format;
1724 asset_list->update_format(session->assetlist_format, 0);
1725 async_update_assets();
1726 start_vicon_drawing();
1730 AWindowRemovePluginGUI::
1731 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1732 int x, int y, PluginServer *plugin)
1733 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1735 this->awindow = awindow;
1736 this->thread = thread;
1737 this->plugin = plugin;
1738 VFrame *vframe = plugin->get_picon();
1739 icon = vframe ? create_pixmap(vframe) : 0;
1740 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1743 AWindowRemovePluginGUI::
1744 ~AWindowRemovePluginGUI()
1746 if( !awindow->gui->protected_pixmap(icon) )
1748 plugin_list.remove_all();
1751 void AWindowRemovePluginGUI::create_objects()
1753 lock_window("AWindowRemovePluginGUI::create_objects");
1754 BC_Button *ok_button = new BC_OKButton(this);
1755 add_subwindow(ok_button);
1756 BC_Button *cancel_button = new BC_CancelButton(this);
1757 add_subwindow(cancel_button);
1759 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1760 add_subwindow(title);
1761 y += title->get_h() + 5;
1762 list = new BC_ListBox(x, y,
1763 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1764 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1765 add_subwindow(list);
1770 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1773 for( int i=0; i<folder.size(); ) {
1774 AssetPicon *picon = (AssetPicon *)folder[i];
1775 if( picon->plugin == plugin ) {
1776 folder.remove_object_number(i);
1785 void AWindowRemovePlugin::handle_close_event(int result)
1788 printf(_("remove %s\n"), plugin->path);
1789 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1790 ArrayList<BC_ListBoxItem*> *folder =
1791 plugin->audio ? plugin->transition ?
1792 &awindow->gui->atransitions :
1793 &awindow->gui->aeffects :
1794 plugin->video ? plugin->transition ?
1795 &awindow->gui->vtransitions :
1796 &awindow->gui->veffects :
1798 if( folder ) remove_plugin(plugin, *folder);
1799 MWindow *mwindow = awindow->mwindow;
1800 awindow->gui->unlock_window();
1801 char plugin_path[BCTEXTLEN];
1802 strcpy(plugin_path, plugin->path);
1803 mwindow->plugindb->remove(plugin);
1804 remove(plugin_path);
1805 char index_path[BCTEXTLEN];
1806 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1808 char picon_path[BCTEXTLEN];
1810 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1811 File::get_plugin_path());
1812 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1813 plugin->get_plugin_png_name(png_name);
1814 fs.update(picon_path);
1815 for( int i=0; i<fs.dir_list.total; ++i ) {
1816 char *fs_path = fs.dir_list[i]->path;
1817 if( !fs.is_dir(fs_path) ) continue;
1818 snprintf(png_path, sizeof(picon_path), "%s/%s",
1822 delete plugin; plugin = 0;
1823 awindow->gui->async_update_assets();
1827 AWindowRemovePlugin::
1828 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1831 this->awindow = awindow;
1832 this->plugin = plugin;
1835 AWindowRemovePlugin::
1836 ~AWindowRemovePlugin()
1841 BC_Window* AWindowRemovePlugin::new_gui()
1843 int x = awindow->gui->get_abs_cursor_x(0);
1844 int y = awindow->gui->get_abs_cursor_y(0);
1845 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1846 gui->create_objects();
1850 int AWindowGUI::keypress_event()
1852 switch( get_keypress() ) {
1860 if( !ctrl_down() && !shift_down() ) {
1861 assetlist_menu->load_file->handle_event();
1866 return cycle_assetlist_format();
1868 if( shift_down() && ctrl_down() ) {
1869 PluginServer* plugin = selected_plugin();
1870 if( !plugin ) break;
1871 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1873 remove_plugin->start();
1874 lock_window("AWindowGUI::keypress_event 1");
1878 if( shift_down() ) {
1879 mwindow->awindow->asset_remove->start();
1883 mwindow->remove_assets_from_project(1, 1,
1884 mwindow->session->drag_assets,
1885 mwindow->session->drag_clips);
1886 lock_window("AWindowGUI::keypress_event 2");
1892 if( shift_down() && ctrl_down() ) {
1893 resend_event(mwindow->gui);
1903 int AWindowGUI::create_custom_xatoms()
1905 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1908 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1910 if( event->message_type == UpdateAssetsXAtom ) {
1917 void AWindowGUI::async_update_assets()
1920 event.message_type = UpdateAssetsXAtom;
1921 send_custom_xatom(&event);
1925 void AWindowGUI::update_folder_list()
1927 for( int i = 0; i < folders.total; i++ ) {
1928 AssetPicon *picon = (AssetPicon*)folders.values[i];
1932 // Search assets for folders
1933 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1934 BinFolder *bin_folder = mwindow->edl->folders[i];
1937 for( int j = 0; j < folders.total; j++ ) {
1938 AssetPicon *picon = (AssetPicon*)folders[j];
1939 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1947 const char *title = bin_folder->title;
1948 int folder = bin_folder->awindow_folder;
1949 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1950 picon->create_objects();
1951 folders.append(picon);
1955 // Delete unused non-persistent folders
1956 int do_autoplace = 0;
1957 for( int i=folders.total; --i>=0; ) {
1958 AssetPicon *picon = (AssetPicon*)folders.values[i];
1959 if( !picon->in_use && !picon->persistent ) {
1961 folders.remove_number(i);
1966 folder_list->set_autoplacement(&folders, 0, 1);
1969 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1970 int do_audio, int do_video, int is_realtime, int is_transition)
1972 ArrayList<PluginServer*> plugin_list;
1973 // Get pointers to plugindb entries
1974 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1977 for( int i = 0; i < plugin_list.total; i++ ) {
1978 PluginServer *server = plugin_list.values[i];
1979 int visible = plugin_visibility & (1<<server->dir_idx);
1980 if( !visible ) continue;
1981 // Create new listitem
1982 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1983 picon->create_objects();
1984 output->append(picon);
1988 void AWindowGUI::create_label_folder()
1991 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1992 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1993 picon->create_objects();
1994 labellist.append(picon);
1999 void AWindowGUI::update_asset_list()
2001 ArrayList<AssetPicon *> new_assets;
2002 for( int i = 0; i < assets.total; i++ ) {
2003 AssetPicon *picon = (AssetPicon*)assets.values[i];
2007 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
2008 // Synchronize EDL clips
2009 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
2012 // Look for clip in existing listitems
2013 for( int j = 0; j < assets.total && !exists; j++ ) {
2014 AssetPicon *picon = (AssetPicon*)assets.values[j];
2016 if( picon->id == mwindow->edl->clips[i]->id ) {
2017 picon->edl = mwindow->edl->clips[i];
2018 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
2024 // Create new listitem
2026 AssetPicon *picon = new AssetPicon(mwindow,
2027 this, mwindow->edl->clips[i]);
2028 new_assets.append(picon);
2032 // Synchronize EDL assets
2033 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
2036 // Look for asset in existing listitems
2037 for( int j = 0; j < assets.total && !exists; j++ ) {
2038 AssetPicon *picon = (AssetPicon*)assets.values[j];
2040 if( picon->id == current->id ) {
2041 picon->indexable = current;
2047 // Create new listitem
2049 AssetPicon *picon = new AssetPicon(mwindow,
2051 new_assets.append(picon);
2055 // Synchronize nested EDLs
2056 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
2058 EDL *nested_edl = mwindow->edl->nested_edls[i];
2060 // Look for asset in existing listitems
2061 for( int j=0; j<assets.total && !exists; ++j ) {
2062 AssetPicon *picon = (AssetPicon*)assets.values[j];
2064 if( picon->id == nested_edl->id ) {
2065 picon->indexable = nested_edl;
2071 // Create new listitem
2073 AssetPicon *picon = new AssetPicon(mwindow,
2074 this, (Indexable*)nested_edl);
2075 new_assets.append(picon);
2078 mwindow->gui->unlock_window();
2080 for( int i=0; i<new_assets.size(); ++i ) {
2081 AssetPicon *picon = new_assets[i];
2082 picon->create_objects();
2083 if( picon->indexable )
2084 picon->foldernum = AW_MEDIA_FOLDER;
2085 else if( picon->edl )
2086 picon->foldernum = AW_CLIP_FOLDER;
2087 assets.append(picon);
2090 mwindow->gui->lock_window();
2091 mwindow->gui->default_message();
2092 mwindow->gui->unlock_window();
2094 for( int i = assets.size() - 1; i >= 0; i-- ) {
2095 AssetPicon *picon = (AssetPicon*)assets.get(i);
2096 if( !picon->in_use ) {
2098 assets.remove_number(i);
2101 if( picon->indexable && picon->indexable->is_asset ) {
2102 Asset *asset = (Asset *)picon->indexable;
2104 picon->comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
2105 picon->comments_rate = asset->get_frame_rate();
2106 picon->comments_ffmt = asset->format == FILE_FFMPEG ? '=' : '-';
2107 picon->comments_type = asset->format == FILE_FFMPEG ?
2108 asset->vcodec : File::formattostr(asset->format);
2113 void AWindowGUI::update_picon(Indexable *indexable)
2116 for( int i = 0; i < assets.total; i++ ) {
2117 AssetPicon *picon = (AssetPicon*)assets.values[i];
2118 if( picon->indexable == indexable ||
2119 picon->edl == (EDL *)indexable ) {
2120 char name[BCTEXTLEN];
2122 fs.extract_name(name, indexable->path);
2123 picon->set_text(name);
2124 vicon = picon->vicon;
2129 stop_vicon_drawing();
2130 vicon->clear_images();
2131 vicon->reset(indexable->get_frame_rate());
2132 start_vicon_drawing();
2136 void AWindowGUI::sort_assets()
2138 folder_lock->lock("AWindowGUI::sort_assets");
2139 switch( mwindow->edl->session->awindow_folder ) {
2140 case AW_AEFFECT_FOLDER:
2141 sort_picons(&aeffects);
2143 case AW_VEFFECT_FOLDER:
2144 sort_picons(&veffects);
2146 case AW_ATRANSITION_FOLDER:
2147 sort_picons(&atransitions);
2149 case AW_VTRANSITION_FOLDER:
2150 sort_picons(&vtransitions);
2152 case AW_LABEL_FOLDER:
2153 sort_picons(&labellist);
2156 sort_picons(&assets);
2160 asset_list->update_format(asset_list->get_format(), 0);
2161 folder_lock->unlock();
2165 void AWindowGUI::sort_folders()
2167 folder_lock->lock("AWindowGUI::update_assets");
2168 // folder_list->collapse_recursive(&folders, 0);
2169 folder_list->set_autoplacement(&folders, 0, 1);
2170 sort_picons(&folders);
2171 folder_list->update_format(folder_list->get_format(), 0);
2172 folder_lock->unlock();
2176 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2178 Asset *proxy_asset = (Asset *)indexable;
2179 char path[BCTEXTLEN];
2180 int proxy_scale = mwindow->edl->session->proxy_scale;
2181 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2182 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2183 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2184 // make a clip from proxy video tracks and unproxy audio tracks
2185 EDL *proxy_edl = new EDL(mwindow->edl);
2186 proxy_edl->create_objects();
2187 proxy_edl->set_path(proxy_asset->path);
2188 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2189 strcpy(proxy_edl->local_session->clip_title, path);
2190 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2191 proxy_edl->session->video_tracks = proxy_asset->layers;
2192 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2193 proxy_edl->create_default_tracks();
2194 double length = proxy_asset->frame_rate > 0 ?
2195 ( proxy_asset->video_length >= 0 ?
2196 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2197 ( proxy_edl->session->si_useduration ?
2198 proxy_edl->session->si_duration :
2199 1.0 / proxy_asset->frame_rate ) ) :
2200 1.0 / proxy_edl->session->frame_rate;
2201 Track *current = proxy_edl->tracks->first;
2202 for( int vtrack=0; current; current=NEXT ) {
2203 if( current->data_type != TRACK_VIDEO ) continue;
2204 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2206 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2207 current = proxy_edl->tracks->first;
2208 for( int atrack=0; current; current=NEXT ) {
2209 if( current->data_type != TRACK_AUDIO ) continue;
2210 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2212 proxy_edl->folder_no = AW_PROXY_FOLDER;
2217 void AWindowGUI::collect_assets(int proxy)
2219 mwindow->session->drag_assets->remove_all();
2220 mwindow->session->drag_clips->remove_all();
2221 int i = 0; AssetPicon *result;
2222 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2223 Indexable *indexable = result->indexable;
2224 if( proxy && indexable && indexable->is_asset &&
2225 indexable->folder_no == AW_PROXY_FOLDER ) {
2226 EDL *drag_edl = collect_proxy(indexable);
2227 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2231 mwindow->session->drag_assets->append(indexable);
2235 mwindow->session->drag_clips->append(result->edl);
2241 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2243 // Remove current pointers
2244 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2245 dst[0].remove_all();
2246 dst[1].remove_all_objects();
2248 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2249 int folder = mwindow->edl->session->awindow_folder;
2250 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2251 mwindow->edl->get_folder(folder);
2253 // Create new pointers
2254 for( int i = 0; i < src->total; i++ ) {
2255 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2256 picon = (AssetPicon*)src->values[i];
2257 picon->sort_key = -1;
2258 if( !visible && bin_folder ) {
2259 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2260 picon->indexable ? picon->indexable :
2261 picon->edl ? picon->edl->get_proxy_asset() : 0;
2263 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2264 if( picon->sort_key < 0 ) continue;
2268 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2270 if( !visible && picon->edl && picon->edl->folder_no == folder )
2272 if( visible && sub_items ) {
2273 if( !sub_items->matches(picon->get_text()) )
2277 const char *text = search_text->get_text();
2278 if( text && text[0] )
2279 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2281 if( visible && picon->vicon && picon->vicon->hidden )
2282 picon->vicon->hidden = 0;
2284 BC_ListBoxItem *item2, *item1;
2285 dst[0].append(item1 = picon);
2287 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2290 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2291 else if( picon->comments_time ) {
2292 char date_time[BCSTRLEN];
2293 struct tm stm; localtime_r(&picon->comments_time, &stm);
2294 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d @%0.2f %c%s",
2295 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2296 stm.tm_hour, stm.tm_min, stm.tm_sec,
2297 picon->comments_rate, picon->comments_ffmt,
2298 picon->comments_type);
2299 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2302 dst[1].append(item2 = new BC_ListBoxItem(""));
2303 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2304 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2309 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2311 int done = 0, changed = 0;
2314 for( int i=0; i<src->total-1; ++i ) {
2315 AssetPicon *item1 = (AssetPicon *)src->values[i];
2316 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2317 double v = item2->sort_key - item1->sort_key;
2318 if( v > 0 ) continue;
2320 const char *cp1 = item1->get_text();
2321 const char *bp1 = strrchr(cp1, '/');
2322 if( bp1 ) cp1 = bp1 + 1;
2323 const char *cp2 = item2->get_text();
2324 const char *bp2 = strrchr(cp2, '/');
2325 if( bp2 ) cp2 = bp2 + 1;
2326 if( strcmp(cp2, cp1) >= 0 ) continue;
2328 src->values[i + 1] = item1;
2329 src->values[i] = item2;
2330 done = 0; changed = 1;
2334 for( int i=0; i<src->total; ++i ) {
2335 AssetPicon *item = (AssetPicon *)src->values[i];
2336 item->set_autoplace_icon(1);
2337 item->set_autoplace_text(1);
2342 void AWindowGUI::filter_displayed_assets()
2344 //allow_iconlisting = 1;
2345 asset_titles[0] = C_("Title");
2346 asset_titles[1] = _("Comments");
2347 AssetPicon *picon = 0;
2348 int selected_folder = mwindow->edl->session->awindow_folder;
2349 // Ensure the current folder icon is highlighted
2350 for( int i = 0; i < folders.total; i++ ) {
2351 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2352 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2353 folder_item->set_selected(selected);
2354 if( selected ) picon = folder_item;
2357 ArrayList<BC_ListBoxItem*> *src = &assets;
2358 switch( selected_folder ) {
2359 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2360 case AW_VEFFECT_FOLDER: src = &veffects; break;
2361 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2362 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2363 case AW_LABEL_FOLDER: src = &labellist;
2364 asset_titles[0] = _("Time Stamps");
2365 asset_titles[1] = C_("Title");
2366 //allow_iconlisting = 0;
2369 copy_picons(picon, src);
2373 void AWindowGUI::update_assets()
2375 stop_vicon_drawing();
2376 folder_lock->lock("AWindowGUI::update_assets");
2377 update_folder_list();
2378 update_asset_list();
2379 labellist.remove_all_objects();
2380 create_label_folder();
2382 if( displayed_folder != mwindow->edl->session->awindow_folder )
2383 search_text->clear();
2384 vicon_thread->hide_vicons();
2385 filter_displayed_assets();
2386 folder_lock->unlock();
2388 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2389 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2391 int folder_xposition = folder_list->get_xposition();
2392 int folder_yposition = folder_list->get_yposition();
2393 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2395 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2396 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2398 int asset_xposition = asset_list->get_xposition();
2399 int asset_yposition = asset_list->get_yposition();
2400 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2401 displayed_folder = mwindow->edl->session->awindow_folder;
2402 asset_xposition = asset_yposition = 0;
2404 asset_list->update(displayed_assets, asset_titles,
2405 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2406 asset_xposition, asset_yposition, -1, 0);
2407 asset_list->center_selection();
2410 start_vicon_drawing();
2414 void AWindowGUI::update_effects()
2416 aeffects.remove_all_objects();
2417 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2418 veffects.remove_all_objects();
2419 create_persistent_folder(&veffects, 0, 1, 1, 0);
2420 atransitions.remove_all_objects();
2421 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2422 vtransitions.remove_all_objects();
2423 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2426 int AWindowGUI::drag_motion()
2428 if( get_hidden() ) return 0;
2434 int AWindowGUI::drag_stop()
2436 if( get_hidden() ) return 0;
2440 Indexable* AWindowGUI::selected_asset()
2442 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2443 return picon ? picon->indexable : 0;
2446 PluginServer* AWindowGUI::selected_plugin()
2448 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2449 return picon ? picon->plugin : 0;
2452 AssetPicon* AWindowGUI::selected_folder()
2454 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2465 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2466 : BC_SubWindow(x, y, w, h)
2468 this->mwindow = mwindow;
2471 AWindowDivider::~AWindowDivider()
2475 int AWindowDivider::button_press_event()
2477 if( is_event_win() && cursor_inside() ) {
2478 mwindow->session->current_operation = DRAG_PARTITION;
2484 int AWindowDivider::cursor_motion_event()
2486 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2488 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2489 int fw = gui->get_relative_cursor_x();
2490 if( fw > wmax ) fw = wmax;
2491 if( fw < wmin ) fw = wmin;
2492 mwindow->session->afolders_w = fw;
2493 mwindow->theme->get_awindow_sizes(gui);
2494 gui->reposition_objects();
2500 int AWindowDivider::button_release_event()
2502 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2503 mwindow->session->current_operation = NO_OPERATION;
2514 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2515 : BC_ListBox(x, y, w, h,
2516 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2517 LISTBOX_ICONS : LISTBOX_TEXT,
2518 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2519 0, // Titles for columns. Set to 0 for no titles
2520 0, // width of each column
2521 1, // Total columns.
2522 0, // Pixel of top of window.
2523 0, // If this listbox is a popup window
2524 LISTBOX_SINGLE, // Select one item or multiple items
2525 ICON_TOP, // Position of icon relative to text of each item
2528 this->mwindow = mwindow;
2535 AWindowFolders::~AWindowFolders()
2539 int AWindowFolders::selection_changed()
2541 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2542 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2543 // prefer expanded entry
2544 AWindowFolderItem *item = item1 ? item1 : item0;
2545 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2546 item1->set_selected(0);
2553 AssetPicon *picon = item->get_picon();
2554 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2556 gui->stop_vicon_drawing();
2558 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2559 gui->folderlist_menu->update_titles();
2560 gui->folderlist_menu->activate_menu();
2563 mwindow->edl->session->awindow_folder = picon->foldernum;
2564 gui->asset_list->draw_background();
2565 gui->async_update_assets();
2567 gui->start_vicon_drawing();
2572 int AWindowFolders::button_press_event()
2574 int result = BC_ListBox::button_press_event();
2577 if( get_buttonpress() == RIGHT_BUTTON &&
2578 is_event_win() && cursor_inside() ) {
2579 gui->folderlist_menu->update_titles();
2580 gui->folderlist_menu->activate_menu();
2588 int AWindowFolders::drag_stop()
2591 if( get_hidden() ) return 0;
2592 if( mwindow->session->current_operation == DRAG_ASSET &&
2593 gui->folder_list->cursor_above() ) { // check user folder
2594 int item_no = gui->folder_list->get_cursor_data_item_no();
2595 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2596 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2597 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2598 ArrayList<Indexable *> *drags = folder->is_clips ?
2599 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2600 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2601 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2603 mwindow->session->current_operation = ::NO_OPERATION;
2610 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2611 : AWindowFolderItem(text)
2613 this->parent = parent;
2616 int AWindowFolders::load_expanders()
2618 char expanders_path[BCTEXTLEN];
2619 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2620 FILE *fp = fopen(expanders_path, "r");
2622 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2623 File::get_cindat_path(), EXPANDERS_FILE);
2624 fp = fopen(expanders_path, "r");
2628 const char tab = '\t';
2629 char line[BCTEXTLEN]; line[0] = 0;
2630 AWindowFolderItem *item = 0, *parent;
2631 AWindowFolderSubItems *sub_items = 0;
2633 while( fgets(line,sizeof(line),fp) ) {
2634 if( line[0] == '#' ) continue;
2635 int i = strlen(line);
2636 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2637 if( i == 0 ) continue;
2639 for( char *cp=line; *cp==tab; ++cp ) ++i;
2641 int i = gui->folders.size();
2643 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2644 if( !strcmp(folder->get_text(),_(line)) ) break;
2646 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2651 if( i > k+1 ) continue;
2653 if( line[i] != '-' && sub_items ) {
2654 sub_items->names.append(cstrdup(_(&line[i])));
2662 item = item->parent;
2665 parent = item->parent;
2667 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2668 if( !sublist ) sublist = parent->new_sublist(1);
2669 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2670 sublist->append(item = sub_items);
2677 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2678 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2679 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2680 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2681 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2683 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2684 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2685 mwindow->edl->session->asset_columns, // width of each column
2686 1, // Total columns.
2687 0, // Pixel of top of window.
2688 0, // If this listbox is a popup window
2689 LISTBOX_MULTIPLE, // Select one item or multiple items
2690 ICON_TOP, // Position of icon relative to text of each item
2691 -1) // Allow drags, require shift for scrolling
2693 this->mwindow = mwindow;
2696 set_scroll_stretch(1, 1);
2699 AWindowAssets::~AWindowAssets()
2703 int AWindowAssets::button_press_event()
2705 AssetVIconThread *avt = gui->vicon_thread;
2706 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2707 int dir = 1, button = get_buttonpress();
2709 case WHEEL_DOWN: dir = -1; // fall thru
2711 int x = get_cursor_x(), y = get_cursor_y();
2712 if( avt->cursor_inside(x, y) && avt->view_win )
2713 avt->zoom_scale(dir);
2718 int result = BC_ListBox::button_press_event();
2720 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2721 is_event_win() && cursor_inside() ) {
2722 BC_ListBox::deactivate_selection();
2723 int folder = mwindow->edl->session->awindow_folder;
2725 case AW_AEFFECT_FOLDER:
2726 case AW_VEFFECT_FOLDER:
2727 case AW_ATRANSITION_FOLDER:
2728 case AW_VTRANSITION_FOLDER:
2729 gui->effectlist_menu->update();
2730 gui->effectlist_menu->activate_menu();
2732 case AW_LABEL_FOLDER:
2733 gui->labellist_menu->update();
2734 gui->labellist_menu->activate_menu();
2736 case AW_CLIP_FOLDER:
2737 gui->cliplist_menu->update();
2738 gui->cliplist_menu->activate_menu();
2740 case AW_PROXY_FOLDER:
2741 gui->proxylist_menu->update();
2742 gui->proxylist_menu->activate_menu();
2745 case AW_MEDIA_FOLDER: {
2746 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2747 gui->assetlist_menu->update_titles(shots);
2748 gui->assetlist_menu->activate_menu();
2758 int AWindowAssets::handle_event()
2760 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2761 if( !asset_picon ) return 0;
2762 Indexable *picon_idxbl = asset_picon->indexable;
2763 EDL *picon_edl = asset_picon->edl;
2765 VWindow *vwindow = 0;
2766 switch( mwindow->edl->session->awindow_folder ) {
2767 case AW_AEFFECT_FOLDER:
2768 case AW_VEFFECT_FOLDER:
2769 case AW_ATRANSITION_FOLDER:
2770 case AW_VTRANSITION_FOLDER: return 1;
2771 case AW_PROXY_FOLDER:
2772 proxy = 1; // fall thru
2774 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2775 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2778 if( !vwindow || !vwindow->is_running() ) return 1;
2779 if( proxy && picon_idxbl ) {
2780 picon_edl = gui->collect_proxy(picon_idxbl);
2784 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2785 else if( picon_edl ) vwindow->change_source(picon_edl);
2789 int AWindowAssets::selection_changed()
2791 // Show popup window
2793 int folder = mwindow->edl->session->awindow_folder;
2794 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2795 (item = (AssetPicon*)get_selection(0, 0)) ) {
2797 case AW_AEFFECT_FOLDER:
2798 case AW_VEFFECT_FOLDER:
2799 case AW_ATRANSITION_FOLDER:
2800 case AW_VTRANSITION_FOLDER:
2801 gui->effectlist_menu->update();
2802 gui->effectlist_menu->activate_menu();
2804 case AW_LABEL_FOLDER:
2805 if( !item->label ) break;
2806 gui->label_menu->activate_menu();
2808 case AW_CLIP_FOLDER:
2809 if( !item->indexable && !item->edl ) break;
2810 gui->clip_menu->update();
2811 gui->clip_menu->activate_menu();
2813 case AW_PROXY_FOLDER:
2814 if( !item->indexable && !item->edl ) break;
2815 gui->proxy_menu->update();
2816 gui->proxy_menu->activate_menu();
2819 if( !item->indexable && !item->edl ) break;
2820 gui->asset_menu->update();
2821 gui->asset_menu->activate_menu();
2825 deactivate_selection();
2827 else if( get_button_down() && !gui->play_off &&
2828 mwindow->edl->session->assetlist_format != ASSETS_TEXT ) {
2829 item = (AssetPicon*)get_selection(0, 0);
2830 if( item && !get_selection(0, 1) ) {
2832 case AW_MEDIA_FOLDER:
2833 case AW_PROXY_FOLDER:
2834 case AWINDOW_USER_FOLDERS:
2835 if( get_buttonpress() == LEFT_BUTTON ||
2836 get_buttonpress() == MIDDLE_BUTTON ) {
2837 AssetVIcon *vicon = 0;
2838 AssetVIconThread *avt = gui->vicon_thread;
2839 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2840 vicon = item->vicon;
2841 int draw_mode = !vicon ?
2843 get_buttonpress() == MIDDLE_BUTTON ?
2844 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2845 avt->set_view_popup(vicon, draw_mode);
2848 case AW_CLIP_FOLDER:
2849 if( get_buttonpress() == LEFT_BUTTON ) {
2850 AssetVIcon *vicon = 0;
2851 AssetVIconThread *avt = gui->vicon_thread;
2852 if( !avt->vicon && gui->vicon_drawing != AVICON_NO_PLAY )
2853 vicon = item->vicon;
2854 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2860 gui->vicon_thread->set_view_popup(0);
2861 if( gui->vicon_drawing != AVICON_FULL_PLAY )
2862 gui->stop_vicon_drawing();
2868 void AWindowAssets::draw_background()
2870 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2871 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2872 set_font(LARGEFONT);
2873 int folder = mwindow->edl->session->awindow_folder;
2874 const char *title = mwindow->edl->get_folder_name(folder);
2875 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2876 title, -1, get_bg_surface());
2879 int AWindowAssets::drag_start_event()
2881 gui->vicon_thread->set_view_popup(0);
2882 int collect_pluginservers = 0;
2883 int collect_assets = 0, proxy = 0;
2885 if( BC_ListBox::drag_start_event() ) {
2886 switch( mwindow->edl->session->awindow_folder ) {
2887 case AW_AEFFECT_FOLDER:
2888 mwindow->session->current_operation = DRAG_AEFFECT;
2889 collect_pluginservers = 1;
2891 case AW_VEFFECT_FOLDER:
2892 mwindow->session->current_operation = DRAG_VEFFECT;
2893 collect_pluginservers = 1;
2895 case AW_ATRANSITION_FOLDER:
2896 mwindow->session->current_operation = DRAG_ATRANSITION;
2897 collect_pluginservers = 1;
2899 case AW_VTRANSITION_FOLDER:
2900 mwindow->session->current_operation = DRAG_VTRANSITION;
2901 collect_pluginservers = 1;
2903 case AW_LABEL_FOLDER:
2906 case AW_PROXY_FOLDER:
2907 proxy = 1; // fall thru
2908 case AW_MEDIA_FOLDER:
2910 mwindow->session->current_operation = DRAG_ASSET;
2915 if( collect_pluginservers ) {
2917 mwindow->session->drag_pluginservers->remove_all();
2920 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2921 if( !result ) break;
2923 mwindow->session->drag_pluginservers->append(result->plugin);
2927 if( collect_assets ) {
2928 gui->collect_assets(proxy);
2936 int AWindowAssets::drag_motion_event()
2938 BC_ListBox::drag_motion_event();
2941 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2942 mwindow->gui->drag_motion();
2943 mwindow->gui->unlock_window();
2945 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2946 VWindow *vwindow = mwindow->vwindows.get(i);
2947 if( !vwindow->is_running() ) continue;
2948 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2949 vwindow->gui->drag_motion();
2950 vwindow->gui->unlock_window();
2953 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2954 mwindow->cwindow->gui->drag_motion();
2955 mwindow->cwindow->gui->unlock_window();
2957 lock_window("AWindowAssets::drag_motion_event");
2958 if( mwindow->session->current_operation == DRAG_ASSET &&
2959 gui->folder_list->cursor_above() ) { // highlight user folder
2960 BC_ListBoxItem *item = 0;
2961 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2962 if( item_no >= 0 ) {
2963 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2964 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2967 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2968 int folder_xposition = gui->folder_list->get_xposition();
2969 int folder_yposition = gui->folder_list->get_yposition();
2970 gui->folder_list->update(&gui->folders, 0, 0, 1,
2971 folder_xposition, folder_yposition, item_no, 0, 1);
2976 int AWindowAssets::drag_stop_event()
2980 result = gui->drag_stop();
2985 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2986 result = mwindow->gui->drag_stop();
2987 mwindow->gui->unlock_window();
2991 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2992 VWindow *vwindow = mwindow->vwindows.get(i);
2993 if( !vwindow ) continue;
2994 if( !vwindow->is_running() ) continue;
2995 if( vwindow->gui->is_hidden() ) continue;
2996 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2997 if( vwindow->gui->cursor_above() &&
2998 vwindow->gui->get_cursor_over_window() ) {
2999 result = vwindow->gui->drag_stop();
3001 vwindow->gui->unlock_window();
3006 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
3007 result = mwindow->cwindow->gui->drag_stop();
3008 mwindow->cwindow->gui->unlock_window();
3011 lock_window("AWindowAssets::drag_stop_event");
3013 result = gui->folder_list->drag_stop();
3018 get_drag_popup()->set_animation(0);
3020 BC_ListBox::drag_stop_event();
3021 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
3022 mwindow->session->current_operation = ::NO_OPERATION;
3027 int AWindowAssets::column_resize_event()
3029 mwindow->edl->session->asset_columns[0] = get_column_width(0);
3030 mwindow->edl->session->asset_columns[1] = get_column_width(1);
3034 int AWindowAssets::cursor_enter_event()
3036 int ret = BC_ListBox::cursor_enter_event();
3037 switch( gui->vicon_drawing ) {
3038 case AVICON_FULL_PLAY:
3039 gui->start_vicon_drawing();
3041 case AVICON_MOUSE_OVER:
3042 case AVICON_SRC_TARGET:
3043 case AVICON_NO_PLAY:
3050 int AWindowAssets::cursor_leave_event()
3052 if( !is_event_win() ) return 0;
3053 if( !gui->vicon_thread->viewing )
3054 gui->stop_vicon_drawing();
3055 return BC_ListBox::cursor_leave_event();
3058 int AWindowAssets::focus_out_event()
3060 gui->stop_vicon_drawing();
3061 gui->vicon_thread->set_view_popup(0);
3062 return BC_ListBox::focus_out_event();
3065 void AWindowAssets::update_vicon_area()
3067 int x0 = 0, x1 = get_w();
3068 int y0 = get_title_h();
3070 if( is_highlighted() ) {
3071 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
3072 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
3074 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
3077 int AWindowAssets::mouse_over_event(int no)
3079 AssetPicon *picon = no >= 0 && no < gui->displayed_assets[0].size() ?
3080 (AssetPicon *)gui->displayed_assets[0][no] : 0;
3081 AssetVIcon *vicon = !picon ? 0 : picon->vicon;
3082 switch( gui->vicon_drawing ) {
3083 case AVICON_FULL_PLAY:
3084 gui->vicon_thread->solo = 0;
3085 if( vicon && gui->vicon_thread->viewing )
3086 gui->vicon_thread->set_view_popup(vicon);
3088 case AVICON_MOUSE_OVER:
3090 gui->vicon_thread->solo = vicon;
3091 gui->start_vicon_drawing();
3093 case AVICON_SRC_TARGET:
3095 if( gui->vicon_thread->viewing )
3096 gui->vicon_thread->set_view_popup(vicon);
3098 case AVICON_NO_PLAY:
3106 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
3107 : BC_TextBox(x, y, w, 1, "")
3109 this->search_text = search_text;
3112 int AWindowSearchTextBox::handle_event()
3114 return search_text->handle_event();
3117 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3119 this->mwindow = mwindow;
3125 void AWindowSearchText::create_objects()
3127 int x1 = x, y1 = y, margin = 10;
3128 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3129 x1 += text_title->get_w() + margin;
3130 int w1 = gui->get_w() - x1 - 2*margin;
3131 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3134 int AWindowSearchText::handle_event()
3136 gui->async_update_assets();
3140 int AWindowSearchText::get_w()
3142 return text_box->get_w() + text_title->get_w() + 10;
3145 int AWindowSearchText::get_h()
3147 return bmax(text_box->get_h(),text_title->get_h());
3150 void AWindowSearchText::reposition_window(int x, int y, int w)
3152 int x1 = x, y1 = y, margin = 10;
3153 text_title->reposition_window(x1, y1);
3154 x1 += text_title->get_w() + margin;
3155 int w1 = gui->get_w() - x1 - 2*margin;
3156 text_box->reposition_window(x1, y1, w1);
3159 const char *AWindowSearchText::get_text()
3161 return text_box->get_text();
3164 void AWindowSearchText::clear()
3166 text_box->update("");
3169 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3170 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3172 this->mwindow = mwindow;
3174 set_tooltip(_("Delete asset from disk"));
3177 int AWindowDeleteDisk::handle_event()
3182 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3183 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3185 this->mwindow = mwindow;
3187 set_tooltip(_("Delete asset from project"));
3190 int AWindowDeleteProject::handle_event()
3195 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3196 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3198 // this->mwindow = mwindow;
3200 // set_tooltip(_("Edit information on asset"));
3203 // int AWindowInfo::handle_event()
3205 // int cur_x, cur_y;
3206 // gui->get_abs_cursor(cur_x, cur_y, 0);
3207 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3211 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3212 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3214 this->mwindow = mwindow;
3216 set_tooltip(_("Redraw index"));
3219 int AWindowRedrawIndex::handle_event()
3224 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3225 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3227 this->mwindow = mwindow;
3229 set_tooltip(_("Paste asset on recordable tracks"));
3232 int AWindowPaste::handle_event()
3237 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3238 : BC_Button(x, y, mwindow->theme->appendasset_data)
3240 this->mwindow = mwindow;
3242 set_tooltip(_("Append asset in new tracks"));
3245 int AWindowAppend::handle_event()
3250 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3251 : BC_Button(x, y, mwindow->theme->viewasset_data)
3253 this->mwindow = mwindow;
3255 set_tooltip(_("View asset"));
3258 int AWindowView::handle_event()
3263 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3264 : BC_PopupMenu(x, y, title, -1, 0)
3266 this->mwindow = mwindow;
3270 void AddTools::create_objects()
3273 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3274 vis |= 1 << PLUGIN_FFMPEG_ID;
3275 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3276 vis |= 1 << PLUGIN_LADSPA_ID;
3278 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3279 vis |= 1 << PLUGIN_LV2_ID;
3281 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3282 PluginServer *plugin = MWindow::plugindb->get(i);
3283 if( !plugin->audio && !plugin->video ) continue;
3284 int idx = plugin->dir_idx;
3285 uint32_t msk = 1 << idx;
3286 if( (msk & vis) != 0 ) continue;
3288 char parent[BCTEXTLEN];
3289 strcpy(parent, plugin->path);
3290 char *bp = strrchr(parent, '/');
3291 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3292 if( !bp ) bp = parent; else ++bp;
3293 add_item(new AddPluginItem(this, bp, idx));
3298 // plugin_dirs list from toplevel makefile include plugin_defs
3303 N_("audio_transitions")
3310 N_("video_transitions")
3313 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3314 : BC_MenuItem(_(text))
3318 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3319 int chk = (msk & vis) ? 1 : 0;
3323 int AddPluginItem::handle_event()
3325 int chk = get_checked() ^ 1;
3327 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3328 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3329 menu->gui->update_effects();
3330 menu->gui->save_defaults(menu->mwindow->defaults);
3331 menu->gui->async_update_assets();
3335 AVIconDrawingItem::AVIconDrawingItem(AVIconDrawing *avicon, const char *text, int id)
3338 this->avicon = avicon;
3342 int AVIconDrawingItem::handle_event()
3344 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3345 AVIconDrawingItem *item = (AVIconDrawingItem *) avicon->get_item(i);
3346 item->set_checked(id == i);
3348 AWindowGUI *agui = avicon->agui;
3350 avicon->set_text(get_text());
3351 agui->stop_vicon_drawing();
3352 agui->vicon_thread->set_view_popup(0);
3353 agui->vicon_thread->solo = 0;
3354 agui->vicon_drawing = id;
3355 agui->start_vicon_drawing();
3359 int AVIconDrawing::draw_face(int dx, int color)
3361 int ret = BC_PopupMenu::draw_face(dx, color);
3362 if( agui->play_off && agui->vicon_drawing != AVICON_NO_PLAY ) {
3363 int lx = get_margin(), ly = get_h()/2;
3364 draw_line(lx,ly, get_w()-2*lx,ly);
3369 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, int w, const char *text)
3370 : BC_PopupMenu(x-w, y, w, text, 1, 0, 4)
3375 AVIconDrawing::~AVIconDrawing()
3379 void AVIconDrawing::create_objects()
3381 AVIconDrawingItem *item;
3382 for( int i=0; i<AVICON_PLAY_MODES; ++i ) {
3383 add_item(item = new AVIconDrawingItem(this, avicon_names[i], i));
3384 item->set_checked(agui->vicon_drawing == i);
3388 int AVIconDrawing::button_press_event()
3390 if( !is_event_win() ) return 0;
3391 if( get_buttonpress() == MIDDLE_BUTTON ) {
3392 agui->play_off = !agui->play_off ? 1 : 0;
3395 agui->start_vicon_drawing();
3398 return BC_PopupMenu::button_press_event();
3401 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3402 : BC_MenuItem("","v",'v')
3404 this->mwindow = mwindow;
3408 int AWindowListFormat::handle_event()
3410 return gui->cycle_assetlist_format();
3413 void AWindowListFormat::update()
3415 EDLSession *session = mwindow->edl->session;
3416 const char *text = 0;
3417 switch( session->assetlist_format ) {
3419 text = _("Display icons");
3422 text = _("Display icons packed");
3424 case ASSETS_ICONS_PACKED:
3425 text = _("Display icon list");
3427 case ASSETS_ICON_LIST:
3428 text = _("Display text");
3434 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3435 : BC_MenuItem(_("Sort items"))
3437 this->mwindow = mwindow;
3441 int AWindowListSort::handle_event()
3447 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3450 this->select_used = select_used;
3451 this->action = action;
3454 int AssetSelectUsedItem::handle_event()
3456 MWindow *mwindow = select_used->mwindow;
3457 AWindowGUI *gui = select_used->gui;
3458 AWindowAssets *asset_list = gui->asset_list;
3459 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3464 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3468 asset_list->set_all_selected(data, 0);
3469 for( int i = 0; i < data->total; i++ ) {
3470 AssetPicon *picon = (AssetPicon*)data->values[i];
3471 Indexable *idxbl = picon->indexable ? picon->indexable :
3472 picon->edl ? picon->edl->get_proxy_asset() : 0;
3473 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3474 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3479 int asset_xposition = asset_list->get_xposition();
3480 int asset_yposition = asset_list->get_yposition();
3481 asset_list->update(gui->displayed_assets, gui->asset_titles,
3482 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3483 asset_xposition, asset_yposition, -1, 0);
3484 asset_list->center_selection();
3488 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3489 : BC_MenuItem(_("Select"))
3491 this->mwindow = mwindow;