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 printf("render clip: %s\n", name);
626 int edl_h = edl->get_h(), edl_w = edl->get_w();
627 int height = edl_h > 0 ? edl_h : 1;
628 int width = edl_w > 0 ? edl_w : 1;
629 int color_model = edl->session->color_model;
630 pixmap_w = pixmap_h * width / height;
632 if( gui->temp_picon &&
633 (gui->temp_picon->get_color_model() != color_model ||
634 gui->temp_picon->get_w() != width ||
635 gui->temp_picon->get_h() != height) ) {
636 delete gui->temp_picon; gui->temp_picon = 0;
639 if( !gui->temp_picon ) {
640 gui->temp_picon = new VFrame(0, -1,
641 width, height, color_model, -1);
643 char string[BCTEXTLEN];
644 sprintf(string, _("Rendering %s"), name);
645 mwindow->gui->lock_window("AssetPicon::create_objects");
646 mwindow->gui->show_message(string);
647 mwindow->gui->unlock_window();
648 open_render_engine(edl, 0);
649 render_video(0, gui->temp_picon);
650 close_render_engine();
651 gui->lock_window("AssetPicon::create_objects 0");
652 icon_vframe = new VFrame(0,
653 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
654 icon_vframe->transfer_from(gui->temp_picon);
655 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
658 pixmap_w = icon_vframe->get_w();
659 pixmap_h = icon_vframe->get_h();
661 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
662 icon->draw_vframe(icon_vframe,
663 0, 0, pixmap_w, pixmap_h, 0, 0);
666 icon = gui->clip_icon;
667 icon_vframe = gui->clip_vframe;
671 if( edl->tracks->playable_audio_tracks() ) {
672 if( mwindow->preferences->use_thumbnails ) {
673 gui->unlock_window();
674 char clip_icon_path[BCTEXTLEN];
675 char *clip_icon = edl->local_session->clip_icon;
677 snprintf(clip_icon_path, sizeof(clip_icon_path),
678 "%s/%s", File::get_config_path(), clip_icon);
679 icon_vframe = VFramePng::vframe_png(clip_icon_path);
682 pixmap_w = pixmap_h * 16/9;
683 icon_vframe = new VFrame(0,
684 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
685 char string[BCTEXTLEN];
686 sprintf(string, _("Rendering %s"), name);
687 mwindow->gui->lock_window("AssetPicon::create_objects 3");
688 mwindow->gui->show_message(string);
689 mwindow->gui->unlock_window();
690 int sample_rate = edl->get_sample_rate();
691 int channels = edl->get_audio_channels();
692 if( channels > 2 ) channels = 2;
693 int64_t audio_samples = edl->get_audio_samples();
694 double duration = (double)audio_samples / sample_rate;
695 draw_hue_bar(icon_vframe, duration);
696 Samples *samples[MAX_CHANNELS];
697 int bfrsz = sample_rate;
698 for( int i=0; i<MAX_CHANNELS; ++i )
699 samples[i] = i<channels ? new Samples(bfrsz) : 0;
700 open_render_engine(edl, 1);
701 render_audio(0, samples, bfrsz);
702 close_render_engine();
703 gui->lock_window("AssetPicon::create_objects 4");
704 static int line_colors[2] = { GREEN, YELLOW };
705 static int base_colors[2] = { RED, PINK };
706 for( int i=channels; --i>=0; ) {
707 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
708 base_colors[i], line_colors[i]);
710 for( int i=0; i<channels; ++i ) delete samples[i];
711 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
714 pixmap_w = icon_vframe->get_w();
715 pixmap_h = icon_vframe->get_h();
717 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
718 icon->draw_vframe(icon_vframe,
719 0, 0, pixmap_w, pixmap_h, 0, 0);
722 icon = gui->clip_icon;
723 icon_vframe = gui->clip_vframe;
729 strcpy(name, _(plugin->title));
731 icon_vframe = plugin->get_picon();
733 icon = gui->create_pixmap(icon_vframe);
734 else if( plugin->audio ) {
735 if( plugin->transition ) {
736 icon = gui->atransition_icon;
737 icon_vframe = gui->atransition_vframe;
739 else if( plugin->is_ffmpeg() ) {
740 icon = gui->ff_aud_icon;
741 icon_vframe = gui->ff_aud_vframe;
743 else if( plugin->is_ladspa() ) {
744 icon = gui->ladspa_icon;
745 icon_vframe = gui->ladspa_vframe;
748 icon = gui->aeffect_icon;
749 icon_vframe = gui->aeffect_vframe;
752 else if( plugin->video ) {
753 if( plugin->transition ) {
754 icon = gui->vtransition_icon;
755 icon_vframe = gui->vtransition_vframe;
757 else if( plugin->is_ffmpeg() ) {
758 icon = gui->ff_vid_icon;
759 icon_vframe = gui->ff_vid_vframe;
762 icon = gui->veffect_icon;
763 icon_vframe = gui->veffect_vframe;
771 mwindow->edl->session->time_format,
772 mwindow->edl->session->sample_rate,
773 mwindow->edl->session->frame_rate,
774 mwindow->edl->session->frames_per_foot);
776 icon = gui->label_icon;
777 icon_vframe = gui->label_vframe;
780 icon = gui->file_icon;
781 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
784 set_icon_vframe(icon_vframe);
787 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
788 : BC_Window(_(PROGRAM_NAME ": Resources"),
789 mwindow->session->awindow_x, mwindow->session->awindow_y,
790 mwindow->session->awindow_w, mwindow->session->awindow_h,
793 this->mwindow = mwindow;
794 this->awindow = awindow;
796 file_vframe = 0; file_icon = 0;
797 folder_vframe = 0; folder_icon = 0;
798 audio_vframe = 0; audio_icon = 0;
799 video_vframe = 0; video_icon = 0;
800 label_vframe = 0; label_icon = 0;
802 atransition_vframe = 0; atransition_icon = 0;
803 vtransition_vframe = 0; vtransition_icon = 0;
804 aeffect_vframe = 0; aeffect_icon = 0;
805 ladspa_vframe = 0; ladspa_icon = 0;
806 veffect_vframe = 0; veffect_icon = 0;
807 ff_aud_vframe = 0; ff_aud_icon = 0;
808 ff_vid_vframe = 0; ff_vid_icon = 0;
810 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
811 atransition_folder_vframe = 0; atransition_folder_icon = 0;
812 clip_folder_vframe = 0; clip_folder_icon = 0;
813 label_folder_vframe = 0; label_folder_icon = 0;
814 media_folder_vframe = 0; media_folder_icon = 0;
815 proxy_folder_vframe = 0; proxy_folder_icon = 0;
816 veffect_folder_vframe = 0; veffect_folder_icon = 0;
817 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
819 ladspa_vframe = 0; ladspa_icon = 0;
820 ff_aud_vframe = 0; ff_aud_icon = 0;
821 ff_vid_vframe = 0; ff_vid_icon = 0;
823 clip_vframe = 0; clip_icon = 0;
824 atransition_vframe = 0; atransition_icon = 0;
825 vtransition_vframe = 0; vtransition_icon = 0;
826 aeffect_vframe = 0; aeffect_icon = 0;
827 veffect_vframe = 0; veffect_icon = 0;
829 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
830 newfolder_thread = 0;
839 allow_iconlisting = 1;
844 displayed_folder = AW_NO_FOLDER;
847 AWindowGUI::~AWindowGUI()
849 assets.remove_all_objects();
850 folders.remove_all_objects();
851 aeffects.remove_all_objects();
852 veffects.remove_all_objects();
853 atransitions.remove_all_objects();
854 vtransitions.remove_all_objects();
855 labellist.remove_all_objects();
856 displayed_assets[1].remove_all_objects();
860 delete newfolder_thread;
865 delete effectlist_menu;
866 delete assetlist_menu;
867 delete cliplist_menu;
868 delete labellist_menu;
869 delete folderlist_menu;
872 delete remove_plugin;
874 delete file_vframe; delete file_icon;
875 delete folder_vframe; delete folder_icon;
876 delete audio_vframe; delete audio_icon;
877 delete video_vframe; delete video_icon;
878 delete label_vframe; delete label_icon;
879 delete clip_vframe; delete clip_icon;
880 delete aeffect_folder_vframe; delete aeffect_folder_icon;
881 delete atransition_folder_vframe; delete atransition_folder_icon;
882 delete veffect_folder_vframe; delete veffect_folder_icon;
883 delete vtransition_folder_vframe; delete vtransition_folder_icon;
884 delete clip_folder_vframe; delete clip_folder_icon;
885 delete label_folder_vframe; delete label_folder_icon;
886 delete media_folder_vframe; delete media_folder_icon;
887 delete proxy_folder_vframe; delete proxy_folder_icon;
888 delete ladspa_vframe; delete ladspa_icon;
889 delete ff_aud_vframe; delete ff_aud_icon;
890 delete ff_vid_vframe; delete ff_vid_icon;
891 delete atransition_vframe; delete atransition_icon;
892 delete vtransition_vframe; delete vtransition_icon;
893 delete aeffect_vframe; delete aeffect_icon;
894 delete veffect_vframe; delete veffect_icon;
897 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
899 return icon == file_icon ||
900 icon == folder_icon ||
901 icon == audio_icon ||
902 icon == video_icon ||
904 icon == label_icon ||
905 icon == vtransition_icon ||
906 icon == atransition_icon ||
907 icon == veffect_icon ||
908 icon == aeffect_icon ||
909 icon == ladspa_icon ||
910 icon == ff_aud_icon ||
911 icon == ff_vid_icon ||
912 icon == aeffect_folder_icon ||
913 icon == veffect_folder_icon ||
914 icon == atransition_folder_icon ||
915 icon == vtransition_folder_icon ||
916 icon == label_folder_icon ||
917 icon == clip_folder_icon ||
918 icon == media_folder_icon ||
919 icon == proxy_folder_icon;
922 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
924 char png_path[BCTEXTLEN];
925 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
926 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
927 File::get_plugin_path(), plugin_icons, name);
928 if( access(png_path, R_OK) ) return 0;
929 return VFramePng::vframe_png(png_path,0,0);
932 VFrame *AWindowGUI::get_picon(const char *name)
934 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
936 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
937 snprintf(pp, ep-pp, "%s.png", name);
938 unsigned char *data = mwindow->theme->get_image_data(png_name);
939 if( data ) vframe = new VFramePng(data, 0.);
944 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
946 vfrm = get_picon(fn);
947 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
948 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
950 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
952 vfrm = get_picon(fn);
953 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
954 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
956 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
958 vfrm = get_picon(fn);
959 if( !vfrm ) vfrm = new VFramePng(png);
960 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
963 void AWindowGUI::create_objects()
965 lock_window("AWindowGUI::create_objects");
966 asset_titles[0] = C_("Title");
967 asset_titles[1] = _("Comments");
969 set_icon(mwindow->theme->get_image("awindow_icon"));
971 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
972 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
973 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
974 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
975 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
977 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
978 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
979 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
980 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
981 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
982 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
983 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
984 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
986 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
987 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
988 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
989 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
990 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
991 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
992 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
993 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
995 theme_icon(clip_vframe, clip_icon, "clip_icon");
996 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
997 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
998 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
999 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1001 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1002 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1003 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1005 // Mandatory folders
1006 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1007 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1008 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1009 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1010 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1011 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1012 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1013 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1015 create_label_folder();
1017 mwindow->theme->get_awindow_sizes(this);
1018 load_defaults(mwindow->defaults);
1020 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1021 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1022 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1023 search_text->create_objects();
1024 int dy = search_text->get_h() + 10;
1026 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1028 vicon_thread = new VIconThread(asset_list);
1029 vicon_thread->start();
1030 vicon_audio = new AssetVIconAudio(this);
1032 add_subwindow(divider = new AWindowDivider(mwindow, this,
1033 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1034 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1036 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1038 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1039 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1040 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1041 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1042 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1043 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1044 add_tools->create_objects();
1045 fy += add_tools->get_h(); fh -= add_tools->get_h();
1046 add_subwindow(folder_list = new AWindowFolders(mwindow,
1047 this, fx, fy, fw, fh));
1050 //int x = mwindow->theme->abuttons_x;
1051 //int y = mwindow->theme->abuttons_y;
1054 newfolder_thread = new NewFolderThread(mwindow, this);
1056 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1057 asset_menu->create_objects();
1058 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1059 clip_menu->create_objects();
1060 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1061 label_menu->create_objects();
1063 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1064 effectlist_menu->create_objects();
1065 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1066 assetlist_menu->create_objects();
1067 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1068 cliplist_menu->create_objects();
1069 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1070 labellist_menu->create_objects();
1072 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1073 folderlist_menu->create_objects();
1075 create_custom_xatoms();
1079 int AWindowGUI::resize_event(int w, int h)
1081 mwindow->session->awindow_x = get_x();
1082 mwindow->session->awindow_y = get_y();
1083 mwindow->session->awindow_w = w;
1084 mwindow->session->awindow_h = h;
1086 mwindow->theme->get_awindow_sizes(this);
1087 mwindow->theme->draw_awindow_bg(this);
1088 reposition_objects();
1090 // int x = mwindow->theme->abuttons_x;
1091 // int y = mwindow->theme->abuttons_y;
1092 // new_bin->reposition_window(x, y);
1093 // x += new_bin->get_w();
1094 // delete_bin->reposition_window(x, y);
1095 // x += delete_bin->get_w();
1096 // rename_bin->reposition_window(x, y);
1097 // x += rename_bin->get_w();
1098 // delete_disk->reposition_window(x, y);
1099 // x += delete_disk->get_w();
1100 // delete_project->reposition_window(x, y);
1101 // x += delete_project->get_w();
1102 // info->reposition_window(x, y);
1103 // x += info->get_w();
1104 // redraw_index->reposition_window(x, y);
1105 // x += redraw_index->get_w();
1106 // paste->reposition_window(x, y);
1107 // x += paste->get_w();
1108 // append->reposition_window(x, y);
1109 // x += append->get_w();
1110 // view->reposition_window(x, y);
1112 BC_WindowBase::resize_event(w, h);
1116 int AWindowGUI::translation_event()
1118 mwindow->session->awindow_x = get_x();
1119 mwindow->session->awindow_y = get_y();
1123 void AWindowGUI::reposition_objects()
1125 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1126 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1127 search_text->reposition_window(x1, y1+5, w1);
1128 int dy = search_text->get_h() + 10;
1130 asset_list->reposition_window(x1, y1, w1, h1);
1131 divider->reposition_window(
1132 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1133 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1134 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1135 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1136 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1137 avicon_drawing->reposition_window(fw-avicon_w, fy);
1138 fy += add_tools->get_h(); fh -= add_tools->get_h();
1139 folder_list->reposition_window(fx, fy, fw, fh);
1142 int AWindowGUI::save_defaults(BC_Hash *defaults)
1144 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1145 defaults->update("VICON_DRAWING", vicon_drawing);
1149 int AWindowGUI::load_defaults(BC_Hash *defaults)
1151 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1152 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1156 int AWindowGUI::close_event()
1159 mwindow->session->show_awindow = 0;
1162 mwindow->gui->lock_window("AWindowGUI::close_event");
1163 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1164 mwindow->gui->unlock_window();
1166 lock_window("AWindowGUI::close_event");
1167 save_defaults(mwindow->defaults);
1168 mwindow->save_defaults();
1172 void AWindowGUI::start_vicon_drawing()
1174 if( !vicon_drawing ) return;
1175 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
1176 if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
1177 vicon_thread->start_drawing();
1180 void AWindowGUI::stop_vicon_drawing()
1182 vicon_thread->stop_drawing();
1185 AWindowRemovePluginGUI::
1186 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1187 int x, int y, PluginServer *plugin)
1188 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1190 this->awindow = awindow;
1191 this->thread = thread;
1192 this->plugin = plugin;
1193 VFrame *vframe = plugin->get_picon();
1194 icon = vframe ? create_pixmap(vframe) : 0;
1195 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1198 AWindowRemovePluginGUI::
1199 ~AWindowRemovePluginGUI()
1201 if( !awindow->gui->protected_pixmap(icon) )
1203 plugin_list.remove_all();
1206 void AWindowRemovePluginGUI::create_objects()
1208 BC_Button *ok_button = new BC_OKButton(this);
1209 add_subwindow(ok_button);
1210 BC_Button *cancel_button = new BC_CancelButton(this);
1211 add_subwindow(cancel_button);
1213 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1214 add_subwindow(title);
1215 y += title->get_h() + 5;
1216 list = new BC_ListBox(x, y,
1217 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1218 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1219 add_subwindow(list);
1223 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1226 for( int i=0; i<folder.size(); ) {
1227 AssetPicon *picon = (AssetPicon *)folder[i];
1228 if( picon->plugin == plugin ) {
1229 folder.remove_object_number(i);
1238 void AWindowRemovePlugin::handle_close_event(int result)
1241 printf(_("remove %s\n"), plugin->path);
1242 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1243 ArrayList<BC_ListBoxItem*> *folder =
1244 plugin->audio ? plugin->transition ?
1245 &awindow->gui->atransitions :
1246 &awindow->gui->aeffects :
1247 plugin->video ? plugin->transition ?
1248 &awindow->gui->vtransitions :
1249 &awindow->gui->veffects :
1251 if( folder ) remove_plugin(plugin, *folder);
1252 MWindow *mwindow = awindow->mwindow;
1253 awindow->gui->unlock_window();
1254 char plugin_path[BCTEXTLEN];
1255 strcpy(plugin_path, plugin->path);
1256 mwindow->plugindb->remove(plugin);
1257 remove(plugin_path);
1258 char index_path[BCTEXTLEN];
1259 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1261 char picon_path[BCTEXTLEN];
1263 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1264 File::get_plugin_path());
1265 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1266 plugin->get_plugin_png_name(png_name);
1267 fs.update(picon_path);
1268 for( int i=0; i<fs.dir_list.total; ++i ) {
1269 char *fs_path = fs.dir_list[i]->path;
1270 if( !fs.is_dir(fs_path) ) continue;
1271 snprintf(png_path, sizeof(picon_path), "%s/%s",
1275 delete plugin; plugin = 0;
1276 awindow->gui->async_update_assets();
1280 AWindowRemovePlugin::
1281 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1284 this->awindow = awindow;
1285 this->plugin = plugin;
1288 AWindowRemovePlugin::
1289 ~AWindowRemovePlugin()
1294 BC_Window* AWindowRemovePlugin::new_gui()
1296 int x = awindow->gui->get_abs_cursor_x(0);
1297 int y = awindow->gui->get_abs_cursor_y(0);
1298 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1299 gui->create_objects();
1303 int AWindowGUI::keypress_event()
1305 switch( get_keypress() ) {
1313 if( shift_down() ) {
1314 PluginServer* plugin = selected_plugin();
1315 if( !plugin ) break;
1316 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1318 remove_plugin->start();
1327 int AWindowGUI::create_custom_xatoms()
1329 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1332 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
1334 if( event->message_type == UpdateAssetsXAtom ) {
1341 void AWindowGUI::async_update_assets()
1344 event.message_type = UpdateAssetsXAtom;
1345 send_custom_xatom(&event);
1349 void AWindowGUI::update_folder_list()
1351 for( int i = 0; i < folders.total; i++ ) {
1352 AssetPicon *picon = (AssetPicon*)folders.values[i];
1356 // Search assets for folders
1357 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1358 const char *folder = mwindow->edl->folders.values[i];
1361 for( int j = 0; j < folders.total; j++ ) {
1362 AssetPicon *picon = (AssetPicon*)folders.values[j];
1363 if( !strcasecmp(picon->get_text(), folder) ) {
1371 int aw_folder = folder_number(folder);
1372 if( aw_folder >= 0 ) {
1373 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
1374 picon->create_objects();
1375 folders.append(picon);
1380 // Delete unused non-persistent folders
1381 for( int i=folders.total; --i>=0; ) {
1382 AssetPicon *picon = (AssetPicon*)folders.values[i];
1383 if( !picon->in_use && !picon->persistent ) {
1385 folders.remove_number(i);
1390 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1391 int do_audio, int do_video, int is_realtime, int is_transition)
1393 ArrayList<PluginServer*> plugin_list;
1394 // Get pointers to plugindb entries
1395 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1398 for( int i = 0; i < plugin_list.total; i++ ) {
1399 PluginServer *server = plugin_list.values[i];
1400 int visible = plugin_visibility & (1<<server->dir_idx);
1401 if( !visible ) continue;
1402 // Create new listitem
1403 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1404 picon->create_objects();
1405 output->append(picon);
1409 void AWindowGUI::create_label_folder()
1412 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1413 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1414 picon->create_objects();
1415 labellist.append(picon);
1420 void AWindowGUI::update_asset_list()
1422 for( int i = 0; i < assets.total; i++ ) {
1423 AssetPicon *picon = (AssetPicon*)assets.values[i];
1427 // Synchronize EDL clips
1428 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1431 // Look for clip in existing listitems
1432 for( int j = 0; j < assets.total && !exists; j++ ) {
1433 AssetPicon *picon = (AssetPicon*)assets.values[j];
1435 if( picon->id == mwindow->edl->clips[i]->id ) {
1436 picon->edl = mwindow->edl->clips[i];
1437 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1443 // Create new listitem
1445 AssetPicon *picon = new AssetPicon(mwindow,
1446 this, mwindow->edl->clips[i]);
1447 picon->create_objects();
1448 assets.append(picon);
1452 // Synchronize EDL assets
1453 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1456 // Look for asset in existing listitems
1457 for( int j = 0; j < assets.total && !exists; j++ ) {
1458 AssetPicon *picon = (AssetPicon*)assets.values[j];
1460 if( picon->id == current->id ) {
1461 picon->indexable = current;
1467 // Create new listitem
1469 AssetPicon *picon = new AssetPicon(mwindow,
1471 picon->create_objects();
1472 assets.append(picon);
1476 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1477 mwindow->gui->default_message();
1478 mwindow->gui->unlock_window();
1480 // Synchronize nested EDLs
1481 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1483 EDL *nested_edl = mwindow->edl->nested_edls[i];
1485 // Look for asset in existing listitems
1486 for( int j=0; j<assets.total && !exists; ++j ) {
1487 AssetPicon *picon = (AssetPicon*)assets.values[j];
1489 if( picon->id == nested_edl->id ) {
1490 picon->indexable = nested_edl;
1496 // Create new listitem
1498 AssetPicon *picon = new AssetPicon(mwindow,
1499 this, (Indexable*)nested_edl);
1500 picon->create_objects();
1501 assets.append(picon);
1505 for( int i = assets.size() - 1; i >= 0; i-- ) {
1506 AssetPicon *picon = (AssetPicon*)assets.get(i);
1507 if( !picon->in_use ) {
1509 assets.remove_number(i);
1512 if( !picon->indexable || !picon->indexable->is_asset ) continue;
1514 picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
1518 void AWindowGUI::update_picon(Indexable *indexable)
1521 for( int i = 0; i < assets.total; i++ ) {
1522 AssetPicon *picon = (AssetPicon*)assets.values[i];
1523 if( picon->indexable == indexable ||
1524 picon->edl == (EDL *)indexable ) {
1525 char name[BCTEXTLEN];
1527 fs.extract_name(name, indexable->path);
1528 picon->set_text(name);
1529 vicon = picon->vicon;
1534 stop_vicon_drawing();
1535 vicon->clear_images();
1536 vicon->reset(indexable->get_frame_rate());
1537 start_vicon_drawing();
1541 void AWindowGUI::sort_assets(int use_mtime)
1543 switch( mwindow->edl->session->awindow_folder ) {
1544 case AW_AEFFECT_FOLDER:
1545 sort_picons(&aeffects);
1547 case AW_VEFFECT_FOLDER:
1548 sort_picons(&veffects);
1550 case AW_ATRANSITION_FOLDER:
1551 sort_picons(&atransitions);
1553 case AW_VTRANSITION_FOLDER:
1554 sort_picons(&vtransitions);
1556 case AW_LABEL_FOLDER:
1557 sort_picons(&labellist);
1560 sort_picons(&assets, use_mtime);
1563 asset_list->update_format(asset_list->get_format(), 0);
1567 void AWindowGUI::sort_folders()
1569 sort_picons(&folders);
1570 folder_list->update_format(folder_list->get_format(), 0);
1574 void AWindowGUI::collect_assets()
1577 mwindow->session->drag_assets->remove_all();
1578 mwindow->session->drag_clips->remove_all();
1581 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
1582 if( !result ) break;
1584 if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
1585 if( result->edl ) mwindow->session->drag_clips->append(result->edl);
1589 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1590 ArrayList<BC_ListBoxItem*> *src, int folder)
1592 // Remove current pointers
1593 dst[0].remove_all();
1594 dst[1].remove_all_objects();
1596 // Create new pointers
1597 for( int i = 0; i < src->total; i++ ) {
1598 AssetPicon *picon = (AssetPicon*)src->values[i];
1600 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1601 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1602 const char *text = search_text->get_text();
1603 int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
1604 if( picon->vicon ) picon->vicon->hidden = hidden;
1605 if( hidden ) continue;
1606 BC_ListBoxItem *item2, *item1;
1607 dst[0].append(item1 = picon);
1609 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1611 if( picon->label && picon->label->textstr )
1612 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1613 else if( picon->mtime ) {
1614 char date_time[BCSTRLEN];
1615 struct tm stm; localtime_r(&picon->mtime, &stm);
1616 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1617 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1618 stm.tm_hour, stm.tm_min, stm.tm_sec);
1619 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1622 dst[1].append(item2 = new BC_ListBoxItem(""));
1623 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1624 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1629 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
1631 int done = 0, changed = 0;
1634 for( int i=0; i<src->total-1; ++i ) {
1635 AssetPicon *item1 = (AssetPicon *)src->values[i];
1636 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1637 if( use_mtime ? item1->mtime > item2->mtime :
1638 strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1639 src->values[i + 1] = item1;
1640 src->values[i] = item2;
1641 done = 0; changed = 1;
1646 for( int i=0; i<src->total; ++i ) {
1647 AssetPicon *item = (AssetPicon *)src->values[i];
1648 item->set_autoplace_icon(1);
1649 item->set_autoplace_text(1);
1655 void AWindowGUI::filter_displayed_assets()
1657 //allow_iconlisting = 1;
1658 asset_titles[0] = C_("Title");
1659 asset_titles[1] = _("Comments");
1661 switch( mwindow->edl->session->awindow_folder ) {
1662 case AW_AEFFECT_FOLDER:
1663 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1665 case AW_VEFFECT_FOLDER:
1666 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1668 case AW_ATRANSITION_FOLDER:
1669 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1671 case AW_VTRANSITION_FOLDER:
1672 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1674 case AW_LABEL_FOLDER:
1675 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1676 asset_titles[0] = _("Time Stamps");
1677 asset_titles[1] = C_("Title");
1678 //allow_iconlisting = 0;
1681 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1685 // Ensure the current folder icon is highlighted
1686 int selected_folder = mwindow->edl->session->awindow_folder;
1687 for( int i = 0; i < folders.total; i++ ) {
1688 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1689 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1690 folder_item->set_selected(selected);
1695 void AWindowGUI::update_assets()
1697 stop_vicon_drawing();
1698 update_folder_list();
1699 update_asset_list();
1700 labellist.remove_all_objects();
1701 create_label_folder();
1703 if( displayed_folder != mwindow->edl->session->awindow_folder )
1704 search_text->clear();
1705 filter_displayed_assets();
1707 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1708 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1710 int folder_xposition = folder_list->get_xposition();
1711 int folder_yposition = folder_list->get_yposition();
1712 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1714 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1715 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1717 int asset_xposition = asset_list->get_xposition();
1718 int asset_yposition = asset_list->get_yposition();
1719 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1720 displayed_folder = mwindow->edl->session->awindow_folder;
1721 asset_xposition = asset_yposition = 0;
1723 asset_list->update(displayed_assets, asset_titles,
1724 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1725 asset_xposition, asset_yposition, -1, 0);
1726 asset_list->center_selection();
1729 start_vicon_drawing();
1733 void AWindowGUI::update_effects()
1735 aeffects.remove_all_objects();
1736 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1737 veffects.remove_all_objects();
1738 create_persistent_folder(&veffects, 0, 1, 1, 0);
1739 atransitions.remove_all_objects();
1740 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1741 vtransitions.remove_all_objects();
1742 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1745 int AWindowGUI::folder_number(const char *name)
1747 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1748 if( !strcasecmp(name, folder_names[i]) ) return i;
1750 return AW_NO_FOLDER;
1753 int AWindowGUI::drag_motion()
1755 if( get_hidden() ) return 0;
1761 int AWindowGUI::drag_stop()
1763 if( get_hidden() ) return 0;
1768 Indexable* AWindowGUI::selected_asset()
1770 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1771 return picon ? picon->indexable : 0;
1774 PluginServer* AWindowGUI::selected_plugin()
1776 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1777 return picon ? picon->plugin : 0;
1780 AssetPicon* AWindowGUI::selected_folder()
1782 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1793 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1794 : BC_SubWindow(x, y, w, h)
1796 this->mwindow = mwindow;
1799 AWindowDivider::~AWindowDivider()
1803 int AWindowDivider::button_press_event()
1805 if( is_event_win() && cursor_inside() ) {
1806 mwindow->session->current_operation = DRAG_PARTITION;
1812 int AWindowDivider::cursor_motion_event()
1814 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1816 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1817 int fw = gui->get_relative_cursor_x();
1818 if( fw > wmax ) fw = wmax;
1819 if( fw < wmin ) fw = wmin;
1820 mwindow->session->afolders_w = fw;
1821 mwindow->theme->get_awindow_sizes(gui);
1822 gui->reposition_objects();
1828 int AWindowDivider::button_release_event()
1830 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1831 mwindow->session->current_operation = NO_OPERATION;
1842 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1843 : BC_ListBox(x, y, w, h,
1844 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1845 LISTBOX_ICONS : LISTBOX_TEXT,
1846 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1847 0, // Titles for columns. Set to 0 for no titles
1848 0, // width of each column
1849 1, // Total columns.
1850 0, // Pixel of top of window.
1851 0, // If this listbox is a popup window
1852 LISTBOX_SINGLE, // Select one item or multiple items
1853 ICON_TOP, // Position of icon relative to text of each item
1856 this->mwindow = mwindow;
1861 AWindowFolders::~AWindowFolders()
1865 int AWindowFolders::selection_changed()
1867 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1869 gui->stop_vicon_drawing();
1871 if( get_button_down() && get_buttonpress() == 3 ) {
1872 gui->folderlist_menu->update_titles();
1873 gui->folderlist_menu->activate_menu();
1876 mwindow->edl->session->awindow_folder = picon->foldernum;
1877 gui->asset_list->draw_background();
1878 gui->async_update_assets();
1880 gui->start_vicon_drawing();
1885 int AWindowFolders::button_press_event()
1889 result = BC_ListBox::button_press_event();
1892 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1893 gui->folderlist_menu->update_titles();
1894 gui->folderlist_menu->activate_menu();
1909 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1910 : BC_ListBox(x, y, w, h,
1911 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1912 LISTBOX_ICONS : LISTBOX_TEXT,
1913 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1914 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1915 mwindow->edl->session->asset_columns, // width of each column
1916 1, // Total columns.
1917 0, // Pixel of top of window.
1918 0, // If this listbox is a popup window
1919 LISTBOX_MULTIPLE, // Select one item or multiple items
1920 ICON_TOP, // Position of icon relative to text of each item
1921 -1) // Allow drags, require shift for scrolling
1923 this->mwindow = mwindow;
1926 set_scroll_stretch(1, 1);
1929 AWindowAssets::~AWindowAssets()
1933 int AWindowAssets::button_press_event()
1937 result = BC_ListBox::button_press_event();
1939 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1940 BC_ListBox::deactivate_selection();
1941 int folder = mwindow->edl->session->awindow_folder;
1943 case AW_AEFFECT_FOLDER:
1944 case AW_VEFFECT_FOLDER:
1945 case AW_ATRANSITION_FOLDER:
1946 case AW_VTRANSITION_FOLDER:
1947 gui->effectlist_menu->update();
1948 gui->effectlist_menu->activate_menu();
1950 case AW_LABEL_FOLDER:
1951 gui->labellist_menu->update();
1952 gui->labellist_menu->activate_menu();
1954 case AW_CLIP_FOLDER:
1955 gui->cliplist_menu->update();
1956 gui->cliplist_menu->activate_menu();
1958 case AW_MEDIA_FOLDER:
1959 case AW_PROXY_FOLDER:
1960 gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
1961 gui->assetlist_menu->activate_menu();
1971 int AWindowAssets::handle_event()
1973 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
1974 if( !asset_picon ) return 0;
1975 switch( mwindow->edl->session->awindow_folder ) {
1976 case AW_AEFFECT_FOLDER:
1977 case AW_VEFFECT_FOLDER:
1978 case AW_ATRANSITION_FOLDER:
1979 case AW_VTRANSITION_FOLDER: return 1;
1981 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
1982 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
1983 if( !vwindow || !vwindow->is_running() ) return 1;
1985 if( asset_picon->indexable )
1986 vwindow->change_source(asset_picon->indexable);
1987 else if( asset_picon->edl )
1988 vwindow->change_source(asset_picon->edl);
1992 int AWindowAssets::selection_changed()
1994 // Show popup window
1996 if( get_button_down() && get_buttonpress() == 3 &&
1997 (item = (AssetPicon*)get_selection(0, 0)) ) {
1998 int folder = mwindow->edl->session->awindow_folder;
2000 case AW_AEFFECT_FOLDER:
2001 case AW_VEFFECT_FOLDER:
2002 case AW_ATRANSITION_FOLDER:
2003 case AW_VTRANSITION_FOLDER:
2004 gui->effectlist_menu->update();
2005 gui->effectlist_menu->activate_menu();
2007 case AW_LABEL_FOLDER:
2008 if( !item->label ) break;
2009 gui->label_menu->activate_menu();
2011 case AW_CLIP_FOLDER:
2012 if( !item->indexable && !item->edl ) break;
2013 gui->clip_menu->update();
2014 gui->clip_menu->activate_menu();
2017 if( !item->indexable && !item->edl ) break;
2018 gui->asset_menu->update();
2019 gui->asset_menu->activate_menu();
2023 BC_ListBox::deactivate_selection();
2026 else if( gui->vicon_drawing &&
2027 get_button_down() && get_buttonpress() == 1 &&
2028 (item = (AssetPicon*)get_selection(0, 0)) ) {
2030 if( !gui->vicon_thread->viewing ) {
2031 vicon = item->vicon;
2033 gui->vicon_thread->set_view_popup(vicon);
2039 void AWindowAssets::draw_background()
2041 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2042 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2043 set_font(LARGEFONT);
2044 int aw_folder = mwindow->edl->session->awindow_folder;
2045 if( aw_folder < 0 ) return;
2046 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
2047 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
2048 aw_name, -1, get_bg_surface());
2051 int AWindowAssets::drag_start_event()
2053 int collect_pluginservers = 0;
2054 int collect_assets = 0;
2056 if( BC_ListBox::drag_start_event() ) {
2057 switch( mwindow->edl->session->awindow_folder ) {
2058 case AW_AEFFECT_FOLDER:
2059 mwindow->session->current_operation = DRAG_AEFFECT;
2060 collect_pluginservers = 1;
2062 case AW_VEFFECT_FOLDER:
2063 mwindow->session->current_operation = DRAG_VEFFECT;
2064 collect_pluginservers = 1;
2066 case AW_ATRANSITION_FOLDER:
2067 mwindow->session->current_operation = DRAG_ATRANSITION;
2068 collect_pluginservers = 1;
2070 case AW_VTRANSITION_FOLDER:
2071 mwindow->session->current_operation = DRAG_VTRANSITION;
2072 collect_pluginservers = 1;
2074 case AW_LABEL_FOLDER:
2078 mwindow->session->current_operation = DRAG_ASSET;
2083 if( collect_pluginservers ) {
2085 mwindow->session->drag_pluginservers->remove_all();
2088 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2089 if( !result ) break;
2091 mwindow->session->drag_pluginservers->append(result->plugin);
2095 if( collect_assets ) {
2096 gui->collect_assets();
2104 int AWindowAssets::drag_motion_event()
2106 BC_ListBox::drag_motion_event();
2109 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2110 mwindow->gui->drag_motion();
2111 mwindow->gui->unlock_window();
2113 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2114 VWindow *vwindow = mwindow->vwindows.get(i);
2115 if( !vwindow->is_running() ) continue;
2116 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2117 vwindow->gui->drag_motion();
2118 vwindow->gui->unlock_window();
2121 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2122 mwindow->cwindow->gui->drag_motion();
2123 mwindow->cwindow->gui->unlock_window();
2125 lock_window("AWindowAssets::drag_motion_event");
2129 int AWindowAssets::drag_stop_event()
2133 result = gui->drag_stop();
2138 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2139 result = mwindow->gui->drag_stop();
2140 mwindow->gui->unlock_window();
2144 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2145 VWindow *vwindow = mwindow->vwindows.get(i);
2146 if( !vwindow ) continue;
2147 if( !vwindow->is_running() ) continue;
2148 if( vwindow->gui->is_hidden() ) continue;
2149 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2150 if( vwindow->gui->cursor_above() &&
2151 vwindow->gui->get_cursor_over_window() ) {
2152 result = vwindow->gui->drag_stop();
2154 vwindow->gui->unlock_window();
2159 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2160 result = mwindow->cwindow->gui->drag_stop();
2161 mwindow->cwindow->gui->unlock_window();
2164 lock_window("AWindowAssets::drag_stop_event");
2167 get_drag_popup()->set_animation(0);
2169 BC_ListBox::drag_stop_event();
2170 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2171 mwindow->session->current_operation = ::NO_OPERATION;
2175 int AWindowAssets::column_resize_event()
2177 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2178 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2182 int AWindowAssets::focus_in_event()
2184 gui->start_vicon_drawing();
2188 int AWindowAssets::focus_out_event()
2190 gui->stop_vicon_drawing();
2191 return BC_ListBox::focus_out_event();
2194 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2195 : BC_TextBox(x, y, w, 1, "")
2197 this->search_text = search_text;
2200 int AWindowSearchTextBox::handle_event()
2202 return search_text->handle_event();
2205 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2207 this->mwindow = mwindow;
2213 void AWindowSearchText::create_objects()
2215 int x1 = x, y1 = y, margin = 10;
2216 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2217 x1 += text_title->get_w() + margin;
2218 int w1 = gui->get_w() - x1 - 2*margin;
2219 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2222 int AWindowSearchText::handle_event()
2224 gui->async_update_assets();
2228 int AWindowSearchText::get_w()
2230 return text_box->get_w() + text_title->get_w() + 10;
2233 int AWindowSearchText::get_h()
2235 return bmax(text_box->get_h(),text_title->get_h());
2238 void AWindowSearchText::reposition_window(int x, int y, int w)
2240 int x1 = x, y1 = y, margin = 10;
2241 text_title->reposition_window(x1, y1);
2242 x1 += text_title->get_w() + margin;
2243 int w1 = gui->get_w() - x1 - 2*margin;
2244 text_box->reposition_window(x1, y1, w1);
2247 const char *AWindowSearchText::get_text()
2249 return text_box->get_text();
2252 void AWindowSearchText::clear()
2254 text_box->update("");
2257 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2258 : BC_Button(x, y, mwindow->theme->newbin_data)
2260 this->mwindow = mwindow;
2262 set_tooltip(_("New bin"));
2265 int AWindowNewFolder::handle_event()
2267 gui->newfolder_thread->start_new_folder();
2271 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2272 : BC_Button(x, y, mwindow->theme->deletebin_data)
2274 this->mwindow = mwindow;
2276 set_tooltip(_("Delete bin"));
2279 int AWindowDeleteFolder::handle_event()
2281 if( gui->folder_list->get_selection(0, 0) ) {
2282 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
2283 mwindow->delete_folder(folder->get_text());
2288 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2289 : BC_Button(x, y, mwindow->theme->renamebin_data)
2291 this->mwindow = mwindow;
2293 set_tooltip(_("Rename bin"));
2296 int AWindowRenameFolder::handle_event()
2301 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2302 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2304 this->mwindow = mwindow;
2306 set_tooltip(_("Delete asset from disk"));
2309 int AWindowDeleteDisk::handle_event()
2314 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2315 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2317 this->mwindow = mwindow;
2319 set_tooltip(_("Delete asset from project"));
2322 int AWindowDeleteProject::handle_event()
2327 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2328 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2330 // this->mwindow = mwindow;
2332 // set_tooltip(_("Edit information on asset"));
2335 // int AWindowInfo::handle_event()
2337 // int cur_x, cur_y;
2338 // gui->get_abs_cursor(cur_x, cur_y, 0);
2339 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2343 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2344 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2346 this->mwindow = mwindow;
2348 set_tooltip(_("Redraw index"));
2351 int AWindowRedrawIndex::handle_event()
2356 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2357 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2359 this->mwindow = mwindow;
2361 set_tooltip(_("Paste asset on recordable tracks"));
2364 int AWindowPaste::handle_event()
2369 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2370 : BC_Button(x, y, mwindow->theme->appendasset_data)
2372 this->mwindow = mwindow;
2374 set_tooltip(_("Append asset in new tracks"));
2377 int AWindowAppend::handle_event()
2382 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2383 : BC_Button(x, y, mwindow->theme->viewasset_data)
2385 this->mwindow = mwindow;
2387 set_tooltip(_("View asset"));
2390 int AWindowView::handle_event()
2395 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2396 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2398 this->mwindow = mwindow;
2402 void AddTools::create_objects()
2405 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2406 vis |= 1 << PLUGIN_LADSPA_ID;
2407 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2408 vis |= 1 << PLUGIN_FFMPEG_ID;
2409 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2410 PluginServer *plugin = MWindow::plugindb->get(i);
2411 if( !plugin->audio && !plugin->video ) continue;
2412 int idx = plugin->dir_idx;
2413 uint32_t msk = 1 << idx;
2414 if( (msk & vis) != 0 ) continue;
2416 char parent[BCTEXTLEN];
2417 strcpy(parent, plugin->path);
2418 char *bp = strrchr(parent, '/');
2419 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2420 if( !bp ) bp = parent; else ++bp;
2421 add_item(new AddPluginItem(this, bp, idx));
2426 // plugin_dirs list from toplevel makefile include plugin_defs
2430 N_("audio_transitions")
2437 N_("video_transitions")
2440 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2441 : BC_MenuItem(_(text))
2445 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2446 int chk = (msk & vis) ? 1 : 0;
2450 int AddPluginItem::handle_event()
2452 int chk = get_checked() ^ 1;
2454 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2455 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2456 menu->gui->update_effects();
2457 menu->gui->save_defaults(menu->mwindow->defaults);
2458 menu->gui->async_update_assets();
2462 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2463 : BC_Toggle(x, y, images, agui->vicon_drawing)
2466 set_tooltip(_("draw vicons"));
2469 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2471 int text_line = -1, toggle_x = -1, toggle_y = -1;
2472 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2473 BC_Toggle::calculate_extents(agui, images, 1,
2474 &text_line, ww, hh, &toggle_x, &toggle_y,
2475 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2478 AVIconDrawing::~AVIconDrawing()
2482 int AVIconDrawing::handle_event()
2484 agui->vicon_drawing = get_value();
2485 if( agui->vicon_drawing )
2486 agui->start_vicon_drawing();
2488 agui->stop_vicon_drawing();
2493 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2496 this->mwindow = mwindow;
2500 int AWindowListFormat::handle_event()
2502 gui->stop_vicon_drawing();
2504 EDLSession *session = mwindow->edl->session;
2505 switch( session->assetlist_format ) {
2507 session->assetlist_format = ASSETS_ICONS;
2510 session->assetlist_format = ASSETS_TEXT;
2514 gui->asset_list->update_format(session->assetlist_format, 1);
2515 if( !mwindow->awindow->gui->allow_iconlisting ) {
2516 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2519 gui->start_vicon_drawing();
2523 void AWindowListFormat::update()
2525 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2526 (char*)_("Display icons") : (char*)_("Display text"));
2529 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2530 : BC_MenuItem(_("Sort items"))
2532 this->mwindow = mwindow;
2536 int AWindowListSort::handle_event()
2538 gui->sort_assets(0);