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 "proxypopup.h"
61 #include "renderengine.h"
65 #include "transportque.h"
69 #include "vwindowgui.h"
72 #include "data/lad_picon_png.h"
73 #include "data/ff_audio_png.h"
74 #include "data/ff_video_png.h"
81 const char *AWindowGUI::folder_names[] =
85 N_("Audio Transitions"),
86 N_("Video Transitions"),
94 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
95 : VIcon(w, h, framerate)
98 this->length = length;
102 AssetVIcon::~AssetVIcon()
107 VFrame *AssetVIcon::frame()
109 Asset *asset = (Asset *)picon->indexable;
110 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
111 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
113 int sample_rate = asset->get_sample_rate();
114 int64_t audio_samples = asset->get_audio_samples();
115 double duration = (double)audio_samples / sample_rate;
116 picon->draw_hue_bar(temp, duration);
117 int secs = length / frame_rate + 0.5;
118 if( !secs ) secs = 1;
119 int bfrsz = VICON_SAMPLE_RATE;
120 int samples = audio_size/sizeof(vicon_audio_t);
121 double line_pos = (double)seq_no/(length-1);
122 int audio_pos = samples * line_pos * (secs-1)/secs;
123 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
124 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
125 double data[bfrsz], sample_scale = 1./mx;
126 int len = samples - audio_pos;
127 if( len > bfrsz ) len = bfrsz;
129 while( i < len ) data[i++] = *audio_data++ * sample_scale;
130 while( i < bfrsz ) data[i++] = 0;
131 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
132 int x = (vw-1) * line_pos;
133 temp->pixel_rgb = RED;
134 temp->draw_line(x,0, x,vh);
137 if( seq_no >= images.size() ) {
138 MWindow *mwindow = picon->mwindow;
139 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
140 if( !file ) return 0;
141 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
142 delete temp; temp = 0;
145 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
146 int ww = picon->gui->vicon_thread->view_w;
147 int hh = picon->gui->vicon_thread->view_h;
148 while( seq_no >= images.size() ) {
150 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
151 file->set_video_position(pos,0);
152 if( file->read_frame(temp) ) temp->clear_frame();
153 add_image(temp, ww, hh, BC_RGB8);
155 mwindow->video_cache->check_in(asset);
157 return *images[seq_no];
160 int64_t AssetVIcon::set_seq_no(int64_t no)
162 if( no >= length ) no = 0;
166 int AssetVIcon::get_vx()
168 BC_ListBox *lbox = picon->gui->asset_list;
169 return lbox->get_item_x(picon);
171 int AssetVIcon::get_vy()
173 BC_ListBox *lbox = picon->gui->asset_list;
174 return lbox->get_item_y(picon) + lbox->get_title_h();
177 void AssetVIcon::load_audio()
179 MWindow *mwindow = picon->mwindow;
180 Asset *asset = (Asset *)picon->indexable;
181 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
182 int channels = asset->get_audio_channels();
183 if( channels > 2 ) channels = 2;
184 int sample_rate = asset->get_sample_rate();
185 int bfrsz = sample_rate;
186 Samples samples(bfrsz);
187 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
188 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
189 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
190 double sample_scale = (double)mx / channels;
191 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
192 while( audio_pos < audio_len ) {
193 int64_t pos = audio_pos * time_scale;
194 for( int ch=0; ch<channels; ++ch ) {
195 file->set_channel(ch);
196 file->set_audio_position(pos);
197 file->read_samples(&samples, bfrsz);
198 double *data = samples.get_data();
199 for( int64_t k=audio_pos; k<audio_len; ++k ) {
200 int i = k * time_scale - pos;
201 if( i >= bfrsz ) break;
202 int v = audio_data[k] + data[i] * sample_scale;
203 audio_data[k] = CLIP(v, -mx,mx);
206 audio_pos = (pos + bfrsz) / time_scale;
208 mwindow->audio_cache->check_in(asset);
212 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
216 audio = new AudioDevice(gui->mwindow);
220 AssetVIconAudio::~AssetVIconAudio()
225 void AssetVIconAudio::run()
228 int64_t bfrsz = VICON_SAMPLE_RATE;
229 MWindow *mwindow = gui->mwindow;
230 EDL *edl = mwindow->edl;
231 EDLSession *session = edl->session;
232 AudioOutConfig *aconfig = session->playback_config->aconfig;
233 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
234 audio->start_playback();
235 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
236 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
237 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
239 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
240 while( !interrupted ) {
241 int len = audio_len - audio_pos;
242 if( len <= 0 ) break;
243 if( len > bfrsz ) len = bfrsz;
245 for( int i=0; i<len; ++i,++k )
246 out0[i] = out1[i] = (double)audio_data[k] / mx;
248 audio->write_buffer(out, channels, len);
252 audio->set_last_buffer();
253 audio->stop_audio(interrupted ? 0 : 1);
257 void AssetVIconAudio::start(AssetVIcon *vicon)
259 if( running() ) return;
266 void AssetVIconAudio::stop(int wait)
268 if( running() && !interrupted ) {
270 audio->stop_audio(wait);
274 vicon->playing_audio = 0;
279 void AssetVIcon::start_audio()
281 picon->gui->vicon_audio->stop(0);
283 picon->gui->vicon_audio->start(this);
286 void AssetVIcon::stop_audio()
288 picon->gui->vicon_audio->stop(0);
292 AssetPicon::AssetPicon(MWindow *mwindow,
293 AWindowGUI *gui, Indexable *indexable)
297 this->mwindow = mwindow;
299 this->indexable = indexable;
300 indexable->add_user();
301 this->id = indexable->id;
304 AssetPicon::AssetPicon(MWindow *mwindow,
305 AWindowGUI *gui, EDL *edl)
309 this->mwindow = mwindow;
316 AssetPicon::AssetPicon(MWindow *mwindow,
317 AWindowGUI *gui, int folder, int persist)
318 : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
319 folder>=0 && folder<AWINDOW_FOLDERS ?
320 gui->folder_icons[folder]: gui->folder_icon)
324 this->mwindow = mwindow;
326 persistent = persist;
329 AssetPicon::AssetPicon(MWindow *mwindow,
330 AWindowGUI *gui, PluginServer *plugin)
334 this->mwindow = mwindow;
336 this->plugin = plugin;
339 AssetPicon::AssetPicon(MWindow *mwindow,
340 AWindowGUI *gui, Label *label)
344 this->mwindow = mwindow;
352 AssetPicon::~AssetPicon()
355 gui->vicon_thread->del_vicon(vicon);
356 if( indexable ) indexable->remove_user();
357 if( edl ) edl->remove_user();
358 if( icon && !gui->protected_pixmap(icon) ) {
360 if( !plugin ) delete icon_vframe;
364 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
366 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
368 float h = 300 * t, s = 1., v = 1.;
369 float r, g, b; // duration, 0..1hr == hue red..magenta
370 HSV::hsv_to_rgb(r,g,b, h,s,v);
371 int ih = frame->get_h()/8, iw = frame->get_w();
372 int ir = r * 256; CLAMP(ir, 0,255);
373 int ig = g * 256; CLAMP(ig, 0,255);
374 int ib = b * 256; CLAMP(ib, 0,255);
375 unsigned char **rows = frame->get_rows();
376 for( int y=0; y<ih; ++y ) {
377 unsigned char *rp = rows[y];
378 for( int x=0; x<iw; rp+=3,++x ) {
379 rp[0] = ir; rp[1] = ig; rp[2] = ib;
384 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len, int base_color, int line_color)
386 int w = frame->get_w(), h = frame->get_h();
387 int h1 = h-1, h2 = h/2, y = h2;
388 int rgb_color = frame->pixel_rgb;
389 for( int x=0,x1=0,x2=0; x<w; ++x,x1=x2 ) {
390 double min = *dp, max = min;
391 x2 = (len * (x+1))/w;
392 for( int i=x1; i<x2; ++i ) {
393 double value = *dp++;
394 if( value < min ) min = value;
395 if( value > max ) max = value;
397 int ctr = (min + max) / 2;
398 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
399 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
400 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
401 frame->pixel_rgb = line_color;
402 frame->draw_line(x,y1, x,y2);
403 frame->pixel_rgb = base_color;
404 frame->draw_line(x,y, x,y0);
407 frame->pixel_rgb = rgb_color;
410 void AssetPicon::reset()
416 foldernum = AW_NO_FOLDER;
426 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
428 TransportCommand command;
429 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
430 command.get_edl()->copy_all(edl);
431 command.change_type = CHANGE_ALL;
432 command.realtime = 0;
433 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
434 render_engine->set_vcache(mwindow->video_cache);
435 render_engine->set_acache(mwindow->audio_cache);
436 render_engine->arm_command(&command);
438 void AssetPicon::close_render_engine()
440 delete render_engine; render_engine = 0;
442 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
444 if( !render_engine || !render_engine->vrender ) return;
445 render_engine->vrender->process_buffer(vfrm, pos, 0);
447 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
449 if( !render_engine || !render_engine->arender ) return;
450 render_engine->arender->process_buffer(samples, len, pos);
453 void AssetPicon::create_objects()
456 char name[BCTEXTLEN];
457 int pixmap_w, pixmap_h;
459 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
462 fs.extract_name(name, indexable->path);
466 set_text(strcpy(name, edl->local_session->clip_title));
470 if( indexable && indexable->is_asset ) {
471 Asset *asset = (Asset*)indexable;
472 if( asset->video_data ) {
473 if( mwindow->preferences->use_thumbnails ) {
474 gui->unlock_window();
475 File *file = mwindow->video_cache->check_out(asset,
480 int height = asset->height > 0 ? asset->height : 1;
481 pixmap_w = pixmap_h * asset->width / height;
484 file->set_video_position(0, 0);
486 if( gui->temp_picon &&
487 (gui->temp_picon->get_w() != asset->width ||
488 gui->temp_picon->get_h() != asset->height) ) {
489 delete gui->temp_picon;
493 if( !gui->temp_picon ) {
494 gui->temp_picon = new VFrame(0, -1,
495 asset->width, asset->height,
498 { char string[BCTEXTLEN];
499 sprintf(string, _("Reading %s"), name);
500 mwindow->gui->lock_window("AssetPicon::create_objects");
501 mwindow->gui->show_message(string);
502 mwindow->gui->unlock_window(); }
503 file->read_frame(gui->temp_picon);
504 mwindow->video_cache->check_in(asset);
506 gui->lock_window("AssetPicon::create_objects 0");
507 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
508 icon->draw_vframe(gui->temp_picon,
509 0, 0, pixmap_w, pixmap_h, 0, 0);
510 icon_vframe = new VFrame(0,
511 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
512 icon_vframe->transfer_from(gui->temp_picon);
513 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
515 double framerate = asset->get_frame_rate();
516 if( !framerate ) framerate = VICON_RATE;
517 int64_t frames = asset->get_video_frames();
518 double secs = frames / framerate;
519 if( secs > 5 ) secs = 5;
520 int64_t length = secs * gui->vicon_thread->refresh_rate;
521 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
522 if( asset->audio_data && secs > 0 ) {
523 gui->unlock_window();
524 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
525 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
527 gui->lock_window("AssetPicon::create_objects 1");
529 gui->vicon_thread->add_vicon(vicon);
534 gui->lock_window("AssetPicon::create_objects 2");
535 icon = gui->video_icon;
536 icon_vframe = gui->video_vframe;
540 icon = gui->video_icon;
541 icon_vframe = gui->video_vframe;
545 if( asset->audio_data ) {
546 if( mwindow->preferences->use_thumbnails ) {
547 gui->unlock_window();
548 File *file = mwindow->audio_cache->check_out(asset,
552 pixmap_w = pixmap_h * 16/9;
553 icon_vframe = new VFrame(0,
554 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
555 icon_vframe->clear_frame();
556 { char string[BCTEXTLEN];
557 sprintf(string, _("Reading %s"), name);
558 mwindow->gui->lock_window("AssetPicon::create_objects 3");
559 mwindow->gui->show_message(string);
560 mwindow->gui->unlock_window(); }
561 int sample_rate = asset->get_sample_rate();
562 int channels = asset->get_audio_channels();
563 if( channels > 2 ) channels = 2;
564 int64_t audio_samples = asset->get_audio_samples();
565 double duration = (double)audio_samples / sample_rate;
566 draw_hue_bar(icon_vframe, duration);
567 int bfrsz = sample_rate;
568 Samples samples(bfrsz);
569 static int line_colors[2] = { GREEN, YELLOW };
570 static int base_colors[2] = { RED, PINK };
571 for( int i=channels; --i>=0; ) {
572 file->set_channel(i);
573 file->set_audio_position(0);
574 file->read_samples(&samples, bfrsz);
575 draw_wave(icon_vframe, samples.get_data(), bfrsz,
576 base_colors[i], line_colors[i]);
578 mwindow->audio_cache->check_in(asset);
579 if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
580 double secs = duration;
581 if( secs > 5 ) secs = 5;
582 double refresh_rate = gui->vicon_thread->refresh_rate;
583 int64_t length = secs * refresh_rate;
584 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
585 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
586 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
588 gui->vicon_thread->add_vicon(vicon);
590 gui->lock_window("AssetPicon::create_objects 4");
591 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
592 icon->draw_vframe(icon_vframe,
593 0, 0, pixmap_w, pixmap_h, 0, 0);
596 gui->lock_window("AssetPicon::create_objects 5");
597 icon = gui->audio_icon;
598 icon_vframe = gui->audio_vframe;
602 icon = gui->audio_icon;
603 icon_vframe = gui->audio_vframe;
608 mtime = !stat(asset->path, &st) ? st.st_mtime : 0;
611 if( indexable && !indexable->is_asset ) {
612 icon = gui->video_icon;
613 icon_vframe = gui->video_vframe;
617 if( edl->tracks->playable_video_tracks() ) {
618 if( mwindow->preferences->use_thumbnails ) {
619 gui->unlock_window();
620 char clip_icon_path[BCTEXTLEN];
621 char *clip_icon = edl->local_session->clip_icon;
623 snprintf(clip_icon_path, sizeof(clip_icon_path),
624 "%s/%s", File::get_config_path(), clip_icon);
625 icon_vframe = VFramePng::vframe_png(clip_icon_path);
628 //printf("render clip: %s\n", name);
629 int edl_h = edl->get_h(), edl_w = edl->get_w();
630 int height = edl_h > 0 ? edl_h : 1;
631 int width = edl_w > 0 ? edl_w : 1;
632 int color_model = edl->session->color_model;
633 pixmap_w = pixmap_h * width / height;
635 if( gui->temp_picon &&
636 (gui->temp_picon->get_color_model() != color_model ||
637 gui->temp_picon->get_w() != width ||
638 gui->temp_picon->get_h() != height) ) {
639 delete gui->temp_picon; gui->temp_picon = 0;
642 if( !gui->temp_picon ) {
643 gui->temp_picon = new VFrame(0, -1,
644 width, height, color_model, -1);
646 char string[BCTEXTLEN];
647 sprintf(string, _("Rendering %s"), name);
648 mwindow->gui->lock_window("AssetPicon::create_objects");
649 mwindow->gui->show_message(string);
650 mwindow->gui->unlock_window();
651 open_render_engine(edl, 0);
652 render_video(0, gui->temp_picon);
653 close_render_engine();
654 gui->lock_window("AssetPicon::create_objects 0");
655 icon_vframe = new VFrame(0,
656 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
657 icon_vframe->transfer_from(gui->temp_picon);
658 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
661 pixmap_w = icon_vframe->get_w();
662 pixmap_h = icon_vframe->get_h();
664 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
665 icon->draw_vframe(icon_vframe,
666 0, 0, pixmap_w, pixmap_h, 0, 0);
669 icon = gui->clip_icon;
670 icon_vframe = gui->clip_vframe;
674 if( edl->tracks->playable_audio_tracks() ) {
675 if( mwindow->preferences->use_thumbnails ) {
676 gui->unlock_window();
677 char clip_icon_path[BCTEXTLEN];
678 char *clip_icon = edl->local_session->clip_icon;
680 snprintf(clip_icon_path, sizeof(clip_icon_path),
681 "%s/%s", File::get_config_path(), clip_icon);
682 icon_vframe = VFramePng::vframe_png(clip_icon_path);
685 pixmap_w = pixmap_h * 16/9;
686 icon_vframe = new VFrame(0,
687 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
688 icon_vframe->clear_frame();
689 char string[BCTEXTLEN];
690 sprintf(string, _("Rendering %s"), name);
691 mwindow->gui->lock_window("AssetPicon::create_objects 3");
692 mwindow->gui->show_message(string);
693 mwindow->gui->unlock_window();
694 int sample_rate = edl->get_sample_rate();
695 int channels = edl->get_audio_channels();
696 if( channels > 2 ) channels = 2;
697 int64_t audio_samples = edl->get_audio_samples();
698 double duration = (double)audio_samples / sample_rate;
699 draw_hue_bar(icon_vframe, duration);
700 Samples *samples[MAX_CHANNELS];
701 int bfrsz = sample_rate;
702 for( int i=0; i<MAX_CHANNELS; ++i )
703 samples[i] = i<channels ? new Samples(bfrsz) : 0;
704 open_render_engine(edl, 1);
705 render_audio(0, samples, bfrsz);
706 close_render_engine();
707 gui->lock_window("AssetPicon::create_objects 4");
708 static int line_colors[2] = { GREEN, YELLOW };
709 static int base_colors[2] = { RED, PINK };
710 for( int i=channels; --i>=0; ) {
711 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
712 base_colors[i], line_colors[i]);
714 for( int i=0; i<channels; ++i ) delete samples[i];
715 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
718 pixmap_w = icon_vframe->get_w();
719 pixmap_h = icon_vframe->get_h();
721 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
722 icon->draw_vframe(icon_vframe,
723 0, 0, pixmap_w, pixmap_h, 0, 0);
726 icon = gui->clip_icon;
727 icon_vframe = gui->clip_vframe;
733 strcpy(name, _(plugin->title));
735 icon_vframe = plugin->get_picon();
737 icon = gui->create_pixmap(icon_vframe);
738 else if( plugin->audio ) {
739 if( plugin->transition ) {
740 icon = gui->atransition_icon;
741 icon_vframe = gui->atransition_vframe;
743 else if( plugin->is_ffmpeg() ) {
744 icon = gui->ff_aud_icon;
745 icon_vframe = gui->ff_aud_vframe;
747 else if( plugin->is_ladspa() ) {
748 icon = gui->ladspa_icon;
749 icon_vframe = gui->ladspa_vframe;
752 icon = gui->aeffect_icon;
753 icon_vframe = gui->aeffect_vframe;
756 else if( plugin->video ) {
757 if( plugin->transition ) {
758 icon = gui->vtransition_icon;
759 icon_vframe = gui->vtransition_vframe;
761 else if( plugin->is_ffmpeg() ) {
762 icon = gui->ff_vid_icon;
763 icon_vframe = gui->ff_vid_vframe;
766 icon = gui->veffect_icon;
767 icon_vframe = gui->veffect_vframe;
775 mwindow->edl->session->time_format,
776 mwindow->edl->session->sample_rate,
777 mwindow->edl->session->frame_rate,
778 mwindow->edl->session->frames_per_foot);
780 icon = gui->label_icon;
781 icon_vframe = gui->label_vframe;
784 icon = gui->file_icon;
785 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
788 set_icon_vframe(icon_vframe);
791 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
792 : BC_Window(_(PROGRAM_NAME ": Resources"),
793 mwindow->session->awindow_x, mwindow->session->awindow_y,
794 mwindow->session->awindow_w, mwindow->session->awindow_h,
797 this->mwindow = mwindow;
798 this->awindow = awindow;
800 file_vframe = 0; file_icon = 0;
801 folder_vframe = 0; folder_icon = 0;
802 audio_vframe = 0; audio_icon = 0;
803 video_vframe = 0; video_icon = 0;
804 label_vframe = 0; label_icon = 0;
806 atransition_vframe = 0; atransition_icon = 0;
807 vtransition_vframe = 0; vtransition_icon = 0;
808 aeffect_vframe = 0; aeffect_icon = 0;
809 ladspa_vframe = 0; ladspa_icon = 0;
810 veffect_vframe = 0; veffect_icon = 0;
811 ff_aud_vframe = 0; ff_aud_icon = 0;
812 ff_vid_vframe = 0; ff_vid_icon = 0;
814 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
815 atransition_folder_vframe = 0; atransition_folder_icon = 0;
816 clip_folder_vframe = 0; clip_folder_icon = 0;
817 label_folder_vframe = 0; label_folder_icon = 0;
818 media_folder_vframe = 0; media_folder_icon = 0;
819 proxy_folder_vframe = 0; proxy_folder_icon = 0;
820 veffect_folder_vframe = 0; veffect_folder_icon = 0;
821 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
823 ladspa_vframe = 0; ladspa_icon = 0;
824 ff_aud_vframe = 0; ff_aud_icon = 0;
825 ff_vid_vframe = 0; ff_vid_icon = 0;
827 clip_vframe = 0; clip_icon = 0;
828 atransition_vframe = 0; atransition_icon = 0;
829 vtransition_vframe = 0; vtransition_icon = 0;
830 aeffect_vframe = 0; aeffect_icon = 0;
831 veffect_vframe = 0; veffect_icon = 0;
833 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
834 newfolder_thread = 0;
844 allow_iconlisting = 1;
849 displayed_folder = AW_NO_FOLDER;
852 AWindowGUI::~AWindowGUI()
854 assets.remove_all_objects();
855 folders.remove_all_objects();
856 aeffects.remove_all_objects();
857 veffects.remove_all_objects();
858 atransitions.remove_all_objects();
859 vtransitions.remove_all_objects();
860 labellist.remove_all_objects();
861 displayed_assets[1].remove_all_objects();
865 delete newfolder_thread;
869 delete remove_plugin;
871 delete file_vframe; delete file_icon;
872 delete folder_vframe; delete folder_icon;
873 delete audio_vframe; delete audio_icon;
874 delete video_vframe; delete video_icon;
875 delete label_vframe; delete label_icon;
876 delete clip_vframe; delete clip_icon;
877 delete aeffect_folder_vframe; delete aeffect_folder_icon;
878 delete atransition_folder_vframe; delete atransition_folder_icon;
879 delete veffect_folder_vframe; delete veffect_folder_icon;
880 delete vtransition_folder_vframe; delete vtransition_folder_icon;
881 delete clip_folder_vframe; delete clip_folder_icon;
882 delete label_folder_vframe; delete label_folder_icon;
883 delete media_folder_vframe; delete media_folder_icon;
884 delete proxy_folder_vframe; delete proxy_folder_icon;
885 delete ladspa_vframe; delete ladspa_icon;
886 delete ff_aud_vframe; delete ff_aud_icon;
887 delete ff_vid_vframe; delete ff_vid_icon;
888 delete atransition_vframe; delete atransition_icon;
889 delete vtransition_vframe; delete vtransition_icon;
890 delete aeffect_vframe; delete aeffect_icon;
891 delete veffect_vframe; delete veffect_icon;
894 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
896 return icon == file_icon ||
897 icon == folder_icon ||
898 icon == audio_icon ||
899 icon == video_icon ||
901 icon == label_icon ||
902 icon == vtransition_icon ||
903 icon == atransition_icon ||
904 icon == veffect_icon ||
905 icon == aeffect_icon ||
906 icon == ladspa_icon ||
907 icon == ff_aud_icon ||
908 icon == ff_vid_icon ||
909 icon == aeffect_folder_icon ||
910 icon == veffect_folder_icon ||
911 icon == atransition_folder_icon ||
912 icon == vtransition_folder_icon ||
913 icon == label_folder_icon ||
914 icon == clip_folder_icon ||
915 icon == media_folder_icon ||
916 icon == proxy_folder_icon;
919 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
921 char png_path[BCTEXTLEN];
922 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
923 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
924 File::get_plugin_path(), plugin_icons, name);
925 if( access(png_path, R_OK) ) return 0;
926 return VFramePng::vframe_png(png_path,0,0);
929 VFrame *AWindowGUI::get_picon(const char *name)
931 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
933 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
934 snprintf(pp, ep-pp, "%s.png", name);
935 unsigned char *data = mwindow->theme->get_image_data(png_name);
936 if( data ) vframe = new VFramePng(data, 0.);
941 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
943 vfrm = get_picon(fn);
944 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
945 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
947 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
949 vfrm = get_picon(fn);
950 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
951 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
953 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
955 vfrm = get_picon(fn);
956 if( !vfrm ) vfrm = new VFramePng(png);
957 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
960 void AWindowGUI::create_objects()
962 lock_window("AWindowGUI::create_objects");
963 asset_titles[0] = C_("Title");
964 asset_titles[1] = _("Comments");
966 set_icon(mwindow->theme->get_image("awindow_icon"));
968 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
969 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
970 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
971 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
972 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
974 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
975 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
976 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
977 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
978 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
979 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
980 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
981 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
983 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
984 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
985 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
986 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
987 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
988 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
989 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
990 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
992 theme_icon(clip_vframe, clip_icon, "clip_icon");
993 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
994 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
995 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
996 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
998 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
999 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1000 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1002 // Mandatory folders
1003 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1004 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1005 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1006 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1007 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1008 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1009 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1010 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1012 create_label_folder();
1014 mwindow->theme->get_awindow_sizes(this);
1015 load_defaults(mwindow->defaults);
1017 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1018 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1019 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1020 search_text->create_objects();
1021 int dy = search_text->get_h() + 10;
1023 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1025 vicon_thread = new VIconThread(asset_list);
1026 vicon_thread->start();
1027 vicon_audio = new AssetVIconAudio(this);
1029 add_subwindow(divider = new AWindowDivider(mwindow, this,
1030 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1031 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1033 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1035 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1036 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1037 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1038 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1039 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1040 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1041 add_tools->create_objects();
1042 fy += add_tools->get_h(); fh -= add_tools->get_h();
1043 add_subwindow(folder_list = new AWindowFolders(mwindow,
1044 this, fx, fy, fw, fh));
1047 //int x = mwindow->theme->abuttons_x;
1048 //int y = mwindow->theme->abuttons_y;
1051 newfolder_thread = new NewFolderThread(mwindow, this);
1053 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1054 asset_menu->create_objects();
1055 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1056 clip_menu->create_objects();
1057 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1058 label_menu->create_objects();
1059 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1060 proxy_menu->create_objects();
1062 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1063 effectlist_menu->create_objects();
1064 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1065 assetlist_menu->create_objects();
1066 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1067 cliplist_menu->create_objects();
1068 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1069 labellist_menu->create_objects();
1070 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1071 proxylist_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( !ctrl_down() && !shift_down() ) {
1315 assetlist_menu->load_file->handle_event();
1320 if( shift_down() ) {
1321 PluginServer* plugin = selected_plugin();
1322 if( !plugin ) break;
1323 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1325 remove_plugin->start();
1334 int AWindowGUI::create_custom_xatoms()
1336 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1339 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
1341 if( event->message_type == UpdateAssetsXAtom ) {
1348 void AWindowGUI::async_update_assets()
1351 event.message_type = UpdateAssetsXAtom;
1352 send_custom_xatom(&event);
1356 void AWindowGUI::update_folder_list()
1358 for( int i = 0; i < folders.total; i++ ) {
1359 AssetPicon *picon = (AssetPicon*)folders.values[i];
1363 // Search assets for folders
1364 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1365 const char *folder = mwindow->edl->folders.values[i];
1368 for( int j = 0; j < folders.total; j++ ) {
1369 AssetPicon *picon = (AssetPicon*)folders.values[j];
1370 if( !strcasecmp(picon->get_text(), folder) ) {
1378 int aw_folder = folder_number(folder);
1379 if( aw_folder >= 0 ) {
1380 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
1381 picon->create_objects();
1382 folders.append(picon);
1387 // Delete unused non-persistent folders
1388 for( int i=folders.total; --i>=0; ) {
1389 AssetPicon *picon = (AssetPicon*)folders.values[i];
1390 if( !picon->in_use && !picon->persistent ) {
1392 folders.remove_number(i);
1397 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1398 int do_audio, int do_video, int is_realtime, int is_transition)
1400 ArrayList<PluginServer*> plugin_list;
1401 // Get pointers to plugindb entries
1402 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1405 for( int i = 0; i < plugin_list.total; i++ ) {
1406 PluginServer *server = plugin_list.values[i];
1407 int visible = plugin_visibility & (1<<server->dir_idx);
1408 if( !visible ) continue;
1409 // Create new listitem
1410 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1411 picon->create_objects();
1412 output->append(picon);
1416 void AWindowGUI::create_label_folder()
1419 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1420 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1421 picon->create_objects();
1422 labellist.append(picon);
1427 void AWindowGUI::update_asset_list()
1429 for( int i = 0; i < assets.total; i++ ) {
1430 AssetPicon *picon = (AssetPicon*)assets.values[i];
1434 // Synchronize EDL clips
1435 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1438 // Look for clip in existing listitems
1439 for( int j = 0; j < assets.total && !exists; j++ ) {
1440 AssetPicon *picon = (AssetPicon*)assets.values[j];
1442 if( picon->id == mwindow->edl->clips[i]->id ) {
1443 picon->edl = mwindow->edl->clips[i];
1444 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1450 // Create new listitem
1452 AssetPicon *picon = new AssetPicon(mwindow,
1453 this, mwindow->edl->clips[i]);
1454 picon->create_objects();
1455 assets.append(picon);
1459 // Synchronize EDL assets
1460 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1463 // Look for asset in existing listitems
1464 for( int j = 0; j < assets.total && !exists; j++ ) {
1465 AssetPicon *picon = (AssetPicon*)assets.values[j];
1467 if( picon->id == current->id ) {
1468 picon->indexable = current;
1474 // Create new listitem
1476 AssetPicon *picon = new AssetPicon(mwindow,
1478 picon->create_objects();
1479 assets.append(picon);
1483 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1484 mwindow->gui->default_message();
1485 mwindow->gui->unlock_window();
1487 // Synchronize nested EDLs
1488 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1490 EDL *nested_edl = mwindow->edl->nested_edls[i];
1492 // Look for asset in existing listitems
1493 for( int j=0; j<assets.total && !exists; ++j ) {
1494 AssetPicon *picon = (AssetPicon*)assets.values[j];
1496 if( picon->id == nested_edl->id ) {
1497 picon->indexable = nested_edl;
1503 // Create new listitem
1505 AssetPicon *picon = new AssetPicon(mwindow,
1506 this, (Indexable*)nested_edl);
1507 picon->create_objects();
1508 assets.append(picon);
1512 for( int i = assets.size() - 1; i >= 0; i-- ) {
1513 AssetPicon *picon = (AssetPicon*)assets.get(i);
1514 if( !picon->in_use ) {
1516 assets.remove_number(i);
1519 if( !picon->indexable || !picon->indexable->is_asset ) continue;
1521 picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
1525 void AWindowGUI::update_picon(Indexable *indexable)
1528 for( int i = 0; i < assets.total; i++ ) {
1529 AssetPicon *picon = (AssetPicon*)assets.values[i];
1530 if( picon->indexable == indexable ||
1531 picon->edl == (EDL *)indexable ) {
1532 char name[BCTEXTLEN];
1534 fs.extract_name(name, indexable->path);
1535 picon->set_text(name);
1536 vicon = picon->vicon;
1541 stop_vicon_drawing();
1542 vicon->clear_images();
1543 vicon->reset(indexable->get_frame_rate());
1544 start_vicon_drawing();
1548 void AWindowGUI::sort_assets(int use_mtime)
1550 switch( mwindow->edl->session->awindow_folder ) {
1551 case AW_AEFFECT_FOLDER:
1552 sort_picons(&aeffects);
1554 case AW_VEFFECT_FOLDER:
1555 sort_picons(&veffects);
1557 case AW_ATRANSITION_FOLDER:
1558 sort_picons(&atransitions);
1560 case AW_VTRANSITION_FOLDER:
1561 sort_picons(&vtransitions);
1563 case AW_LABEL_FOLDER:
1564 sort_picons(&labellist);
1567 sort_picons(&assets, use_mtime);
1570 asset_list->update_format(asset_list->get_format(), 0);
1574 void AWindowGUI::sort_folders()
1576 sort_picons(&folders);
1577 folder_list->update_format(folder_list->get_format(), 0);
1581 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1583 Asset *proxy_asset = (Asset *)indexable;
1584 char path[BCTEXTLEN];
1585 int proxy_scale = mwindow->edl->session->proxy_scale;
1586 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1587 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1588 if( !unproxy_asset || !unproxy_asset->channels ) return 0;
1589 // make a clip from proxy video tracks and unproxy audio tracks
1590 EDL *proxy_edl = new EDL(mwindow->edl);
1591 proxy_edl->create_objects();
1592 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1593 proxy_edl->set_path(path);
1594 strcpy(proxy_edl->local_session->clip_title, path);
1595 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1596 proxy_edl->session->video_tracks = proxy_asset->layers;
1597 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1598 proxy_edl->create_default_tracks();
1599 double length = proxy_asset->frame_rate > 0 ?
1600 (double)proxy_asset->video_length / proxy_asset->frame_rate :
1601 1.0 / mwindow->edl->session->frame_rate;
1602 Track *current = proxy_edl->tracks->first;
1603 for( int vtrack=0; current; current=NEXT ) {
1604 if( current->data_type != TRACK_VIDEO ) continue;
1605 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1607 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1608 current = proxy_edl->tracks->first;
1609 for( int atrack=0; current; current=NEXT ) {
1610 if( current->data_type != TRACK_AUDIO ) continue;
1611 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1617 void AWindowGUI::collect_assets(int proxy)
1619 mwindow->session->drag_assets->remove_all();
1620 mwindow->session->drag_clips->remove_all();
1621 mwindow->session->clear_drag_proxy();
1622 int i = 0; AssetPicon *result;
1623 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1624 Indexable *indexable = result->indexable; EDL *drag_edl;
1625 if( proxy && (drag_edl=collect_proxy(indexable)) ) {
1626 mwindow->session->drag_clips->append(drag_edl);
1627 mwindow->session->drag_proxy->append(drag_edl);
1631 mwindow->session->drag_assets->append(indexable);
1635 mwindow->session->drag_clips->append(result->edl);
1641 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1642 ArrayList<BC_ListBoxItem*> *src, int folder)
1644 // Remove current pointers
1645 dst[0].remove_all();
1646 dst[1].remove_all_objects();
1648 // Create new pointers
1649 for( int i = 0; i < src->total; i++ ) {
1650 AssetPicon *picon = (AssetPicon*)src->values[i];
1652 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1653 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1654 const char *text = search_text->get_text();
1655 int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
1656 if( picon->vicon ) picon->vicon->hidden = hidden;
1657 if( hidden ) continue;
1658 BC_ListBoxItem *item2, *item1;
1659 dst[0].append(item1 = picon);
1661 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1663 if( picon->label && picon->label->textstr )
1664 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1665 else if( picon->mtime ) {
1666 char date_time[BCSTRLEN];
1667 struct tm stm; localtime_r(&picon->mtime, &stm);
1668 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1669 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1670 stm.tm_hour, stm.tm_min, stm.tm_sec);
1671 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1674 dst[1].append(item2 = new BC_ListBoxItem(""));
1675 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1676 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1681 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
1683 int done = 0, changed = 0;
1686 for( int i=0; i<src->total-1; ++i ) {
1687 AssetPicon *item1 = (AssetPicon *)src->values[i];
1688 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1689 if( use_mtime ? item1->mtime > item2->mtime :
1690 strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1691 src->values[i + 1] = item1;
1692 src->values[i] = item2;
1693 done = 0; changed = 1;
1698 for( int i=0; i<src->total; ++i ) {
1699 AssetPicon *item = (AssetPicon *)src->values[i];
1700 item->set_autoplace_icon(1);
1701 item->set_autoplace_text(1);
1707 void AWindowGUI::filter_displayed_assets()
1709 //allow_iconlisting = 1;
1710 asset_titles[0] = C_("Title");
1711 asset_titles[1] = _("Comments");
1713 switch( mwindow->edl->session->awindow_folder ) {
1714 case AW_AEFFECT_FOLDER:
1715 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1717 case AW_VEFFECT_FOLDER:
1718 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1720 case AW_ATRANSITION_FOLDER:
1721 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1723 case AW_VTRANSITION_FOLDER:
1724 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1726 case AW_LABEL_FOLDER:
1727 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1728 asset_titles[0] = _("Time Stamps");
1729 asset_titles[1] = C_("Title");
1730 //allow_iconlisting = 0;
1733 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1737 // Ensure the current folder icon is highlighted
1738 int selected_folder = mwindow->edl->session->awindow_folder;
1739 for( int i = 0; i < folders.total; i++ ) {
1740 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1741 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1742 folder_item->set_selected(selected);
1747 void AWindowGUI::update_assets()
1749 stop_vicon_drawing();
1750 update_folder_list();
1751 update_asset_list();
1752 labellist.remove_all_objects();
1753 create_label_folder();
1755 if( displayed_folder != mwindow->edl->session->awindow_folder )
1756 search_text->clear();
1757 filter_displayed_assets();
1759 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1760 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1762 int folder_xposition = folder_list->get_xposition();
1763 int folder_yposition = folder_list->get_yposition();
1764 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1766 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1767 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1769 int asset_xposition = asset_list->get_xposition();
1770 int asset_yposition = asset_list->get_yposition();
1771 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1772 displayed_folder = mwindow->edl->session->awindow_folder;
1773 asset_xposition = asset_yposition = 0;
1775 asset_list->update(displayed_assets, asset_titles,
1776 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1777 asset_xposition, asset_yposition, -1, 0);
1778 asset_list->center_selection();
1781 start_vicon_drawing();
1785 void AWindowGUI::update_effects()
1787 aeffects.remove_all_objects();
1788 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1789 veffects.remove_all_objects();
1790 create_persistent_folder(&veffects, 0, 1, 1, 0);
1791 atransitions.remove_all_objects();
1792 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1793 vtransitions.remove_all_objects();
1794 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1797 int AWindowGUI::folder_number(const char *name)
1799 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1800 if( !strcasecmp(name, folder_names[i]) ) return i;
1802 return AW_NO_FOLDER;
1805 int AWindowGUI::drag_motion()
1807 if( get_hidden() ) return 0;
1813 int AWindowGUI::drag_stop()
1815 if( get_hidden() ) return 0;
1819 Indexable* AWindowGUI::selected_asset()
1821 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1822 return picon ? picon->indexable : 0;
1825 PluginServer* AWindowGUI::selected_plugin()
1827 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1828 return picon ? picon->plugin : 0;
1831 AssetPicon* AWindowGUI::selected_folder()
1833 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1844 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1845 : BC_SubWindow(x, y, w, h)
1847 this->mwindow = mwindow;
1850 AWindowDivider::~AWindowDivider()
1854 int AWindowDivider::button_press_event()
1856 if( is_event_win() && cursor_inside() ) {
1857 mwindow->session->current_operation = DRAG_PARTITION;
1863 int AWindowDivider::cursor_motion_event()
1865 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1867 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1868 int fw = gui->get_relative_cursor_x();
1869 if( fw > wmax ) fw = wmax;
1870 if( fw < wmin ) fw = wmin;
1871 mwindow->session->afolders_w = fw;
1872 mwindow->theme->get_awindow_sizes(gui);
1873 gui->reposition_objects();
1879 int AWindowDivider::button_release_event()
1881 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1882 mwindow->session->current_operation = NO_OPERATION;
1893 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1894 : BC_ListBox(x, y, w, h,
1895 mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
1896 LISTBOX_ICONS : LISTBOX_TEXT,
1897 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1898 0, // Titles for columns. Set to 0 for no titles
1899 0, // width of each column
1900 1, // Total columns.
1901 0, // Pixel of top of window.
1902 0, // If this listbox is a popup window
1903 LISTBOX_SINGLE, // Select one item or multiple items
1904 ICON_TOP, // Position of icon relative to text of each item
1907 this->mwindow = mwindow;
1912 AWindowFolders::~AWindowFolders()
1916 int AWindowFolders::selection_changed()
1918 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1920 gui->stop_vicon_drawing();
1922 if( get_button_down() && get_buttonpress() == 3 ) {
1923 gui->folderlist_menu->update_titles();
1924 gui->folderlist_menu->activate_menu();
1927 mwindow->edl->session->awindow_folder = picon->foldernum;
1928 gui->asset_list->draw_background();
1929 gui->async_update_assets();
1931 gui->start_vicon_drawing();
1936 int AWindowFolders::button_press_event()
1940 result = BC_ListBox::button_press_event();
1943 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1944 gui->folderlist_menu->update_titles();
1945 gui->folderlist_menu->activate_menu();
1960 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1961 : BC_ListBox(x, y, w, h,
1962 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
1963 LISTBOX_ICONS : LISTBOX_TEXT,
1964 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1965 gui->asset_titles,// Titles for columns. Set to 0 for no titles
1966 mwindow->edl->session->asset_columns, // width of each column
1967 1, // Total columns.
1968 0, // Pixel of top of window.
1969 0, // If this listbox is a popup window
1970 LISTBOX_MULTIPLE, // Select one item or multiple items
1971 ICON_TOP, // Position of icon relative to text of each item
1972 -1) // Allow drags, require shift for scrolling
1974 this->mwindow = mwindow;
1977 set_scroll_stretch(1, 1);
1980 AWindowAssets::~AWindowAssets()
1984 int AWindowAssets::button_press_event()
1988 result = BC_ListBox::button_press_event();
1990 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1991 BC_ListBox::deactivate_selection();
1992 int folder = mwindow->edl->session->awindow_folder;
1994 case AW_AEFFECT_FOLDER:
1995 case AW_VEFFECT_FOLDER:
1996 case AW_ATRANSITION_FOLDER:
1997 case AW_VTRANSITION_FOLDER:
1998 gui->effectlist_menu->update();
1999 gui->effectlist_menu->activate_menu();
2001 case AW_LABEL_FOLDER:
2002 gui->labellist_menu->update();
2003 gui->labellist_menu->activate_menu();
2005 case AW_CLIP_FOLDER:
2006 gui->cliplist_menu->update();
2007 gui->cliplist_menu->activate_menu();
2009 case AW_PROXY_FOLDER:
2010 gui->proxylist_menu->update();
2011 gui->proxylist_menu->activate_menu();
2013 case AW_MEDIA_FOLDER:
2014 gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
2015 gui->assetlist_menu->activate_menu();
2025 int AWindowAssets::handle_event()
2027 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2028 if( !asset_picon ) return 0;
2029 switch( mwindow->edl->session->awindow_folder ) {
2030 case AW_AEFFECT_FOLDER:
2031 case AW_VEFFECT_FOLDER:
2032 case AW_ATRANSITION_FOLDER:
2033 case AW_VTRANSITION_FOLDER: return 1;
2035 VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
2036 mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
2037 if( !vwindow || !vwindow->is_running() ) return 1;
2039 if( asset_picon->indexable )
2040 vwindow->change_source(asset_picon->indexable);
2041 else if( asset_picon->edl )
2042 vwindow->change_source(asset_picon->edl);
2046 int AWindowAssets::selection_changed()
2048 // Show popup window
2050 if( get_button_down() && get_buttonpress() == 3 &&
2051 (item = (AssetPicon*)get_selection(0, 0)) ) {
2052 int folder = mwindow->edl->session->awindow_folder;
2054 case AW_AEFFECT_FOLDER:
2055 case AW_VEFFECT_FOLDER:
2056 case AW_ATRANSITION_FOLDER:
2057 case AW_VTRANSITION_FOLDER:
2058 gui->effectlist_menu->update();
2059 gui->effectlist_menu->activate_menu();
2061 case AW_LABEL_FOLDER:
2062 if( !item->label ) break;
2063 gui->label_menu->activate_menu();
2065 case AW_CLIP_FOLDER:
2066 if( !item->indexable && !item->edl ) break;
2067 gui->clip_menu->update();
2068 gui->clip_menu->activate_menu();
2070 case AW_PROXY_FOLDER:
2071 if( !item->indexable && !item->edl ) break;
2072 gui->proxy_menu->update();
2073 gui->proxy_menu->activate_menu();
2076 if( !item->indexable && !item->edl ) break;
2077 gui->asset_menu->update();
2078 gui->asset_menu->activate_menu();
2082 BC_ListBox::deactivate_selection();
2085 else if( gui->vicon_drawing &&
2086 get_button_down() && get_buttonpress() == 1 &&
2087 (item = (AssetPicon*)get_selection(0, 0)) ) {
2089 if( !gui->vicon_thread->viewing ) {
2090 vicon = item->vicon;
2092 gui->vicon_thread->set_view_popup(vicon);
2098 void AWindowAssets::draw_background()
2100 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2101 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2102 set_font(LARGEFONT);
2103 int aw_folder = mwindow->edl->session->awindow_folder;
2104 if( aw_folder < 0 ) return;
2105 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
2106 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
2107 aw_name, -1, get_bg_surface());
2110 int AWindowAssets::drag_start_event()
2112 int collect_pluginservers = 0;
2113 int collect_assets = 0, proxy = 0;
2115 if( BC_ListBox::drag_start_event() ) {
2116 switch( mwindow->edl->session->awindow_folder ) {
2117 case AW_AEFFECT_FOLDER:
2118 mwindow->session->current_operation = DRAG_AEFFECT;
2119 collect_pluginservers = 1;
2121 case AW_VEFFECT_FOLDER:
2122 mwindow->session->current_operation = DRAG_VEFFECT;
2123 collect_pluginservers = 1;
2125 case AW_ATRANSITION_FOLDER:
2126 mwindow->session->current_operation = DRAG_ATRANSITION;
2127 collect_pluginservers = 1;
2129 case AW_VTRANSITION_FOLDER:
2130 mwindow->session->current_operation = DRAG_VTRANSITION;
2131 collect_pluginservers = 1;
2133 case AW_LABEL_FOLDER:
2136 case AW_PROXY_FOLDER:
2139 case AW_MEDIA_FOLDER:
2141 mwindow->session->current_operation = DRAG_ASSET;
2146 if( collect_pluginservers ) {
2148 mwindow->session->drag_pluginservers->remove_all();
2151 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2152 if( !result ) break;
2154 mwindow->session->drag_pluginservers->append(result->plugin);
2158 if( collect_assets ) {
2159 gui->collect_assets(proxy);
2167 int AWindowAssets::drag_motion_event()
2169 BC_ListBox::drag_motion_event();
2172 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2173 mwindow->gui->drag_motion();
2174 mwindow->gui->unlock_window();
2176 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2177 VWindow *vwindow = mwindow->vwindows.get(i);
2178 if( !vwindow->is_running() ) continue;
2179 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2180 vwindow->gui->drag_motion();
2181 vwindow->gui->unlock_window();
2184 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2185 mwindow->cwindow->gui->drag_motion();
2186 mwindow->cwindow->gui->unlock_window();
2188 lock_window("AWindowAssets::drag_motion_event");
2192 int AWindowAssets::drag_stop_event()
2196 result = gui->drag_stop();
2201 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2202 result = mwindow->gui->drag_stop();
2203 mwindow->gui->unlock_window();
2207 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2208 VWindow *vwindow = mwindow->vwindows.get(i);
2209 if( !vwindow ) continue;
2210 if( !vwindow->is_running() ) continue;
2211 if( vwindow->gui->is_hidden() ) continue;
2212 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2213 if( vwindow->gui->cursor_above() &&
2214 vwindow->gui->get_cursor_over_window() ) {
2215 result = vwindow->gui->drag_stop();
2217 vwindow->gui->unlock_window();
2222 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2223 result = mwindow->cwindow->gui->drag_stop();
2224 mwindow->cwindow->gui->unlock_window();
2227 lock_window("AWindowAssets::drag_stop_event");
2230 get_drag_popup()->set_animation(0);
2232 BC_ListBox::drag_stop_event();
2233 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2234 mwindow->session->current_operation = ::NO_OPERATION;
2235 mwindow->session->clear_drag_proxy();
2240 int AWindowAssets::column_resize_event()
2242 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2243 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2247 int AWindowAssets::focus_in_event()
2249 gui->start_vicon_drawing();
2253 int AWindowAssets::focus_out_event()
2255 gui->stop_vicon_drawing();
2256 return BC_ListBox::focus_out_event();
2259 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2260 : BC_TextBox(x, y, w, 1, "")
2262 this->search_text = search_text;
2265 int AWindowSearchTextBox::handle_event()
2267 return search_text->handle_event();
2270 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2272 this->mwindow = mwindow;
2278 void AWindowSearchText::create_objects()
2280 int x1 = x, y1 = y, margin = 10;
2281 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2282 x1 += text_title->get_w() + margin;
2283 int w1 = gui->get_w() - x1 - 2*margin;
2284 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2287 int AWindowSearchText::handle_event()
2289 gui->async_update_assets();
2293 int AWindowSearchText::get_w()
2295 return text_box->get_w() + text_title->get_w() + 10;
2298 int AWindowSearchText::get_h()
2300 return bmax(text_box->get_h(),text_title->get_h());
2303 void AWindowSearchText::reposition_window(int x, int y, int w)
2305 int x1 = x, y1 = y, margin = 10;
2306 text_title->reposition_window(x1, y1);
2307 x1 += text_title->get_w() + margin;
2308 int w1 = gui->get_w() - x1 - 2*margin;
2309 text_box->reposition_window(x1, y1, w1);
2312 const char *AWindowSearchText::get_text()
2314 return text_box->get_text();
2317 void AWindowSearchText::clear()
2319 text_box->update("");
2322 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2323 : BC_Button(x, y, mwindow->theme->newbin_data)
2325 this->mwindow = mwindow;
2327 set_tooltip(_("New bin"));
2330 int AWindowNewFolder::handle_event()
2332 gui->newfolder_thread->start_new_folder();
2336 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2337 : BC_Button(x, y, mwindow->theme->deletebin_data)
2339 this->mwindow = mwindow;
2341 set_tooltip(_("Delete bin"));
2344 int AWindowDeleteFolder::handle_event()
2346 if( gui->folder_list->get_selection(0, 0) ) {
2347 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
2348 mwindow->delete_folder(folder->get_text());
2353 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2354 : BC_Button(x, y, mwindow->theme->renamebin_data)
2356 this->mwindow = mwindow;
2358 set_tooltip(_("Rename bin"));
2361 int AWindowRenameFolder::handle_event()
2366 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2367 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2369 this->mwindow = mwindow;
2371 set_tooltip(_("Delete asset from disk"));
2374 int AWindowDeleteDisk::handle_event()
2379 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2380 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2382 this->mwindow = mwindow;
2384 set_tooltip(_("Delete asset from project"));
2387 int AWindowDeleteProject::handle_event()
2392 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2393 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2395 // this->mwindow = mwindow;
2397 // set_tooltip(_("Edit information on asset"));
2400 // int AWindowInfo::handle_event()
2402 // int cur_x, cur_y;
2403 // gui->get_abs_cursor(cur_x, cur_y, 0);
2404 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2408 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2409 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2411 this->mwindow = mwindow;
2413 set_tooltip(_("Redraw index"));
2416 int AWindowRedrawIndex::handle_event()
2421 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2422 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2424 this->mwindow = mwindow;
2426 set_tooltip(_("Paste asset on recordable tracks"));
2429 int AWindowPaste::handle_event()
2434 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2435 : BC_Button(x, y, mwindow->theme->appendasset_data)
2437 this->mwindow = mwindow;
2439 set_tooltip(_("Append asset in new tracks"));
2442 int AWindowAppend::handle_event()
2447 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2448 : BC_Button(x, y, mwindow->theme->viewasset_data)
2450 this->mwindow = mwindow;
2452 set_tooltip(_("View asset"));
2455 int AWindowView::handle_event()
2460 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2461 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2463 this->mwindow = mwindow;
2467 void AddTools::create_objects()
2470 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2471 vis |= 1 << PLUGIN_FFMPEG_ID;
2472 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2473 vis |= 1 << PLUGIN_LADSPA_ID;
2475 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
2476 vis |= 1 << PLUGIN_LV2_ID;
2478 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2479 PluginServer *plugin = MWindow::plugindb->get(i);
2480 if( !plugin->audio && !plugin->video ) continue;
2481 int idx = plugin->dir_idx;
2482 uint32_t msk = 1 << idx;
2483 if( (msk & vis) != 0 ) continue;
2485 char parent[BCTEXTLEN];
2486 strcpy(parent, plugin->path);
2487 char *bp = strrchr(parent, '/');
2488 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2489 if( !bp ) bp = parent; else ++bp;
2490 add_item(new AddPluginItem(this, bp, idx));
2495 // plugin_dirs list from toplevel makefile include plugin_defs
2500 N_("audio_transitions")
2507 N_("video_transitions")
2510 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2511 : BC_MenuItem(_(text))
2515 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2516 int chk = (msk & vis) ? 1 : 0;
2520 int AddPluginItem::handle_event()
2522 int chk = get_checked() ^ 1;
2524 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2525 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2526 menu->gui->update_effects();
2527 menu->gui->save_defaults(menu->mwindow->defaults);
2528 menu->gui->async_update_assets();
2532 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2533 : BC_Toggle(x, y, images, agui->vicon_drawing)
2536 set_tooltip(_("draw vicons"));
2539 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2541 int text_line = -1, toggle_x = -1, toggle_y = -1;
2542 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2543 BC_Toggle::calculate_extents(agui, images, 1,
2544 &text_line, ww, hh, &toggle_x, &toggle_y,
2545 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2548 AVIconDrawing::~AVIconDrawing()
2552 int AVIconDrawing::handle_event()
2554 agui->vicon_drawing = get_value();
2555 if( agui->vicon_drawing )
2556 agui->start_vicon_drawing();
2558 agui->stop_vicon_drawing();
2563 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2566 this->mwindow = mwindow;
2570 int AWindowListFormat::handle_event()
2572 gui->stop_vicon_drawing();
2574 EDLSession *session = mwindow->edl->session;
2575 switch( session->assetlist_format ) {
2577 session->assetlist_format = ASSETS_ICONS;
2580 session->assetlist_format = ASSETS_TEXT;
2584 gui->asset_list->update_format(session->assetlist_format, 1);
2585 if( !mwindow->awindow->gui->allow_iconlisting ) {
2586 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2589 gui->start_vicon_drawing();
2593 void AWindowListFormat::update()
2595 set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
2596 (char*)_("Display icons") : (char*)_("Display text"));
2599 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2600 : BC_MenuItem(_("Sort items"))
2602 this->mwindow = mwindow;
2606 int AWindowListSort::handle_event()
2608 gui->sort_assets(0);