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"
58 #include "mainsession.h"
59 #include "mwindowgui.h"
61 #include "preferences.h"
63 #include "proxypopup.h"
64 #include "renderengine.h"
69 #include "transportque.h"
73 #include "vwindowgui.h"
76 #include "data/lad_picon_png.h"
77 #include "data/ff_audio_png.h"
78 #include "data/ff_video_png.h"
85 const char *AWindowGUI::folder_names[] =
89 N_("Audio Transitions"),
90 N_("Video Transitions"),
98 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
99 : VIcon(w, h, framerate), Garbage("AssetVIcon")
102 this->length = length;
106 AssetVIcon::~AssetVIcon()
108 picon->gui->vicon_thread->del_vicon(this);
112 VFrame *AssetVIcon::frame()
114 Asset *asset = (Asset *)picon->indexable;
115 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
116 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
118 int sample_rate = asset->get_sample_rate();
119 int64_t audio_samples = asset->get_audio_samples();
120 double duration = (double)audio_samples / sample_rate;
121 picon->draw_hue_bar(temp, duration);
122 int secs = length / frame_rate + 0.5;
123 if( !secs ) secs = 1;
124 int bfrsz = VICON_SAMPLE_RATE;
125 int samples = audio_size/sizeof(vicon_audio_t);
126 double line_pos = (double)seq_no/(length-1);
127 int audio_pos = samples * line_pos * (secs-1)/secs;
128 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
129 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
130 double data[bfrsz], sample_scale = 1./mx;
131 int len = samples - audio_pos;
132 if( len > bfrsz ) len = bfrsz;
134 while( i < len ) data[i++] = *audio_data++ * sample_scale;
135 while( i < bfrsz ) data[i++] = 0;
136 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
137 int x = (vw-1) * line_pos;
138 temp->pixel_rgb = RED;
139 temp->draw_line(x,0, x,vh);
142 int ww = picon->gui->vicon_thread->view_w;
143 int hh = picon->gui->vicon_thread->view_h;
144 if( !asset->video_data ) {
146 temp = new VFrame(0, -1, ww, hh, BC_RGB888, -1);
151 if( seq_no >= images.size() ) {
152 MWindow *mwindow = picon->mwindow;
153 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
154 if( !file ) return 0;
155 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
156 delete temp; temp = 0;
159 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
160 while( seq_no >= images.size() ) {
161 mwindow->video_cache->check_in(asset);
163 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
164 if( !file ) { usleep(1000); continue; }
166 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
167 file->set_video_position(pos,0);
168 if( file->read_frame(temp) ) temp->clear_frame();
169 add_image(temp, ww, hh, BC_RGB8);
171 mwindow->video_cache->check_in(asset);
173 return *images[seq_no];
176 int64_t AssetVIcon::set_seq_no(int64_t no)
178 if( no >= length ) no = 0;
182 int AssetVIcon::get_vx()
184 BC_ListBox *lbox = picon->gui->asset_list;
185 return lbox->get_icon_x(picon);
187 int AssetVIcon::get_vy()
189 BC_ListBox *lbox = picon->gui->asset_list;
190 return lbox->get_icon_y(picon);
193 void AssetVIcon::load_audio()
195 MWindow *mwindow = picon->mwindow;
196 Asset *asset = (Asset *)picon->indexable;
197 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
198 int channels = asset->get_audio_channels();
199 if( channels > 2 ) channels = 2;
200 int sample_rate = asset->get_sample_rate();
201 int bfrsz = sample_rate;
202 Samples samples(bfrsz);
203 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
204 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
205 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
206 double sample_scale = (double)mx / channels;
207 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
208 while( audio_pos < audio_len ) {
209 int64_t pos = audio_pos * time_scale;
210 for( int ch=0; ch<channels; ++ch ) {
211 file->set_channel(ch);
212 file->set_audio_position(pos);
213 file->read_samples(&samples, bfrsz);
214 double *data = samples.get_data();
215 for( int64_t k=audio_pos; k<audio_len; ++k ) {
216 int i = k * time_scale - pos;
217 if( i >= bfrsz ) break;
218 int v = audio_data[k] + data[i] * sample_scale;
219 audio_data[k] = CLIP(v, -mx,mx);
222 audio_pos = (pos + bfrsz) / time_scale;
224 mwindow->audio_cache->check_in(asset);
228 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
232 audio = new AudioDevice(gui->mwindow);
236 AssetVIconAudio::~AssetVIconAudio()
241 void AssetVIconAudio::run()
244 int64_t bfrsz = VICON_SAMPLE_RATE;
245 MWindow *mwindow = gui->mwindow;
246 EDL *edl = mwindow->edl;
247 EDLSession *session = edl->session;
248 AudioOutConfig *aconfig = session->playback_config->aconfig;
249 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
250 audio->start_playback();
251 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
252 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
253 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
255 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
256 while( !interrupted ) {
257 int len = audio_len - audio_pos;
258 if( len <= 0 ) break;
259 if( len > bfrsz ) len = bfrsz;
261 for( int i=0; i<len; ++i,++k )
262 out0[i] = out1[i] = (double)audio_data[k] / mx;
264 audio->write_buffer(out, channels, len);
268 audio->set_last_buffer();
269 audio->stop_audio(interrupted ? 0 : 1);
273 void AssetVIconAudio::start(AssetVIcon *vicon)
275 if( running() ) return;
282 void AssetVIconAudio::stop(int wait)
284 if( running() && !interrupted ) {
286 audio->stop_audio(wait);
290 vicon->playing_audio = 0;
295 void AssetVIcon::start_audio()
297 if( playing_audio < 0 ) return;
298 picon->gui->vicon_audio->stop(0);
300 picon->gui->vicon_audio->start(this);
303 void AssetVIcon::stop_audio()
305 if( playing_audio > 0 )
306 picon->gui->vicon_audio->stop(0);
310 int AssetVIcon::popup_button_press(int x, int y)
312 if( playing_audio >= 0 ) return 0;
313 VIconThread *vt = picon->gui->vicon_thread;
314 ViewPopup *view_win = vt->view_win;
315 if( !view_win || !view_win->is_event_win() ) return 0;
316 int view_w = view_win->get_w(), view_h = view_win->get_h();
317 MWindow *mwindow = picon->mwindow;
318 EDL *edl = mwindow->edl;
319 if( y < VIEW_POPUP_BAR_H ) {
321 picon->indexable ? picon->indexable :
322 picon->edl ? picon->edl : 0;
323 if( !idxbl ) return 0;
324 double sample_rate = idxbl->get_sample_rate();
325 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
326 idxbl->get_audio_samples() / sample_rate : 0;
327 double frame_rate = idxbl->get_frame_rate();
328 double video_length = frame_rate > 0 && idxbl->have_video() ?
329 idxbl->get_video_frames() / frame_rate : 0;
330 double idxbl_length = bmax(audio_length, video_length);
331 double pos = x * idxbl_length / view_w;
332 double start = 0, end = idxbl_length;
333 double lt = DBL_MAX, rt = DBL_MAX;
334 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
335 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
336 Indexable *indexable = (Indexable *)edit->asset;
337 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
338 if( !indexable ) continue;
339 if( indexable->id == idxbl->id ||
340 (!indexable->is_asset == !idxbl->is_asset &&
341 !strcmp(indexable->path, idxbl->path)) ) {
342 double start_pos = track->from_units(edit->startsource);
343 double end_pos = track->from_units(edit->startsource + edit->length);
344 double dlt = pos - start_pos, drt = end_pos - pos;
345 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
346 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
347 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
348 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
352 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
353 VWindow *vwindow = mwindow->get_viewer(1, 0);
354 vwindow->change_source(idxbl);
355 mwindow->gui->unlock_window();
356 EDL *vedl = vwindow->get_edl();
357 vedl->set_inpoint(start);
358 vedl->set_outpoint(end);
359 vedl->local_session->set_selectionstart(start);
360 vedl->local_session->set_selectionend(end);
361 vwindow->update_position(CHANGE_NONE, 0, 1, 0);
364 return y < view_h-VIEW_POPUP_BAR_H ? 0 : popup_cursor_motion(x, y);
367 int AssetVIcon::popup_cursor_motion(int x, int y)
369 if( playing_audio >= 0 ) return 0;
370 VIconThread *vt = picon->gui->vicon_thread;
371 ViewPopup *view_win = (ViewPopup *)vt->view_win;
372 if( !view_win || !view_win->is_event_win() ||
373 !view_win->get_button_down() ) return 0;
374 int view_w = view_win->get_w(), view_h = view_win->get_h();
375 MWindow *mwindow = picon->mwindow;
376 EDL *edl = mwindow->edl;
377 if( y >= view_h-VIEW_POPUP_BAR_H ) {
378 double total_length = edl->tracks->total_length();
379 double pos = x * total_length / view_w;
380 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
381 mwindow->select_point(pos);
382 mwindow->zoom_sample(edl->local_session->zoom_sample);
383 mwindow->gui->unlock_window();
390 AWindowFolderItem::AWindowFolderItem()
396 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
397 : BC_ListBoxItem(text, color)
402 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
403 : BC_ListBoxItem(text, icon, color)
408 AssetPicon *AWindowFolderItem::get_picon()
410 AWindowFolderItem *item = this;
411 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
412 return (AssetPicon*)item;
415 int AWindowFolderSubItems::matches(const char *text)
417 int i = names.size();
418 while( --i >= 0 && strcmp(names[i], text) );
420 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
421 i = sublist ? sublist->size() : 0;
423 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
424 if( item->matches(text) ) break;
427 return i >= 0 ? 1 : 0;
431 AssetPicon::AssetPicon(MWindow *mwindow,
432 AWindowGUI *gui, Indexable *indexable)
433 : AWindowFolderItem()
436 this->mwindow = mwindow;
438 this->indexable = indexable;
439 indexable->add_user();
440 this->id = indexable->id;
443 AssetPicon::AssetPicon(MWindow *mwindow,
444 AWindowGUI *gui, EDL *edl)
445 : AWindowFolderItem()
448 this->mwindow = mwindow;
455 AssetPicon::AssetPicon(MWindow *mwindow,
456 AWindowGUI *gui, int folder, int persist)
457 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
458 folder>=0 && folder<AWINDOW_FOLDERS ?
459 gui->folder_icons[folder] : gui->folder_icon)
463 this->mwindow = mwindow;
465 persistent = persist;
468 AssetPicon::AssetPicon(MWindow *mwindow,
469 AWindowGUI *gui, int folder, const char *title)
470 : AWindowFolderItem(title, gui->folder_icon)
474 this->mwindow = mwindow;
479 AssetPicon::AssetPicon(MWindow *mwindow,
480 AWindowGUI *gui, PluginServer *plugin)
481 : AWindowFolderItem()
484 this->mwindow = mwindow;
486 this->plugin = plugin;
489 AssetPicon::AssetPicon(MWindow *mwindow,
490 AWindowGUI *gui, Label *label)
491 : AWindowFolderItem()
494 this->mwindow = mwindow;
502 AssetPicon::~AssetPicon()
504 if( vicon ) vicon->remove_user();
506 if( indexable ) indexable->remove_user();
507 if( edl ) edl->remove_user();
508 if( icon && !gui->protected_pixmap(icon) ) {
510 if( !plugin ) delete icon_vframe;
514 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
516 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
518 float h = 300 * t, s = 1., v = 1.;
519 float r, g, b; // duration, 0..1hr == hue red..magenta
520 HSV::hsv_to_rgb(r,g,b, h,s,v);
521 int ih = frame->get_h()/8, iw = frame->get_w();
522 int ir = r * 256; CLAMP(ir, 0,255);
523 int ig = g * 256; CLAMP(ig, 0,255);
524 int ib = b * 256; CLAMP(ib, 0,255);
525 unsigned char **rows = frame->get_rows();
526 for( int y=0; y<ih; ++y ) {
527 unsigned char *rp = rows[y];
528 for( int x=0; x<iw; rp+=3,++x ) {
529 rp[0] = ir; rp[1] = ig; rp[2] = ib;
534 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
535 int base_color, int line_color, int x, int y, int w, int h)
537 int h1 = h-1, h2 = h/2, iy = h2;
538 int rgb_color = frame->pixel_rgb;
539 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
540 double min = *dp, max = min;
541 x2 = (len * (ix+1))/w;
542 for( int i=x1; i<x2; ++i ) {
543 double value = *dp++;
544 if( value < min ) min = value;
545 if( value > max ) max = value;
547 int ctr = (min + max) / 2;
548 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
549 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
550 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
551 frame->pixel_rgb = line_color;
552 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
553 frame->pixel_rgb = base_color;
554 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
557 frame->pixel_rgb = rgb_color;
560 void AssetPicon::reset()
568 foldernum = AW_NO_FOLDER;
580 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
582 TransportCommand command;
583 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
584 command.get_edl()->copy_all(edl);
585 command.change_type = CHANGE_ALL;
586 command.realtime = 0;
587 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
588 render_engine->set_vcache(mwindow->video_cache);
589 render_engine->set_acache(mwindow->audio_cache);
590 render_engine->arm_command(&command);
592 void AssetPicon::close_render_engine()
594 delete render_engine; render_engine = 0;
596 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
598 if( !render_engine || !render_engine->vrender ) return;
599 render_engine->vrender->process_buffer(vfrm, pos, 0);
601 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
603 if( !render_engine || !render_engine->arender ) return;
604 render_engine->arender->process_buffer(samples, len, pos);
607 void AssetPicon::create_objects()
610 char name[BCTEXTLEN];
611 int pixmap_w, pixmap_h;
613 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
616 fs.extract_name(name, indexable->path);
620 set_text(strcpy(name, edl->local_session->clip_title));
624 if( indexable && indexable->is_asset ) {
625 Asset *asset = (Asset*)indexable;
626 if( asset->video_data ) {
627 if( mwindow->preferences->use_thumbnails ) {
628 gui->unlock_window();
629 File *file = mwindow->video_cache->check_out(asset,
634 int height = asset->height > 0 ? asset->height : 1;
635 pixmap_w = pixmap_h * asset->width / height;
638 file->set_video_position(0, 0);
640 if( gui->temp_picon &&
641 (gui->temp_picon->get_w() != asset->width ||
642 gui->temp_picon->get_h() != asset->height) ) {
643 delete gui->temp_picon;
647 if( !gui->temp_picon ) {
648 gui->temp_picon = new VFrame(0, -1,
649 asset->width, asset->height,
652 { char string[BCTEXTLEN];
653 sprintf(string, _("Reading %s"), name);
654 mwindow->gui->lock_window("AssetPicon::create_objects");
655 mwindow->gui->show_message(string);
656 mwindow->gui->unlock_window(); }
657 file->read_frame(gui->temp_picon);
658 mwindow->video_cache->check_in(asset);
660 gui->lock_window("AssetPicon::create_objects 0");
661 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
662 icon->draw_vframe(gui->temp_picon,
663 0, 0, pixmap_w, pixmap_h, 0, 0);
664 icon_vframe = new VFrame(0,
665 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
666 icon_vframe->transfer_from(gui->temp_picon);
667 if( asset->folder_no == AW_MEDIA_FOLDER ) {
669 double framerate = asset->get_frame_rate();
670 if( !framerate ) framerate = VICON_RATE;
671 int64_t frames = asset->get_video_frames();
672 double secs = frames / framerate;
673 if( secs > 5 ) secs = 5;
674 int64_t length = secs * gui->vicon_thread->refresh_rate;
675 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
676 if( asset->audio_data && secs > 0 ) {
677 gui->unlock_window();
678 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
679 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
681 gui->lock_window("AssetPicon::create_objects 1");
683 gui->vicon_thread->add_vicon(vicon);
685 else if( asset->folder_no == AW_PROXY_FOLDER ) {
686 char unproxy_path[BCTEXTLEN];
687 int proxy_scale = mwindow->edl->session->proxy_scale;
688 if( !ProxyRender::from_proxy_path(unproxy_path, asset, proxy_scale) ) {
689 Asset *unproxy = mwindow->edl->assets->get_asset(unproxy_path);
691 int i = gui->assets.total;
693 AssetPicon *picon = (AssetPicon*)gui->assets[i];
694 if( picon->id == unproxy->id ) {
695 vicon = picon->vicon;
696 if( vicon ) vicon->add_user();
706 gui->lock_window("AssetPicon::create_objects 2");
707 icon = gui->video_icon;
708 icon_vframe = gui->video_vframe;
712 icon = gui->video_icon;
713 icon_vframe = gui->video_vframe;
717 if( asset->audio_data ) {
718 if( mwindow->preferences->use_thumbnails ) {
719 gui->unlock_window();
720 File *file = mwindow->audio_cache->check_out(asset,
724 pixmap_w = pixmap_h * 16/9;
725 icon_vframe = new VFrame(0,
726 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
727 icon_vframe->clear_frame();
728 { char string[BCTEXTLEN];
729 sprintf(string, _("Reading %s"), name);
730 mwindow->gui->lock_window("AssetPicon::create_objects 3");
731 mwindow->gui->show_message(string);
732 mwindow->gui->unlock_window(); }
733 int sample_rate = asset->get_sample_rate();
734 int channels = asset->get_audio_channels();
735 if( channels > 2 ) channels = 2;
736 int64_t audio_samples = asset->get_audio_samples();
737 double duration = (double)audio_samples / sample_rate;
738 draw_hue_bar(icon_vframe, duration);
739 int bfrsz = sample_rate;
740 Samples samples(bfrsz);
741 static int line_colors[2] = { GREEN, YELLOW };
742 static int base_colors[2] = { RED, PINK };
743 for( int i=channels; --i>=0; ) {
744 file->set_channel(i);
745 file->set_audio_position(0);
746 file->read_samples(&samples, bfrsz);
747 draw_wave(icon_vframe, samples.get_data(), bfrsz,
748 base_colors[i], line_colors[i]);
750 mwindow->audio_cache->check_in(asset);
751 if( asset->folder_no == AW_MEDIA_FOLDER ) {
752 double secs = duration;
753 if( secs > 5 ) secs = 5;
754 double refresh_rate = gui->vicon_thread->refresh_rate;
755 int64_t length = secs * refresh_rate;
756 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
757 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
758 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
760 gui->vicon_thread->add_vicon(vicon);
762 gui->lock_window("AssetPicon::create_objects 4");
763 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
764 icon->draw_vframe(icon_vframe,
765 0, 0, pixmap_w, pixmap_h, 0, 0);
768 gui->lock_window("AssetPicon::create_objects 5");
769 icon = gui->audio_icon;
770 icon_vframe = gui->audio_vframe;
774 icon = gui->audio_icon;
775 icon_vframe = gui->audio_vframe;
780 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
783 if( indexable && !indexable->is_asset ) {
784 icon = gui->video_icon;
785 icon_vframe = gui->video_vframe;
789 if( edl->tracks->playable_video_tracks() ) {
790 if( mwindow->preferences->use_thumbnails ) {
791 gui->unlock_window();
792 char clip_icon_path[BCTEXTLEN];
793 char *clip_icon = edl->local_session->clip_icon;
795 snprintf(clip_icon_path, sizeof(clip_icon_path),
796 "%s/%s", File::get_config_path(), clip_icon);
797 icon_vframe = VFramePng::vframe_png(clip_icon_path);
800 //printf("render clip: %s\n", name);
801 int edl_h = edl->get_h(), edl_w = edl->get_w();
802 int height = edl_h > 0 ? edl_h : 1;
803 int width = edl_w > 0 ? edl_w : 1;
804 int color_model = edl->session->color_model;
805 pixmap_w = pixmap_h * width / height;
807 if( gui->temp_picon &&
808 (gui->temp_picon->get_color_model() != color_model ||
809 gui->temp_picon->get_w() != width ||
810 gui->temp_picon->get_h() != height) ) {
811 delete gui->temp_picon; gui->temp_picon = 0;
814 if( !gui->temp_picon ) {
815 gui->temp_picon = new VFrame(0, -1,
816 width, height, color_model, -1);
818 char string[BCTEXTLEN];
819 sprintf(string, _("Rendering %s"), name);
820 mwindow->gui->lock_window("AssetPicon::create_objects");
821 mwindow->gui->show_message(string);
822 mwindow->gui->unlock_window();
823 open_render_engine(edl, 0);
824 render_video(0, gui->temp_picon);
825 close_render_engine();
826 icon_vframe = new VFrame(0,
827 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
828 icon_vframe->transfer_from(gui->temp_picon);
829 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
832 pixmap_w = icon_vframe->get_w();
833 pixmap_h = icon_vframe->get_h();
835 gui->lock_window("AssetPicon::create_objects 0");
836 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
837 icon->draw_vframe(icon_vframe,
838 0, 0, pixmap_w, pixmap_h, 0, 0);
841 icon = gui->clip_icon;
842 icon_vframe = gui->clip_vframe;
846 if( edl->tracks->playable_audio_tracks() ) {
847 if( mwindow->preferences->use_thumbnails ) {
848 gui->unlock_window();
849 char clip_icon_path[BCTEXTLEN];
850 char *clip_icon = edl->local_session->clip_icon;
852 snprintf(clip_icon_path, sizeof(clip_icon_path),
853 "%s/%s", File::get_config_path(), clip_icon);
854 icon_vframe = VFramePng::vframe_png(clip_icon_path);
857 pixmap_w = pixmap_h * 16/9;
858 icon_vframe = new VFrame(0,
859 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
860 icon_vframe->clear_frame();
861 char string[BCTEXTLEN];
862 sprintf(string, _("Rendering %s"), name);
863 mwindow->gui->lock_window("AssetPicon::create_objects 3");
864 mwindow->gui->show_message(string);
865 mwindow->gui->unlock_window();
866 int sample_rate = edl->get_sample_rate();
867 int channels = edl->get_audio_channels();
868 if( channels > 2 ) channels = 2;
869 int64_t audio_samples = edl->get_audio_samples();
870 double duration = (double)audio_samples / sample_rate;
871 draw_hue_bar(icon_vframe, duration);
872 Samples *samples[MAX_CHANNELS];
873 int bfrsz = sample_rate;
874 for( int i=0; i<MAX_CHANNELS; ++i )
875 samples[i] = i<channels ? new Samples(bfrsz) : 0;
876 open_render_engine(edl, 1);
877 render_audio(0, samples, bfrsz);
878 close_render_engine();
879 gui->lock_window("AssetPicon::create_objects 4");
880 static int line_colors[2] = { GREEN, YELLOW };
881 static int base_colors[2] = { RED, PINK };
882 for( int i=channels; --i>=0; ) {
883 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
884 base_colors[i], line_colors[i]);
886 for( int i=0; i<channels; ++i ) delete samples[i];
887 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
890 pixmap_w = icon_vframe->get_w();
891 pixmap_h = icon_vframe->get_h();
893 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
894 icon->draw_vframe(icon_vframe,
895 0, 0, pixmap_w, pixmap_h, 0, 0);
898 icon = gui->clip_icon;
899 icon_vframe = gui->clip_vframe;
905 strcpy(name, _(plugin->title));
907 icon_vframe = plugin->get_picon();
909 icon = gui->create_pixmap(icon_vframe);
910 else if( plugin->audio ) {
911 if( plugin->transition ) {
912 icon = gui->atransition_icon;
913 icon_vframe = gui->atransition_vframe;
915 else if( plugin->is_ffmpeg() ) {
916 icon = gui->ff_aud_icon;
917 icon_vframe = gui->ff_aud_vframe;
919 else if( plugin->is_ladspa() ) {
920 icon = gui->ladspa_icon;
921 icon_vframe = gui->ladspa_vframe;
924 icon = gui->aeffect_icon;
925 icon_vframe = gui->aeffect_vframe;
928 else if( plugin->video ) {
929 if( plugin->transition ) {
930 icon = gui->vtransition_icon;
931 icon_vframe = gui->vtransition_vframe;
933 else if( plugin->is_ffmpeg() ) {
934 icon = gui->ff_vid_icon;
935 icon_vframe = gui->ff_vid_vframe;
938 icon = gui->veffect_icon;
939 icon_vframe = gui->veffect_vframe;
947 mwindow->edl->session->time_format,
948 mwindow->edl->session->sample_rate,
949 mwindow->edl->session->frame_rate,
950 mwindow->edl->session->frames_per_foot);
952 icon = gui->label_icon;
953 icon_vframe = gui->label_vframe;
956 icon = gui->file_icon;
957 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
960 set_icon_vframe(icon_vframe);
963 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
964 : BC_Window(_(PROGRAM_NAME ": Resources"),
965 mwindow->session->awindow_x, mwindow->session->awindow_y,
966 mwindow->session->awindow_w, mwindow->session->awindow_h,
969 this->mwindow = mwindow;
970 this->awindow = awindow;
972 file_vframe = 0; file_icon = 0;
973 folder_vframe = 0; folder_icon = 0;
974 audio_vframe = 0; audio_icon = 0;
975 video_vframe = 0; video_icon = 0;
976 label_vframe = 0; label_icon = 0;
978 atransition_vframe = 0; atransition_icon = 0;
979 vtransition_vframe = 0; vtransition_icon = 0;
980 aeffect_vframe = 0; aeffect_icon = 0;
981 ladspa_vframe = 0; ladspa_icon = 0;
982 veffect_vframe = 0; veffect_icon = 0;
983 ff_aud_vframe = 0; ff_aud_icon = 0;
984 ff_vid_vframe = 0; ff_vid_icon = 0;
986 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
987 atransition_folder_vframe = 0; atransition_folder_icon = 0;
988 clip_folder_vframe = 0; clip_folder_icon = 0;
989 label_folder_vframe = 0; label_folder_icon = 0;
990 media_folder_vframe = 0; media_folder_icon = 0;
991 proxy_folder_vframe = 0; proxy_folder_icon = 0;
992 veffect_folder_vframe = 0; veffect_folder_icon = 0;
993 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
995 ladspa_vframe = 0; ladspa_icon = 0;
996 ff_aud_vframe = 0; ff_aud_icon = 0;
997 ff_vid_vframe = 0; ff_vid_icon = 0;
999 clip_vframe = 0; clip_icon = 0;
1000 atransition_vframe = 0; atransition_icon = 0;
1001 vtransition_vframe = 0; vtransition_icon = 0;
1002 aeffect_vframe = 0; aeffect_icon = 0;
1003 veffect_vframe = 0; veffect_icon = 0;
1005 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1007 effectlist_menu = 0;
1012 folderlist_menu = 0;
1015 allow_iconlisting = 1;
1020 displayed_folder = AW_NO_FOLDER;
1021 new_folder_thread = 0;
1022 modify_folder_thread = 0;
1023 folder_lock = new Mutex("AWindowGUI::folder_lock");
1026 AWindowGUI::~AWindowGUI()
1028 assets.remove_all_objects();
1029 folders.remove_all_objects();
1030 aeffects.remove_all_objects();
1031 veffects.remove_all_objects();
1032 atransitions.remove_all_objects();
1033 vtransitions.remove_all_objects();
1034 labellist.remove_all_objects();
1035 displayed_assets[1].remove_all_objects();
1037 delete new_folder_thread;
1038 delete modify_folder_thread;
1039 delete vicon_thread;
1044 delete remove_plugin;
1046 delete file_vframe; delete file_icon;
1047 delete folder_vframe; delete folder_icon;
1048 delete audio_vframe; delete audio_icon;
1049 delete video_vframe; delete video_icon;
1050 delete label_vframe; delete label_icon;
1051 delete clip_vframe; delete clip_icon;
1052 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1053 delete atransition_folder_vframe; delete atransition_folder_icon;
1054 delete veffect_folder_vframe; delete veffect_folder_icon;
1055 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1056 delete clip_folder_vframe; delete clip_folder_icon;
1057 delete label_folder_vframe; delete label_folder_icon;
1058 delete media_folder_vframe; delete media_folder_icon;
1059 delete proxy_folder_vframe; delete proxy_folder_icon;
1060 delete ladspa_vframe; delete ladspa_icon;
1061 delete ff_aud_vframe; delete ff_aud_icon;
1062 delete ff_vid_vframe; delete ff_vid_icon;
1063 delete atransition_vframe; delete atransition_icon;
1064 delete vtransition_vframe; delete vtransition_icon;
1065 delete aeffect_vframe; delete aeffect_icon;
1066 delete veffect_vframe; delete veffect_icon;
1070 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1072 return icon == file_icon ||
1073 icon == folder_icon ||
1074 icon == audio_icon ||
1075 icon == video_icon ||
1076 icon == clip_icon ||
1077 icon == label_icon ||
1078 icon == vtransition_icon ||
1079 icon == atransition_icon ||
1080 icon == veffect_icon ||
1081 icon == aeffect_icon ||
1082 icon == ladspa_icon ||
1083 icon == ff_aud_icon ||
1084 icon == ff_vid_icon ||
1085 icon == aeffect_folder_icon ||
1086 icon == veffect_folder_icon ||
1087 icon == atransition_folder_icon ||
1088 icon == vtransition_folder_icon ||
1089 icon == label_folder_icon ||
1090 icon == clip_folder_icon ||
1091 icon == media_folder_icon ||
1092 icon == proxy_folder_icon;
1095 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1097 char png_path[BCTEXTLEN];
1098 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1099 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1100 File::get_plugin_path(), plugin_icons, name);
1101 if( access(png_path, R_OK) ) return 0;
1102 return VFramePng::vframe_png(png_path,0,0);
1105 VFrame *AWindowGUI::get_picon(const char *name)
1107 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1109 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1110 snprintf(pp, ep-pp, "%s.png", name);
1111 unsigned char *data = mwindow->theme->get_image_data(png_name);
1112 if( data ) vframe = new VFramePng(data, 0.);
1117 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1119 vfrm = get_picon(fn);
1120 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1121 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1123 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1125 vfrm = get_picon(fn);
1126 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1127 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1129 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1131 vfrm = get_picon(fn);
1132 if( !vfrm ) vfrm = new VFramePng(png);
1133 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1136 void AWindowGUI::create_objects()
1138 lock_window("AWindowGUI::create_objects");
1139 asset_titles[0] = C_("Title");
1140 asset_titles[1] = _("Comments");
1142 set_icon(mwindow->theme->get_image("awindow_icon"));
1144 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1145 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1146 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1147 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1148 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1150 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1151 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1152 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1153 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1154 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1155 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1156 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1157 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1159 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1160 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1161 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1162 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1163 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1164 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1165 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1166 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1168 theme_icon(clip_vframe, clip_icon, "clip_icon");
1169 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1170 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1171 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1172 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1174 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1175 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1176 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1177 folder_lock->lock("AWindowGUI::create_objects");
1178 // Mandatory folders
1179 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1180 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1181 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1182 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1183 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1184 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1185 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1186 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1188 create_label_folder();
1189 folder_lock->unlock();
1191 mwindow->theme->get_awindow_sizes(this);
1192 load_defaults(mwindow->defaults);
1193 new_folder_thread = new NewFolderThread(this);
1194 modify_folder_thread = new ModifyFolderThread(this);
1196 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1197 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1198 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1199 search_text->create_objects();
1200 int dy = search_text->get_h() + 10;
1202 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1204 vicon_thread = new VIconThread(asset_list);
1205 asset_list->update_vicon_area();
1206 vicon_thread->start();
1207 vicon_audio = new AssetVIconAudio(this);
1209 add_subwindow(divider = new AWindowDivider(mwindow, this,
1210 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1211 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1213 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1215 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1216 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1217 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1218 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1219 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1220 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1221 add_tools->create_objects();
1222 fy += add_tools->get_h(); fh -= add_tools->get_h();
1223 add_subwindow(folder_list = new AWindowFolders(mwindow,
1224 this, fx, fy, fw, fh));
1226 folder_list->load_expanders();
1228 //int x = mwindow->theme->abuttons_x;
1229 //int y = mwindow->theme->abuttons_y;
1231 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1232 asset_menu->create_objects();
1233 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1234 clip_menu->create_objects();
1235 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1236 label_menu->create_objects();
1237 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1238 proxy_menu->create_objects();
1240 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1241 effectlist_menu->create_objects();
1242 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1243 assetlist_menu->create_objects();
1244 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1245 cliplist_menu->create_objects();
1246 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1247 labellist_menu->create_objects();
1248 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1249 proxylist_menu->create_objects();
1251 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1252 folderlist_menu->create_objects();
1254 create_custom_xatoms();
1258 int AWindowGUI::resize_event(int w, int h)
1260 mwindow->session->awindow_x = get_x();
1261 mwindow->session->awindow_y = get_y();
1262 mwindow->session->awindow_w = w;
1263 mwindow->session->awindow_h = h;
1265 mwindow->theme->get_awindow_sizes(this);
1266 mwindow->theme->draw_awindow_bg(this);
1267 reposition_objects();
1269 // int x = mwindow->theme->abuttons_x;
1270 // int y = mwindow->theme->abuttons_y;
1271 // new_bin->reposition_window(x, y);
1272 // x += new_bin->get_w();
1273 // delete_bin->reposition_window(x, y);
1274 // x += delete_bin->get_w();
1275 // rename_bin->reposition_window(x, y);
1276 // x += rename_bin->get_w();
1277 // delete_disk->reposition_window(x, y);
1278 // x += delete_disk->get_w();
1279 // delete_project->reposition_window(x, y);
1280 // x += delete_project->get_w();
1281 // info->reposition_window(x, y);
1282 // x += info->get_w();
1283 // redraw_index->reposition_window(x, y);
1284 // x += redraw_index->get_w();
1285 // paste->reposition_window(x, y);
1286 // x += paste->get_w();
1287 // append->reposition_window(x, y);
1288 // x += append->get_w();
1289 // view->reposition_window(x, y);
1291 BC_WindowBase::resize_event(w, h);
1292 asset_list->update_vicon_area();
1296 int AWindowGUI::translation_event()
1298 mwindow->session->awindow_x = get_x();
1299 mwindow->session->awindow_y = get_y();
1303 void AWindowGUI::reposition_objects()
1305 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1306 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1307 search_text->reposition_window(x1, y1+5, w1);
1308 int dy = search_text->get_h() + 10;
1310 asset_list->reposition_window(x1, y1, w1, h1);
1311 divider->reposition_window(
1312 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1313 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1314 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1315 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1316 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1317 avicon_drawing->reposition_window(fw-avicon_w, fy);
1318 fy += add_tools->get_h(); fh -= add_tools->get_h();
1319 folder_list->reposition_window(fx, fy, fw, fh);
1322 int AWindowGUI::save_defaults(BC_Hash *defaults)
1324 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1325 defaults->update("VICON_DRAWING", vicon_drawing);
1329 int AWindowGUI::load_defaults(BC_Hash *defaults)
1331 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1332 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1336 int AWindowGUI::close_event()
1339 mwindow->session->show_awindow = 0;
1342 mwindow->gui->lock_window("AWindowGUI::close_event");
1343 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1344 mwindow->gui->unlock_window();
1346 lock_window("AWindowGUI::close_event");
1347 save_defaults(mwindow->defaults);
1348 mwindow->save_defaults();
1352 void AWindowGUI::start_vicon_drawing()
1354 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1355 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1356 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1357 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1358 switch( mwindow->edl->session->assetlist_format ) {
1360 case ASSETS_ICONS_PACKED:
1361 case ASSETS_ICON_LIST:
1362 asset_list->update_vicon_area();
1363 vicon_thread->start_drawing();
1371 void AWindowGUI::stop_vicon_drawing()
1373 if( vicon_thread->interrupted ) return;
1374 vicon_thread->stop_drawing();
1377 VFrame *AssetPicon::get_vicon_frame()
1379 if( !vicon ) return 0;
1380 if( gui->vicon_thread->interrupted ) return 0;
1381 VFrame *frame = vicon->frame();
1382 if( !frame ) return 0;
1384 vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model());
1385 vicon_frame->transfer_from(frame);
1389 int AWindowGUI::cycle_assetlist_format()
1391 EDLSession *session = mwindow->edl->session;
1392 int format = ASSETS_TEXT;
1393 if( allow_iconlisting ) {
1394 switch( session->assetlist_format ) {
1396 format = ASSETS_ICONS;
1399 format = ASSETS_ICONS_PACKED;
1401 case ASSETS_ICONS_PACKED:
1402 format = ASSETS_ICON_LIST;
1404 case ASSETS_ICON_LIST:
1405 format = ASSETS_TEXT;
1409 stop_vicon_drawing();
1410 session->assetlist_format = format;
1411 asset_list->update_format(session->assetlist_format, 0);
1412 async_update_assets();
1413 start_vicon_drawing();
1417 AWindowRemovePluginGUI::
1418 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1419 int x, int y, PluginServer *plugin)
1420 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1422 this->awindow = awindow;
1423 this->thread = thread;
1424 this->plugin = plugin;
1425 VFrame *vframe = plugin->get_picon();
1426 icon = vframe ? create_pixmap(vframe) : 0;
1427 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1430 AWindowRemovePluginGUI::
1431 ~AWindowRemovePluginGUI()
1433 if( !awindow->gui->protected_pixmap(icon) )
1435 plugin_list.remove_all();
1438 void AWindowRemovePluginGUI::create_objects()
1440 lock_window("AWindowRemovePluginGUI::create_objects");
1441 BC_Button *ok_button = new BC_OKButton(this);
1442 add_subwindow(ok_button);
1443 BC_Button *cancel_button = new BC_CancelButton(this);
1444 add_subwindow(cancel_button);
1446 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1447 add_subwindow(title);
1448 y += title->get_h() + 5;
1449 list = new BC_ListBox(x, y,
1450 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1451 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1452 add_subwindow(list);
1457 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1460 for( int i=0; i<folder.size(); ) {
1461 AssetPicon *picon = (AssetPicon *)folder[i];
1462 if( picon->plugin == plugin ) {
1463 folder.remove_object_number(i);
1472 void AWindowRemovePlugin::handle_close_event(int result)
1475 printf(_("remove %s\n"), plugin->path);
1476 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1477 ArrayList<BC_ListBoxItem*> *folder =
1478 plugin->audio ? plugin->transition ?
1479 &awindow->gui->atransitions :
1480 &awindow->gui->aeffects :
1481 plugin->video ? plugin->transition ?
1482 &awindow->gui->vtransitions :
1483 &awindow->gui->veffects :
1485 if( folder ) remove_plugin(plugin, *folder);
1486 MWindow *mwindow = awindow->mwindow;
1487 awindow->gui->unlock_window();
1488 char plugin_path[BCTEXTLEN];
1489 strcpy(plugin_path, plugin->path);
1490 mwindow->plugindb->remove(plugin);
1491 remove(plugin_path);
1492 char index_path[BCTEXTLEN];
1493 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1495 char picon_path[BCTEXTLEN];
1497 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1498 File::get_plugin_path());
1499 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1500 plugin->get_plugin_png_name(png_name);
1501 fs.update(picon_path);
1502 for( int i=0; i<fs.dir_list.total; ++i ) {
1503 char *fs_path = fs.dir_list[i]->path;
1504 if( !fs.is_dir(fs_path) ) continue;
1505 snprintf(png_path, sizeof(picon_path), "%s/%s",
1509 delete plugin; plugin = 0;
1510 awindow->gui->async_update_assets();
1514 AWindowRemovePlugin::
1515 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1518 this->awindow = awindow;
1519 this->plugin = plugin;
1522 AWindowRemovePlugin::
1523 ~AWindowRemovePlugin()
1528 BC_Window* AWindowRemovePlugin::new_gui()
1530 int x = awindow->gui->get_abs_cursor_x(0);
1531 int y = awindow->gui->get_abs_cursor_y(0);
1532 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1533 gui->create_objects();
1537 int AWindowGUI::keypress_event()
1539 switch( get_keypress() ) {
1547 if( !ctrl_down() && !shift_down() ) {
1548 assetlist_menu->load_file->handle_event();
1553 return cycle_assetlist_format();
1555 if( shift_down() && ctrl_down() ) {
1556 PluginServer* plugin = selected_plugin();
1557 if( !plugin ) break;
1558 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1560 remove_plugin->start();
1561 lock_window("AWindowGUI::keypress_event 1");
1565 if( shift_down() ) {
1566 mwindow->awindow->asset_remove->start();
1570 mwindow->remove_assets_from_project(1, 1,
1571 mwindow->session->drag_assets,
1572 mwindow->session->drag_clips);
1573 lock_window("AWindowGUI::keypress_event 2");
1579 if( shift_down() && ctrl_down() ) {
1580 resend_event(mwindow->gui);
1590 int AWindowGUI::create_custom_xatoms()
1592 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1595 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1597 if( event->message_type == UpdateAssetsXAtom ) {
1604 void AWindowGUI::async_update_assets()
1607 event.message_type = UpdateAssetsXAtom;
1608 send_custom_xatom(&event);
1612 void AWindowGUI::update_folder_list()
1614 for( int i = 0; i < folders.total; i++ ) {
1615 AssetPicon *picon = (AssetPicon*)folders.values[i];
1619 // Search assets for folders
1620 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1621 BinFolder *bin_folder = mwindow->edl->folders[i];
1624 for( int j = 0; j < folders.total; j++ ) {
1625 AssetPicon *picon = (AssetPicon*)folders[j];
1626 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1634 const char *title = bin_folder->title;
1635 int folder = bin_folder->awindow_folder;
1636 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1637 picon->create_objects();
1638 folders.append(picon);
1642 // Delete unused non-persistent folders
1643 int do_autoplace = 0;
1644 for( int i=folders.total; --i>=0; ) {
1645 AssetPicon *picon = (AssetPicon*)folders.values[i];
1646 if( !picon->in_use && !picon->persistent ) {
1648 folders.remove_number(i);
1653 folder_list->set_autoplacement(&folders, 0, 1);
1656 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1657 int do_audio, int do_video, int is_realtime, int is_transition)
1659 ArrayList<PluginServer*> plugin_list;
1660 // Get pointers to plugindb entries
1661 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1664 for( int i = 0; i < plugin_list.total; i++ ) {
1665 PluginServer *server = plugin_list.values[i];
1666 int visible = plugin_visibility & (1<<server->dir_idx);
1667 if( !visible ) continue;
1668 // Create new listitem
1669 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1670 picon->create_objects();
1671 output->append(picon);
1675 void AWindowGUI::create_label_folder()
1678 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1679 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1680 picon->create_objects();
1681 labellist.append(picon);
1686 void AWindowGUI::update_asset_list()
1688 ArrayList<AssetPicon *> new_assets;
1689 for( int i = 0; i < assets.total; i++ ) {
1690 AssetPicon *picon = (AssetPicon*)assets.values[i];
1694 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1695 // Synchronize EDL clips
1696 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1699 // Look for clip in existing listitems
1700 for( int j = 0; j < assets.total && !exists; j++ ) {
1701 AssetPicon *picon = (AssetPicon*)assets.values[j];
1703 if( picon->id == mwindow->edl->clips[i]->id ) {
1704 picon->edl = mwindow->edl->clips[i];
1705 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1711 // Create new listitem
1713 AssetPicon *picon = new AssetPicon(mwindow,
1714 this, mwindow->edl->clips[i]);
1715 new_assets.append(picon);
1719 // Synchronize EDL assets
1720 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1723 // Look for asset in existing listitems
1724 for( int j = 0; j < assets.total && !exists; j++ ) {
1725 AssetPicon *picon = (AssetPicon*)assets.values[j];
1727 if( picon->id == current->id ) {
1728 picon->indexable = current;
1734 // Create new listitem
1736 AssetPicon *picon = new AssetPicon(mwindow,
1738 new_assets.append(picon);
1742 // Synchronize nested EDLs
1743 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1745 EDL *nested_edl = mwindow->edl->nested_edls[i];
1747 // Look for asset in existing listitems
1748 for( int j=0; j<assets.total && !exists; ++j ) {
1749 AssetPicon *picon = (AssetPicon*)assets.values[j];
1751 if( picon->id == nested_edl->id ) {
1752 picon->indexable = nested_edl;
1758 // Create new listitem
1760 AssetPicon *picon = new AssetPicon(mwindow,
1761 this, (Indexable*)nested_edl);
1762 new_assets.append(picon);
1765 mwindow->gui->unlock_window();
1767 for( int i=0; i<new_assets.size(); ++i ) {
1768 AssetPicon *picon = new_assets[i];
1769 picon->create_objects();
1770 if( picon->indexable )
1771 picon->foldernum = AW_MEDIA_FOLDER;
1772 else if( picon->edl )
1773 picon->foldernum = AW_CLIP_FOLDER;
1774 assets.append(picon);
1777 mwindow->gui->lock_window();
1778 mwindow->gui->default_message();
1779 mwindow->gui->unlock_window();
1781 for( int i = assets.size() - 1; i >= 0; i-- ) {
1782 AssetPicon *picon = (AssetPicon*)assets.get(i);
1783 if( !picon->in_use ) {
1785 assets.remove_number(i);
1788 if( picon->indexable && picon->indexable->is_asset ) {
1790 picon->comments_time = !stat(picon->indexable->path, &st) ?
1796 void AWindowGUI::update_picon(Indexable *indexable)
1799 for( int i = 0; i < assets.total; i++ ) {
1800 AssetPicon *picon = (AssetPicon*)assets.values[i];
1801 if( picon->indexable == indexable ||
1802 picon->edl == (EDL *)indexable ) {
1803 char name[BCTEXTLEN];
1805 fs.extract_name(name, indexable->path);
1806 picon->set_text(name);
1807 vicon = picon->vicon;
1812 stop_vicon_drawing();
1813 vicon->clear_images();
1814 vicon->reset(indexable->get_frame_rate());
1815 start_vicon_drawing();
1819 void AWindowGUI::sort_assets()
1821 folder_lock->lock("AWindowGUI::sort_assets");
1822 switch( mwindow->edl->session->awindow_folder ) {
1823 case AW_AEFFECT_FOLDER:
1824 sort_picons(&aeffects);
1826 case AW_VEFFECT_FOLDER:
1827 sort_picons(&veffects);
1829 case AW_ATRANSITION_FOLDER:
1830 sort_picons(&atransitions);
1832 case AW_VTRANSITION_FOLDER:
1833 sort_picons(&vtransitions);
1835 case AW_LABEL_FOLDER:
1836 sort_picons(&labellist);
1839 sort_picons(&assets);
1843 asset_list->update_format(asset_list->get_format(), 0);
1844 folder_lock->unlock();
1848 void AWindowGUI::sort_folders()
1850 folder_lock->lock("AWindowGUI::update_assets");
1851 // folder_list->collapse_recursive(&folders, 0);
1852 folder_list->set_autoplacement(&folders, 0, 1);
1853 sort_picons(&folders);
1854 folder_list->update_format(folder_list->get_format(), 0);
1855 folder_lock->unlock();
1859 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1861 Asset *proxy_asset = (Asset *)indexable;
1862 char path[BCTEXTLEN];
1863 int proxy_scale = mwindow->edl->session->proxy_scale;
1864 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1865 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1866 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
1867 // make a clip from proxy video tracks and unproxy audio tracks
1868 EDL *proxy_edl = new EDL(mwindow->edl);
1869 proxy_edl->create_objects();
1870 proxy_edl->set_path(proxy_asset->path);
1871 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1872 strcpy(proxy_edl->local_session->clip_title, path);
1873 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1874 proxy_edl->session->video_tracks = proxy_asset->layers;
1875 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1876 proxy_edl->create_default_tracks();
1877 double length = proxy_asset->frame_rate > 0 ?
1878 ( proxy_asset->video_length >= 0 ?
1879 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
1880 ( proxy_edl->session->si_useduration ?
1881 proxy_edl->session->si_duration :
1882 1.0 / proxy_asset->frame_rate ) ) :
1883 1.0 / proxy_edl->session->frame_rate;
1884 Track *current = proxy_edl->tracks->first;
1885 for( int vtrack=0; current; current=NEXT ) {
1886 if( current->data_type != TRACK_VIDEO ) continue;
1887 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1889 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1890 current = proxy_edl->tracks->first;
1891 for( int atrack=0; current; current=NEXT ) {
1892 if( current->data_type != TRACK_AUDIO ) continue;
1893 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1895 proxy_edl->folder_no = AW_PROXY_FOLDER;
1900 void AWindowGUI::collect_assets(int proxy)
1902 mwindow->session->drag_assets->remove_all();
1903 mwindow->session->drag_clips->remove_all();
1904 int i = 0; AssetPicon *result;
1905 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1906 Indexable *indexable = result->indexable;
1907 if( proxy && indexable && indexable->is_asset &&
1908 indexable->folder_no == AW_PROXY_FOLDER ) {
1909 EDL *drag_edl = collect_proxy(indexable);
1910 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
1914 mwindow->session->drag_assets->append(indexable);
1918 mwindow->session->drag_clips->append(result->edl);
1924 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
1926 // Remove current pointers
1927 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
1928 dst[0].remove_all();
1929 dst[1].remove_all_objects();
1931 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
1932 int folder = mwindow->edl->session->awindow_folder;
1933 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
1934 mwindow->edl->get_folder(folder);
1936 // Create new pointers
1937 for( int i = 0; i < src->total; i++ ) {
1938 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
1939 picon = (AssetPicon*)src->values[i];
1940 picon->sort_key = -1;
1941 if( !visible && bin_folder ) {
1942 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
1943 picon->indexable ? picon->indexable :
1944 picon->edl ? picon->edl->get_proxy_asset() : 0;
1946 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
1947 if( picon->sort_key < 0 ) continue;
1951 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
1953 if( !visible && picon->edl && picon->edl->folder_no == folder )
1955 if( visible && sub_items ) {
1956 if( !sub_items->matches(picon->get_text()) )
1960 const char *text = search_text->get_text();
1961 if( text && text[0] )
1962 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
1964 if( visible && picon->vicon && picon->vicon->hidden )
1965 picon->vicon->hidden = 0;
1967 BC_ListBoxItem *item2, *item1;
1968 dst[0].append(item1 = picon);
1970 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1973 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1974 else if( picon->comments_time ) {
1975 char date_time[BCSTRLEN];
1976 struct tm stm; localtime_r(&picon->comments_time, &stm);
1977 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1978 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1979 stm.tm_hour, stm.tm_min, stm.tm_sec);
1980 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1983 dst[1].append(item2 = new BC_ListBoxItem(""));
1984 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1985 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1990 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
1992 int done = 0, changed = 0;
1995 for( int i=0; i<src->total-1; ++i ) {
1996 AssetPicon *item1 = (AssetPicon *)src->values[i];
1997 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1998 double v = item2->sort_key - item1->sort_key;
1999 if( v > 0 ) continue;
2001 const char *cp1 = item1->get_text();
2002 const char *bp1 = strrchr(cp1, '/');
2003 if( bp1 ) cp1 = bp1 + 1;
2004 const char *cp2 = item2->get_text();
2005 const char *bp2 = strrchr(cp2, '/');
2006 if( bp2 ) cp2 = bp2 + 1;
2007 if( strcmp(cp2, cp1) >= 0 ) continue;
2009 src->values[i + 1] = item1;
2010 src->values[i] = item2;
2011 done = 0; changed = 1;
2015 for( int i=0; i<src->total; ++i ) {
2016 AssetPicon *item = (AssetPicon *)src->values[i];
2017 item->set_autoplace_icon(1);
2018 item->set_autoplace_text(1);
2023 void AWindowGUI::filter_displayed_assets()
2025 //allow_iconlisting = 1;
2026 asset_titles[0] = C_("Title");
2027 asset_titles[1] = _("Comments");
2028 AssetPicon *picon = 0;
2029 int selected_folder = mwindow->edl->session->awindow_folder;
2030 // Ensure the current folder icon is highlighted
2031 for( int i = 0; i < folders.total; i++ ) {
2032 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2033 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2034 folder_item->set_selected(selected);
2035 if( selected ) picon = folder_item;
2038 ArrayList<BC_ListBoxItem*> *src = &assets;
2039 switch( selected_folder ) {
2040 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2041 case AW_VEFFECT_FOLDER: src = &veffects; break;
2042 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2043 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2044 case AW_LABEL_FOLDER: src = &labellist;
2045 asset_titles[0] = _("Time Stamps");
2046 asset_titles[1] = C_("Title");
2047 //allow_iconlisting = 0;
2050 copy_picons(picon, src);
2054 void AWindowGUI::update_assets()
2056 stop_vicon_drawing();
2057 folder_lock->lock("AWindowGUI::update_assets");
2058 update_folder_list();
2059 update_asset_list();
2060 labellist.remove_all_objects();
2061 create_label_folder();
2063 if( displayed_folder != mwindow->edl->session->awindow_folder )
2064 search_text->clear();
2065 vicon_thread->hide_vicons();
2066 filter_displayed_assets();
2067 folder_lock->unlock();
2069 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2070 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2072 int folder_xposition = folder_list->get_xposition();
2073 int folder_yposition = folder_list->get_yposition();
2074 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2076 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2077 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2079 int asset_xposition = asset_list->get_xposition();
2080 int asset_yposition = asset_list->get_yposition();
2081 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2082 displayed_folder = mwindow->edl->session->awindow_folder;
2083 asset_xposition = asset_yposition = 0;
2085 asset_list->update(displayed_assets, asset_titles,
2086 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2087 asset_xposition, asset_yposition, -1, 0);
2088 asset_list->center_selection();
2091 start_vicon_drawing();
2095 void AWindowGUI::update_effects()
2097 aeffects.remove_all_objects();
2098 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2099 veffects.remove_all_objects();
2100 create_persistent_folder(&veffects, 0, 1, 1, 0);
2101 atransitions.remove_all_objects();
2102 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2103 vtransitions.remove_all_objects();
2104 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2107 int AWindowGUI::drag_motion()
2109 if( get_hidden() ) return 0;
2115 int AWindowGUI::drag_stop()
2117 if( get_hidden() ) return 0;
2121 Indexable* AWindowGUI::selected_asset()
2123 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2124 return picon ? picon->indexable : 0;
2127 PluginServer* AWindowGUI::selected_plugin()
2129 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2130 return picon ? picon->plugin : 0;
2133 AssetPicon* AWindowGUI::selected_folder()
2135 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2146 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2147 : BC_SubWindow(x, y, w, h)
2149 this->mwindow = mwindow;
2152 AWindowDivider::~AWindowDivider()
2156 int AWindowDivider::button_press_event()
2158 if( is_event_win() && cursor_inside() ) {
2159 mwindow->session->current_operation = DRAG_PARTITION;
2165 int AWindowDivider::cursor_motion_event()
2167 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2169 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2170 int fw = gui->get_relative_cursor_x();
2171 if( fw > wmax ) fw = wmax;
2172 if( fw < wmin ) fw = wmin;
2173 mwindow->session->afolders_w = fw;
2174 mwindow->theme->get_awindow_sizes(gui);
2175 gui->reposition_objects();
2181 int AWindowDivider::button_release_event()
2183 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2184 mwindow->session->current_operation = NO_OPERATION;
2195 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2196 : BC_ListBox(x, y, w, h,
2197 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2198 LISTBOX_ICONS : LISTBOX_TEXT,
2199 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2200 0, // Titles for columns. Set to 0 for no titles
2201 0, // width of each column
2202 1, // Total columns.
2203 0, // Pixel of top of window.
2204 0, // If this listbox is a popup window
2205 LISTBOX_SINGLE, // Select one item or multiple items
2206 ICON_TOP, // Position of icon relative to text of each item
2209 this->mwindow = mwindow;
2216 AWindowFolders::~AWindowFolders()
2220 int AWindowFolders::selection_changed()
2222 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2223 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2224 // prefer expanded entry
2225 AWindowFolderItem *item = item1 ? item1 : item0;
2226 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2227 item1->set_selected(0);
2234 AssetPicon *picon = item->get_picon();
2235 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2237 gui->stop_vicon_drawing();
2239 if( get_button_down() && get_buttonpress() == 3 ) {
2240 gui->folderlist_menu->update_titles();
2241 gui->folderlist_menu->activate_menu();
2244 mwindow->edl->session->awindow_folder = picon->foldernum;
2245 gui->asset_list->draw_background();
2246 gui->async_update_assets();
2248 gui->start_vicon_drawing();
2253 int AWindowFolders::button_press_event()
2257 result = BC_ListBox::button_press_event();
2260 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2261 gui->folderlist_menu->update_titles();
2262 gui->folderlist_menu->activate_menu();
2271 int AWindowFolders::drag_stop()
2274 if( get_hidden() ) return 0;
2275 if( mwindow->session->current_operation == DRAG_ASSET &&
2276 gui->folder_list->cursor_above() ) { // check user folder
2277 int item_no = gui->folder_list->get_cursor_data_item_no();
2278 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2279 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2280 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2281 ArrayList<Indexable *> *drags = folder->is_clips ?
2282 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2283 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2284 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2286 mwindow->session->current_operation = ::NO_OPERATION;
2293 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2294 : AWindowFolderItem(text)
2296 this->parent = parent;
2299 int AWindowFolders::load_expanders()
2301 char expanders_path[BCTEXTLEN];
2302 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2303 FILE *fp = fopen(expanders_path, "r");
2305 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2306 File::get_cindat_path(), EXPANDERS_FILE);
2307 fp = fopen(expanders_path, "r");
2311 const char tab = '\t';
2312 char line[BCTEXTLEN]; line[0] = 0;
2313 AWindowFolderItem *item = 0, *parent;
2314 AWindowFolderSubItems *sub_items = 0;
2316 while( fgets(line,sizeof(line),fp) ) {
2317 if( line[0] == '#' ) continue;
2318 int i = strlen(line);
2319 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2320 if( i == 0 ) continue;
2322 for( char *cp=line; *cp==tab; ++cp ) ++i;
2324 int i = gui->folders.size();
2326 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2327 if( !strcmp(folder->get_text(),_(line)) ) break;
2329 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2334 if( i > k+1 ) continue;
2336 if( line[i] != '-' && sub_items ) {
2337 sub_items->names.append(cstrdup(_(&line[i])));
2345 item = item->parent;
2348 parent = item->parent;
2350 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2351 if( !sublist ) sublist = parent->new_sublist(1);
2352 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2353 sublist->append(item = sub_items);
2360 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2361 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2362 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2363 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2364 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2366 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2367 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2368 mwindow->edl->session->asset_columns, // width of each column
2369 1, // Total columns.
2370 0, // Pixel of top of window.
2371 0, // If this listbox is a popup window
2372 LISTBOX_MULTIPLE, // Select one item or multiple items
2373 ICON_TOP, // Position of icon relative to text of each item
2374 -1) // Allow drags, require shift for scrolling
2376 this->mwindow = mwindow;
2379 set_scroll_stretch(1, 1);
2383 AWindowAssets::~AWindowAssets()
2387 int AWindowAssets::button_press_event()
2391 result = BC_ListBox::button_press_event();
2393 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2394 BC_ListBox::deactivate_selection();
2395 int folder = mwindow->edl->session->awindow_folder;
2397 case AW_AEFFECT_FOLDER:
2398 case AW_VEFFECT_FOLDER:
2399 case AW_ATRANSITION_FOLDER:
2400 case AW_VTRANSITION_FOLDER:
2401 gui->effectlist_menu->update();
2402 gui->effectlist_menu->activate_menu();
2404 case AW_LABEL_FOLDER:
2405 gui->labellist_menu->update();
2406 gui->labellist_menu->activate_menu();
2408 case AW_CLIP_FOLDER:
2409 gui->cliplist_menu->update();
2410 gui->cliplist_menu->activate_menu();
2412 case AW_PROXY_FOLDER:
2413 gui->proxylist_menu->update();
2414 gui->proxylist_menu->activate_menu();
2417 case AW_MEDIA_FOLDER: {
2418 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2419 gui->assetlist_menu->update_titles(shots);
2420 gui->assetlist_menu->activate_menu();
2430 int AWindowAssets::handle_event()
2432 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2433 if( !asset_picon ) return 0;
2434 Indexable *picon_idxbl = asset_picon->indexable;
2435 EDL *picon_edl = asset_picon->edl;
2437 VWindow *vwindow = 0;
2438 switch( mwindow->edl->session->awindow_folder ) {
2439 case AW_AEFFECT_FOLDER:
2440 case AW_VEFFECT_FOLDER:
2441 case AW_ATRANSITION_FOLDER:
2442 case AW_VTRANSITION_FOLDER: return 1;
2443 case AW_PROXY_FOLDER:
2444 proxy = 1; // fall thru
2446 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2447 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2450 if( !vwindow || !vwindow->is_running() ) return 1;
2451 if( proxy && picon_idxbl ) {
2452 picon_edl = gui->collect_proxy(picon_idxbl);
2456 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2457 else if( picon_edl ) vwindow->change_source(picon_edl);
2461 int AWindowAssets::selection_changed()
2463 // Show popup window
2465 if( get_button_down() && get_buttonpress() == 3 &&
2466 (item = (AssetPicon*)get_selection(0, 0)) ) {
2467 int folder = mwindow->edl->session->awindow_folder;
2469 case AW_AEFFECT_FOLDER:
2470 case AW_VEFFECT_FOLDER:
2471 case AW_ATRANSITION_FOLDER:
2472 case AW_VTRANSITION_FOLDER:
2473 gui->effectlist_menu->update();
2474 gui->effectlist_menu->activate_menu();
2476 case AW_LABEL_FOLDER:
2477 if( !item->label ) break;
2478 gui->label_menu->activate_menu();
2480 case AW_CLIP_FOLDER:
2481 if( !item->indexable && !item->edl ) break;
2482 gui->clip_menu->update();
2483 gui->clip_menu->activate_menu();
2485 case AW_PROXY_FOLDER:
2486 if( !item->indexable && !item->edl ) break;
2487 gui->proxy_menu->update();
2488 gui->proxy_menu->activate_menu();
2491 if( !item->indexable && !item->edl ) break;
2492 gui->asset_menu->update();
2493 gui->asset_menu->activate_menu();
2497 deactivate_selection();
2499 else if( gui->vicon_drawing && get_button_down() &&
2500 ( get_buttonpress() == 1 || get_buttonpress() == 2 ) &&
2501 ( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
2502 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
2503 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) &&
2504 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2506 if( !gui->vicon_thread->vicon ) {
2507 vicon = item->vicon;
2509 if( vicon && get_buttonpress() == 2 ) {
2510 vicon->playing_audio = -1;
2511 draw_func = AWindowAssets::draw_vframe;
2515 gui->vicon_thread->set_view_popup(vicon, draw_func);
2520 void AWindowAssets::draw_vframe(BC_WindowBase *wdw, VFrame *vframe)
2522 int y1 = VIEW_POPUP_BAR_H;
2523 int y2 = wdw->get_h()-VIEW_POPUP_BAR_H;
2524 wdw->set_color(BLACK);
2525 wdw->draw_box(0,0,wdw->get_w(),wdw->get_h());
2526 wdw->draw_vframe(vframe, 0,y1, wdw->get_w(),y2-y1);
2527 ViewPopup *view_popup = (ViewPopup *)wdw;
2528 VIconThread *vt = view_popup->vt;
2529 AssetVIcon *vicon = (AssetVIcon *)vt->vicon;
2530 AssetPicon *picon = (AssetPicon *)vicon->picon;
2532 picon->indexable ? picon->indexable :
2533 picon->edl ? picon->edl : 0;
2534 if( !idxbl ) return;
2535 double sample_rate = idxbl->get_sample_rate();
2536 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
2537 idxbl->get_audio_samples() / sample_rate : 0;
2538 double frame_rate = idxbl->get_frame_rate();
2539 double video_length = frame_rate > 0 && idxbl->have_video() ?
2540 idxbl->get_video_frames() / frame_rate : 0;
2541 double idxbl_length = bmax(audio_length, video_length);
2542 if( !idxbl_length ) idxbl_length = 1;
2544 EDL *edl = picon->mwindow->edl;
2545 double total_length = edl->tracks->total_length();
2546 if( !total_length ) total_length = 1;
2547 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
2548 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
2549 Indexable *indexable = (Indexable *)edit->asset;
2550 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
2551 if( !indexable ) continue;
2552 if( indexable->id == idxbl->id ||
2553 (!indexable->is_asset == !idxbl->is_asset &&
2554 !strcmp(indexable->path, idxbl->path)) ) {
2555 double pos1 = track->from_units(edit->startsource);
2556 double pos2 = track->from_units(edit->startsource + edit->length);
2557 double xscale = wdw->get_w() / idxbl_length;
2558 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
2559 wdw->set_color(WHITE);
2560 wdw->draw_box(ex1,0, ex2-ex1,y1);
2561 wdw->set_color(BLACK);
2562 wdw->draw_line(ex1,0, ex1,y1);
2563 wdw->draw_line(ex2,0, ex2,y1);
2564 pos1 = track->from_units(edit->startproject);
2565 pos2 = track->from_units(edit->startproject + edit->length);
2566 xscale = wdw->get_w() / total_length;
2567 int px1 = pos1 * xscale, px2 = pos2 * xscale;
2568 wdw->set_color(RED);
2569 wdw->draw_box(px1,y2, px2-px1,wdw->get_h()-y2);
2570 wdw->set_color(BLACK);
2571 wdw->draw_line(px1,y2, px1,wdw->get_h()-1);
2572 wdw->draw_line(px2,y2, px2,wdw->get_h()-1);
2574 wdw->set_color(YELLOW);
2575 wdw->draw_line(ex1,y1, px1,y2);
2576 wdw->draw_line(ex2,y1, px2,y2);
2582 void AWindowAssets::draw_background()
2584 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2585 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2586 set_font(LARGEFONT);
2587 int folder = mwindow->edl->session->awindow_folder;
2588 const char *title = mwindow->edl->get_folder_name(folder);
2589 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2590 title, -1, get_bg_surface());
2593 int AWindowAssets::drag_start_event()
2595 int collect_pluginservers = 0;
2596 int collect_assets = 0, proxy = 0;
2598 if( BC_ListBox::drag_start_event() ) {
2599 switch( mwindow->edl->session->awindow_folder ) {
2600 case AW_AEFFECT_FOLDER:
2601 mwindow->session->current_operation = DRAG_AEFFECT;
2602 collect_pluginservers = 1;
2604 case AW_VEFFECT_FOLDER:
2605 mwindow->session->current_operation = DRAG_VEFFECT;
2606 collect_pluginservers = 1;
2608 case AW_ATRANSITION_FOLDER:
2609 mwindow->session->current_operation = DRAG_ATRANSITION;
2610 collect_pluginservers = 1;
2612 case AW_VTRANSITION_FOLDER:
2613 mwindow->session->current_operation = DRAG_VTRANSITION;
2614 collect_pluginservers = 1;
2616 case AW_LABEL_FOLDER:
2619 case AW_PROXY_FOLDER:
2620 proxy = 1; // fall thru
2621 case AW_MEDIA_FOLDER:
2623 mwindow->session->current_operation = DRAG_ASSET;
2628 if( collect_pluginservers ) {
2630 mwindow->session->drag_pluginservers->remove_all();
2633 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2634 if( !result ) break;
2636 mwindow->session->drag_pluginservers->append(result->plugin);
2640 if( collect_assets ) {
2641 gui->collect_assets(proxy);
2649 int AWindowAssets::drag_motion_event()
2651 BC_ListBox::drag_motion_event();
2654 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2655 mwindow->gui->drag_motion();
2656 mwindow->gui->unlock_window();
2658 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2659 VWindow *vwindow = mwindow->vwindows.get(i);
2660 if( !vwindow->is_running() ) continue;
2661 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2662 vwindow->gui->drag_motion();
2663 vwindow->gui->unlock_window();
2666 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2667 mwindow->cwindow->gui->drag_motion();
2668 mwindow->cwindow->gui->unlock_window();
2670 lock_window("AWindowAssets::drag_motion_event");
2671 if( mwindow->session->current_operation == DRAG_ASSET &&
2672 gui->folder_list->cursor_above() ) { // highlight user folder
2673 BC_ListBoxItem *item = 0;
2674 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2675 if( item_no >= 0 ) {
2676 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2677 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2680 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2681 int folder_xposition = gui->folder_list->get_xposition();
2682 int folder_yposition = gui->folder_list->get_yposition();
2683 gui->folder_list->update(&gui->folders, 0, 0, 1,
2684 folder_xposition, folder_yposition, item_no, 0, 1);
2689 int AWindowAssets::drag_stop_event()
2693 result = gui->drag_stop();
2698 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2699 result = mwindow->gui->drag_stop();
2700 mwindow->gui->unlock_window();
2704 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2705 VWindow *vwindow = mwindow->vwindows.get(i);
2706 if( !vwindow ) continue;
2707 if( !vwindow->is_running() ) continue;
2708 if( vwindow->gui->is_hidden() ) continue;
2709 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2710 if( vwindow->gui->cursor_above() &&
2711 vwindow->gui->get_cursor_over_window() ) {
2712 result = vwindow->gui->drag_stop();
2714 vwindow->gui->unlock_window();
2719 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2720 result = mwindow->cwindow->gui->drag_stop();
2721 mwindow->cwindow->gui->unlock_window();
2724 lock_window("AWindowAssets::drag_stop_event");
2726 result = gui->folder_list->drag_stop();
2731 get_drag_popup()->set_animation(0);
2733 BC_ListBox::drag_stop_event();
2734 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2735 mwindow->session->current_operation = ::NO_OPERATION;
2740 int AWindowAssets::column_resize_event()
2742 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2743 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2747 int AWindowAssets::focus_in_event()
2749 int ret = BC_ListBox::focus_in_event();
2750 gui->start_vicon_drawing();
2754 int AWindowAssets::focus_out_event()
2756 gui->stop_vicon_drawing();
2757 return BC_ListBox::focus_out_event();
2760 int AWindowAssets::cursor_enter_event()
2762 int ret = BC_ListBox::cursor_enter_event();
2763 gui->start_vicon_drawing();
2767 int AWindowAssets::cursor_leave_event()
2769 VIcon *vicon = gui->vicon_thread->vicon;
2770 if( vicon && vicon->playing_audio >= 0 )
2771 gui->stop_vicon_drawing();
2772 return BC_ListBox::cursor_leave_event();
2775 void AWindowAssets::update_vicon_area()
2777 int x0 = 0, x1 = get_w();
2778 int y0 = get_title_h();
2780 if( is_highlighted() ) {
2781 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2782 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2784 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2787 int AWindowAssets::mouse_over_event(int no)
2789 if( gui->vicon_thread->viewing &&
2790 no >= 0 && no < gui->displayed_assets[0].size() ) {
2791 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2792 VIcon *vicon = picon->vicon;
2793 if( gui->vicon_thread->vicon &&
2794 gui->vicon_thread->vicon->playing_audio < 0 )
2795 vicon->playing_audio = -1;
2796 picon->gui->vicon_thread->set_view_popup(vicon, draw_func);
2802 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2803 : BC_TextBox(x, y, w, 1, "")
2805 this->search_text = search_text;
2808 int AWindowSearchTextBox::handle_event()
2810 return search_text->handle_event();
2813 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2815 this->mwindow = mwindow;
2821 void AWindowSearchText::create_objects()
2823 int x1 = x, y1 = y, margin = 10;
2824 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2825 x1 += text_title->get_w() + margin;
2826 int w1 = gui->get_w() - x1 - 2*margin;
2827 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2830 int AWindowSearchText::handle_event()
2832 gui->async_update_assets();
2836 int AWindowSearchText::get_w()
2838 return text_box->get_w() + text_title->get_w() + 10;
2841 int AWindowSearchText::get_h()
2843 return bmax(text_box->get_h(),text_title->get_h());
2846 void AWindowSearchText::reposition_window(int x, int y, int w)
2848 int x1 = x, y1 = y, margin = 10;
2849 text_title->reposition_window(x1, y1);
2850 x1 += text_title->get_w() + margin;
2851 int w1 = gui->get_w() - x1 - 2*margin;
2852 text_box->reposition_window(x1, y1, w1);
2855 const char *AWindowSearchText::get_text()
2857 return text_box->get_text();
2860 void AWindowSearchText::clear()
2862 text_box->update("");
2865 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2866 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2868 this->mwindow = mwindow;
2870 set_tooltip(_("Delete asset from disk"));
2873 int AWindowDeleteDisk::handle_event()
2878 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2879 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2881 this->mwindow = mwindow;
2883 set_tooltip(_("Delete asset from project"));
2886 int AWindowDeleteProject::handle_event()
2891 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2892 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2894 // this->mwindow = mwindow;
2896 // set_tooltip(_("Edit information on asset"));
2899 // int AWindowInfo::handle_event()
2901 // int cur_x, cur_y;
2902 // gui->get_abs_cursor(cur_x, cur_y, 0);
2903 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2907 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2908 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2910 this->mwindow = mwindow;
2912 set_tooltip(_("Redraw index"));
2915 int AWindowRedrawIndex::handle_event()
2920 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2921 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2923 this->mwindow = mwindow;
2925 set_tooltip(_("Paste asset on recordable tracks"));
2928 int AWindowPaste::handle_event()
2933 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2934 : BC_Button(x, y, mwindow->theme->appendasset_data)
2936 this->mwindow = mwindow;
2938 set_tooltip(_("Append asset in new tracks"));
2941 int AWindowAppend::handle_event()
2946 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2947 : BC_Button(x, y, mwindow->theme->viewasset_data)
2949 this->mwindow = mwindow;
2951 set_tooltip(_("View asset"));
2954 int AWindowView::handle_event()
2959 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2960 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2962 this->mwindow = mwindow;
2966 void AddTools::create_objects()
2969 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2970 vis |= 1 << PLUGIN_FFMPEG_ID;
2971 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2972 vis |= 1 << PLUGIN_LADSPA_ID;
2974 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
2975 vis |= 1 << PLUGIN_LV2_ID;
2977 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2978 PluginServer *plugin = MWindow::plugindb->get(i);
2979 if( !plugin->audio && !plugin->video ) continue;
2980 int idx = plugin->dir_idx;
2981 uint32_t msk = 1 << idx;
2982 if( (msk & vis) != 0 ) continue;
2984 char parent[BCTEXTLEN];
2985 strcpy(parent, plugin->path);
2986 char *bp = strrchr(parent, '/');
2987 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2988 if( !bp ) bp = parent; else ++bp;
2989 add_item(new AddPluginItem(this, bp, idx));
2994 // plugin_dirs list from toplevel makefile include plugin_defs
2999 N_("audio_transitions")
3006 N_("video_transitions")
3009 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3010 : BC_MenuItem(_(text))
3014 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3015 int chk = (msk & vis) ? 1 : 0;
3019 int AddPluginItem::handle_event()
3021 int chk = get_checked() ^ 1;
3023 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3024 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3025 menu->gui->update_effects();
3026 menu->gui->save_defaults(menu->mwindow->defaults);
3027 menu->gui->async_update_assets();
3031 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3032 : BC_Toggle(x, y, images, agui->vicon_drawing)
3035 set_tooltip(_("Preview"));
3038 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3040 int text_line = -1, toggle_x = -1, toggle_y = -1;
3041 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3042 BC_Toggle::calculate_extents(agui, images, 1,
3043 &text_line, ww, hh, &toggle_x, &toggle_y,
3044 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3047 AVIconDrawing::~AVIconDrawing()
3051 int AVIconDrawing::handle_event()
3053 agui->vicon_drawing = get_value();
3054 if( agui->vicon_drawing )
3055 agui->start_vicon_drawing();
3057 agui->stop_vicon_drawing();
3062 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3063 : BC_MenuItem("","v",'v')
3065 this->mwindow = mwindow;
3069 int AWindowListFormat::handle_event()
3071 return gui->cycle_assetlist_format();
3074 void AWindowListFormat::update()
3076 EDLSession *session = mwindow->edl->session;
3077 const char *text = 0;
3078 switch( session->assetlist_format ) {
3080 text = _("Display icons");
3083 text = _("Display icons packed");
3085 case ASSETS_ICONS_PACKED:
3086 text = _("Display icon list");
3088 case ASSETS_ICON_LIST:
3089 text = _("Display text");
3095 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3096 : BC_MenuItem(_("Sort items"))
3098 this->mwindow = mwindow;
3102 int AWindowListSort::handle_event()
3108 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3111 this->select_used = select_used;
3112 this->action = action;
3115 int AssetSelectUsedItem::handle_event()
3117 MWindow *mwindow = select_used->mwindow;
3118 AWindowGUI *gui = select_used->gui;
3119 AWindowAssets *asset_list = gui->asset_list;
3120 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3125 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3129 asset_list->set_all_selected(data, 0);
3130 for( int i = 0; i < data->total; i++ ) {
3131 AssetPicon *picon = (AssetPicon*)data->values[i];
3132 Indexable *idxbl = picon->indexable ? picon->indexable :
3133 picon->edl ? picon->edl->get_proxy_asset() : 0;
3134 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3135 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3140 int asset_xposition = asset_list->get_xposition();
3141 int asset_yposition = asset_list->get_yposition();
3142 asset_list->update(gui->displayed_assets, gui->asset_titles,
3143 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3144 asset_xposition, asset_yposition, -1, 0);
3145 asset_list->center_selection();
3149 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3150 : BC_MenuItem(_("Select"))
3152 this->mwindow = mwindow;