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"
27 #include "audiodevice.h"
28 #include "awindowgui.h"
30 #include "bccmodels.h"
31 #include "bcsignals.h"
33 #include "binfolder.h"
38 #include "clippopup.h"
40 #include "cwindowgui.h"
43 #include "edlsession.h"
44 #include "effectlist.h"
46 #include "filesystem.h"
47 #include "folderlistmenu.h"
48 #include "indexable.h"
52 #include "labelpopup.h"
53 #include "localsession.h"
55 #include "mainsession.h"
56 #include "mwindowgui.h"
58 #include "preferences.h"
60 #include "proxypopup.h"
61 #include "renderengine.h"
65 #include "transportque.h"
69 #include "vwindowgui.h"
72 #include "data/lad_picon_png.h"
73 #include "data/ff_audio_png.h"
74 #include "data/ff_video_png.h"
81 const char *AWindowGUI::folder_names[] =
85 N_("Audio Transitions"),
86 N_("Video Transitions"),
94 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
95 : VIcon(w, h, framerate)
98 this->length = length;
102 AssetVIcon::~AssetVIcon()
107 VFrame *AssetVIcon::frame()
109 Asset *asset = (Asset *)picon->indexable;
110 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
111 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
113 int sample_rate = asset->get_sample_rate();
114 int64_t audio_samples = asset->get_audio_samples();
115 double duration = (double)audio_samples / sample_rate;
116 picon->draw_hue_bar(temp, duration);
117 int secs = length / frame_rate + 0.5;
118 if( !secs ) secs = 1;
119 int bfrsz = VICON_SAMPLE_RATE;
120 int samples = audio_size/sizeof(vicon_audio_t);
121 double line_pos = (double)seq_no/(length-1);
122 int audio_pos = samples * line_pos * (secs-1)/secs;
123 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
124 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
125 double data[bfrsz], sample_scale = 1./mx;
126 int len = samples - audio_pos;
127 if( len > bfrsz ) len = bfrsz;
129 while( i < len ) data[i++] = *audio_data++ * sample_scale;
130 while( i < bfrsz ) data[i++] = 0;
131 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
132 int x = (vw-1) * line_pos;
133 temp->pixel_rgb = RED;
134 temp->draw_line(x,0, x,vh);
137 int ww = picon->gui->vicon_thread->view_w;
138 int hh = picon->gui->vicon_thread->view_h;
139 if( !asset->video_data ) {
141 temp = new VFrame(0, -1, ww, hh, BC_RGB888, -1);
146 if( seq_no >= images.size() ) {
147 MWindow *mwindow = picon->mwindow;
148 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
149 if( !file ) return 0;
150 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
151 delete temp; temp = 0;
154 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
155 while( seq_no >= images.size() ) {
157 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
158 file->set_video_position(pos,0);
159 if( file->read_frame(temp) ) temp->clear_frame();
160 add_image(temp, ww, hh, BC_RGB8);
162 mwindow->video_cache->check_in(asset);
164 return *images[seq_no];
167 int64_t AssetVIcon::set_seq_no(int64_t no)
169 if( no >= length ) no = 0;
173 int AssetVIcon::get_vx()
175 BC_ListBox *lbox = picon->gui->asset_list;
176 return lbox->get_icon_x(picon);
178 int AssetVIcon::get_vy()
180 BC_ListBox *lbox = picon->gui->asset_list;
181 return lbox->get_icon_y(picon);
184 void AssetVIcon::load_audio()
186 MWindow *mwindow = picon->mwindow;
187 Asset *asset = (Asset *)picon->indexable;
188 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
189 int channels = asset->get_audio_channels();
190 if( channels > 2 ) channels = 2;
191 int sample_rate = asset->get_sample_rate();
192 int bfrsz = sample_rate;
193 Samples samples(bfrsz);
194 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
195 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
196 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
197 double sample_scale = (double)mx / channels;
198 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
199 while( audio_pos < audio_len ) {
200 int64_t pos = audio_pos * time_scale;
201 for( int ch=0; ch<channels; ++ch ) {
202 file->set_channel(ch);
203 file->set_audio_position(pos);
204 file->read_samples(&samples, bfrsz);
205 double *data = samples.get_data();
206 for( int64_t k=audio_pos; k<audio_len; ++k ) {
207 int i = k * time_scale - pos;
208 if( i >= bfrsz ) break;
209 int v = audio_data[k] + data[i] * sample_scale;
210 audio_data[k] = CLIP(v, -mx,mx);
213 audio_pos = (pos + bfrsz) / time_scale;
215 mwindow->audio_cache->check_in(asset);
219 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
223 audio = new AudioDevice(gui->mwindow);
227 AssetVIconAudio::~AssetVIconAudio()
232 void AssetVIconAudio::run()
235 int64_t bfrsz = VICON_SAMPLE_RATE;
236 MWindow *mwindow = gui->mwindow;
237 EDL *edl = mwindow->edl;
238 EDLSession *session = edl->session;
239 AudioOutConfig *aconfig = session->playback_config->aconfig;
240 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
241 audio->start_playback();
242 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
243 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
244 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
246 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
247 while( !interrupted ) {
248 int len = audio_len - audio_pos;
249 if( len <= 0 ) break;
250 if( len > bfrsz ) len = bfrsz;
252 for( int i=0; i<len; ++i,++k )
253 out0[i] = out1[i] = (double)audio_data[k] / mx;
255 audio->write_buffer(out, channels, len);
259 audio->set_last_buffer();
260 audio->stop_audio(interrupted ? 0 : 1);
264 void AssetVIconAudio::start(AssetVIcon *vicon)
266 if( running() ) return;
273 void AssetVIconAudio::stop(int wait)
275 if( running() && !interrupted ) {
277 audio->stop_audio(wait);
281 vicon->playing_audio = 0;
286 void AssetVIcon::start_audio()
288 picon->gui->vicon_audio->stop(0);
290 picon->gui->vicon_audio->start(this);
293 void AssetVIcon::stop_audio()
295 picon->gui->vicon_audio->stop(0);
299 AssetPicon::AssetPicon(MWindow *mwindow,
300 AWindowGUI *gui, Indexable *indexable)
304 this->mwindow = mwindow;
306 this->indexable = indexable;
307 indexable->add_user();
308 this->id = indexable->id;
311 AssetPicon::AssetPicon(MWindow *mwindow,
312 AWindowGUI *gui, EDL *edl)
316 this->mwindow = mwindow;
323 AssetPicon::AssetPicon(MWindow *mwindow,
324 AWindowGUI *gui, int folder, int persist)
325 : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
326 folder>=0 && folder<AWINDOW_FOLDERS ?
327 gui->folder_icons[folder]: gui->folder_icon)
331 this->mwindow = mwindow;
333 persistent = persist;
336 AssetPicon::AssetPicon(MWindow *mwindow,
337 AWindowGUI *gui, int folder, const char *title)
338 : BC_ListBoxItem(title, gui->folder_icon)
342 this->mwindow = mwindow;
347 AssetPicon::AssetPicon(MWindow *mwindow,
348 AWindowGUI *gui, PluginServer *plugin)
352 this->mwindow = mwindow;
354 this->plugin = plugin;
357 AssetPicon::AssetPicon(MWindow *mwindow,
358 AWindowGUI *gui, Label *label)
362 this->mwindow = mwindow;
370 AssetPicon::~AssetPicon()
373 gui->vicon_thread->del_vicon(vicon);
375 if( indexable ) indexable->remove_user();
376 if( edl ) edl->remove_user();
377 if( icon && !gui->protected_pixmap(icon) ) {
379 if( !plugin ) delete icon_vframe;
383 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
385 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
387 float h = 300 * t, s = 1., v = 1.;
388 float r, g, b; // duration, 0..1hr == hue red..magenta
389 HSV::hsv_to_rgb(r,g,b, h,s,v);
390 int ih = frame->get_h()/8, iw = frame->get_w();
391 int ir = r * 256; CLAMP(ir, 0,255);
392 int ig = g * 256; CLAMP(ig, 0,255);
393 int ib = b * 256; CLAMP(ib, 0,255);
394 unsigned char **rows = frame->get_rows();
395 for( int y=0; y<ih; ++y ) {
396 unsigned char *rp = rows[y];
397 for( int x=0; x<iw; rp+=3,++x ) {
398 rp[0] = ir; rp[1] = ig; rp[2] = ib;
403 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len, int base_color, int line_color)
405 int w = frame->get_w(), h = frame->get_h();
406 int h1 = h-1, h2 = h/2, y = h2;
407 int rgb_color = frame->pixel_rgb;
408 for( int x=0,x1=0,x2=0; x<w; ++x,x1=x2 ) {
409 double min = *dp, max = min;
410 x2 = (len * (x+1))/w;
411 for( int i=x1; i<x2; ++i ) {
412 double value = *dp++;
413 if( value < min ) min = value;
414 if( value > max ) max = value;
416 int ctr = (min + max) / 2;
417 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
418 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
419 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
420 frame->pixel_rgb = line_color;
421 frame->draw_line(x,y1, x,y2);
422 frame->pixel_rgb = base_color;
423 frame->draw_line(x,y, x,y0);
426 frame->pixel_rgb = rgb_color;
429 void AssetPicon::reset()
435 foldernum = AW_NO_FOLDER;
447 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
449 TransportCommand command;
450 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
451 command.get_edl()->copy_all(edl);
452 command.change_type = CHANGE_ALL;
453 command.realtime = 0;
454 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
455 render_engine->set_vcache(mwindow->video_cache);
456 render_engine->set_acache(mwindow->audio_cache);
457 render_engine->arm_command(&command);
459 void AssetPicon::close_render_engine()
461 delete render_engine; render_engine = 0;
463 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
465 if( !render_engine || !render_engine->vrender ) return;
466 render_engine->vrender->process_buffer(vfrm, pos, 0);
468 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
470 if( !render_engine || !render_engine->arender ) return;
471 render_engine->arender->process_buffer(samples, len, pos);
474 void AssetPicon::create_objects()
477 char name[BCTEXTLEN];
478 int pixmap_w, pixmap_h;
480 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
483 fs.extract_name(name, indexable->path);
487 set_text(strcpy(name, edl->local_session->clip_title));
491 if( indexable && indexable->is_asset ) {
492 Asset *asset = (Asset*)indexable;
493 if( asset->video_data ) {
494 if( mwindow->preferences->use_thumbnails ) {
495 gui->unlock_window();
496 File *file = mwindow->video_cache->check_out(asset,
501 int height = asset->height > 0 ? asset->height : 1;
502 pixmap_w = pixmap_h * asset->width / height;
505 file->set_video_position(0, 0);
507 if( gui->temp_picon &&
508 (gui->temp_picon->get_w() != asset->width ||
509 gui->temp_picon->get_h() != asset->height) ) {
510 delete gui->temp_picon;
514 if( !gui->temp_picon ) {
515 gui->temp_picon = new VFrame(0, -1,
516 asset->width, asset->height,
519 { char string[BCTEXTLEN];
520 sprintf(string, _("Reading %s"), name);
521 mwindow->gui->lock_window("AssetPicon::create_objects");
522 mwindow->gui->show_message(string);
523 mwindow->gui->unlock_window(); }
524 file->read_frame(gui->temp_picon);
525 mwindow->video_cache->check_in(asset);
527 gui->lock_window("AssetPicon::create_objects 0");
528 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
529 icon->draw_vframe(gui->temp_picon,
530 0, 0, pixmap_w, pixmap_h, 0, 0);
531 icon_vframe = new VFrame(0,
532 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
533 icon_vframe->transfer_from(gui->temp_picon);
534 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
536 double framerate = asset->get_frame_rate();
537 if( !framerate ) framerate = VICON_RATE;
538 int64_t frames = asset->get_video_frames();
539 double secs = frames / framerate;
540 if( secs > 5 ) secs = 5;
541 int64_t length = secs * gui->vicon_thread->refresh_rate;
542 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
543 if( asset->audio_data && secs > 0 ) {
544 gui->unlock_window();
545 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
546 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
548 gui->lock_window("AssetPicon::create_objects 1");
550 gui->vicon_thread->add_vicon(vicon);
555 gui->lock_window("AssetPicon::create_objects 2");
556 icon = gui->video_icon;
557 icon_vframe = gui->video_vframe;
561 icon = gui->video_icon;
562 icon_vframe = gui->video_vframe;
566 if( asset->audio_data ) {
567 if( mwindow->preferences->use_thumbnails ) {
568 gui->unlock_window();
569 File *file = mwindow->audio_cache->check_out(asset,
573 pixmap_w = pixmap_h * 16/9;
574 icon_vframe = new VFrame(0,
575 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
576 icon_vframe->clear_frame();
577 { char string[BCTEXTLEN];
578 sprintf(string, _("Reading %s"), name);
579 mwindow->gui->lock_window("AssetPicon::create_objects 3");
580 mwindow->gui->show_message(string);
581 mwindow->gui->unlock_window(); }
582 int sample_rate = asset->get_sample_rate();
583 int channels = asset->get_audio_channels();
584 if( channels > 2 ) channels = 2;
585 int64_t audio_samples = asset->get_audio_samples();
586 double duration = (double)audio_samples / sample_rate;
587 draw_hue_bar(icon_vframe, duration);
588 int bfrsz = sample_rate;
589 Samples samples(bfrsz);
590 static int line_colors[2] = { GREEN, YELLOW };
591 static int base_colors[2] = { RED, PINK };
592 for( int i=channels; --i>=0; ) {
593 file->set_channel(i);
594 file->set_audio_position(0);
595 file->read_samples(&samples, bfrsz);
596 draw_wave(icon_vframe, samples.get_data(), bfrsz,
597 base_colors[i], line_colors[i]);
599 mwindow->audio_cache->check_in(asset);
600 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
601 double secs = duration;
602 if( secs > 5 ) secs = 5;
603 double refresh_rate = gui->vicon_thread->refresh_rate;
604 int64_t length = secs * refresh_rate;
605 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
606 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
607 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
609 gui->vicon_thread->add_vicon(vicon);
611 gui->lock_window("AssetPicon::create_objects 4");
612 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
613 icon->draw_vframe(icon_vframe,
614 0, 0, pixmap_w, pixmap_h, 0, 0);
617 gui->lock_window("AssetPicon::create_objects 5");
618 icon = gui->audio_icon;
619 icon_vframe = gui->audio_vframe;
623 icon = gui->audio_icon;
624 icon_vframe = gui->audio_vframe;
629 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
632 if( indexable && !indexable->is_asset ) {
633 icon = gui->video_icon;
634 icon_vframe = gui->video_vframe;
638 if( edl->tracks->playable_video_tracks() ) {
639 if( mwindow->preferences->use_thumbnails ) {
640 gui->unlock_window();
641 char clip_icon_path[BCTEXTLEN];
642 char *clip_icon = edl->local_session->clip_icon;
644 snprintf(clip_icon_path, sizeof(clip_icon_path),
645 "%s/%s", File::get_config_path(), clip_icon);
646 icon_vframe = VFramePng::vframe_png(clip_icon_path);
649 //printf("render clip: %s\n", name);
650 int edl_h = edl->get_h(), edl_w = edl->get_w();
651 int height = edl_h > 0 ? edl_h : 1;
652 int width = edl_w > 0 ? edl_w : 1;
653 int color_model = edl->session->color_model;
654 pixmap_w = pixmap_h * width / height;
656 if( gui->temp_picon &&
657 (gui->temp_picon->get_color_model() != color_model ||
658 gui->temp_picon->get_w() != width ||
659 gui->temp_picon->get_h() != height) ) {
660 delete gui->temp_picon; gui->temp_picon = 0;
663 if( !gui->temp_picon ) {
664 gui->temp_picon = new VFrame(0, -1,
665 width, height, color_model, -1);
667 char string[BCTEXTLEN];
668 sprintf(string, _("Rendering %s"), name);
669 mwindow->gui->lock_window("AssetPicon::create_objects");
670 mwindow->gui->show_message(string);
671 mwindow->gui->unlock_window();
672 open_render_engine(edl, 0);
673 render_video(0, gui->temp_picon);
674 close_render_engine();
675 icon_vframe = new VFrame(0,
676 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
677 icon_vframe->transfer_from(gui->temp_picon);
678 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
681 pixmap_w = icon_vframe->get_w();
682 pixmap_h = icon_vframe->get_h();
684 gui->lock_window("AssetPicon::create_objects 0");
685 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
686 icon->draw_vframe(icon_vframe,
687 0, 0, pixmap_w, pixmap_h, 0, 0);
690 icon = gui->clip_icon;
691 icon_vframe = gui->clip_vframe;
695 if( edl->tracks->playable_audio_tracks() ) {
696 if( mwindow->preferences->use_thumbnails ) {
697 gui->unlock_window();
698 char clip_icon_path[BCTEXTLEN];
699 char *clip_icon = edl->local_session->clip_icon;
701 snprintf(clip_icon_path, sizeof(clip_icon_path),
702 "%s/%s", File::get_config_path(), clip_icon);
703 icon_vframe = VFramePng::vframe_png(clip_icon_path);
706 pixmap_w = pixmap_h * 16/9;
707 icon_vframe = new VFrame(0,
708 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
709 icon_vframe->clear_frame();
710 char string[BCTEXTLEN];
711 sprintf(string, _("Rendering %s"), name);
712 mwindow->gui->lock_window("AssetPicon::create_objects 3");
713 mwindow->gui->show_message(string);
714 mwindow->gui->unlock_window();
715 int sample_rate = edl->get_sample_rate();
716 int channels = edl->get_audio_channels();
717 if( channels > 2 ) channels = 2;
718 int64_t audio_samples = edl->get_audio_samples();
719 double duration = (double)audio_samples / sample_rate;
720 draw_hue_bar(icon_vframe, duration);
721 Samples *samples[MAX_CHANNELS];
722 int bfrsz = sample_rate;
723 for( int i=0; i<MAX_CHANNELS; ++i )
724 samples[i] = i<channels ? new Samples(bfrsz) : 0;
725 open_render_engine(edl, 1);
726 render_audio(0, samples, bfrsz);
727 close_render_engine();
728 gui->lock_window("AssetPicon::create_objects 4");
729 static int line_colors[2] = { GREEN, YELLOW };
730 static int base_colors[2] = { RED, PINK };
731 for( int i=channels; --i>=0; ) {
732 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
733 base_colors[i], line_colors[i]);
735 for( int i=0; i<channels; ++i ) delete samples[i];
736 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
739 pixmap_w = icon_vframe->get_w();
740 pixmap_h = icon_vframe->get_h();
742 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
743 icon->draw_vframe(icon_vframe,
744 0, 0, pixmap_w, pixmap_h, 0, 0);
747 icon = gui->clip_icon;
748 icon_vframe = gui->clip_vframe;
754 strcpy(name, _(plugin->title));
756 icon_vframe = plugin->get_picon();
758 icon = gui->create_pixmap(icon_vframe);
759 else if( plugin->audio ) {
760 if( plugin->transition ) {
761 icon = gui->atransition_icon;
762 icon_vframe = gui->atransition_vframe;
764 else if( plugin->is_ffmpeg() ) {
765 icon = gui->ff_aud_icon;
766 icon_vframe = gui->ff_aud_vframe;
768 else if( plugin->is_ladspa() ) {
769 icon = gui->ladspa_icon;
770 icon_vframe = gui->ladspa_vframe;
773 icon = gui->aeffect_icon;
774 icon_vframe = gui->aeffect_vframe;
777 else if( plugin->video ) {
778 if( plugin->transition ) {
779 icon = gui->vtransition_icon;
780 icon_vframe = gui->vtransition_vframe;
782 else if( plugin->is_ffmpeg() ) {
783 icon = gui->ff_vid_icon;
784 icon_vframe = gui->ff_vid_vframe;
787 icon = gui->veffect_icon;
788 icon_vframe = gui->veffect_vframe;
796 mwindow->edl->session->time_format,
797 mwindow->edl->session->sample_rate,
798 mwindow->edl->session->frame_rate,
799 mwindow->edl->session->frames_per_foot);
801 icon = gui->label_icon;
802 icon_vframe = gui->label_vframe;
805 icon = gui->file_icon;
806 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
809 set_icon_vframe(icon_vframe);
812 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
813 : BC_Window(_(PROGRAM_NAME ": Resources"),
814 mwindow->session->awindow_x, mwindow->session->awindow_y,
815 mwindow->session->awindow_w, mwindow->session->awindow_h,
818 this->mwindow = mwindow;
819 this->awindow = awindow;
821 file_vframe = 0; file_icon = 0;
822 folder_vframe = 0; folder_icon = 0;
823 audio_vframe = 0; audio_icon = 0;
824 video_vframe = 0; video_icon = 0;
825 label_vframe = 0; label_icon = 0;
827 atransition_vframe = 0; atransition_icon = 0;
828 vtransition_vframe = 0; vtransition_icon = 0;
829 aeffect_vframe = 0; aeffect_icon = 0;
830 ladspa_vframe = 0; ladspa_icon = 0;
831 veffect_vframe = 0; veffect_icon = 0;
832 ff_aud_vframe = 0; ff_aud_icon = 0;
833 ff_vid_vframe = 0; ff_vid_icon = 0;
835 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
836 atransition_folder_vframe = 0; atransition_folder_icon = 0;
837 clip_folder_vframe = 0; clip_folder_icon = 0;
838 label_folder_vframe = 0; label_folder_icon = 0;
839 media_folder_vframe = 0; media_folder_icon = 0;
840 proxy_folder_vframe = 0; proxy_folder_icon = 0;
841 veffect_folder_vframe = 0; veffect_folder_icon = 0;
842 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
844 ladspa_vframe = 0; ladspa_icon = 0;
845 ff_aud_vframe = 0; ff_aud_icon = 0;
846 ff_vid_vframe = 0; ff_vid_icon = 0;
848 clip_vframe = 0; clip_icon = 0;
849 atransition_vframe = 0; atransition_icon = 0;
850 vtransition_vframe = 0; vtransition_icon = 0;
851 aeffect_vframe = 0; aeffect_icon = 0;
852 veffect_vframe = 0; veffect_icon = 0;
854 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
864 allow_iconlisting = 1;
869 displayed_folder = AW_NO_FOLDER;
870 new_folder_thread = 0;
871 modify_folder_thread = 0;
872 folder_lock = new Mutex("AWindowGUI::folder_lock");
875 AWindowGUI::~AWindowGUI()
877 assets.remove_all_objects();
878 folders.remove_all_objects();
879 aeffects.remove_all_objects();
880 veffects.remove_all_objects();
881 atransitions.remove_all_objects();
882 vtransitions.remove_all_objects();
883 labellist.remove_all_objects();
884 displayed_assets[1].remove_all_objects();
886 delete new_folder_thread;
887 delete modify_folder_thread;
893 delete remove_plugin;
895 delete file_vframe; delete file_icon;
896 delete folder_vframe; delete folder_icon;
897 delete audio_vframe; delete audio_icon;
898 delete video_vframe; delete video_icon;
899 delete label_vframe; delete label_icon;
900 delete clip_vframe; delete clip_icon;
901 delete aeffect_folder_vframe; delete aeffect_folder_icon;
902 delete atransition_folder_vframe; delete atransition_folder_icon;
903 delete veffect_folder_vframe; delete veffect_folder_icon;
904 delete vtransition_folder_vframe; delete vtransition_folder_icon;
905 delete clip_folder_vframe; delete clip_folder_icon;
906 delete label_folder_vframe; delete label_folder_icon;
907 delete media_folder_vframe; delete media_folder_icon;
908 delete proxy_folder_vframe; delete proxy_folder_icon;
909 delete ladspa_vframe; delete ladspa_icon;
910 delete ff_aud_vframe; delete ff_aud_icon;
911 delete ff_vid_vframe; delete ff_vid_icon;
912 delete atransition_vframe; delete atransition_icon;
913 delete vtransition_vframe; delete vtransition_icon;
914 delete aeffect_vframe; delete aeffect_icon;
915 delete veffect_vframe; delete veffect_icon;
919 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
921 return icon == file_icon ||
922 icon == folder_icon ||
923 icon == audio_icon ||
924 icon == video_icon ||
926 icon == label_icon ||
927 icon == vtransition_icon ||
928 icon == atransition_icon ||
929 icon == veffect_icon ||
930 icon == aeffect_icon ||
931 icon == ladspa_icon ||
932 icon == ff_aud_icon ||
933 icon == ff_vid_icon ||
934 icon == aeffect_folder_icon ||
935 icon == veffect_folder_icon ||
936 icon == atransition_folder_icon ||
937 icon == vtransition_folder_icon ||
938 icon == label_folder_icon ||
939 icon == clip_folder_icon ||
940 icon == media_folder_icon ||
941 icon == proxy_folder_icon;
944 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
946 char png_path[BCTEXTLEN];
947 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
948 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
949 File::get_plugin_path(), plugin_icons, name);
950 if( access(png_path, R_OK) ) return 0;
951 return VFramePng::vframe_png(png_path,0,0);
954 VFrame *AWindowGUI::get_picon(const char *name)
956 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
958 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
959 snprintf(pp, ep-pp, "%s.png", name);
960 unsigned char *data = mwindow->theme->get_image_data(png_name);
961 if( data ) vframe = new VFramePng(data, 0.);
966 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
968 vfrm = get_picon(fn);
969 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
970 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
972 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
974 vfrm = get_picon(fn);
975 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
976 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
978 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
980 vfrm = get_picon(fn);
981 if( !vfrm ) vfrm = new VFramePng(png);
982 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
985 void AWindowGUI::create_objects()
987 lock_window("AWindowGUI::create_objects");
988 asset_titles[0] = C_("Title");
989 asset_titles[1] = _("Comments");
991 set_icon(mwindow->theme->get_image("awindow_icon"));
993 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
994 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
995 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
996 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
997 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
999 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1000 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1001 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1002 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1003 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1004 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1005 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1006 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1008 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1009 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1010 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1011 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1012 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1013 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1014 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1015 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1017 theme_icon(clip_vframe, clip_icon, "clip_icon");
1018 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1019 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1020 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1021 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1023 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1024 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1025 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1026 folder_lock->lock("AWindowGUI::create_objects");
1027 // Mandatory folders
1028 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1029 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1030 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1031 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1032 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1033 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1034 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1035 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1037 create_label_folder();
1038 folder_lock->unlock();
1040 mwindow->theme->get_awindow_sizes(this);
1041 load_defaults(mwindow->defaults);
1042 new_folder_thread = new NewFolderThread(this);
1043 modify_folder_thread = new ModifyFolderThread(this);
1045 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1046 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1047 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1048 search_text->create_objects();
1049 int dy = search_text->get_h() + 10;
1051 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1053 vicon_thread = new VIconThread(asset_list);
1054 asset_list->update_vicon_area();
1055 vicon_thread->start();
1056 vicon_audio = new AssetVIconAudio(this);
1058 add_subwindow(divider = new AWindowDivider(mwindow, this,
1059 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1060 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1062 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1064 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1065 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1066 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1067 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1068 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1069 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1070 add_tools->create_objects();
1071 fy += add_tools->get_h(); fh -= add_tools->get_h();
1072 add_subwindow(folder_list = new AWindowFolders(mwindow,
1073 this, fx, fy, fw, fh));
1076 //int x = mwindow->theme->abuttons_x;
1077 //int y = mwindow->theme->abuttons_y;
1079 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1080 asset_menu->create_objects();
1081 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1082 clip_menu->create_objects();
1083 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1084 label_menu->create_objects();
1085 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1086 proxy_menu->create_objects();
1088 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1089 effectlist_menu->create_objects();
1090 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1091 assetlist_menu->create_objects();
1092 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1093 cliplist_menu->create_objects();
1094 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1095 labellist_menu->create_objects();
1096 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1097 proxylist_menu->create_objects();
1099 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1100 folderlist_menu->create_objects();
1102 create_custom_xatoms();
1106 int AWindowGUI::resize_event(int w, int h)
1108 mwindow->session->awindow_x = get_x();
1109 mwindow->session->awindow_y = get_y();
1110 mwindow->session->awindow_w = w;
1111 mwindow->session->awindow_h = h;
1113 mwindow->theme->get_awindow_sizes(this);
1114 mwindow->theme->draw_awindow_bg(this);
1115 reposition_objects();
1117 // int x = mwindow->theme->abuttons_x;
1118 // int y = mwindow->theme->abuttons_y;
1119 // new_bin->reposition_window(x, y);
1120 // x += new_bin->get_w();
1121 // delete_bin->reposition_window(x, y);
1122 // x += delete_bin->get_w();
1123 // rename_bin->reposition_window(x, y);
1124 // x += rename_bin->get_w();
1125 // delete_disk->reposition_window(x, y);
1126 // x += delete_disk->get_w();
1127 // delete_project->reposition_window(x, y);
1128 // x += delete_project->get_w();
1129 // info->reposition_window(x, y);
1130 // x += info->get_w();
1131 // redraw_index->reposition_window(x, y);
1132 // x += redraw_index->get_w();
1133 // paste->reposition_window(x, y);
1134 // x += paste->get_w();
1135 // append->reposition_window(x, y);
1136 // x += append->get_w();
1137 // view->reposition_window(x, y);
1139 BC_WindowBase::resize_event(w, h);
1140 asset_list->update_vicon_area();
1144 int AWindowGUI::translation_event()
1146 mwindow->session->awindow_x = get_x();
1147 mwindow->session->awindow_y = get_y();
1151 void AWindowGUI::reposition_objects()
1153 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1154 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1155 search_text->reposition_window(x1, y1+5, w1);
1156 int dy = search_text->get_h() + 10;
1158 asset_list->reposition_window(x1, y1, w1, h1);
1159 divider->reposition_window(
1160 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1161 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1162 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1163 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1164 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1165 avicon_drawing->reposition_window(fw-avicon_w, fy);
1166 fy += add_tools->get_h(); fh -= add_tools->get_h();
1167 folder_list->reposition_window(fx, fy, fw, fh);
1170 int AWindowGUI::save_defaults(BC_Hash *defaults)
1172 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1173 defaults->update("VICON_DRAWING", vicon_drawing);
1177 int AWindowGUI::load_defaults(BC_Hash *defaults)
1179 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1180 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1184 int AWindowGUI::close_event()
1187 mwindow->session->show_awindow = 0;
1190 mwindow->gui->lock_window("AWindowGUI::close_event");
1191 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1192 mwindow->gui->unlock_window();
1194 lock_window("AWindowGUI::close_event");
1195 save_defaults(mwindow->defaults);
1196 mwindow->save_defaults();
1200 void AWindowGUI::start_vicon_drawing()
1202 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1203 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1204 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1205 switch( mwindow->edl->session->assetlist_format ) {
1207 case ASSETS_ICONS_PACKED:
1208 case ASSETS_ICON_LIST:
1209 asset_list->update_vicon_area();
1210 vicon_thread->start_drawing();
1218 void AWindowGUI::stop_vicon_drawing()
1220 if( vicon_thread->interrupted ) return;
1221 vicon_thread->stop_drawing();
1224 VFrame *AssetPicon::get_vicon_frame()
1226 if( !vicon ) return 0;
1227 if( gui->vicon_thread->interrupted ) return 0;
1228 VFrame *frame = vicon->frame();
1229 if( !frame ) return 0;
1231 vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model());
1232 vicon_frame->transfer_from(frame);
1236 int AWindowGUI::cycle_assetlist_format()
1238 EDLSession *session = mwindow->edl->session;
1239 int format = ASSETS_TEXT;
1240 if( allow_iconlisting ) {
1241 switch( session->assetlist_format ) {
1243 format = ASSETS_ICONS;
1246 format = ASSETS_ICONS_PACKED;
1248 case ASSETS_ICONS_PACKED:
1249 format = ASSETS_ICON_LIST;
1251 case ASSETS_ICON_LIST:
1252 format = ASSETS_TEXT;
1256 stop_vicon_drawing();
1257 session->assetlist_format = format;
1258 asset_list->update_format(session->assetlist_format, 0);
1259 async_update_assets();
1260 start_vicon_drawing();
1264 AWindowRemovePluginGUI::
1265 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1266 int x, int y, PluginServer *plugin)
1267 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1269 this->awindow = awindow;
1270 this->thread = thread;
1271 this->plugin = plugin;
1272 VFrame *vframe = plugin->get_picon();
1273 icon = vframe ? create_pixmap(vframe) : 0;
1274 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1277 AWindowRemovePluginGUI::
1278 ~AWindowRemovePluginGUI()
1280 if( !awindow->gui->protected_pixmap(icon) )
1282 plugin_list.remove_all();
1285 void AWindowRemovePluginGUI::create_objects()
1287 lock_window("AWindowRemovePluginGUI::create_objects");
1288 BC_Button *ok_button = new BC_OKButton(this);
1289 add_subwindow(ok_button);
1290 BC_Button *cancel_button = new BC_CancelButton(this);
1291 add_subwindow(cancel_button);
1293 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1294 add_subwindow(title);
1295 y += title->get_h() + 5;
1296 list = new BC_ListBox(x, y,
1297 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1298 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1299 add_subwindow(list);
1304 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1307 for( int i=0; i<folder.size(); ) {
1308 AssetPicon *picon = (AssetPicon *)folder[i];
1309 if( picon->plugin == plugin ) {
1310 folder.remove_object_number(i);
1319 void AWindowRemovePlugin::handle_close_event(int result)
1322 printf(_("remove %s\n"), plugin->path);
1323 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1324 ArrayList<BC_ListBoxItem*> *folder =
1325 plugin->audio ? plugin->transition ?
1326 &awindow->gui->atransitions :
1327 &awindow->gui->aeffects :
1328 plugin->video ? plugin->transition ?
1329 &awindow->gui->vtransitions :
1330 &awindow->gui->veffects :
1332 if( folder ) remove_plugin(plugin, *folder);
1333 MWindow *mwindow = awindow->mwindow;
1334 awindow->gui->unlock_window();
1335 char plugin_path[BCTEXTLEN];
1336 strcpy(plugin_path, plugin->path);
1337 mwindow->plugindb->remove(plugin);
1338 remove(plugin_path);
1339 char index_path[BCTEXTLEN];
1340 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1342 char picon_path[BCTEXTLEN];
1344 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1345 File::get_plugin_path());
1346 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1347 plugin->get_plugin_png_name(png_name);
1348 fs.update(picon_path);
1349 for( int i=0; i<fs.dir_list.total; ++i ) {
1350 char *fs_path = fs.dir_list[i]->path;
1351 if( !fs.is_dir(fs_path) ) continue;
1352 snprintf(png_path, sizeof(picon_path), "%s/%s",
1356 delete plugin; plugin = 0;
1357 awindow->gui->async_update_assets();
1361 AWindowRemovePlugin::
1362 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1365 this->awindow = awindow;
1366 this->plugin = plugin;
1369 AWindowRemovePlugin::
1370 ~AWindowRemovePlugin()
1375 BC_Window* AWindowRemovePlugin::new_gui()
1377 int x = awindow->gui->get_abs_cursor_x(0);
1378 int y = awindow->gui->get_abs_cursor_y(0);
1379 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1380 gui->create_objects();
1384 int AWindowGUI::keypress_event()
1386 switch( get_keypress() ) {
1394 if( !ctrl_down() && !shift_down() ) {
1395 assetlist_menu->load_file->handle_event();
1400 return cycle_assetlist_format();
1402 if( shift_down() ) {
1403 PluginServer* plugin = selected_plugin();
1404 if( !plugin ) break;
1405 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1407 remove_plugin->start();
1416 int AWindowGUI::create_custom_xatoms()
1418 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1421 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1423 if( event->message_type == UpdateAssetsXAtom ) {
1430 void AWindowGUI::async_update_assets()
1433 event.message_type = UpdateAssetsXAtom;
1434 send_custom_xatom(&event);
1438 void AWindowGUI::update_folder_list()
1440 for( int i = 0; i < folders.total; i++ ) {
1441 AssetPicon *picon = (AssetPicon*)folders.values[i];
1445 // Search assets for folders
1446 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1447 BinFolder *bin_folder = mwindow->edl->folders[i];
1450 for( int j = 0; j < folders.total; j++ ) {
1451 AssetPicon *picon = (AssetPicon*)folders[j];
1452 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1460 const char *title = bin_folder->title;
1461 int folder = bin_folder->awindow_folder;
1462 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1463 picon->create_objects();
1464 folders.append(picon);
1468 // Delete unused non-persistent folders
1469 int do_autoplace = 0;
1470 for( int i=folders.total; --i>=0; ) {
1471 AssetPicon *picon = (AssetPicon*)folders.values[i];
1472 if( !picon->in_use && !picon->persistent ) {
1474 folders.remove_number(i);
1479 folder_list->set_autoplacement(&folders, 0, 1);
1482 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1483 int do_audio, int do_video, int is_realtime, int is_transition)
1485 ArrayList<PluginServer*> plugin_list;
1486 // Get pointers to plugindb entries
1487 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1490 for( int i = 0; i < plugin_list.total; i++ ) {
1491 PluginServer *server = plugin_list.values[i];
1492 int visible = plugin_visibility & (1<<server->dir_idx);
1493 if( !visible ) continue;
1494 // Create new listitem
1495 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1496 picon->create_objects();
1497 output->append(picon);
1501 void AWindowGUI::create_label_folder()
1504 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1505 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1506 picon->create_objects();
1507 labellist.append(picon);
1512 void AWindowGUI::update_asset_list()
1514 ArrayList<AssetPicon *> new_assets;
1515 for( int i = 0; i < assets.total; i++ ) {
1516 AssetPicon *picon = (AssetPicon*)assets.values[i];
1520 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1521 // Synchronize EDL clips
1522 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1525 // Look for clip in existing listitems
1526 for( int j = 0; j < assets.total && !exists; j++ ) {
1527 AssetPicon *picon = (AssetPicon*)assets.values[j];
1529 if( picon->id == mwindow->edl->clips[i]->id ) {
1530 picon->edl = mwindow->edl->clips[i];
1531 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1537 // Create new listitem
1539 AssetPicon *picon = new AssetPicon(mwindow,
1540 this, mwindow->edl->clips[i]);
1541 new_assets.append(picon);
1545 // Synchronize EDL assets
1546 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1549 // Look for asset in existing listitems
1550 for( int j = 0; j < assets.total && !exists; j++ ) {
1551 AssetPicon *picon = (AssetPicon*)assets.values[j];
1553 if( picon->id == current->id ) {
1554 picon->indexable = current;
1560 // Create new listitem
1562 AssetPicon *picon = new AssetPicon(mwindow,
1564 new_assets.append(picon);
1568 // Synchronize nested EDLs
1569 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1571 EDL *nested_edl = mwindow->edl->nested_edls[i];
1573 // Look for asset in existing listitems
1574 for( int j=0; j<assets.total && !exists; ++j ) {
1575 AssetPicon *picon = (AssetPicon*)assets.values[j];
1577 if( picon->id == nested_edl->id ) {
1578 picon->indexable = nested_edl;
1584 // Create new listitem
1586 AssetPicon *picon = new AssetPicon(mwindow,
1587 this, (Indexable*)nested_edl);
1588 new_assets.append(picon);
1591 mwindow->gui->unlock_window();
1593 for( int i=0; i<new_assets.size(); ++i ) {
1594 AssetPicon *picon = new_assets[i];
1595 picon->create_objects();
1596 assets.append(picon);
1599 mwindow->gui->lock_window();
1600 mwindow->gui->default_message();
1601 mwindow->gui->unlock_window();
1603 for( int i = assets.size() - 1; i >= 0; i-- ) {
1604 AssetPicon *picon = (AssetPicon*)assets.get(i);
1605 if( !picon->in_use ) {
1607 assets.remove_number(i);
1610 if( picon->indexable && picon->indexable->is_asset ) {
1612 picon->comments_time = !stat(picon->indexable->path, &st) ?
1618 void AWindowGUI::update_picon(Indexable *indexable)
1621 for( int i = 0; i < assets.total; i++ ) {
1622 AssetPicon *picon = (AssetPicon*)assets.values[i];
1623 if( picon->indexable == indexable ||
1624 picon->edl == (EDL *)indexable ) {
1625 char name[BCTEXTLEN];
1627 fs.extract_name(name, indexable->path);
1628 picon->set_text(name);
1629 vicon = picon->vicon;
1634 stop_vicon_drawing();
1635 vicon->clear_images();
1636 vicon->reset(indexable->get_frame_rate());
1637 start_vicon_drawing();
1641 void AWindowGUI::sort_assets()
1643 folder_lock->lock("AWindowGUI::sort_assets");
1644 switch( mwindow->edl->session->awindow_folder ) {
1645 case AW_AEFFECT_FOLDER:
1646 sort_picons(&aeffects);
1648 case AW_VEFFECT_FOLDER:
1649 sort_picons(&veffects);
1651 case AW_ATRANSITION_FOLDER:
1652 sort_picons(&atransitions);
1654 case AW_VTRANSITION_FOLDER:
1655 sort_picons(&vtransitions);
1657 case AW_LABEL_FOLDER:
1658 sort_picons(&labellist);
1661 sort_picons(&assets);
1665 asset_list->update_format(asset_list->get_format(), 0);
1666 folder_lock->unlock();
1670 void AWindowGUI::sort_folders()
1672 folder_lock->lock("AWindowGUI::update_assets");
1673 sort_picons(&folders);
1674 folder_list->update_format(folder_list->get_format(), 0);
1675 folder_lock->unlock();
1679 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1681 Asset *proxy_asset = (Asset *)indexable;
1682 char path[BCTEXTLEN];
1683 int proxy_scale = mwindow->edl->session->proxy_scale;
1684 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1685 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1686 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
1687 // make a clip from proxy video tracks and unproxy audio tracks
1688 EDL *proxy_edl = new EDL(mwindow->edl);
1689 proxy_edl->create_objects();
1690 proxy_edl->set_path(proxy_asset->path);
1691 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1692 strcpy(proxy_edl->local_session->clip_title, path);
1693 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1694 proxy_edl->session->video_tracks = proxy_asset->layers;
1695 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1696 proxy_edl->create_default_tracks();
1697 double length = proxy_asset->frame_rate > 0 ?
1698 (double)proxy_asset->video_length / proxy_asset->frame_rate :
1699 1.0 / mwindow->edl->session->frame_rate;
1700 Track *current = proxy_edl->tracks->first;
1701 for( int vtrack=0; current; current=NEXT ) {
1702 if( current->data_type != TRACK_VIDEO ) continue;
1703 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1705 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1706 current = proxy_edl->tracks->first;
1707 for( int atrack=0; current; current=NEXT ) {
1708 if( current->data_type != TRACK_AUDIO ) continue;
1709 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1711 proxy_edl->awindow_folder = AW_PROXY_FOLDER;
1716 void AWindowGUI::collect_assets()
1718 mwindow->session->drag_assets->remove_all();
1719 mwindow->session->drag_clips->remove_all();
1720 int i = 0; AssetPicon *result;
1721 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1722 Indexable *indexable = result->indexable;
1723 if( indexable && indexable->is_asset &&
1724 indexable->awindow_folder == AW_PROXY_FOLDER ) {
1725 EDL *drag_edl = collect_proxy(indexable);
1726 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
1729 mwindow->session->drag_assets->append(indexable);
1733 mwindow->session->drag_clips->append(result->edl);
1739 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1740 ArrayList<BC_ListBoxItem*> *src, int folder)
1742 // Remove current pointers
1743 dst[0].remove_all();
1744 dst[1].remove_all_objects();
1745 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
1746 mwindow->edl->get_folder(folder);
1748 // Create new pointers
1749 for( int i = 0; i < src->total; i++ ) {
1750 int visible = folder < 0 ? 1 : 0;
1751 AssetPicon *picon = (AssetPicon*)src->values[i];
1752 picon->sort_key = -1;
1753 if( !visible && bin_folder ) {
1754 Indexable *idxbl = bin_folder->is_clips ? picon->edl : picon->indexable;
1756 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
1757 if( picon->sort_key >= 0 ) visible = 1;
1760 if( !visible && picon->indexable && picon->indexable->awindow_folder == folder )
1762 if( !visible && picon->edl && picon->edl->local_session->folder == folder )
1765 const char *text = search_text->get_text();
1766 if( text && text[0] )
1767 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
1770 picon->vicon->hidden = !visible ? 1 : 0;
1772 BC_ListBoxItem *item2, *item1;
1773 dst[0].append(item1 = picon);
1775 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1778 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1779 else if( picon->comments_time ) {
1780 char date_time[BCSTRLEN];
1781 struct tm stm; localtime_r(&picon->comments_time, &stm);
1782 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1783 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1784 stm.tm_hour, stm.tm_min, stm.tm_sec);
1785 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1788 dst[1].append(item2 = new BC_ListBoxItem(""));
1789 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1790 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1795 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
1797 int done = 0, changed = 0;
1800 for( int i=0; i<src->total-1; ++i ) {
1801 AssetPicon *item1 = (AssetPicon *)src->values[i];
1802 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1803 double v = item2->sort_key - item1->sort_key;
1804 if( v > 0 ) continue;
1806 const char *cp1 = item1->get_text();
1807 const char *bp1 = strrchr(cp1, '/');
1808 if( bp1 ) cp1 = bp1 + 1;
1809 const char *cp2 = item2->get_text();
1810 const char *bp2 = strrchr(cp2, '/');
1811 if( bp2 ) cp2 = bp2 + 1;
1812 if( strcmp(cp2, cp1) >= 0 ) continue;
1814 src->values[i + 1] = item1;
1815 src->values[i] = item2;
1816 done = 0; changed = 1;
1820 for( int i=0; i<src->total; ++i ) {
1821 AssetPicon *item = (AssetPicon *)src->values[i];
1822 item->set_autoplace_icon(1);
1823 item->set_autoplace_text(1);
1828 void AWindowGUI::filter_displayed_assets()
1830 //allow_iconlisting = 1;
1831 asset_titles[0] = C_("Title");
1832 asset_titles[1] = _("Comments");
1834 switch( mwindow->edl->session->awindow_folder ) {
1835 case AW_AEFFECT_FOLDER:
1836 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1838 case AW_VEFFECT_FOLDER:
1839 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1841 case AW_ATRANSITION_FOLDER:
1842 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1844 case AW_VTRANSITION_FOLDER:
1845 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1847 case AW_LABEL_FOLDER:
1848 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1849 asset_titles[0] = _("Time Stamps");
1850 asset_titles[1] = C_("Title");
1851 //allow_iconlisting = 0;
1854 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1858 // Ensure the current folder icon is highlighted
1859 int selected_folder = mwindow->edl->session->awindow_folder;
1860 for( int i = 0; i < folders.total; i++ ) {
1861 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1862 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1863 folder_item->set_selected(selected);
1868 void AWindowGUI::update_assets()
1870 stop_vicon_drawing();
1871 folder_lock->lock("AWindowGUI::update_assets");
1872 update_folder_list();
1873 update_asset_list();
1874 labellist.remove_all_objects();
1875 create_label_folder();
1877 if( displayed_folder != mwindow->edl->session->awindow_folder )
1878 search_text->clear();
1879 vicon_thread->hide_vicons();
1880 filter_displayed_assets();
1881 folder_lock->unlock();
1883 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1884 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1886 int folder_xposition = folder_list->get_xposition();
1887 int folder_yposition = folder_list->get_yposition();
1888 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1890 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1891 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1893 int asset_xposition = asset_list->get_xposition();
1894 int asset_yposition = asset_list->get_yposition();
1895 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1896 displayed_folder = mwindow->edl->session->awindow_folder;
1897 asset_xposition = asset_yposition = 0;
1899 asset_list->update(displayed_assets, asset_titles,
1900 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1901 asset_xposition, asset_yposition, -1, 0);
1902 asset_list->center_selection();
1905 start_vicon_drawing();
1909 void AWindowGUI::update_effects()
1911 aeffects.remove_all_objects();
1912 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1913 veffects.remove_all_objects();
1914 create_persistent_folder(&veffects, 0, 1, 1, 0);
1915 atransitions.remove_all_objects();
1916 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1917 vtransitions.remove_all_objects();
1918 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1921 int AWindowGUI::drag_motion()
1923 if( get_hidden() ) return 0;
1929 int AWindowGUI::drag_stop()
1931 if( get_hidden() ) return 0;
1935 Indexable* AWindowGUI::selected_asset()
1937 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1938 return picon ? picon->indexable : 0;
1941 PluginServer* AWindowGUI::selected_plugin()
1943 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1944 return picon ? picon->plugin : 0;
1947 AssetPicon* AWindowGUI::selected_folder()
1949 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1960 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1961 : BC_SubWindow(x, y, w, h)
1963 this->mwindow = mwindow;
1966 AWindowDivider::~AWindowDivider()
1970 int AWindowDivider::button_press_event()
1972 if( is_event_win() && cursor_inside() ) {
1973 mwindow->session->current_operation = DRAG_PARTITION;
1979 int AWindowDivider::cursor_motion_event()
1981 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1983 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1984 int fw = gui->get_relative_cursor_x();
1985 if( fw > wmax ) fw = wmax;
1986 if( fw < wmin ) fw = wmin;
1987 mwindow->session->afolders_w = fw;
1988 mwindow->theme->get_awindow_sizes(gui);
1989 gui->reposition_objects();
1995 int AWindowDivider::button_release_event()
1997 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1998 mwindow->session->current_operation = NO_OPERATION;
2009 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2010 : BC_ListBox(x, y, w, h,
2011 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2012 LISTBOX_ICONS : LISTBOX_TEXT,
2013 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2014 0, // Titles for columns. Set to 0 for no titles
2015 0, // width of each column
2016 1, // Total columns.
2017 0, // Pixel of top of window.
2018 0, // If this listbox is a popup window
2019 LISTBOX_SINGLE, // Select one item or multiple items
2020 ICON_TOP, // Position of icon relative to text of each item
2023 this->mwindow = mwindow;
2028 AWindowFolders::~AWindowFolders()
2032 int AWindowFolders::selection_changed()
2034 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
2036 gui->stop_vicon_drawing();
2038 if( get_button_down() && get_buttonpress() == 3 ) {
2039 gui->folderlist_menu->update_titles();
2040 gui->folderlist_menu->activate_menu();
2043 mwindow->edl->session->awindow_folder = picon->foldernum;
2044 gui->asset_list->draw_background();
2045 gui->async_update_assets();
2047 gui->start_vicon_drawing();
2052 int AWindowFolders::button_press_event()
2056 result = BC_ListBox::button_press_event();
2059 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2060 gui->folderlist_menu->update_titles();
2061 gui->folderlist_menu->activate_menu();
2070 int AWindowFolders::drag_stop()
2073 if( get_hidden() ) return 0;
2074 if( mwindow->session->current_operation == DRAG_ASSET &&
2075 gui->folder_list->cursor_above() ) { // check user folder
2076 int item_no = gui->folder_list->get_cursor_item();
2077 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2078 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2079 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2080 ArrayList<Indexable *> *drags = folder->is_clips ?
2081 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2082 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2083 if( folder && drags && !folder->add_patterns(drags) )
2085 mwindow->session->current_operation = ::NO_OPERATION;
2093 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2094 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2095 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2096 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2097 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2099 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2100 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2101 mwindow->edl->session->asset_columns, // width of each column
2102 1, // Total columns.
2103 0, // Pixel of top of window.
2104 0, // If this listbox is a popup window
2105 LISTBOX_MULTIPLE, // Select one item or multiple items
2106 ICON_TOP, // Position of icon relative to text of each item
2107 -1) // Allow drags, require shift for scrolling
2109 this->mwindow = mwindow;
2112 set_scroll_stretch(1, 1);
2115 AWindowAssets::~AWindowAssets()
2119 int AWindowAssets::button_press_event()
2123 result = BC_ListBox::button_press_event();
2125 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2126 BC_ListBox::deactivate_selection();
2127 int folder = mwindow->edl->session->awindow_folder;
2129 case AW_AEFFECT_FOLDER:
2130 case AW_VEFFECT_FOLDER:
2131 case AW_ATRANSITION_FOLDER:
2132 case AW_VTRANSITION_FOLDER:
2133 gui->effectlist_menu->update();
2134 gui->effectlist_menu->activate_menu();
2136 case AW_LABEL_FOLDER:
2137 gui->labellist_menu->update();
2138 gui->labellist_menu->activate_menu();
2140 case AW_CLIP_FOLDER:
2141 gui->cliplist_menu->update();
2142 gui->cliplist_menu->activate_menu();
2144 case AW_PROXY_FOLDER:
2145 gui->proxylist_menu->update();
2146 gui->proxylist_menu->activate_menu();
2149 case AW_MEDIA_FOLDER: {
2150 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2151 gui->assetlist_menu->update_titles(shots);
2152 gui->assetlist_menu->activate_menu();
2162 int AWindowAssets::handle_event()
2164 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2165 if( !asset_picon ) return 0;
2166 Indexable *picon_idxbl = asset_picon->indexable;
2167 EDL *picon_edl = asset_picon->edl;
2169 VWindow *vwindow = 0;
2170 switch( mwindow->edl->session->awindow_folder ) {
2171 case AW_AEFFECT_FOLDER:
2172 case AW_VEFFECT_FOLDER:
2173 case AW_ATRANSITION_FOLDER:
2174 case AW_VTRANSITION_FOLDER: return 1;
2175 case AW_PROXY_FOLDER:
2176 proxy = 1; // fall thru
2178 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2179 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2182 if( !vwindow || !vwindow->is_running() ) return 1;
2183 if( proxy && picon_idxbl ) {
2184 picon_edl = gui->collect_proxy(picon_idxbl);
2188 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2189 else if( picon_edl ) vwindow->change_source(picon_edl);
2193 int AWindowAssets::selection_changed()
2195 // Show popup window
2197 if( get_button_down() && get_buttonpress() == 3 &&
2198 (item = (AssetPicon*)get_selection(0, 0)) ) {
2199 int folder = mwindow->edl->session->awindow_folder;
2201 case AW_AEFFECT_FOLDER:
2202 case AW_VEFFECT_FOLDER:
2203 case AW_ATRANSITION_FOLDER:
2204 case AW_VTRANSITION_FOLDER:
2205 gui->effectlist_menu->update();
2206 gui->effectlist_menu->activate_menu();
2208 case AW_LABEL_FOLDER:
2209 if( !item->label ) break;
2210 gui->label_menu->activate_menu();
2212 case AW_CLIP_FOLDER:
2213 if( !item->indexable && !item->edl ) break;
2214 gui->clip_menu->update();
2215 gui->clip_menu->activate_menu();
2217 case AW_PROXY_FOLDER:
2218 if( !item->indexable && !item->edl ) break;
2219 gui->proxy_menu->update();
2220 gui->proxy_menu->activate_menu();
2223 if( !item->indexable && !item->edl ) break;
2224 gui->asset_menu->update();
2225 gui->asset_menu->activate_menu();
2229 BC_ListBox::deactivate_selection();
2231 else if( gui->vicon_drawing &&
2232 get_button_down() && get_buttonpress() == 1 &&
2233 (item = (AssetPicon*)get_selection(0, 0)) ) {
2235 if( !gui->vicon_thread->viewing ) {
2236 vicon = item->vicon;
2238 gui->vicon_thread->set_view_popup(vicon);
2244 void AWindowAssets::draw_background()
2246 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2247 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2248 set_font(LARGEFONT);
2249 int folder = mwindow->edl->session->awindow_folder;
2250 const char *title = mwindow->edl->get_folder_name(folder);
2251 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2252 title, -1, get_bg_surface());
2255 int AWindowAssets::drag_start_event()
2257 int collect_pluginservers = 0;
2258 int collect_assets = 0;
2260 if( BC_ListBox::drag_start_event() ) {
2261 switch( mwindow->edl->session->awindow_folder ) {
2262 case AW_AEFFECT_FOLDER:
2263 mwindow->session->current_operation = DRAG_AEFFECT;
2264 collect_pluginservers = 1;
2266 case AW_VEFFECT_FOLDER:
2267 mwindow->session->current_operation = DRAG_VEFFECT;
2268 collect_pluginservers = 1;
2270 case AW_ATRANSITION_FOLDER:
2271 mwindow->session->current_operation = DRAG_ATRANSITION;
2272 collect_pluginservers = 1;
2274 case AW_VTRANSITION_FOLDER:
2275 mwindow->session->current_operation = DRAG_VTRANSITION;
2276 collect_pluginservers = 1;
2278 case AW_LABEL_FOLDER:
2281 case AW_MEDIA_FOLDER:
2283 mwindow->session->current_operation = DRAG_ASSET;
2288 if( collect_pluginservers ) {
2290 mwindow->session->drag_pluginservers->remove_all();
2293 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2294 if( !result ) break;
2296 mwindow->session->drag_pluginservers->append(result->plugin);
2300 if( collect_assets ) {
2301 gui->collect_assets();
2309 int AWindowAssets::drag_motion_event()
2311 BC_ListBox::drag_motion_event();
2314 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2315 mwindow->gui->drag_motion();
2316 mwindow->gui->unlock_window();
2318 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2319 VWindow *vwindow = mwindow->vwindows.get(i);
2320 if( !vwindow->is_running() ) continue;
2321 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2322 vwindow->gui->drag_motion();
2323 vwindow->gui->unlock_window();
2326 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2327 mwindow->cwindow->gui->drag_motion();
2328 mwindow->cwindow->gui->unlock_window();
2330 lock_window("AWindowAssets::drag_motion_event");
2331 if( mwindow->session->current_operation == DRAG_ASSET &&
2332 gui->folder_list->cursor_above() ) { // highlight user folder
2333 int item_no = gui->folder_list->get_cursor_item();
2334 if( item_no >= 0 ) {
2335 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2336 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2338 int folder_xposition = gui->folder_list->get_xposition();
2339 int folder_yposition = gui->folder_list->get_yposition();
2340 gui->folder_list->update(&gui->folders, 0, 0, 1,
2341 folder_xposition, folder_yposition, item_no, 0, 1);
2346 int AWindowAssets::drag_stop_event()
2350 result = gui->drag_stop();
2355 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2356 result = mwindow->gui->drag_stop();
2357 mwindow->gui->unlock_window();
2361 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2362 VWindow *vwindow = mwindow->vwindows.get(i);
2363 if( !vwindow ) continue;
2364 if( !vwindow->is_running() ) continue;
2365 if( vwindow->gui->is_hidden() ) continue;
2366 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2367 if( vwindow->gui->cursor_above() &&
2368 vwindow->gui->get_cursor_over_window() ) {
2369 result = vwindow->gui->drag_stop();
2371 vwindow->gui->unlock_window();
2376 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2377 result = mwindow->cwindow->gui->drag_stop();
2378 mwindow->cwindow->gui->unlock_window();
2381 lock_window("AWindowAssets::drag_stop_event");
2383 result = gui->folder_list->drag_stop();
2388 get_drag_popup()->set_animation(0);
2390 BC_ListBox::drag_stop_event();
2391 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2392 mwindow->session->current_operation = ::NO_OPERATION;
2397 int AWindowAssets::column_resize_event()
2399 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2400 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2404 int AWindowAssets::focus_in_event()
2406 gui->start_vicon_drawing();
2410 int AWindowAssets::focus_out_event()
2412 gui->stop_vicon_drawing();
2413 return BC_ListBox::focus_out_event();
2416 void AWindowAssets::update_vicon_area()
2418 int x0 = 0, x1 = get_w();
2419 int y0 = get_title_h();
2421 if( is_highlighted() ) {
2422 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2423 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2425 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2428 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2429 : BC_TextBox(x, y, w, 1, "")
2431 this->search_text = search_text;
2434 int AWindowSearchTextBox::handle_event()
2436 return search_text->handle_event();
2439 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2441 this->mwindow = mwindow;
2447 void AWindowSearchText::create_objects()
2449 int x1 = x, y1 = y, margin = 10;
2450 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2451 x1 += text_title->get_w() + margin;
2452 int w1 = gui->get_w() - x1 - 2*margin;
2453 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2456 int AWindowSearchText::handle_event()
2458 gui->async_update_assets();
2462 int AWindowSearchText::get_w()
2464 return text_box->get_w() + text_title->get_w() + 10;
2467 int AWindowSearchText::get_h()
2469 return bmax(text_box->get_h(),text_title->get_h());
2472 void AWindowSearchText::reposition_window(int x, int y, int w)
2474 int x1 = x, y1 = y, margin = 10;
2475 text_title->reposition_window(x1, y1);
2476 x1 += text_title->get_w() + margin;
2477 int w1 = gui->get_w() - x1 - 2*margin;
2478 text_box->reposition_window(x1, y1, w1);
2481 const char *AWindowSearchText::get_text()
2483 return text_box->get_text();
2486 void AWindowSearchText::clear()
2488 text_box->update("");
2491 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2492 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2494 this->mwindow = mwindow;
2496 set_tooltip(_("Delete asset from disk"));
2499 int AWindowDeleteDisk::handle_event()
2504 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2505 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2507 this->mwindow = mwindow;
2509 set_tooltip(_("Delete asset from project"));
2512 int AWindowDeleteProject::handle_event()
2517 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2518 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2520 // this->mwindow = mwindow;
2522 // set_tooltip(_("Edit information on asset"));
2525 // int AWindowInfo::handle_event()
2527 // int cur_x, cur_y;
2528 // gui->get_abs_cursor(cur_x, cur_y, 0);
2529 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2533 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2534 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2536 this->mwindow = mwindow;
2538 set_tooltip(_("Redraw index"));
2541 int AWindowRedrawIndex::handle_event()
2546 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2547 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2549 this->mwindow = mwindow;
2551 set_tooltip(_("Paste asset on recordable tracks"));
2554 int AWindowPaste::handle_event()
2559 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2560 : BC_Button(x, y, mwindow->theme->appendasset_data)
2562 this->mwindow = mwindow;
2564 set_tooltip(_("Append asset in new tracks"));
2567 int AWindowAppend::handle_event()
2572 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2573 : BC_Button(x, y, mwindow->theme->viewasset_data)
2575 this->mwindow = mwindow;
2577 set_tooltip(_("View asset"));
2580 int AWindowView::handle_event()
2585 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2586 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2588 this->mwindow = mwindow;
2592 void AddTools::create_objects()
2595 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2596 vis |= 1 << PLUGIN_FFMPEG_ID;
2597 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2598 vis |= 1 << PLUGIN_LADSPA_ID;
2600 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
2601 vis |= 1 << PLUGIN_LV2_ID;
2603 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2604 PluginServer *plugin = MWindow::plugindb->get(i);
2605 if( !plugin->audio && !plugin->video ) continue;
2606 int idx = plugin->dir_idx;
2607 uint32_t msk = 1 << idx;
2608 if( (msk & vis) != 0 ) continue;
2610 char parent[BCTEXTLEN];
2611 strcpy(parent, plugin->path);
2612 char *bp = strrchr(parent, '/');
2613 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2614 if( !bp ) bp = parent; else ++bp;
2615 add_item(new AddPluginItem(this, bp, idx));
2620 // plugin_dirs list from toplevel makefile include plugin_defs
2625 N_("audio_transitions")
2632 N_("video_transitions")
2635 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2636 : BC_MenuItem(_(text))
2640 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2641 int chk = (msk & vis) ? 1 : 0;
2645 int AddPluginItem::handle_event()
2647 int chk = get_checked() ^ 1;
2649 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2650 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2651 menu->gui->update_effects();
2652 menu->gui->save_defaults(menu->mwindow->defaults);
2653 menu->gui->async_update_assets();
2657 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2658 : BC_Toggle(x, y, images, agui->vicon_drawing)
2661 set_tooltip(_("draw vicons"));
2664 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2666 int text_line = -1, toggle_x = -1, toggle_y = -1;
2667 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2668 BC_Toggle::calculate_extents(agui, images, 1,
2669 &text_line, ww, hh, &toggle_x, &toggle_y,
2670 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2673 AVIconDrawing::~AVIconDrawing()
2677 int AVIconDrawing::handle_event()
2679 agui->vicon_drawing = get_value();
2680 if( agui->vicon_drawing )
2681 agui->start_vicon_drawing();
2683 agui->stop_vicon_drawing();
2688 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2689 : BC_MenuItem("","v",'v')
2691 this->mwindow = mwindow;
2695 int AWindowListFormat::handle_event()
2697 return gui->cycle_assetlist_format();
2700 void AWindowListFormat::update()
2702 EDLSession *session = mwindow->edl->session;
2703 const char *text = 0;
2704 switch( session->assetlist_format ) {
2706 text = _("Display icons");
2709 text = _("Display icons packed");
2711 case ASSETS_ICONS_PACKED:
2712 text = _("Display icon list");
2714 case ASSETS_ICON_LIST:
2715 text = _("Display text");
2721 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2722 : BC_MenuItem(_("Sort items"))
2724 this->mwindow = mwindow;
2728 int AWindowListSort::handle_event()