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"),
99 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
100 : VIcon(w, h, framerate), Garbage("AssetVIcon")
103 this->length = length;
107 AssetVIcon::~AssetVIcon()
109 picon->gui->vicon_thread->del_vicon(this);
113 VFrame *AssetVIcon::frame()
115 AssetVIconThread *avt = picon->gui->vicon_thread;
116 Asset *asset = (Asset *)picon->indexable;
119 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
120 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
122 int sample_rate = asset->get_sample_rate();
123 int64_t audio_samples = asset->get_audio_samples();
124 double duration = (double)audio_samples / sample_rate;
125 picon->draw_hue_bar(temp, duration);
126 int secs = length / frame_rate + 0.5;
127 if( !secs ) secs = 1;
128 int bfrsz = VICON_SAMPLE_RATE;
129 int samples = audio_size/sizeof(vicon_audio_t);
130 double line_pos = (double)seq_no/(length-1);
131 int audio_pos = samples * line_pos * (secs-1)/secs;
132 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
133 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
134 double data[bfrsz], sample_scale = 1./mx;
135 int len = samples - audio_pos;
136 if( len > bfrsz ) len = bfrsz;
138 while( i < len ) data[i++] = *audio_data++ * sample_scale;
139 while( i < bfrsz ) data[i++] = 0;
140 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
141 int x = (w-1) * line_pos;
142 temp->pixel_rgb = RED;
143 temp->draw_line(x,0, x,h);
146 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
147 if( !asset->video_data ) {
149 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
154 if( seq_no >= images.size() ) {
155 MWindow *mwindow = picon->mwindow;
156 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
157 if( !file ) return 0;
158 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
159 delete temp; temp = 0;
162 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
163 while( seq_no >= images.size() ) {
164 mwindow->video_cache->check_in(asset);
166 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
167 if( !file ) { usleep(1000); continue; }
169 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
170 file->set_video_position(pos,0);
171 if( file->read_frame(temp) ) temp->clear_frame();
172 add_image(temp, vw, vh, vicon_cmodel);
174 mwindow->video_cache->check_in(asset);
176 return *images[seq_no];
179 int64_t AssetVIcon::set_seq_no(int64_t no)
181 if( no >= length ) no = 0;
185 int AssetVIcon::get_vx()
187 BC_ListBox *lbox = picon->gui->asset_list;
188 return lbox->get_icon_x(picon);
190 int AssetVIcon::get_vy()
192 BC_ListBox *lbox = picon->gui->asset_list;
193 return lbox->get_icon_y(picon);
196 void AssetVIcon::load_audio()
198 MWindow *mwindow = picon->mwindow;
199 Asset *asset = (Asset *)picon->indexable;
200 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
201 int channels = asset->get_audio_channels();
202 if( channels > 2 ) channels = 2;
203 int sample_rate = asset->get_sample_rate();
204 int bfrsz = sample_rate;
205 Samples samples(bfrsz);
206 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
207 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
208 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
209 double sample_scale = (double)mx / channels;
210 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
211 while( audio_pos < audio_len ) {
212 int64_t pos = audio_pos * time_scale;
213 for( int ch=0; ch<channels; ++ch ) {
214 file->set_channel(ch);
215 file->set_audio_position(pos);
216 file->read_samples(&samples, bfrsz);
217 double *data = samples.get_data();
218 for( int64_t k=audio_pos; k<audio_len; ++k ) {
219 int i = k * time_scale - pos;
220 if( i >= bfrsz ) break;
221 int v = audio_data[k] + data[i] * sample_scale;
222 audio_data[k] = CLIP(v, -mx,mx);
225 audio_pos = (pos + bfrsz) / time_scale;
227 mwindow->audio_cache->check_in(asset);
231 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
235 audio = new AudioDevice(gui->mwindow);
239 AssetVIconAudio::~AssetVIconAudio()
244 void AssetVIconAudio::run()
247 int64_t bfrsz = VICON_SAMPLE_RATE;
248 MWindow *mwindow = gui->mwindow;
249 EDL *edl = mwindow->edl;
250 EDLSession *session = edl->session;
251 AudioOutConfig *aconfig = session->playback_config->aconfig;
252 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
253 audio->start_playback();
254 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
255 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
256 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
258 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
259 while( !interrupted ) {
260 int len = audio_len - audio_pos;
261 if( len <= 0 ) break;
262 if( len > bfrsz ) len = bfrsz;
264 for( int i=0; i<len; ++i,++k )
265 out0[i] = out1[i] = (double)audio_data[k] / mx;
267 audio->write_buffer(out, channels, len);
271 audio->set_last_buffer();
272 audio->stop_audio(interrupted ? 0 : 1);
276 void AssetVIconAudio::start(AssetVIcon *vicon)
278 if( running() ) return;
285 void AssetVIconAudio::stop(int wait)
287 if( running() && !interrupted ) {
289 audio->stop_audio(wait);
293 vicon->playing_audio = 0;
298 void AssetVIcon::start_audio()
300 if( playing_audio < 0 ) return;
301 picon->gui->vicon_audio->stop(0);
303 picon->gui->vicon_audio->start(this);
306 void AssetVIcon::stop_audio()
308 if( playing_audio > 0 )
309 picon->gui->vicon_audio->stop(0);
313 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
314 int x, int y, int w, int h)
315 : ViewPopup(vt, x, y, w, h)
317 this->draw_mode = draw_mode;
318 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
321 AssetViewPopup::~AssetViewPopup()
325 int AssetViewPopup::button_press_event()
327 if( !is_event_win() ) return 0;
328 AssetVIconThread *avt = (AssetVIconThread *)vt;
329 if( !avt->vicon ) return 0;
331 switch( draw_mode ) {
332 case ASSET_VIEW_MEDIA_MAP:
333 case ASSET_VIEW_FULL:
340 switch( get_buttonpress() ) {
347 if( draw_mode != ASSET_VIEW_FULL )
348 return avt->zoom_scale(dir);
354 int x = get_cursor_x(), y = get_cursor_y();
355 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
356 AssetPicon *picon = vicon->picon;
357 MWindow *mwindow = picon->mwindow;
358 EDL *edl = mwindow->edl;
360 if( y < get_h()/2 ) {
362 picon->indexable ? picon->indexable :
363 picon->edl ? picon->edl : 0;
364 if( !idxbl ) return 0;
365 double sample_rate = idxbl->get_sample_rate();
366 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
367 idxbl->get_audio_samples() / sample_rate : 0;
368 double frame_rate = idxbl->get_frame_rate();
369 double video_length = frame_rate > 0 && idxbl->have_video() ?
370 idxbl->get_video_frames() / frame_rate : 0;
371 double idxbl_length = bmax(audio_length, video_length);
372 double pos = x * idxbl_length / get_w();
373 double start = 0, end = idxbl_length;
374 double lt = DBL_MAX, rt = DBL_MAX;
375 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
376 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
377 Indexable *indexable = (Indexable *)edit->asset;
378 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
379 if( !indexable ) continue;
380 if( indexable->id == idxbl->id ||
381 (!indexable->is_asset == !idxbl->is_asset &&
382 !strcmp(indexable->path, idxbl->path)) ) {
383 double start_pos = track->from_units(edit->startsource);
384 double end_pos = track->from_units(edit->startsource + edit->length);
385 double dlt = pos - start_pos, drt = end_pos - pos;
386 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
387 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
388 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
389 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
393 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
394 VWindow *vwindow = mwindow->get_viewer(1, 0);
395 vwindow->change_source(idxbl);
396 mwindow->gui->unlock_window();
397 EDL *vedl = vwindow->get_edl();
398 vedl->set_inpoint(start);
399 vedl->set_outpoint(end);
400 vedl->local_session->set_selectionstart(start);
401 vedl->local_session->set_selectionend(end);
402 vwindow->update_position(CHANGE_NONE, 0, 1, 0);
407 if( !ctrl_down() && !shift_down() )
408 return cursor_motion_event();
410 picon->indexable ? picon->indexable :
411 picon->edl ? picon->edl : 0;
412 if( !idxbl ) return 0;
413 double total_length = mwindow->edl->tracks->total_length();
414 double pos = x * total_length / get_w();
415 double start = 0, end = total_length;
416 double lt = DBL_MAX, rt = DBL_MAX;
417 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
418 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
419 Indexable *indexable = (Indexable *)edit->asset;
420 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
421 if( !indexable ) continue;
422 if( indexable->id == idxbl->id ||
423 (!indexable->is_asset == !idxbl->is_asset &&
424 !strcmp(indexable->path, idxbl->path)) ) {
425 double start_pos = track->from_units(edit->startproject);
426 double end_pos = track->from_units(edit->startproject + edit->length);
427 double dlt = pos - start_pos, drt = end_pos - pos;
428 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
429 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
430 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
431 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
435 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
436 mwindow->select_point(!ctrl_down() && !shift_down() ? pos : start);
437 edl->local_session->set_selectionstart(start);
438 edl->local_session->set_selectionend(!shift_down() ? start : end);
439 mwindow->zoom_sample(edl->local_session->zoom_sample);
440 mwindow->gui->unlock_window();
446 int AssetViewPopup::button_release_event()
448 if( !is_event_win() ) return 0;
453 int AssetViewPopup::cursor_motion_event()
455 if( !is_event_win() ) return 0;
456 AssetVIconThread *avt = (AssetVIconThread *)vt;
458 ( draw_mode != ASSET_VIEW_FULL &&
459 draw_mode != ASSET_VIEW_MEDIA_MAP ) ) return 0;
460 if( !get_button_down() || get_buttonpress() != LEFT_BUTTON ||
461 ctrl_down() || alt_down() || shift_down() )
463 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
464 MWindow *mwindow = vicon->picon->mwindow;
465 EDL *edl = mwindow->edl;
467 int x = get_cursor_x();
468 double total_length = edl->tracks->total_length();
469 double pos = x * total_length / get_w();
470 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
471 mwindow->select_point(pos);
472 mwindow->zoom_sample(edl->local_session->zoom_sample);
473 mwindow->gui->unlock_window();
479 void AssetViewPopup::draw_vframe(VFrame *vframe)
481 switch( draw_mode ) {
482 case ASSET_VIEW_MEDIA:
483 case ASSET_VIEW_ICON:
484 ViewPopup::draw_vframe(vframe);
485 case ASSET_VIEW_NONE:
488 case ASSET_VIEW_MEDIA_MAP:
489 case ASSET_VIEW_FULL:
493 draw_box(0,0,get_w(),get_h());
495 int y2 = get_h()-bar_h;
496 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
497 AssetVIconThread *avt = (AssetVIconThread *)vt;
498 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
499 AssetPicon *picon = (AssetPicon *)vicon->picon;
501 picon->indexable ? picon->indexable :
502 picon->edl ? picon->edl : 0;
504 double sample_rate = idxbl->get_sample_rate();
505 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
506 idxbl->get_audio_samples() / sample_rate : 0;
507 double frame_rate = idxbl->get_frame_rate();
508 double video_length = frame_rate > 0 && idxbl->have_video() ?
509 idxbl->get_video_frames() / frame_rate : 0;
510 double idxbl_length = bmax(audio_length, video_length);
511 if( !idxbl_length ) idxbl_length = 1;
513 EDL *edl = picon->mwindow->edl;
514 double total_length = edl->tracks->total_length();
515 if( !total_length ) total_length = 1;
516 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
517 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
518 Indexable *indexable = (Indexable *)edit->asset;
519 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
520 if( !indexable ) continue;
521 if( indexable->id == idxbl->id ||
522 (!indexable->is_asset == !idxbl->is_asset &&
523 !strcmp(indexable->path, idxbl->path)) ) {
524 double pos1 = track->from_units(edit->startsource);
525 double pos2 = track->from_units(edit->startsource + edit->length);
526 double xscale = get_w() / idxbl_length;
527 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
529 draw_box(ex1,0, ex2-ex1,y1);
531 draw_line(ex1,0, ex1,y1);
532 draw_line(ex2,0, ex2,y1);
533 pos1 = track->from_units(edit->startproject);
534 pos2 = track->from_units(edit->startproject + edit->length);
535 xscale = get_w() / total_length;
536 int px1 = pos1 * xscale, px2 = pos2 * xscale;
538 draw_box(px1,y2, px2-px1,get_h()-y2);
540 draw_line(px1,y2, px1,get_h()-1);
541 draw_line(px2,y2, px2,get_h()-1);
544 draw_line(ex1,y1, px1,y2);
545 draw_line(ex2,y1, px2,y2);
551 int AssetViewPopup::keypress_event()
553 AssetVIconThread *avt = (AssetVIconThread *)vt;
554 switch( avt->draw_mode ) {
555 case ASSET_VIEW_MEDIA_MAP:
556 switch( get_keypress() ) {
559 avt->draw_mode = ASSET_VIEW_FULL;
564 case ASSET_VIEW_FULL:
565 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
569 return ViewPopup::keypress_event();
573 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
574 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
575 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
578 draw_mode = ASSET_VIEW_NONE;
579 int vicon_cmodel = BC_RGB8;
580 switch( preferences->vicon_color_mode ) {
581 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
582 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
583 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
585 this->vicon_cmodel = vicon_cmodel;
586 this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
589 AssetVIconThread::~AssetVIconThread()
594 void AssetVIconThread::drawing_started()
596 draw_lock->lock("AssetVIconThread::drawing_started");
599 void AssetVIconThread::drawing_stopped()
604 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
606 gui->stop_vicon_drawing();
607 int mode = !v ? ASSET_VIEW_NONE :
608 draw_mode >= 0 ? draw_mode :
611 this->draw_mode = mode;
612 gui->start_vicon_drawing();
615 ViewPopup *AssetVIconThread::new_view_window()
617 BC_WindowBase *parent = wdw->get_parent();
618 int rx = 0, ry = 0, rw = 0, rh = 0;
619 if( draw_mode != ASSET_VIEW_FULL ) {
620 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
621 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
622 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
623 int vx = viewing->get_vx(), vy = viewing->get_vy();
624 wdw->get_root_coordinates(vx, vy, &rx, &ry);
625 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
626 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
627 rw = view_w; rh = view_h;
630 parent->get_fullscreen_geometry(rx, ry, rw, rh);
631 AssetViewPopup *popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
632 if( draw_mode == ASSET_VIEW_MEDIA_MAP || draw_mode == ASSET_VIEW_FULL )
633 vicon->playing_audio = -1;
634 wdw->set_active_subwindow(popup);
638 void AssetVIconThread::close_view_popup()
641 drawing_started(); // waits for draw lock
646 AWindowFolderItem::AWindowFolderItem()
652 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
653 : BC_ListBoxItem(text, color)
658 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
659 : BC_ListBoxItem(text, icon, color)
664 AssetPicon *AWindowFolderItem::get_picon()
666 AWindowFolderItem *item = this;
667 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
668 return (AssetPicon*)item;
671 int AWindowFolderSubItems::matches(const char *text)
673 int i = names.size();
674 while( --i >= 0 && strcmp(names[i], text) );
676 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
677 i = sublist ? sublist->size() : 0;
679 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
680 if( item->matches(text) ) break;
683 return i >= 0 ? 1 : 0;
687 AssetPicon::AssetPicon(MWindow *mwindow,
688 AWindowGUI *gui, Indexable *indexable)
689 : AWindowFolderItem()
692 this->mwindow = mwindow;
694 this->indexable = indexable;
695 indexable->add_user();
696 this->id = indexable->id;
699 AssetPicon::AssetPicon(MWindow *mwindow,
700 AWindowGUI *gui, EDL *edl)
701 : AWindowFolderItem()
704 this->mwindow = mwindow;
711 AssetPicon::AssetPicon(MWindow *mwindow,
712 AWindowGUI *gui, int folder, int persist)
713 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
714 folder>=0 && folder<AWINDOW_FOLDERS ?
715 gui->folder_icons[folder] : gui->folder_icon)
719 this->mwindow = mwindow;
721 persistent = persist;
724 AssetPicon::AssetPicon(MWindow *mwindow,
725 AWindowGUI *gui, int folder, const char *title)
726 : AWindowFolderItem(title, gui->folder_icon)
730 this->mwindow = mwindow;
735 AssetPicon::AssetPicon(MWindow *mwindow,
736 AWindowGUI *gui, PluginServer *plugin)
737 : AWindowFolderItem()
740 this->mwindow = mwindow;
742 this->plugin = plugin;
745 AssetPicon::AssetPicon(MWindow *mwindow,
746 AWindowGUI *gui, Label *label)
747 : AWindowFolderItem()
750 this->mwindow = mwindow;
758 AssetPicon::~AssetPicon()
760 if( vicon ) vicon->remove_user();
762 if( indexable ) indexable->remove_user();
763 if( edl ) edl->remove_user();
764 if( icon && !gui->protected_pixmap(icon) ) {
766 if( !plugin ) delete icon_vframe;
770 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
772 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
774 float h = 300 * t, s = 1., v = 1.;
775 float r, g, b; // duration, 0..1hr == hue red..magenta
776 HSV::hsv_to_rgb(r,g,b, h,s,v);
777 int ih = frame->get_h()/8, iw = frame->get_w();
778 int ir = r * 256; CLAMP(ir, 0,255);
779 int ig = g * 256; CLAMP(ig, 0,255);
780 int ib = b * 256; CLAMP(ib, 0,255);
781 unsigned char **rows = frame->get_rows();
782 for( int y=0; y<ih; ++y ) {
783 unsigned char *rp = rows[y];
784 for( int x=0; x<iw; rp+=3,++x ) {
785 rp[0] = ir; rp[1] = ig; rp[2] = ib;
790 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
791 int base_color, int line_color, int x, int y, int w, int h)
793 int h1 = h-1, h2 = h/2, iy = h2;
794 int rgb_color = frame->pixel_rgb;
795 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
796 double min = *dp, max = min;
797 x2 = (len * (ix+1))/w;
798 for( int i=x1; i<x2; ++i ) {
799 double value = *dp++;
800 if( value < min ) min = value;
801 if( value > max ) max = value;
803 int ctr = (min + max) / 2;
804 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
805 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
806 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
807 frame->pixel_rgb = line_color;
808 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
809 frame->pixel_rgb = base_color;
810 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
813 frame->pixel_rgb = rgb_color;
816 void AssetPicon::reset()
824 foldernum = AW_NO_FOLDER;
836 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
838 TransportCommand command;
839 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
840 command.get_edl()->copy_all(edl);
841 command.change_type = CHANGE_ALL;
842 command.realtime = 0;
843 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
844 render_engine->set_vcache(mwindow->video_cache);
845 render_engine->set_acache(mwindow->audio_cache);
846 render_engine->arm_command(&command);
848 void AssetPicon::close_render_engine()
850 delete render_engine; render_engine = 0;
852 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
854 if( !render_engine || !render_engine->vrender ) return;
855 render_engine->vrender->process_buffer(vfrm, pos, 0);
857 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
859 if( !render_engine || !render_engine->arender ) return;
860 render_engine->arender->process_buffer(samples, len, pos);
863 void AssetPicon::create_objects()
866 char name[BCTEXTLEN];
867 int pixmap_w, pixmap_h;
869 int picon_h = mwindow->preferences->awindow_picon_h;
870 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
873 fs.extract_name(name, indexable->path);
877 set_text(strcpy(name, edl->local_session->clip_title));
881 if( indexable && indexable->is_asset ) {
882 Asset *asset = (Asset*)indexable;
883 if( asset->video_data ) {
884 if( mwindow->preferences->use_thumbnails ) {
885 gui->unlock_window();
886 File *file = mwindow->video_cache->check_out(asset,
891 int height = asset->height > 0 ? asset->height : 1;
892 pixmap_w = pixmap_h * asset->width / height;
895 file->set_video_position(0, 0);
897 if( gui->temp_picon &&
898 (gui->temp_picon->get_w() != asset->width ||
899 gui->temp_picon->get_h() != asset->height) ) {
900 delete gui->temp_picon;
904 if( !gui->temp_picon ) {
905 gui->temp_picon = new VFrame(0, -1,
906 asset->width, asset->height,
909 { char string[BCTEXTLEN];
910 sprintf(string, _("Reading %s"), name);
911 mwindow->gui->lock_window("AssetPicon::create_objects");
912 mwindow->gui->show_message(string);
913 mwindow->gui->unlock_window(); }
914 file->read_frame(gui->temp_picon);
915 mwindow->video_cache->check_in(asset);
917 gui->lock_window("AssetPicon::create_objects 0");
918 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
919 icon->draw_vframe(gui->temp_picon,
920 0, 0, pixmap_w, pixmap_h, 0, 0);
921 icon_vframe = new VFrame(0,
922 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
923 icon_vframe->transfer_from(gui->temp_picon);
924 if( asset->folder_no == AW_MEDIA_FOLDER ||
925 asset->folder_no == AW_PROXY_FOLDER ) {
927 double framerate = asset->get_frame_rate();
928 if( !framerate ) framerate = VICON_RATE;
929 int64_t frames = asset->get_video_frames();
930 double secs = frames / framerate;
931 if( secs > 5 ) secs = 5;
932 int64_t length = secs * gui->vicon_thread->refresh_rate;
933 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
934 if( asset->audio_data && secs > 0 ) {
935 gui->unlock_window();
936 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
937 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
939 gui->lock_window("AssetPicon::create_objects 1");
941 gui->vicon_thread->add_vicon(vicon);
945 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
946 gui->lock_window("AssetPicon::create_objects 2");
947 icon = gui->video_icon;
948 icon_vframe = gui->video_vframe;
952 icon = gui->video_icon;
953 icon_vframe = gui->video_vframe;
957 if( asset->audio_data ) {
958 if( mwindow->preferences->use_thumbnails ) {
959 gui->unlock_window();
960 File *file = mwindow->audio_cache->check_out(asset,
964 pixmap_w = pixmap_h * 16/9;
965 icon_vframe = new VFrame(0,
966 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
967 icon_vframe->clear_frame();
968 { char string[BCTEXTLEN];
969 sprintf(string, _("Reading %s"), name);
970 mwindow->gui->lock_window("AssetPicon::create_objects 3");
971 mwindow->gui->show_message(string);
972 mwindow->gui->unlock_window(); }
973 int sample_rate = asset->get_sample_rate();
974 int channels = asset->get_audio_channels();
975 if( channels > 2 ) channels = 2;
976 int64_t audio_samples = asset->get_audio_samples();
977 double duration = (double)audio_samples / sample_rate;
978 draw_hue_bar(icon_vframe, duration);
979 int bfrsz = sample_rate;
980 Samples samples(bfrsz);
981 static int line_colors[2] = { GREEN, YELLOW };
982 static int base_colors[2] = { RED, PINK };
983 for( int i=channels; --i>=0; ) {
984 file->set_channel(i);
985 file->set_audio_position(0);
986 file->read_samples(&samples, bfrsz);
987 draw_wave(icon_vframe, samples.get_data(), bfrsz,
988 base_colors[i], line_colors[i]);
990 mwindow->audio_cache->check_in(asset);
991 if( asset->folder_no == AW_MEDIA_FOLDER ) {
992 double secs = duration;
993 if( secs > 5 ) secs = 5;
994 double refresh_rate = gui->vicon_thread->refresh_rate;
995 int64_t length = secs * refresh_rate;
996 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
997 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
998 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1000 gui->vicon_thread->add_vicon(vicon);
1002 gui->lock_window("AssetPicon::create_objects 4");
1003 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1004 icon->draw_vframe(icon_vframe,
1005 0, 0, pixmap_w, pixmap_h, 0, 0);
1008 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1009 gui->lock_window("AssetPicon::create_objects 5");
1010 icon = gui->audio_icon;
1011 icon_vframe = gui->audio_vframe;
1015 icon = gui->audio_icon;
1016 icon_vframe = gui->audio_vframe;
1021 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1024 if( indexable && !indexable->is_asset ) {
1025 icon = gui->video_icon;
1026 icon_vframe = gui->video_vframe;
1030 if( edl->tracks->playable_video_tracks() ) {
1031 if( mwindow->preferences->use_thumbnails ) {
1032 gui->unlock_window();
1033 AssetVIconThread *avt = gui->vicon_thread;
1034 char clip_icon_path[BCTEXTLEN];
1035 char *clip_icon = edl->local_session->clip_icon;
1037 if( clip_icon[0] ) {
1038 snprintf(clip_icon_path, sizeof(clip_icon_path),
1039 "%s/%s", File::get_config_path(), clip_icon);
1040 vframe = VFramePng::vframe_png(clip_icon_path);
1043 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1044 delete vframe; vframe = 0;
1046 int edl_h = edl->get_h(), edl_w = edl->get_w();
1047 int height = edl_h > 0 ? edl_h : 1;
1048 int width = edl_w > 0 ? edl_w : 1;
1049 int color_model = edl->session->color_model;
1051 //printf("render clip: %s\n", name);
1052 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1053 char string[BCTEXTLEN];
1054 sprintf(string, _("Rendering %s"), name);
1055 mwindow->gui->lock_window("AssetPicon::create_objects");
1056 mwindow->gui->show_message(string);
1057 mwindow->gui->unlock_window();
1058 open_render_engine(edl, 0);
1059 render_video(0, gui->temp_picon);
1060 close_render_engine();
1061 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1062 vframe->transfer_from(gui->temp_picon);
1064 vframe->write_png(clip_icon_path);
1066 pixmap_w = pixmap_h * width / height;
1067 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1068 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1069 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1070 icon_vframe->transfer_from(vframe);
1072 gui->lock_window("AssetPicon::create_objects 0");
1073 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1074 icon->draw_vframe(icon_vframe,
1075 0, 0, pixmap_w, pixmap_h, 0, 0);
1078 icon = gui->clip_icon;
1079 icon_vframe = gui->clip_vframe;
1083 if( edl->tracks->playable_audio_tracks() ) {
1084 if( mwindow->preferences->use_thumbnails ) {
1085 gui->unlock_window();
1086 char clip_icon_path[BCTEXTLEN];
1087 char *clip_icon = edl->local_session->clip_icon;
1088 if( clip_icon[0] ) {
1089 snprintf(clip_icon_path, sizeof(clip_icon_path),
1090 "%s/%s", File::get_config_path(), clip_icon);
1091 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1093 if( !icon_vframe ) {
1094 pixmap_w = pixmap_h * 16/9;
1095 icon_vframe = new VFrame(0,
1096 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1097 icon_vframe->clear_frame();
1098 char string[BCTEXTLEN];
1099 sprintf(string, _("Rendering %s"), name);
1100 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1101 mwindow->gui->show_message(string);
1102 mwindow->gui->unlock_window();
1103 int sample_rate = edl->get_sample_rate();
1104 int channels = edl->get_audio_channels();
1105 if( channels > 2 ) channels = 2;
1106 int64_t audio_samples = edl->get_audio_samples();
1107 double duration = (double)audio_samples / sample_rate;
1108 draw_hue_bar(icon_vframe, duration);
1109 Samples *samples[MAX_CHANNELS];
1110 int bfrsz = sample_rate;
1111 for( int i=0; i<MAX_CHANNELS; ++i )
1112 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1113 open_render_engine(edl, 1);
1114 render_audio(0, samples, bfrsz);
1115 close_render_engine();
1116 gui->lock_window("AssetPicon::create_objects 4");
1117 static int line_colors[2] = { GREEN, YELLOW };
1118 static int base_colors[2] = { RED, PINK };
1119 for( int i=channels; --i>=0; ) {
1120 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1121 base_colors[i], line_colors[i]);
1123 for( int i=0; i<channels; ++i ) delete samples[i];
1124 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1127 pixmap_w = icon_vframe->get_w();
1128 pixmap_h = icon_vframe->get_h();
1130 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1131 icon->draw_vframe(icon_vframe,
1132 0, 0, pixmap_w, pixmap_h, 0, 0);
1135 icon = gui->clip_icon;
1136 icon_vframe = gui->clip_vframe;
1142 strcpy(name, _(plugin->title));
1144 icon_vframe = plugin->get_picon();
1146 icon = gui->create_pixmap(icon_vframe);
1147 else if( plugin->audio ) {
1148 if( plugin->transition ) {
1149 icon = gui->atransition_icon;
1150 icon_vframe = gui->atransition_vframe;
1152 else if( plugin->is_ffmpeg() ) {
1153 icon = gui->ff_aud_icon;
1154 icon_vframe = gui->ff_aud_vframe;
1156 else if( plugin->is_ladspa() ) {
1157 icon = gui->ladspa_icon;
1158 icon_vframe = gui->ladspa_vframe;
1161 icon = gui->aeffect_icon;
1162 icon_vframe = gui->aeffect_vframe;
1165 else if( plugin->video ) {
1166 if( plugin->transition ) {
1167 icon = gui->vtransition_icon;
1168 icon_vframe = gui->vtransition_vframe;
1170 else if( plugin->is_ffmpeg() ) {
1171 icon = gui->ff_vid_icon;
1172 icon_vframe = gui->ff_vid_vframe;
1175 icon = gui->veffect_icon;
1176 icon_vframe = gui->veffect_vframe;
1184 mwindow->edl->session->time_format,
1185 mwindow->edl->session->sample_rate,
1186 mwindow->edl->session->frame_rate,
1187 mwindow->edl->session->frames_per_foot);
1189 icon = gui->label_icon;
1190 icon_vframe = gui->label_vframe;
1193 icon = gui->file_icon;
1194 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1197 set_icon_vframe(icon_vframe);
1200 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1201 : BC_Window(_(PROGRAM_NAME ": Resources"),
1202 mwindow->session->awindow_x, mwindow->session->awindow_y,
1203 mwindow->session->awindow_w, mwindow->session->awindow_h,
1206 this->mwindow = mwindow;
1207 this->awindow = awindow;
1209 file_vframe = 0; file_icon = 0;
1210 folder_vframe = 0; folder_icon = 0;
1211 audio_vframe = 0; audio_icon = 0;
1212 video_vframe = 0; video_icon = 0;
1213 label_vframe = 0; label_icon = 0;
1215 atransition_vframe = 0; atransition_icon = 0;
1216 vtransition_vframe = 0; vtransition_icon = 0;
1217 aeffect_vframe = 0; aeffect_icon = 0;
1218 ladspa_vframe = 0; ladspa_icon = 0;
1219 veffect_vframe = 0; veffect_icon = 0;
1220 ff_aud_vframe = 0; ff_aud_icon = 0;
1221 ff_vid_vframe = 0; ff_vid_icon = 0;
1223 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1224 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1225 clip_folder_vframe = 0; clip_folder_icon = 0;
1226 label_folder_vframe = 0; label_folder_icon = 0;
1227 media_folder_vframe = 0; media_folder_icon = 0;
1228 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1229 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1230 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1232 ladspa_vframe = 0; ladspa_icon = 0;
1233 ff_aud_vframe = 0; ff_aud_icon = 0;
1234 ff_vid_vframe = 0; ff_vid_icon = 0;
1236 clip_vframe = 0; clip_icon = 0;
1237 atransition_vframe = 0; atransition_icon = 0;
1238 vtransition_vframe = 0; vtransition_icon = 0;
1239 aeffect_vframe = 0; aeffect_icon = 0;
1240 veffect_vframe = 0; veffect_icon = 0;
1242 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1244 effectlist_menu = 0;
1249 folderlist_menu = 0;
1252 allow_iconlisting = 1;
1257 displayed_folder = AW_NO_FOLDER;
1258 new_folder_thread = 0;
1259 modify_folder_thread = 0;
1260 folder_lock = new Mutex("AWindowGUI::folder_lock");
1263 AWindowGUI::~AWindowGUI()
1265 assets.remove_all_objects();
1266 folders.remove_all_objects();
1267 aeffects.remove_all_objects();
1268 veffects.remove_all_objects();
1269 atransitions.remove_all_objects();
1270 vtransitions.remove_all_objects();
1271 labellist.remove_all_objects();
1272 displayed_assets[1].remove_all_objects();
1274 delete new_folder_thread;
1275 delete modify_folder_thread;
1276 delete vicon_thread;
1281 delete remove_plugin;
1283 delete file_vframe; delete file_icon;
1284 delete folder_vframe; delete folder_icon;
1285 delete audio_vframe; delete audio_icon;
1286 delete video_vframe; delete video_icon;
1287 delete label_vframe; delete label_icon;
1288 delete clip_vframe; delete clip_icon;
1289 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1290 delete atransition_folder_vframe; delete atransition_folder_icon;
1291 delete veffect_folder_vframe; delete veffect_folder_icon;
1292 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1293 delete clip_folder_vframe; delete clip_folder_icon;
1294 delete label_folder_vframe; delete label_folder_icon;
1295 delete media_folder_vframe; delete media_folder_icon;
1296 delete proxy_folder_vframe; delete proxy_folder_icon;
1297 delete ladspa_vframe; delete ladspa_icon;
1298 delete ff_aud_vframe; delete ff_aud_icon;
1299 delete ff_vid_vframe; delete ff_vid_icon;
1300 delete atransition_vframe; delete atransition_icon;
1301 delete vtransition_vframe; delete vtransition_icon;
1302 delete aeffect_vframe; delete aeffect_icon;
1303 delete veffect_vframe; delete veffect_icon;
1307 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1309 return icon == file_icon ||
1310 icon == folder_icon ||
1311 icon == audio_icon ||
1312 icon == video_icon ||
1313 icon == clip_icon ||
1314 icon == label_icon ||
1315 icon == vtransition_icon ||
1316 icon == atransition_icon ||
1317 icon == veffect_icon ||
1318 icon == aeffect_icon ||
1319 icon == ladspa_icon ||
1320 icon == ff_aud_icon ||
1321 icon == ff_vid_icon ||
1322 icon == aeffect_folder_icon ||
1323 icon == veffect_folder_icon ||
1324 icon == atransition_folder_icon ||
1325 icon == vtransition_folder_icon ||
1326 icon == label_folder_icon ||
1327 icon == clip_folder_icon ||
1328 icon == media_folder_icon ||
1329 icon == proxy_folder_icon;
1332 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1334 char png_path[BCTEXTLEN];
1335 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1336 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1337 File::get_plugin_path(), plugin_icons, name);
1338 if( access(png_path, R_OK) ) return 0;
1339 return VFramePng::vframe_png(png_path,0,0);
1342 VFrame *AWindowGUI::get_picon(const char *name)
1344 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1346 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1347 snprintf(pp, ep-pp, "%s.png", name);
1348 unsigned char *data = mwindow->theme->get_image_data(png_name);
1349 if( data ) vframe = new VFramePng(data, 0.);
1354 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1356 vfrm = get_picon(fn);
1357 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1358 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1360 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1362 vfrm = get_picon(fn);
1363 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1364 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1366 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1368 vfrm = get_picon(fn);
1369 if( !vfrm ) vfrm = new VFramePng(png);
1370 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1373 void AWindowGUI::create_objects()
1375 lock_window("AWindowGUI::create_objects");
1376 asset_titles[0] = C_("Title");
1377 asset_titles[1] = _("Comments");
1379 set_icon(mwindow->theme->get_image("awindow_icon"));
1381 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1382 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1383 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1384 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1385 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1387 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1388 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1389 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1390 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1391 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1392 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1393 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1394 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1396 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1397 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1398 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1399 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1400 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1401 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1402 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1403 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1405 theme_icon(clip_vframe, clip_icon, "clip_icon");
1406 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1407 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1408 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1409 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1411 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1412 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1413 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1414 folder_lock->lock("AWindowGUI::create_objects");
1415 // Mandatory folders
1416 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1417 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1418 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1419 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1420 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1421 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1422 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1423 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1425 create_label_folder();
1426 folder_lock->unlock();
1428 mwindow->theme->get_awindow_sizes(this);
1429 load_defaults(mwindow->defaults);
1430 new_folder_thread = new NewFolderThread(this);
1431 modify_folder_thread = new ModifyFolderThread(this);
1433 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1434 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1435 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1436 search_text->create_objects();
1437 int dy = search_text->get_h() + 10;
1439 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1441 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1442 asset_list->update_vicon_area();
1443 vicon_thread->start();
1444 vicon_audio = new AssetVIconAudio(this);
1446 add_subwindow(divider = new AWindowDivider(mwindow, this,
1447 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1448 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1450 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1452 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1453 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1454 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1455 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1456 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1457 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1458 add_tools->create_objects();
1459 fy += add_tools->get_h(); fh -= add_tools->get_h();
1460 add_subwindow(folder_list = new AWindowFolders(mwindow,
1461 this, fx, fy, fw, fh));
1463 folder_list->load_expanders();
1465 //int x = mwindow->theme->abuttons_x;
1466 //int y = mwindow->theme->abuttons_y;
1468 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1469 asset_menu->create_objects();
1470 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1471 clip_menu->create_objects();
1472 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1473 label_menu->create_objects();
1474 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1475 proxy_menu->create_objects();
1477 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1478 effectlist_menu->create_objects();
1479 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1480 assetlist_menu->create_objects();
1481 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1482 cliplist_menu->create_objects();
1483 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1484 labellist_menu->create_objects();
1485 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1486 proxylist_menu->create_objects();
1488 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1489 folderlist_menu->create_objects();
1491 create_custom_xatoms();
1495 int AWindowGUI::resize_event(int w, int h)
1497 mwindow->session->awindow_x = get_x();
1498 mwindow->session->awindow_y = get_y();
1499 mwindow->session->awindow_w = w;
1500 mwindow->session->awindow_h = h;
1502 mwindow->theme->get_awindow_sizes(this);
1503 mwindow->theme->draw_awindow_bg(this);
1504 reposition_objects();
1506 // int x = mwindow->theme->abuttons_x;
1507 // int y = mwindow->theme->abuttons_y;
1508 // new_bin->reposition_window(x, y);
1509 // x += new_bin->get_w();
1510 // delete_bin->reposition_window(x, y);
1511 // x += delete_bin->get_w();
1512 // rename_bin->reposition_window(x, y);
1513 // x += rename_bin->get_w();
1514 // delete_disk->reposition_window(x, y);
1515 // x += delete_disk->get_w();
1516 // delete_project->reposition_window(x, y);
1517 // x += delete_project->get_w();
1518 // info->reposition_window(x, y);
1519 // x += info->get_w();
1520 // redraw_index->reposition_window(x, y);
1521 // x += redraw_index->get_w();
1522 // paste->reposition_window(x, y);
1523 // x += paste->get_w();
1524 // append->reposition_window(x, y);
1525 // x += append->get_w();
1526 // view->reposition_window(x, y);
1528 BC_WindowBase::resize_event(w, h);
1529 asset_list->update_vicon_area();
1533 int AWindowGUI::translation_event()
1535 mwindow->session->awindow_x = get_x();
1536 mwindow->session->awindow_y = get_y();
1540 void AWindowGUI::reposition_objects()
1542 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1543 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1544 search_text->reposition_window(x1, y1+5, w1);
1545 int dy = search_text->get_h() + 10;
1547 asset_list->reposition_window(x1, y1, w1, h1);
1548 divider->reposition_window(
1549 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1550 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1551 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1552 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1553 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1554 avicon_drawing->reposition_window(fw-avicon_w, fy);
1555 fy += add_tools->get_h(); fh -= add_tools->get_h();
1556 folder_list->reposition_window(fx, fy, fw, fh);
1559 int AWindowGUI::save_defaults(BC_Hash *defaults)
1561 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1562 defaults->update("VICON_DRAWING", vicon_drawing);
1566 int AWindowGUI::load_defaults(BC_Hash *defaults)
1568 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1569 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1573 int AWindowGUI::close_event()
1576 mwindow->session->show_awindow = 0;
1579 mwindow->gui->lock_window("AWindowGUI::close_event");
1580 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1581 mwindow->gui->unlock_window();
1583 lock_window("AWindowGUI::close_event");
1584 save_defaults(mwindow->defaults);
1585 mwindow->save_defaults();
1589 void AWindowGUI::start_vicon_drawing()
1591 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1592 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1593 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1594 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1595 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1596 switch( mwindow->edl->session->assetlist_format ) {
1598 case ASSETS_ICONS_PACKED:
1599 case ASSETS_ICON_LIST:
1600 asset_list->update_vicon_area();
1601 vicon_thread->start_drawing();
1609 void AWindowGUI::stop_vicon_drawing()
1611 if( vicon_thread->interrupted ) return;
1612 vicon_thread->stop_drawing();
1615 void AWindowGUI::close_view_popup()
1617 vicon_thread->close_view_popup();
1620 VFrame *AssetPicon::get_vicon_frame()
1622 if( !vicon ) return 0;
1623 if( gui->vicon_thread->interrupted ) return 0;
1624 VFrame *frame = vicon->frame();
1625 if( !frame ) return 0;
1627 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1628 vicon_frame->transfer_from(frame);
1632 int AWindowGUI::cycle_assetlist_format()
1634 EDLSession *session = mwindow->edl->session;
1635 int format = ASSETS_TEXT;
1636 if( allow_iconlisting ) {
1637 switch( session->assetlist_format ) {
1639 format = ASSETS_ICONS;
1642 format = ASSETS_ICONS_PACKED;
1644 case ASSETS_ICONS_PACKED:
1645 format = ASSETS_ICON_LIST;
1647 case ASSETS_ICON_LIST:
1648 format = ASSETS_TEXT;
1652 stop_vicon_drawing();
1653 session->assetlist_format = format;
1654 asset_list->update_format(session->assetlist_format, 0);
1655 async_update_assets();
1656 start_vicon_drawing();
1660 AWindowRemovePluginGUI::
1661 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1662 int x, int y, PluginServer *plugin)
1663 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1665 this->awindow = awindow;
1666 this->thread = thread;
1667 this->plugin = plugin;
1668 VFrame *vframe = plugin->get_picon();
1669 icon = vframe ? create_pixmap(vframe) : 0;
1670 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1673 AWindowRemovePluginGUI::
1674 ~AWindowRemovePluginGUI()
1676 if( !awindow->gui->protected_pixmap(icon) )
1678 plugin_list.remove_all();
1681 void AWindowRemovePluginGUI::create_objects()
1683 lock_window("AWindowRemovePluginGUI::create_objects");
1684 BC_Button *ok_button = new BC_OKButton(this);
1685 add_subwindow(ok_button);
1686 BC_Button *cancel_button = new BC_CancelButton(this);
1687 add_subwindow(cancel_button);
1689 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1690 add_subwindow(title);
1691 y += title->get_h() + 5;
1692 list = new BC_ListBox(x, y,
1693 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1694 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1695 add_subwindow(list);
1700 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1703 for( int i=0; i<folder.size(); ) {
1704 AssetPicon *picon = (AssetPicon *)folder[i];
1705 if( picon->plugin == plugin ) {
1706 folder.remove_object_number(i);
1715 void AWindowRemovePlugin::handle_close_event(int result)
1718 printf(_("remove %s\n"), plugin->path);
1719 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1720 ArrayList<BC_ListBoxItem*> *folder =
1721 plugin->audio ? plugin->transition ?
1722 &awindow->gui->atransitions :
1723 &awindow->gui->aeffects :
1724 plugin->video ? plugin->transition ?
1725 &awindow->gui->vtransitions :
1726 &awindow->gui->veffects :
1728 if( folder ) remove_plugin(plugin, *folder);
1729 MWindow *mwindow = awindow->mwindow;
1730 awindow->gui->unlock_window();
1731 char plugin_path[BCTEXTLEN];
1732 strcpy(plugin_path, plugin->path);
1733 mwindow->plugindb->remove(plugin);
1734 remove(plugin_path);
1735 char index_path[BCTEXTLEN];
1736 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1738 char picon_path[BCTEXTLEN];
1740 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1741 File::get_plugin_path());
1742 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1743 plugin->get_plugin_png_name(png_name);
1744 fs.update(picon_path);
1745 for( int i=0; i<fs.dir_list.total; ++i ) {
1746 char *fs_path = fs.dir_list[i]->path;
1747 if( !fs.is_dir(fs_path) ) continue;
1748 snprintf(png_path, sizeof(picon_path), "%s/%s",
1752 delete plugin; plugin = 0;
1753 awindow->gui->async_update_assets();
1757 AWindowRemovePlugin::
1758 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1761 this->awindow = awindow;
1762 this->plugin = plugin;
1765 AWindowRemovePlugin::
1766 ~AWindowRemovePlugin()
1771 BC_Window* AWindowRemovePlugin::new_gui()
1773 int x = awindow->gui->get_abs_cursor_x(0);
1774 int y = awindow->gui->get_abs_cursor_y(0);
1775 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1776 gui->create_objects();
1780 int AWindowGUI::keypress_event()
1782 switch( get_keypress() ) {
1790 if( !ctrl_down() && !shift_down() ) {
1791 assetlist_menu->load_file->handle_event();
1796 return cycle_assetlist_format();
1798 if( shift_down() && ctrl_down() ) {
1799 PluginServer* plugin = selected_plugin();
1800 if( !plugin ) break;
1801 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1803 remove_plugin->start();
1804 lock_window("AWindowGUI::keypress_event 1");
1808 if( shift_down() ) {
1809 mwindow->awindow->asset_remove->start();
1813 mwindow->remove_assets_from_project(1, 1,
1814 mwindow->session->drag_assets,
1815 mwindow->session->drag_clips);
1816 lock_window("AWindowGUI::keypress_event 2");
1822 if( shift_down() && ctrl_down() ) {
1823 resend_event(mwindow->gui);
1833 int AWindowGUI::create_custom_xatoms()
1835 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1838 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1840 if( event->message_type == UpdateAssetsXAtom ) {
1847 void AWindowGUI::async_update_assets()
1850 event.message_type = UpdateAssetsXAtom;
1851 send_custom_xatom(&event);
1855 void AWindowGUI::update_folder_list()
1857 for( int i = 0; i < folders.total; i++ ) {
1858 AssetPicon *picon = (AssetPicon*)folders.values[i];
1862 // Search assets for folders
1863 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1864 BinFolder *bin_folder = mwindow->edl->folders[i];
1867 for( int j = 0; j < folders.total; j++ ) {
1868 AssetPicon *picon = (AssetPicon*)folders[j];
1869 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1877 const char *title = bin_folder->title;
1878 int folder = bin_folder->awindow_folder;
1879 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1880 picon->create_objects();
1881 folders.append(picon);
1885 // Delete unused non-persistent folders
1886 int do_autoplace = 0;
1887 for( int i=folders.total; --i>=0; ) {
1888 AssetPicon *picon = (AssetPicon*)folders.values[i];
1889 if( !picon->in_use && !picon->persistent ) {
1891 folders.remove_number(i);
1896 folder_list->set_autoplacement(&folders, 0, 1);
1899 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1900 int do_audio, int do_video, int is_realtime, int is_transition)
1902 ArrayList<PluginServer*> plugin_list;
1903 // Get pointers to plugindb entries
1904 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1907 for( int i = 0; i < plugin_list.total; i++ ) {
1908 PluginServer *server = plugin_list.values[i];
1909 int visible = plugin_visibility & (1<<server->dir_idx);
1910 if( !visible ) continue;
1911 // Create new listitem
1912 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1913 picon->create_objects();
1914 output->append(picon);
1918 void AWindowGUI::create_label_folder()
1921 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1922 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1923 picon->create_objects();
1924 labellist.append(picon);
1929 void AWindowGUI::update_asset_list()
1931 ArrayList<AssetPicon *> new_assets;
1932 for( int i = 0; i < assets.total; i++ ) {
1933 AssetPicon *picon = (AssetPicon*)assets.values[i];
1937 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1938 // Synchronize EDL clips
1939 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1942 // Look for clip in existing listitems
1943 for( int j = 0; j < assets.total && !exists; j++ ) {
1944 AssetPicon *picon = (AssetPicon*)assets.values[j];
1946 if( picon->id == mwindow->edl->clips[i]->id ) {
1947 picon->edl = mwindow->edl->clips[i];
1948 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1954 // Create new listitem
1956 AssetPicon *picon = new AssetPicon(mwindow,
1957 this, mwindow->edl->clips[i]);
1958 new_assets.append(picon);
1962 // Synchronize EDL assets
1963 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1966 // Look for asset in existing listitems
1967 for( int j = 0; j < assets.total && !exists; j++ ) {
1968 AssetPicon *picon = (AssetPicon*)assets.values[j];
1970 if( picon->id == current->id ) {
1971 picon->indexable = current;
1977 // Create new listitem
1979 AssetPicon *picon = new AssetPicon(mwindow,
1981 new_assets.append(picon);
1985 // Synchronize nested EDLs
1986 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1988 EDL *nested_edl = mwindow->edl->nested_edls[i];
1990 // Look for asset in existing listitems
1991 for( int j=0; j<assets.total && !exists; ++j ) {
1992 AssetPicon *picon = (AssetPicon*)assets.values[j];
1994 if( picon->id == nested_edl->id ) {
1995 picon->indexable = nested_edl;
2001 // Create new listitem
2003 AssetPicon *picon = new AssetPicon(mwindow,
2004 this, (Indexable*)nested_edl);
2005 new_assets.append(picon);
2008 mwindow->gui->unlock_window();
2010 for( int i=0; i<new_assets.size(); ++i ) {
2011 AssetPicon *picon = new_assets[i];
2012 picon->create_objects();
2013 if( picon->indexable )
2014 picon->foldernum = AW_MEDIA_FOLDER;
2015 else if( picon->edl )
2016 picon->foldernum = AW_CLIP_FOLDER;
2017 assets.append(picon);
2020 mwindow->gui->lock_window();
2021 mwindow->gui->default_message();
2022 mwindow->gui->unlock_window();
2024 for( int i = assets.size() - 1; i >= 0; i-- ) {
2025 AssetPicon *picon = (AssetPicon*)assets.get(i);
2026 if( !picon->in_use ) {
2028 assets.remove_number(i);
2031 if( picon->indexable && picon->indexable->is_asset ) {
2033 picon->comments_time = !stat(picon->indexable->path, &st) ?
2039 void AWindowGUI::update_picon(Indexable *indexable)
2042 for( int i = 0; i < assets.total; i++ ) {
2043 AssetPicon *picon = (AssetPicon*)assets.values[i];
2044 if( picon->indexable == indexable ||
2045 picon->edl == (EDL *)indexable ) {
2046 char name[BCTEXTLEN];
2048 fs.extract_name(name, indexable->path);
2049 picon->set_text(name);
2050 vicon = picon->vicon;
2055 stop_vicon_drawing();
2056 vicon->clear_images();
2057 vicon->reset(indexable->get_frame_rate());
2058 start_vicon_drawing();
2062 void AWindowGUI::sort_assets()
2064 folder_lock->lock("AWindowGUI::sort_assets");
2065 switch( mwindow->edl->session->awindow_folder ) {
2066 case AW_AEFFECT_FOLDER:
2067 sort_picons(&aeffects);
2069 case AW_VEFFECT_FOLDER:
2070 sort_picons(&veffects);
2072 case AW_ATRANSITION_FOLDER:
2073 sort_picons(&atransitions);
2075 case AW_VTRANSITION_FOLDER:
2076 sort_picons(&vtransitions);
2078 case AW_LABEL_FOLDER:
2079 sort_picons(&labellist);
2082 sort_picons(&assets);
2086 asset_list->update_format(asset_list->get_format(), 0);
2087 folder_lock->unlock();
2091 void AWindowGUI::sort_folders()
2093 folder_lock->lock("AWindowGUI::update_assets");
2094 // folder_list->collapse_recursive(&folders, 0);
2095 folder_list->set_autoplacement(&folders, 0, 1);
2096 sort_picons(&folders);
2097 folder_list->update_format(folder_list->get_format(), 0);
2098 folder_lock->unlock();
2102 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2104 Asset *proxy_asset = (Asset *)indexable;
2105 char path[BCTEXTLEN];
2106 int proxy_scale = mwindow->edl->session->proxy_scale;
2107 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2108 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2109 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2110 // make a clip from proxy video tracks and unproxy audio tracks
2111 EDL *proxy_edl = new EDL(mwindow->edl);
2112 proxy_edl->create_objects();
2113 proxy_edl->set_path(proxy_asset->path);
2114 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2115 strcpy(proxy_edl->local_session->clip_title, path);
2116 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2117 proxy_edl->session->video_tracks = proxy_asset->layers;
2118 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2119 proxy_edl->create_default_tracks();
2120 double length = proxy_asset->frame_rate > 0 ?
2121 ( proxy_asset->video_length >= 0 ?
2122 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2123 ( proxy_edl->session->si_useduration ?
2124 proxy_edl->session->si_duration :
2125 1.0 / proxy_asset->frame_rate ) ) :
2126 1.0 / proxy_edl->session->frame_rate;
2127 Track *current = proxy_edl->tracks->first;
2128 for( int vtrack=0; current; current=NEXT ) {
2129 if( current->data_type != TRACK_VIDEO ) continue;
2130 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2132 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2133 current = proxy_edl->tracks->first;
2134 for( int atrack=0; current; current=NEXT ) {
2135 if( current->data_type != TRACK_AUDIO ) continue;
2136 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2138 proxy_edl->folder_no = AW_PROXY_FOLDER;
2143 void AWindowGUI::collect_assets(int proxy)
2145 mwindow->session->drag_assets->remove_all();
2146 mwindow->session->drag_clips->remove_all();
2147 int i = 0; AssetPicon *result;
2148 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2149 Indexable *indexable = result->indexable;
2150 if( proxy && indexable && indexable->is_asset &&
2151 indexable->folder_no == AW_PROXY_FOLDER ) {
2152 EDL *drag_edl = collect_proxy(indexable);
2153 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2157 mwindow->session->drag_assets->append(indexable);
2161 mwindow->session->drag_clips->append(result->edl);
2167 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2169 // Remove current pointers
2170 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2171 dst[0].remove_all();
2172 dst[1].remove_all_objects();
2174 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2175 int folder = mwindow->edl->session->awindow_folder;
2176 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2177 mwindow->edl->get_folder(folder);
2179 // Create new pointers
2180 for( int i = 0; i < src->total; i++ ) {
2181 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2182 picon = (AssetPicon*)src->values[i];
2183 picon->sort_key = -1;
2184 if( !visible && bin_folder ) {
2185 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2186 picon->indexable ? picon->indexable :
2187 picon->edl ? picon->edl->get_proxy_asset() : 0;
2189 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2190 if( picon->sort_key < 0 ) continue;
2194 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2196 if( !visible && picon->edl && picon->edl->folder_no == folder )
2198 if( visible && sub_items ) {
2199 if( !sub_items->matches(picon->get_text()) )
2203 const char *text = search_text->get_text();
2204 if( text && text[0] )
2205 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2207 if( visible && picon->vicon && picon->vicon->hidden )
2208 picon->vicon->hidden = 0;
2210 BC_ListBoxItem *item2, *item1;
2211 dst[0].append(item1 = picon);
2213 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2216 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2217 else if( picon->comments_time ) {
2218 char date_time[BCSTRLEN];
2219 struct tm stm; localtime_r(&picon->comments_time, &stm);
2220 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2221 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2222 stm.tm_hour, stm.tm_min, stm.tm_sec);
2223 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2226 dst[1].append(item2 = new BC_ListBoxItem(""));
2227 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2228 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2233 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2235 int done = 0, changed = 0;
2238 for( int i=0; i<src->total-1; ++i ) {
2239 AssetPicon *item1 = (AssetPicon *)src->values[i];
2240 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2241 double v = item2->sort_key - item1->sort_key;
2242 if( v > 0 ) continue;
2244 const char *cp1 = item1->get_text();
2245 const char *bp1 = strrchr(cp1, '/');
2246 if( bp1 ) cp1 = bp1 + 1;
2247 const char *cp2 = item2->get_text();
2248 const char *bp2 = strrchr(cp2, '/');
2249 if( bp2 ) cp2 = bp2 + 1;
2250 if( strcmp(cp2, cp1) >= 0 ) continue;
2252 src->values[i + 1] = item1;
2253 src->values[i] = item2;
2254 done = 0; changed = 1;
2258 for( int i=0; i<src->total; ++i ) {
2259 AssetPicon *item = (AssetPicon *)src->values[i];
2260 item->set_autoplace_icon(1);
2261 item->set_autoplace_text(1);
2266 void AWindowGUI::filter_displayed_assets()
2268 //allow_iconlisting = 1;
2269 asset_titles[0] = C_("Title");
2270 asset_titles[1] = _("Comments");
2271 AssetPicon *picon = 0;
2272 int selected_folder = mwindow->edl->session->awindow_folder;
2273 // Ensure the current folder icon is highlighted
2274 for( int i = 0; i < folders.total; i++ ) {
2275 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2276 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2277 folder_item->set_selected(selected);
2278 if( selected ) picon = folder_item;
2281 ArrayList<BC_ListBoxItem*> *src = &assets;
2282 switch( selected_folder ) {
2283 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2284 case AW_VEFFECT_FOLDER: src = &veffects; break;
2285 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2286 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2287 case AW_LABEL_FOLDER: src = &labellist;
2288 asset_titles[0] = _("Time Stamps");
2289 asset_titles[1] = C_("Title");
2290 //allow_iconlisting = 0;
2293 copy_picons(picon, src);
2297 void AWindowGUI::update_assets()
2299 stop_vicon_drawing();
2300 folder_lock->lock("AWindowGUI::update_assets");
2301 update_folder_list();
2302 update_asset_list();
2303 labellist.remove_all_objects();
2304 create_label_folder();
2306 if( displayed_folder != mwindow->edl->session->awindow_folder )
2307 search_text->clear();
2308 vicon_thread->hide_vicons();
2309 filter_displayed_assets();
2310 folder_lock->unlock();
2312 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2313 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2315 int folder_xposition = folder_list->get_xposition();
2316 int folder_yposition = folder_list->get_yposition();
2317 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2319 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2320 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2322 int asset_xposition = asset_list->get_xposition();
2323 int asset_yposition = asset_list->get_yposition();
2324 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2325 displayed_folder = mwindow->edl->session->awindow_folder;
2326 asset_xposition = asset_yposition = 0;
2328 asset_list->update(displayed_assets, asset_titles,
2329 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2330 asset_xposition, asset_yposition, -1, 0);
2331 asset_list->center_selection();
2334 start_vicon_drawing();
2338 void AWindowGUI::update_effects()
2340 aeffects.remove_all_objects();
2341 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2342 veffects.remove_all_objects();
2343 create_persistent_folder(&veffects, 0, 1, 1, 0);
2344 atransitions.remove_all_objects();
2345 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2346 vtransitions.remove_all_objects();
2347 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2350 int AWindowGUI::drag_motion()
2352 if( get_hidden() ) return 0;
2358 int AWindowGUI::drag_stop()
2360 if( get_hidden() ) return 0;
2364 Indexable* AWindowGUI::selected_asset()
2366 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2367 return picon ? picon->indexable : 0;
2370 PluginServer* AWindowGUI::selected_plugin()
2372 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2373 return picon ? picon->plugin : 0;
2376 AssetPicon* AWindowGUI::selected_folder()
2378 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2389 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2390 : BC_SubWindow(x, y, w, h)
2392 this->mwindow = mwindow;
2395 AWindowDivider::~AWindowDivider()
2399 int AWindowDivider::button_press_event()
2401 if( is_event_win() && cursor_inside() ) {
2402 mwindow->session->current_operation = DRAG_PARTITION;
2408 int AWindowDivider::cursor_motion_event()
2410 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2412 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2413 int fw = gui->get_relative_cursor_x();
2414 if( fw > wmax ) fw = wmax;
2415 if( fw < wmin ) fw = wmin;
2416 mwindow->session->afolders_w = fw;
2417 mwindow->theme->get_awindow_sizes(gui);
2418 gui->reposition_objects();
2424 int AWindowDivider::button_release_event()
2426 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2427 mwindow->session->current_operation = NO_OPERATION;
2438 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2439 : BC_ListBox(x, y, w, h,
2440 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2441 LISTBOX_ICONS : LISTBOX_TEXT,
2442 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2443 0, // Titles for columns. Set to 0 for no titles
2444 0, // width of each column
2445 1, // Total columns.
2446 0, // Pixel of top of window.
2447 0, // If this listbox is a popup window
2448 LISTBOX_SINGLE, // Select one item or multiple items
2449 ICON_TOP, // Position of icon relative to text of each item
2452 this->mwindow = mwindow;
2459 AWindowFolders::~AWindowFolders()
2463 int AWindowFolders::selection_changed()
2465 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2466 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2467 // prefer expanded entry
2468 AWindowFolderItem *item = item1 ? item1 : item0;
2469 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2470 item1->set_selected(0);
2477 AssetPicon *picon = item->get_picon();
2478 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2480 gui->stop_vicon_drawing();
2482 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2483 gui->folderlist_menu->update_titles();
2484 gui->folderlist_menu->activate_menu();
2487 mwindow->edl->session->awindow_folder = picon->foldernum;
2488 gui->asset_list->draw_background();
2489 gui->async_update_assets();
2491 gui->start_vicon_drawing();
2496 int AWindowFolders::button_press_event()
2498 int result = BC_ListBox::button_press_event();
2501 if( get_buttonpress() == RIGHT_BUTTON &&
2502 is_event_win() && cursor_inside() ) {
2503 gui->folderlist_menu->update_titles();
2504 gui->folderlist_menu->activate_menu();
2512 int AWindowFolders::drag_stop()
2515 if( get_hidden() ) return 0;
2516 if( mwindow->session->current_operation == DRAG_ASSET &&
2517 gui->folder_list->cursor_above() ) { // check user folder
2518 int item_no = gui->folder_list->get_cursor_data_item_no();
2519 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2520 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2521 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2522 ArrayList<Indexable *> *drags = folder->is_clips ?
2523 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2524 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2525 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2527 mwindow->session->current_operation = ::NO_OPERATION;
2534 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2535 : AWindowFolderItem(text)
2537 this->parent = parent;
2540 int AWindowFolders::load_expanders()
2542 char expanders_path[BCTEXTLEN];
2543 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2544 FILE *fp = fopen(expanders_path, "r");
2546 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2547 File::get_cindat_path(), EXPANDERS_FILE);
2548 fp = fopen(expanders_path, "r");
2552 const char tab = '\t';
2553 char line[BCTEXTLEN]; line[0] = 0;
2554 AWindowFolderItem *item = 0, *parent;
2555 AWindowFolderSubItems *sub_items = 0;
2557 while( fgets(line,sizeof(line),fp) ) {
2558 if( line[0] == '#' ) continue;
2559 int i = strlen(line);
2560 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2561 if( i == 0 ) continue;
2563 for( char *cp=line; *cp==tab; ++cp ) ++i;
2565 int i = gui->folders.size();
2567 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2568 if( !strcmp(folder->get_text(),_(line)) ) break;
2570 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2575 if( i > k+1 ) continue;
2577 if( line[i] != '-' && sub_items ) {
2578 sub_items->names.append(cstrdup(_(&line[i])));
2586 item = item->parent;
2589 parent = item->parent;
2591 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2592 if( !sublist ) sublist = parent->new_sublist(1);
2593 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2594 sublist->append(item = sub_items);
2601 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2602 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2603 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2604 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2605 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2607 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2608 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2609 mwindow->edl->session->asset_columns, // width of each column
2610 1, // Total columns.
2611 0, // Pixel of top of window.
2612 0, // If this listbox is a popup window
2613 LISTBOX_MULTIPLE, // Select one item or multiple items
2614 ICON_TOP, // Position of icon relative to text of each item
2615 -1) // Allow drags, require shift for scrolling
2617 this->mwindow = mwindow;
2620 set_scroll_stretch(1, 1);
2623 AWindowAssets::~AWindowAssets()
2627 int AWindowAssets::button_press_event()
2629 AssetVIconThread *avt = gui->vicon_thread;
2630 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2631 int dir = 1, button = get_buttonpress();
2633 case WHEEL_DOWN: dir = -1; // fall thru
2635 int x = get_cursor_x(), y = get_cursor_y();
2636 if( avt->cursor_inside(x, y) && avt->view_win )
2637 return avt->zoom_scale(dir);
2642 int result = BC_ListBox::button_press_event();
2644 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2645 is_event_win() && cursor_inside() ) {
2646 BC_ListBox::deactivate_selection();
2647 int folder = mwindow->edl->session->awindow_folder;
2649 case AW_AEFFECT_FOLDER:
2650 case AW_VEFFECT_FOLDER:
2651 case AW_ATRANSITION_FOLDER:
2652 case AW_VTRANSITION_FOLDER:
2653 gui->effectlist_menu->update();
2654 gui->effectlist_menu->activate_menu();
2656 case AW_LABEL_FOLDER:
2657 gui->labellist_menu->update();
2658 gui->labellist_menu->activate_menu();
2660 case AW_CLIP_FOLDER:
2661 gui->cliplist_menu->update();
2662 gui->cliplist_menu->activate_menu();
2664 case AW_PROXY_FOLDER:
2665 gui->proxylist_menu->update();
2666 gui->proxylist_menu->activate_menu();
2669 case AW_MEDIA_FOLDER: {
2670 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2671 gui->assetlist_menu->update_titles(shots);
2672 gui->assetlist_menu->activate_menu();
2682 int AWindowAssets::handle_event()
2684 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2685 if( !asset_picon ) return 0;
2686 Indexable *picon_idxbl = asset_picon->indexable;
2687 EDL *picon_edl = asset_picon->edl;
2689 VWindow *vwindow = 0;
2690 switch( mwindow->edl->session->awindow_folder ) {
2691 case AW_AEFFECT_FOLDER:
2692 case AW_VEFFECT_FOLDER:
2693 case AW_ATRANSITION_FOLDER:
2694 case AW_VTRANSITION_FOLDER: return 1;
2695 case AW_PROXY_FOLDER:
2696 proxy = 1; // fall thru
2698 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2699 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2702 if( !vwindow || !vwindow->is_running() ) return 1;
2703 if( proxy && picon_idxbl ) {
2704 picon_edl = gui->collect_proxy(picon_idxbl);
2708 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2709 else if( picon_edl ) vwindow->change_source(picon_edl);
2713 int AWindowAssets::selection_changed()
2715 // Show popup window
2717 int folder = mwindow->edl->session->awindow_folder;
2718 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2719 (item = (AssetPicon*)get_selection(0, 0)) ) {
2721 case AW_AEFFECT_FOLDER:
2722 case AW_VEFFECT_FOLDER:
2723 case AW_ATRANSITION_FOLDER:
2724 case AW_VTRANSITION_FOLDER:
2725 gui->effectlist_menu->update();
2726 gui->effectlist_menu->activate_menu();
2728 case AW_LABEL_FOLDER:
2729 if( !item->label ) break;
2730 gui->label_menu->activate_menu();
2732 case AW_CLIP_FOLDER:
2733 if( !item->indexable && !item->edl ) break;
2734 gui->clip_menu->update();
2735 gui->clip_menu->activate_menu();
2737 case AW_PROXY_FOLDER:
2738 if( !item->indexable && !item->edl ) break;
2739 gui->proxy_menu->update();
2740 gui->proxy_menu->activate_menu();
2743 if( !item->indexable && !item->edl ) break;
2744 gui->asset_menu->update();
2745 gui->asset_menu->activate_menu();
2749 deactivate_selection();
2751 else if( gui->vicon_drawing && get_button_down() &&
2752 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2754 case AW_MEDIA_FOLDER:
2755 case AW_PROXY_FOLDER:
2756 case AWINDOW_USER_FOLDERS:
2757 if( get_buttonpress() == LEFT_BUTTON ||
2758 get_buttonpress() == MIDDLE_BUTTON ) {
2759 AssetVIcon *vicon = 0;
2760 if( !gui->vicon_thread->vicon )
2761 vicon = item->vicon;
2762 int draw_mode = vicon && get_buttonpress() == MIDDLE_BUTTON ?
2763 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2764 gui->vicon_thread->set_view_popup(vicon, draw_mode);
2767 case AW_CLIP_FOLDER:
2768 if( get_buttonpress() == LEFT_BUTTON ) {
2769 AssetVIcon *vicon = 0;
2770 if( !gui->vicon_thread->vicon )
2771 vicon = item->vicon;
2772 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2780 void AWindowAssets::draw_background()
2782 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2783 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2784 set_font(LARGEFONT);
2785 int folder = mwindow->edl->session->awindow_folder;
2786 const char *title = mwindow->edl->get_folder_name(folder);
2787 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2788 title, -1, get_bg_surface());
2791 int AWindowAssets::drag_start_event()
2793 int collect_pluginservers = 0;
2794 int collect_assets = 0, proxy = 0;
2796 if( BC_ListBox::drag_start_event() ) {
2797 switch( mwindow->edl->session->awindow_folder ) {
2798 case AW_AEFFECT_FOLDER:
2799 mwindow->session->current_operation = DRAG_AEFFECT;
2800 collect_pluginservers = 1;
2802 case AW_VEFFECT_FOLDER:
2803 mwindow->session->current_operation = DRAG_VEFFECT;
2804 collect_pluginservers = 1;
2806 case AW_ATRANSITION_FOLDER:
2807 mwindow->session->current_operation = DRAG_ATRANSITION;
2808 collect_pluginservers = 1;
2810 case AW_VTRANSITION_FOLDER:
2811 mwindow->session->current_operation = DRAG_VTRANSITION;
2812 collect_pluginservers = 1;
2814 case AW_LABEL_FOLDER:
2817 case AW_PROXY_FOLDER:
2818 proxy = 1; // fall thru
2819 case AW_MEDIA_FOLDER:
2821 mwindow->session->current_operation = DRAG_ASSET;
2826 if( collect_pluginservers ) {
2828 mwindow->session->drag_pluginservers->remove_all();
2831 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2832 if( !result ) break;
2834 mwindow->session->drag_pluginservers->append(result->plugin);
2838 if( collect_assets ) {
2839 gui->collect_assets(proxy);
2847 int AWindowAssets::drag_motion_event()
2849 BC_ListBox::drag_motion_event();
2852 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2853 mwindow->gui->drag_motion();
2854 mwindow->gui->unlock_window();
2856 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2857 VWindow *vwindow = mwindow->vwindows.get(i);
2858 if( !vwindow->is_running() ) continue;
2859 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2860 vwindow->gui->drag_motion();
2861 vwindow->gui->unlock_window();
2864 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2865 mwindow->cwindow->gui->drag_motion();
2866 mwindow->cwindow->gui->unlock_window();
2868 lock_window("AWindowAssets::drag_motion_event");
2869 if( mwindow->session->current_operation == DRAG_ASSET &&
2870 gui->folder_list->cursor_above() ) { // highlight user folder
2871 BC_ListBoxItem *item = 0;
2872 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2873 if( item_no >= 0 ) {
2874 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2875 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2878 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2879 int folder_xposition = gui->folder_list->get_xposition();
2880 int folder_yposition = gui->folder_list->get_yposition();
2881 gui->folder_list->update(&gui->folders, 0, 0, 1,
2882 folder_xposition, folder_yposition, item_no, 0, 1);
2887 int AWindowAssets::drag_stop_event()
2891 result = gui->drag_stop();
2896 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2897 result = mwindow->gui->drag_stop();
2898 mwindow->gui->unlock_window();
2902 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2903 VWindow *vwindow = mwindow->vwindows.get(i);
2904 if( !vwindow ) continue;
2905 if( !vwindow->is_running() ) continue;
2906 if( vwindow->gui->is_hidden() ) continue;
2907 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2908 if( vwindow->gui->cursor_above() &&
2909 vwindow->gui->get_cursor_over_window() ) {
2910 result = vwindow->gui->drag_stop();
2912 vwindow->gui->unlock_window();
2917 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2918 result = mwindow->cwindow->gui->drag_stop();
2919 mwindow->cwindow->gui->unlock_window();
2922 lock_window("AWindowAssets::drag_stop_event");
2924 result = gui->folder_list->drag_stop();
2929 get_drag_popup()->set_animation(0);
2931 BC_ListBox::drag_stop_event();
2932 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2933 mwindow->session->current_operation = ::NO_OPERATION;
2938 int AWindowAssets::column_resize_event()
2940 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2941 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2945 int AWindowAssets::focus_in_event()
2947 int ret = BC_ListBox::focus_in_event();
2948 gui->start_vicon_drawing();
2952 int AWindowAssets::focus_out_event()
2954 gui->stop_vicon_drawing();
2955 return BC_ListBox::focus_out_event();
2958 void AWindowAssets::update_vicon_area()
2960 int x0 = 0, x1 = get_w();
2961 int y0 = get_title_h();
2963 if( is_highlighted() ) {
2964 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2965 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2967 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2970 int AWindowAssets::mouse_over_event(int no)
2972 if( gui->vicon_thread->viewing &&
2973 no >= 0 && no < gui->displayed_assets[0].size() ) {
2974 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2975 gui->vicon_thread->set_view_popup(picon->vicon);
2981 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2982 : BC_TextBox(x, y, w, 1, "")
2984 this->search_text = search_text;
2987 int AWindowSearchTextBox::handle_event()
2989 return search_text->handle_event();
2992 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2994 this->mwindow = mwindow;
3000 void AWindowSearchText::create_objects()
3002 int x1 = x, y1 = y, margin = 10;
3003 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
3004 x1 += text_title->get_w() + margin;
3005 int w1 = gui->get_w() - x1 - 2*margin;
3006 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3009 int AWindowSearchText::handle_event()
3011 gui->async_update_assets();
3015 int AWindowSearchText::get_w()
3017 return text_box->get_w() + text_title->get_w() + 10;
3020 int AWindowSearchText::get_h()
3022 return bmax(text_box->get_h(),text_title->get_h());
3025 void AWindowSearchText::reposition_window(int x, int y, int w)
3027 int x1 = x, y1 = y, margin = 10;
3028 text_title->reposition_window(x1, y1);
3029 x1 += text_title->get_w() + margin;
3030 int w1 = gui->get_w() - x1 - 2*margin;
3031 text_box->reposition_window(x1, y1, w1);
3034 const char *AWindowSearchText::get_text()
3036 return text_box->get_text();
3039 void AWindowSearchText::clear()
3041 text_box->update("");
3044 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3045 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3047 this->mwindow = mwindow;
3049 set_tooltip(_("Delete asset from disk"));
3052 int AWindowDeleteDisk::handle_event()
3057 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3058 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3060 this->mwindow = mwindow;
3062 set_tooltip(_("Delete asset from project"));
3065 int AWindowDeleteProject::handle_event()
3070 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3071 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3073 // this->mwindow = mwindow;
3075 // set_tooltip(_("Edit information on asset"));
3078 // int AWindowInfo::handle_event()
3080 // int cur_x, cur_y;
3081 // gui->get_abs_cursor(cur_x, cur_y, 0);
3082 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3086 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3087 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3089 this->mwindow = mwindow;
3091 set_tooltip(_("Redraw index"));
3094 int AWindowRedrawIndex::handle_event()
3099 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3100 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3102 this->mwindow = mwindow;
3104 set_tooltip(_("Paste asset on recordable tracks"));
3107 int AWindowPaste::handle_event()
3112 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3113 : BC_Button(x, y, mwindow->theme->appendasset_data)
3115 this->mwindow = mwindow;
3117 set_tooltip(_("Append asset in new tracks"));
3120 int AWindowAppend::handle_event()
3125 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3126 : BC_Button(x, y, mwindow->theme->viewasset_data)
3128 this->mwindow = mwindow;
3130 set_tooltip(_("View asset"));
3133 int AWindowView::handle_event()
3138 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3139 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3141 this->mwindow = mwindow;
3145 void AddTools::create_objects()
3148 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3149 vis |= 1 << PLUGIN_FFMPEG_ID;
3150 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3151 vis |= 1 << PLUGIN_LADSPA_ID;
3153 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3154 vis |= 1 << PLUGIN_LV2_ID;
3156 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3157 PluginServer *plugin = MWindow::plugindb->get(i);
3158 if( !plugin->audio && !plugin->video ) continue;
3159 int idx = plugin->dir_idx;
3160 uint32_t msk = 1 << idx;
3161 if( (msk & vis) != 0 ) continue;
3163 char parent[BCTEXTLEN];
3164 strcpy(parent, plugin->path);
3165 char *bp = strrchr(parent, '/');
3166 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3167 if( !bp ) bp = parent; else ++bp;
3168 add_item(new AddPluginItem(this, bp, idx));
3173 // plugin_dirs list from toplevel makefile include plugin_defs
3178 N_("audio_transitions")
3185 N_("video_transitions")
3188 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3189 : BC_MenuItem(_(text))
3193 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3194 int chk = (msk & vis) ? 1 : 0;
3198 int AddPluginItem::handle_event()
3200 int chk = get_checked() ^ 1;
3202 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3203 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3204 menu->gui->update_effects();
3205 menu->gui->save_defaults(menu->mwindow->defaults);
3206 menu->gui->async_update_assets();
3210 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3211 : BC_Toggle(x, y, images, agui->vicon_drawing)
3214 set_tooltip(_("Preview"));
3217 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3219 int text_line = -1, toggle_x = -1, toggle_y = -1;
3220 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3221 BC_Toggle::calculate_extents(agui, images, 1,
3222 &text_line, ww, hh, &toggle_x, &toggle_y,
3223 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3226 AVIconDrawing::~AVIconDrawing()
3230 int AVIconDrawing::handle_event()
3232 agui->vicon_drawing = get_value();
3233 if( agui->vicon_drawing )
3234 agui->start_vicon_drawing();
3236 agui->stop_vicon_drawing();
3241 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3242 : BC_MenuItem("","v",'v')
3244 this->mwindow = mwindow;
3248 int AWindowListFormat::handle_event()
3250 return gui->cycle_assetlist_format();
3253 void AWindowListFormat::update()
3255 EDLSession *session = mwindow->edl->session;
3256 const char *text = 0;
3257 switch( session->assetlist_format ) {
3259 text = _("Display icons");
3262 text = _("Display icons packed");
3264 case ASSETS_ICONS_PACKED:
3265 text = _("Display icon list");
3267 case ASSETS_ICON_LIST:
3268 text = _("Display text");
3274 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3275 : BC_MenuItem(_("Sort items"))
3277 this->mwindow = mwindow;
3281 int AWindowListSort::handle_event()
3287 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3290 this->select_used = select_used;
3291 this->action = action;
3294 int AssetSelectUsedItem::handle_event()
3296 MWindow *mwindow = select_used->mwindow;
3297 AWindowGUI *gui = select_used->gui;
3298 AWindowAssets *asset_list = gui->asset_list;
3299 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3304 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3308 asset_list->set_all_selected(data, 0);
3309 for( int i = 0; i < data->total; i++ ) {
3310 AssetPicon *picon = (AssetPicon*)data->values[i];
3311 Indexable *idxbl = picon->indexable ? picon->indexable :
3312 picon->edl ? picon->edl->get_proxy_asset() : 0;
3313 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3314 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3319 int asset_xposition = asset_list->get_xposition();
3320 int asset_yposition = asset_list->get_yposition();
3321 asset_list->update(gui->displayed_assets, gui->asset_titles,
3322 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3323 asset_xposition, asset_yposition, -1, 0);
3324 asset_list->center_selection();
3328 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3329 : BC_MenuItem(_("Select"))
3331 this->mwindow = mwindow;