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"
60 #include "renderengine.h"
64 #include "transportque.h"
68 #include "vwindowgui.h"
71 #include "data/lad_picon_png.h"
72 #include "data/ff_audio_png.h"
73 #include "data/ff_video_png.h"
80 const char *AWindowGUI::folder_names[] =
84 N_("Audio Transitions"),
85 N_("Video Transitions"),
93 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
94 : VIcon(w, h, framerate)
97 this->length = length;
101 AssetVIcon::~AssetVIcon()
106 VFrame *AssetVIcon::frame()
108 Asset *asset = (Asset *)picon->indexable;
109 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
110 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
112 int sample_rate = asset->get_sample_rate();
113 int64_t audio_samples = asset->get_audio_samples();
114 double duration = (double)audio_samples / sample_rate;
115 picon->draw_hue_bar(temp, duration);
116 int secs = length / frame_rate + 0.5;
117 if( !secs ) secs = 1;
118 int bfrsz = VICON_SAMPLE_RATE;
119 int samples = audio_size/sizeof(vicon_audio_t);
120 double line_pos = (double)seq_no/(length-1);
121 int audio_pos = samples * line_pos * (secs-1)/secs;
122 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
123 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
124 double data[bfrsz], sample_scale = 1./mx;
125 int len = samples - audio_pos;
126 if( len > bfrsz ) len = bfrsz;
128 while( i < len ) data[i++] = *audio_data++ * sample_scale;
129 while( i < bfrsz ) data[i++] = 0;
130 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
131 int x = (vw-1) * line_pos;
132 temp->pixel_rgb = RED;
133 temp->draw_line(x,0, x,vh);
136 if( seq_no >= images.size() ) {
137 MWindow *mwindow = picon->mwindow;
138 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
139 if( !file ) return 0;
140 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
141 delete temp; temp = 0;
144 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
145 int ww = picon->gui->vicon_thread->view_w;
146 int hh = picon->gui->vicon_thread->view_h;
147 while( seq_no >= images.size() ) {
149 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
150 file->set_video_position(pos,0);
151 if( file->read_frame(temp) ) temp->clear_frame();
152 add_image(temp, ww, hh, BC_RGB8);
154 mwindow->video_cache->check_in(asset);
156 return *images[seq_no];
159 int64_t AssetVIcon::set_seq_no(int64_t no)
161 if( no >= length ) no = 0;
165 int AssetVIcon::get_vx()
167 BC_ListBox *lbox = picon->gui->asset_list;
168 return lbox->get_item_x(picon);
170 int AssetVIcon::get_vy()
172 BC_ListBox *lbox = picon->gui->asset_list;
173 return lbox->get_item_y(picon) + lbox->get_title_h();
176 void AssetVIcon::load_audio()
178 MWindow *mwindow = picon->mwindow;
179 Asset *asset = (Asset *)picon->indexable;
180 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
181 int channels = asset->get_audio_channels();
182 if( channels > 2 ) channels = 2;
183 int sample_rate = asset->get_sample_rate();
184 int bfrsz = sample_rate;
185 Samples samples(bfrsz);
186 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
187 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
188 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
189 double sample_scale = (double)mx / channels;
190 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
191 while( audio_pos < audio_len ) {
192 int64_t pos = audio_pos * time_scale;
193 for( int ch=0; ch<channels; ++ch ) {
194 file->set_channel(ch);
195 file->set_audio_position(pos);
196 file->read_samples(&samples, bfrsz);
197 double *data = samples.get_data();
198 for( int64_t k=audio_pos; k<audio_len; ++k ) {
199 int i = k * time_scale - pos;
200 if( i >= bfrsz ) break;
201 int v = audio_data[k] + data[i] * sample_scale;
202 audio_data[k] = CLIP(v, -mx,mx);
205 audio_pos = (pos + bfrsz) / time_scale;
207 mwindow->audio_cache->check_in(asset);
211 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
215 audio = new AudioDevice(gui->mwindow);
219 AssetVIconAudio::~AssetVIconAudio()
224 void AssetVIconAudio::run()
227 int64_t bfrsz = VICON_SAMPLE_RATE;
228 MWindow *mwindow = gui->mwindow;
229 EDL *edl = mwindow->edl;
230 EDLSession *session = edl->session;
231 AudioOutConfig *aconfig = session->playback_config->aconfig;
232 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
233 audio->start_playback();
234 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
235 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
236 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
238 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
239 while( !interrupted ) {
240 int len = audio_len - audio_pos;
241 if( len <= 0 ) break;
242 if( len > bfrsz ) len = bfrsz;
244 for( int i=0; i<len; ++i,++k )
245 out0[i] = out1[i] = (double)audio_data[k] / mx;
247 audio->write_buffer(out, channels, len);
251 audio->set_last_buffer();
252 audio->stop_audio(interrupted ? 0 : 1);
256 void AssetVIconAudio::start(AssetVIcon *vicon)
258 if( running() ) return;
265 void AssetVIconAudio::stop(int wait)
267 if( running() && !interrupted ) {
269 audio->stop_audio(wait);
273 vicon->playing_audio = 0;
278 void AssetVIcon::start_audio()
280 picon->gui->vicon_audio->stop(0);
282 picon->gui->vicon_audio->start(this);
285 void AssetVIcon::stop_audio()
287 picon->gui->vicon_audio->stop(0);
291 AssetPicon::AssetPicon(MWindow *mwindow,
292 AWindowGUI *gui, Indexable *indexable)
296 this->mwindow = mwindow;
298 this->indexable = indexable;
299 indexable->add_user();
300 this->id = indexable->id;
303 AssetPicon::AssetPicon(MWindow *mwindow,
304 AWindowGUI *gui, EDL *edl)
308 this->mwindow = mwindow;
315 AssetPicon::AssetPicon(MWindow *mwindow,
316 AWindowGUI *gui, int folder, int persist)
317 : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
318 folder>=0 && folder<AWINDOW_FOLDERS ?
319 gui->folder_icons[folder]: gui->folder_icon)
323 this->mwindow = mwindow;
325 persistent = persist;
328 AssetPicon::AssetPicon(MWindow *mwindow,
329 AWindowGUI *gui, PluginServer *plugin)
333 this->mwindow = mwindow;
335 this->plugin = plugin;
338 AssetPicon::AssetPicon(MWindow *mwindow,
339 AWindowGUI *gui, Label *label)
343 this->mwindow = mwindow;
351 AssetPicon::~AssetPicon()
354 gui->vicon_thread->del_vicon(vicon);
355 if( indexable ) indexable->remove_user();
356 if( edl ) edl->remove_user();
357 if( icon && !gui->protected_pixmap(icon) ) {
359 if( !plugin ) delete icon_vframe;
363 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
365 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
367 float h = 300 * t, s = 1., v = 1.;
368 float r, g, b; // duration, 0..1hr == hue red..magenta
369 HSV::hsv_to_rgb(r,g,b, h,s,v);
370 int ih = frame->get_h()/8, iw = frame->get_w();
371 int ir = r * 256; CLAMP(ir, 0,255);
372 int ig = g * 256; CLAMP(ig, 0,255);
373 int ib = b * 256; CLAMP(ib, 0,255);
374 unsigned char **rows = frame->get_rows();
375 for( int y=0; y<ih; ++y ) {
376 unsigned char *rp = rows[y];
377 for( int x=0; x<iw; rp+=3,++x ) {
378 rp[0] = ir; rp[1] = ig; rp[2] = ib;
383 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len, int base_color, int line_color)
385 int w = frame->get_w(), h = frame->get_h();
386 int h1 = h-1, h2 = h/2, y = h2;
387 int rgb_color = frame->pixel_rgb;
388 for( int x=0,x1=0,x2=0; x<w; ++x,x1=x2 ) {
389 double min = *dp, max = min;
390 x2 = (len * (x+1))/w;
391 for( int i=x1; i<x2; ++i ) {
392 double value = *dp++;
393 if( value < min ) min = value;
394 if( value > max ) max = value;
396 int ctr = (min + max) / 2;
397 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
398 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
399 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
400 frame->pixel_rgb = line_color;
401 frame->draw_line(x,y1, x,y2);
402 frame->pixel_rgb = base_color;
403 frame->draw_line(x,y, x,y0);
406 frame->pixel_rgb = rgb_color;
409 void AssetPicon::reset()
415 foldernum = AW_NO_FOLDER;
425 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
427 TransportCommand command;
428 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
429 command.get_edl()->copy_all(edl);
430 command.change_type = CHANGE_ALL;
431 command.realtime = 0;
432 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
433 render_engine->set_vcache(mwindow->video_cache);
434 render_engine->set_acache(mwindow->audio_cache);
435 render_engine->arm_command(&command);
437 void AssetPicon::close_render_engine()
439 delete render_engine; render_engine = 0;
441 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
443 if( !render_engine || !render_engine->vrender ) return;
444 render_engine->vrender->process_buffer(vfrm, pos, 0);
446 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
448 if( !render_engine || !render_engine->arender ) return;
449 render_engine->arender->process_buffer(samples, len, pos);
452 void AssetPicon::create_objects()
455 char name[BCTEXTLEN];
456 int pixmap_w, pixmap_h;
458 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
461 fs.extract_name(name, indexable->path);
465 set_text(strcpy(name, edl->local_session->clip_title));
469 if( indexable && indexable->is_asset ) {
470 Asset *asset = (Asset*)indexable;
471 if( asset->video_data ) {
472 if( mwindow->preferences->use_thumbnails ) {
473 gui->unlock_window();
474 File *file = mwindow->video_cache->check_out(asset,
479 int height = asset->height > 0 ? asset->height : 1;
480 pixmap_w = pixmap_h * asset->width / height;
483 file->set_video_position(0, 0);
485 if( gui->temp_picon &&
486 (gui->temp_picon->get_w() != asset->width ||
487 gui->temp_picon->get_h() != asset->height) ) {
488 delete gui->temp_picon;
492 if( !gui->temp_picon ) {
493 gui->temp_picon = new VFrame(0, -1,
494 asset->width, asset->height,
497 { char string[BCTEXTLEN];
498 sprintf(string, _("Reading %s"), name);
499 mwindow->gui->lock_window("AssetPicon::create_objects");
500 mwindow->gui->show_message(string);
501 mwindow->gui->unlock_window(); }
502 file->read_frame(gui->temp_picon);
503 mwindow->video_cache->check_in(asset);
505 gui->lock_window("AssetPicon::create_objects 0");
506 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
507 icon->draw_vframe(gui->temp_picon,
508 0, 0, pixmap_w, pixmap_h, 0, 0);
509 icon_vframe = new VFrame(0,
510 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
511 icon_vframe->transfer_from(gui->temp_picon);
512 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
514 double framerate = asset->get_frame_rate();
515 if( !framerate ) framerate = VICON_RATE;
516 int64_t frames = asset->get_video_frames();
517 double secs = frames / framerate;
518 if( secs > 5 ) secs = 5;
519 int64_t length = secs * gui->vicon_thread->refresh_rate;
520 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
521 if( asset->audio_data && secs > 0 ) {
522 gui->unlock_window();
523 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
524 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
526 gui->lock_window("AssetPicon::create_objects 1");
528 gui->vicon_thread->add_vicon(vicon);
533 gui->lock_window("AssetPicon::create_objects 2");
534 icon = gui->video_icon;
535 icon_vframe = gui->video_vframe;
539 icon = gui->video_icon;
540 icon_vframe = gui->video_vframe;
544 if( asset->audio_data ) {
545 if( mwindow->preferences->use_thumbnails ) {
546 gui->unlock_window();
547 File *file = mwindow->audio_cache->check_out(asset,
551 pixmap_w = pixmap_h * 16/9;
552 icon_vframe = new VFrame(0,
553 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
554 { char string[BCTEXTLEN];
555 sprintf(string, _("Reading %s"), name);
556 mwindow->gui->lock_window("AssetPicon::create_objects 3");
557 mwindow->gui->show_message(string);
558 mwindow->gui->unlock_window(); }
559 int sample_rate = asset->get_sample_rate();
560 int channels = asset->get_audio_channels();
561 if( channels > 2 ) channels = 2;
562 int64_t audio_samples = asset->get_audio_samples();
563 double duration = (double)audio_samples / sample_rate;
564 draw_hue_bar(icon_vframe, duration);
565 int bfrsz = sample_rate;
566 Samples samples(bfrsz);
567 static int line_colors[2] = { GREEN, YELLOW };
568 static int base_colors[2] = { RED, PINK };
569 for( int i=channels; --i>=0; ) {
570 file->set_channel(i);
571 file->set_audio_position(0);
572 file->read_samples(&samples, bfrsz);
573 draw_wave(icon_vframe, samples.get_data(), bfrsz,
574 base_colors[i], line_colors[i]);
576 mwindow->audio_cache->check_in(asset);
577 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
578 double secs = duration;
579 if( secs > 5 ) secs = 5;
580 double refresh_rate = gui->vicon_thread->refresh_rate;
581 int64_t length = secs * refresh_rate;
582 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
583 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
584 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
586 gui->vicon_thread->add_vicon(vicon);
588 gui->lock_window("AssetPicon::create_objects 4");
589 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
590 icon->draw_vframe(icon_vframe,
591 0, 0, pixmap_w, pixmap_h, 0, 0);
594 gui->lock_window("AssetPicon::create_objects 5");
595 icon = gui->audio_icon;
596 icon_vframe = gui->audio_vframe;
600 icon = gui->audio_icon;
601 icon_vframe = gui->audio_vframe;
606 mtime = !stat(asset->path, &st) ? st.st_mtime : 0;
609 if( indexable && !indexable->is_asset ) {
610 icon = gui->video_icon;
611 icon_vframe = gui->video_vframe;
615 if( edl->tracks->playable_video_tracks() ) {
616 if( mwindow->preferences->use_thumbnails ) {
617 gui->unlock_window();
618 char clip_icon_path[BCTEXTLEN];
619 char *clip_icon = edl->local_session->clip_icon;
621 snprintf(clip_icon_path, sizeof(clip_icon_path),
622 "%s/%s", File::get_config_path(), clip_icon);
623 icon_vframe = VFramePng::vframe_png(clip_icon_path);
626 //printf("render clip: %s\n", name);
627 int edl_h = edl->get_h(), edl_w = edl->get_w();
628 int height = edl_h > 0 ? edl_h : 1;
629 int width = edl_w > 0 ? edl_w : 1;
630 int color_model = edl->session->color_model;
631 pixmap_w = pixmap_h * width / height;
633 if( gui->temp_picon &&
634 (gui->temp_picon->get_color_model() != color_model ||
635 gui->temp_picon->get_w() != width ||
636 gui->temp_picon->get_h() != height) ) {
637 delete gui->temp_picon; gui->temp_picon = 0;
640 if( !gui->temp_picon ) {
641 gui->temp_picon = new VFrame(0, -1,
642 width, height, color_model, -1);
644 char string[BCTEXTLEN];
645 sprintf(string, _("Rendering %s"), name);
646 mwindow->gui->lock_window("AssetPicon::create_objects");
647 mwindow->gui->show_message(string);
648 mwindow->gui->unlock_window();
649 open_render_engine(edl, 0);
650 render_video(0, gui->temp_picon);
651 close_render_engine();
652 gui->lock_window("AssetPicon::create_objects 0");
653 icon_vframe = new VFrame(0,
654 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
655 icon_vframe->transfer_from(gui->temp_picon);
656 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
659 pixmap_w = icon_vframe->get_w();
660 pixmap_h = icon_vframe->get_h();
662 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
663 icon->draw_vframe(icon_vframe,
664 0, 0, pixmap_w, pixmap_h, 0, 0);
667 icon = gui->clip_icon;
668 icon_vframe = gui->clip_vframe;
672 if( edl->tracks->playable_audio_tracks() ) {
673 if( mwindow->preferences->use_thumbnails ) {
674 gui->unlock_window();
675 char clip_icon_path[BCTEXTLEN];
676 char *clip_icon = edl->local_session->clip_icon;
678 snprintf(clip_icon_path, sizeof(clip_icon_path),
679 "%s/%s", File::get_config_path(), clip_icon);
680 icon_vframe = VFramePng::vframe_png(clip_icon_path);
683 pixmap_w = pixmap_h * 16/9;
684 icon_vframe = new VFrame(0,
685 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
686 char string[BCTEXTLEN];
687 sprintf(string, _("Rendering %s"), name);
688 mwindow->gui->lock_window("AssetPicon::create_objects 3");
689 mwindow->gui->show_message(string);
690 mwindow->gui->unlock_window();
691 int sample_rate = edl->get_sample_rate();
692 int channels = edl->get_audio_channels();
693 if( channels > 2 ) channels = 2;
694 int64_t audio_samples = edl->get_audio_samples();
695 double duration = (double)audio_samples / sample_rate;
696 draw_hue_bar(icon_vframe, duration);
697 Samples *samples[MAX_CHANNELS];
698 int bfrsz = sample_rate;
699 for( int i=0; i<MAX_CHANNELS; ++i )
700 samples[i] = i<channels ? new Samples(bfrsz) : 0;
701 open_render_engine(edl, 1);
702 render_audio(0, samples, bfrsz);
703 close_render_engine();
704 gui->lock_window("AssetPicon::create_objects 4");
705 static int line_colors[2] = { GREEN, YELLOW };
706 static int base_colors[2] = { RED, PINK };
707 for( int i=channels; --i>=0; ) {
708 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
709 base_colors[i], line_colors[i]);
711 for( int i=0; i<channels; ++i ) delete samples[i];
712 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
715 pixmap_w = icon_vframe->get_w();
716 pixmap_h = icon_vframe->get_h();
718 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
719 icon->draw_vframe(icon_vframe,
720 0, 0, pixmap_w, pixmap_h, 0, 0);
723 icon = gui->clip_icon;
724 icon_vframe = gui->clip_vframe;
730 strcpy(name, _(plugin->title));
732 icon_vframe = plugin->get_picon();
734 icon = gui->create_pixmap(icon_vframe);
735 else if( plugin->audio ) {
736 if( plugin->transition ) {
737 icon = gui->atransition_icon;
738 icon_vframe = gui->atransition_vframe;
740 else if( plugin->is_ffmpeg() ) {
741 icon = gui->ff_aud_icon;
742 icon_vframe = gui->ff_aud_vframe;
744 else if( plugin->is_ladspa() ) {
745 icon = gui->ladspa_icon;
746 icon_vframe = gui->ladspa_vframe;
749 icon = gui->aeffect_icon;
750 icon_vframe = gui->aeffect_vframe;
753 else if( plugin->video ) {
754 if( plugin->transition ) {
755 icon = gui->vtransition_icon;
756 icon_vframe = gui->vtransition_vframe;
758 else if( plugin->is_ffmpeg() ) {
759 icon = gui->ff_vid_icon;
760 icon_vframe = gui->ff_vid_vframe;
763 icon = gui->veffect_icon;
764 icon_vframe = gui->veffect_vframe;
772 mwindow->edl->session->time_format,
773 mwindow->edl->session->sample_rate,
774 mwindow->edl->session->frame_rate,
775 mwindow->edl->session->frames_per_foot);
777 icon = gui->label_icon;
778 icon_vframe = gui->label_vframe;
781 icon = gui->file_icon;
782 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
785 set_icon_vframe(icon_vframe);
788 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
789 : BC_Window(_(PROGRAM_NAME ": Resources"),
790 mwindow->session->awindow_x, mwindow->session->awindow_y,
791 mwindow->session->awindow_w, mwindow->session->awindow_h,
794 this->mwindow = mwindow;
795 this->awindow = awindow;
797 file_vframe = 0; file_icon = 0;
798 folder_vframe = 0; folder_icon = 0;
799 audio_vframe = 0; audio_icon = 0;
800 video_vframe = 0; video_icon = 0;
801 label_vframe = 0; label_icon = 0;
803 atransition_vframe = 0; atransition_icon = 0;
804 vtransition_vframe = 0; vtransition_icon = 0;
805 aeffect_vframe = 0; aeffect_icon = 0;
806 ladspa_vframe = 0; ladspa_icon = 0;
807 veffect_vframe = 0; veffect_icon = 0;
808 ff_aud_vframe = 0; ff_aud_icon = 0;
809 ff_vid_vframe = 0; ff_vid_icon = 0;
811 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
812 atransition_folder_vframe = 0; atransition_folder_icon = 0;
813 clip_folder_vframe = 0; clip_folder_icon = 0;
814 label_folder_vframe = 0; label_folder_icon = 0;
815 media_folder_vframe = 0; media_folder_icon = 0;
816 proxy_folder_vframe = 0; proxy_folder_icon = 0;
817 veffect_folder_vframe = 0; veffect_folder_icon = 0;
818 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
820 ladspa_vframe = 0; ladspa_icon = 0;
821 ff_aud_vframe = 0; ff_aud_icon = 0;
822 ff_vid_vframe = 0; ff_vid_icon = 0;
824 clip_vframe = 0; clip_icon = 0;
825 atransition_vframe = 0; atransition_icon = 0;
826 vtransition_vframe = 0; vtransition_icon = 0;
827 aeffect_vframe = 0; aeffect_icon = 0;
828 veffect_vframe = 0; veffect_icon = 0;
830 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
831 newfolder_thread = 0;
840 allow_iconlisting = 1;
845 displayed_folder = AW_NO_FOLDER;
848 AWindowGUI::~AWindowGUI()
850 assets.remove_all_objects();
851 folders.remove_all_objects();
852 aeffects.remove_all_objects();
853 veffects.remove_all_objects();
854 atransitions.remove_all_objects();
855 vtransitions.remove_all_objects();
856 labellist.remove_all_objects();
857 displayed_assets[1].remove_all_objects();
861 delete newfolder_thread;
866 delete effectlist_menu;
867 delete assetlist_menu;
868 delete cliplist_menu;
869 delete labellist_menu;
870 delete folderlist_menu;
873 delete remove_plugin;
875 delete file_vframe; delete file_icon;
876 delete folder_vframe; delete folder_icon;
877 delete audio_vframe; delete audio_icon;
878 delete video_vframe; delete video_icon;
879 delete label_vframe; delete label_icon;
880 delete clip_vframe; delete clip_icon;
881 delete aeffect_folder_vframe; delete aeffect_folder_icon;
882 delete atransition_folder_vframe; delete atransition_folder_icon;
883 delete veffect_folder_vframe; delete veffect_folder_icon;
884 delete vtransition_folder_vframe; delete vtransition_folder_icon;
885 delete clip_folder_vframe; delete clip_folder_icon;
886 delete label_folder_vframe; delete label_folder_icon;
887 delete media_folder_vframe; delete media_folder_icon;
888 delete proxy_folder_vframe; delete proxy_folder_icon;
889 delete ladspa_vframe; delete ladspa_icon;
890 delete ff_aud_vframe; delete ff_aud_icon;
891 delete ff_vid_vframe; delete ff_vid_icon;
892 delete atransition_vframe; delete atransition_icon;
893 delete vtransition_vframe; delete vtransition_icon;
894 delete aeffect_vframe; delete aeffect_icon;
895 delete veffect_vframe; delete veffect_icon;
898 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
900 return icon == file_icon ||
901 icon == folder_icon ||
902 icon == audio_icon ||
903 icon == video_icon ||
905 icon == label_icon ||
906 icon == vtransition_icon ||
907 icon == atransition_icon ||
908 icon == veffect_icon ||
909 icon == aeffect_icon ||
910 icon == ladspa_icon ||
911 icon == ff_aud_icon ||
912 icon == ff_vid_icon ||
913 icon == aeffect_folder_icon ||
914 icon == veffect_folder_icon ||
915 icon == atransition_folder_icon ||
916 icon == vtransition_folder_icon ||
917 icon == label_folder_icon ||
918 icon == clip_folder_icon ||
919 icon == media_folder_icon ||
920 icon == proxy_folder_icon;
923 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
925 char png_path[BCTEXTLEN];
926 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
927 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
928 File::get_plugin_path(), plugin_icons, name);
929 if( access(png_path, R_OK) ) return 0;
930 return VFramePng::vframe_png(png_path,0,0);
933 VFrame *AWindowGUI::get_picon(const char *name)
935 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
937 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
938 snprintf(pp, ep-pp, "%s.png", name);
939 unsigned char *data = mwindow->theme->get_image_data(png_name);
940 if( data ) vframe = new VFramePng(data, 0.);
945 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
947 vfrm = get_picon(fn);
948 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
949 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
951 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
953 vfrm = get_picon(fn);
954 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
955 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
957 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
959 vfrm = get_picon(fn);
960 if( !vfrm ) vfrm = new VFramePng(png);
961 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
964 void AWindowGUI::create_objects()
966 lock_window("AWindowGUI::create_objects");
967 asset_titles[0] = C_("Title");
968 asset_titles[1] = _("Comments");
970 set_icon(mwindow->theme->get_image("awindow_icon"));
972 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
973 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
974 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
975 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
976 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
978 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
979 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
980 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
981 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
982 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
983 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
984 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
985 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
987 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
988 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
989 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
990 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
991 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
992 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
993 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
994 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
996 theme_icon(clip_vframe, clip_icon, "clip_icon");
997 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
998 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
999 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1000 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1002 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1003 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1004 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1006 // Mandatory folders
1007 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1008 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1009 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1010 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1011 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1012 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1013 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1014 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1016 create_label_folder();
1018 mwindow->theme->get_awindow_sizes(this);
1019 load_defaults(mwindow->defaults);
1021 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1022 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1023 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1024 search_text->create_objects();
1025 int dy = search_text->get_h() + 10;
1027 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1029 vicon_thread = new VIconThread(asset_list);
1030 vicon_thread->start();
1031 vicon_audio = new AssetVIconAudio(this);
1033 add_subwindow(divider = new AWindowDivider(mwindow, this,
1034 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1035 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1037 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1039 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1040 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1041 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1042 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1043 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1044 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1045 add_tools->create_objects();
1046 fy += add_tools->get_h(); fh -= add_tools->get_h();
1047 add_subwindow(folder_list = new AWindowFolders(mwindow,
1048 this, fx, fy, fw, fh));
1051 //int x = mwindow->theme->abuttons_x;
1052 //int y = mwindow->theme->abuttons_y;
1055 newfolder_thread = new NewFolderThread(mwindow, this);
1057 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1058 asset_menu->create_objects();
1059 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1060 clip_menu->create_objects();
1061 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1062 label_menu->create_objects();
1064 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1065 effectlist_menu->create_objects();
1066 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1067 assetlist_menu->create_objects();
1068 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1069 cliplist_menu->create_objects();
1070 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1071 labellist_menu->create_objects();
1073 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1074 folderlist_menu->create_objects();
1076 create_custom_xatoms();
1080 int AWindowGUI::resize_event(int w, int h)
1082 mwindow->session->awindow_x = get_x();
1083 mwindow->session->awindow_y = get_y();
1084 mwindow->session->awindow_w = w;
1085 mwindow->session->awindow_h = h;
1087 mwindow->theme->get_awindow_sizes(this);
1088 mwindow->theme->draw_awindow_bg(this);
1089 reposition_objects();
1091 // int x = mwindow->theme->abuttons_x;
1092 // int y = mwindow->theme->abuttons_y;
1093 // new_bin->reposition_window(x, y);
1094 // x += new_bin->get_w();
1095 // delete_bin->reposition_window(x, y);
1096 // x += delete_bin->get_w();
1097 // rename_bin->reposition_window(x, y);
1098 // x += rename_bin->get_w();
1099 // delete_disk->reposition_window(x, y);
1100 // x += delete_disk->get_w();
1101 // delete_project->reposition_window(x, y);
1102 // x += delete_project->get_w();
1103 // info->reposition_window(x, y);
1104 // x += info->get_w();
1105 // redraw_index->reposition_window(x, y);
1106 // x += redraw_index->get_w();
1107 // paste->reposition_window(x, y);
1108 // x += paste->get_w();
1109 // append->reposition_window(x, y);
1110 // x += append->get_w();
1111 // view->reposition_window(x, y);
1113 BC_WindowBase::resize_event(w, h);
1117 int AWindowGUI::translation_event()
1119 mwindow->session->awindow_x = get_x();
1120 mwindow->session->awindow_y = get_y();
1124 void AWindowGUI::reposition_objects()
1126 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1127 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1128 search_text->reposition_window(x1, y1+5, w1);
1129 int dy = search_text->get_h() + 10;
1131 asset_list->reposition_window(x1, y1, w1, h1);
1132 divider->reposition_window(
1133 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1134 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1135 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1136 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1137 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1138 avicon_drawing->reposition_window(fw-avicon_w, fy);
1139 fy += add_tools->get_h(); fh -= add_tools->get_h();
1140 folder_list->reposition_window(fx, fy, fw, fh);
1143 int AWindowGUI::save_defaults(BC_Hash *defaults)
1145 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1146 defaults->update("VICON_DRAWING", vicon_drawing);
1150 int AWindowGUI::load_defaults(BC_Hash *defaults)
1152 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1153 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1157 int AWindowGUI::close_event()
1160 mwindow->session->show_awindow = 0;
1163 mwindow->gui->lock_window("AWindowGUI::close_event");
1164 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1165 mwindow->gui->unlock_window();
1167 lock_window("AWindowGUI::close_event");
1168 save_defaults(mwindow->defaults);
1169 mwindow->save_defaults();
1173 void AWindowGUI::start_vicon_drawing()
1175 if( !vicon_drawing ) return;
1176 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
1177 if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
1178 vicon_thread->start_drawing();
1181 void AWindowGUI::stop_vicon_drawing()
1183 vicon_thread->stop_drawing();
1186 AWindowRemovePluginGUI::
1187 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1188 int x, int y, PluginServer *plugin)
1189 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1191 this->awindow = awindow;
1192 this->thread = thread;
1193 this->plugin = plugin;
1194 VFrame *vframe = plugin->get_picon();
1195 icon = vframe ? create_pixmap(vframe) : 0;
1196 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1199 AWindowRemovePluginGUI::
1200 ~AWindowRemovePluginGUI()
1202 if( !awindow->gui->protected_pixmap(icon) )
1204 plugin_list.remove_all();
1207 void AWindowRemovePluginGUI::create_objects()
1209 BC_Button *ok_button = new BC_OKButton(this);
1210 add_subwindow(ok_button);
1211 BC_Button *cancel_button = new BC_CancelButton(this);
1212 add_subwindow(cancel_button);
1214 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1215 add_subwindow(title);
1216 y += title->get_h() + 5;
1217 list = new BC_ListBox(x, y,
1218 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1219 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1220 add_subwindow(list);
1224 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1227 for( int i=0; i<folder.size(); ) {
1228 AssetPicon *picon = (AssetPicon *)folder[i];
1229 if( picon->plugin == plugin ) {
1230 folder.remove_object_number(i);
1239 void AWindowRemovePlugin::handle_close_event(int result)
1242 printf(_("remove %s\n"), plugin->path);
1243 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1244 ArrayList<BC_ListBoxItem*> *folder =
1245 plugin->audio ? plugin->transition ?
1246 &awindow->gui->atransitions :
1247 &awindow->gui->aeffects :
1248 plugin->video ? plugin->transition ?
1249 &awindow->gui->vtransitions :
1250 &awindow->gui->veffects :
1252 if( folder ) remove_plugin(plugin, *folder);
1253 MWindow *mwindow = awindow->mwindow;
1254 awindow->gui->unlock_window();
1255 char plugin_path[BCTEXTLEN];
1256 strcpy(plugin_path, plugin->path);
1257 mwindow->plugindb->remove(plugin);
1258 remove(plugin_path);
1259 char index_path[BCTEXTLEN];
1260 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1262 char picon_path[BCTEXTLEN];
1264 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1265 File::get_plugin_path());
1266 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1267 plugin->get_plugin_png_name(png_name);
1268 fs.update(picon_path);
1269 for( int i=0; i<fs.dir_list.total; ++i ) {
1270 char *fs_path = fs.dir_list[i]->path;
1271 if( !fs.is_dir(fs_path) ) continue;
1272 snprintf(png_path, sizeof(picon_path), "%s/%s",
1276 delete plugin; plugin = 0;
1277 awindow->gui->async_update_assets();
1281 AWindowRemovePlugin::
1282 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1285 this->awindow = awindow;
1286 this->plugin = plugin;
1289 AWindowRemovePlugin::
1290 ~AWindowRemovePlugin()
1295 BC_Window* AWindowRemovePlugin::new_gui()
1297 int x = awindow->gui->get_abs_cursor_x(0);
1298 int y = awindow->gui->get_abs_cursor_y(0);
1299 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1300 gui->create_objects();
1304 int AWindowGUI::keypress_event()
1306 switch( get_keypress() ) {
1314 if( shift_down() ) {
1315 PluginServer* plugin = selected_plugin();
1316 if( !plugin ) break;
1317 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1319 remove_plugin->start();
1328 int AWindowGUI::create_custom_xatoms()
1330 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1333 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
1335 if( event->message_type == UpdateAssetsXAtom ) {
1342 void AWindowGUI::async_update_assets()
1345 event.message_type = UpdateAssetsXAtom;
1346 send_custom_xatom(&event);
1350 void AWindowGUI::update_folder_list()
1352 for( int i = 0; i < folders.total; i++ ) {
1353 AssetPicon *picon = (AssetPicon*)folders.values[i];
1357 // Search assets for folders
1358 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1359 const char *folder = mwindow->edl->folders.values[i];
1362 for( int j = 0; j < folders.total; j++ ) {
1363 AssetPicon *picon = (AssetPicon*)folders.values[j];
1364 if( !strcasecmp(picon->get_text(), folder) ) {
1372 int aw_folder = folder_number(folder);
1373 if( aw_folder >= 0 ) {
1374 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
1375 picon->create_objects();
1376 folders.append(picon);
1381 // Delete unused non-persistent folders
1382 for( int i=folders.total; --i>=0; ) {
1383 AssetPicon *picon = (AssetPicon*)folders.values[i];
1384 if( !picon->in_use && !picon->persistent ) {
1386 folders.remove_number(i);
1391 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1392 int do_audio, int do_video, int is_realtime, int is_transition)
1394 ArrayList<PluginServer*> plugin_list;
1395 // Get pointers to plugindb entries
1396 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1399 for( int i = 0; i < plugin_list.total; i++ ) {
1400 PluginServer *server = plugin_list.values[i];
1401 int visible = plugin_visibility & (1<<server->dir_idx);
1402 if( !visible ) continue;
1403 // Create new listitem
1404 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1405 picon->create_objects();
1406 output->append(picon);
1410 void AWindowGUI::create_label_folder()
1413 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1414 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1415 picon->create_objects();
1416 labellist.append(picon);
1421 void AWindowGUI::update_asset_list()
1423 for( int i = 0; i < assets.total; i++ ) {
1424 AssetPicon *picon = (AssetPicon*)assets.values[i];
1428 // Synchronize EDL clips
1429 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1432 // Look for clip in existing listitems
1433 for( int j = 0; j < assets.total && !exists; j++ ) {
1434 AssetPicon *picon = (AssetPicon*)assets.values[j];
1436 if( picon->id == mwindow->edl->clips[i]->id ) {
1437 picon->edl = mwindow->edl->clips[i];
1438 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1444 // Create new listitem
1446 AssetPicon *picon = new AssetPicon(mwindow,
1447 this, mwindow->edl->clips[i]);
1448 picon->create_objects();
1449 assets.append(picon);
1453 // Synchronize EDL assets
1454 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1457 // Look for asset in existing listitems
1458 for( int j = 0; j < assets.total && !exists; j++ ) {
1459 AssetPicon *picon = (AssetPicon*)assets.values[j];
1461 if( picon->id == current->id ) {
1462 picon->indexable = current;
1468 // Create new listitem
1470 AssetPicon *picon = new AssetPicon(mwindow,
1472 picon->create_objects();
1473 assets.append(picon);
1477 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1478 mwindow->gui->default_message();
1479 mwindow->gui->unlock_window();
1481 // Synchronize nested EDLs
1482 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1484 EDL *nested_edl = mwindow->edl->nested_edls[i];
1486 // Look for asset in existing listitems
1487 for( int j=0; j<assets.total && !exists; ++j ) {
1488 AssetPicon *picon = (AssetPicon*)assets.values[j];
1490 if( picon->id == nested_edl->id ) {
1491 picon->indexable = nested_edl;
1497 // Create new listitem
1499 AssetPicon *picon = new AssetPicon(mwindow,
1500 this, (Indexable*)nested_edl);
1501 picon->create_objects();
1502 assets.append(picon);
1506 for( int i = assets.size() - 1; i >= 0; i-- ) {
1507 AssetPicon *picon = (AssetPicon*)assets.get(i);
1508 if( !picon->in_use ) {
1510 assets.remove_number(i);
1513 if( !picon->indexable || !picon->indexable->is_asset ) continue;
1515 picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
1519 void AWindowGUI::update_picon(Indexable *indexable)
1522 for( int i = 0; i < assets.total; i++ ) {
1523 AssetPicon *picon = (AssetPicon*)assets.values[i];
1524 if( picon->indexable == indexable ||
1525 picon->edl == (EDL *)indexable ) {
1526 char name[BCTEXTLEN];
1528 fs.extract_name(name, indexable->path);
1529 picon->set_text(name);
1530 vicon = picon->vicon;
1535 stop_vicon_drawing();
1536 vicon->clear_images();
1537 vicon->reset(indexable->get_frame_rate());
1538 start_vicon_drawing();
1542 void AWindowGUI::sort_assets(int use_mtime)
1544 switch( mwindow->edl->session->awindow_folder ) {
1545 case AW_AEFFECT_FOLDER:
1546 sort_picons(&aeffects);
1548 case AW_VEFFECT_FOLDER:
1549 sort_picons(&veffects);
1551 case AW_ATRANSITION_FOLDER:
1552 sort_picons(&atransitions);
1554 case AW_VTRANSITION_FOLDER:
1555 sort_picons(&vtransitions);
1557 case AW_LABEL_FOLDER:
1558 sort_picons(&labellist);
1561 sort_picons(&assets, use_mtime);
1564 asset_list->update_format(asset_list->get_format(), 0);
1568 void AWindowGUI::sort_folders()
1570 sort_picons(&folders);
1571 folder_list->update_format(folder_list->get_format(), 0);
1575 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1577 Asset *proxy_asset = (Asset *)indexable;
1578 char path[BCTEXTLEN];
1579 int proxy_scale = mwindow->edl->session->proxy_scale;
1580 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1581 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1582 if( !unproxy_asset || !unproxy_asset->channels ) return 0;
1583 // make a clip from proxy video tracks and unproxy audio tracks
1584 EDL *proxy_edl = new EDL(mwindow->edl);
1585 proxy_edl->create_objects();
1586 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1587 strcpy(proxy_edl->local_session->clip_title, path);
1588 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1589 proxy_edl->session->video_tracks = proxy_asset->layers;
1590 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1591 proxy_edl->create_default_tracks();
1592 double length = proxy_asset->frame_rate > 0 ?
1593 (double)proxy_asset->video_length / proxy_asset->frame_rate :
1594 1.0 / mwindow->edl->session->frame_rate;
1595 Track *current = proxy_edl->tracks->first;
1596 for( int vtrack=0; current; current=NEXT ) {
1597 if( current->data_type != TRACK_VIDEO ) continue;
1598 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1600 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1601 current = proxy_edl->tracks->first;
1602 for( int atrack=0; current; current=NEXT ) {
1603 if( current->data_type != TRACK_AUDIO ) continue;
1604 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1610 void AWindowGUI::collect_assets(int proxy)
1612 mwindow->session->drag_assets->remove_all();
1613 mwindow->session->drag_clips->remove_all();
1614 mwindow->session->clear_drag_proxy();
1615 int i = 0; AssetPicon *result;
1616 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1617 Indexable *indexable = result->indexable; EDL *drag_edl;
1618 if( proxy && (drag_edl=collect_proxy(indexable)) ) {
1619 mwindow->session->drag_clips->append(drag_edl);
1620 mwindow->session->drag_proxy->append(drag_edl);
1624 mwindow->session->drag_assets->append(indexable);
1628 mwindow->session->drag_clips->append(result->edl);
1634 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1635 ArrayList<BC_ListBoxItem*> *src, int folder)
1637 // Remove current pointers
1638 dst[0].remove_all();
1639 dst[1].remove_all_objects();
1641 // Create new pointers
1642 for( int i = 0; i < src->total; i++ ) {
1643 AssetPicon *picon = (AssetPicon*)src->values[i];
1645 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1646 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1647 const char *text = search_text->get_text();
1648 int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
1649 if( picon->vicon ) picon->vicon->hidden = hidden;
1650 if( hidden ) continue;
1651 BC_ListBoxItem *item2, *item1;
1652 dst[0].append(item1 = picon);
1654 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1656 if( picon->label && picon->label->textstr )
1657 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1658 else if( picon->mtime ) {
1659 char date_time[BCSTRLEN];
1660 struct tm stm; localtime_r(&picon->mtime, &stm);
1661 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1662 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1663 stm.tm_hour, stm.tm_min, stm.tm_sec);
1664 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1667 dst[1].append(item2 = new BC_ListBoxItem(""));
1668 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1669 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1674 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
1676 int done = 0, changed = 0;
1679 for( int i=0; i<src->total-1; ++i ) {
1680 AssetPicon *item1 = (AssetPicon *)src->values[i];
1681 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1682 if( use_mtime ? item1->mtime > item2->mtime :
1683 strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1684 src->values[i + 1] = item1;
1685 src->values[i] = item2;
1686 done = 0; changed = 1;
1691 for( int i=0; i<src->total; ++i ) {
1692 AssetPicon *item = (AssetPicon *)src->values[i];
1693 item->set_autoplace_icon(1);
1694 item->set_autoplace_text(1);
1700 void AWindowGUI::filter_displayed_assets()
1702 //allow_iconlisting = 1;
1703 asset_titles[0] = C_("Title");
1704 asset_titles[1] = _("Comments");
1706 switch( mwindow->edl->session->awindow_folder ) {
1707 case AW_AEFFECT_FOLDER:
1708 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1710 case AW_VEFFECT_FOLDER:
1711 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1713 case AW_ATRANSITION_FOLDER:
1714 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1716 case AW_VTRANSITION_FOLDER:
1717 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1719 case AW_LABEL_FOLDER:
1720 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1721 asset_titles[0] = _("Time Stamps");
1722 asset_titles[1] = C_("Title");
1723 //allow_iconlisting = 0;
1726 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1730 // Ensure the current folder icon is highlighted
1731 int selected_folder = mwindow->edl->session->awindow_folder;
1732 for( int i = 0; i < folders.total; i++ ) {
1733 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1734 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1735 folder_item->set_selected(selected);
1740 void AWindowGUI::update_assets()
1742 stop_vicon_drawing();
1743 update_folder_list();
1744 update_asset_list();
1745 labellist.remove_all_objects();
1746 create_label_folder();
1748 if( displayed_folder != mwindow->edl->session->awindow_folder )
1749 search_text->clear();
1750 filter_displayed_assets();
1752 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1753 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1755 int folder_xposition = folder_list->get_xposition();
1756 int folder_yposition = folder_list->get_yposition();
1757 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1759 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1760 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1762 int asset_xposition = asset_list->get_xposition();
1763 int asset_yposition = asset_list->get_yposition();
1764 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1765 displayed_folder = mwindow->edl->session->awindow_folder;
1766 asset_xposition = asset_yposition = 0;
1768 asset_list->update(displayed_assets, asset_titles,
1769 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1770 asset_xposition, asset_yposition, -1, 0);
1771 asset_list->center_selection();
1774 start_vicon_drawing();
1778 void AWindowGUI::update_effects()
1780 aeffects.remove_all_objects();
1781 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1782 veffects.remove_all_objects();
1783 create_persistent_folder(&veffects, 0, 1, 1, 0);
1784 atransitions.remove_all_objects();
1785 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1786 vtransitions.remove_all_objects();
1787 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1790 int AWindowGUI::folder_number(const char *name)
1792 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1793 if( !strcasecmp(name, folder_names[i]) ) return i;
1795 return AW_NO_FOLDER;
1798 int AWindowGUI::drag_motion()
1800 if( get_hidden() ) return 0;
1806 int AWindowGUI::drag_stop()
1808 if( get_hidden() ) return 0;
1812 Indexable* AWindowGUI::selected_asset()
1814 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1815 return picon ? picon->indexable : 0;
1818 PluginServer* AWindowGUI::selected_plugin()
1820 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1821 return picon ? picon->plugin : 0;
1824 AssetPicon* AWindowGUI::selected_folder()
1826 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1837 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1838 : BC_SubWindow(x, y, w, h)
1840 this->mwindow = mwindow;
1843 AWindowDivider::~AWindowDivider()
1847 int AWindowDivider::button_press_event()
1849 if( is_event_win() && cursor_inside() ) {
1850 mwindow->session->current_operation = DRAG_PARTITION;
1856 int AWindowDivider::cursor_motion_event()
1858 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1860 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1861 int fw = gui->get_relative_cursor_x();
1862 if( fw > wmax ) fw = wmax;
1863 if( fw < wmin ) fw = wmin;
1864 mwindow->session->afolders_w = fw;
1865 mwindow->theme->get_awindow_sizes(gui);
1866 gui->reposition_objects();
1872 int AWindowDivider::button_release_event()
1874 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1875 mwindow->session->current_operation = NO_OPERATION;
1886 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1887 : BC_ListBox(x, y, w, h,
1888 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1889 LISTBOX_ICONS : LISTBOX_TEXT,
1890 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1891 0, // Titles for columns. Set to 0 for no titles
1892 0, // width of each column
1893 1, // Total columns.
1894 0, // Pixel of top of window.
1895 0, // If this listbox is a popup window
1896 LISTBOX_SINGLE, // Select one item or multiple items
1897 ICON_TOP, // Position of icon relative to text of each item
1900 this->mwindow = mwindow;
1905 AWindowFolders::~AWindowFolders()
1909 int AWindowFolders::selection_changed()
1911 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1913 gui->stop_vicon_drawing();
1915 if( get_button_down() && get_buttonpress() == 3 ) {
1916 gui->folderlist_menu->update_titles();
1917 gui->folderlist_menu->activate_menu();
1920 mwindow->edl->session->awindow_folder = picon->foldernum;
1921 gui->asset_list->draw_background();
1922 gui->async_update_assets();
1924 gui->start_vicon_drawing();
1929 int AWindowFolders::button_press_event()
1933 result = BC_ListBox::button_press_event();
1936 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1937 gui->folderlist_menu->update_titles();
1938 gui->folderlist_menu->activate_menu();
1953 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1954 : BC_ListBox(x, y, w, h,
1955 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1956 LISTBOX_ICONS : LISTBOX_TEXT,
1957 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1958 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1959 mwindow->edl->session->asset_columns, // width of each column
1960 1, // Total columns.
1961 0, // Pixel of top of window.
1962 0, // If this listbox is a popup window
1963 LISTBOX_MULTIPLE, // Select one item or multiple items
1964 ICON_TOP, // Position of icon relative to text of each item
1965 -1) // Allow drags, require shift for scrolling
1967 this->mwindow = mwindow;
1970 set_scroll_stretch(1, 1);
1973 AWindowAssets::~AWindowAssets()
1977 int AWindowAssets::button_press_event()
1981 result = BC_ListBox::button_press_event();
1983 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1984 BC_ListBox::deactivate_selection();
1985 int folder = mwindow->edl->session->awindow_folder;
1987 case AW_AEFFECT_FOLDER:
1988 case AW_VEFFECT_FOLDER:
1989 case AW_ATRANSITION_FOLDER:
1990 case AW_VTRANSITION_FOLDER:
1991 gui->effectlist_menu->update();
1992 gui->effectlist_menu->activate_menu();
1994 case AW_LABEL_FOLDER:
1995 gui->labellist_menu->update();
1996 gui->labellist_menu->activate_menu();
1998 case AW_CLIP_FOLDER:
1999 gui->cliplist_menu->update();
2000 gui->cliplist_menu->activate_menu();
2002 case AW_MEDIA_FOLDER:
2003 case AW_PROXY_FOLDER:
2004 gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
2005 gui->assetlist_menu->activate_menu();
2015 int AWindowAssets::handle_event()
2017 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2018 if( !asset_picon ) return 0;
2019 switch( mwindow->edl->session->awindow_folder ) {
2020 case AW_AEFFECT_FOLDER:
2021 case AW_VEFFECT_FOLDER:
2022 case AW_ATRANSITION_FOLDER:
2023 case AW_VTRANSITION_FOLDER: return 1;
2025 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
2026 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
2027 if( !vwindow || !vwindow->is_running() ) return 1;
2029 if( asset_picon->indexable )
2030 vwindow->change_source(asset_picon->indexable);
2031 else if( asset_picon->edl )
2032 vwindow->change_source(asset_picon->edl);
2036 int AWindowAssets::selection_changed()
2038 // Show popup window
2040 if( get_button_down() && get_buttonpress() == 3 &&
2041 (item = (AssetPicon*)get_selection(0, 0)) ) {
2042 int folder = mwindow->edl->session->awindow_folder;
2044 case AW_AEFFECT_FOLDER:
2045 case AW_VEFFECT_FOLDER:
2046 case AW_ATRANSITION_FOLDER:
2047 case AW_VTRANSITION_FOLDER:
2048 gui->effectlist_menu->update();
2049 gui->effectlist_menu->activate_menu();
2051 case AW_LABEL_FOLDER:
2052 if( !item->label ) break;
2053 gui->label_menu->activate_menu();
2055 case AW_CLIP_FOLDER:
2056 if( !item->indexable && !item->edl ) break;
2057 gui->clip_menu->update();
2058 gui->clip_menu->activate_menu();
2061 if( !item->indexable && !item->edl ) break;
2062 gui->asset_menu->update();
2063 gui->asset_menu->activate_menu();
2067 BC_ListBox::deactivate_selection();
2070 else if( gui->vicon_drawing &&
2071 get_button_down() && get_buttonpress() == 1 &&
2072 (item = (AssetPicon*)get_selection(0, 0)) ) {
2074 if( !gui->vicon_thread->viewing ) {
2075 vicon = item->vicon;
2077 gui->vicon_thread->set_view_popup(vicon);
2083 void AWindowAssets::draw_background()
2085 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2086 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2087 set_font(LARGEFONT);
2088 int aw_folder = mwindow->edl->session->awindow_folder;
2089 if( aw_folder < 0 ) return;
2090 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
2091 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
2092 aw_name, -1, get_bg_surface());
2095 int AWindowAssets::drag_start_event()
2097 int collect_pluginservers = 0;
2098 int collect_assets = 0, proxy = 0;
2100 if( BC_ListBox::drag_start_event() ) {
2101 switch( mwindow->edl->session->awindow_folder ) {
2102 case AW_AEFFECT_FOLDER:
2103 mwindow->session->current_operation = DRAG_AEFFECT;
2104 collect_pluginservers = 1;
2106 case AW_VEFFECT_FOLDER:
2107 mwindow->session->current_operation = DRAG_VEFFECT;
2108 collect_pluginservers = 1;
2110 case AW_ATRANSITION_FOLDER:
2111 mwindow->session->current_operation = DRAG_ATRANSITION;
2112 collect_pluginservers = 1;
2114 case AW_VTRANSITION_FOLDER:
2115 mwindow->session->current_operation = DRAG_VTRANSITION;
2116 collect_pluginservers = 1;
2118 case AW_LABEL_FOLDER:
2121 case AW_PROXY_FOLDER:
2124 case AW_MEDIA_FOLDER:
2126 mwindow->session->current_operation = DRAG_ASSET;
2131 if( collect_pluginservers ) {
2133 mwindow->session->drag_pluginservers->remove_all();
2136 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2137 if( !result ) break;
2139 mwindow->session->drag_pluginservers->append(result->plugin);
2143 if( collect_assets ) {
2144 gui->collect_assets(proxy);
2152 int AWindowAssets::drag_motion_event()
2154 BC_ListBox::drag_motion_event();
2157 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2158 mwindow->gui->drag_motion();
2159 mwindow->gui->unlock_window();
2161 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2162 VWindow *vwindow = mwindow->vwindows.get(i);
2163 if( !vwindow->is_running() ) continue;
2164 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2165 vwindow->gui->drag_motion();
2166 vwindow->gui->unlock_window();
2169 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2170 mwindow->cwindow->gui->drag_motion();
2171 mwindow->cwindow->gui->unlock_window();
2173 lock_window("AWindowAssets::drag_motion_event");
2177 int AWindowAssets::drag_stop_event()
2181 result = gui->drag_stop();
2186 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2187 result = mwindow->gui->drag_stop();
2188 mwindow->gui->unlock_window();
2192 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2193 VWindow *vwindow = mwindow->vwindows.get(i);
2194 if( !vwindow ) continue;
2195 if( !vwindow->is_running() ) continue;
2196 if( vwindow->gui->is_hidden() ) continue;
2197 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2198 if( vwindow->gui->cursor_above() &&
2199 vwindow->gui->get_cursor_over_window() ) {
2200 result = vwindow->gui->drag_stop();
2202 vwindow->gui->unlock_window();
2207 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2208 result = mwindow->cwindow->gui->drag_stop();
2209 mwindow->cwindow->gui->unlock_window();
2212 lock_window("AWindowAssets::drag_stop_event");
2215 get_drag_popup()->set_animation(0);
2217 BC_ListBox::drag_stop_event();
2218 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2219 mwindow->session->current_operation = ::NO_OPERATION;
2220 mwindow->session->clear_drag_proxy();
2225 int AWindowAssets::column_resize_event()
2227 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2228 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2232 int AWindowAssets::focus_in_event()
2234 gui->start_vicon_drawing();
2238 int AWindowAssets::focus_out_event()
2240 gui->stop_vicon_drawing();
2241 return BC_ListBox::focus_out_event();
2244 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2245 : BC_TextBox(x, y, w, 1, "")
2247 this->search_text = search_text;
2250 int AWindowSearchTextBox::handle_event()
2252 return search_text->handle_event();
2255 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2257 this->mwindow = mwindow;
2263 void AWindowSearchText::create_objects()
2265 int x1 = x, y1 = y, margin = 10;
2266 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2267 x1 += text_title->get_w() + margin;
2268 int w1 = gui->get_w() - x1 - 2*margin;
2269 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2272 int AWindowSearchText::handle_event()
2274 gui->async_update_assets();
2278 int AWindowSearchText::get_w()
2280 return text_box->get_w() + text_title->get_w() + 10;
2283 int AWindowSearchText::get_h()
2285 return bmax(text_box->get_h(),text_title->get_h());
2288 void AWindowSearchText::reposition_window(int x, int y, int w)
2290 int x1 = x, y1 = y, margin = 10;
2291 text_title->reposition_window(x1, y1);
2292 x1 += text_title->get_w() + margin;
2293 int w1 = gui->get_w() - x1 - 2*margin;
2294 text_box->reposition_window(x1, y1, w1);
2297 const char *AWindowSearchText::get_text()
2299 return text_box->get_text();
2302 void AWindowSearchText::clear()
2304 text_box->update("");
2307 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2308 : BC_Button(x, y, mwindow->theme->newbin_data)
2310 this->mwindow = mwindow;
2312 set_tooltip(_("New bin"));
2315 int AWindowNewFolder::handle_event()
2317 gui->newfolder_thread->start_new_folder();
2321 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2322 : BC_Button(x, y, mwindow->theme->deletebin_data)
2324 this->mwindow = mwindow;
2326 set_tooltip(_("Delete bin"));
2329 int AWindowDeleteFolder::handle_event()
2331 if( gui->folder_list->get_selection(0, 0) ) {
2332 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
2333 mwindow->delete_folder(folder->get_text());
2338 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2339 : BC_Button(x, y, mwindow->theme->renamebin_data)
2341 this->mwindow = mwindow;
2343 set_tooltip(_("Rename bin"));
2346 int AWindowRenameFolder::handle_event()
2351 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2352 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2354 this->mwindow = mwindow;
2356 set_tooltip(_("Delete asset from disk"));
2359 int AWindowDeleteDisk::handle_event()
2364 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2365 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2367 this->mwindow = mwindow;
2369 set_tooltip(_("Delete asset from project"));
2372 int AWindowDeleteProject::handle_event()
2377 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2378 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2380 // this->mwindow = mwindow;
2382 // set_tooltip(_("Edit information on asset"));
2385 // int AWindowInfo::handle_event()
2387 // int cur_x, cur_y;
2388 // gui->get_abs_cursor(cur_x, cur_y, 0);
2389 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2393 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2394 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2396 this->mwindow = mwindow;
2398 set_tooltip(_("Redraw index"));
2401 int AWindowRedrawIndex::handle_event()
2406 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2407 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2409 this->mwindow = mwindow;
2411 set_tooltip(_("Paste asset on recordable tracks"));
2414 int AWindowPaste::handle_event()
2419 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2420 : BC_Button(x, y, mwindow->theme->appendasset_data)
2422 this->mwindow = mwindow;
2424 set_tooltip(_("Append asset in new tracks"));
2427 int AWindowAppend::handle_event()
2432 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2433 : BC_Button(x, y, mwindow->theme->viewasset_data)
2435 this->mwindow = mwindow;
2437 set_tooltip(_("View asset"));
2440 int AWindowView::handle_event()
2445 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2446 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2448 this->mwindow = mwindow;
2452 void AddTools::create_objects()
2455 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2456 vis |= 1 << PLUGIN_LADSPA_ID;
2457 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2458 vis |= 1 << PLUGIN_FFMPEG_ID;
2459 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2460 PluginServer *plugin = MWindow::plugindb->get(i);
2461 if( !plugin->audio && !plugin->video ) continue;
2462 int idx = plugin->dir_idx;
2463 uint32_t msk = 1 << idx;
2464 if( (msk & vis) != 0 ) continue;
2466 char parent[BCTEXTLEN];
2467 strcpy(parent, plugin->path);
2468 char *bp = strrchr(parent, '/');
2469 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2470 if( !bp ) bp = parent; else ++bp;
2471 add_item(new AddPluginItem(this, bp, idx));
2476 // plugin_dirs list from toplevel makefile include plugin_defs
2480 N_("audio_transitions")
2487 N_("video_transitions")
2490 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2491 : BC_MenuItem(_(text))
2495 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2496 int chk = (msk & vis) ? 1 : 0;
2500 int AddPluginItem::handle_event()
2502 int chk = get_checked() ^ 1;
2504 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2505 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2506 menu->gui->update_effects();
2507 menu->gui->save_defaults(menu->mwindow->defaults);
2508 menu->gui->async_update_assets();
2512 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2513 : BC_Toggle(x, y, images, agui->vicon_drawing)
2516 set_tooltip(_("draw vicons"));
2519 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2521 int text_line = -1, toggle_x = -1, toggle_y = -1;
2522 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2523 BC_Toggle::calculate_extents(agui, images, 1,
2524 &text_line, ww, hh, &toggle_x, &toggle_y,
2525 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2528 AVIconDrawing::~AVIconDrawing()
2532 int AVIconDrawing::handle_event()
2534 agui->vicon_drawing = get_value();
2535 if( agui->vicon_drawing )
2536 agui->start_vicon_drawing();
2538 agui->stop_vicon_drawing();
2543 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2546 this->mwindow = mwindow;
2550 int AWindowListFormat::handle_event()
2552 gui->stop_vicon_drawing();
2554 EDLSession *session = mwindow->edl->session;
2555 switch( session->assetlist_format ) {
2557 session->assetlist_format = ASSETS_ICONS;
2560 session->assetlist_format = ASSETS_TEXT;
2564 gui->asset_list->update_format(session->assetlist_format, 1);
2565 if( !mwindow->awindow->gui->allow_iconlisting ) {
2566 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2569 gui->start_vicon_drawing();
2573 void AWindowListFormat::update()
2575 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2576 (char*)_("Display icons") : (char*)_("Display text"));
2579 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2580 : BC_MenuItem(_("Sort items"))
2582 this->mwindow = mwindow;
2586 int AWindowListSort::handle_event()
2588 gui->sort_assets(0);