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 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;
552 AssetVIconThread::~AssetVIconThread()
556 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
558 gui->stop_vicon_drawing();
559 int mode = !v ? ASSET_VIEW_NONE :
560 draw_mode >= 0 ? draw_mode :
563 this->draw_mode = mode;
564 gui->start_vicon_drawing();
567 ViewPopup *AssetVIconThread::new_view_window()
569 BC_WindowBase *parent = wdw->get_parent();
570 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
571 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
572 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
573 int vx = viewing->get_vx(), rx = 0;
574 int vy = viewing->get_vy(), ry = 0;
575 wdw->get_root_coordinates(vx, vy, &rx, &ry);
576 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
577 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
578 AssetViewPopup *popup = new AssetViewPopup(this, draw_mode,
579 rx, ry, view_w, view_h);
580 if( draw_mode == ASSET_VIEW_MEDIA_MAP )
581 vicon->playing_audio = -1;
582 wdw->set_active_subwindow(popup);
587 AWindowFolderItem::AWindowFolderItem()
593 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
594 : BC_ListBoxItem(text, color)
599 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
600 : BC_ListBoxItem(text, icon, color)
605 AssetPicon *AWindowFolderItem::get_picon()
607 AWindowFolderItem *item = this;
608 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
609 return (AssetPicon*)item;
612 int AWindowFolderSubItems::matches(const char *text)
614 int i = names.size();
615 while( --i >= 0 && strcmp(names[i], text) );
617 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
618 i = sublist ? sublist->size() : 0;
620 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
621 if( item->matches(text) ) break;
624 return i >= 0 ? 1 : 0;
628 AssetPicon::AssetPicon(MWindow *mwindow,
629 AWindowGUI *gui, Indexable *indexable)
630 : AWindowFolderItem()
633 this->mwindow = mwindow;
635 this->indexable = indexable;
636 indexable->add_user();
637 this->id = indexable->id;
640 AssetPicon::AssetPicon(MWindow *mwindow,
641 AWindowGUI *gui, EDL *edl)
642 : AWindowFolderItem()
645 this->mwindow = mwindow;
652 AssetPicon::AssetPicon(MWindow *mwindow,
653 AWindowGUI *gui, int folder, int persist)
654 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
655 folder>=0 && folder<AWINDOW_FOLDERS ?
656 gui->folder_icons[folder] : gui->folder_icon)
660 this->mwindow = mwindow;
662 persistent = persist;
665 AssetPicon::AssetPicon(MWindow *mwindow,
666 AWindowGUI *gui, int folder, const char *title)
667 : AWindowFolderItem(title, gui->folder_icon)
671 this->mwindow = mwindow;
676 AssetPicon::AssetPicon(MWindow *mwindow,
677 AWindowGUI *gui, PluginServer *plugin)
678 : AWindowFolderItem()
681 this->mwindow = mwindow;
683 this->plugin = plugin;
686 AssetPicon::AssetPicon(MWindow *mwindow,
687 AWindowGUI *gui, Label *label)
688 : AWindowFolderItem()
691 this->mwindow = mwindow;
699 AssetPicon::~AssetPicon()
701 if( vicon ) vicon->remove_user();
703 if( indexable ) indexable->remove_user();
704 if( edl ) edl->remove_user();
705 if( icon && !gui->protected_pixmap(icon) ) {
707 if( !plugin ) delete icon_vframe;
711 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
713 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
715 float h = 300 * t, s = 1., v = 1.;
716 float r, g, b; // duration, 0..1hr == hue red..magenta
717 HSV::hsv_to_rgb(r,g,b, h,s,v);
718 int ih = frame->get_h()/8, iw = frame->get_w();
719 int ir = r * 256; CLAMP(ir, 0,255);
720 int ig = g * 256; CLAMP(ig, 0,255);
721 int ib = b * 256; CLAMP(ib, 0,255);
722 unsigned char **rows = frame->get_rows();
723 for( int y=0; y<ih; ++y ) {
724 unsigned char *rp = rows[y];
725 for( int x=0; x<iw; rp+=3,++x ) {
726 rp[0] = ir; rp[1] = ig; rp[2] = ib;
731 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
732 int base_color, int line_color, int x, int y, int w, int h)
734 int h1 = h-1, h2 = h/2, iy = h2;
735 int rgb_color = frame->pixel_rgb;
736 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
737 double min = *dp, max = min;
738 x2 = (len * (ix+1))/w;
739 for( int i=x1; i<x2; ++i ) {
740 double value = *dp++;
741 if( value < min ) min = value;
742 if( value > max ) max = value;
744 int ctr = (min + max) / 2;
745 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
746 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
747 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
748 frame->pixel_rgb = line_color;
749 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
750 frame->pixel_rgb = base_color;
751 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
754 frame->pixel_rgb = rgb_color;
757 void AssetPicon::reset()
765 foldernum = AW_NO_FOLDER;
777 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
779 TransportCommand command;
780 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
781 command.get_edl()->copy_all(edl);
782 command.change_type = CHANGE_ALL;
783 command.realtime = 0;
784 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
785 render_engine->set_vcache(mwindow->video_cache);
786 render_engine->set_acache(mwindow->audio_cache);
787 render_engine->arm_command(&command);
789 void AssetPicon::close_render_engine()
791 delete render_engine; render_engine = 0;
793 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
795 if( !render_engine || !render_engine->vrender ) return;
796 render_engine->vrender->process_buffer(vfrm, pos, 0);
798 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
800 if( !render_engine || !render_engine->arender ) return;
801 render_engine->arender->process_buffer(samples, len, pos);
804 void AssetPicon::create_objects()
807 char name[BCTEXTLEN];
808 int pixmap_w, pixmap_h;
810 int picon_h = mwindow->preferences->awindow_picon_h;
811 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
814 fs.extract_name(name, indexable->path);
818 set_text(strcpy(name, edl->local_session->clip_title));
822 if( indexable && indexable->is_asset ) {
823 Asset *asset = (Asset*)indexable;
824 if( asset->video_data ) {
825 if( mwindow->preferences->use_thumbnails ) {
826 gui->unlock_window();
827 File *file = mwindow->video_cache->check_out(asset,
832 int height = asset->height > 0 ? asset->height : 1;
833 pixmap_w = pixmap_h * asset->width / height;
836 file->set_video_position(0, 0);
838 if( gui->temp_picon &&
839 (gui->temp_picon->get_w() != asset->width ||
840 gui->temp_picon->get_h() != asset->height) ) {
841 delete gui->temp_picon;
845 if( !gui->temp_picon ) {
846 gui->temp_picon = new VFrame(0, -1,
847 asset->width, asset->height,
850 { char string[BCTEXTLEN];
851 sprintf(string, _("Reading %s"), name);
852 mwindow->gui->lock_window("AssetPicon::create_objects");
853 mwindow->gui->show_message(string);
854 mwindow->gui->unlock_window(); }
855 file->read_frame(gui->temp_picon);
856 mwindow->video_cache->check_in(asset);
858 gui->lock_window("AssetPicon::create_objects 0");
859 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
860 icon->draw_vframe(gui->temp_picon,
861 0, 0, pixmap_w, pixmap_h, 0, 0);
862 icon_vframe = new VFrame(0,
863 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
864 icon_vframe->transfer_from(gui->temp_picon);
865 if( asset->folder_no == AW_MEDIA_FOLDER ||
866 asset->folder_no == AW_PROXY_FOLDER ) {
868 double framerate = asset->get_frame_rate();
869 if( !framerate ) framerate = VICON_RATE;
870 int64_t frames = asset->get_video_frames();
871 double secs = frames / framerate;
872 if( secs > 5 ) secs = 5;
873 int64_t length = secs * gui->vicon_thread->refresh_rate;
874 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
875 if( asset->audio_data && secs > 0 ) {
876 gui->unlock_window();
877 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
878 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
880 gui->lock_window("AssetPicon::create_objects 1");
882 gui->vicon_thread->add_vicon(vicon);
886 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
887 gui->lock_window("AssetPicon::create_objects 2");
888 icon = gui->video_icon;
889 icon_vframe = gui->video_vframe;
893 icon = gui->video_icon;
894 icon_vframe = gui->video_vframe;
898 if( asset->audio_data ) {
899 if( mwindow->preferences->use_thumbnails ) {
900 gui->unlock_window();
901 File *file = mwindow->audio_cache->check_out(asset,
905 pixmap_w = pixmap_h * 16/9;
906 icon_vframe = new VFrame(0,
907 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
908 icon_vframe->clear_frame();
909 { char string[BCTEXTLEN];
910 sprintf(string, _("Reading %s"), name);
911 mwindow->gui->lock_window("AssetPicon::create_objects 3");
912 mwindow->gui->show_message(string);
913 mwindow->gui->unlock_window(); }
914 int sample_rate = asset->get_sample_rate();
915 int channels = asset->get_audio_channels();
916 if( channels > 2 ) channels = 2;
917 int64_t audio_samples = asset->get_audio_samples();
918 double duration = (double)audio_samples / sample_rate;
919 draw_hue_bar(icon_vframe, duration);
920 int bfrsz = sample_rate;
921 Samples samples(bfrsz);
922 static int line_colors[2] = { GREEN, YELLOW };
923 static int base_colors[2] = { RED, PINK };
924 for( int i=channels; --i>=0; ) {
925 file->set_channel(i);
926 file->set_audio_position(0);
927 file->read_samples(&samples, bfrsz);
928 draw_wave(icon_vframe, samples.get_data(), bfrsz,
929 base_colors[i], line_colors[i]);
931 mwindow->audio_cache->check_in(asset);
932 if( asset->folder_no == AW_MEDIA_FOLDER ) {
933 double secs = duration;
934 if( secs > 5 ) secs = 5;
935 double refresh_rate = gui->vicon_thread->refresh_rate;
936 int64_t length = secs * refresh_rate;
937 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
938 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
939 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
941 gui->vicon_thread->add_vicon(vicon);
943 gui->lock_window("AssetPicon::create_objects 4");
944 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
945 icon->draw_vframe(icon_vframe,
946 0, 0, pixmap_w, pixmap_h, 0, 0);
949 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
950 gui->lock_window("AssetPicon::create_objects 5");
951 icon = gui->audio_icon;
952 icon_vframe = gui->audio_vframe;
956 icon = gui->audio_icon;
957 icon_vframe = gui->audio_vframe;
962 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
965 if( indexable && !indexable->is_asset ) {
966 icon = gui->video_icon;
967 icon_vframe = gui->video_vframe;
971 if( edl->tracks->playable_video_tracks() ) {
972 if( mwindow->preferences->use_thumbnails ) {
973 gui->unlock_window();
974 AssetVIconThread *avt = gui->vicon_thread;
975 char clip_icon_path[BCTEXTLEN];
976 char *clip_icon = edl->local_session->clip_icon;
979 snprintf(clip_icon_path, sizeof(clip_icon_path),
980 "%s/%s", File::get_config_path(), clip_icon);
981 vframe = VFramePng::vframe_png(clip_icon_path);
984 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
985 delete vframe; vframe = 0;
987 int edl_h = edl->get_h(), edl_w = edl->get_w();
988 int height = edl_h > 0 ? edl_h : 1;
989 int width = edl_w > 0 ? edl_w : 1;
990 int color_model = edl->session->color_model;
992 //printf("render clip: %s\n", name);
993 VFrame::get_temp(gui->temp_picon, width, height, color_model);
994 char string[BCTEXTLEN];
995 sprintf(string, _("Rendering %s"), name);
996 mwindow->gui->lock_window("AssetPicon::create_objects");
997 mwindow->gui->show_message(string);
998 mwindow->gui->unlock_window();
999 open_render_engine(edl, 0);
1000 render_video(0, gui->temp_picon);
1001 close_render_engine();
1002 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1003 vframe->transfer_from(gui->temp_picon);
1005 vframe->write_png(clip_icon_path);
1007 pixmap_w = pixmap_h * width / height;
1008 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1009 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1010 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1011 icon_vframe->transfer_from(vframe);
1013 gui->lock_window("AssetPicon::create_objects 0");
1014 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1015 icon->draw_vframe(icon_vframe,
1016 0, 0, pixmap_w, pixmap_h, 0, 0);
1019 icon = gui->clip_icon;
1020 icon_vframe = gui->clip_vframe;
1024 if( edl->tracks->playable_audio_tracks() ) {
1025 if( mwindow->preferences->use_thumbnails ) {
1026 gui->unlock_window();
1027 char clip_icon_path[BCTEXTLEN];
1028 char *clip_icon = edl->local_session->clip_icon;
1029 if( clip_icon[0] ) {
1030 snprintf(clip_icon_path, sizeof(clip_icon_path),
1031 "%s/%s", File::get_config_path(), clip_icon);
1032 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1034 if( !icon_vframe ) {
1035 pixmap_w = pixmap_h * 16/9;
1036 icon_vframe = new VFrame(0,
1037 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1038 icon_vframe->clear_frame();
1039 char string[BCTEXTLEN];
1040 sprintf(string, _("Rendering %s"), name);
1041 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1042 mwindow->gui->show_message(string);
1043 mwindow->gui->unlock_window();
1044 int sample_rate = edl->get_sample_rate();
1045 int channels = edl->get_audio_channels();
1046 if( channels > 2 ) channels = 2;
1047 int64_t audio_samples = edl->get_audio_samples();
1048 double duration = (double)audio_samples / sample_rate;
1049 draw_hue_bar(icon_vframe, duration);
1050 Samples *samples[MAX_CHANNELS];
1051 int bfrsz = sample_rate;
1052 for( int i=0; i<MAX_CHANNELS; ++i )
1053 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1054 open_render_engine(edl, 1);
1055 render_audio(0, samples, bfrsz);
1056 close_render_engine();
1057 gui->lock_window("AssetPicon::create_objects 4");
1058 static int line_colors[2] = { GREEN, YELLOW };
1059 static int base_colors[2] = { RED, PINK };
1060 for( int i=channels; --i>=0; ) {
1061 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1062 base_colors[i], line_colors[i]);
1064 for( int i=0; i<channels; ++i ) delete samples[i];
1065 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1068 pixmap_w = icon_vframe->get_w();
1069 pixmap_h = icon_vframe->get_h();
1071 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1072 icon->draw_vframe(icon_vframe,
1073 0, 0, pixmap_w, pixmap_h, 0, 0);
1076 icon = gui->clip_icon;
1077 icon_vframe = gui->clip_vframe;
1083 strcpy(name, _(plugin->title));
1085 icon_vframe = plugin->get_picon();
1087 icon = gui->create_pixmap(icon_vframe);
1088 else if( plugin->audio ) {
1089 if( plugin->transition ) {
1090 icon = gui->atransition_icon;
1091 icon_vframe = gui->atransition_vframe;
1093 else if( plugin->is_ffmpeg() ) {
1094 icon = gui->ff_aud_icon;
1095 icon_vframe = gui->ff_aud_vframe;
1097 else if( plugin->is_ladspa() ) {
1098 icon = gui->ladspa_icon;
1099 icon_vframe = gui->ladspa_vframe;
1102 icon = gui->aeffect_icon;
1103 icon_vframe = gui->aeffect_vframe;
1106 else if( plugin->video ) {
1107 if( plugin->transition ) {
1108 icon = gui->vtransition_icon;
1109 icon_vframe = gui->vtransition_vframe;
1111 else if( plugin->is_ffmpeg() ) {
1112 icon = gui->ff_vid_icon;
1113 icon_vframe = gui->ff_vid_vframe;
1116 icon = gui->veffect_icon;
1117 icon_vframe = gui->veffect_vframe;
1125 mwindow->edl->session->time_format,
1126 mwindow->edl->session->sample_rate,
1127 mwindow->edl->session->frame_rate,
1128 mwindow->edl->session->frames_per_foot);
1130 icon = gui->label_icon;
1131 icon_vframe = gui->label_vframe;
1134 icon = gui->file_icon;
1135 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1138 set_icon_vframe(icon_vframe);
1141 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1142 : BC_Window(_(PROGRAM_NAME ": Resources"),
1143 mwindow->session->awindow_x, mwindow->session->awindow_y,
1144 mwindow->session->awindow_w, mwindow->session->awindow_h,
1147 this->mwindow = mwindow;
1148 this->awindow = awindow;
1150 file_vframe = 0; file_icon = 0;
1151 folder_vframe = 0; folder_icon = 0;
1152 audio_vframe = 0; audio_icon = 0;
1153 video_vframe = 0; video_icon = 0;
1154 label_vframe = 0; label_icon = 0;
1156 atransition_vframe = 0; atransition_icon = 0;
1157 vtransition_vframe = 0; vtransition_icon = 0;
1158 aeffect_vframe = 0; aeffect_icon = 0;
1159 ladspa_vframe = 0; ladspa_icon = 0;
1160 veffect_vframe = 0; veffect_icon = 0;
1161 ff_aud_vframe = 0; ff_aud_icon = 0;
1162 ff_vid_vframe = 0; ff_vid_icon = 0;
1164 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1165 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1166 clip_folder_vframe = 0; clip_folder_icon = 0;
1167 label_folder_vframe = 0; label_folder_icon = 0;
1168 media_folder_vframe = 0; media_folder_icon = 0;
1169 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1170 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1171 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1173 ladspa_vframe = 0; ladspa_icon = 0;
1174 ff_aud_vframe = 0; ff_aud_icon = 0;
1175 ff_vid_vframe = 0; ff_vid_icon = 0;
1177 clip_vframe = 0; clip_icon = 0;
1178 atransition_vframe = 0; atransition_icon = 0;
1179 vtransition_vframe = 0; vtransition_icon = 0;
1180 aeffect_vframe = 0; aeffect_icon = 0;
1181 veffect_vframe = 0; veffect_icon = 0;
1183 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1185 effectlist_menu = 0;
1190 folderlist_menu = 0;
1193 allow_iconlisting = 1;
1198 displayed_folder = AW_NO_FOLDER;
1199 new_folder_thread = 0;
1200 modify_folder_thread = 0;
1201 folder_lock = new Mutex("AWindowGUI::folder_lock");
1204 AWindowGUI::~AWindowGUI()
1206 assets.remove_all_objects();
1207 folders.remove_all_objects();
1208 aeffects.remove_all_objects();
1209 veffects.remove_all_objects();
1210 atransitions.remove_all_objects();
1211 vtransitions.remove_all_objects();
1212 labellist.remove_all_objects();
1213 displayed_assets[1].remove_all_objects();
1215 delete new_folder_thread;
1216 delete modify_folder_thread;
1217 delete vicon_thread;
1222 delete remove_plugin;
1224 delete file_vframe; delete file_icon;
1225 delete folder_vframe; delete folder_icon;
1226 delete audio_vframe; delete audio_icon;
1227 delete video_vframe; delete video_icon;
1228 delete label_vframe; delete label_icon;
1229 delete clip_vframe; delete clip_icon;
1230 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1231 delete atransition_folder_vframe; delete atransition_folder_icon;
1232 delete veffect_folder_vframe; delete veffect_folder_icon;
1233 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1234 delete clip_folder_vframe; delete clip_folder_icon;
1235 delete label_folder_vframe; delete label_folder_icon;
1236 delete media_folder_vframe; delete media_folder_icon;
1237 delete proxy_folder_vframe; delete proxy_folder_icon;
1238 delete ladspa_vframe; delete ladspa_icon;
1239 delete ff_aud_vframe; delete ff_aud_icon;
1240 delete ff_vid_vframe; delete ff_vid_icon;
1241 delete atransition_vframe; delete atransition_icon;
1242 delete vtransition_vframe; delete vtransition_icon;
1243 delete aeffect_vframe; delete aeffect_icon;
1244 delete veffect_vframe; delete veffect_icon;
1248 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1250 return icon == file_icon ||
1251 icon == folder_icon ||
1252 icon == audio_icon ||
1253 icon == video_icon ||
1254 icon == clip_icon ||
1255 icon == label_icon ||
1256 icon == vtransition_icon ||
1257 icon == atransition_icon ||
1258 icon == veffect_icon ||
1259 icon == aeffect_icon ||
1260 icon == ladspa_icon ||
1261 icon == ff_aud_icon ||
1262 icon == ff_vid_icon ||
1263 icon == aeffect_folder_icon ||
1264 icon == veffect_folder_icon ||
1265 icon == atransition_folder_icon ||
1266 icon == vtransition_folder_icon ||
1267 icon == label_folder_icon ||
1268 icon == clip_folder_icon ||
1269 icon == media_folder_icon ||
1270 icon == proxy_folder_icon;
1273 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1275 char png_path[BCTEXTLEN];
1276 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1277 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1278 File::get_plugin_path(), plugin_icons, name);
1279 if( access(png_path, R_OK) ) return 0;
1280 return VFramePng::vframe_png(png_path,0,0);
1283 VFrame *AWindowGUI::get_picon(const char *name)
1285 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1287 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1288 snprintf(pp, ep-pp, "%s.png", name);
1289 unsigned char *data = mwindow->theme->get_image_data(png_name);
1290 if( data ) vframe = new VFramePng(data, 0.);
1295 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1297 vfrm = get_picon(fn);
1298 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1299 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1301 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1303 vfrm = get_picon(fn);
1304 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1305 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1307 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1309 vfrm = get_picon(fn);
1310 if( !vfrm ) vfrm = new VFramePng(png);
1311 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1314 void AWindowGUI::create_objects()
1316 lock_window("AWindowGUI::create_objects");
1317 asset_titles[0] = C_("Title");
1318 asset_titles[1] = _("Comments");
1320 set_icon(mwindow->theme->get_image("awindow_icon"));
1322 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1323 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1324 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1325 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1326 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1328 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1329 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1330 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1331 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1332 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1333 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1334 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1335 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1337 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1338 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1339 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1340 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1341 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1342 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1343 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1344 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1346 theme_icon(clip_vframe, clip_icon, "clip_icon");
1347 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1348 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1349 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1350 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1352 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1353 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1354 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1355 folder_lock->lock("AWindowGUI::create_objects");
1356 // Mandatory folders
1357 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1358 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1359 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1360 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1361 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1362 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1363 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1364 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1366 create_label_folder();
1367 folder_lock->unlock();
1369 mwindow->theme->get_awindow_sizes(this);
1370 load_defaults(mwindow->defaults);
1371 new_folder_thread = new NewFolderThread(this);
1372 modify_folder_thread = new ModifyFolderThread(this);
1374 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1375 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1376 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1377 search_text->create_objects();
1378 int dy = search_text->get_h() + 10;
1380 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1382 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1383 asset_list->update_vicon_area();
1384 vicon_thread->start();
1385 vicon_audio = new AssetVIconAudio(this);
1387 add_subwindow(divider = new AWindowDivider(mwindow, this,
1388 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1389 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1391 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1393 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1394 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1395 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1396 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1397 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1398 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1399 add_tools->create_objects();
1400 fy += add_tools->get_h(); fh -= add_tools->get_h();
1401 add_subwindow(folder_list = new AWindowFolders(mwindow,
1402 this, fx, fy, fw, fh));
1404 folder_list->load_expanders();
1406 //int x = mwindow->theme->abuttons_x;
1407 //int y = mwindow->theme->abuttons_y;
1409 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1410 asset_menu->create_objects();
1411 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1412 clip_menu->create_objects();
1413 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1414 label_menu->create_objects();
1415 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1416 proxy_menu->create_objects();
1418 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1419 effectlist_menu->create_objects();
1420 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1421 assetlist_menu->create_objects();
1422 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1423 cliplist_menu->create_objects();
1424 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1425 labellist_menu->create_objects();
1426 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1427 proxylist_menu->create_objects();
1429 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1430 folderlist_menu->create_objects();
1432 create_custom_xatoms();
1436 int AWindowGUI::resize_event(int w, int h)
1438 mwindow->session->awindow_x = get_x();
1439 mwindow->session->awindow_y = get_y();
1440 mwindow->session->awindow_w = w;
1441 mwindow->session->awindow_h = h;
1443 mwindow->theme->get_awindow_sizes(this);
1444 mwindow->theme->draw_awindow_bg(this);
1445 reposition_objects();
1447 // int x = mwindow->theme->abuttons_x;
1448 // int y = mwindow->theme->abuttons_y;
1449 // new_bin->reposition_window(x, y);
1450 // x += new_bin->get_w();
1451 // delete_bin->reposition_window(x, y);
1452 // x += delete_bin->get_w();
1453 // rename_bin->reposition_window(x, y);
1454 // x += rename_bin->get_w();
1455 // delete_disk->reposition_window(x, y);
1456 // x += delete_disk->get_w();
1457 // delete_project->reposition_window(x, y);
1458 // x += delete_project->get_w();
1459 // info->reposition_window(x, y);
1460 // x += info->get_w();
1461 // redraw_index->reposition_window(x, y);
1462 // x += redraw_index->get_w();
1463 // paste->reposition_window(x, y);
1464 // x += paste->get_w();
1465 // append->reposition_window(x, y);
1466 // x += append->get_w();
1467 // view->reposition_window(x, y);
1469 BC_WindowBase::resize_event(w, h);
1470 asset_list->update_vicon_area();
1474 int AWindowGUI::translation_event()
1476 mwindow->session->awindow_x = get_x();
1477 mwindow->session->awindow_y = get_y();
1481 void AWindowGUI::reposition_objects()
1483 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1484 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1485 search_text->reposition_window(x1, y1+5, w1);
1486 int dy = search_text->get_h() + 10;
1488 asset_list->reposition_window(x1, y1, w1, h1);
1489 divider->reposition_window(
1490 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1491 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1492 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1493 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1494 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1495 avicon_drawing->reposition_window(fw-avicon_w, fy);
1496 fy += add_tools->get_h(); fh -= add_tools->get_h();
1497 folder_list->reposition_window(fx, fy, fw, fh);
1500 int AWindowGUI::save_defaults(BC_Hash *defaults)
1502 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1503 defaults->update("VICON_DRAWING", vicon_drawing);
1507 int AWindowGUI::load_defaults(BC_Hash *defaults)
1509 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1510 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1514 int AWindowGUI::close_event()
1517 mwindow->session->show_awindow = 0;
1520 mwindow->gui->lock_window("AWindowGUI::close_event");
1521 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1522 mwindow->gui->unlock_window();
1524 lock_window("AWindowGUI::close_event");
1525 save_defaults(mwindow->defaults);
1526 mwindow->save_defaults();
1530 void AWindowGUI::start_vicon_drawing()
1532 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1533 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1534 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1535 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1536 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1537 switch( mwindow->edl->session->assetlist_format ) {
1539 case ASSETS_ICONS_PACKED:
1540 case ASSETS_ICON_LIST:
1541 asset_list->update_vicon_area();
1542 vicon_thread->start_drawing();
1550 void AWindowGUI::stop_vicon_drawing()
1552 if( vicon_thread->interrupted ) return;
1553 vicon_thread->stop_drawing();
1556 VFrame *AssetPicon::get_vicon_frame()
1558 if( !vicon ) return 0;
1559 if( gui->vicon_thread->interrupted ) return 0;
1560 VFrame *frame = vicon->frame();
1561 if( !frame ) return 0;
1563 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1564 vicon_frame->transfer_from(frame);
1568 int AWindowGUI::cycle_assetlist_format()
1570 EDLSession *session = mwindow->edl->session;
1571 int format = ASSETS_TEXT;
1572 if( allow_iconlisting ) {
1573 switch( session->assetlist_format ) {
1575 format = ASSETS_ICONS;
1578 format = ASSETS_ICONS_PACKED;
1580 case ASSETS_ICONS_PACKED:
1581 format = ASSETS_ICON_LIST;
1583 case ASSETS_ICON_LIST:
1584 format = ASSETS_TEXT;
1588 stop_vicon_drawing();
1589 session->assetlist_format = format;
1590 asset_list->update_format(session->assetlist_format, 0);
1591 async_update_assets();
1592 start_vicon_drawing();
1596 AWindowRemovePluginGUI::
1597 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1598 int x, int y, PluginServer *plugin)
1599 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1601 this->awindow = awindow;
1602 this->thread = thread;
1603 this->plugin = plugin;
1604 VFrame *vframe = plugin->get_picon();
1605 icon = vframe ? create_pixmap(vframe) : 0;
1606 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1609 AWindowRemovePluginGUI::
1610 ~AWindowRemovePluginGUI()
1612 if( !awindow->gui->protected_pixmap(icon) )
1614 plugin_list.remove_all();
1617 void AWindowRemovePluginGUI::create_objects()
1619 lock_window("AWindowRemovePluginGUI::create_objects");
1620 BC_Button *ok_button = new BC_OKButton(this);
1621 add_subwindow(ok_button);
1622 BC_Button *cancel_button = new BC_CancelButton(this);
1623 add_subwindow(cancel_button);
1625 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1626 add_subwindow(title);
1627 y += title->get_h() + 5;
1628 list = new BC_ListBox(x, y,
1629 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1630 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1631 add_subwindow(list);
1636 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1639 for( int i=0; i<folder.size(); ) {
1640 AssetPicon *picon = (AssetPicon *)folder[i];
1641 if( picon->plugin == plugin ) {
1642 folder.remove_object_number(i);
1651 void AWindowRemovePlugin::handle_close_event(int result)
1654 printf(_("remove %s\n"), plugin->path);
1655 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1656 ArrayList<BC_ListBoxItem*> *folder =
1657 plugin->audio ? plugin->transition ?
1658 &awindow->gui->atransitions :
1659 &awindow->gui->aeffects :
1660 plugin->video ? plugin->transition ?
1661 &awindow->gui->vtransitions :
1662 &awindow->gui->veffects :
1664 if( folder ) remove_plugin(plugin, *folder);
1665 MWindow *mwindow = awindow->mwindow;
1666 awindow->gui->unlock_window();
1667 char plugin_path[BCTEXTLEN];
1668 strcpy(plugin_path, plugin->path);
1669 mwindow->plugindb->remove(plugin);
1670 remove(plugin_path);
1671 char index_path[BCTEXTLEN];
1672 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1674 char picon_path[BCTEXTLEN];
1676 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1677 File::get_plugin_path());
1678 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1679 plugin->get_plugin_png_name(png_name);
1680 fs.update(picon_path);
1681 for( int i=0; i<fs.dir_list.total; ++i ) {
1682 char *fs_path = fs.dir_list[i]->path;
1683 if( !fs.is_dir(fs_path) ) continue;
1684 snprintf(png_path, sizeof(picon_path), "%s/%s",
1688 delete plugin; plugin = 0;
1689 awindow->gui->async_update_assets();
1693 AWindowRemovePlugin::
1694 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1697 this->awindow = awindow;
1698 this->plugin = plugin;
1701 AWindowRemovePlugin::
1702 ~AWindowRemovePlugin()
1707 BC_Window* AWindowRemovePlugin::new_gui()
1709 int x = awindow->gui->get_abs_cursor_x(0);
1710 int y = awindow->gui->get_abs_cursor_y(0);
1711 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1712 gui->create_objects();
1716 int AWindowGUI::keypress_event()
1718 switch( get_keypress() ) {
1726 if( !ctrl_down() && !shift_down() ) {
1727 assetlist_menu->load_file->handle_event();
1732 return cycle_assetlist_format();
1734 if( shift_down() && ctrl_down() ) {
1735 PluginServer* plugin = selected_plugin();
1736 if( !plugin ) break;
1737 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1739 remove_plugin->start();
1740 lock_window("AWindowGUI::keypress_event 1");
1744 if( shift_down() ) {
1745 mwindow->awindow->asset_remove->start();
1749 mwindow->remove_assets_from_project(1, 1,
1750 mwindow->session->drag_assets,
1751 mwindow->session->drag_clips);
1752 lock_window("AWindowGUI::keypress_event 2");
1758 if( shift_down() && ctrl_down() ) {
1759 resend_event(mwindow->gui);
1769 int AWindowGUI::create_custom_xatoms()
1771 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1774 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1776 if( event->message_type == UpdateAssetsXAtom ) {
1783 void AWindowGUI::async_update_assets()
1786 event.message_type = UpdateAssetsXAtom;
1787 send_custom_xatom(&event);
1791 void AWindowGUI::update_folder_list()
1793 for( int i = 0; i < folders.total; i++ ) {
1794 AssetPicon *picon = (AssetPicon*)folders.values[i];
1798 // Search assets for folders
1799 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1800 BinFolder *bin_folder = mwindow->edl->folders[i];
1803 for( int j = 0; j < folders.total; j++ ) {
1804 AssetPicon *picon = (AssetPicon*)folders[j];
1805 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1813 const char *title = bin_folder->title;
1814 int folder = bin_folder->awindow_folder;
1815 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1816 picon->create_objects();
1817 folders.append(picon);
1821 // Delete unused non-persistent folders
1822 int do_autoplace = 0;
1823 for( int i=folders.total; --i>=0; ) {
1824 AssetPicon *picon = (AssetPicon*)folders.values[i];
1825 if( !picon->in_use && !picon->persistent ) {
1827 folders.remove_number(i);
1832 folder_list->set_autoplacement(&folders, 0, 1);
1835 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1836 int do_audio, int do_video, int is_realtime, int is_transition)
1838 ArrayList<PluginServer*> plugin_list;
1839 // Get pointers to plugindb entries
1840 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1843 for( int i = 0; i < plugin_list.total; i++ ) {
1844 PluginServer *server = plugin_list.values[i];
1845 int visible = plugin_visibility & (1<<server->dir_idx);
1846 if( !visible ) continue;
1847 // Create new listitem
1848 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1849 picon->create_objects();
1850 output->append(picon);
1854 void AWindowGUI::create_label_folder()
1857 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1858 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1859 picon->create_objects();
1860 labellist.append(picon);
1865 void AWindowGUI::update_asset_list()
1867 ArrayList<AssetPicon *> new_assets;
1868 for( int i = 0; i < assets.total; i++ ) {
1869 AssetPicon *picon = (AssetPicon*)assets.values[i];
1873 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1874 // Synchronize EDL clips
1875 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1878 // Look for clip in existing listitems
1879 for( int j = 0; j < assets.total && !exists; j++ ) {
1880 AssetPicon *picon = (AssetPicon*)assets.values[j];
1882 if( picon->id == mwindow->edl->clips[i]->id ) {
1883 picon->edl = mwindow->edl->clips[i];
1884 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1890 // Create new listitem
1892 AssetPicon *picon = new AssetPicon(mwindow,
1893 this, mwindow->edl->clips[i]);
1894 new_assets.append(picon);
1898 // Synchronize EDL assets
1899 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1902 // Look for asset in existing listitems
1903 for( int j = 0; j < assets.total && !exists; j++ ) {
1904 AssetPicon *picon = (AssetPicon*)assets.values[j];
1906 if( picon->id == current->id ) {
1907 picon->indexable = current;
1913 // Create new listitem
1915 AssetPicon *picon = new AssetPicon(mwindow,
1917 new_assets.append(picon);
1921 // Synchronize nested EDLs
1922 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1924 EDL *nested_edl = mwindow->edl->nested_edls[i];
1926 // Look for asset in existing listitems
1927 for( int j=0; j<assets.total && !exists; ++j ) {
1928 AssetPicon *picon = (AssetPicon*)assets.values[j];
1930 if( picon->id == nested_edl->id ) {
1931 picon->indexable = nested_edl;
1937 // Create new listitem
1939 AssetPicon *picon = new AssetPicon(mwindow,
1940 this, (Indexable*)nested_edl);
1941 new_assets.append(picon);
1944 mwindow->gui->unlock_window();
1946 for( int i=0; i<new_assets.size(); ++i ) {
1947 AssetPicon *picon = new_assets[i];
1948 picon->create_objects();
1949 if( picon->indexable )
1950 picon->foldernum = AW_MEDIA_FOLDER;
1951 else if( picon->edl )
1952 picon->foldernum = AW_CLIP_FOLDER;
1953 assets.append(picon);
1956 mwindow->gui->lock_window();
1957 mwindow->gui->default_message();
1958 mwindow->gui->unlock_window();
1960 for( int i = assets.size() - 1; i >= 0; i-- ) {
1961 AssetPicon *picon = (AssetPicon*)assets.get(i);
1962 if( !picon->in_use ) {
1964 assets.remove_number(i);
1967 if( picon->indexable && picon->indexable->is_asset ) {
1969 picon->comments_time = !stat(picon->indexable->path, &st) ?
1975 void AWindowGUI::update_picon(Indexable *indexable)
1978 for( int i = 0; i < assets.total; i++ ) {
1979 AssetPicon *picon = (AssetPicon*)assets.values[i];
1980 if( picon->indexable == indexable ||
1981 picon->edl == (EDL *)indexable ) {
1982 char name[BCTEXTLEN];
1984 fs.extract_name(name, indexable->path);
1985 picon->set_text(name);
1986 vicon = picon->vicon;
1991 stop_vicon_drawing();
1992 vicon->clear_images();
1993 vicon->reset(indexable->get_frame_rate());
1994 start_vicon_drawing();
1998 void AWindowGUI::sort_assets()
2000 folder_lock->lock("AWindowGUI::sort_assets");
2001 switch( mwindow->edl->session->awindow_folder ) {
2002 case AW_AEFFECT_FOLDER:
2003 sort_picons(&aeffects);
2005 case AW_VEFFECT_FOLDER:
2006 sort_picons(&veffects);
2008 case AW_ATRANSITION_FOLDER:
2009 sort_picons(&atransitions);
2011 case AW_VTRANSITION_FOLDER:
2012 sort_picons(&vtransitions);
2014 case AW_LABEL_FOLDER:
2015 sort_picons(&labellist);
2018 sort_picons(&assets);
2022 asset_list->update_format(asset_list->get_format(), 0);
2023 folder_lock->unlock();
2027 void AWindowGUI::sort_folders()
2029 folder_lock->lock("AWindowGUI::update_assets");
2030 // folder_list->collapse_recursive(&folders, 0);
2031 folder_list->set_autoplacement(&folders, 0, 1);
2032 sort_picons(&folders);
2033 folder_list->update_format(folder_list->get_format(), 0);
2034 folder_lock->unlock();
2038 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2040 Asset *proxy_asset = (Asset *)indexable;
2041 char path[BCTEXTLEN];
2042 int proxy_scale = mwindow->edl->session->proxy_scale;
2043 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2044 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2045 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2046 // make a clip from proxy video tracks and unproxy audio tracks
2047 EDL *proxy_edl = new EDL(mwindow->edl);
2048 proxy_edl->create_objects();
2049 proxy_edl->set_path(proxy_asset->path);
2050 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2051 strcpy(proxy_edl->local_session->clip_title, path);
2052 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2053 proxy_edl->session->video_tracks = proxy_asset->layers;
2054 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2055 proxy_edl->create_default_tracks();
2056 double length = proxy_asset->frame_rate > 0 ?
2057 ( proxy_asset->video_length >= 0 ?
2058 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2059 ( proxy_edl->session->si_useduration ?
2060 proxy_edl->session->si_duration :
2061 1.0 / proxy_asset->frame_rate ) ) :
2062 1.0 / proxy_edl->session->frame_rate;
2063 Track *current = proxy_edl->tracks->first;
2064 for( int vtrack=0; current; current=NEXT ) {
2065 if( current->data_type != TRACK_VIDEO ) continue;
2066 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2068 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2069 current = proxy_edl->tracks->first;
2070 for( int atrack=0; current; current=NEXT ) {
2071 if( current->data_type != TRACK_AUDIO ) continue;
2072 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2074 proxy_edl->folder_no = AW_PROXY_FOLDER;
2079 void AWindowGUI::collect_assets(int proxy)
2081 mwindow->session->drag_assets->remove_all();
2082 mwindow->session->drag_clips->remove_all();
2083 int i = 0; AssetPicon *result;
2084 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2085 Indexable *indexable = result->indexable;
2086 if( proxy && indexable && indexable->is_asset &&
2087 indexable->folder_no == AW_PROXY_FOLDER ) {
2088 EDL *drag_edl = collect_proxy(indexable);
2089 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2093 mwindow->session->drag_assets->append(indexable);
2097 mwindow->session->drag_clips->append(result->edl);
2103 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2105 // Remove current pointers
2106 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2107 dst[0].remove_all();
2108 dst[1].remove_all_objects();
2110 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2111 int folder = mwindow->edl->session->awindow_folder;
2112 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2113 mwindow->edl->get_folder(folder);
2115 // Create new pointers
2116 for( int i = 0; i < src->total; i++ ) {
2117 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2118 picon = (AssetPicon*)src->values[i];
2119 picon->sort_key = -1;
2120 if( !visible && bin_folder ) {
2121 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2122 picon->indexable ? picon->indexable :
2123 picon->edl ? picon->edl->get_proxy_asset() : 0;
2125 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2126 if( picon->sort_key < 0 ) continue;
2130 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2132 if( !visible && picon->edl && picon->edl->folder_no == folder )
2134 if( visible && sub_items ) {
2135 if( !sub_items->matches(picon->get_text()) )
2139 const char *text = search_text->get_text();
2140 if( text && text[0] )
2141 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2143 if( visible && picon->vicon && picon->vicon->hidden )
2144 picon->vicon->hidden = 0;
2146 BC_ListBoxItem *item2, *item1;
2147 dst[0].append(item1 = picon);
2149 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2152 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2153 else if( picon->comments_time ) {
2154 char date_time[BCSTRLEN];
2155 struct tm stm; localtime_r(&picon->comments_time, &stm);
2156 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2157 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2158 stm.tm_hour, stm.tm_min, stm.tm_sec);
2159 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2162 dst[1].append(item2 = new BC_ListBoxItem(""));
2163 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2164 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2169 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2171 int done = 0, changed = 0;
2174 for( int i=0; i<src->total-1; ++i ) {
2175 AssetPicon *item1 = (AssetPicon *)src->values[i];
2176 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2177 double v = item2->sort_key - item1->sort_key;
2178 if( v > 0 ) continue;
2180 const char *cp1 = item1->get_text();
2181 const char *bp1 = strrchr(cp1, '/');
2182 if( bp1 ) cp1 = bp1 + 1;
2183 const char *cp2 = item2->get_text();
2184 const char *bp2 = strrchr(cp2, '/');
2185 if( bp2 ) cp2 = bp2 + 1;
2186 if( strcmp(cp2, cp1) >= 0 ) continue;
2188 src->values[i + 1] = item1;
2189 src->values[i] = item2;
2190 done = 0; changed = 1;
2194 for( int i=0; i<src->total; ++i ) {
2195 AssetPicon *item = (AssetPicon *)src->values[i];
2196 item->set_autoplace_icon(1);
2197 item->set_autoplace_text(1);
2202 void AWindowGUI::filter_displayed_assets()
2204 //allow_iconlisting = 1;
2205 asset_titles[0] = C_("Title");
2206 asset_titles[1] = _("Comments");
2207 AssetPicon *picon = 0;
2208 int selected_folder = mwindow->edl->session->awindow_folder;
2209 // Ensure the current folder icon is highlighted
2210 for( int i = 0; i < folders.total; i++ ) {
2211 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2212 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2213 folder_item->set_selected(selected);
2214 if( selected ) picon = folder_item;
2217 ArrayList<BC_ListBoxItem*> *src = &assets;
2218 switch( selected_folder ) {
2219 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2220 case AW_VEFFECT_FOLDER: src = &veffects; break;
2221 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2222 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2223 case AW_LABEL_FOLDER: src = &labellist;
2224 asset_titles[0] = _("Time Stamps");
2225 asset_titles[1] = C_("Title");
2226 //allow_iconlisting = 0;
2229 copy_picons(picon, src);
2233 void AWindowGUI::update_assets()
2235 stop_vicon_drawing();
2236 folder_lock->lock("AWindowGUI::update_assets");
2237 update_folder_list();
2238 update_asset_list();
2239 labellist.remove_all_objects();
2240 create_label_folder();
2242 if( displayed_folder != mwindow->edl->session->awindow_folder )
2243 search_text->clear();
2244 vicon_thread->hide_vicons();
2245 filter_displayed_assets();
2246 folder_lock->unlock();
2248 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2249 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2251 int folder_xposition = folder_list->get_xposition();
2252 int folder_yposition = folder_list->get_yposition();
2253 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2255 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2256 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2258 int asset_xposition = asset_list->get_xposition();
2259 int asset_yposition = asset_list->get_yposition();
2260 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2261 displayed_folder = mwindow->edl->session->awindow_folder;
2262 asset_xposition = asset_yposition = 0;
2264 asset_list->update(displayed_assets, asset_titles,
2265 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2266 asset_xposition, asset_yposition, -1, 0);
2267 asset_list->center_selection();
2270 start_vicon_drawing();
2274 void AWindowGUI::update_effects()
2276 aeffects.remove_all_objects();
2277 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2278 veffects.remove_all_objects();
2279 create_persistent_folder(&veffects, 0, 1, 1, 0);
2280 atransitions.remove_all_objects();
2281 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2282 vtransitions.remove_all_objects();
2283 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2286 int AWindowGUI::drag_motion()
2288 if( get_hidden() ) return 0;
2294 int AWindowGUI::drag_stop()
2296 if( get_hidden() ) return 0;
2300 Indexable* AWindowGUI::selected_asset()
2302 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2303 return picon ? picon->indexable : 0;
2306 PluginServer* AWindowGUI::selected_plugin()
2308 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2309 return picon ? picon->plugin : 0;
2312 AssetPicon* AWindowGUI::selected_folder()
2314 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2325 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2326 : BC_SubWindow(x, y, w, h)
2328 this->mwindow = mwindow;
2331 AWindowDivider::~AWindowDivider()
2335 int AWindowDivider::button_press_event()
2337 if( is_event_win() && cursor_inside() ) {
2338 mwindow->session->current_operation = DRAG_PARTITION;
2344 int AWindowDivider::cursor_motion_event()
2346 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2348 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2349 int fw = gui->get_relative_cursor_x();
2350 if( fw > wmax ) fw = wmax;
2351 if( fw < wmin ) fw = wmin;
2352 mwindow->session->afolders_w = fw;
2353 mwindow->theme->get_awindow_sizes(gui);
2354 gui->reposition_objects();
2360 int AWindowDivider::button_release_event()
2362 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2363 mwindow->session->current_operation = NO_OPERATION;
2374 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2375 : BC_ListBox(x, y, w, h,
2376 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2377 LISTBOX_ICONS : LISTBOX_TEXT,
2378 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2379 0, // Titles for columns. Set to 0 for no titles
2380 0, // width of each column
2381 1, // Total columns.
2382 0, // Pixel of top of window.
2383 0, // If this listbox is a popup window
2384 LISTBOX_SINGLE, // Select one item or multiple items
2385 ICON_TOP, // Position of icon relative to text of each item
2388 this->mwindow = mwindow;
2395 AWindowFolders::~AWindowFolders()
2399 int AWindowFolders::selection_changed()
2401 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2402 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2403 // prefer expanded entry
2404 AWindowFolderItem *item = item1 ? item1 : item0;
2405 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2406 item1->set_selected(0);
2413 AssetPicon *picon = item->get_picon();
2414 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2416 gui->stop_vicon_drawing();
2418 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2419 gui->folderlist_menu->update_titles();
2420 gui->folderlist_menu->activate_menu();
2423 mwindow->edl->session->awindow_folder = picon->foldernum;
2424 gui->asset_list->draw_background();
2425 gui->async_update_assets();
2427 gui->start_vicon_drawing();
2432 int AWindowFolders::button_press_event()
2434 int result = BC_ListBox::button_press_event();
2437 if( get_buttonpress() == RIGHT_BUTTON &&
2438 is_event_win() && cursor_inside() ) {
2439 gui->folderlist_menu->update_titles();
2440 gui->folderlist_menu->activate_menu();
2448 int AWindowFolders::drag_stop()
2451 if( get_hidden() ) return 0;
2452 if( mwindow->session->current_operation == DRAG_ASSET &&
2453 gui->folder_list->cursor_above() ) { // check user folder
2454 int item_no = gui->folder_list->get_cursor_data_item_no();
2455 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2456 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2457 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2458 ArrayList<Indexable *> *drags = folder->is_clips ?
2459 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2460 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2461 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2463 mwindow->session->current_operation = ::NO_OPERATION;
2470 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2471 : AWindowFolderItem(text)
2473 this->parent = parent;
2476 int AWindowFolders::load_expanders()
2478 char expanders_path[BCTEXTLEN];
2479 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2480 FILE *fp = fopen(expanders_path, "r");
2482 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2483 File::get_cindat_path(), EXPANDERS_FILE);
2484 fp = fopen(expanders_path, "r");
2488 const char tab = '\t';
2489 char line[BCTEXTLEN]; line[0] = 0;
2490 AWindowFolderItem *item = 0, *parent;
2491 AWindowFolderSubItems *sub_items = 0;
2493 while( fgets(line,sizeof(line),fp) ) {
2494 if( line[0] == '#' ) continue;
2495 int i = strlen(line);
2496 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2497 if( i == 0 ) continue;
2499 for( char *cp=line; *cp==tab; ++cp ) ++i;
2501 int i = gui->folders.size();
2503 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2504 if( !strcmp(folder->get_text(),_(line)) ) break;
2506 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2511 if( i > k+1 ) continue;
2513 if( line[i] != '-' && sub_items ) {
2514 sub_items->names.append(cstrdup(_(&line[i])));
2522 item = item->parent;
2525 parent = item->parent;
2527 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2528 if( !sublist ) sublist = parent->new_sublist(1);
2529 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2530 sublist->append(item = sub_items);
2537 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2538 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2539 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2540 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2541 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2543 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2544 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2545 mwindow->edl->session->asset_columns, // width of each column
2546 1, // Total columns.
2547 0, // Pixel of top of window.
2548 0, // If this listbox is a popup window
2549 LISTBOX_MULTIPLE, // Select one item or multiple items
2550 ICON_TOP, // Position of icon relative to text of each item
2551 -1) // Allow drags, require shift for scrolling
2553 this->mwindow = mwindow;
2556 set_scroll_stretch(1, 1);
2559 AWindowAssets::~AWindowAssets()
2563 int AWindowAssets::button_press_event()
2565 AssetVIconThread *avt = gui->vicon_thread;
2566 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2567 int dir = 1, button = get_buttonpress();
2569 case WHEEL_DOWN: dir = -1; // fall thru
2571 int x = get_cursor_x(), y = get_cursor_y();
2572 if( avt->cursor_inside(x, y) && avt->view_win )
2573 return avt->view_win->zoom_scale(dir);
2578 int result = BC_ListBox::button_press_event();
2580 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2581 is_event_win() && cursor_inside() ) {
2582 BC_ListBox::deactivate_selection();
2583 int folder = mwindow->edl->session->awindow_folder;
2585 case AW_AEFFECT_FOLDER:
2586 case AW_VEFFECT_FOLDER:
2587 case AW_ATRANSITION_FOLDER:
2588 case AW_VTRANSITION_FOLDER:
2589 gui->effectlist_menu->update();
2590 gui->effectlist_menu->activate_menu();
2592 case AW_LABEL_FOLDER:
2593 gui->labellist_menu->update();
2594 gui->labellist_menu->activate_menu();
2596 case AW_CLIP_FOLDER:
2597 gui->cliplist_menu->update();
2598 gui->cliplist_menu->activate_menu();
2600 case AW_PROXY_FOLDER:
2601 gui->proxylist_menu->update();
2602 gui->proxylist_menu->activate_menu();
2605 case AW_MEDIA_FOLDER: {
2606 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2607 gui->assetlist_menu->update_titles(shots);
2608 gui->assetlist_menu->activate_menu();
2618 int AWindowAssets::handle_event()
2620 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2621 if( !asset_picon ) return 0;
2622 Indexable *picon_idxbl = asset_picon->indexable;
2623 EDL *picon_edl = asset_picon->edl;
2625 VWindow *vwindow = 0;
2626 switch( mwindow->edl->session->awindow_folder ) {
2627 case AW_AEFFECT_FOLDER:
2628 case AW_VEFFECT_FOLDER:
2629 case AW_ATRANSITION_FOLDER:
2630 case AW_VTRANSITION_FOLDER: return 1;
2631 case AW_PROXY_FOLDER:
2632 proxy = 1; // fall thru
2634 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2635 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2638 if( !vwindow || !vwindow->is_running() ) return 1;
2639 if( proxy && picon_idxbl ) {
2640 picon_edl = gui->collect_proxy(picon_idxbl);
2644 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2645 else if( picon_edl ) vwindow->change_source(picon_edl);
2649 int AWindowAssets::selection_changed()
2651 // Show popup window
2653 int folder = mwindow->edl->session->awindow_folder;
2654 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2655 (item = (AssetPicon*)get_selection(0, 0)) ) {
2657 case AW_AEFFECT_FOLDER:
2658 case AW_VEFFECT_FOLDER:
2659 case AW_ATRANSITION_FOLDER:
2660 case AW_VTRANSITION_FOLDER:
2661 gui->effectlist_menu->update();
2662 gui->effectlist_menu->activate_menu();
2664 case AW_LABEL_FOLDER:
2665 if( !item->label ) break;
2666 gui->label_menu->activate_menu();
2668 case AW_CLIP_FOLDER:
2669 if( !item->indexable && !item->edl ) break;
2670 gui->clip_menu->update();
2671 gui->clip_menu->activate_menu();
2673 case AW_PROXY_FOLDER:
2674 if( !item->indexable && !item->edl ) break;
2675 gui->proxy_menu->update();
2676 gui->proxy_menu->activate_menu();
2679 if( !item->indexable && !item->edl ) break;
2680 gui->asset_menu->update();
2681 gui->asset_menu->activate_menu();
2685 deactivate_selection();
2687 else if( gui->vicon_drawing && get_button_down() &&
2688 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2690 case AW_MEDIA_FOLDER:
2691 case AW_PROXY_FOLDER:
2692 case AWINDOW_USER_FOLDERS:
2693 if( get_buttonpress() == LEFT_BUTTON ||
2694 get_buttonpress() == MIDDLE_BUTTON ) {
2695 AssetVIcon *vicon = 0;
2696 if( !gui->vicon_thread->vicon )
2697 vicon = item->vicon;
2698 int draw_mode = vicon && get_buttonpress() == MIDDLE_BUTTON ?
2699 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2700 gui->vicon_thread->set_view_popup(vicon, draw_mode);
2703 case AW_CLIP_FOLDER:
2704 if( get_buttonpress() == LEFT_BUTTON ) {
2705 AssetVIcon *vicon = 0;
2706 if( !gui->vicon_thread->vicon )
2707 vicon = item->vicon;
2708 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2716 void AWindowAssets::draw_background()
2718 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2719 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2720 set_font(LARGEFONT);
2721 int folder = mwindow->edl->session->awindow_folder;
2722 const char *title = mwindow->edl->get_folder_name(folder);
2723 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2724 title, -1, get_bg_surface());
2727 int AWindowAssets::drag_start_event()
2729 int collect_pluginservers = 0;
2730 int collect_assets = 0, proxy = 0;
2732 if( BC_ListBox::drag_start_event() ) {
2733 switch( mwindow->edl->session->awindow_folder ) {
2734 case AW_AEFFECT_FOLDER:
2735 mwindow->session->current_operation = DRAG_AEFFECT;
2736 collect_pluginservers = 1;
2738 case AW_VEFFECT_FOLDER:
2739 mwindow->session->current_operation = DRAG_VEFFECT;
2740 collect_pluginservers = 1;
2742 case AW_ATRANSITION_FOLDER:
2743 mwindow->session->current_operation = DRAG_ATRANSITION;
2744 collect_pluginservers = 1;
2746 case AW_VTRANSITION_FOLDER:
2747 mwindow->session->current_operation = DRAG_VTRANSITION;
2748 collect_pluginservers = 1;
2750 case AW_LABEL_FOLDER:
2753 case AW_PROXY_FOLDER:
2754 proxy = 1; // fall thru
2755 case AW_MEDIA_FOLDER:
2757 mwindow->session->current_operation = DRAG_ASSET;
2762 if( collect_pluginservers ) {
2764 mwindow->session->drag_pluginservers->remove_all();
2767 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2768 if( !result ) break;
2770 mwindow->session->drag_pluginservers->append(result->plugin);
2774 if( collect_assets ) {
2775 gui->collect_assets(proxy);
2783 int AWindowAssets::drag_motion_event()
2785 BC_ListBox::drag_motion_event();
2788 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2789 mwindow->gui->drag_motion();
2790 mwindow->gui->unlock_window();
2792 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2793 VWindow *vwindow = mwindow->vwindows.get(i);
2794 if( !vwindow->is_running() ) continue;
2795 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2796 vwindow->gui->drag_motion();
2797 vwindow->gui->unlock_window();
2800 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2801 mwindow->cwindow->gui->drag_motion();
2802 mwindow->cwindow->gui->unlock_window();
2804 lock_window("AWindowAssets::drag_motion_event");
2805 if( mwindow->session->current_operation == DRAG_ASSET &&
2806 gui->folder_list->cursor_above() ) { // highlight user folder
2807 BC_ListBoxItem *item = 0;
2808 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2809 if( item_no >= 0 ) {
2810 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2811 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2814 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2815 int folder_xposition = gui->folder_list->get_xposition();
2816 int folder_yposition = gui->folder_list->get_yposition();
2817 gui->folder_list->update(&gui->folders, 0, 0, 1,
2818 folder_xposition, folder_yposition, item_no, 0, 1);
2823 int AWindowAssets::drag_stop_event()
2827 result = gui->drag_stop();
2832 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2833 result = mwindow->gui->drag_stop();
2834 mwindow->gui->unlock_window();
2838 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2839 VWindow *vwindow = mwindow->vwindows.get(i);
2840 if( !vwindow ) continue;
2841 if( !vwindow->is_running() ) continue;
2842 if( vwindow->gui->is_hidden() ) continue;
2843 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2844 if( vwindow->gui->cursor_above() &&
2845 vwindow->gui->get_cursor_over_window() ) {
2846 result = vwindow->gui->drag_stop();
2848 vwindow->gui->unlock_window();
2853 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2854 result = mwindow->cwindow->gui->drag_stop();
2855 mwindow->cwindow->gui->unlock_window();
2858 lock_window("AWindowAssets::drag_stop_event");
2860 result = gui->folder_list->drag_stop();
2865 get_drag_popup()->set_animation(0);
2867 BC_ListBox::drag_stop_event();
2868 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2869 mwindow->session->current_operation = ::NO_OPERATION;
2874 int AWindowAssets::column_resize_event()
2876 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2877 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2881 int AWindowAssets::focus_in_event()
2883 int ret = BC_ListBox::focus_in_event();
2884 gui->start_vicon_drawing();
2888 int AWindowAssets::focus_out_event()
2890 gui->stop_vicon_drawing();
2891 return BC_ListBox::focus_out_event();
2894 void AWindowAssets::update_vicon_area()
2896 int x0 = 0, x1 = get_w();
2897 int y0 = get_title_h();
2899 if( is_highlighted() ) {
2900 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2901 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2903 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2906 int AWindowAssets::mouse_over_event(int no)
2908 if( gui->vicon_thread->viewing &&
2909 no >= 0 && no < gui->displayed_assets[0].size() ) {
2910 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2911 gui->vicon_thread->set_view_popup(picon->vicon);
2917 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2918 : BC_TextBox(x, y, w, 1, "")
2920 this->search_text = search_text;
2923 int AWindowSearchTextBox::handle_event()
2925 return search_text->handle_event();
2928 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2930 this->mwindow = mwindow;
2936 void AWindowSearchText::create_objects()
2938 int x1 = x, y1 = y, margin = 10;
2939 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2940 x1 += text_title->get_w() + margin;
2941 int w1 = gui->get_w() - x1 - 2*margin;
2942 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2945 int AWindowSearchText::handle_event()
2947 gui->async_update_assets();
2951 int AWindowSearchText::get_w()
2953 return text_box->get_w() + text_title->get_w() + 10;
2956 int AWindowSearchText::get_h()
2958 return bmax(text_box->get_h(),text_title->get_h());
2961 void AWindowSearchText::reposition_window(int x, int y, int w)
2963 int x1 = x, y1 = y, margin = 10;
2964 text_title->reposition_window(x1, y1);
2965 x1 += text_title->get_w() + margin;
2966 int w1 = gui->get_w() - x1 - 2*margin;
2967 text_box->reposition_window(x1, y1, w1);
2970 const char *AWindowSearchText::get_text()
2972 return text_box->get_text();
2975 void AWindowSearchText::clear()
2977 text_box->update("");
2980 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2981 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2983 this->mwindow = mwindow;
2985 set_tooltip(_("Delete asset from disk"));
2988 int AWindowDeleteDisk::handle_event()
2993 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2994 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2996 this->mwindow = mwindow;
2998 set_tooltip(_("Delete asset from project"));
3001 int AWindowDeleteProject::handle_event()
3006 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3007 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3009 // this->mwindow = mwindow;
3011 // set_tooltip(_("Edit information on asset"));
3014 // int AWindowInfo::handle_event()
3016 // int cur_x, cur_y;
3017 // gui->get_abs_cursor(cur_x, cur_y, 0);
3018 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3022 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3023 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3025 this->mwindow = mwindow;
3027 set_tooltip(_("Redraw index"));
3030 int AWindowRedrawIndex::handle_event()
3035 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3036 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3038 this->mwindow = mwindow;
3040 set_tooltip(_("Paste asset on recordable tracks"));
3043 int AWindowPaste::handle_event()
3048 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3049 : BC_Button(x, y, mwindow->theme->appendasset_data)
3051 this->mwindow = mwindow;
3053 set_tooltip(_("Append asset in new tracks"));
3056 int AWindowAppend::handle_event()
3061 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3062 : BC_Button(x, y, mwindow->theme->viewasset_data)
3064 this->mwindow = mwindow;
3066 set_tooltip(_("View asset"));
3069 int AWindowView::handle_event()
3074 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3075 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3077 this->mwindow = mwindow;
3081 void AddTools::create_objects()
3084 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3085 vis |= 1 << PLUGIN_FFMPEG_ID;
3086 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3087 vis |= 1 << PLUGIN_LADSPA_ID;
3089 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3090 vis |= 1 << PLUGIN_LV2_ID;
3092 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3093 PluginServer *plugin = MWindow::plugindb->get(i);
3094 if( !plugin->audio && !plugin->video ) continue;
3095 int idx = plugin->dir_idx;
3096 uint32_t msk = 1 << idx;
3097 if( (msk & vis) != 0 ) continue;
3099 char parent[BCTEXTLEN];
3100 strcpy(parent, plugin->path);
3101 char *bp = strrchr(parent, '/');
3102 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3103 if( !bp ) bp = parent; else ++bp;
3104 add_item(new AddPluginItem(this, bp, idx));
3109 // plugin_dirs list from toplevel makefile include plugin_defs
3114 N_("audio_transitions")
3121 N_("video_transitions")
3124 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3125 : BC_MenuItem(_(text))
3129 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3130 int chk = (msk & vis) ? 1 : 0;
3134 int AddPluginItem::handle_event()
3136 int chk = get_checked() ^ 1;
3138 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3139 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3140 menu->gui->update_effects();
3141 menu->gui->save_defaults(menu->mwindow->defaults);
3142 menu->gui->async_update_assets();
3146 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3147 : BC_Toggle(x, y, images, agui->vicon_drawing)
3150 set_tooltip(_("Preview"));
3153 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3155 int text_line = -1, toggle_x = -1, toggle_y = -1;
3156 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3157 BC_Toggle::calculate_extents(agui, images, 1,
3158 &text_line, ww, hh, &toggle_x, &toggle_y,
3159 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3162 AVIconDrawing::~AVIconDrawing()
3166 int AVIconDrawing::handle_event()
3168 agui->vicon_drawing = get_value();
3169 if( agui->vicon_drawing )
3170 agui->start_vicon_drawing();
3172 agui->stop_vicon_drawing();
3177 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3178 : BC_MenuItem("","v",'v')
3180 this->mwindow = mwindow;
3184 int AWindowListFormat::handle_event()
3186 return gui->cycle_assetlist_format();
3189 void AWindowListFormat::update()
3191 EDLSession *session = mwindow->edl->session;
3192 const char *text = 0;
3193 switch( session->assetlist_format ) {
3195 text = _("Display icons");
3198 text = _("Display icons packed");
3200 case ASSETS_ICONS_PACKED:
3201 text = _("Display icon list");
3203 case ASSETS_ICON_LIST:
3204 text = _("Display text");
3210 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3211 : BC_MenuItem(_("Sort items"))
3213 this->mwindow = mwindow;
3217 int AWindowListSort::handle_event()
3223 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3226 this->select_used = select_used;
3227 this->action = action;
3230 int AssetSelectUsedItem::handle_event()
3232 MWindow *mwindow = select_used->mwindow;
3233 AWindowGUI *gui = select_used->gui;
3234 AWindowAssets *asset_list = gui->asset_list;
3235 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3240 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3244 asset_list->set_all_selected(data, 0);
3245 for( int i = 0; i < data->total; i++ ) {
3246 AssetPicon *picon = (AssetPicon*)data->values[i];
3247 Indexable *idxbl = picon->indexable ? picon->indexable :
3248 picon->edl ? picon->edl->get_proxy_asset() : 0;
3249 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3250 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3255 int asset_xposition = asset_list->get_xposition();
3256 int asset_yposition = asset_list->get_yposition();
3257 asset_list->update(gui->displayed_assets, gui->asset_titles,
3258 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3259 asset_xposition, asset_yposition, -1, 0);
3260 asset_list->center_selection();
3264 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3265 : BC_MenuItem(_("Select"))
3267 this->mwindow = mwindow;