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 int dir = 1, button = get_buttonpress();
333 case WHEEL_DOWN: dir = -1; // fall thru
334 case WHEEL_UP: return avt->zoom_scale(dir);
341 if( draw_mode != ASSET_VIEW_MEDIA_MAP ) return 0;
342 int x = get_cursor_x(), y = get_cursor_y();
343 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
344 AssetPicon *picon = vicon->picon;
345 MWindow *mwindow = picon->mwindow;
346 EDL *edl = mwindow->edl;
350 picon->indexable ? picon->indexable :
351 picon->edl ? picon->edl : 0;
352 if( !idxbl ) return 0;
353 double sample_rate = idxbl->get_sample_rate();
354 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
355 idxbl->get_audio_samples() / sample_rate : 0;
356 double frame_rate = idxbl->get_frame_rate();
357 double video_length = frame_rate > 0 && idxbl->have_video() ?
358 idxbl->get_video_frames() / frame_rate : 0;
359 double idxbl_length = bmax(audio_length, video_length);
360 double pos = x * idxbl_length / get_w();
361 double start = 0, end = idxbl_length;
362 double lt = DBL_MAX, rt = DBL_MAX;
363 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
364 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
365 Indexable *indexable = (Indexable *)edit->asset;
366 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
367 if( !indexable ) continue;
368 if( indexable->id == idxbl->id ||
369 (!indexable->is_asset == !idxbl->is_asset &&
370 !strcmp(indexable->path, idxbl->path)) ) {
371 double start_pos = track->from_units(edit->startsource);
372 double end_pos = track->from_units(edit->startsource + edit->length);
373 double dlt = pos - start_pos, drt = end_pos - pos;
374 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
375 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
376 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
377 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
381 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
382 VWindow *vwindow = mwindow->get_viewer(1, 0);
383 vwindow->change_source(idxbl);
384 mwindow->gui->unlock_window();
385 EDL *vedl = vwindow->get_edl();
386 vedl->set_inpoint(start);
387 vedl->set_outpoint(end);
388 vedl->local_session->set_selectionstart(start);
389 vedl->local_session->set_selectionend(end);
390 vwindow->update_position(CHANGE_NONE, 0, 1, 0);
393 if( y >= get_h()-bar_h ) {
395 if( !ctrl_down() && !shift_down() )
396 return cursor_motion_event();
398 picon->indexable ? picon->indexable :
399 picon->edl ? picon->edl : 0;
400 if( !idxbl ) return 0;
401 double total_length = mwindow->edl->tracks->total_length();
402 double pos = x * total_length / get_w();
403 double start = 0, end = total_length;
404 double lt = DBL_MAX, rt = DBL_MAX;
405 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
406 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
407 Indexable *indexable = (Indexable *)edit->asset;
408 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
409 if( !indexable ) continue;
410 if( indexable->id == idxbl->id ||
411 (!indexable->is_asset == !idxbl->is_asset &&
412 !strcmp(indexable->path, idxbl->path)) ) {
413 double start_pos = track->from_units(edit->startproject);
414 double end_pos = track->from_units(edit->startproject + edit->length);
415 double dlt = pos - start_pos, drt = end_pos - pos;
416 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
417 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
418 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
419 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
423 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
424 mwindow->select_point(!ctrl_down() && !shift_down() ? pos : start);
425 edl->local_session->set_selectionstart(start);
426 edl->local_session->set_selectionend(!shift_down() ? start : end);
427 mwindow->zoom_sample(edl->local_session->zoom_sample);
428 mwindow->gui->unlock_window();
434 int AssetViewPopup::button_release_event()
436 if( !is_event_win() ) return 0;
441 int AssetViewPopup::cursor_motion_event()
443 if( !is_event_win() ) return 0;
444 AssetVIconThread *avt = (AssetVIconThread *)vt;
445 if( !avt->vicon || draw_mode != ASSET_VIEW_MEDIA_MAP ) return 0;
446 if( !get_button_down() || get_buttonpress() != LEFT_BUTTON ||
447 ctrl_down() || alt_down() || shift_down() )
449 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
450 MWindow *mwindow = vicon->picon->mwindow;
451 EDL *edl = mwindow->edl;
453 int x = get_cursor_x();
454 double total_length = edl->tracks->total_length();
455 double pos = x * total_length / get_w();
456 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
457 mwindow->select_point(pos);
458 mwindow->zoom_sample(edl->local_session->zoom_sample);
459 mwindow->gui->unlock_window();
465 void AssetViewPopup::draw_vframe(VFrame *vframe)
467 switch( draw_mode ) {
468 case ASSET_VIEW_MEDIA:
469 case ASSET_VIEW_ICON:
470 ViewPopup::draw_vframe(vframe);
471 case ASSET_VIEW_NONE:
474 case ASSET_VIEW_MEDIA_MAP:
478 draw_box(0,0,get_w(),get_h());
480 int y2 = get_h()-bar_h;
481 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
482 AssetVIconThread *avt = (AssetVIconThread *)vt;
483 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
484 AssetPicon *picon = (AssetPicon *)vicon->picon;
486 picon->indexable ? picon->indexable :
487 picon->edl ? picon->edl : 0;
489 double sample_rate = idxbl->get_sample_rate();
490 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
491 idxbl->get_audio_samples() / sample_rate : 0;
492 double frame_rate = idxbl->get_frame_rate();
493 double video_length = frame_rate > 0 && idxbl->have_video() ?
494 idxbl->get_video_frames() / frame_rate : 0;
495 double idxbl_length = bmax(audio_length, video_length);
496 if( !idxbl_length ) idxbl_length = 1;
498 EDL *edl = picon->mwindow->edl;
499 double total_length = edl->tracks->total_length();
500 if( !total_length ) total_length = 1;
501 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
502 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
503 Indexable *indexable = (Indexable *)edit->asset;
504 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
505 if( !indexable ) continue;
506 if( indexable->id == idxbl->id ||
507 (!indexable->is_asset == !idxbl->is_asset &&
508 !strcmp(indexable->path, idxbl->path)) ) {
509 double pos1 = track->from_units(edit->startsource);
510 double pos2 = track->from_units(edit->startsource + edit->length);
511 double xscale = get_w() / idxbl_length;
512 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
514 draw_box(ex1,0, ex2-ex1,y1);
516 draw_line(ex1,0, ex1,y1);
517 draw_line(ex2,0, ex2,y1);
518 pos1 = track->from_units(edit->startproject);
519 pos2 = track->from_units(edit->startproject + edit->length);
520 xscale = get_w() / total_length;
521 int px1 = pos1 * xscale, px2 = pos2 * xscale;
523 draw_box(px1,y2, px2-px1,get_h()-y2);
525 draw_line(px1,y2, px1,get_h()-1);
526 draw_line(px2,y2, px2,get_h()-1);
529 draw_line(ex1,y1, px1,y2);
530 draw_line(ex2,y1, px2,y2);
537 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
538 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
539 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
542 draw_mode = ASSET_VIEW_NONE;
543 int vicon_cmodel = BC_RGB8;
544 switch( preferences->vicon_color_mode ) {
545 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
546 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
547 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
549 this->vicon_cmodel = vicon_cmodel;
550 this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
553 AssetVIconThread::~AssetVIconThread()
558 void AssetVIconThread::drawing_started()
560 draw_lock->lock("AssetVIconThread::drawing_started");
563 void AssetVIconThread::drawing_stopped()
568 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
570 gui->stop_vicon_drawing();
571 int mode = !v ? ASSET_VIEW_NONE :
572 draw_mode >= 0 ? draw_mode :
575 this->draw_mode = mode;
576 gui->start_vicon_drawing();
579 ViewPopup *AssetVIconThread::new_view_window()
581 BC_WindowBase *parent = wdw->get_parent();
582 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
583 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
584 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
585 int vx = viewing->get_vx(), rx = 0;
586 int vy = viewing->get_vy(), ry = 0;
587 wdw->get_root_coordinates(vx, vy, &rx, &ry);
588 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
589 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
590 AssetViewPopup *popup = new AssetViewPopup(this, draw_mode,
591 rx, ry, view_w, view_h);
592 if( draw_mode == ASSET_VIEW_MEDIA_MAP )
593 vicon->playing_audio = -1;
594 wdw->set_active_subwindow(popup);
599 AWindowFolderItem::AWindowFolderItem()
605 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
606 : BC_ListBoxItem(text, color)
611 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
612 : BC_ListBoxItem(text, icon, color)
617 AssetPicon *AWindowFolderItem::get_picon()
619 AWindowFolderItem *item = this;
620 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
621 return (AssetPicon*)item;
624 int AWindowFolderSubItems::matches(const char *text)
626 int i = names.size();
627 while( --i >= 0 && strcmp(names[i], text) );
629 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
630 i = sublist ? sublist->size() : 0;
632 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
633 if( item->matches(text) ) break;
636 return i >= 0 ? 1 : 0;
640 AssetPicon::AssetPicon(MWindow *mwindow,
641 AWindowGUI *gui, Indexable *indexable)
642 : AWindowFolderItem()
645 this->mwindow = mwindow;
647 this->indexable = indexable;
648 indexable->add_user();
649 this->id = indexable->id;
652 AssetPicon::AssetPicon(MWindow *mwindow,
653 AWindowGUI *gui, EDL *edl)
654 : AWindowFolderItem()
657 this->mwindow = mwindow;
664 AssetPicon::AssetPicon(MWindow *mwindow,
665 AWindowGUI *gui, int folder, int persist)
666 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
667 folder>=0 && folder<AWINDOW_FOLDERS ?
668 gui->folder_icons[folder] : gui->folder_icon)
672 this->mwindow = mwindow;
674 persistent = persist;
677 AssetPicon::AssetPicon(MWindow *mwindow,
678 AWindowGUI *gui, int folder, const char *title)
679 : AWindowFolderItem(title, gui->folder_icon)
683 this->mwindow = mwindow;
688 AssetPicon::AssetPicon(MWindow *mwindow,
689 AWindowGUI *gui, PluginServer *plugin)
690 : AWindowFolderItem()
693 this->mwindow = mwindow;
695 this->plugin = plugin;
698 AssetPicon::AssetPicon(MWindow *mwindow,
699 AWindowGUI *gui, Label *label)
700 : AWindowFolderItem()
703 this->mwindow = mwindow;
711 AssetPicon::~AssetPicon()
713 if( vicon ) vicon->remove_user();
715 if( indexable ) indexable->remove_user();
716 if( edl ) edl->remove_user();
717 if( icon && !gui->protected_pixmap(icon) ) {
719 if( !plugin ) delete icon_vframe;
723 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
725 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
727 float h = 300 * t, s = 1., v = 1.;
728 float r, g, b; // duration, 0..1hr == hue red..magenta
729 HSV::hsv_to_rgb(r,g,b, h,s,v);
730 int ih = frame->get_h()/8, iw = frame->get_w();
731 int ir = r * 256; CLAMP(ir, 0,255);
732 int ig = g * 256; CLAMP(ig, 0,255);
733 int ib = b * 256; CLAMP(ib, 0,255);
734 unsigned char **rows = frame->get_rows();
735 for( int y=0; y<ih; ++y ) {
736 unsigned char *rp = rows[y];
737 for( int x=0; x<iw; rp+=3,++x ) {
738 rp[0] = ir; rp[1] = ig; rp[2] = ib;
743 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
744 int base_color, int line_color, int x, int y, int w, int h)
746 int h1 = h-1, h2 = h/2, iy = h2;
747 int rgb_color = frame->pixel_rgb;
748 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
749 double min = *dp, max = min;
750 x2 = (len * (ix+1))/w;
751 for( int i=x1; i<x2; ++i ) {
752 double value = *dp++;
753 if( value < min ) min = value;
754 if( value > max ) max = value;
756 int ctr = (min + max) / 2;
757 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
758 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
759 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
760 frame->pixel_rgb = line_color;
761 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
762 frame->pixel_rgb = base_color;
763 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
766 frame->pixel_rgb = rgb_color;
769 void AssetPicon::reset()
777 foldernum = AW_NO_FOLDER;
789 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
791 TransportCommand command;
792 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
793 command.get_edl()->copy_all(edl);
794 command.change_type = CHANGE_ALL;
795 command.realtime = 0;
796 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
797 render_engine->set_vcache(mwindow->video_cache);
798 render_engine->set_acache(mwindow->audio_cache);
799 render_engine->arm_command(&command);
801 void AssetPicon::close_render_engine()
803 delete render_engine; render_engine = 0;
805 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
807 if( !render_engine || !render_engine->vrender ) return;
808 render_engine->vrender->process_buffer(vfrm, pos, 0);
810 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
812 if( !render_engine || !render_engine->arender ) return;
813 render_engine->arender->process_buffer(samples, len, pos);
816 void AssetPicon::create_objects()
819 char name[BCTEXTLEN];
820 int pixmap_w, pixmap_h;
822 int picon_h = mwindow->preferences->awindow_picon_h;
823 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
826 fs.extract_name(name, indexable->path);
830 set_text(strcpy(name, edl->local_session->clip_title));
834 if( indexable && indexable->is_asset ) {
835 Asset *asset = (Asset*)indexable;
836 if( asset->video_data ) {
837 if( mwindow->preferences->use_thumbnails ) {
838 gui->unlock_window();
839 File *file = mwindow->video_cache->check_out(asset,
844 int height = asset->height > 0 ? asset->height : 1;
845 pixmap_w = pixmap_h * asset->width / height;
848 file->set_video_position(0, 0);
850 if( gui->temp_picon &&
851 (gui->temp_picon->get_w() != asset->width ||
852 gui->temp_picon->get_h() != asset->height) ) {
853 delete gui->temp_picon;
857 if( !gui->temp_picon ) {
858 gui->temp_picon = new VFrame(0, -1,
859 asset->width, asset->height,
862 { char string[BCTEXTLEN];
863 sprintf(string, _("Reading %s"), name);
864 mwindow->gui->lock_window("AssetPicon::create_objects");
865 mwindow->gui->show_message(string);
866 mwindow->gui->unlock_window(); }
867 file->read_frame(gui->temp_picon);
868 mwindow->video_cache->check_in(asset);
870 gui->lock_window("AssetPicon::create_objects 0");
871 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
872 icon->draw_vframe(gui->temp_picon,
873 0, 0, pixmap_w, pixmap_h, 0, 0);
874 icon_vframe = new VFrame(0,
875 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
876 icon_vframe->transfer_from(gui->temp_picon);
877 if( asset->folder_no == AW_MEDIA_FOLDER ||
878 asset->folder_no == AW_PROXY_FOLDER ) {
880 double framerate = asset->get_frame_rate();
881 if( !framerate ) framerate = VICON_RATE;
882 int64_t frames = asset->get_video_frames();
883 double secs = frames / framerate;
884 if( secs > 5 ) secs = 5;
885 int64_t length = secs * gui->vicon_thread->refresh_rate;
886 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
887 if( asset->audio_data && secs > 0 ) {
888 gui->unlock_window();
889 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
890 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
892 gui->lock_window("AssetPicon::create_objects 1");
894 gui->vicon_thread->add_vicon(vicon);
898 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
899 gui->lock_window("AssetPicon::create_objects 2");
900 icon = gui->video_icon;
901 icon_vframe = gui->video_vframe;
905 icon = gui->video_icon;
906 icon_vframe = gui->video_vframe;
910 if( asset->audio_data ) {
911 if( mwindow->preferences->use_thumbnails ) {
912 gui->unlock_window();
913 File *file = mwindow->audio_cache->check_out(asset,
917 pixmap_w = pixmap_h * 16/9;
918 icon_vframe = new VFrame(0,
919 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
920 icon_vframe->clear_frame();
921 { char string[BCTEXTLEN];
922 sprintf(string, _("Reading %s"), name);
923 mwindow->gui->lock_window("AssetPicon::create_objects 3");
924 mwindow->gui->show_message(string);
925 mwindow->gui->unlock_window(); }
926 int sample_rate = asset->get_sample_rate();
927 int channels = asset->get_audio_channels();
928 if( channels > 2 ) channels = 2;
929 int64_t audio_samples = asset->get_audio_samples();
930 double duration = (double)audio_samples / sample_rate;
931 draw_hue_bar(icon_vframe, duration);
932 int bfrsz = sample_rate;
933 Samples samples(bfrsz);
934 static int line_colors[2] = { GREEN, YELLOW };
935 static int base_colors[2] = { RED, PINK };
936 for( int i=channels; --i>=0; ) {
937 file->set_channel(i);
938 file->set_audio_position(0);
939 file->read_samples(&samples, bfrsz);
940 draw_wave(icon_vframe, samples.get_data(), bfrsz,
941 base_colors[i], line_colors[i]);
943 mwindow->audio_cache->check_in(asset);
944 if( asset->folder_no == AW_MEDIA_FOLDER ) {
945 double secs = duration;
946 if( secs > 5 ) secs = 5;
947 double refresh_rate = gui->vicon_thread->refresh_rate;
948 int64_t length = secs * refresh_rate;
949 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
950 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
951 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
953 gui->vicon_thread->add_vicon(vicon);
955 gui->lock_window("AssetPicon::create_objects 4");
956 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
957 icon->draw_vframe(icon_vframe,
958 0, 0, pixmap_w, pixmap_h, 0, 0);
961 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
962 gui->lock_window("AssetPicon::create_objects 5");
963 icon = gui->audio_icon;
964 icon_vframe = gui->audio_vframe;
968 icon = gui->audio_icon;
969 icon_vframe = gui->audio_vframe;
974 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
977 if( indexable && !indexable->is_asset ) {
978 icon = gui->video_icon;
979 icon_vframe = gui->video_vframe;
983 if( edl->tracks->playable_video_tracks() ) {
984 if( mwindow->preferences->use_thumbnails ) {
985 gui->unlock_window();
986 AssetVIconThread *avt = gui->vicon_thread;
987 char clip_icon_path[BCTEXTLEN];
988 char *clip_icon = edl->local_session->clip_icon;
991 snprintf(clip_icon_path, sizeof(clip_icon_path),
992 "%s/%s", File::get_config_path(), clip_icon);
993 vframe = VFramePng::vframe_png(clip_icon_path);
996 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
997 delete vframe; vframe = 0;
999 int edl_h = edl->get_h(), edl_w = edl->get_w();
1000 int height = edl_h > 0 ? edl_h : 1;
1001 int width = edl_w > 0 ? edl_w : 1;
1002 int color_model = edl->session->color_model;
1004 //printf("render clip: %s\n", name);
1005 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1006 char string[BCTEXTLEN];
1007 sprintf(string, _("Rendering %s"), name);
1008 mwindow->gui->lock_window("AssetPicon::create_objects");
1009 mwindow->gui->show_message(string);
1010 mwindow->gui->unlock_window();
1011 open_render_engine(edl, 0);
1012 render_video(0, gui->temp_picon);
1013 close_render_engine();
1014 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1015 vframe->transfer_from(gui->temp_picon);
1017 vframe->write_png(clip_icon_path);
1019 pixmap_w = pixmap_h * width / height;
1020 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1021 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1022 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1023 icon_vframe->transfer_from(vframe);
1025 gui->lock_window("AssetPicon::create_objects 0");
1026 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1027 icon->draw_vframe(icon_vframe,
1028 0, 0, pixmap_w, pixmap_h, 0, 0);
1031 icon = gui->clip_icon;
1032 icon_vframe = gui->clip_vframe;
1036 if( edl->tracks->playable_audio_tracks() ) {
1037 if( mwindow->preferences->use_thumbnails ) {
1038 gui->unlock_window();
1039 char clip_icon_path[BCTEXTLEN];
1040 char *clip_icon = edl->local_session->clip_icon;
1041 if( clip_icon[0] ) {
1042 snprintf(clip_icon_path, sizeof(clip_icon_path),
1043 "%s/%s", File::get_config_path(), clip_icon);
1044 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1046 if( !icon_vframe ) {
1047 pixmap_w = pixmap_h * 16/9;
1048 icon_vframe = new VFrame(0,
1049 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1050 icon_vframe->clear_frame();
1051 char string[BCTEXTLEN];
1052 sprintf(string, _("Rendering %s"), name);
1053 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1054 mwindow->gui->show_message(string);
1055 mwindow->gui->unlock_window();
1056 int sample_rate = edl->get_sample_rate();
1057 int channels = edl->get_audio_channels();
1058 if( channels > 2 ) channels = 2;
1059 int64_t audio_samples = edl->get_audio_samples();
1060 double duration = (double)audio_samples / sample_rate;
1061 draw_hue_bar(icon_vframe, duration);
1062 Samples *samples[MAX_CHANNELS];
1063 int bfrsz = sample_rate;
1064 for( int i=0; i<MAX_CHANNELS; ++i )
1065 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1066 open_render_engine(edl, 1);
1067 render_audio(0, samples, bfrsz);
1068 close_render_engine();
1069 gui->lock_window("AssetPicon::create_objects 4");
1070 static int line_colors[2] = { GREEN, YELLOW };
1071 static int base_colors[2] = { RED, PINK };
1072 for( int i=channels; --i>=0; ) {
1073 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1074 base_colors[i], line_colors[i]);
1076 for( int i=0; i<channels; ++i ) delete samples[i];
1077 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1080 pixmap_w = icon_vframe->get_w();
1081 pixmap_h = icon_vframe->get_h();
1083 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1084 icon->draw_vframe(icon_vframe,
1085 0, 0, pixmap_w, pixmap_h, 0, 0);
1088 icon = gui->clip_icon;
1089 icon_vframe = gui->clip_vframe;
1095 strcpy(name, _(plugin->title));
1097 icon_vframe = plugin->get_picon();
1099 icon = gui->create_pixmap(icon_vframe);
1100 else if( plugin->audio ) {
1101 if( plugin->transition ) {
1102 icon = gui->atransition_icon;
1103 icon_vframe = gui->atransition_vframe;
1105 else if( plugin->is_ffmpeg() ) {
1106 icon = gui->ff_aud_icon;
1107 icon_vframe = gui->ff_aud_vframe;
1109 else if( plugin->is_ladspa() ) {
1110 icon = gui->ladspa_icon;
1111 icon_vframe = gui->ladspa_vframe;
1114 icon = gui->aeffect_icon;
1115 icon_vframe = gui->aeffect_vframe;
1118 else if( plugin->video ) {
1119 if( plugin->transition ) {
1120 icon = gui->vtransition_icon;
1121 icon_vframe = gui->vtransition_vframe;
1123 else if( plugin->is_ffmpeg() ) {
1124 icon = gui->ff_vid_icon;
1125 icon_vframe = gui->ff_vid_vframe;
1128 icon = gui->veffect_icon;
1129 icon_vframe = gui->veffect_vframe;
1137 mwindow->edl->session->time_format,
1138 mwindow->edl->session->sample_rate,
1139 mwindow->edl->session->frame_rate,
1140 mwindow->edl->session->frames_per_foot);
1142 icon = gui->label_icon;
1143 icon_vframe = gui->label_vframe;
1146 icon = gui->file_icon;
1147 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1150 set_icon_vframe(icon_vframe);
1153 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1154 : BC_Window(_(PROGRAM_NAME ": Resources"),
1155 mwindow->session->awindow_x, mwindow->session->awindow_y,
1156 mwindow->session->awindow_w, mwindow->session->awindow_h,
1159 this->mwindow = mwindow;
1160 this->awindow = awindow;
1162 file_vframe = 0; file_icon = 0;
1163 folder_vframe = 0; folder_icon = 0;
1164 audio_vframe = 0; audio_icon = 0;
1165 video_vframe = 0; video_icon = 0;
1166 label_vframe = 0; label_icon = 0;
1168 atransition_vframe = 0; atransition_icon = 0;
1169 vtransition_vframe = 0; vtransition_icon = 0;
1170 aeffect_vframe = 0; aeffect_icon = 0;
1171 ladspa_vframe = 0; ladspa_icon = 0;
1172 veffect_vframe = 0; veffect_icon = 0;
1173 ff_aud_vframe = 0; ff_aud_icon = 0;
1174 ff_vid_vframe = 0; ff_vid_icon = 0;
1176 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1177 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1178 clip_folder_vframe = 0; clip_folder_icon = 0;
1179 label_folder_vframe = 0; label_folder_icon = 0;
1180 media_folder_vframe = 0; media_folder_icon = 0;
1181 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1182 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1183 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1185 ladspa_vframe = 0; ladspa_icon = 0;
1186 ff_aud_vframe = 0; ff_aud_icon = 0;
1187 ff_vid_vframe = 0; ff_vid_icon = 0;
1189 clip_vframe = 0; clip_icon = 0;
1190 atransition_vframe = 0; atransition_icon = 0;
1191 vtransition_vframe = 0; vtransition_icon = 0;
1192 aeffect_vframe = 0; aeffect_icon = 0;
1193 veffect_vframe = 0; veffect_icon = 0;
1195 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1197 effectlist_menu = 0;
1202 folderlist_menu = 0;
1205 allow_iconlisting = 1;
1210 displayed_folder = AW_NO_FOLDER;
1211 new_folder_thread = 0;
1212 modify_folder_thread = 0;
1213 folder_lock = new Mutex("AWindowGUI::folder_lock");
1216 AWindowGUI::~AWindowGUI()
1218 assets.remove_all_objects();
1219 folders.remove_all_objects();
1220 aeffects.remove_all_objects();
1221 veffects.remove_all_objects();
1222 atransitions.remove_all_objects();
1223 vtransitions.remove_all_objects();
1224 labellist.remove_all_objects();
1225 displayed_assets[1].remove_all_objects();
1227 delete new_folder_thread;
1228 delete modify_folder_thread;
1229 delete vicon_thread;
1234 delete remove_plugin;
1236 delete file_vframe; delete file_icon;
1237 delete folder_vframe; delete folder_icon;
1238 delete audio_vframe; delete audio_icon;
1239 delete video_vframe; delete video_icon;
1240 delete label_vframe; delete label_icon;
1241 delete clip_vframe; delete clip_icon;
1242 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1243 delete atransition_folder_vframe; delete atransition_folder_icon;
1244 delete veffect_folder_vframe; delete veffect_folder_icon;
1245 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1246 delete clip_folder_vframe; delete clip_folder_icon;
1247 delete label_folder_vframe; delete label_folder_icon;
1248 delete media_folder_vframe; delete media_folder_icon;
1249 delete proxy_folder_vframe; delete proxy_folder_icon;
1250 delete ladspa_vframe; delete ladspa_icon;
1251 delete ff_aud_vframe; delete ff_aud_icon;
1252 delete ff_vid_vframe; delete ff_vid_icon;
1253 delete atransition_vframe; delete atransition_icon;
1254 delete vtransition_vframe; delete vtransition_icon;
1255 delete aeffect_vframe; delete aeffect_icon;
1256 delete veffect_vframe; delete veffect_icon;
1260 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1262 return icon == file_icon ||
1263 icon == folder_icon ||
1264 icon == audio_icon ||
1265 icon == video_icon ||
1266 icon == clip_icon ||
1267 icon == label_icon ||
1268 icon == vtransition_icon ||
1269 icon == atransition_icon ||
1270 icon == veffect_icon ||
1271 icon == aeffect_icon ||
1272 icon == ladspa_icon ||
1273 icon == ff_aud_icon ||
1274 icon == ff_vid_icon ||
1275 icon == aeffect_folder_icon ||
1276 icon == veffect_folder_icon ||
1277 icon == atransition_folder_icon ||
1278 icon == vtransition_folder_icon ||
1279 icon == label_folder_icon ||
1280 icon == clip_folder_icon ||
1281 icon == media_folder_icon ||
1282 icon == proxy_folder_icon;
1285 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1287 char png_path[BCTEXTLEN];
1288 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1289 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1290 File::get_plugin_path(), plugin_icons, name);
1291 if( access(png_path, R_OK) ) return 0;
1292 return VFramePng::vframe_png(png_path,0,0);
1295 VFrame *AWindowGUI::get_picon(const char *name)
1297 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1299 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1300 snprintf(pp, ep-pp, "%s.png", name);
1301 unsigned char *data = mwindow->theme->get_image_data(png_name);
1302 if( data ) vframe = new VFramePng(data, 0.);
1307 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1309 vfrm = get_picon(fn);
1310 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1311 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1313 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1315 vfrm = get_picon(fn);
1316 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1317 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1319 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1321 vfrm = get_picon(fn);
1322 if( !vfrm ) vfrm = new VFramePng(png);
1323 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1326 void AWindowGUI::create_objects()
1328 lock_window("AWindowGUI::create_objects");
1329 asset_titles[0] = C_("Title");
1330 asset_titles[1] = _("Comments");
1332 set_icon(mwindow->theme->get_image("awindow_icon"));
1334 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1335 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1336 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1337 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1338 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1340 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1341 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1342 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1343 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1344 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1345 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1346 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1347 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1349 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1350 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1351 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1352 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1353 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1354 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1355 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1356 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1358 theme_icon(clip_vframe, clip_icon, "clip_icon");
1359 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1360 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1361 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1362 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1364 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1365 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1366 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1367 folder_lock->lock("AWindowGUI::create_objects");
1368 // Mandatory folders
1369 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1370 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1371 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1372 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1373 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1374 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1375 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1376 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1378 create_label_folder();
1379 folder_lock->unlock();
1381 mwindow->theme->get_awindow_sizes(this);
1382 load_defaults(mwindow->defaults);
1383 new_folder_thread = new NewFolderThread(this);
1384 modify_folder_thread = new ModifyFolderThread(this);
1386 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1387 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1388 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1389 search_text->create_objects();
1390 int dy = search_text->get_h() + 10;
1392 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1394 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1395 asset_list->update_vicon_area();
1396 vicon_thread->start();
1397 vicon_audio = new AssetVIconAudio(this);
1399 add_subwindow(divider = new AWindowDivider(mwindow, this,
1400 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1401 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1403 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1405 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1406 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1407 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1408 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1409 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1410 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1411 add_tools->create_objects();
1412 fy += add_tools->get_h(); fh -= add_tools->get_h();
1413 add_subwindow(folder_list = new AWindowFolders(mwindow,
1414 this, fx, fy, fw, fh));
1416 folder_list->load_expanders();
1418 //int x = mwindow->theme->abuttons_x;
1419 //int y = mwindow->theme->abuttons_y;
1421 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1422 asset_menu->create_objects();
1423 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1424 clip_menu->create_objects();
1425 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1426 label_menu->create_objects();
1427 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1428 proxy_menu->create_objects();
1430 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1431 effectlist_menu->create_objects();
1432 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1433 assetlist_menu->create_objects();
1434 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1435 cliplist_menu->create_objects();
1436 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1437 labellist_menu->create_objects();
1438 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1439 proxylist_menu->create_objects();
1441 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1442 folderlist_menu->create_objects();
1444 create_custom_xatoms();
1448 int AWindowGUI::resize_event(int w, int h)
1450 mwindow->session->awindow_x = get_x();
1451 mwindow->session->awindow_y = get_y();
1452 mwindow->session->awindow_w = w;
1453 mwindow->session->awindow_h = h;
1455 mwindow->theme->get_awindow_sizes(this);
1456 mwindow->theme->draw_awindow_bg(this);
1457 reposition_objects();
1459 // int x = mwindow->theme->abuttons_x;
1460 // int y = mwindow->theme->abuttons_y;
1461 // new_bin->reposition_window(x, y);
1462 // x += new_bin->get_w();
1463 // delete_bin->reposition_window(x, y);
1464 // x += delete_bin->get_w();
1465 // rename_bin->reposition_window(x, y);
1466 // x += rename_bin->get_w();
1467 // delete_disk->reposition_window(x, y);
1468 // x += delete_disk->get_w();
1469 // delete_project->reposition_window(x, y);
1470 // x += delete_project->get_w();
1471 // info->reposition_window(x, y);
1472 // x += info->get_w();
1473 // redraw_index->reposition_window(x, y);
1474 // x += redraw_index->get_w();
1475 // paste->reposition_window(x, y);
1476 // x += paste->get_w();
1477 // append->reposition_window(x, y);
1478 // x += append->get_w();
1479 // view->reposition_window(x, y);
1481 BC_WindowBase::resize_event(w, h);
1482 asset_list->update_vicon_area();
1486 int AWindowGUI::translation_event()
1488 mwindow->session->awindow_x = get_x();
1489 mwindow->session->awindow_y = get_y();
1493 void AWindowGUI::reposition_objects()
1495 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1496 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1497 search_text->reposition_window(x1, y1+5, w1);
1498 int dy = search_text->get_h() + 10;
1500 asset_list->reposition_window(x1, y1, w1, h1);
1501 divider->reposition_window(
1502 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1503 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1504 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1505 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1506 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1507 avicon_drawing->reposition_window(fw-avicon_w, fy);
1508 fy += add_tools->get_h(); fh -= add_tools->get_h();
1509 folder_list->reposition_window(fx, fy, fw, fh);
1512 int AWindowGUI::save_defaults(BC_Hash *defaults)
1514 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1515 defaults->update("VICON_DRAWING", vicon_drawing);
1519 int AWindowGUI::load_defaults(BC_Hash *defaults)
1521 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1522 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1526 int AWindowGUI::close_event()
1529 mwindow->session->show_awindow = 0;
1532 mwindow->gui->lock_window("AWindowGUI::close_event");
1533 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1534 mwindow->gui->unlock_window();
1536 lock_window("AWindowGUI::close_event");
1537 save_defaults(mwindow->defaults);
1538 mwindow->save_defaults();
1542 void AWindowGUI::start_vicon_drawing()
1544 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1545 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1546 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1547 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1548 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1549 switch( mwindow->edl->session->assetlist_format ) {
1551 case ASSETS_ICONS_PACKED:
1552 case ASSETS_ICON_LIST:
1553 asset_list->update_vicon_area();
1554 vicon_thread->start_drawing();
1562 void AWindowGUI::stop_vicon_drawing()
1564 if( vicon_thread->interrupted ) return;
1565 vicon_thread->stop_drawing();
1568 VFrame *AssetPicon::get_vicon_frame()
1570 if( !vicon ) return 0;
1571 if( gui->vicon_thread->interrupted ) return 0;
1572 VFrame *frame = vicon->frame();
1573 if( !frame ) return 0;
1575 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1576 vicon_frame->transfer_from(frame);
1580 int AWindowGUI::cycle_assetlist_format()
1582 EDLSession *session = mwindow->edl->session;
1583 int format = ASSETS_TEXT;
1584 if( allow_iconlisting ) {
1585 switch( session->assetlist_format ) {
1587 format = ASSETS_ICONS;
1590 format = ASSETS_ICONS_PACKED;
1592 case ASSETS_ICONS_PACKED:
1593 format = ASSETS_ICON_LIST;
1595 case ASSETS_ICON_LIST:
1596 format = ASSETS_TEXT;
1600 stop_vicon_drawing();
1601 session->assetlist_format = format;
1602 asset_list->update_format(session->assetlist_format, 0);
1603 async_update_assets();
1604 start_vicon_drawing();
1608 AWindowRemovePluginGUI::
1609 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1610 int x, int y, PluginServer *plugin)
1611 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1613 this->awindow = awindow;
1614 this->thread = thread;
1615 this->plugin = plugin;
1616 VFrame *vframe = plugin->get_picon();
1617 icon = vframe ? create_pixmap(vframe) : 0;
1618 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1621 AWindowRemovePluginGUI::
1622 ~AWindowRemovePluginGUI()
1624 if( !awindow->gui->protected_pixmap(icon) )
1626 plugin_list.remove_all();
1629 void AWindowRemovePluginGUI::create_objects()
1631 lock_window("AWindowRemovePluginGUI::create_objects");
1632 BC_Button *ok_button = new BC_OKButton(this);
1633 add_subwindow(ok_button);
1634 BC_Button *cancel_button = new BC_CancelButton(this);
1635 add_subwindow(cancel_button);
1637 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1638 add_subwindow(title);
1639 y += title->get_h() + 5;
1640 list = new BC_ListBox(x, y,
1641 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1642 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1643 add_subwindow(list);
1648 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1651 for( int i=0; i<folder.size(); ) {
1652 AssetPicon *picon = (AssetPicon *)folder[i];
1653 if( picon->plugin == plugin ) {
1654 folder.remove_object_number(i);
1663 void AWindowRemovePlugin::handle_close_event(int result)
1666 printf(_("remove %s\n"), plugin->path);
1667 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1668 ArrayList<BC_ListBoxItem*> *folder =
1669 plugin->audio ? plugin->transition ?
1670 &awindow->gui->atransitions :
1671 &awindow->gui->aeffects :
1672 plugin->video ? plugin->transition ?
1673 &awindow->gui->vtransitions :
1674 &awindow->gui->veffects :
1676 if( folder ) remove_plugin(plugin, *folder);
1677 MWindow *mwindow = awindow->mwindow;
1678 awindow->gui->unlock_window();
1679 char plugin_path[BCTEXTLEN];
1680 strcpy(plugin_path, plugin->path);
1681 mwindow->plugindb->remove(plugin);
1682 remove(plugin_path);
1683 char index_path[BCTEXTLEN];
1684 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1686 char picon_path[BCTEXTLEN];
1688 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1689 File::get_plugin_path());
1690 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1691 plugin->get_plugin_png_name(png_name);
1692 fs.update(picon_path);
1693 for( int i=0; i<fs.dir_list.total; ++i ) {
1694 char *fs_path = fs.dir_list[i]->path;
1695 if( !fs.is_dir(fs_path) ) continue;
1696 snprintf(png_path, sizeof(picon_path), "%s/%s",
1700 delete plugin; plugin = 0;
1701 awindow->gui->async_update_assets();
1705 AWindowRemovePlugin::
1706 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1709 this->awindow = awindow;
1710 this->plugin = plugin;
1713 AWindowRemovePlugin::
1714 ~AWindowRemovePlugin()
1719 BC_Window* AWindowRemovePlugin::new_gui()
1721 int x = awindow->gui->get_abs_cursor_x(0);
1722 int y = awindow->gui->get_abs_cursor_y(0);
1723 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1724 gui->create_objects();
1728 int AWindowGUI::keypress_event()
1730 switch( get_keypress() ) {
1738 if( !ctrl_down() && !shift_down() ) {
1739 assetlist_menu->load_file->handle_event();
1744 return cycle_assetlist_format();
1746 if( shift_down() && ctrl_down() ) {
1747 PluginServer* plugin = selected_plugin();
1748 if( !plugin ) break;
1749 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1751 remove_plugin->start();
1752 lock_window("AWindowGUI::keypress_event 1");
1756 if( shift_down() ) {
1757 mwindow->awindow->asset_remove->start();
1761 mwindow->remove_assets_from_project(1, 1,
1762 mwindow->session->drag_assets,
1763 mwindow->session->drag_clips);
1764 lock_window("AWindowGUI::keypress_event 2");
1770 if( shift_down() && ctrl_down() ) {
1771 resend_event(mwindow->gui);
1781 int AWindowGUI::create_custom_xatoms()
1783 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1786 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1788 if( event->message_type == UpdateAssetsXAtom ) {
1795 void AWindowGUI::async_update_assets()
1798 event.message_type = UpdateAssetsXAtom;
1799 send_custom_xatom(&event);
1803 void AWindowGUI::update_folder_list()
1805 for( int i = 0; i < folders.total; i++ ) {
1806 AssetPicon *picon = (AssetPicon*)folders.values[i];
1810 // Search assets for folders
1811 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1812 BinFolder *bin_folder = mwindow->edl->folders[i];
1815 for( int j = 0; j < folders.total; j++ ) {
1816 AssetPicon *picon = (AssetPicon*)folders[j];
1817 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1825 const char *title = bin_folder->title;
1826 int folder = bin_folder->awindow_folder;
1827 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1828 picon->create_objects();
1829 folders.append(picon);
1833 // Delete unused non-persistent folders
1834 int do_autoplace = 0;
1835 for( int i=folders.total; --i>=0; ) {
1836 AssetPicon *picon = (AssetPicon*)folders.values[i];
1837 if( !picon->in_use && !picon->persistent ) {
1839 folders.remove_number(i);
1844 folder_list->set_autoplacement(&folders, 0, 1);
1847 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1848 int do_audio, int do_video, int is_realtime, int is_transition)
1850 ArrayList<PluginServer*> plugin_list;
1851 // Get pointers to plugindb entries
1852 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1855 for( int i = 0; i < plugin_list.total; i++ ) {
1856 PluginServer *server = plugin_list.values[i];
1857 int visible = plugin_visibility & (1<<server->dir_idx);
1858 if( !visible ) continue;
1859 // Create new listitem
1860 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1861 picon->create_objects();
1862 output->append(picon);
1866 void AWindowGUI::create_label_folder()
1869 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1870 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1871 picon->create_objects();
1872 labellist.append(picon);
1877 void AWindowGUI::update_asset_list()
1879 ArrayList<AssetPicon *> new_assets;
1880 for( int i = 0; i < assets.total; i++ ) {
1881 AssetPicon *picon = (AssetPicon*)assets.values[i];
1885 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1886 // Synchronize EDL clips
1887 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1890 // Look for clip in existing listitems
1891 for( int j = 0; j < assets.total && !exists; j++ ) {
1892 AssetPicon *picon = (AssetPicon*)assets.values[j];
1894 if( picon->id == mwindow->edl->clips[i]->id ) {
1895 picon->edl = mwindow->edl->clips[i];
1896 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1902 // Create new listitem
1904 AssetPicon *picon = new AssetPicon(mwindow,
1905 this, mwindow->edl->clips[i]);
1906 new_assets.append(picon);
1910 // Synchronize EDL assets
1911 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1914 // Look for asset in existing listitems
1915 for( int j = 0; j < assets.total && !exists; j++ ) {
1916 AssetPicon *picon = (AssetPicon*)assets.values[j];
1918 if( picon->id == current->id ) {
1919 picon->indexable = current;
1925 // Create new listitem
1927 AssetPicon *picon = new AssetPicon(mwindow,
1929 new_assets.append(picon);
1933 // Synchronize nested EDLs
1934 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1936 EDL *nested_edl = mwindow->edl->nested_edls[i];
1938 // Look for asset in existing listitems
1939 for( int j=0; j<assets.total && !exists; ++j ) {
1940 AssetPicon *picon = (AssetPicon*)assets.values[j];
1942 if( picon->id == nested_edl->id ) {
1943 picon->indexable = nested_edl;
1949 // Create new listitem
1951 AssetPicon *picon = new AssetPicon(mwindow,
1952 this, (Indexable*)nested_edl);
1953 new_assets.append(picon);
1956 mwindow->gui->unlock_window();
1958 for( int i=0; i<new_assets.size(); ++i ) {
1959 AssetPicon *picon = new_assets[i];
1960 picon->create_objects();
1961 if( picon->indexable )
1962 picon->foldernum = AW_MEDIA_FOLDER;
1963 else if( picon->edl )
1964 picon->foldernum = AW_CLIP_FOLDER;
1965 assets.append(picon);
1968 mwindow->gui->lock_window();
1969 mwindow->gui->default_message();
1970 mwindow->gui->unlock_window();
1972 for( int i = assets.size() - 1; i >= 0; i-- ) {
1973 AssetPicon *picon = (AssetPicon*)assets.get(i);
1974 if( !picon->in_use ) {
1976 assets.remove_number(i);
1979 if( picon->indexable && picon->indexable->is_asset ) {
1981 picon->comments_time = !stat(picon->indexable->path, &st) ?
1987 void AWindowGUI::update_picon(Indexable *indexable)
1990 for( int i = 0; i < assets.total; i++ ) {
1991 AssetPicon *picon = (AssetPicon*)assets.values[i];
1992 if( picon->indexable == indexable ||
1993 picon->edl == (EDL *)indexable ) {
1994 char name[BCTEXTLEN];
1996 fs.extract_name(name, indexable->path);
1997 picon->set_text(name);
1998 vicon = picon->vicon;
2003 stop_vicon_drawing();
2004 vicon->clear_images();
2005 vicon->reset(indexable->get_frame_rate());
2006 start_vicon_drawing();
2010 void AWindowGUI::sort_assets()
2012 folder_lock->lock("AWindowGUI::sort_assets");
2013 switch( mwindow->edl->session->awindow_folder ) {
2014 case AW_AEFFECT_FOLDER:
2015 sort_picons(&aeffects);
2017 case AW_VEFFECT_FOLDER:
2018 sort_picons(&veffects);
2020 case AW_ATRANSITION_FOLDER:
2021 sort_picons(&atransitions);
2023 case AW_VTRANSITION_FOLDER:
2024 sort_picons(&vtransitions);
2026 case AW_LABEL_FOLDER:
2027 sort_picons(&labellist);
2030 sort_picons(&assets);
2034 asset_list->update_format(asset_list->get_format(), 0);
2035 folder_lock->unlock();
2039 void AWindowGUI::sort_folders()
2041 folder_lock->lock("AWindowGUI::update_assets");
2042 // folder_list->collapse_recursive(&folders, 0);
2043 folder_list->set_autoplacement(&folders, 0, 1);
2044 sort_picons(&folders);
2045 folder_list->update_format(folder_list->get_format(), 0);
2046 folder_lock->unlock();
2050 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2052 Asset *proxy_asset = (Asset *)indexable;
2053 char path[BCTEXTLEN];
2054 int proxy_scale = mwindow->edl->session->proxy_scale;
2055 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2056 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2057 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2058 // make a clip from proxy video tracks and unproxy audio tracks
2059 EDL *proxy_edl = new EDL(mwindow->edl);
2060 proxy_edl->create_objects();
2061 proxy_edl->set_path(proxy_asset->path);
2062 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2063 strcpy(proxy_edl->local_session->clip_title, path);
2064 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2065 proxy_edl->session->video_tracks = proxy_asset->layers;
2066 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2067 proxy_edl->create_default_tracks();
2068 double length = proxy_asset->frame_rate > 0 ?
2069 ( proxy_asset->video_length >= 0 ?
2070 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2071 ( proxy_edl->session->si_useduration ?
2072 proxy_edl->session->si_duration :
2073 1.0 / proxy_asset->frame_rate ) ) :
2074 1.0 / proxy_edl->session->frame_rate;
2075 Track *current = proxy_edl->tracks->first;
2076 for( int vtrack=0; current; current=NEXT ) {
2077 if( current->data_type != TRACK_VIDEO ) continue;
2078 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2080 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2081 current = proxy_edl->tracks->first;
2082 for( int atrack=0; current; current=NEXT ) {
2083 if( current->data_type != TRACK_AUDIO ) continue;
2084 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2086 proxy_edl->folder_no = AW_PROXY_FOLDER;
2091 void AWindowGUI::collect_assets(int proxy)
2093 mwindow->session->drag_assets->remove_all();
2094 mwindow->session->drag_clips->remove_all();
2095 int i = 0; AssetPicon *result;
2096 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2097 Indexable *indexable = result->indexable;
2098 if( proxy && indexable && indexable->is_asset &&
2099 indexable->folder_no == AW_PROXY_FOLDER ) {
2100 EDL *drag_edl = collect_proxy(indexable);
2101 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2105 mwindow->session->drag_assets->append(indexable);
2109 mwindow->session->drag_clips->append(result->edl);
2115 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2117 // Remove current pointers
2118 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2119 dst[0].remove_all();
2120 dst[1].remove_all_objects();
2122 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2123 int folder = mwindow->edl->session->awindow_folder;
2124 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2125 mwindow->edl->get_folder(folder);
2127 // Create new pointers
2128 for( int i = 0; i < src->total; i++ ) {
2129 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2130 picon = (AssetPicon*)src->values[i];
2131 picon->sort_key = -1;
2132 if( !visible && bin_folder ) {
2133 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2134 picon->indexable ? picon->indexable :
2135 picon->edl ? picon->edl->get_proxy_asset() : 0;
2137 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2138 if( picon->sort_key < 0 ) continue;
2142 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2144 if( !visible && picon->edl && picon->edl->folder_no == folder )
2146 if( visible && sub_items ) {
2147 if( !sub_items->matches(picon->get_text()) )
2151 const char *text = search_text->get_text();
2152 if( text && text[0] )
2153 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2155 if( visible && picon->vicon && picon->vicon->hidden )
2156 picon->vicon->hidden = 0;
2158 BC_ListBoxItem *item2, *item1;
2159 dst[0].append(item1 = picon);
2161 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2164 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2165 else if( picon->comments_time ) {
2166 char date_time[BCSTRLEN];
2167 struct tm stm; localtime_r(&picon->comments_time, &stm);
2168 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2169 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2170 stm.tm_hour, stm.tm_min, stm.tm_sec);
2171 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2174 dst[1].append(item2 = new BC_ListBoxItem(""));
2175 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2176 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2181 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2183 int done = 0, changed = 0;
2186 for( int i=0; i<src->total-1; ++i ) {
2187 AssetPicon *item1 = (AssetPicon *)src->values[i];
2188 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2189 double v = item2->sort_key - item1->sort_key;
2190 if( v > 0 ) continue;
2192 const char *cp1 = item1->get_text();
2193 const char *bp1 = strrchr(cp1, '/');
2194 if( bp1 ) cp1 = bp1 + 1;
2195 const char *cp2 = item2->get_text();
2196 const char *bp2 = strrchr(cp2, '/');
2197 if( bp2 ) cp2 = bp2 + 1;
2198 if( strcmp(cp2, cp1) >= 0 ) continue;
2200 src->values[i + 1] = item1;
2201 src->values[i] = item2;
2202 done = 0; changed = 1;
2206 for( int i=0; i<src->total; ++i ) {
2207 AssetPicon *item = (AssetPicon *)src->values[i];
2208 item->set_autoplace_icon(1);
2209 item->set_autoplace_text(1);
2214 void AWindowGUI::filter_displayed_assets()
2216 //allow_iconlisting = 1;
2217 asset_titles[0] = C_("Title");
2218 asset_titles[1] = _("Comments");
2219 AssetPicon *picon = 0;
2220 int selected_folder = mwindow->edl->session->awindow_folder;
2221 // Ensure the current folder icon is highlighted
2222 for( int i = 0; i < folders.total; i++ ) {
2223 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2224 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2225 folder_item->set_selected(selected);
2226 if( selected ) picon = folder_item;
2229 ArrayList<BC_ListBoxItem*> *src = &assets;
2230 switch( selected_folder ) {
2231 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2232 case AW_VEFFECT_FOLDER: src = &veffects; break;
2233 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2234 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2235 case AW_LABEL_FOLDER: src = &labellist;
2236 asset_titles[0] = _("Time Stamps");
2237 asset_titles[1] = C_("Title");
2238 //allow_iconlisting = 0;
2241 copy_picons(picon, src);
2245 void AWindowGUI::update_assets()
2247 stop_vicon_drawing();
2248 folder_lock->lock("AWindowGUI::update_assets");
2249 update_folder_list();
2250 update_asset_list();
2251 labellist.remove_all_objects();
2252 create_label_folder();
2254 if( displayed_folder != mwindow->edl->session->awindow_folder )
2255 search_text->clear();
2256 vicon_thread->hide_vicons();
2257 filter_displayed_assets();
2258 folder_lock->unlock();
2260 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2261 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2263 int folder_xposition = folder_list->get_xposition();
2264 int folder_yposition = folder_list->get_yposition();
2265 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2267 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2268 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2270 int asset_xposition = asset_list->get_xposition();
2271 int asset_yposition = asset_list->get_yposition();
2272 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2273 displayed_folder = mwindow->edl->session->awindow_folder;
2274 asset_xposition = asset_yposition = 0;
2276 asset_list->update(displayed_assets, asset_titles,
2277 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2278 asset_xposition, asset_yposition, -1, 0);
2279 asset_list->center_selection();
2282 start_vicon_drawing();
2286 void AWindowGUI::update_effects()
2288 aeffects.remove_all_objects();
2289 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2290 veffects.remove_all_objects();
2291 create_persistent_folder(&veffects, 0, 1, 1, 0);
2292 atransitions.remove_all_objects();
2293 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2294 vtransitions.remove_all_objects();
2295 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2298 int AWindowGUI::drag_motion()
2300 if( get_hidden() ) return 0;
2306 int AWindowGUI::drag_stop()
2308 if( get_hidden() ) return 0;
2312 Indexable* AWindowGUI::selected_asset()
2314 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2315 return picon ? picon->indexable : 0;
2318 PluginServer* AWindowGUI::selected_plugin()
2320 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2321 return picon ? picon->plugin : 0;
2324 AssetPicon* AWindowGUI::selected_folder()
2326 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2337 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2338 : BC_SubWindow(x, y, w, h)
2340 this->mwindow = mwindow;
2343 AWindowDivider::~AWindowDivider()
2347 int AWindowDivider::button_press_event()
2349 if( is_event_win() && cursor_inside() ) {
2350 mwindow->session->current_operation = DRAG_PARTITION;
2356 int AWindowDivider::cursor_motion_event()
2358 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2360 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2361 int fw = gui->get_relative_cursor_x();
2362 if( fw > wmax ) fw = wmax;
2363 if( fw < wmin ) fw = wmin;
2364 mwindow->session->afolders_w = fw;
2365 mwindow->theme->get_awindow_sizes(gui);
2366 gui->reposition_objects();
2372 int AWindowDivider::button_release_event()
2374 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2375 mwindow->session->current_operation = NO_OPERATION;
2386 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2387 : BC_ListBox(x, y, w, h,
2388 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2389 LISTBOX_ICONS : LISTBOX_TEXT,
2390 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2391 0, // Titles for columns. Set to 0 for no titles
2392 0, // width of each column
2393 1, // Total columns.
2394 0, // Pixel of top of window.
2395 0, // If this listbox is a popup window
2396 LISTBOX_SINGLE, // Select one item or multiple items
2397 ICON_TOP, // Position of icon relative to text of each item
2400 this->mwindow = mwindow;
2407 AWindowFolders::~AWindowFolders()
2411 int AWindowFolders::selection_changed()
2413 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2414 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2415 // prefer expanded entry
2416 AWindowFolderItem *item = item1 ? item1 : item0;
2417 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2418 item1->set_selected(0);
2425 AssetPicon *picon = item->get_picon();
2426 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2428 gui->stop_vicon_drawing();
2430 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2431 gui->folderlist_menu->update_titles();
2432 gui->folderlist_menu->activate_menu();
2435 mwindow->edl->session->awindow_folder = picon->foldernum;
2436 gui->asset_list->draw_background();
2437 gui->async_update_assets();
2439 gui->start_vicon_drawing();
2444 int AWindowFolders::button_press_event()
2446 int result = BC_ListBox::button_press_event();
2449 if( get_buttonpress() == RIGHT_BUTTON &&
2450 is_event_win() && cursor_inside() ) {
2451 gui->folderlist_menu->update_titles();
2452 gui->folderlist_menu->activate_menu();
2460 int AWindowFolders::drag_stop()
2463 if( get_hidden() ) return 0;
2464 if( mwindow->session->current_operation == DRAG_ASSET &&
2465 gui->folder_list->cursor_above() ) { // check user folder
2466 int item_no = gui->folder_list->get_cursor_data_item_no();
2467 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2468 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2469 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2470 ArrayList<Indexable *> *drags = folder->is_clips ?
2471 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2472 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2473 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2475 mwindow->session->current_operation = ::NO_OPERATION;
2482 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2483 : AWindowFolderItem(text)
2485 this->parent = parent;
2488 int AWindowFolders::load_expanders()
2490 char expanders_path[BCTEXTLEN];
2491 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2492 FILE *fp = fopen(expanders_path, "r");
2494 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2495 File::get_cindat_path(), EXPANDERS_FILE);
2496 fp = fopen(expanders_path, "r");
2500 const char tab = '\t';
2501 char line[BCTEXTLEN]; line[0] = 0;
2502 AWindowFolderItem *item = 0, *parent;
2503 AWindowFolderSubItems *sub_items = 0;
2505 while( fgets(line,sizeof(line),fp) ) {
2506 if( line[0] == '#' ) continue;
2507 int i = strlen(line);
2508 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2509 if( i == 0 ) continue;
2511 for( char *cp=line; *cp==tab; ++cp ) ++i;
2513 int i = gui->folders.size();
2515 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2516 if( !strcmp(folder->get_text(),_(line)) ) break;
2518 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2523 if( i > k+1 ) continue;
2525 if( line[i] != '-' && sub_items ) {
2526 sub_items->names.append(cstrdup(_(&line[i])));
2534 item = item->parent;
2537 parent = item->parent;
2539 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2540 if( !sublist ) sublist = parent->new_sublist(1);
2541 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2542 sublist->append(item = sub_items);
2549 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2550 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2551 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2552 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2553 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2555 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2556 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2557 mwindow->edl->session->asset_columns, // width of each column
2558 1, // Total columns.
2559 0, // Pixel of top of window.
2560 0, // If this listbox is a popup window
2561 LISTBOX_MULTIPLE, // Select one item or multiple items
2562 ICON_TOP, // Position of icon relative to text of each item
2563 -1) // Allow drags, require shift for scrolling
2565 this->mwindow = mwindow;
2568 set_scroll_stretch(1, 1);
2571 AWindowAssets::~AWindowAssets()
2575 int AWindowAssets::button_press_event()
2577 AssetVIconThread *avt = gui->vicon_thread;
2578 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2579 int dir = 1, button = get_buttonpress();
2581 case WHEEL_DOWN: dir = -1; // fall thru
2583 int x = get_cursor_x(), y = get_cursor_y();
2584 if( avt->cursor_inside(x, y) && avt->view_win )
2585 return avt->zoom_scale(dir);
2590 int result = BC_ListBox::button_press_event();
2592 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2593 is_event_win() && cursor_inside() ) {
2594 BC_ListBox::deactivate_selection();
2595 int folder = mwindow->edl->session->awindow_folder;
2597 case AW_AEFFECT_FOLDER:
2598 case AW_VEFFECT_FOLDER:
2599 case AW_ATRANSITION_FOLDER:
2600 case AW_VTRANSITION_FOLDER:
2601 gui->effectlist_menu->update();
2602 gui->effectlist_menu->activate_menu();
2604 case AW_LABEL_FOLDER:
2605 gui->labellist_menu->update();
2606 gui->labellist_menu->activate_menu();
2608 case AW_CLIP_FOLDER:
2609 gui->cliplist_menu->update();
2610 gui->cliplist_menu->activate_menu();
2612 case AW_PROXY_FOLDER:
2613 gui->proxylist_menu->update();
2614 gui->proxylist_menu->activate_menu();
2617 case AW_MEDIA_FOLDER: {
2618 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2619 gui->assetlist_menu->update_titles(shots);
2620 gui->assetlist_menu->activate_menu();
2630 int AWindowAssets::handle_event()
2632 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2633 if( !asset_picon ) return 0;
2634 Indexable *picon_idxbl = asset_picon->indexable;
2635 EDL *picon_edl = asset_picon->edl;
2637 VWindow *vwindow = 0;
2638 switch( mwindow->edl->session->awindow_folder ) {
2639 case AW_AEFFECT_FOLDER:
2640 case AW_VEFFECT_FOLDER:
2641 case AW_ATRANSITION_FOLDER:
2642 case AW_VTRANSITION_FOLDER: return 1;
2643 case AW_PROXY_FOLDER:
2644 proxy = 1; // fall thru
2646 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2647 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2650 if( !vwindow || !vwindow->is_running() ) return 1;
2651 if( proxy && picon_idxbl ) {
2652 picon_edl = gui->collect_proxy(picon_idxbl);
2656 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2657 else if( picon_edl ) vwindow->change_source(picon_edl);
2661 int AWindowAssets::selection_changed()
2663 // Show popup window
2665 int folder = mwindow->edl->session->awindow_folder;
2666 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2667 (item = (AssetPicon*)get_selection(0, 0)) ) {
2669 case AW_AEFFECT_FOLDER:
2670 case AW_VEFFECT_FOLDER:
2671 case AW_ATRANSITION_FOLDER:
2672 case AW_VTRANSITION_FOLDER:
2673 gui->effectlist_menu->update();
2674 gui->effectlist_menu->activate_menu();
2676 case AW_LABEL_FOLDER:
2677 if( !item->label ) break;
2678 gui->label_menu->activate_menu();
2680 case AW_CLIP_FOLDER:
2681 if( !item->indexable && !item->edl ) break;
2682 gui->clip_menu->update();
2683 gui->clip_menu->activate_menu();
2685 case AW_PROXY_FOLDER:
2686 if( !item->indexable && !item->edl ) break;
2687 gui->proxy_menu->update();
2688 gui->proxy_menu->activate_menu();
2691 if( !item->indexable && !item->edl ) break;
2692 gui->asset_menu->update();
2693 gui->asset_menu->activate_menu();
2697 deactivate_selection();
2699 else if( gui->vicon_drawing && get_button_down() &&
2700 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2702 case AW_MEDIA_FOLDER:
2703 case AW_PROXY_FOLDER:
2704 case AWINDOW_USER_FOLDERS:
2705 if( get_buttonpress() == LEFT_BUTTON ||
2706 get_buttonpress() == MIDDLE_BUTTON ) {
2707 AssetVIcon *vicon = 0;
2708 if( !gui->vicon_thread->vicon )
2709 vicon = item->vicon;
2710 int draw_mode = vicon && get_buttonpress() == MIDDLE_BUTTON ?
2711 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2712 gui->vicon_thread->set_view_popup(vicon, draw_mode);
2715 case AW_CLIP_FOLDER:
2716 if( get_buttonpress() == LEFT_BUTTON ) {
2717 AssetVIcon *vicon = 0;
2718 if( !gui->vicon_thread->vicon )
2719 vicon = item->vicon;
2720 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2728 void AWindowAssets::draw_background()
2730 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2731 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2732 set_font(LARGEFONT);
2733 int folder = mwindow->edl->session->awindow_folder;
2734 const char *title = mwindow->edl->get_folder_name(folder);
2735 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2736 title, -1, get_bg_surface());
2739 int AWindowAssets::drag_start_event()
2741 int collect_pluginservers = 0;
2742 int collect_assets = 0, proxy = 0;
2744 if( BC_ListBox::drag_start_event() ) {
2745 switch( mwindow->edl->session->awindow_folder ) {
2746 case AW_AEFFECT_FOLDER:
2747 mwindow->session->current_operation = DRAG_AEFFECT;
2748 collect_pluginservers = 1;
2750 case AW_VEFFECT_FOLDER:
2751 mwindow->session->current_operation = DRAG_VEFFECT;
2752 collect_pluginservers = 1;
2754 case AW_ATRANSITION_FOLDER:
2755 mwindow->session->current_operation = DRAG_ATRANSITION;
2756 collect_pluginservers = 1;
2758 case AW_VTRANSITION_FOLDER:
2759 mwindow->session->current_operation = DRAG_VTRANSITION;
2760 collect_pluginservers = 1;
2762 case AW_LABEL_FOLDER:
2765 case AW_PROXY_FOLDER:
2766 proxy = 1; // fall thru
2767 case AW_MEDIA_FOLDER:
2769 mwindow->session->current_operation = DRAG_ASSET;
2774 if( collect_pluginservers ) {
2776 mwindow->session->drag_pluginservers->remove_all();
2779 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2780 if( !result ) break;
2782 mwindow->session->drag_pluginservers->append(result->plugin);
2786 if( collect_assets ) {
2787 gui->collect_assets(proxy);
2795 int AWindowAssets::drag_motion_event()
2797 BC_ListBox::drag_motion_event();
2800 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2801 mwindow->gui->drag_motion();
2802 mwindow->gui->unlock_window();
2804 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2805 VWindow *vwindow = mwindow->vwindows.get(i);
2806 if( !vwindow->is_running() ) continue;
2807 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2808 vwindow->gui->drag_motion();
2809 vwindow->gui->unlock_window();
2812 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2813 mwindow->cwindow->gui->drag_motion();
2814 mwindow->cwindow->gui->unlock_window();
2816 lock_window("AWindowAssets::drag_motion_event");
2817 if( mwindow->session->current_operation == DRAG_ASSET &&
2818 gui->folder_list->cursor_above() ) { // highlight user folder
2819 BC_ListBoxItem *item = 0;
2820 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2821 if( item_no >= 0 ) {
2822 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2823 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2826 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2827 int folder_xposition = gui->folder_list->get_xposition();
2828 int folder_yposition = gui->folder_list->get_yposition();
2829 gui->folder_list->update(&gui->folders, 0, 0, 1,
2830 folder_xposition, folder_yposition, item_no, 0, 1);
2835 int AWindowAssets::drag_stop_event()
2839 result = gui->drag_stop();
2844 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2845 result = mwindow->gui->drag_stop();
2846 mwindow->gui->unlock_window();
2850 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2851 VWindow *vwindow = mwindow->vwindows.get(i);
2852 if( !vwindow ) continue;
2853 if( !vwindow->is_running() ) continue;
2854 if( vwindow->gui->is_hidden() ) continue;
2855 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2856 if( vwindow->gui->cursor_above() &&
2857 vwindow->gui->get_cursor_over_window() ) {
2858 result = vwindow->gui->drag_stop();
2860 vwindow->gui->unlock_window();
2865 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2866 result = mwindow->cwindow->gui->drag_stop();
2867 mwindow->cwindow->gui->unlock_window();
2870 lock_window("AWindowAssets::drag_stop_event");
2872 result = gui->folder_list->drag_stop();
2877 get_drag_popup()->set_animation(0);
2879 BC_ListBox::drag_stop_event();
2880 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2881 mwindow->session->current_operation = ::NO_OPERATION;
2886 int AWindowAssets::column_resize_event()
2888 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2889 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2893 int AWindowAssets::focus_in_event()
2895 int ret = BC_ListBox::focus_in_event();
2896 gui->start_vicon_drawing();
2900 int AWindowAssets::focus_out_event()
2902 gui->stop_vicon_drawing();
2903 return BC_ListBox::focus_out_event();
2906 void AWindowAssets::update_vicon_area()
2908 int x0 = 0, x1 = get_w();
2909 int y0 = get_title_h();
2911 if( is_highlighted() ) {
2912 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2913 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2915 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2918 int AWindowAssets::mouse_over_event(int no)
2920 if( gui->vicon_thread->viewing &&
2921 no >= 0 && no < gui->displayed_assets[0].size() ) {
2922 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2923 gui->vicon_thread->set_view_popup(picon->vicon);
2929 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2930 : BC_TextBox(x, y, w, 1, "")
2932 this->search_text = search_text;
2935 int AWindowSearchTextBox::handle_event()
2937 return search_text->handle_event();
2940 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2942 this->mwindow = mwindow;
2948 void AWindowSearchText::create_objects()
2950 int x1 = x, y1 = y, margin = 10;
2951 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2952 x1 += text_title->get_w() + margin;
2953 int w1 = gui->get_w() - x1 - 2*margin;
2954 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2957 int AWindowSearchText::handle_event()
2959 gui->async_update_assets();
2963 int AWindowSearchText::get_w()
2965 return text_box->get_w() + text_title->get_w() + 10;
2968 int AWindowSearchText::get_h()
2970 return bmax(text_box->get_h(),text_title->get_h());
2973 void AWindowSearchText::reposition_window(int x, int y, int w)
2975 int x1 = x, y1 = y, margin = 10;
2976 text_title->reposition_window(x1, y1);
2977 x1 += text_title->get_w() + margin;
2978 int w1 = gui->get_w() - x1 - 2*margin;
2979 text_box->reposition_window(x1, y1, w1);
2982 const char *AWindowSearchText::get_text()
2984 return text_box->get_text();
2987 void AWindowSearchText::clear()
2989 text_box->update("");
2992 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2993 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2995 this->mwindow = mwindow;
2997 set_tooltip(_("Delete asset from disk"));
3000 int AWindowDeleteDisk::handle_event()
3005 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3006 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3008 this->mwindow = mwindow;
3010 set_tooltip(_("Delete asset from project"));
3013 int AWindowDeleteProject::handle_event()
3018 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3019 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3021 // this->mwindow = mwindow;
3023 // set_tooltip(_("Edit information on asset"));
3026 // int AWindowInfo::handle_event()
3028 // int cur_x, cur_y;
3029 // gui->get_abs_cursor(cur_x, cur_y, 0);
3030 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3034 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3035 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3037 this->mwindow = mwindow;
3039 set_tooltip(_("Redraw index"));
3042 int AWindowRedrawIndex::handle_event()
3047 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3048 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3050 this->mwindow = mwindow;
3052 set_tooltip(_("Paste asset on recordable tracks"));
3055 int AWindowPaste::handle_event()
3060 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3061 : BC_Button(x, y, mwindow->theme->appendasset_data)
3063 this->mwindow = mwindow;
3065 set_tooltip(_("Append asset in new tracks"));
3068 int AWindowAppend::handle_event()
3073 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3074 : BC_Button(x, y, mwindow->theme->viewasset_data)
3076 this->mwindow = mwindow;
3078 set_tooltip(_("View asset"));
3081 int AWindowView::handle_event()
3086 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3087 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3089 this->mwindow = mwindow;
3093 void AddTools::create_objects()
3096 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3097 vis |= 1 << PLUGIN_FFMPEG_ID;
3098 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3099 vis |= 1 << PLUGIN_LADSPA_ID;
3101 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3102 vis |= 1 << PLUGIN_LV2_ID;
3104 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3105 PluginServer *plugin = MWindow::plugindb->get(i);
3106 if( !plugin->audio && !plugin->video ) continue;
3107 int idx = plugin->dir_idx;
3108 uint32_t msk = 1 << idx;
3109 if( (msk & vis) != 0 ) continue;
3111 char parent[BCTEXTLEN];
3112 strcpy(parent, plugin->path);
3113 char *bp = strrchr(parent, '/');
3114 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3115 if( !bp ) bp = parent; else ++bp;
3116 add_item(new AddPluginItem(this, bp, idx));
3121 // plugin_dirs list from toplevel makefile include plugin_defs
3126 N_("audio_transitions")
3133 N_("video_transitions")
3136 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3137 : BC_MenuItem(_(text))
3141 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3142 int chk = (msk & vis) ? 1 : 0;
3146 int AddPluginItem::handle_event()
3148 int chk = get_checked() ^ 1;
3150 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3151 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3152 menu->gui->update_effects();
3153 menu->gui->save_defaults(menu->mwindow->defaults);
3154 menu->gui->async_update_assets();
3158 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3159 : BC_Toggle(x, y, images, agui->vicon_drawing)
3162 set_tooltip(_("Preview"));
3165 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3167 int text_line = -1, toggle_x = -1, toggle_y = -1;
3168 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3169 BC_Toggle::calculate_extents(agui, images, 1,
3170 &text_line, ww, hh, &toggle_x, &toggle_y,
3171 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3174 AVIconDrawing::~AVIconDrawing()
3178 int AVIconDrawing::handle_event()
3180 agui->vicon_drawing = get_value();
3181 if( agui->vicon_drawing )
3182 agui->start_vicon_drawing();
3184 agui->stop_vicon_drawing();
3189 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3190 : BC_MenuItem("","v",'v')
3192 this->mwindow = mwindow;
3196 int AWindowListFormat::handle_event()
3198 return gui->cycle_assetlist_format();
3201 void AWindowListFormat::update()
3203 EDLSession *session = mwindow->edl->session;
3204 const char *text = 0;
3205 switch( session->assetlist_format ) {
3207 text = _("Display icons");
3210 text = _("Display icons packed");
3212 case ASSETS_ICONS_PACKED:
3213 text = _("Display icon list");
3215 case ASSETS_ICON_LIST:
3216 text = _("Display text");
3222 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3223 : BC_MenuItem(_("Sort items"))
3225 this->mwindow = mwindow;
3229 int AWindowListSort::handle_event()
3235 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3238 this->select_used = select_used;
3239 this->action = action;
3242 int AssetSelectUsedItem::handle_event()
3244 MWindow *mwindow = select_used->mwindow;
3245 AWindowGUI *gui = select_used->gui;
3246 AWindowAssets *asset_list = gui->asset_list;
3247 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3252 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3256 asset_list->set_all_selected(data, 0);
3257 for( int i = 0; i < data->total; i++ ) {
3258 AssetPicon *picon = (AssetPicon*)data->values[i];
3259 Indexable *idxbl = picon->indexable ? picon->indexable :
3260 picon->edl ? picon->edl->get_proxy_asset() : 0;
3261 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3262 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3267 int asset_xposition = asset_list->get_xposition();
3268 int asset_yposition = asset_list->get_yposition();
3269 asset_list->update(gui->displayed_assets, gui->asset_titles,
3270 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3271 asset_xposition, asset_yposition, -1, 0);
3272 asset_list->center_selection();
3276 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3277 : BC_MenuItem(_("Select"))
3279 this->mwindow = mwindow;