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"
37 #include "clippopup.h"
39 #include "cwindowgui.h"
42 #include "edlsession.h"
43 #include "effectlist.h"
45 #include "filesystem.h"
46 #include "folderlistmenu.h"
47 #include "indexable.h"
51 #include "labelpopup.h"
52 #include "localsession.h"
54 #include "mainsession.h"
55 #include "mwindowgui.h"
57 #include "newfolder.h"
58 #include "preferences.h"
59 #include "renderengine.h"
63 #include "transportque.h"
67 #include "vwindowgui.h"
70 #include "data/lad_picon_png.h"
71 #include "data/ff_audio_png.h"
72 #include "data/ff_video_png.h"
79 const char *AWindowGUI::folder_names[] =
83 N_("Audio Transitions"),
84 N_("Video Transitions"),
92 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
93 : VIcon(w, h, framerate)
96 this->length = length;
100 AssetVIcon::~AssetVIcon()
105 VFrame *AssetVIcon::frame()
107 Asset *asset = (Asset *)picon->indexable;
108 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
109 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
111 int sample_rate = asset->get_sample_rate();
112 int64_t audio_samples = asset->get_audio_samples();
113 double duration = (double)audio_samples / sample_rate;
114 picon->draw_hue_bar(temp, duration);
115 int secs = length / frame_rate + 0.5;
116 if( !secs ) secs = 1;
117 int bfrsz = VICON_SAMPLE_RATE;
118 int samples = audio_size/sizeof(vicon_audio_t);
119 double line_pos = (double)seq_no/(length-1);
120 int audio_pos = samples * line_pos * (secs-1)/secs;
121 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
122 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
123 double data[bfrsz], sample_scale = 1./mx;
124 int len = samples - audio_pos;
125 if( len > bfrsz ) len = bfrsz;
127 while( i < len ) data[i++] = *audio_data++ * sample_scale;
128 while( i < bfrsz ) data[i++] = 0;
129 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
130 int x = (vw-1) * line_pos;
131 temp->pixel_rgb = RED;
132 temp->draw_line(x,0, x,vh);
135 if( seq_no >= images.size() ) {
136 MWindow *mwindow = picon->mwindow;
137 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
138 if( !file ) return 0;
139 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
140 delete temp; temp = 0;
143 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
144 int ww = picon->gui->vicon_thread->view_w;
145 int hh = picon->gui->vicon_thread->view_h;
146 while( seq_no >= images.size() ) {
148 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
149 file->set_video_position(pos,0);
150 if( file->read_frame(temp) ) temp->clear_frame();
151 add_image(temp, ww, hh, BC_RGB8);
153 mwindow->video_cache->check_in(asset);
155 return *images[seq_no];
158 int64_t AssetVIcon::set_seq_no(int64_t no)
160 if( no >= length ) no = 0;
164 int AssetVIcon::get_vx()
166 BC_ListBox *lbox = picon->gui->asset_list;
167 return lbox->get_item_x(picon);
169 int AssetVIcon::get_vy()
171 BC_ListBox *lbox = picon->gui->asset_list;
172 return lbox->get_item_y(picon) + lbox->get_title_h();
175 void AssetVIcon::load_audio()
177 MWindow *mwindow = picon->mwindow;
178 Asset *asset = (Asset *)picon->indexable;
179 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
180 int channels = asset->get_audio_channels();
181 if( channels > 2 ) channels = 2;
182 int sample_rate = asset->get_sample_rate();
183 int bfrsz = sample_rate;
184 Samples samples(bfrsz);
185 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
186 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
187 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
188 double sample_scale = (double)mx / channels;
189 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
190 while( audio_pos < audio_len ) {
191 int64_t pos = audio_pos * time_scale;
192 for( int ch=0; ch<channels; ++ch ) {
193 file->set_channel(ch);
194 file->set_audio_position(pos);
195 file->read_samples(&samples, bfrsz);
196 double *data = samples.get_data();
197 for( int64_t k=audio_pos; k<audio_len; ++k ) {
198 int i = k * time_scale - pos;
199 if( i >= bfrsz ) break;
200 int v = audio_data[k] + data[i] * sample_scale;
201 audio_data[k] = CLIP(v, -mx,mx);
204 audio_pos = (pos + bfrsz) / time_scale;
206 mwindow->audio_cache->check_in(asset);
210 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
214 audio = new AudioDevice(gui->mwindow);
218 AssetVIconAudio::~AssetVIconAudio()
223 void AssetVIconAudio::run()
226 int64_t bfrsz = VICON_SAMPLE_RATE;
227 MWindow *mwindow = gui->mwindow;
228 EDL *edl = mwindow->edl;
229 EDLSession *session = edl->session;
230 AudioOutConfig *aconfig = session->playback_config->aconfig;
231 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
232 audio->start_playback();
233 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
234 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
235 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
237 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
238 while( !interrupted ) {
239 int len = audio_len - audio_pos;
240 if( len <= 0 ) break;
241 if( len > bfrsz ) len = bfrsz;
243 for( int i=0; i<len; ++i,++k )
244 out0[i] = out1[i] = (double)audio_data[k] / mx;
246 audio->write_buffer(out, channels, len);
250 audio->set_last_buffer();
251 audio->stop_audio(interrupted ? 0 : 1);
255 void AssetVIconAudio::start(AssetVIcon *vicon)
257 if( running() ) return;
264 void AssetVIconAudio::stop(int wait)
266 if( running() && !interrupted ) {
268 audio->stop_audio(wait);
272 vicon->playing_audio = 0;
277 void AssetVIcon::start_audio()
279 picon->gui->vicon_audio->stop(0);
281 picon->gui->vicon_audio->start(this);
284 void AssetVIcon::stop_audio()
286 picon->gui->vicon_audio->stop(0);
290 AssetPicon::AssetPicon(MWindow *mwindow,
291 AWindowGUI *gui, Indexable *indexable)
295 this->mwindow = mwindow;
297 this->indexable = indexable;
298 indexable->add_user();
299 this->id = indexable->id;
302 AssetPicon::AssetPicon(MWindow *mwindow,
303 AWindowGUI *gui, EDL *edl)
307 this->mwindow = mwindow;
314 AssetPicon::AssetPicon(MWindow *mwindow,
315 AWindowGUI *gui, int folder, int persist)
316 : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
317 folder>=0 && folder<AWINDOW_FOLDERS ?
318 gui->folder_icons[folder]: gui->folder_icon)
322 this->mwindow = mwindow;
324 persistent = persist;
327 AssetPicon::AssetPicon(MWindow *mwindow,
328 AWindowGUI *gui, PluginServer *plugin)
332 this->mwindow = mwindow;
334 this->plugin = plugin;
337 AssetPicon::AssetPicon(MWindow *mwindow,
338 AWindowGUI *gui, Label *label)
342 this->mwindow = mwindow;
350 AssetPicon::~AssetPicon()
353 gui->vicon_thread->del_vicon(vicon);
354 if( indexable ) indexable->remove_user();
355 if( edl ) edl->remove_user();
356 if( icon && !gui->protected_pixmap(icon) ) {
358 if( !plugin ) delete icon_vframe;
362 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
364 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
366 float h = 300 * t, s = 1., v = 1.;
367 float r, g, b; // duration, 0..1hr == hue red..magenta
368 HSV::hsv_to_rgb(r,g,b, h,s,v);
369 int ih = frame->get_h()/8, iw = frame->get_w();
370 int ir = r * 256; CLAMP(ir, 0,255);
371 int ig = g * 256; CLAMP(ig, 0,255);
372 int ib = b * 256; CLAMP(ib, 0,255);
373 unsigned char **rows = frame->get_rows();
374 for( int y=0; y<ih; ++y ) {
375 unsigned char *rp = rows[y];
376 for( int x=0; x<iw; rp+=3,++x ) {
377 rp[0] = ir; rp[1] = ig; rp[2] = ib;
382 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len, int base_color, int line_color)
384 int w = frame->get_w(), h = frame->get_h();
385 int h1 = h-1, h2 = h/2, y = h2;
386 int rgb_color = frame->pixel_rgb;
387 for( int x=0,x1=0,x2=0; x<w; ++x,x1=x2 ) {
388 double min = *dp, max = min;
389 x2 = (len * (x+1))/w;
390 for( int i=x1; i<x2; ++i ) {
391 double value = *dp++;
392 if( value < min ) min = value;
393 if( value > max ) max = value;
395 int ctr = (min + max) / 2;
396 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
397 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
398 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
399 frame->pixel_rgb = line_color;
400 frame->draw_line(x,y1, x,y2);
401 frame->pixel_rgb = base_color;
402 frame->draw_line(x,y, x,y0);
405 frame->pixel_rgb = rgb_color;
408 void AssetPicon::reset()
414 foldernum = AW_NO_FOLDER;
424 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
426 TransportCommand command;
427 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
428 command.get_edl()->copy_all(edl);
429 command.change_type = CHANGE_ALL;
430 command.realtime = 0;
431 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
432 render_engine->set_vcache(mwindow->video_cache);
433 render_engine->set_acache(mwindow->audio_cache);
434 render_engine->arm_command(&command);
436 void AssetPicon::close_render_engine()
438 delete render_engine; render_engine = 0;
440 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
442 if( !render_engine || !render_engine->vrender ) return;
443 render_engine->vrender->process_buffer(vfrm, pos, 0);
445 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
447 if( !render_engine || !render_engine->arender ) return;
448 render_engine->arender->process_buffer(samples, len, pos);
451 void AssetPicon::create_objects()
454 char name[BCTEXTLEN];
455 int pixmap_w, pixmap_h;
457 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
460 fs.extract_name(name, indexable->path);
464 set_text(strcpy(name, edl->local_session->clip_title));
468 if( indexable && indexable->is_asset ) {
469 Asset *asset = (Asset*)indexable;
470 if( asset->video_data ) {
471 if( mwindow->preferences->use_thumbnails ) {
472 gui->unlock_window();
473 File *file = mwindow->video_cache->check_out(asset,
478 int height = asset->height > 0 ? asset->height : 1;
479 pixmap_w = pixmap_h * asset->width / height;
482 file->set_video_position(0, 0);
484 if( gui->temp_picon &&
485 (gui->temp_picon->get_w() != asset->width ||
486 gui->temp_picon->get_h() != asset->height) ) {
487 delete gui->temp_picon;
491 if( !gui->temp_picon ) {
492 gui->temp_picon = new VFrame(0, -1,
493 asset->width, asset->height,
496 { char string[BCTEXTLEN];
497 sprintf(string, _("Reading %s"), name);
498 mwindow->gui->lock_window("AssetPicon::create_objects");
499 mwindow->gui->show_message(string);
500 mwindow->gui->unlock_window(); }
501 file->read_frame(gui->temp_picon);
502 mwindow->video_cache->check_in(asset);
504 gui->lock_window("AssetPicon::create_objects 0");
505 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
506 icon->draw_vframe(gui->temp_picon,
507 0, 0, pixmap_w, pixmap_h, 0, 0);
508 icon_vframe = new VFrame(0,
509 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
510 icon_vframe->transfer_from(gui->temp_picon);
511 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
513 double framerate = asset->get_frame_rate();
514 if( !framerate ) framerate = VICON_RATE;
515 int64_t frames = asset->get_video_frames();
516 double secs = frames / framerate;
517 if( secs > 5 ) secs = 5;
518 int64_t length = secs * gui->vicon_thread->refresh_rate;
519 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
520 if( asset->audio_data && secs > 0 ) {
521 gui->unlock_window();
522 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
523 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
525 gui->lock_window("AssetPicon::create_objects 1");
527 gui->vicon_thread->add_vicon(vicon);
532 gui->lock_window("AssetPicon::create_objects 2");
533 icon = gui->video_icon;
534 icon_vframe = gui->video_vframe;
538 icon = gui->video_icon;
539 icon_vframe = gui->video_vframe;
543 if( asset->audio_data ) {
544 if( mwindow->preferences->use_thumbnails ) {
545 gui->unlock_window();
546 File *file = mwindow->audio_cache->check_out(asset,
550 pixmap_w = pixmap_h * 16/9;
551 icon_vframe = new VFrame(0,
552 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
553 { char string[BCTEXTLEN];
554 sprintf(string, _("Reading %s"), name);
555 mwindow->gui->lock_window("AssetPicon::create_objects 3");
556 mwindow->gui->show_message(string);
557 mwindow->gui->unlock_window(); }
558 int sample_rate = asset->get_sample_rate();
559 int channels = asset->get_audio_channels();
560 if( channels > 2 ) channels = 2;
561 int64_t audio_samples = asset->get_audio_samples();
562 double duration = (double)audio_samples / sample_rate;
563 draw_hue_bar(icon_vframe, duration);
564 int bfrsz = sample_rate;
565 Samples samples(bfrsz);
566 static int line_colors[2] = { GREEN, YELLOW };
567 static int base_colors[2] = { RED, PINK };
568 for( int i=channels; --i>=0; ) {
569 file->set_channel(i);
570 file->set_audio_position(0);
571 file->read_samples(&samples, bfrsz);
572 draw_wave(icon_vframe, samples.get_data(), bfrsz,
573 base_colors[i], line_colors[i]);
575 mwindow->audio_cache->check_in(asset);
576 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
577 double secs = duration;
578 if( secs > 5 ) secs = 5;
579 double refresh_rate = gui->vicon_thread->refresh_rate;
580 int64_t length = secs * refresh_rate;
581 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
582 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
583 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
585 gui->vicon_thread->add_vicon(vicon);
587 gui->lock_window("AssetPicon::create_objects 4");
588 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
589 icon->draw_vframe(icon_vframe,
590 0, 0, pixmap_w, pixmap_h, 0, 0);
593 gui->lock_window("AssetPicon::create_objects 5");
594 icon = gui->audio_icon;
595 icon_vframe = gui->audio_vframe;
599 icon = gui->audio_icon;
600 icon_vframe = gui->audio_vframe;
605 mtime = !stat(asset->path, &st) ? st.st_mtime : 0;
608 if( indexable && !indexable->is_asset ) {
609 icon = gui->video_icon;
610 icon_vframe = gui->video_vframe;
614 if( edl->tracks->playable_video_tracks() ) {
615 if( mwindow->preferences->use_thumbnails ) {
616 gui->unlock_window();
617 char clip_icon_path[BCTEXTLEN];
618 char *clip_icon = edl->local_session->clip_icon;
620 snprintf(clip_icon_path, sizeof(clip_icon_path),
621 "%s/%s", File::get_config_path(), clip_icon);
622 icon_vframe = VFramePng::vframe_png(clip_icon_path);
625 int edl_h = edl->get_h(), edl_w = edl->get_w();
626 int height = edl_h > 0 ? edl_h : 1;
627 int width = edl_w > 0 ? edl_w : 1;
628 pixmap_w = pixmap_h * width / height;
630 if( gui->temp_picon &&
631 (gui->temp_picon->get_w() != width ||
632 gui->temp_picon->get_h() != height) ) {
633 delete gui->temp_picon; gui->temp_picon = 0;
636 if( !gui->temp_picon ) {
637 gui->temp_picon = new VFrame(0, -1,
638 width, height, BC_RGB888, -1);
640 char string[BCTEXTLEN];
641 sprintf(string, _("Rendering %s"), name);
642 mwindow->gui->lock_window("AssetPicon::create_objects");
643 mwindow->gui->show_message(string);
644 mwindow->gui->unlock_window();
645 open_render_engine(edl, 0);
646 render_video(0, gui->temp_picon);
647 close_render_engine();
648 gui->lock_window("AssetPicon::create_objects 0");
649 icon_vframe = new VFrame(0,
650 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
651 icon_vframe->transfer_from(gui->temp_picon);
652 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
655 pixmap_w = icon_vframe->get_w();
656 pixmap_h = icon_vframe->get_h();
658 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
659 icon->draw_vframe(icon_vframe,
660 0, 0, pixmap_w, pixmap_h, 0, 0);
663 icon = gui->clip_icon;
664 icon_vframe = gui->clip_vframe;
668 if( edl->tracks->playable_audio_tracks() ) {
669 if( mwindow->preferences->use_thumbnails ) {
670 gui->unlock_window();
671 char clip_icon_path[BCTEXTLEN];
672 char *clip_icon = edl->local_session->clip_icon;
674 snprintf(clip_icon_path, sizeof(clip_icon_path),
675 "%s/%s", File::get_config_path(), clip_icon);
676 icon_vframe = VFramePng::vframe_png(clip_icon_path);
679 pixmap_w = pixmap_h * 16/9;
680 icon_vframe = new VFrame(0,
681 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
682 char string[BCTEXTLEN];
683 sprintf(string, _("Rendering %s"), name);
684 mwindow->gui->lock_window("AssetPicon::create_objects 3");
685 mwindow->gui->show_message(string);
686 mwindow->gui->unlock_window();
687 int sample_rate = edl->get_sample_rate();
688 int channels = edl->get_audio_channels();
689 if( channels > 2 ) channels = 2;
690 int64_t audio_samples = edl->get_audio_samples();
691 double duration = (double)audio_samples / sample_rate;
692 draw_hue_bar(icon_vframe, duration);
693 Samples *samples[MAX_CHANNELS];
694 int bfrsz = sample_rate;
695 for( int i=0; i<MAX_CHANNELS; ++i )
696 samples[i] = i<channels ? new Samples(bfrsz) : 0;
697 open_render_engine(edl, 1);
698 render_audio(0, samples, bfrsz);
699 close_render_engine();
700 gui->lock_window("AssetPicon::create_objects 4");
701 static int line_colors[2] = { GREEN, YELLOW };
702 static int base_colors[2] = { RED, PINK };
703 for( int i=channels; --i>=0; ) {
704 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
705 base_colors[i], line_colors[i]);
707 for( int i=0; i<channels; ++i ) delete samples[i];
708 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
711 pixmap_w = icon_vframe->get_w();
712 pixmap_h = icon_vframe->get_h();
714 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
715 icon->draw_vframe(icon_vframe,
716 0, 0, pixmap_w, pixmap_h, 0, 0);
719 icon = gui->clip_icon;
720 icon_vframe = gui->clip_vframe;
726 strcpy(name, _(plugin->title));
728 icon_vframe = plugin->get_picon();
730 icon = gui->create_pixmap(icon_vframe);
731 else if( plugin->audio ) {
732 if( plugin->transition ) {
733 icon = gui->atransition_icon;
734 icon_vframe = gui->atransition_vframe;
736 else if( plugin->is_ffmpeg() ) {
737 icon = gui->ff_aud_icon;
738 icon_vframe = gui->ff_aud_vframe;
740 else if( plugin->is_ladspa() ) {
741 icon = gui->ladspa_icon;
742 icon_vframe = gui->ladspa_vframe;
745 icon = gui->aeffect_icon;
746 icon_vframe = gui->aeffect_vframe;
749 else if( plugin->video ) {
750 if( plugin->transition ) {
751 icon = gui->vtransition_icon;
752 icon_vframe = gui->vtransition_vframe;
754 else if( plugin->is_ffmpeg() ) {
755 icon = gui->ff_vid_icon;
756 icon_vframe = gui->ff_vid_vframe;
759 icon = gui->veffect_icon;
760 icon_vframe = gui->veffect_vframe;
768 mwindow->edl->session->time_format,
769 mwindow->edl->session->sample_rate,
770 mwindow->edl->session->frame_rate,
771 mwindow->edl->session->frames_per_foot);
773 icon = gui->label_icon;
774 icon_vframe = gui->label_vframe;
777 icon = gui->file_icon;
778 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
781 set_icon_vframe(icon_vframe);
784 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
785 : BC_Window(_(PROGRAM_NAME ": Resources"),
786 mwindow->session->awindow_x, mwindow->session->awindow_y,
787 mwindow->session->awindow_w, mwindow->session->awindow_h,
790 this->mwindow = mwindow;
791 this->awindow = awindow;
793 file_vframe = 0; file_icon = 0;
794 folder_vframe = 0; folder_icon = 0;
795 audio_vframe = 0; audio_icon = 0;
796 video_vframe = 0; video_icon = 0;
797 label_vframe = 0; label_icon = 0;
799 atransition_vframe = 0; atransition_icon = 0;
800 vtransition_vframe = 0; vtransition_icon = 0;
801 aeffect_vframe = 0; aeffect_icon = 0;
802 ladspa_vframe = 0; ladspa_icon = 0;
803 veffect_vframe = 0; veffect_icon = 0;
804 ff_aud_vframe = 0; ff_aud_icon = 0;
805 ff_vid_vframe = 0; ff_vid_icon = 0;
807 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
808 atransition_folder_vframe = 0; atransition_folder_icon = 0;
809 clip_folder_vframe = 0; clip_folder_icon = 0;
810 label_folder_vframe = 0; label_folder_icon = 0;
811 media_folder_vframe = 0; media_folder_icon = 0;
812 proxy_folder_vframe = 0; proxy_folder_icon = 0;
813 veffect_folder_vframe = 0; veffect_folder_icon = 0;
814 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
816 ladspa_vframe = 0; ladspa_icon = 0;
817 ff_aud_vframe = 0; ff_aud_icon = 0;
818 ff_vid_vframe = 0; ff_vid_icon = 0;
820 clip_vframe = 0; clip_icon = 0;
821 atransition_vframe = 0; atransition_icon = 0;
822 vtransition_vframe = 0; vtransition_icon = 0;
823 aeffect_vframe = 0; aeffect_icon = 0;
824 veffect_vframe = 0; veffect_icon = 0;
826 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
827 newfolder_thread = 0;
836 allow_iconlisting = 1;
841 displayed_folder = AW_NO_FOLDER;
844 AWindowGUI::~AWindowGUI()
846 assets.remove_all_objects();
847 folders.remove_all_objects();
848 aeffects.remove_all_objects();
849 veffects.remove_all_objects();
850 atransitions.remove_all_objects();
851 vtransitions.remove_all_objects();
852 labellist.remove_all_objects();
853 displayed_assets[1].remove_all_objects();
857 delete newfolder_thread;
862 delete effectlist_menu;
863 delete assetlist_menu;
864 delete cliplist_menu;
865 delete labellist_menu;
866 delete folderlist_menu;
869 delete remove_plugin;
871 delete file_vframe; delete file_icon;
872 delete folder_vframe; delete folder_icon;
873 delete audio_vframe; delete audio_icon;
874 delete video_vframe; delete video_icon;
875 delete label_vframe; delete label_icon;
876 delete clip_vframe; delete clip_icon;
877 delete aeffect_folder_vframe; delete aeffect_folder_icon;
878 delete atransition_folder_vframe; delete atransition_folder_icon;
879 delete veffect_folder_vframe; delete veffect_folder_icon;
880 delete vtransition_folder_vframe; delete vtransition_folder_icon;
881 delete clip_folder_vframe; delete clip_folder_icon;
882 delete label_folder_vframe; delete label_folder_icon;
883 delete media_folder_vframe; delete media_folder_icon;
884 delete proxy_folder_vframe; delete proxy_folder_icon;
885 delete ladspa_vframe; delete ladspa_icon;
886 delete ff_aud_vframe; delete ff_aud_icon;
887 delete ff_vid_vframe; delete ff_vid_icon;
888 delete atransition_vframe; delete atransition_icon;
889 delete vtransition_vframe; delete vtransition_icon;
890 delete aeffect_vframe; delete aeffect_icon;
891 delete veffect_vframe; delete veffect_icon;
894 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
896 return icon == file_icon ||
897 icon == folder_icon ||
898 icon == audio_icon ||
899 icon == video_icon ||
901 icon == label_icon ||
902 icon == vtransition_icon ||
903 icon == atransition_icon ||
904 icon == veffect_icon ||
905 icon == aeffect_icon ||
906 icon == ladspa_icon ||
907 icon == ff_aud_icon ||
908 icon == ff_vid_icon ||
909 icon == aeffect_folder_icon ||
910 icon == veffect_folder_icon ||
911 icon == atransition_folder_icon ||
912 icon == vtransition_folder_icon ||
913 icon == label_folder_icon ||
914 icon == clip_folder_icon ||
915 icon == media_folder_icon ||
916 icon == proxy_folder_icon;
919 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
921 char png_path[BCTEXTLEN];
922 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
923 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
924 File::get_plugin_path(), plugin_icons, name);
925 if( access(png_path, R_OK) ) return 0;
926 return VFramePng::vframe_png(png_path,0,0);
929 VFrame *AWindowGUI::get_picon(const char *name)
931 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
933 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
934 snprintf(pp, ep-pp, "%s.png", name);
935 unsigned char *data = mwindow->theme->get_image_data(png_name);
936 if( data ) vframe = new VFramePng(data, 0.);
941 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
943 vfrm = get_picon(fn);
944 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
945 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
947 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
949 vfrm = get_picon(fn);
950 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
951 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
953 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
955 vfrm = get_picon(fn);
956 if( !vfrm ) vfrm = new VFramePng(png);
957 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
960 void AWindowGUI::create_objects()
962 lock_window("AWindowGUI::create_objects");
963 asset_titles[0] = C_("Title");
964 asset_titles[1] = _("Comments");
966 set_icon(mwindow->theme->get_image("awindow_icon"));
968 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
969 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
970 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
971 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
972 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
974 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
975 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
976 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
977 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
978 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
979 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
980 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
981 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
983 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
984 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
985 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
986 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
987 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
988 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
989 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
990 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
992 theme_icon(clip_vframe, clip_icon, "clip_icon");
993 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
994 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
995 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
996 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
998 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
999 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1000 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1002 // Mandatory folders
1003 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1004 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1005 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1006 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1007 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1008 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1009 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1010 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1012 create_label_folder();
1014 mwindow->theme->get_awindow_sizes(this);
1015 load_defaults(mwindow->defaults);
1017 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1018 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1019 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1020 search_text->create_objects();
1021 int dy = search_text->get_h() + 10;
1023 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1025 vicon_thread = new VIconThread(asset_list);
1026 vicon_thread->start();
1027 vicon_audio = new AssetVIconAudio(this);
1029 add_subwindow(divider = new AWindowDivider(mwindow, this,
1030 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1031 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1033 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1035 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1036 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1037 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1038 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1039 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1040 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1041 add_tools->create_objects();
1042 fy += add_tools->get_h(); fh -= add_tools->get_h();
1043 add_subwindow(folder_list = new AWindowFolders(mwindow,
1044 this, fx, fy, fw, fh));
1047 //int x = mwindow->theme->abuttons_x;
1048 //int y = mwindow->theme->abuttons_y;
1051 newfolder_thread = new NewFolderThread(mwindow, this);
1053 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1054 asset_menu->create_objects();
1055 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1056 clip_menu->create_objects();
1057 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1058 label_menu->create_objects();
1060 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1061 effectlist_menu->create_objects();
1062 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1063 assetlist_menu->create_objects();
1064 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1065 cliplist_menu->create_objects();
1066 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1067 labellist_menu->create_objects();
1069 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1070 folderlist_menu->create_objects();
1072 create_custom_xatoms();
1076 int AWindowGUI::resize_event(int w, int h)
1078 mwindow->session->awindow_x = get_x();
1079 mwindow->session->awindow_y = get_y();
1080 mwindow->session->awindow_w = w;
1081 mwindow->session->awindow_h = h;
1083 mwindow->theme->get_awindow_sizes(this);
1084 mwindow->theme->draw_awindow_bg(this);
1085 reposition_objects();
1087 // int x = mwindow->theme->abuttons_x;
1088 // int y = mwindow->theme->abuttons_y;
1089 // new_bin->reposition_window(x, y);
1090 // x += new_bin->get_w();
1091 // delete_bin->reposition_window(x, y);
1092 // x += delete_bin->get_w();
1093 // rename_bin->reposition_window(x, y);
1094 // x += rename_bin->get_w();
1095 // delete_disk->reposition_window(x, y);
1096 // x += delete_disk->get_w();
1097 // delete_project->reposition_window(x, y);
1098 // x += delete_project->get_w();
1099 // info->reposition_window(x, y);
1100 // x += info->get_w();
1101 // redraw_index->reposition_window(x, y);
1102 // x += redraw_index->get_w();
1103 // paste->reposition_window(x, y);
1104 // x += paste->get_w();
1105 // append->reposition_window(x, y);
1106 // x += append->get_w();
1107 // view->reposition_window(x, y);
1109 BC_WindowBase::resize_event(w, h);
1113 int AWindowGUI::translation_event()
1115 mwindow->session->awindow_x = get_x();
1116 mwindow->session->awindow_y = get_y();
1120 void AWindowGUI::reposition_objects()
1122 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1123 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1124 search_text->reposition_window(x1, y1+5, w1);
1125 int dy = search_text->get_h() + 10;
1127 asset_list->reposition_window(x1, y1, w1, h1);
1128 divider->reposition_window(
1129 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1130 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1131 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1132 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1133 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1134 avicon_drawing->reposition_window(fw-avicon_w, fy);
1135 fy += add_tools->get_h(); fh -= add_tools->get_h();
1136 folder_list->reposition_window(fx, fy, fw, fh);
1139 int AWindowGUI::save_defaults(BC_Hash *defaults)
1141 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1142 defaults->update("VICON_DRAWING", vicon_drawing);
1146 int AWindowGUI::load_defaults(BC_Hash *defaults)
1148 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1149 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1153 int AWindowGUI::close_event()
1156 mwindow->session->show_awindow = 0;
1159 mwindow->gui->lock_window("AWindowGUI::close_event");
1160 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1161 mwindow->gui->unlock_window();
1163 lock_window("AWindowGUI::close_event");
1164 save_defaults(mwindow->defaults);
1165 mwindow->save_defaults();
1169 void AWindowGUI::start_vicon_drawing()
1171 if( !vicon_drawing ) return;
1172 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
1173 if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
1174 vicon_thread->start_drawing();
1177 void AWindowGUI::stop_vicon_drawing()
1179 vicon_thread->stop_drawing();
1182 AWindowRemovePluginGUI::
1183 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1184 int x, int y, PluginServer *plugin)
1185 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1187 this->awindow = awindow;
1188 this->thread = thread;
1189 this->plugin = plugin;
1190 VFrame *vframe = plugin->get_picon();
1191 icon = vframe ? create_pixmap(vframe) : 0;
1192 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1195 AWindowRemovePluginGUI::
1196 ~AWindowRemovePluginGUI()
1198 if( !awindow->gui->protected_pixmap(icon) )
1200 plugin_list.remove_all();
1203 void AWindowRemovePluginGUI::create_objects()
1205 BC_Button *ok_button = new BC_OKButton(this);
1206 add_subwindow(ok_button);
1207 BC_Button *cancel_button = new BC_CancelButton(this);
1208 add_subwindow(cancel_button);
1210 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1211 add_subwindow(title);
1212 y += title->get_h() + 5;
1213 list = new BC_ListBox(x, y,
1214 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1215 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1216 add_subwindow(list);
1220 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1223 for( int i=0; i<folder.size(); ) {
1224 AssetPicon *picon = (AssetPicon *)folder[i];
1225 if( picon->plugin == plugin ) {
1226 folder.remove_object_number(i);
1235 void AWindowRemovePlugin::handle_close_event(int result)
1238 printf(_("remove %s\n"), plugin->path);
1239 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1240 ArrayList<BC_ListBoxItem*> *folder =
1241 plugin->audio ? plugin->transition ?
1242 &awindow->gui->atransitions :
1243 &awindow->gui->aeffects :
1244 plugin->video ? plugin->transition ?
1245 &awindow->gui->vtransitions :
1246 &awindow->gui->veffects :
1248 if( folder ) remove_plugin(plugin, *folder);
1249 MWindow *mwindow = awindow->mwindow;
1250 awindow->gui->unlock_window();
1251 char plugin_path[BCTEXTLEN];
1252 strcpy(plugin_path, plugin->path);
1253 mwindow->plugindb->remove(plugin);
1254 remove(plugin_path);
1255 char index_path[BCTEXTLEN];
1256 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1258 char picon_path[BCTEXTLEN];
1260 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1261 File::get_plugin_path());
1262 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1263 plugin->get_plugin_png_name(png_name);
1264 fs.update(picon_path);
1265 for( int i=0; i<fs.dir_list.total; ++i ) {
1266 char *fs_path = fs.dir_list[i]->path;
1267 if( !fs.is_dir(fs_path) ) continue;
1268 snprintf(png_path, sizeof(picon_path), "%s/%s",
1272 delete plugin; plugin = 0;
1273 awindow->gui->async_update_assets();
1277 AWindowRemovePlugin::
1278 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1281 this->awindow = awindow;
1282 this->plugin = plugin;
1285 AWindowRemovePlugin::
1286 ~AWindowRemovePlugin()
1291 BC_Window* AWindowRemovePlugin::new_gui()
1293 int x = awindow->gui->get_abs_cursor_x(0);
1294 int y = awindow->gui->get_abs_cursor_y(0);
1295 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1296 gui->create_objects();
1300 int AWindowGUI::keypress_event()
1302 switch( get_keypress() ) {
1310 if( shift_down() ) {
1311 PluginServer* plugin = selected_plugin();
1312 if( !plugin ) break;
1313 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1315 remove_plugin->start();
1324 int AWindowGUI::create_custom_xatoms()
1326 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1329 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
1331 if( event->message_type == UpdateAssetsXAtom ) {
1338 void AWindowGUI::async_update_assets()
1341 event.message_type = UpdateAssetsXAtom;
1342 send_custom_xatom(&event);
1346 void AWindowGUI::update_folder_list()
1348 for( int i = 0; i < folders.total; i++ ) {
1349 AssetPicon *picon = (AssetPicon*)folders.values[i];
1353 // Search assets for folders
1354 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1355 const char *folder = mwindow->edl->folders.values[i];
1358 for( int j = 0; j < folders.total; j++ ) {
1359 AssetPicon *picon = (AssetPicon*)folders.values[j];
1360 if( !strcasecmp(picon->get_text(), folder) ) {
1368 int aw_folder = folder_number(folder);
1369 if( aw_folder >= 0 ) {
1370 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
1371 picon->create_objects();
1372 folders.append(picon);
1377 // Delete unused non-persistent folders
1378 for( int i=folders.total; --i>=0; ) {
1379 AssetPicon *picon = (AssetPicon*)folders.values[i];
1380 if( !picon->in_use && !picon->persistent ) {
1382 folders.remove_number(i);
1387 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1388 int do_audio, int do_video, int is_realtime, int is_transition)
1390 ArrayList<PluginServer*> plugin_list;
1391 // Get pointers to plugindb entries
1392 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1395 for( int i = 0; i < plugin_list.total; i++ ) {
1396 PluginServer *server = plugin_list.values[i];
1397 int visible = plugin_visibility & (1<<server->dir_idx);
1398 if( !visible ) continue;
1399 // Create new listitem
1400 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1401 picon->create_objects();
1402 output->append(picon);
1406 void AWindowGUI::create_label_folder()
1409 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1410 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1411 picon->create_objects();
1412 labellist.append(picon);
1417 void AWindowGUI::update_asset_list()
1419 for( int i = 0; i < assets.total; i++ ) {
1420 AssetPicon *picon = (AssetPicon*)assets.values[i];
1424 // Synchronize EDL clips
1425 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1428 // Look for clip in existing listitems
1429 for( int j = 0; j < assets.total && !exists; j++ ) {
1430 AssetPicon *picon = (AssetPicon*)assets.values[j];
1432 if( picon->id == mwindow->edl->clips[i]->id ) {
1433 picon->edl = mwindow->edl->clips[i];
1434 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1440 // Create new listitem
1442 AssetPicon *picon = new AssetPicon(mwindow,
1443 this, mwindow->edl->clips[i]);
1444 picon->create_objects();
1445 assets.append(picon);
1449 // Synchronize EDL assets
1450 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1453 // Look for asset in existing listitems
1454 for( int j = 0; j < assets.total && !exists; j++ ) {
1455 AssetPicon *picon = (AssetPicon*)assets.values[j];
1457 if( picon->id == current->id ) {
1458 picon->indexable = current;
1464 // Create new listitem
1466 AssetPicon *picon = new AssetPicon(mwindow,
1468 picon->create_objects();
1469 assets.append(picon);
1473 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1474 mwindow->gui->default_message();
1475 mwindow->gui->unlock_window();
1477 // Synchronize nested EDLs
1478 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1480 EDL *nested_edl = mwindow->edl->nested_edls[i];
1482 // Look for asset in existing listitems
1483 for( int j=0; j<assets.total && !exists; ++j ) {
1484 AssetPicon *picon = (AssetPicon*)assets.values[j];
1486 if( picon->id == nested_edl->id ) {
1487 picon->indexable = nested_edl;
1493 // Create new listitem
1495 AssetPicon *picon = new AssetPicon(mwindow,
1496 this, (Indexable*)nested_edl);
1497 picon->create_objects();
1498 assets.append(picon);
1502 for( int i = assets.size() - 1; i >= 0; i-- ) {
1503 AssetPicon *picon = (AssetPicon*)assets.get(i);
1504 if( !picon->in_use ) {
1506 assets.remove_number(i);
1509 if( !picon->indexable || !picon->indexable->is_asset ) continue;
1511 picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
1515 void AWindowGUI::update_picon(Indexable *indexable)
1518 for( int i = 0; i < assets.total; i++ ) {
1519 AssetPicon *picon = (AssetPicon*)assets.values[i];
1520 if( picon->indexable == indexable ||
1521 picon->edl == (EDL *)indexable ) {
1522 char name[BCTEXTLEN];
1524 fs.extract_name(name, indexable->path);
1525 picon->set_text(name);
1526 vicon = picon->vicon;
1531 stop_vicon_drawing();
1532 vicon->clear_images();
1533 vicon->reset(indexable->get_frame_rate());
1534 start_vicon_drawing();
1538 void AWindowGUI::sort_assets(int use_mtime)
1540 switch( mwindow->edl->session->awindow_folder ) {
1541 case AW_AEFFECT_FOLDER:
1542 sort_picons(&aeffects);
1544 case AW_VEFFECT_FOLDER:
1545 sort_picons(&veffects);
1547 case AW_ATRANSITION_FOLDER:
1548 sort_picons(&atransitions);
1550 case AW_VTRANSITION_FOLDER:
1551 sort_picons(&vtransitions);
1553 case AW_LABEL_FOLDER:
1554 sort_picons(&labellist);
1557 sort_picons(&assets, use_mtime);
1560 asset_list->update_format(asset_list->get_format(), 0);
1564 void AWindowGUI::sort_folders()
1566 sort_picons(&folders);
1567 folder_list->update_format(folder_list->get_format(), 0);
1571 void AWindowGUI::collect_assets()
1574 mwindow->session->drag_assets->remove_all();
1575 mwindow->session->drag_clips->remove_all();
1578 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1579 if( !result ) break;
1581 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1582 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1586 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1587 ArrayList<BC_ListBoxItem*> *src, int folder)
1589 // Remove current pointers
1590 dst[0].remove_all();
1591 dst[1].remove_all_objects();
1593 // Create new pointers
1594 for( int i = 0; i < src->total; i++ ) {
1595 AssetPicon *picon = (AssetPicon*)src->values[i];
1597 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1598 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1599 const char *text = search_text->get_text();
1600 int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
1601 if( picon->vicon ) picon->vicon->hidden = hidden;
1602 if( hidden ) continue;
1603 BC_ListBoxItem *item2, *item1;
1604 dst[0].append(item1 = picon);
1606 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1608 if( picon->label && picon->label->textstr )
1609 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1610 else if( picon->mtime ) {
1611 char date_time[BCSTRLEN];
1612 struct tm stm; localtime_r(&picon->mtime, &stm);
1613 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1614 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1615 stm.tm_hour, stm.tm_min, stm.tm_sec);
1616 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1619 dst[1].append(item2 = new BC_ListBoxItem(""));
1620 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1621 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1626 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
1628 int done = 0, changed = 0;
1631 for( int i=0; i<src->total-1; ++i ) {
1632 AssetPicon *item1 = (AssetPicon *)src->values[i];
1633 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1634 if( use_mtime ? item1->mtime > item2->mtime :
1635 strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1636 src->values[i + 1] = item1;
1637 src->values[i] = item2;
1638 done = 0; changed = 1;
1643 for( int i=0; i<src->total; ++i ) {
1644 AssetPicon *item = (AssetPicon *)src->values[i];
1645 item->set_autoplace_icon(1);
1646 item->set_autoplace_text(1);
1652 void AWindowGUI::filter_displayed_assets()
1654 //allow_iconlisting = 1;
1655 asset_titles[0] = C_("Title");
1656 asset_titles[1] = _("Comments");
1658 switch( mwindow->edl->session->awindow_folder ) {
1659 case AW_AEFFECT_FOLDER:
1660 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1662 case AW_VEFFECT_FOLDER:
1663 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1665 case AW_ATRANSITION_FOLDER:
1666 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1668 case AW_VTRANSITION_FOLDER:
1669 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1671 case AW_LABEL_FOLDER:
1672 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1673 asset_titles[0] = _("Time Stamps");
1674 asset_titles[1] = C_("Title");
1675 //allow_iconlisting = 0;
1678 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1682 // Ensure the current folder icon is highlighted
1683 int selected_folder = mwindow->edl->session->awindow_folder;
1684 for( int i = 0; i < folders.total; i++ ) {
1685 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1686 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1687 folder_item->set_selected(selected);
1692 void AWindowGUI::update_assets()
1694 stop_vicon_drawing();
1695 update_folder_list();
1696 update_asset_list();
1697 labellist.remove_all_objects();
1698 create_label_folder();
1700 if( displayed_folder != mwindow->edl->session->awindow_folder )
1701 search_text->clear();
1702 filter_displayed_assets();
1704 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1705 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1707 int folder_xposition = folder_list->get_xposition();
1708 int folder_yposition = folder_list->get_yposition();
1709 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1711 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1712 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1714 int asset_xposition = asset_list->get_xposition();
1715 int asset_yposition = asset_list->get_yposition();
1716 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1717 displayed_folder = mwindow->edl->session->awindow_folder;
1718 asset_xposition = asset_yposition = 0;
1720 asset_list->update(displayed_assets, asset_titles,
1721 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1722 asset_xposition, asset_yposition, -1, 0);
1723 asset_list->center_selection();
1726 start_vicon_drawing();
1730 void AWindowGUI::update_effects()
1732 aeffects.remove_all_objects();
1733 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1734 veffects.remove_all_objects();
1735 create_persistent_folder(&veffects, 0, 1, 1, 0);
1736 atransitions.remove_all_objects();
1737 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1738 vtransitions.remove_all_objects();
1739 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1742 int AWindowGUI::folder_number(const char *name)
1744 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1745 if( !strcasecmp(name, folder_names[i]) ) return i;
1747 return AW_NO_FOLDER;
1750 int AWindowGUI::drag_motion()
1752 if( get_hidden() ) return 0;
1758 int AWindowGUI::drag_stop()
1760 if( get_hidden() ) return 0;
1765 Indexable* AWindowGUI::selected_asset()
1767 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1768 return picon ? picon->indexable : 0;
1771 PluginServer* AWindowGUI::selected_plugin()
1773 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1774 return picon ? picon->plugin : 0;
1777 AssetPicon* AWindowGUI::selected_folder()
1779 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1790 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1791 : BC_SubWindow(x, y, w, h)
1793 this->mwindow = mwindow;
1796 AWindowDivider::~AWindowDivider()
1800 int AWindowDivider::button_press_event()
1802 if( is_event_win() && cursor_inside() ) {
1803 mwindow->session->current_operation = DRAG_PARTITION;
1809 int AWindowDivider::cursor_motion_event()
1811 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1813 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1814 int fw = gui->get_relative_cursor_x();
1815 if( fw > wmax ) fw = wmax;
1816 if( fw < wmin ) fw = wmin;
1817 mwindow->session->afolders_w = fw;
1818 mwindow->theme->get_awindow_sizes(gui);
1819 gui->reposition_objects();
1825 int AWindowDivider::button_release_event()
1827 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1828 mwindow->session->current_operation = NO_OPERATION;
1839 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1840 : BC_ListBox(x, y, w, h,
1841 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1842 LISTBOX_ICONS : LISTBOX_TEXT,
1843 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1844 0, // Titles for columns. Set to 0 for no titles
1845 0, // width of each column
1846 1, // Total columns.
1847 0, // Pixel of top of window.
1848 0, // If this listbox is a popup window
1849 LISTBOX_SINGLE, // Select one item or multiple items
1850 ICON_TOP, // Position of icon relative to text of each item
1853 this->mwindow = mwindow;
1858 AWindowFolders::~AWindowFolders()
1862 int AWindowFolders::selection_changed()
1864 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1866 gui->stop_vicon_drawing();
1868 if( get_button_down() && get_buttonpress() == 3 ) {
1869 gui->folderlist_menu->update_titles();
1870 gui->folderlist_menu->activate_menu();
1873 mwindow->edl->session->awindow_folder = picon->foldernum;
1874 gui->asset_list->draw_background();
1875 gui->async_update_assets();
1877 gui->start_vicon_drawing();
1882 int AWindowFolders::button_press_event()
1886 result = BC_ListBox::button_press_event();
1889 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1890 gui->folderlist_menu->update_titles();
1891 gui->folderlist_menu->activate_menu();
1906 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1907 : BC_ListBox(x, y, w, h,
1908 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1909 LISTBOX_ICONS : LISTBOX_TEXT,
1910 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1911 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1912 mwindow->edl->session->asset_columns, // width of each column
1913 1, // Total columns.
1914 0, // Pixel of top of window.
1915 0, // If this listbox is a popup window
1916 LISTBOX_MULTIPLE, // Select one item or multiple items
1917 ICON_TOP, // Position of icon relative to text of each item
1918 -1) // Allow drags, require shift for scrolling
1920 this->mwindow = mwindow;
1923 set_scroll_stretch(1, 1);
1926 AWindowAssets::~AWindowAssets()
1930 int AWindowAssets::button_press_event()
1934 result = BC_ListBox::button_press_event();
1936 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1937 BC_ListBox::deactivate_selection();
1938 int folder = mwindow->edl->session->awindow_folder;
1940 case AW_AEFFECT_FOLDER:
1941 case AW_VEFFECT_FOLDER:
1942 case AW_ATRANSITION_FOLDER:
1943 case AW_VTRANSITION_FOLDER:
1944 gui->effectlist_menu->update();
1945 gui->effectlist_menu->activate_menu();
1947 case AW_LABEL_FOLDER:
1948 gui->labellist_menu->update();
1949 gui->labellist_menu->activate_menu();
1951 case AW_CLIP_FOLDER:
1952 gui->cliplist_menu->update();
1953 gui->cliplist_menu->activate_menu();
1955 case AW_MEDIA_FOLDER:
1956 case AW_PROXY_FOLDER:
1957 gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
1958 gui->assetlist_menu->activate_menu();
1968 int AWindowAssets::handle_event()
1970 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
1971 if( !asset_picon ) return 0;
1972 switch( mwindow->edl->session->awindow_folder ) {
1973 case AW_AEFFECT_FOLDER:
1974 case AW_VEFFECT_FOLDER:
1975 case AW_ATRANSITION_FOLDER:
1976 case AW_VTRANSITION_FOLDER: return 1;
1978 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1979 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1980 if( !vwindow || !vwindow->is_running() ) return 1;
1982 if( asset_picon->indexable )
1983 vwindow->change_source(asset_picon->indexable);
1984 else if( asset_picon->edl )
1985 vwindow->change_source(asset_picon->edl);
1989 int AWindowAssets::selection_changed()
1991 // Show popup window
1993 if( get_button_down() && get_buttonpress() == 3 &&
1994 (item = (AssetPicon*)get_selection(0, 0)) ) {
1995 int folder = mwindow->edl->session->awindow_folder;
1997 case AW_AEFFECT_FOLDER:
1998 case AW_VEFFECT_FOLDER:
1999 case AW_ATRANSITION_FOLDER:
2000 case AW_VTRANSITION_FOLDER:
2001 gui->effectlist_menu->update();
2002 gui->effectlist_menu->activate_menu();
2004 case AW_LABEL_FOLDER:
2005 if( !item->label ) break;
2006 gui->label_menu->activate_menu();
2008 case AW_CLIP_FOLDER:
2009 if( !item->indexable && !item->edl ) break;
2010 gui->clip_menu->update();
2011 gui->clip_menu->activate_menu();
2014 if( !item->indexable && !item->edl ) break;
2015 gui->asset_menu->update();
2016 gui->asset_menu->activate_menu();
2020 BC_ListBox::deactivate_selection();
2023 else if( gui->vicon_drawing &&
2024 get_button_down() && get_buttonpress() == 1 &&
2025 (item = (AssetPicon*)get_selection(0, 0)) ) {
2027 if( !gui->vicon_thread->viewing ) {
2028 vicon = item->vicon;
2030 gui->vicon_thread->set_view_popup(vicon);
2036 void AWindowAssets::draw_background()
2038 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2039 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2040 set_font(LARGEFONT);
2041 int aw_folder = mwindow->edl->session->awindow_folder;
2042 if( aw_folder < 0 ) return;
2043 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
2044 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
2045 aw_name, -1, get_bg_surface());
2048 int AWindowAssets::drag_start_event()
2050 int collect_pluginservers = 0;
2051 int collect_assets = 0;
2053 if( BC_ListBox::drag_start_event() ) {
2054 switch( mwindow->edl->session->awindow_folder ) {
2055 case AW_AEFFECT_FOLDER:
2056 mwindow->session->current_operation = DRAG_AEFFECT;
2057 collect_pluginservers = 1;
2059 case AW_VEFFECT_FOLDER:
2060 mwindow->session->current_operation = DRAG_VEFFECT;
2061 collect_pluginservers = 1;
2063 case AW_ATRANSITION_FOLDER:
2064 mwindow->session->current_operation = DRAG_ATRANSITION;
2065 collect_pluginservers = 1;
2067 case AW_VTRANSITION_FOLDER:
2068 mwindow->session->current_operation = DRAG_VTRANSITION;
2069 collect_pluginservers = 1;
2071 case AW_LABEL_FOLDER:
2075 mwindow->session->current_operation = DRAG_ASSET;
2080 if( collect_pluginservers ) {
2082 mwindow->session->drag_pluginservers->remove_all();
2085 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2086 if( !result ) break;
2088 mwindow->session->drag_pluginservers->append(result->plugin);
2092 if( collect_assets ) {
2093 gui->collect_assets();
2101 int AWindowAssets::drag_motion_event()
2103 BC_ListBox::drag_motion_event();
2106 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2107 mwindow->gui->drag_motion();
2108 mwindow->gui->unlock_window();
2110 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2111 VWindow *vwindow = mwindow->vwindows.get(i);
2112 if( !vwindow->is_running() ) continue;
2113 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2114 vwindow->gui->drag_motion();
2115 vwindow->gui->unlock_window();
2118 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2119 mwindow->cwindow->gui->drag_motion();
2120 mwindow->cwindow->gui->unlock_window();
2122 lock_window("AWindowAssets::drag_motion_event");
2126 int AWindowAssets::drag_stop_event()
2130 result = gui->drag_stop();
2135 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2136 result = mwindow->gui->drag_stop();
2137 mwindow->gui->unlock_window();
2141 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2142 VWindow *vwindow = mwindow->vwindows.get(i);
2143 if( !vwindow ) continue;
2144 if( !vwindow->is_running() ) continue;
2145 if( vwindow->gui->is_hidden() ) continue;
2146 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2147 if( vwindow->gui->cursor_above() &&
2148 vwindow->gui->get_cursor_over_window() ) {
2149 result = vwindow->gui->drag_stop();
2151 vwindow->gui->unlock_window();
2156 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2157 result = mwindow->cwindow->gui->drag_stop();
2158 mwindow->cwindow->gui->unlock_window();
2161 lock_window("AWindowAssets::drag_stop_event");
2164 get_drag_popup()->set_animation(0);
2166 BC_ListBox::drag_stop_event();
2167 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2168 mwindow->session->current_operation = ::NO_OPERATION;
2172 int AWindowAssets::column_resize_event()
2174 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2175 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2179 int AWindowAssets::focus_in_event()
2181 gui->start_vicon_drawing();
2185 int AWindowAssets::focus_out_event()
2187 gui->stop_vicon_drawing();
2188 return BC_ListBox::focus_out_event();
2191 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2192 : BC_TextBox(x, y, w, 1, "")
2194 this->search_text = search_text;
2197 int AWindowSearchTextBox::handle_event()
2199 return search_text->handle_event();
2202 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2204 this->mwindow = mwindow;
2210 void AWindowSearchText::create_objects()
2212 int x1 = x, y1 = y, margin = 10;
2213 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2214 x1 += text_title->get_w() + margin;
2215 int w1 = gui->get_w() - x1 - 2*margin;
2216 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2219 int AWindowSearchText::handle_event()
2221 gui->async_update_assets();
2225 int AWindowSearchText::get_w()
2227 return text_box->get_w() + text_title->get_w() + 10;
2230 int AWindowSearchText::get_h()
2232 return bmax(text_box->get_h(),text_title->get_h());
2235 void AWindowSearchText::reposition_window(int x, int y, int w)
2237 int x1 = x, y1 = y, margin = 10;
2238 text_title->reposition_window(x1, y1);
2239 x1 += text_title->get_w() + margin;
2240 int w1 = gui->get_w() - x1 - 2*margin;
2241 text_box->reposition_window(x1, y1, w1);
2244 const char *AWindowSearchText::get_text()
2246 return text_box->get_text();
2249 void AWindowSearchText::clear()
2251 text_box->update("");
2254 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2255 : BC_Button(x, y, mwindow->theme->newbin_data)
2257 this->mwindow = mwindow;
2259 set_tooltip(_("New bin"));
2262 int AWindowNewFolder::handle_event()
2264 gui->newfolder_thread->start_new_folder();
2268 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2269 : BC_Button(x, y, mwindow->theme->deletebin_data)
2271 this->mwindow = mwindow;
2273 set_tooltip(_("Delete bin"));
2276 int AWindowDeleteFolder::handle_event()
2278 if( gui->folder_list->get_selection(0, 0) ) {
2279 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
2280 mwindow->delete_folder(folder->get_text());
2285 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2286 : BC_Button(x, y, mwindow->theme->renamebin_data)
2288 this->mwindow = mwindow;
2290 set_tooltip(_("Rename bin"));
2293 int AWindowRenameFolder::handle_event()
2298 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2299 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2301 this->mwindow = mwindow;
2303 set_tooltip(_("Delete asset from disk"));
2306 int AWindowDeleteDisk::handle_event()
2311 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2312 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2314 this->mwindow = mwindow;
2316 set_tooltip(_("Delete asset from project"));
2319 int AWindowDeleteProject::handle_event()
2324 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2325 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2327 // this->mwindow = mwindow;
2329 // set_tooltip(_("Edit information on asset"));
2332 // int AWindowInfo::handle_event()
2334 // int cur_x, cur_y;
2335 // gui->get_abs_cursor(cur_x, cur_y, 0);
2336 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2340 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2341 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2343 this->mwindow = mwindow;
2345 set_tooltip(_("Redraw index"));
2348 int AWindowRedrawIndex::handle_event()
2353 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2354 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2356 this->mwindow = mwindow;
2358 set_tooltip(_("Paste asset on recordable tracks"));
2361 int AWindowPaste::handle_event()
2366 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2367 : BC_Button(x, y, mwindow->theme->appendasset_data)
2369 this->mwindow = mwindow;
2371 set_tooltip(_("Append asset in new tracks"));
2374 int AWindowAppend::handle_event()
2379 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2380 : BC_Button(x, y, mwindow->theme->viewasset_data)
2382 this->mwindow = mwindow;
2384 set_tooltip(_("View asset"));
2387 int AWindowView::handle_event()
2392 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2393 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2395 this->mwindow = mwindow;
2399 void AddTools::create_objects()
2402 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2403 vis |= 1 << PLUGIN_LADSPA_ID;
2404 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2405 vis |= 1 << PLUGIN_FFMPEG_ID;
2406 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2407 PluginServer *plugin = MWindow::plugindb->get(i);
2408 if( !plugin->audio && !plugin->video ) continue;
2409 int idx = plugin->dir_idx;
2410 uint32_t msk = 1 << idx;
2411 if( (msk & vis) != 0 ) continue;
2413 char parent[BCTEXTLEN];
2414 strcpy(parent, plugin->path);
2415 char *bp = strrchr(parent, '/');
2416 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2417 if( !bp ) bp = parent; else ++bp;
2418 add_item(new AddPluginItem(this, bp, idx));
2423 // plugin_dirs list from toplevel makefile include plugin_defs
2427 N_("audio_transitions")
2434 N_("video_transitions")
2437 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2438 : BC_MenuItem(_(text))
2442 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2443 int chk = (msk & vis) ? 1 : 0;
2447 int AddPluginItem::handle_event()
2449 int chk = get_checked() ^ 1;
2451 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2452 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2453 menu->gui->update_effects();
2454 menu->gui->save_defaults(menu->mwindow->defaults);
2455 menu->gui->async_update_assets();
2459 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2460 : BC_Toggle(x, y, images, agui->vicon_drawing)
2463 set_tooltip(_("draw vicons"));
2466 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2468 int text_line = -1, toggle_x = -1, toggle_y = -1;
2469 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2470 BC_Toggle::calculate_extents(agui, images, 1,
2471 &text_line, ww, hh, &toggle_x, &toggle_y,
2472 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2475 AVIconDrawing::~AVIconDrawing()
2479 int AVIconDrawing::handle_event()
2481 agui->vicon_drawing = get_value();
2482 if( agui->vicon_drawing )
2483 agui->start_vicon_drawing();
2485 agui->stop_vicon_drawing();
2490 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2493 this->mwindow = mwindow;
2497 int AWindowListFormat::handle_event()
2499 gui->stop_vicon_drawing();
2501 EDLSession *session = mwindow->edl->session;
2502 switch( session->assetlist_format ) {
2504 session->assetlist_format = ASSETS_ICONS;
2507 session->assetlist_format = ASSETS_TEXT;
2511 gui->asset_list->update_format(session->assetlist_format, 1);
2512 if( !mwindow->awindow->gui->allow_iconlisting ) {
2513 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2516 gui->start_vicon_drawing();
2520 void AWindowListFormat::update()
2522 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2523 (char*)_("Display icons") : (char*)_("Display text"));
2526 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2527 : BC_MenuItem(_("Sort items"))
2529 this->mwindow = mwindow;
2533 int AWindowListSort::handle_event()
2535 gui->sort_assets(0);