4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "assetedit.h"
25 #include "assetpopup.h"
26 #include "assetremove.h"
28 #include "audiodevice.h"
30 #include "awindowgui.h"
31 #include "bccmodels.h"
32 #include "bcsignals.h"
34 #include "binfolder.h"
39 #include "clippopup.h"
41 #include "cwindowgui.h"
46 #include "edlsession.h"
47 #include "effectlist.h"
49 #include "filesystem.h"
50 #include "folderlistmenu.h"
51 #include "indexable.h"
55 #include "labelpopup.h"
56 #include "localsession.h"
57 #include "mainerror.h"
59 #include "mainsession.h"
60 #include "mwindowgui.h"
62 #include "preferences.h"
64 #include "proxypopup.h"
65 #include "renderengine.h"
70 #include "transportque.h"
74 #include "vwindowgui.h"
77 #include "data/lad_picon_png.h"
78 #include "data/ff_audio_png.h"
79 #include "data/ff_video_png.h"
86 const char *AWindowGUI::folder_names[] =
90 N_("Audio Transitions"),
91 N_("Video Transitions"),
99 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
100 : VIcon(w, h, framerate), Garbage("AssetVIcon")
103 this->length = length;
107 AssetVIcon::~AssetVIcon()
109 picon->gui->vicon_thread->del_vicon(this);
113 VFrame *AssetVIcon::frame()
115 AssetVIconThread *avt = picon->gui->vicon_thread;
116 Asset *asset = (Asset *)picon->indexable;
119 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
120 if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1);
122 int sample_rate = asset->get_sample_rate();
123 int64_t audio_samples = asset->get_audio_samples();
124 double duration = (double)audio_samples / sample_rate;
125 picon->draw_hue_bar(temp, duration);
126 int secs = length / frame_rate + 0.5;
127 if( !secs ) secs = 1;
128 int bfrsz = VICON_SAMPLE_RATE;
129 int samples = audio_size/sizeof(vicon_audio_t);
130 double line_pos = (double)seq_no/(length-1);
131 int audio_pos = samples * line_pos * (secs-1)/secs;
132 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
133 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
134 double data[bfrsz], sample_scale = 1./mx;
135 int len = samples - audio_pos;
136 if( len > bfrsz ) len = bfrsz;
138 while( i < len ) data[i++] = *audio_data++ * sample_scale;
139 while( i < bfrsz ) data[i++] = 0;
140 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
141 int x = (w-1) * line_pos;
142 temp->pixel_rgb = RED;
143 temp->draw_line(x,0, x,h);
146 int vw = avt->vw, vh = avt->vh, vicon_cmodel = avt->vicon_cmodel;
147 if( !asset->video_data ) {
149 temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
154 if( seq_no >= images.size() ) {
155 MWindow *mwindow = picon->mwindow;
156 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
157 if( !file ) return 0;
158 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
159 delete temp; temp = 0;
162 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
163 while( seq_no >= images.size() ) {
164 mwindow->video_cache->check_in(asset);
166 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
167 if( !file ) { usleep(1000); continue; }
169 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
170 file->set_video_position(pos,0);
171 if( file->read_frame(temp) ) temp->clear_frame();
172 add_image(temp, vw, vh, vicon_cmodel);
174 mwindow->video_cache->check_in(asset);
176 return *images[seq_no];
179 int64_t AssetVIcon::set_seq_no(int64_t no)
181 if( no >= length ) no = 0;
185 int AssetVIcon::get_vx()
187 BC_ListBox *lbox = picon->gui->asset_list;
188 return lbox->get_icon_x(picon);
190 int AssetVIcon::get_vy()
192 BC_ListBox *lbox = picon->gui->asset_list;
193 return lbox->get_icon_y(picon);
196 void AssetVIcon::load_audio()
198 MWindow *mwindow = picon->mwindow;
199 Asset *asset = (Asset *)picon->indexable;
200 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
201 int channels = asset->get_audio_channels();
202 if( channels > 2 ) channels = 2;
203 int sample_rate = asset->get_sample_rate();
204 int bfrsz = sample_rate;
205 Samples samples(bfrsz);
206 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
207 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
208 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
209 double sample_scale = (double)mx / channels;
210 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
211 while( audio_pos < audio_len ) {
212 int64_t pos = audio_pos * time_scale;
213 for( int ch=0; ch<channels; ++ch ) {
214 file->set_channel(ch);
215 file->set_audio_position(pos);
216 file->read_samples(&samples, bfrsz);
217 double *data = samples.get_data();
218 for( int64_t k=audio_pos; k<audio_len; ++k ) {
219 int i = k * time_scale - pos;
220 if( i >= bfrsz ) break;
221 int v = audio_data[k] + data[i] * sample_scale;
222 audio_data[k] = CLIP(v, -mx,mx);
225 audio_pos = (pos + bfrsz) / time_scale;
227 mwindow->audio_cache->check_in(asset);
231 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
235 audio = new AudioDevice(gui->mwindow);
239 AssetVIconAudio::~AssetVIconAudio()
244 void AssetVIconAudio::run()
247 int64_t bfrsz = VICON_SAMPLE_RATE;
248 MWindow *mwindow = gui->mwindow;
249 EDL *edl = mwindow->edl;
250 EDLSession *session = edl->session;
251 AudioOutConfig *aconfig = session->playback_config->aconfig;
252 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
253 audio->start_playback();
254 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
255 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
256 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
258 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
259 while( !interrupted ) {
260 int len = audio_len - audio_pos;
261 if( len <= 0 ) break;
262 if( len > bfrsz ) len = bfrsz;
264 for( int i=0; i<len; ++i,++k )
265 out0[i] = out1[i] = (double)audio_data[k] / mx;
267 audio->write_buffer(out, channels, len);
271 audio->set_last_buffer();
272 audio->stop_audio(interrupted ? 0 : 1);
276 void AssetVIconAudio::start(AssetVIcon *vicon)
278 if( running() ) return;
285 void AssetVIconAudio::stop(int wait)
287 if( running() && !interrupted ) {
289 audio->stop_audio(wait);
293 vicon->playing_audio = 0;
298 void AssetVIcon::start_audio()
300 if( playing_audio < 0 ) return;
301 picon->gui->vicon_audio->stop(0);
303 picon->gui->vicon_audio->start(this);
306 void AssetVIcon::stop_audio()
308 if( playing_audio > 0 )
309 picon->gui->vicon_audio->stop(0);
313 AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode,
314 int x, int y, int w, int h)
315 : ViewPopup(vt, x, y, w, h)
317 this->draw_mode = draw_mode;
318 this->bar_h = (VIEW_POPUP_BAR_H * h) / 200;
321 AssetViewPopup::~AssetViewPopup()
325 int AssetViewPopup::button_press_event()
327 if( !is_event_win() ) return 0;
328 AssetVIconThread *avt = (AssetVIconThread *)vt;
329 if( !avt->vicon ) return 0;
331 switch( draw_mode ) {
332 case ASSET_VIEW_MEDIA_MAP:
333 case ASSET_VIEW_FULL:
340 switch( get_buttonpress() ) {
347 if( draw_mode != ASSET_VIEW_FULL )
348 return avt->zoom_scale(dir);
354 int x = get_cursor_x(), y = get_cursor_y();
355 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
356 AssetPicon *picon = vicon->picon;
357 MWindow *mwindow = picon->mwindow;
358 EDL *edl = mwindow->edl;
360 if( y < get_h()/2 ) {
362 picon->indexable ? picon->indexable :
363 picon->edl ? picon->edl : 0;
364 if( !idxbl ) return 0;
365 double sample_rate = idxbl->get_sample_rate();
366 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
367 idxbl->get_audio_samples() / sample_rate : 0;
368 double frame_rate = idxbl->get_frame_rate();
369 double video_length = frame_rate > 0 && idxbl->have_video() ?
370 idxbl->get_video_frames() / frame_rate : 0;
371 double idxbl_length = bmax(audio_length, video_length);
372 double pos = x * idxbl_length / get_w();
373 double start = 0, end = idxbl_length;
374 double lt = DBL_MAX, rt = DBL_MAX;
375 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
376 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
377 Indexable *indexable = (Indexable *)edit->asset;
378 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
379 if( !indexable ) continue;
380 if( indexable->id == idxbl->id ||
381 (!indexable->is_asset == !idxbl->is_asset &&
382 !strcmp(indexable->path, idxbl->path)) ) {
383 double start_pos = track->from_units(edit->startsource);
384 double end_pos = track->from_units(edit->startsource + edit->length);
385 double dlt = pos - start_pos, drt = end_pos - pos;
386 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
387 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
388 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
389 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
393 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
394 VWindow *vwindow = mwindow->get_viewer(1, 0);
395 vwindow->change_source(idxbl);
396 mwindow->gui->unlock_window();
397 EDL *vedl = vwindow->get_edl();
398 vedl->set_inpoint(start);
399 vedl->set_outpoint(end);
400 vedl->local_session->set_selectionstart(start);
401 vedl->local_session->set_selectionend(end);
402 vwindow->gui->lock_window("AssetViewPopup::button_press_event");
403 vwindow->update_position();
404 vwindow->gui->unlock_window();
409 if( !ctrl_down() && !shift_down() )
410 return cursor_motion_event();
412 picon->indexable ? picon->indexable :
413 picon->edl ? picon->edl : 0;
414 if( !idxbl ) return 0;
415 double total_length = mwindow->edl->tracks->total_length();
416 double pos = x * total_length / get_w();
417 double start = 0, end = total_length;
418 double lt = DBL_MAX, rt = DBL_MAX;
419 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
420 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
421 Indexable *indexable = (Indexable *)edit->asset;
422 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
423 if( !indexable ) continue;
424 if( indexable->id == idxbl->id ||
425 (!indexable->is_asset == !idxbl->is_asset &&
426 !strcmp(indexable->path, idxbl->path)) ) {
427 double start_pos = track->from_units(edit->startproject);
428 double end_pos = track->from_units(edit->startproject + edit->length);
429 double dlt = pos - start_pos, drt = end_pos - pos;
430 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
431 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
432 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
433 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
437 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
438 mwindow->select_point(!ctrl_down() && !shift_down() ? pos : start);
439 edl->local_session->set_selectionstart(start);
440 edl->local_session->set_selectionend(!shift_down() ? start : end);
441 mwindow->zoom_sample(edl->local_session->zoom_sample);
442 mwindow->gui->unlock_window();
448 int AssetViewPopup::button_release_event()
450 if( !is_event_win() ) return 0;
455 int AssetViewPopup::cursor_motion_event()
457 if( !is_event_win() ) return 0;
458 AssetVIconThread *avt = (AssetVIconThread *)vt;
460 ( draw_mode != ASSET_VIEW_FULL &&
461 draw_mode != ASSET_VIEW_MEDIA_MAP ) ) return 0;
462 if( !get_button_down() || get_buttonpress() != LEFT_BUTTON ||
463 ctrl_down() || alt_down() || shift_down() )
465 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
466 MWindow *mwindow = vicon->picon->mwindow;
467 EDL *edl = mwindow->edl;
469 int x = get_cursor_x();
470 double total_length = edl->tracks->total_length();
471 double pos = x * total_length / get_w();
472 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
473 mwindow->select_point(pos);
474 mwindow->zoom_sample(edl->local_session->zoom_sample);
475 mwindow->gui->unlock_window();
481 void AssetViewPopup::draw_vframe(VFrame *vframe)
483 switch( draw_mode ) {
484 case ASSET_VIEW_MEDIA:
485 case ASSET_VIEW_ICON:
486 ViewPopup::draw_vframe(vframe);
487 case ASSET_VIEW_NONE:
490 case ASSET_VIEW_MEDIA_MAP:
491 case ASSET_VIEW_FULL:
495 draw_box(0,0,get_w(),get_h());
497 int y2 = get_h()-bar_h;
498 BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
499 AssetVIconThread *avt = (AssetVIconThread *)vt;
500 AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
501 AssetPicon *picon = (AssetPicon *)vicon->picon;
503 picon->indexable ? picon->indexable :
504 picon->edl ? picon->edl : 0;
506 double sample_rate = idxbl->get_sample_rate();
507 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
508 idxbl->get_audio_samples() / sample_rate : 0;
509 double frame_rate = idxbl->get_frame_rate();
510 double video_length = frame_rate > 0 && idxbl->have_video() ?
511 idxbl->get_video_frames() / frame_rate : 0;
512 double idxbl_length = bmax(audio_length, video_length);
513 if( !idxbl_length ) idxbl_length = 1;
515 EDL *edl = picon->mwindow->edl;
516 double total_length = edl->tracks->total_length();
517 if( !total_length ) total_length = 1;
518 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
519 if( !track->record ) continue;
520 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
521 Indexable *indexable = (Indexable *)edit->asset;
522 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
523 if( !indexable ) continue;
524 if( indexable->id == idxbl->id ||
525 (!indexable->is_asset == !idxbl->is_asset &&
526 !strcmp(indexable->path, idxbl->path)) ) {
527 double pos1 = track->from_units(edit->startsource);
528 double pos2 = track->from_units(edit->startsource + edit->length);
529 double xscale = get_w() / idxbl_length;
530 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
532 draw_box(ex1,0, ex2-ex1,y1);
534 draw_line(ex1,0, ex1,y1);
535 draw_line(ex2,0, ex2,y1);
536 pos1 = track->from_units(edit->startproject);
537 pos2 = track->from_units(edit->startproject + edit->length);
538 xscale = get_w() / total_length;
539 int px1 = pos1 * xscale, px2 = pos2 * xscale;
541 draw_box(px1,y2, px2-px1,get_h()-y2);
543 draw_line(px1,y2, px1,get_h()-1);
544 draw_line(px2,y2, px2,get_h()-1);
547 draw_line(ex1,y1, px1,y2);
548 draw_line(ex2,y1, px2,y2);
554 int AssetViewPopup::keypress_event()
556 AssetVIconThread *avt = (AssetVIconThread *)vt;
557 switch( avt->draw_mode ) {
558 case ASSET_VIEW_MEDIA_MAP:
559 switch( get_keypress() ) {
562 avt->draw_mode = ASSET_VIEW_FULL;
567 case ASSET_VIEW_FULL:
568 avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
572 return ViewPopup::keypress_event();
576 AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
577 : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
578 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
581 draw_mode = ASSET_VIEW_NONE;
582 int vicon_cmodel = BC_RGB8;
583 switch( preferences->vicon_color_mode ) {
584 case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
585 case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
586 case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
588 this->vicon_cmodel = vicon_cmodel;
589 this->draw_lock = new Mutex("AssetVIconThread::draw_lock");
592 AssetVIconThread::~AssetVIconThread()
597 void AssetVIconThread::drawing_started()
599 draw_lock->lock("AssetVIconThread::drawing_started");
602 void AssetVIconThread::drawing_stopped()
607 void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
609 gui->stop_vicon_drawing();
610 int mode = !v ? ASSET_VIEW_NONE :
611 draw_mode >= 0 ? draw_mode :
614 this->draw_mode = mode;
615 gui->start_vicon_drawing();
618 ViewPopup *AssetVIconThread::new_view_window()
620 BC_WindowBase *parent = wdw->get_parent();
621 int rx = 0, ry = 0, rw = 0, rh = 0;
622 if( draw_mode != ASSET_VIEW_FULL ) {
623 XineramaScreenInfo *info = parent->get_xinerama_info(-1);
624 int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
625 int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
626 int vx = viewing->get_vx(), vy = viewing->get_vy();
627 wdw->get_root_coordinates(vx, vy, &rx, &ry);
628 rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
629 ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
630 rw = view_w; rh = view_h;
633 parent->get_fullscreen_geometry(rx, ry, rw, rh);
634 AssetViewPopup *popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
635 if( draw_mode == ASSET_VIEW_MEDIA_MAP || draw_mode == ASSET_VIEW_FULL )
636 vicon->playing_audio = -1;
637 wdw->set_active_subwindow(popup);
641 void AssetVIconThread::close_view_popup()
644 drawing_started(); // waits for draw lock
649 AWindowFolderItem::AWindowFolderItem()
655 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
656 : BC_ListBoxItem(text, color)
661 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
662 : BC_ListBoxItem(text, icon, color)
667 AssetPicon *AWindowFolderItem::get_picon()
669 AWindowFolderItem *item = this;
670 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
671 return (AssetPicon*)item;
674 int AWindowFolderSubItems::matches(const char *text)
676 int i = names.size();
677 while( --i >= 0 && strcmp(names[i], text) );
679 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
680 i = sublist ? sublist->size() : 0;
682 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
683 if( item->matches(text) ) break;
686 return i >= 0 ? 1 : 0;
690 AssetPicon::AssetPicon(MWindow *mwindow,
691 AWindowGUI *gui, Indexable *indexable)
692 : AWindowFolderItem()
695 this->mwindow = mwindow;
697 this->indexable = indexable;
698 indexable->add_user();
699 this->id = indexable->id;
702 AssetPicon::AssetPicon(MWindow *mwindow,
703 AWindowGUI *gui, EDL *edl)
704 : AWindowFolderItem()
707 this->mwindow = mwindow;
714 AssetPicon::AssetPicon(MWindow *mwindow,
715 AWindowGUI *gui, int folder, int persist)
716 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
717 folder>=0 && folder<AWINDOW_FOLDERS ?
718 gui->folder_icons[folder] : gui->folder_icon)
722 this->mwindow = mwindow;
724 persistent = persist;
727 AssetPicon::AssetPicon(MWindow *mwindow,
728 AWindowGUI *gui, int folder, const char *title)
729 : AWindowFolderItem(title, gui->folder_icon)
733 this->mwindow = mwindow;
738 AssetPicon::AssetPicon(MWindow *mwindow,
739 AWindowGUI *gui, PluginServer *plugin)
740 : AWindowFolderItem()
743 this->mwindow = mwindow;
745 this->plugin = plugin;
748 AssetPicon::AssetPicon(MWindow *mwindow,
749 AWindowGUI *gui, Label *label)
750 : AWindowFolderItem()
753 this->mwindow = mwindow;
761 AssetPicon::~AssetPicon()
763 if( vicon ) vicon->remove_user();
765 if( indexable ) indexable->remove_user();
766 if( edl ) edl->remove_user();
767 if( icon && !gui->protected_pixmap(icon) ) {
769 if( !plugin ) delete icon_vframe;
773 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
775 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
777 float h = 300 * t, s = 1., v = 1.;
778 float r, g, b; // duration, 0..1hr == hue red..magenta
779 HSV::hsv_to_rgb(r,g,b, h,s,v);
780 int ih = frame->get_h()/8, iw = frame->get_w();
781 int ir = r * 256; CLAMP(ir, 0,255);
782 int ig = g * 256; CLAMP(ig, 0,255);
783 int ib = b * 256; CLAMP(ib, 0,255);
784 unsigned char **rows = frame->get_rows();
785 for( int y=0; y<ih; ++y ) {
786 unsigned char *rp = rows[y];
787 for( int x=0; x<iw; rp+=3,++x ) {
788 rp[0] = ir; rp[1] = ig; rp[2] = ib;
793 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
794 int base_color, int line_color, int x, int y, int w, int h)
796 int h1 = h-1, h2 = h/2, iy = h2;
797 int rgb_color = frame->pixel_rgb;
798 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
799 double min = *dp, max = min;
800 x2 = (len * (ix+1))/w;
801 for( int i=x1; i<x2; ++i ) {
802 double value = *dp++;
803 if( value < min ) min = value;
804 if( value > max ) max = value;
806 int ctr = (min + max) / 2;
807 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
808 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
809 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
810 frame->pixel_rgb = line_color;
811 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
812 frame->pixel_rgb = base_color;
813 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
816 frame->pixel_rgb = rgb_color;
819 void AssetPicon::reset()
827 foldernum = AW_NO_FOLDER;
839 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
841 TransportCommand command;
842 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
843 command.get_edl()->copy_all(edl);
844 command.change_type = CHANGE_ALL;
845 command.realtime = 0;
846 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
847 render_engine->set_vcache(mwindow->video_cache);
848 render_engine->set_acache(mwindow->audio_cache);
849 render_engine->arm_command(&command);
851 void AssetPicon::close_render_engine()
853 delete render_engine; render_engine = 0;
855 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
857 if( !render_engine || !render_engine->vrender ) return;
858 render_engine->vrender->process_buffer(vfrm, pos, 0);
860 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
862 if( !render_engine || !render_engine->arender ) return;
863 render_engine->arender->process_buffer(samples, len, pos);
866 void AssetPicon::create_objects()
869 char name[BCTEXTLEN];
870 int pixmap_w, pixmap_h;
872 int picon_h = mwindow->preferences->awindow_picon_h;
873 pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale;
876 fs.extract_name(name, indexable->path);
880 set_text(strcpy(name, edl->local_session->clip_title));
884 if( indexable && indexable->is_asset ) {
885 Asset *asset = (Asset*)indexable;
886 if( asset->video_data ) {
887 if( mwindow->preferences->use_thumbnails ) {
888 gui->unlock_window();
889 File *file = mwindow->video_cache->check_out(asset,
894 int height = asset->height > 0 ? asset->height : 1;
895 pixmap_w = pixmap_h * asset->width / height;
898 file->set_video_position(0, 0);
900 if( gui->temp_picon &&
901 (gui->temp_picon->get_w() != asset->width ||
902 gui->temp_picon->get_h() != asset->height) ) {
903 delete gui->temp_picon;
907 if( !gui->temp_picon ) {
908 gui->temp_picon = new VFrame(0, -1,
909 asset->width, asset->height,
912 { char string[BCTEXTLEN];
913 sprintf(string, _("Reading %s"), name);
914 mwindow->gui->lock_window("AssetPicon::create_objects");
915 mwindow->gui->show_message(string);
916 mwindow->gui->unlock_window(); }
917 file->read_frame(gui->temp_picon);
918 mwindow->video_cache->check_in(asset);
920 gui->lock_window("AssetPicon::create_objects 0");
921 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
922 icon->draw_vframe(gui->temp_picon,
923 0, 0, pixmap_w, pixmap_h, 0, 0);
924 icon_vframe = new VFrame(0,
925 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
926 icon_vframe->transfer_from(gui->temp_picon);
927 if( asset->folder_no == AW_MEDIA_FOLDER ||
928 asset->folder_no == AW_PROXY_FOLDER ) {
930 double framerate = asset->get_frame_rate();
931 if( !framerate ) framerate = VICON_RATE;
932 int64_t frames = asset->get_video_frames();
933 double secs = frames / framerate;
934 if( secs > 5 ) secs = 5;
935 int64_t length = secs * gui->vicon_thread->refresh_rate;
936 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
937 if( asset->audio_data && secs > 0 ) {
938 gui->unlock_window();
939 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
940 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
942 gui->lock_window("AssetPicon::create_objects 1");
944 gui->vicon_thread->add_vicon(vicon);
948 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
949 gui->lock_window("AssetPicon::create_objects 2");
950 icon = gui->video_icon;
951 icon_vframe = gui->video_vframe;
955 icon = gui->video_icon;
956 icon_vframe = gui->video_vframe;
960 if( asset->audio_data ) {
961 if( mwindow->preferences->use_thumbnails ) {
962 gui->unlock_window();
963 File *file = mwindow->audio_cache->check_out(asset,
967 pixmap_w = pixmap_h * 16/9;
968 icon_vframe = new VFrame(0,
969 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
970 icon_vframe->clear_frame();
971 { char string[BCTEXTLEN];
972 sprintf(string, _("Reading %s"), name);
973 mwindow->gui->lock_window("AssetPicon::create_objects 3");
974 mwindow->gui->show_message(string);
975 mwindow->gui->unlock_window(); }
976 int sample_rate = asset->get_sample_rate();
977 int channels = asset->get_audio_channels();
978 if( channels > 2 ) channels = 2;
979 int64_t audio_samples = asset->get_audio_samples();
980 double duration = (double)audio_samples / sample_rate;
981 draw_hue_bar(icon_vframe, duration);
982 int bfrsz = sample_rate;
983 Samples samples(bfrsz);
984 static int line_colors[2] = { GREEN, YELLOW };
985 static int base_colors[2] = { RED, PINK };
986 for( int i=channels; --i>=0; ) {
987 file->set_channel(i);
988 file->set_audio_position(0);
989 file->read_samples(&samples, bfrsz);
990 draw_wave(icon_vframe, samples.get_data(), bfrsz,
991 base_colors[i], line_colors[i]);
993 mwindow->audio_cache->check_in(asset);
994 if( asset->folder_no == AW_MEDIA_FOLDER ) {
995 double secs = duration;
996 if( secs > 5 ) secs = 5;
997 double refresh_rate = gui->vicon_thread->refresh_rate;
998 int64_t length = secs * refresh_rate;
999 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
1000 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
1001 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
1002 vicon->load_audio();
1003 gui->vicon_thread->add_vicon(vicon);
1005 gui->lock_window("AssetPicon::create_objects 4");
1006 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1007 icon->draw_vframe(icon_vframe,
1008 0, 0, pixmap_w, pixmap_h, 0, 0);
1011 eprintf("Unable to open %s\nin asset: %s",asset->path, get_text());
1012 gui->lock_window("AssetPicon::create_objects 5");
1013 icon = gui->audio_icon;
1014 icon_vframe = gui->audio_vframe;
1018 icon = gui->audio_icon;
1019 icon_vframe = gui->audio_vframe;
1024 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
1027 if( indexable && !indexable->is_asset ) {
1028 icon = gui->video_icon;
1029 icon_vframe = gui->video_vframe;
1033 if( edl->tracks->playable_video_tracks() ) {
1034 if( mwindow->preferences->use_thumbnails ) {
1035 gui->unlock_window();
1036 AssetVIconThread *avt = gui->vicon_thread;
1037 char clip_icon_path[BCTEXTLEN];
1038 char *clip_icon = edl->local_session->clip_icon;
1040 if( clip_icon[0] ) {
1041 snprintf(clip_icon_path, sizeof(clip_icon_path),
1042 "%s/%s", File::get_config_path(), clip_icon);
1043 vframe = VFramePng::vframe_png(clip_icon_path);
1046 ( vframe->get_w() != avt->vw || vframe->get_h() != avt->vh ) ) {
1047 delete vframe; vframe = 0;
1049 int edl_h = edl->get_h(), edl_w = edl->get_w();
1050 int height = edl_h > 0 ? edl_h : 1;
1051 int width = edl_w > 0 ? edl_w : 1;
1052 int color_model = edl->session->color_model;
1054 //printf("render clip: %s\n", name);
1055 VFrame::get_temp(gui->temp_picon, width, height, color_model);
1056 char string[BCTEXTLEN];
1057 sprintf(string, _("Rendering %s"), name);
1058 mwindow->gui->lock_window("AssetPicon::create_objects");
1059 mwindow->gui->show_message(string);
1060 mwindow->gui->unlock_window();
1061 open_render_engine(edl, 0);
1062 render_video(0, gui->temp_picon);
1063 close_render_engine();
1064 vframe = new VFrame(avt->vw, avt->vh, BC_RGB888);
1065 vframe->transfer_from(gui->temp_picon);
1067 vframe->write_png(clip_icon_path);
1069 pixmap_w = pixmap_h * width / height;
1070 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, VICON_RATE, 1);
1071 vicon->add_image(vframe, avt->vw, avt->vh, avt->vicon_cmodel);
1072 icon_vframe = new VFrame(pixmap_w, pixmap_h, BC_RGB888);
1073 icon_vframe->transfer_from(vframe);
1075 gui->lock_window("AssetPicon::create_objects 0");
1076 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1077 icon->draw_vframe(icon_vframe,
1078 0, 0, pixmap_w, pixmap_h, 0, 0);
1081 icon = gui->clip_icon;
1082 icon_vframe = gui->clip_vframe;
1086 if( edl->tracks->playable_audio_tracks() ) {
1087 if( mwindow->preferences->use_thumbnails ) {
1088 gui->unlock_window();
1089 char clip_icon_path[BCTEXTLEN];
1090 char *clip_icon = edl->local_session->clip_icon;
1091 if( clip_icon[0] ) {
1092 snprintf(clip_icon_path, sizeof(clip_icon_path),
1093 "%s/%s", File::get_config_path(), clip_icon);
1094 icon_vframe = VFramePng::vframe_png(clip_icon_path);
1096 if( !icon_vframe ) {
1097 pixmap_w = pixmap_h * 16/9;
1098 icon_vframe = new VFrame(0,
1099 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
1100 icon_vframe->clear_frame();
1101 char string[BCTEXTLEN];
1102 sprintf(string, _("Rendering %s"), name);
1103 mwindow->gui->lock_window("AssetPicon::create_objects 3");
1104 mwindow->gui->show_message(string);
1105 mwindow->gui->unlock_window();
1106 int sample_rate = edl->get_sample_rate();
1107 int channels = edl->get_audio_channels();
1108 if( channels > 2 ) channels = 2;
1109 int64_t audio_samples = edl->get_audio_samples();
1110 double duration = (double)audio_samples / sample_rate;
1111 draw_hue_bar(icon_vframe, duration);
1112 Samples *samples[MAX_CHANNELS];
1113 int bfrsz = sample_rate;
1114 for( int i=0; i<MAX_CHANNELS; ++i )
1115 samples[i] = i<channels ? new Samples(bfrsz) : 0;
1116 open_render_engine(edl, 1);
1117 render_audio(0, samples, bfrsz);
1118 close_render_engine();
1119 gui->lock_window("AssetPicon::create_objects 4");
1120 static int line_colors[2] = { GREEN, YELLOW };
1121 static int base_colors[2] = { RED, PINK };
1122 for( int i=channels; --i>=0; ) {
1123 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
1124 base_colors[i], line_colors[i]);
1126 for( int i=0; i<channels; ++i ) delete samples[i];
1127 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
1130 pixmap_w = icon_vframe->get_w();
1131 pixmap_h = icon_vframe->get_h();
1133 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
1134 icon->draw_vframe(icon_vframe,
1135 0, 0, pixmap_w, pixmap_h, 0, 0);
1138 icon = gui->clip_icon;
1139 icon_vframe = gui->clip_vframe;
1145 strcpy(name, _(plugin->title));
1147 icon_vframe = plugin->get_picon();
1149 icon = gui->create_pixmap(icon_vframe);
1150 else if( plugin->audio ) {
1151 if( plugin->transition ) {
1152 icon = gui->atransition_icon;
1153 icon_vframe = gui->atransition_vframe;
1155 else if( plugin->is_ffmpeg() ) {
1156 icon = gui->ff_aud_icon;
1157 icon_vframe = gui->ff_aud_vframe;
1159 else if( plugin->is_ladspa() ) {
1160 icon = gui->ladspa_icon;
1161 icon_vframe = gui->ladspa_vframe;
1164 icon = gui->aeffect_icon;
1165 icon_vframe = gui->aeffect_vframe;
1168 else if( plugin->video ) {
1169 if( plugin->transition ) {
1170 icon = gui->vtransition_icon;
1171 icon_vframe = gui->vtransition_vframe;
1173 else if( plugin->is_ffmpeg() ) {
1174 icon = gui->ff_vid_icon;
1175 icon_vframe = gui->ff_vid_vframe;
1178 icon = gui->veffect_icon;
1179 icon_vframe = gui->veffect_vframe;
1187 mwindow->edl->session->time_format,
1188 mwindow->edl->session->sample_rate,
1189 mwindow->edl->session->frame_rate,
1190 mwindow->edl->session->frames_per_foot);
1192 icon = gui->label_icon;
1193 icon_vframe = gui->label_vframe;
1196 icon = gui->file_icon;
1197 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1200 set_icon_vframe(icon_vframe);
1203 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1204 : BC_Window(_(PROGRAM_NAME ": Resources"),
1205 mwindow->session->awindow_x, mwindow->session->awindow_y,
1206 mwindow->session->awindow_w, mwindow->session->awindow_h,
1209 this->mwindow = mwindow;
1210 this->awindow = awindow;
1212 file_vframe = 0; file_icon = 0;
1213 folder_vframe = 0; folder_icon = 0;
1214 audio_vframe = 0; audio_icon = 0;
1215 video_vframe = 0; video_icon = 0;
1216 label_vframe = 0; label_icon = 0;
1218 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1219 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1220 clip_folder_vframe = 0; clip_folder_icon = 0;
1221 label_folder_vframe = 0; label_folder_icon = 0;
1222 media_folder_vframe = 0; media_folder_icon = 0;
1223 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1224 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1225 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1227 ladspa_vframe = 0; ladspa_icon = 0;
1228 ff_aud_vframe = 0; ff_aud_icon = 0;
1229 ff_vid_vframe = 0; ff_vid_icon = 0;
1231 clip_vframe = 0; clip_icon = 0;
1232 atransition_vframe = 0; atransition_icon = 0;
1233 vtransition_vframe = 0; vtransition_icon = 0;
1234 aeffect_vframe = 0; aeffect_icon = 0;
1235 veffect_vframe = 0; veffect_icon = 0;
1237 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1239 effectlist_menu = 0;
1244 folderlist_menu = 0;
1247 allow_iconlisting = 1;
1252 displayed_folder = AW_NO_FOLDER;
1253 new_folder_thread = 0;
1254 modify_folder_thread = 0;
1255 folder_lock = new Mutex("AWindowGUI::folder_lock");
1258 AWindowGUI::~AWindowGUI()
1260 assets.remove_all_objects();
1261 folders.remove_all_objects();
1262 aeffects.remove_all_objects();
1263 veffects.remove_all_objects();
1264 atransitions.remove_all_objects();
1265 vtransitions.remove_all_objects();
1266 labellist.remove_all_objects();
1267 displayed_assets[1].remove_all_objects();
1269 delete new_folder_thread;
1270 delete modify_folder_thread;
1271 delete vicon_thread;
1276 delete remove_plugin;
1278 delete file_vframe; delete file_icon;
1279 delete folder_vframe; delete folder_icon;
1280 delete audio_vframe; delete audio_icon;
1281 delete video_vframe; delete video_icon;
1282 delete label_vframe; delete label_icon;
1283 delete clip_vframe; delete clip_icon;
1284 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1285 delete atransition_folder_vframe; delete atransition_folder_icon;
1286 delete veffect_folder_vframe; delete veffect_folder_icon;
1287 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1288 delete clip_folder_vframe; delete clip_folder_icon;
1289 delete label_folder_vframe; delete label_folder_icon;
1290 delete media_folder_vframe; delete media_folder_icon;
1291 delete proxy_folder_vframe; delete proxy_folder_icon;
1292 delete ladspa_vframe; delete ladspa_icon;
1293 delete ff_aud_vframe; delete ff_aud_icon;
1294 delete ff_vid_vframe; delete ff_vid_icon;
1295 delete atransition_vframe; delete atransition_icon;
1296 delete vtransition_vframe; delete vtransition_icon;
1297 delete aeffect_vframe; delete aeffect_icon;
1298 delete veffect_vframe; delete veffect_icon;
1302 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1304 return icon == file_icon ||
1305 icon == folder_icon ||
1306 icon == audio_icon ||
1307 icon == video_icon ||
1308 icon == clip_icon ||
1309 icon == label_icon ||
1310 icon == vtransition_icon ||
1311 icon == atransition_icon ||
1312 icon == veffect_icon ||
1313 icon == aeffect_icon ||
1314 icon == ladspa_icon ||
1315 icon == ff_aud_icon ||
1316 icon == ff_vid_icon ||
1317 icon == aeffect_folder_icon ||
1318 icon == veffect_folder_icon ||
1319 icon == atransition_folder_icon ||
1320 icon == vtransition_folder_icon ||
1321 icon == label_folder_icon ||
1322 icon == clip_folder_icon ||
1323 icon == media_folder_icon ||
1324 icon == proxy_folder_icon;
1327 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1329 char png_path[BCTEXTLEN];
1330 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1331 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1332 File::get_plugin_path(), plugin_icons, name);
1333 if( access(png_path, R_OK) ) return 0;
1334 return VFramePng::vframe_png(png_path,0,0);
1337 VFrame *AWindowGUI::get_picon(const char *name)
1339 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1341 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1342 snprintf(pp, ep-pp, "%s.png", name);
1343 unsigned char *data = mwindow->theme->get_image_data(png_name);
1344 if( data ) vframe = new VFramePng(data, 0.);
1349 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1351 vfrm = get_picon(fn);
1352 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1353 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1355 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1357 vfrm = get_picon(fn);
1358 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1359 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1361 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1363 vfrm = get_picon(fn);
1364 if( !vfrm ) vfrm = new VFramePng(png);
1365 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1368 void AWindowGUI::create_objects()
1370 lock_window("AWindowGUI::create_objects");
1371 asset_titles[0] = C_("Title");
1372 asset_titles[1] = _("Comments");
1374 set_icon(mwindow->theme->get_image("awindow_icon"));
1376 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1377 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1378 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1379 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1380 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1382 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1383 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1384 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1385 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1386 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1387 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1388 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1389 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1391 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1392 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1393 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1394 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1395 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1396 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1397 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1398 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1400 theme_icon(clip_vframe, clip_icon, "clip_icon");
1401 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1402 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1403 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1404 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1406 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1407 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1408 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1409 folder_lock->lock("AWindowGUI::create_objects");
1410 // Mandatory folders
1411 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1412 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1413 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1414 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1415 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1416 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1417 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1418 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1420 create_label_folder();
1421 folder_lock->unlock();
1423 mwindow->theme->get_awindow_sizes(this);
1424 load_defaults(mwindow->defaults);
1425 new_folder_thread = new NewFolderThread(this);
1426 modify_folder_thread = new ModifyFolderThread(this);
1428 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1429 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1430 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1431 search_text->create_objects();
1432 int dy = search_text->get_h() + 10;
1434 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1436 vicon_thread = new AssetVIconThread(this, mwindow->preferences);
1437 asset_list->update_vicon_area();
1438 vicon_thread->start();
1439 vicon_audio = new AssetVIconAudio(this);
1441 add_subwindow(divider = new AWindowDivider(mwindow, this,
1442 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1443 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1445 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1447 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1448 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1449 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1450 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1451 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1452 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1453 add_tools->create_objects();
1454 fy += add_tools->get_h(); fh -= add_tools->get_h();
1455 add_subwindow(folder_list = new AWindowFolders(mwindow,
1456 this, fx, fy, fw, fh));
1458 folder_list->load_expanders();
1460 //int x = mwindow->theme->abuttons_x;
1461 //int y = mwindow->theme->abuttons_y;
1463 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1464 asset_menu->create_objects();
1465 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1466 clip_menu->create_objects();
1467 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1468 label_menu->create_objects();
1469 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1470 proxy_menu->create_objects();
1472 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1473 effectlist_menu->create_objects();
1474 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1475 assetlist_menu->create_objects();
1476 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1477 cliplist_menu->create_objects();
1478 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1479 labellist_menu->create_objects();
1480 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1481 proxylist_menu->create_objects();
1483 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1484 folderlist_menu->create_objects();
1486 create_custom_xatoms();
1490 int AWindowGUI::resize_event(int w, int h)
1492 mwindow->session->awindow_x = get_x();
1493 mwindow->session->awindow_y = get_y();
1494 mwindow->session->awindow_w = w;
1495 mwindow->session->awindow_h = h;
1497 mwindow->theme->get_awindow_sizes(this);
1498 mwindow->theme->draw_awindow_bg(this);
1499 reposition_objects();
1501 // int x = mwindow->theme->abuttons_x;
1502 // int y = mwindow->theme->abuttons_y;
1503 // new_bin->reposition_window(x, y);
1504 // x += new_bin->get_w();
1505 // delete_bin->reposition_window(x, y);
1506 // x += delete_bin->get_w();
1507 // rename_bin->reposition_window(x, y);
1508 // x += rename_bin->get_w();
1509 // delete_disk->reposition_window(x, y);
1510 // x += delete_disk->get_w();
1511 // delete_project->reposition_window(x, y);
1512 // x += delete_project->get_w();
1513 // info->reposition_window(x, y);
1514 // x += info->get_w();
1515 // redraw_index->reposition_window(x, y);
1516 // x += redraw_index->get_w();
1517 // paste->reposition_window(x, y);
1518 // x += paste->get_w();
1519 // append->reposition_window(x, y);
1520 // x += append->get_w();
1521 // view->reposition_window(x, y);
1523 BC_WindowBase::resize_event(w, h);
1524 asset_list->update_vicon_area();
1528 int AWindowGUI::translation_event()
1530 mwindow->session->awindow_x = get_x();
1531 mwindow->session->awindow_y = get_y();
1535 void AWindowGUI::reposition_objects()
1537 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1538 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1539 search_text->reposition_window(x1, y1+5, w1);
1540 int dy = search_text->get_h() + 10;
1542 asset_list->reposition_window(x1, y1, w1, h1);
1543 divider->reposition_window(
1544 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1545 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1546 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1547 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1548 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1549 avicon_drawing->reposition_window(fw-avicon_w, fy);
1550 fy += add_tools->get_h(); fh -= add_tools->get_h();
1551 folder_list->reposition_window(fx, fy, fw, fh);
1554 int AWindowGUI::save_defaults(BC_Hash *defaults)
1556 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1557 defaults->update("VICON_DRAWING", vicon_drawing);
1561 int AWindowGUI::load_defaults(BC_Hash *defaults)
1563 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1564 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1568 int AWindowGUI::close_event()
1571 mwindow->session->show_awindow = 0;
1574 mwindow->gui->lock_window("AWindowGUI::close_event");
1575 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1576 mwindow->gui->unlock_window();
1578 lock_window("AWindowGUI::close_event");
1579 save_defaults(mwindow->defaults);
1580 mwindow->save_defaults();
1584 void AWindowGUI::start_vicon_drawing()
1586 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1587 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1588 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1589 mwindow->edl->session->awindow_folder == AW_CLIP_FOLDER ||
1590 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1591 switch( mwindow->edl->session->assetlist_format ) {
1593 case ASSETS_ICONS_PACKED:
1594 case ASSETS_ICON_LIST:
1595 asset_list->update_vicon_area();
1596 vicon_thread->start_drawing();
1604 void AWindowGUI::stop_vicon_drawing()
1606 if( vicon_thread->interrupted ) return;
1607 vicon_thread->stop_drawing();
1610 void AWindowGUI::close_view_popup()
1612 vicon_thread->close_view_popup();
1615 VFrame *AssetPicon::get_vicon_frame()
1617 if( !vicon ) return 0;
1618 if( gui->vicon_thread->interrupted ) return 0;
1619 VFrame *frame = vicon->frame();
1620 if( !frame ) return 0;
1622 vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model());
1623 vicon_frame->transfer_from(frame);
1627 int AWindowGUI::cycle_assetlist_format()
1629 EDLSession *session = mwindow->edl->session;
1630 int format = ASSETS_TEXT;
1631 if( allow_iconlisting ) {
1632 switch( session->assetlist_format ) {
1634 format = ASSETS_ICONS;
1637 format = ASSETS_ICONS_PACKED;
1639 case ASSETS_ICONS_PACKED:
1640 format = ASSETS_ICON_LIST;
1642 case ASSETS_ICON_LIST:
1643 format = ASSETS_TEXT;
1647 stop_vicon_drawing();
1648 session->assetlist_format = format;
1649 asset_list->update_format(session->assetlist_format, 0);
1650 async_update_assets();
1651 start_vicon_drawing();
1655 AWindowRemovePluginGUI::
1656 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1657 int x, int y, PluginServer *plugin)
1658 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1660 this->awindow = awindow;
1661 this->thread = thread;
1662 this->plugin = plugin;
1663 VFrame *vframe = plugin->get_picon();
1664 icon = vframe ? create_pixmap(vframe) : 0;
1665 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1668 AWindowRemovePluginGUI::
1669 ~AWindowRemovePluginGUI()
1671 if( !awindow->gui->protected_pixmap(icon) )
1673 plugin_list.remove_all();
1676 void AWindowRemovePluginGUI::create_objects()
1678 lock_window("AWindowRemovePluginGUI::create_objects");
1679 BC_Button *ok_button = new BC_OKButton(this);
1680 add_subwindow(ok_button);
1681 BC_Button *cancel_button = new BC_CancelButton(this);
1682 add_subwindow(cancel_button);
1684 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1685 add_subwindow(title);
1686 y += title->get_h() + 5;
1687 list = new BC_ListBox(x, y,
1688 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1689 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1690 add_subwindow(list);
1695 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1698 for( int i=0; i<folder.size(); ) {
1699 AssetPicon *picon = (AssetPicon *)folder[i];
1700 if( picon->plugin == plugin ) {
1701 folder.remove_object_number(i);
1710 void AWindowRemovePlugin::handle_close_event(int result)
1713 printf(_("remove %s\n"), plugin->path);
1714 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1715 ArrayList<BC_ListBoxItem*> *folder =
1716 plugin->audio ? plugin->transition ?
1717 &awindow->gui->atransitions :
1718 &awindow->gui->aeffects :
1719 plugin->video ? plugin->transition ?
1720 &awindow->gui->vtransitions :
1721 &awindow->gui->veffects :
1723 if( folder ) remove_plugin(plugin, *folder);
1724 MWindow *mwindow = awindow->mwindow;
1725 awindow->gui->unlock_window();
1726 char plugin_path[BCTEXTLEN];
1727 strcpy(plugin_path, plugin->path);
1728 mwindow->plugindb->remove(plugin);
1729 remove(plugin_path);
1730 char index_path[BCTEXTLEN];
1731 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1733 char picon_path[BCTEXTLEN];
1735 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1736 File::get_plugin_path());
1737 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1738 plugin->get_plugin_png_name(png_name);
1739 fs.update(picon_path);
1740 for( int i=0; i<fs.dir_list.total; ++i ) {
1741 char *fs_path = fs.dir_list[i]->path;
1742 if( !fs.is_dir(fs_path) ) continue;
1743 snprintf(png_path, sizeof(picon_path), "%s/%s",
1747 delete plugin; plugin = 0;
1748 awindow->gui->async_update_assets();
1752 AWindowRemovePlugin::
1753 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1756 this->awindow = awindow;
1757 this->plugin = plugin;
1760 AWindowRemovePlugin::
1761 ~AWindowRemovePlugin()
1766 BC_Window* AWindowRemovePlugin::new_gui()
1768 int x = awindow->gui->get_abs_cursor_x(0);
1769 int y = awindow->gui->get_abs_cursor_y(0);
1770 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1771 gui->create_objects();
1775 int AWindowGUI::keypress_event()
1777 switch( get_keypress() ) {
1785 if( !ctrl_down() && !shift_down() ) {
1786 assetlist_menu->load_file->handle_event();
1791 return cycle_assetlist_format();
1793 if( shift_down() && ctrl_down() ) {
1794 PluginServer* plugin = selected_plugin();
1795 if( !plugin ) break;
1796 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1798 remove_plugin->start();
1799 lock_window("AWindowGUI::keypress_event 1");
1803 if( shift_down() ) {
1804 mwindow->awindow->asset_remove->start();
1808 mwindow->remove_assets_from_project(1, 1,
1809 mwindow->session->drag_assets,
1810 mwindow->session->drag_clips);
1811 lock_window("AWindowGUI::keypress_event 2");
1817 if( shift_down() && ctrl_down() ) {
1818 resend_event(mwindow->gui);
1828 int AWindowGUI::create_custom_xatoms()
1830 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1833 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1835 if( event->message_type == UpdateAssetsXAtom ) {
1842 void AWindowGUI::async_update_assets()
1845 event.message_type = UpdateAssetsXAtom;
1846 send_custom_xatom(&event);
1850 void AWindowGUI::update_folder_list()
1852 for( int i = 0; i < folders.total; i++ ) {
1853 AssetPicon *picon = (AssetPicon*)folders.values[i];
1857 // Search assets for folders
1858 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1859 BinFolder *bin_folder = mwindow->edl->folders[i];
1862 for( int j = 0; j < folders.total; j++ ) {
1863 AssetPicon *picon = (AssetPicon*)folders[j];
1864 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1872 const char *title = bin_folder->title;
1873 int folder = bin_folder->awindow_folder;
1874 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1875 picon->create_objects();
1876 folders.append(picon);
1880 // Delete unused non-persistent folders
1881 int do_autoplace = 0;
1882 for( int i=folders.total; --i>=0; ) {
1883 AssetPicon *picon = (AssetPicon*)folders.values[i];
1884 if( !picon->in_use && !picon->persistent ) {
1886 folders.remove_number(i);
1891 folder_list->set_autoplacement(&folders, 0, 1);
1894 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1895 int do_audio, int do_video, int is_realtime, int is_transition)
1897 ArrayList<PluginServer*> plugin_list;
1898 // Get pointers to plugindb entries
1899 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1902 for( int i = 0; i < plugin_list.total; i++ ) {
1903 PluginServer *server = plugin_list.values[i];
1904 int visible = plugin_visibility & (1<<server->dir_idx);
1905 if( !visible ) continue;
1906 // Create new listitem
1907 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1908 picon->create_objects();
1909 output->append(picon);
1913 void AWindowGUI::create_label_folder()
1916 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1917 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1918 picon->create_objects();
1919 labellist.append(picon);
1924 void AWindowGUI::update_asset_list()
1926 ArrayList<AssetPicon *> new_assets;
1927 for( int i = 0; i < assets.total; i++ ) {
1928 AssetPicon *picon = (AssetPicon*)assets.values[i];
1932 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1933 // Synchronize EDL clips
1934 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1937 // Look for clip in existing listitems
1938 for( int j = 0; j < assets.total && !exists; j++ ) {
1939 AssetPicon *picon = (AssetPicon*)assets.values[j];
1941 if( picon->id == mwindow->edl->clips[i]->id ) {
1942 picon->edl = mwindow->edl->clips[i];
1943 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1949 // Create new listitem
1951 AssetPicon *picon = new AssetPicon(mwindow,
1952 this, mwindow->edl->clips[i]);
1953 new_assets.append(picon);
1957 // Synchronize EDL assets
1958 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1961 // Look for asset in existing listitems
1962 for( int j = 0; j < assets.total && !exists; j++ ) {
1963 AssetPicon *picon = (AssetPicon*)assets.values[j];
1965 if( picon->id == current->id ) {
1966 picon->indexable = current;
1972 // Create new listitem
1974 AssetPicon *picon = new AssetPicon(mwindow,
1976 new_assets.append(picon);
1980 // Synchronize nested EDLs
1981 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1983 EDL *nested_edl = mwindow->edl->nested_edls[i];
1985 // Look for asset in existing listitems
1986 for( int j=0; j<assets.total && !exists; ++j ) {
1987 AssetPicon *picon = (AssetPicon*)assets.values[j];
1989 if( picon->id == nested_edl->id ) {
1990 picon->indexable = nested_edl;
1996 // Create new listitem
1998 AssetPicon *picon = new AssetPicon(mwindow,
1999 this, (Indexable*)nested_edl);
2000 new_assets.append(picon);
2003 mwindow->gui->unlock_window();
2005 for( int i=0; i<new_assets.size(); ++i ) {
2006 AssetPicon *picon = new_assets[i];
2007 picon->create_objects();
2008 if( picon->indexable )
2009 picon->foldernum = AW_MEDIA_FOLDER;
2010 else if( picon->edl )
2011 picon->foldernum = AW_CLIP_FOLDER;
2012 assets.append(picon);
2015 mwindow->gui->lock_window();
2016 mwindow->gui->default_message();
2017 mwindow->gui->unlock_window();
2019 for( int i = assets.size() - 1; i >= 0; i-- ) {
2020 AssetPicon *picon = (AssetPicon*)assets.get(i);
2021 if( !picon->in_use ) {
2023 assets.remove_number(i);
2026 if( picon->indexable && picon->indexable->is_asset ) {
2028 picon->comments_time = !stat(picon->indexable->path, &st) ?
2034 void AWindowGUI::update_picon(Indexable *indexable)
2037 for( int i = 0; i < assets.total; i++ ) {
2038 AssetPicon *picon = (AssetPicon*)assets.values[i];
2039 if( picon->indexable == indexable ||
2040 picon->edl == (EDL *)indexable ) {
2041 char name[BCTEXTLEN];
2043 fs.extract_name(name, indexable->path);
2044 picon->set_text(name);
2045 vicon = picon->vicon;
2050 stop_vicon_drawing();
2051 vicon->clear_images();
2052 vicon->reset(indexable->get_frame_rate());
2053 start_vicon_drawing();
2057 void AWindowGUI::sort_assets()
2059 folder_lock->lock("AWindowGUI::sort_assets");
2060 switch( mwindow->edl->session->awindow_folder ) {
2061 case AW_AEFFECT_FOLDER:
2062 sort_picons(&aeffects);
2064 case AW_VEFFECT_FOLDER:
2065 sort_picons(&veffects);
2067 case AW_ATRANSITION_FOLDER:
2068 sort_picons(&atransitions);
2070 case AW_VTRANSITION_FOLDER:
2071 sort_picons(&vtransitions);
2073 case AW_LABEL_FOLDER:
2074 sort_picons(&labellist);
2077 sort_picons(&assets);
2081 asset_list->update_format(asset_list->get_format(), 0);
2082 folder_lock->unlock();
2086 void AWindowGUI::sort_folders()
2088 folder_lock->lock("AWindowGUI::update_assets");
2089 // folder_list->collapse_recursive(&folders, 0);
2090 folder_list->set_autoplacement(&folders, 0, 1);
2091 sort_picons(&folders);
2092 folder_list->update_format(folder_list->get_format(), 0);
2093 folder_lock->unlock();
2097 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
2099 Asset *proxy_asset = (Asset *)indexable;
2100 char path[BCTEXTLEN];
2101 int proxy_scale = mwindow->edl->session->proxy_scale;
2102 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
2103 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
2104 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
2105 // make a clip from proxy video tracks and unproxy audio tracks
2106 EDL *proxy_edl = new EDL(mwindow->edl);
2107 proxy_edl->create_objects();
2108 proxy_edl->set_path(proxy_asset->path);
2109 FileSystem fs; fs.extract_name(path, proxy_asset->path);
2110 strcpy(proxy_edl->local_session->clip_title, path);
2111 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
2112 proxy_edl->session->video_tracks = proxy_asset->layers;
2113 proxy_edl->session->audio_tracks = unproxy_asset->channels;
2114 proxy_edl->create_default_tracks();
2115 double length = proxy_asset->frame_rate > 0 ?
2116 ( proxy_asset->video_length >= 0 ?
2117 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
2118 ( proxy_edl->session->si_useduration ?
2119 proxy_edl->session->si_duration :
2120 1.0 / proxy_asset->frame_rate ) ) :
2121 1.0 / proxy_edl->session->frame_rate;
2122 Track *current = proxy_edl->tracks->first;
2123 for( int vtrack=0; current; current=NEXT ) {
2124 if( current->data_type != TRACK_VIDEO ) continue;
2125 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
2127 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
2128 current = proxy_edl->tracks->first;
2129 for( int atrack=0; current; current=NEXT ) {
2130 if( current->data_type != TRACK_AUDIO ) continue;
2131 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
2133 proxy_edl->folder_no = AW_PROXY_FOLDER;
2138 void AWindowGUI::collect_assets(int proxy)
2140 mwindow->session->drag_assets->remove_all();
2141 mwindow->session->drag_clips->remove_all();
2142 int i = 0; AssetPicon *result;
2143 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
2144 Indexable *indexable = result->indexable;
2145 if( proxy && indexable && indexable->is_asset &&
2146 indexable->folder_no == AW_PROXY_FOLDER ) {
2147 EDL *drag_edl = collect_proxy(indexable);
2148 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
2152 mwindow->session->drag_assets->append(indexable);
2156 mwindow->session->drag_clips->append(result->edl);
2162 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
2164 // Remove current pointers
2165 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
2166 dst[0].remove_all();
2167 dst[1].remove_all_objects();
2169 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
2170 int folder = mwindow->edl->session->awindow_folder;
2171 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
2172 mwindow->edl->get_folder(folder);
2174 // Create new pointers
2175 for( int i = 0; i < src->total; i++ ) {
2176 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2177 picon = (AssetPicon*)src->values[i];
2178 picon->sort_key = -1;
2179 if( !visible && bin_folder ) {
2180 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2181 picon->indexable ? picon->indexable :
2182 picon->edl ? picon->edl->get_proxy_asset() : 0;
2184 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2185 if( picon->sort_key < 0 ) continue;
2189 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2191 if( !visible && picon->edl && picon->edl->folder_no == folder )
2193 if( visible && sub_items ) {
2194 if( !sub_items->matches(picon->get_text()) )
2198 const char *text = search_text->get_text();
2199 if( text && text[0] )
2200 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2202 if( visible && picon->vicon && picon->vicon->hidden )
2203 picon->vicon->hidden = 0;
2205 BC_ListBoxItem *item2, *item1;
2206 dst[0].append(item1 = picon);
2208 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2211 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2212 else if( picon->comments_time ) {
2213 char date_time[BCSTRLEN];
2214 struct tm stm; localtime_r(&picon->comments_time, &stm);
2215 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2216 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2217 stm.tm_hour, stm.tm_min, stm.tm_sec);
2218 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2221 dst[1].append(item2 = new BC_ListBoxItem(""));
2222 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2223 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2228 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2230 int done = 0, changed = 0;
2233 for( int i=0; i<src->total-1; ++i ) {
2234 AssetPicon *item1 = (AssetPicon *)src->values[i];
2235 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2236 double v = item2->sort_key - item1->sort_key;
2237 if( v > 0 ) continue;
2239 const char *cp1 = item1->get_text();
2240 const char *bp1 = strrchr(cp1, '/');
2241 if( bp1 ) cp1 = bp1 + 1;
2242 const char *cp2 = item2->get_text();
2243 const char *bp2 = strrchr(cp2, '/');
2244 if( bp2 ) cp2 = bp2 + 1;
2245 if( strcmp(cp2, cp1) >= 0 ) continue;
2247 src->values[i + 1] = item1;
2248 src->values[i] = item2;
2249 done = 0; changed = 1;
2253 for( int i=0; i<src->total; ++i ) {
2254 AssetPicon *item = (AssetPicon *)src->values[i];
2255 item->set_autoplace_icon(1);
2256 item->set_autoplace_text(1);
2261 void AWindowGUI::filter_displayed_assets()
2263 //allow_iconlisting = 1;
2264 asset_titles[0] = C_("Title");
2265 asset_titles[1] = _("Comments");
2266 AssetPicon *picon = 0;
2267 int selected_folder = mwindow->edl->session->awindow_folder;
2268 // Ensure the current folder icon is highlighted
2269 for( int i = 0; i < folders.total; i++ ) {
2270 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2271 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2272 folder_item->set_selected(selected);
2273 if( selected ) picon = folder_item;
2276 ArrayList<BC_ListBoxItem*> *src = &assets;
2277 switch( selected_folder ) {
2278 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2279 case AW_VEFFECT_FOLDER: src = &veffects; break;
2280 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2281 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2282 case AW_LABEL_FOLDER: src = &labellist;
2283 asset_titles[0] = _("Time Stamps");
2284 asset_titles[1] = C_("Title");
2285 //allow_iconlisting = 0;
2288 copy_picons(picon, src);
2292 void AWindowGUI::update_assets()
2294 stop_vicon_drawing();
2295 folder_lock->lock("AWindowGUI::update_assets");
2296 update_folder_list();
2297 update_asset_list();
2298 labellist.remove_all_objects();
2299 create_label_folder();
2301 if( displayed_folder != mwindow->edl->session->awindow_folder )
2302 search_text->clear();
2303 vicon_thread->hide_vicons();
2304 filter_displayed_assets();
2305 folder_lock->unlock();
2307 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2308 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2310 int folder_xposition = folder_list->get_xposition();
2311 int folder_yposition = folder_list->get_yposition();
2312 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2314 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2315 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2317 int asset_xposition = asset_list->get_xposition();
2318 int asset_yposition = asset_list->get_yposition();
2319 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2320 displayed_folder = mwindow->edl->session->awindow_folder;
2321 asset_xposition = asset_yposition = 0;
2323 asset_list->update(displayed_assets, asset_titles,
2324 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2325 asset_xposition, asset_yposition, -1, 0);
2326 asset_list->center_selection();
2329 start_vicon_drawing();
2333 void AWindowGUI::update_effects()
2335 aeffects.remove_all_objects();
2336 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2337 veffects.remove_all_objects();
2338 create_persistent_folder(&veffects, 0, 1, 1, 0);
2339 atransitions.remove_all_objects();
2340 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2341 vtransitions.remove_all_objects();
2342 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2345 int AWindowGUI::drag_motion()
2347 if( get_hidden() ) return 0;
2353 int AWindowGUI::drag_stop()
2355 if( get_hidden() ) return 0;
2359 Indexable* AWindowGUI::selected_asset()
2361 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2362 return picon ? picon->indexable : 0;
2365 PluginServer* AWindowGUI::selected_plugin()
2367 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2368 return picon ? picon->plugin : 0;
2371 AssetPicon* AWindowGUI::selected_folder()
2373 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2384 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2385 : BC_SubWindow(x, y, w, h)
2387 this->mwindow = mwindow;
2390 AWindowDivider::~AWindowDivider()
2394 int AWindowDivider::button_press_event()
2396 if( is_event_win() && cursor_inside() ) {
2397 mwindow->session->current_operation = DRAG_PARTITION;
2403 int AWindowDivider::cursor_motion_event()
2405 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2407 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2408 int fw = gui->get_relative_cursor_x();
2409 if( fw > wmax ) fw = wmax;
2410 if( fw < wmin ) fw = wmin;
2411 mwindow->session->afolders_w = fw;
2412 mwindow->theme->get_awindow_sizes(gui);
2413 gui->reposition_objects();
2419 int AWindowDivider::button_release_event()
2421 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2422 mwindow->session->current_operation = NO_OPERATION;
2433 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2434 : BC_ListBox(x, y, w, h,
2435 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2436 LISTBOX_ICONS : LISTBOX_TEXT,
2437 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2438 0, // Titles for columns. Set to 0 for no titles
2439 0, // width of each column
2440 1, // Total columns.
2441 0, // Pixel of top of window.
2442 0, // If this listbox is a popup window
2443 LISTBOX_SINGLE, // Select one item or multiple items
2444 ICON_TOP, // Position of icon relative to text of each item
2447 this->mwindow = mwindow;
2454 AWindowFolders::~AWindowFolders()
2458 int AWindowFolders::selection_changed()
2460 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2461 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2462 // prefer expanded entry
2463 AWindowFolderItem *item = item1 ? item1 : item0;
2464 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2465 item1->set_selected(0);
2472 AssetPicon *picon = item->get_picon();
2473 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2475 gui->stop_vicon_drawing();
2477 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON ) {
2478 gui->folderlist_menu->update_titles();
2479 gui->folderlist_menu->activate_menu();
2482 mwindow->edl->session->awindow_folder = picon->foldernum;
2483 gui->asset_list->draw_background();
2484 gui->async_update_assets();
2486 gui->start_vicon_drawing();
2491 int AWindowFolders::button_press_event()
2493 int result = BC_ListBox::button_press_event();
2496 if( get_buttonpress() == RIGHT_BUTTON &&
2497 is_event_win() && cursor_inside() ) {
2498 gui->folderlist_menu->update_titles();
2499 gui->folderlist_menu->activate_menu();
2507 int AWindowFolders::drag_stop()
2510 if( get_hidden() ) return 0;
2511 if( mwindow->session->current_operation == DRAG_ASSET &&
2512 gui->folder_list->cursor_above() ) { // check user folder
2513 int item_no = gui->folder_list->get_cursor_data_item_no();
2514 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2515 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2516 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2517 ArrayList<Indexable *> *drags = folder->is_clips ?
2518 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2519 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2520 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2522 mwindow->session->current_operation = ::NO_OPERATION;
2529 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2530 : AWindowFolderItem(text)
2532 this->parent = parent;
2535 int AWindowFolders::load_expanders()
2537 char expanders_path[BCTEXTLEN];
2538 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2539 FILE *fp = fopen(expanders_path, "r");
2541 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2542 File::get_cindat_path(), EXPANDERS_FILE);
2543 fp = fopen(expanders_path, "r");
2547 const char tab = '\t';
2548 char line[BCTEXTLEN]; line[0] = 0;
2549 AWindowFolderItem *item = 0, *parent;
2550 AWindowFolderSubItems *sub_items = 0;
2552 while( fgets(line,sizeof(line),fp) ) {
2553 if( line[0] == '#' ) continue;
2554 int i = strlen(line);
2555 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2556 if( i == 0 ) continue;
2558 for( char *cp=line; *cp==tab; ++cp ) ++i;
2560 int i = gui->folders.size();
2562 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2563 if( !strcmp(folder->get_text(),_(line)) ) break;
2565 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2570 if( i > k+1 ) continue;
2572 if( line[i] != '-' && sub_items ) {
2573 sub_items->names.append(cstrdup(_(&line[i])));
2581 item = item->parent;
2584 parent = item->parent;
2586 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2587 if( !sublist ) sublist = parent->new_sublist(1);
2588 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2589 sublist->append(item = sub_items);
2596 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2597 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2598 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2599 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2600 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2602 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2603 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2604 mwindow->edl->session->asset_columns, // width of each column
2605 1, // Total columns.
2606 0, // Pixel of top of window.
2607 0, // If this listbox is a popup window
2608 LISTBOX_MULTIPLE, // Select one item or multiple items
2609 ICON_TOP, // Position of icon relative to text of each item
2610 -1) // Allow drags, require shift for scrolling
2612 this->mwindow = mwindow;
2615 set_scroll_stretch(1, 1);
2618 AWindowAssets::~AWindowAssets()
2622 int AWindowAssets::button_press_event()
2624 AssetVIconThread *avt = gui->vicon_thread;
2625 if( avt->draw_mode != ASSET_VIEW_NONE && is_event_win() ) {
2626 int dir = 1, button = get_buttonpress();
2628 case WHEEL_DOWN: dir = -1; // fall thru
2630 int x = get_cursor_x(), y = get_cursor_y();
2631 if( avt->cursor_inside(x, y) && avt->view_win )
2632 return avt->zoom_scale(dir);
2637 int result = BC_ListBox::button_press_event();
2639 if( !result && get_buttonpress() == RIGHT_BUTTON &&
2640 is_event_win() && cursor_inside() ) {
2641 BC_ListBox::deactivate_selection();
2642 int folder = mwindow->edl->session->awindow_folder;
2644 case AW_AEFFECT_FOLDER:
2645 case AW_VEFFECT_FOLDER:
2646 case AW_ATRANSITION_FOLDER:
2647 case AW_VTRANSITION_FOLDER:
2648 gui->effectlist_menu->update();
2649 gui->effectlist_menu->activate_menu();
2651 case AW_LABEL_FOLDER:
2652 gui->labellist_menu->update();
2653 gui->labellist_menu->activate_menu();
2655 case AW_CLIP_FOLDER:
2656 gui->cliplist_menu->update();
2657 gui->cliplist_menu->activate_menu();
2659 case AW_PROXY_FOLDER:
2660 gui->proxylist_menu->update();
2661 gui->proxylist_menu->activate_menu();
2664 case AW_MEDIA_FOLDER: {
2665 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2666 gui->assetlist_menu->update_titles(shots);
2667 gui->assetlist_menu->activate_menu();
2677 int AWindowAssets::handle_event()
2679 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2680 if( !asset_picon ) return 0;
2681 Indexable *picon_idxbl = asset_picon->indexable;
2682 EDL *picon_edl = asset_picon->edl;
2684 VWindow *vwindow = 0;
2685 switch( mwindow->edl->session->awindow_folder ) {
2686 case AW_AEFFECT_FOLDER:
2687 case AW_VEFFECT_FOLDER:
2688 case AW_ATRANSITION_FOLDER:
2689 case AW_VTRANSITION_FOLDER: return 1;
2690 case AW_PROXY_FOLDER:
2691 proxy = 1; // fall thru
2693 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2694 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2697 if( !vwindow || !vwindow->is_running() ) return 1;
2698 if( proxy && picon_idxbl ) {
2699 picon_edl = gui->collect_proxy(picon_idxbl);
2703 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2704 else if( picon_edl ) vwindow->change_source(picon_edl);
2708 int AWindowAssets::selection_changed()
2710 // Show popup window
2712 int folder = mwindow->edl->session->awindow_folder;
2713 if( get_button_down() && get_buttonpress() == RIGHT_BUTTON &&
2714 (item = (AssetPicon*)get_selection(0, 0)) ) {
2716 case AW_AEFFECT_FOLDER:
2717 case AW_VEFFECT_FOLDER:
2718 case AW_ATRANSITION_FOLDER:
2719 case AW_VTRANSITION_FOLDER:
2720 gui->effectlist_menu->update();
2721 gui->effectlist_menu->activate_menu();
2723 case AW_LABEL_FOLDER:
2724 if( !item->label ) break;
2725 gui->label_menu->activate_menu();
2727 case AW_CLIP_FOLDER:
2728 if( !item->indexable && !item->edl ) break;
2729 gui->clip_menu->update();
2730 gui->clip_menu->activate_menu();
2732 case AW_PROXY_FOLDER:
2733 if( !item->indexable && !item->edl ) break;
2734 gui->proxy_menu->update();
2735 gui->proxy_menu->activate_menu();
2738 if( !item->indexable && !item->edl ) break;
2739 gui->asset_menu->update();
2740 gui->asset_menu->activate_menu();
2744 deactivate_selection();
2746 else if( gui->vicon_drawing && get_button_down() &&
2747 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2749 case AW_MEDIA_FOLDER:
2750 case AW_PROXY_FOLDER:
2751 case AWINDOW_USER_FOLDERS:
2752 if( get_buttonpress() == LEFT_BUTTON ||
2753 get_buttonpress() == MIDDLE_BUTTON ) {
2754 AssetVIcon *vicon = 0;
2755 if( !gui->vicon_thread->vicon )
2756 vicon = item->vicon;
2757 int draw_mode = vicon && get_buttonpress() == MIDDLE_BUTTON ?
2758 ASSET_VIEW_MEDIA_MAP : ASSET_VIEW_MEDIA;
2759 gui->vicon_thread->set_view_popup(vicon, draw_mode);
2762 case AW_CLIP_FOLDER:
2763 if( get_buttonpress() == LEFT_BUTTON ) {
2764 AssetVIcon *vicon = 0;
2765 if( !gui->vicon_thread->vicon )
2766 vicon = item->vicon;
2767 gui->vicon_thread->set_view_popup(vicon, ASSET_VIEW_ICON);
2775 void AWindowAssets::draw_background()
2777 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2778 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2779 set_font(LARGEFONT);
2780 int folder = mwindow->edl->session->awindow_folder;
2781 const char *title = mwindow->edl->get_folder_name(folder);
2782 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2783 title, -1, get_bg_surface());
2786 int AWindowAssets::drag_start_event()
2788 int collect_pluginservers = 0;
2789 int collect_assets = 0, proxy = 0;
2791 if( BC_ListBox::drag_start_event() ) {
2792 switch( mwindow->edl->session->awindow_folder ) {
2793 case AW_AEFFECT_FOLDER:
2794 mwindow->session->current_operation = DRAG_AEFFECT;
2795 collect_pluginservers = 1;
2797 case AW_VEFFECT_FOLDER:
2798 mwindow->session->current_operation = DRAG_VEFFECT;
2799 collect_pluginservers = 1;
2801 case AW_ATRANSITION_FOLDER:
2802 mwindow->session->current_operation = DRAG_ATRANSITION;
2803 collect_pluginservers = 1;
2805 case AW_VTRANSITION_FOLDER:
2806 mwindow->session->current_operation = DRAG_VTRANSITION;
2807 collect_pluginservers = 1;
2809 case AW_LABEL_FOLDER:
2812 case AW_PROXY_FOLDER:
2813 proxy = 1; // fall thru
2814 case AW_MEDIA_FOLDER:
2816 mwindow->session->current_operation = DRAG_ASSET;
2821 if( collect_pluginservers ) {
2823 mwindow->session->drag_pluginservers->remove_all();
2826 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2827 if( !result ) break;
2829 mwindow->session->drag_pluginservers->append(result->plugin);
2833 if( collect_assets ) {
2834 gui->collect_assets(proxy);
2842 int AWindowAssets::drag_motion_event()
2844 BC_ListBox::drag_motion_event();
2847 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2848 mwindow->gui->drag_motion();
2849 mwindow->gui->unlock_window();
2851 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2852 VWindow *vwindow = mwindow->vwindows.get(i);
2853 if( !vwindow->is_running() ) continue;
2854 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2855 vwindow->gui->drag_motion();
2856 vwindow->gui->unlock_window();
2859 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2860 mwindow->cwindow->gui->drag_motion();
2861 mwindow->cwindow->gui->unlock_window();
2863 lock_window("AWindowAssets::drag_motion_event");
2864 if( mwindow->session->current_operation == DRAG_ASSET &&
2865 gui->folder_list->cursor_above() ) { // highlight user folder
2866 BC_ListBoxItem *item = 0;
2867 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2868 if( item_no >= 0 ) {
2869 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2870 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2873 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2874 int folder_xposition = gui->folder_list->get_xposition();
2875 int folder_yposition = gui->folder_list->get_yposition();
2876 gui->folder_list->update(&gui->folders, 0, 0, 1,
2877 folder_xposition, folder_yposition, item_no, 0, 1);
2882 int AWindowAssets::drag_stop_event()
2886 result = gui->drag_stop();
2891 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2892 result = mwindow->gui->drag_stop();
2893 mwindow->gui->unlock_window();
2897 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2898 VWindow *vwindow = mwindow->vwindows.get(i);
2899 if( !vwindow ) continue;
2900 if( !vwindow->is_running() ) continue;
2901 if( vwindow->gui->is_hidden() ) continue;
2902 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2903 if( vwindow->gui->cursor_above() &&
2904 vwindow->gui->get_cursor_over_window() ) {
2905 result = vwindow->gui->drag_stop();
2907 vwindow->gui->unlock_window();
2912 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2913 result = mwindow->cwindow->gui->drag_stop();
2914 mwindow->cwindow->gui->unlock_window();
2917 lock_window("AWindowAssets::drag_stop_event");
2919 result = gui->folder_list->drag_stop();
2924 get_drag_popup()->set_animation(0);
2926 BC_ListBox::drag_stop_event();
2927 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2928 mwindow->session->current_operation = ::NO_OPERATION;
2933 int AWindowAssets::column_resize_event()
2935 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2936 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2940 int AWindowAssets::focus_in_event()
2942 int ret = BC_ListBox::focus_in_event();
2943 gui->start_vicon_drawing();
2947 int AWindowAssets::focus_out_event()
2949 gui->stop_vicon_drawing();
2950 return BC_ListBox::focus_out_event();
2953 void AWindowAssets::update_vicon_area()
2955 int x0 = 0, x1 = get_w();
2956 int y0 = get_title_h();
2958 if( is_highlighted() ) {
2959 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2960 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2962 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2965 int AWindowAssets::mouse_over_event(int no)
2967 if( gui->vicon_thread->viewing &&
2968 no >= 0 && no < gui->displayed_assets[0].size() ) {
2969 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2970 gui->vicon_thread->set_view_popup(picon->vicon);
2976 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2977 : BC_TextBox(x, y, w, 1, "")
2979 this->search_text = search_text;
2982 int AWindowSearchTextBox::handle_event()
2984 return search_text->handle_event();
2987 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2989 this->mwindow = mwindow;
2995 void AWindowSearchText::create_objects()
2997 int x1 = x, y1 = y, margin = 10;
2998 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2999 x1 += text_title->get_w() + margin;
3000 int w1 = gui->get_w() - x1 - 2*margin;
3001 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
3004 int AWindowSearchText::handle_event()
3006 gui->async_update_assets();
3010 int AWindowSearchText::get_w()
3012 return text_box->get_w() + text_title->get_w() + 10;
3015 int AWindowSearchText::get_h()
3017 return bmax(text_box->get_h(),text_title->get_h());
3020 void AWindowSearchText::reposition_window(int x, int y, int w)
3022 int x1 = x, y1 = y, margin = 10;
3023 text_title->reposition_window(x1, y1);
3024 x1 += text_title->get_w() + margin;
3025 int w1 = gui->get_w() - x1 - 2*margin;
3026 text_box->reposition_window(x1, y1, w1);
3029 const char *AWindowSearchText::get_text()
3031 return text_box->get_text();
3034 void AWindowSearchText::clear()
3036 text_box->update("");
3039 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3040 : BC_Button(x, y, mwindow->theme->deletedisk_data)
3042 this->mwindow = mwindow;
3044 set_tooltip(_("Delete asset from disk"));
3047 int AWindowDeleteDisk::handle_event()
3052 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3053 : BC_Button(x, y, mwindow->theme->deleteproject_data)
3055 this->mwindow = mwindow;
3057 set_tooltip(_("Delete asset from project"));
3060 int AWindowDeleteProject::handle_event()
3065 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3066 // : BC_Button(x, y, mwindow->theme->infoasset_data)
3068 // this->mwindow = mwindow;
3070 // set_tooltip(_("Edit information on asset"));
3073 // int AWindowInfo::handle_event()
3075 // int cur_x, cur_y;
3076 // gui->get_abs_cursor(cur_x, cur_y, 0);
3077 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
3081 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3082 : BC_Button(x, y, mwindow->theme->redrawindex_data)
3084 this->mwindow = mwindow;
3086 set_tooltip(_("Redraw index"));
3089 int AWindowRedrawIndex::handle_event()
3094 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3095 : BC_Button(x, y, mwindow->theme->pasteasset_data)
3097 this->mwindow = mwindow;
3099 set_tooltip(_("Paste asset on recordable tracks"));
3102 int AWindowPaste::handle_event()
3107 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3108 : BC_Button(x, y, mwindow->theme->appendasset_data)
3110 this->mwindow = mwindow;
3112 set_tooltip(_("Append asset in new tracks"));
3115 int AWindowAppend::handle_event()
3120 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3121 : BC_Button(x, y, mwindow->theme->viewasset_data)
3123 this->mwindow = mwindow;
3125 set_tooltip(_("View asset"));
3128 int AWindowView::handle_event()
3133 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3134 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3136 this->mwindow = mwindow;
3140 void AddTools::create_objects()
3143 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3144 vis |= 1 << PLUGIN_FFMPEG_ID;
3145 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3146 vis |= 1 << PLUGIN_LADSPA_ID;
3148 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3149 vis |= 1 << PLUGIN_LV2_ID;
3151 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3152 PluginServer *plugin = MWindow::plugindb->get(i);
3153 if( !plugin->audio && !plugin->video ) continue;
3154 int idx = plugin->dir_idx;
3155 uint32_t msk = 1 << idx;
3156 if( (msk & vis) != 0 ) continue;
3158 char parent[BCTEXTLEN];
3159 strcpy(parent, plugin->path);
3160 char *bp = strrchr(parent, '/');
3161 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3162 if( !bp ) bp = parent; else ++bp;
3163 add_item(new AddPluginItem(this, bp, idx));
3168 // plugin_dirs list from toplevel makefile include plugin_defs
3173 N_("audio_transitions")
3180 N_("video_transitions")
3183 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3184 : BC_MenuItem(_(text))
3188 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3189 int chk = (msk & vis) ? 1 : 0;
3193 int AddPluginItem::handle_event()
3195 int chk = get_checked() ^ 1;
3197 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3198 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3199 menu->gui->update_effects();
3200 menu->gui->save_defaults(menu->mwindow->defaults);
3201 menu->gui->async_update_assets();
3205 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3206 : BC_Toggle(x, y, images, agui->vicon_drawing)
3209 set_tooltip(_("Preview"));
3212 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3214 int text_line = -1, toggle_x = -1, toggle_y = -1;
3215 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3216 BC_Toggle::calculate_extents(agui, images, 1,
3217 &text_line, ww, hh, &toggle_x, &toggle_y,
3218 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3221 AVIconDrawing::~AVIconDrawing()
3225 int AVIconDrawing::handle_event()
3227 agui->vicon_drawing = get_value();
3228 if( agui->vicon_drawing )
3229 agui->start_vicon_drawing();
3231 agui->stop_vicon_drawing();
3236 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3237 : BC_MenuItem("","v",'v')
3239 this->mwindow = mwindow;
3243 int AWindowListFormat::handle_event()
3245 return gui->cycle_assetlist_format();
3248 void AWindowListFormat::update()
3250 EDLSession *session = mwindow->edl->session;
3251 const char *text = 0;
3252 switch( session->assetlist_format ) {
3254 text = _("Display icons");
3257 text = _("Display icons packed");
3259 case ASSETS_ICONS_PACKED:
3260 text = _("Display icon list");
3262 case ASSETS_ICON_LIST:
3263 text = _("Display text");
3269 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3270 : BC_MenuItem(_("Sort items"))
3272 this->mwindow = mwindow;
3276 int AWindowListSort::handle_event()
3282 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3285 this->select_used = select_used;
3286 this->action = action;
3289 int AssetSelectUsedItem::handle_event()
3291 MWindow *mwindow = select_used->mwindow;
3292 AWindowGUI *gui = select_used->gui;
3293 AWindowAssets *asset_list = gui->asset_list;
3294 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3299 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3303 asset_list->set_all_selected(data, 0);
3304 for( int i = 0; i < data->total; i++ ) {
3305 AssetPicon *picon = (AssetPicon*)data->values[i];
3306 Indexable *idxbl = picon->indexable ? picon->indexable :
3307 picon->edl ? picon->edl->get_proxy_asset() : 0;
3308 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3309 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3314 int asset_xposition = asset_list->get_xposition();
3315 int asset_yposition = asset_list->get_yposition();
3316 asset_list->update(gui->displayed_assets, gui->asset_titles,
3317 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3318 asset_xposition, asset_yposition, -1, 0);
3319 asset_list->center_selection();
3323 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3324 : BC_MenuItem(_("Select"))
3326 this->mwindow = mwindow;