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);
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 icon_vframe = new VFrame(0,
655 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
656 icon_vframe->transfer_from(gui->temp_picon);
657 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
660 pixmap_w = icon_vframe->get_w();
661 pixmap_h = icon_vframe->get_h();
663 gui->lock_window("AssetPicon::create_objects 0");
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;
850 folder_lock = new Mutex("AWindowGUI::folder_lock");
853 AWindowGUI::~AWindowGUI()
855 assets.remove_all_objects();
856 folders.remove_all_objects();
857 aeffects.remove_all_objects();
858 veffects.remove_all_objects();
859 atransitions.remove_all_objects();
860 vtransitions.remove_all_objects();
861 labellist.remove_all_objects();
862 displayed_assets[1].remove_all_objects();
866 delete newfolder_thread;
870 delete remove_plugin;
872 delete file_vframe; delete file_icon;
873 delete folder_vframe; delete folder_icon;
874 delete audio_vframe; delete audio_icon;
875 delete video_vframe; delete video_icon;
876 delete label_vframe; delete label_icon;
877 delete clip_vframe; delete clip_icon;
878 delete aeffect_folder_vframe; delete aeffect_folder_icon;
879 delete atransition_folder_vframe; delete atransition_folder_icon;
880 delete veffect_folder_vframe; delete veffect_folder_icon;
881 delete vtransition_folder_vframe; delete vtransition_folder_icon;
882 delete clip_folder_vframe; delete clip_folder_icon;
883 delete label_folder_vframe; delete label_folder_icon;
884 delete media_folder_vframe; delete media_folder_icon;
885 delete proxy_folder_vframe; delete proxy_folder_icon;
886 delete ladspa_vframe; delete ladspa_icon;
887 delete ff_aud_vframe; delete ff_aud_icon;
888 delete ff_vid_vframe; delete ff_vid_icon;
889 delete atransition_vframe; delete atransition_icon;
890 delete vtransition_vframe; delete vtransition_icon;
891 delete aeffect_vframe; delete aeffect_icon;
892 delete veffect_vframe; delete veffect_icon;
896 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
898 return icon == file_icon ||
899 icon == folder_icon ||
900 icon == audio_icon ||
901 icon == video_icon ||
903 icon == label_icon ||
904 icon == vtransition_icon ||
905 icon == atransition_icon ||
906 icon == veffect_icon ||
907 icon == aeffect_icon ||
908 icon == ladspa_icon ||
909 icon == ff_aud_icon ||
910 icon == ff_vid_icon ||
911 icon == aeffect_folder_icon ||
912 icon == veffect_folder_icon ||
913 icon == atransition_folder_icon ||
914 icon == vtransition_folder_icon ||
915 icon == label_folder_icon ||
916 icon == clip_folder_icon ||
917 icon == media_folder_icon ||
918 icon == proxy_folder_icon;
921 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
923 char png_path[BCTEXTLEN];
924 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
925 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
926 File::get_plugin_path(), plugin_icons, name);
927 if( access(png_path, R_OK) ) return 0;
928 return VFramePng::vframe_png(png_path,0,0);
931 VFrame *AWindowGUI::get_picon(const char *name)
933 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
935 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
936 snprintf(pp, ep-pp, "%s.png", name);
937 unsigned char *data = mwindow->theme->get_image_data(png_name);
938 if( data ) vframe = new VFramePng(data, 0.);
943 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
945 vfrm = get_picon(fn);
946 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
947 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
949 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
951 vfrm = get_picon(fn);
952 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
953 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
955 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
957 vfrm = get_picon(fn);
958 if( !vfrm ) vfrm = new VFramePng(png);
959 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
962 void AWindowGUI::create_objects()
964 lock_window("AWindowGUI::create_objects");
965 asset_titles[0] = C_("Title");
966 asset_titles[1] = _("Comments");
968 set_icon(mwindow->theme->get_image("awindow_icon"));
970 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
971 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
972 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
973 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
974 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
976 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
977 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
978 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
979 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
980 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
981 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
982 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
983 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
985 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
986 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
987 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
988 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
989 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
990 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
991 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
992 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
994 theme_icon(clip_vframe, clip_icon, "clip_icon");
995 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
996 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
997 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
998 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1000 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1001 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1002 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1003 folder_lock->lock("AWindowGUI::create_objects");
1004 // Mandatory folders
1005 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1006 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1007 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1008 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1009 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1010 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1011 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1012 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1014 create_label_folder();
1015 folder_lock->unlock();
1017 mwindow->theme->get_awindow_sizes(this);
1018 load_defaults(mwindow->defaults);
1020 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1021 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1022 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1023 search_text->create_objects();
1024 int dy = search_text->get_h() + 10;
1026 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1028 vicon_thread = new VIconThread(asset_list);
1029 int x0 = 0, y0 = asset_list->get_title_h();
1030 vicon_thread->set_drawing_area(x0,y0, get_w(),get_h());
1031 vicon_thread->start();
1032 vicon_audio = new AssetVIconAudio(this);
1034 add_subwindow(divider = new AWindowDivider(mwindow, this,
1035 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1036 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1038 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1040 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1041 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1042 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1043 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1044 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1045 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1046 add_tools->create_objects();
1047 fy += add_tools->get_h(); fh -= add_tools->get_h();
1048 add_subwindow(folder_list = new AWindowFolders(mwindow,
1049 this, fx, fy, fw, fh));
1052 //int x = mwindow->theme->abuttons_x;
1053 //int y = mwindow->theme->abuttons_y;
1056 newfolder_thread = new NewFolderThread(mwindow, this);
1058 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1059 asset_menu->create_objects();
1060 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1061 clip_menu->create_objects();
1062 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1063 label_menu->create_objects();
1064 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1065 proxy_menu->create_objects();
1067 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1068 effectlist_menu->create_objects();
1069 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1070 assetlist_menu->create_objects();
1071 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1072 cliplist_menu->create_objects();
1073 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1074 labellist_menu->create_objects();
1075 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1076 proxylist_menu->create_objects();
1078 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1079 folderlist_menu->create_objects();
1081 create_custom_xatoms();
1085 int AWindowGUI::resize_event(int w, int h)
1087 mwindow->session->awindow_x = get_x();
1088 mwindow->session->awindow_y = get_y();
1089 mwindow->session->awindow_w = w;
1090 mwindow->session->awindow_h = h;
1092 mwindow->theme->get_awindow_sizes(this);
1093 mwindow->theme->draw_awindow_bg(this);
1094 reposition_objects();
1096 // int x = mwindow->theme->abuttons_x;
1097 // int y = mwindow->theme->abuttons_y;
1098 // new_bin->reposition_window(x, y);
1099 // x += new_bin->get_w();
1100 // delete_bin->reposition_window(x, y);
1101 // x += delete_bin->get_w();
1102 // rename_bin->reposition_window(x, y);
1103 // x += rename_bin->get_w();
1104 // delete_disk->reposition_window(x, y);
1105 // x += delete_disk->get_w();
1106 // delete_project->reposition_window(x, y);
1107 // x += delete_project->get_w();
1108 // info->reposition_window(x, y);
1109 // x += info->get_w();
1110 // redraw_index->reposition_window(x, y);
1111 // x += redraw_index->get_w();
1112 // paste->reposition_window(x, y);
1113 // x += paste->get_w();
1114 // append->reposition_window(x, y);
1115 // x += append->get_w();
1116 // view->reposition_window(x, y);
1118 BC_WindowBase::resize_event(w, h);
1122 int AWindowGUI::translation_event()
1124 mwindow->session->awindow_x = get_x();
1125 mwindow->session->awindow_y = get_y();
1129 void AWindowGUI::reposition_objects()
1131 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1132 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1133 search_text->reposition_window(x1, y1+5, w1);
1134 int dy = search_text->get_h() + 10;
1136 asset_list->reposition_window(x1, y1, w1, h1);
1137 divider->reposition_window(
1138 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1139 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1140 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1141 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1142 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1143 avicon_drawing->reposition_window(fw-avicon_w, fy);
1144 fy += add_tools->get_h(); fh -= add_tools->get_h();
1145 folder_list->reposition_window(fx, fy, fw, fh);
1148 int AWindowGUI::save_defaults(BC_Hash *defaults)
1150 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1151 defaults->update("VICON_DRAWING", vicon_drawing);
1155 int AWindowGUI::load_defaults(BC_Hash *defaults)
1157 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1158 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1162 int AWindowGUI::close_event()
1165 mwindow->session->show_awindow = 0;
1168 mwindow->gui->lock_window("AWindowGUI::close_event");
1169 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1170 mwindow->gui->unlock_window();
1172 lock_window("AWindowGUI::close_event");
1173 save_defaults(mwindow->defaults);
1174 mwindow->save_defaults();
1178 void AWindowGUI::start_vicon_drawing()
1180 if( !vicon_drawing ) return;
1181 if( mwindow->edl->session->awindow_folder != AW_MEDIA_FOLDER ) return;
1182 switch( mwindow->edl->session->assetlist_format ) {
1184 case ASSETS_ICONS_PACKED:
1185 case ASSETS_ICON_LIST:
1186 vicon_thread->start_drawing();
1193 void AWindowGUI::stop_vicon_drawing()
1195 vicon_thread->stop_drawing();
1198 AWindowRemovePluginGUI::
1199 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1200 int x, int y, PluginServer *plugin)
1201 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1203 this->awindow = awindow;
1204 this->thread = thread;
1205 this->plugin = plugin;
1206 VFrame *vframe = plugin->get_picon();
1207 icon = vframe ? create_pixmap(vframe) : 0;
1208 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1211 AWindowRemovePluginGUI::
1212 ~AWindowRemovePluginGUI()
1214 if( !awindow->gui->protected_pixmap(icon) )
1216 plugin_list.remove_all();
1219 void AWindowRemovePluginGUI::create_objects()
1221 lock_window("AWindowRemovePluginGUI::create_objects");
1222 BC_Button *ok_button = new BC_OKButton(this);
1223 add_subwindow(ok_button);
1224 BC_Button *cancel_button = new BC_CancelButton(this);
1225 add_subwindow(cancel_button);
1227 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1228 add_subwindow(title);
1229 y += title->get_h() + 5;
1230 list = new BC_ListBox(x, y,
1231 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1232 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1233 add_subwindow(list);
1238 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1241 for( int i=0; i<folder.size(); ) {
1242 AssetPicon *picon = (AssetPicon *)folder[i];
1243 if( picon->plugin == plugin ) {
1244 folder.remove_object_number(i);
1253 void AWindowRemovePlugin::handle_close_event(int result)
1256 printf(_("remove %s\n"), plugin->path);
1257 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1258 ArrayList<BC_ListBoxItem*> *folder =
1259 plugin->audio ? plugin->transition ?
1260 &awindow->gui->atransitions :
1261 &awindow->gui->aeffects :
1262 plugin->video ? plugin->transition ?
1263 &awindow->gui->vtransitions :
1264 &awindow->gui->veffects :
1266 if( folder ) remove_plugin(plugin, *folder);
1267 MWindow *mwindow = awindow->mwindow;
1268 awindow->gui->unlock_window();
1269 char plugin_path[BCTEXTLEN];
1270 strcpy(plugin_path, plugin->path);
1271 mwindow->plugindb->remove(plugin);
1272 remove(plugin_path);
1273 char index_path[BCTEXTLEN];
1274 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1276 char picon_path[BCTEXTLEN];
1278 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1279 File::get_plugin_path());
1280 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1281 plugin->get_plugin_png_name(png_name);
1282 fs.update(picon_path);
1283 for( int i=0; i<fs.dir_list.total; ++i ) {
1284 char *fs_path = fs.dir_list[i]->path;
1285 if( !fs.is_dir(fs_path) ) continue;
1286 snprintf(png_path, sizeof(picon_path), "%s/%s",
1290 delete plugin; plugin = 0;
1291 awindow->gui->async_update_assets();
1295 AWindowRemovePlugin::
1296 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1299 this->awindow = awindow;
1300 this->plugin = plugin;
1303 AWindowRemovePlugin::
1304 ~AWindowRemovePlugin()
1309 BC_Window* AWindowRemovePlugin::new_gui()
1311 int x = awindow->gui->get_abs_cursor_x(0);
1312 int y = awindow->gui->get_abs_cursor_y(0);
1313 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1314 gui->create_objects();
1318 int AWindowGUI::keypress_event()
1320 switch( get_keypress() ) {
1328 if( !ctrl_down() && !shift_down() ) {
1329 assetlist_menu->load_file->handle_event();
1334 if( shift_down() ) {
1335 PluginServer* plugin = selected_plugin();
1336 if( !plugin ) break;
1337 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1339 remove_plugin->start();
1348 int AWindowGUI::create_custom_xatoms()
1350 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1353 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
1355 if( event->message_type == UpdateAssetsXAtom ) {
1362 void AWindowGUI::async_update_assets()
1365 event.message_type = UpdateAssetsXAtom;
1366 send_custom_xatom(&event);
1370 void AWindowGUI::update_folder_list()
1372 for( int i = 0; i < folders.total; i++ ) {
1373 AssetPicon *picon = (AssetPicon*)folders.values[i];
1377 // Search assets for folders
1378 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1379 const char *folder = mwindow->edl->folders.values[i];
1382 for( int j = 0; j < folders.total; j++ ) {
1383 AssetPicon *picon = (AssetPicon*)folders.values[j];
1384 if( !strcasecmp(picon->get_text(), folder) ) {
1392 int aw_folder = folder_number(folder);
1393 if( aw_folder >= 0 ) {
1394 AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
1395 picon->create_objects();
1396 folders.append(picon);
1401 // Delete unused non-persistent folders
1402 for( int i=folders.total; --i>=0; ) {
1403 AssetPicon *picon = (AssetPicon*)folders.values[i];
1404 if( !picon->in_use && !picon->persistent ) {
1406 folders.remove_number(i);
1411 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1412 int do_audio, int do_video, int is_realtime, int is_transition)
1414 ArrayList<PluginServer*> plugin_list;
1415 // Get pointers to plugindb entries
1416 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1419 for( int i = 0; i < plugin_list.total; i++ ) {
1420 PluginServer *server = plugin_list.values[i];
1421 int visible = plugin_visibility & (1<<server->dir_idx);
1422 if( !visible ) continue;
1423 // Create new listitem
1424 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1425 picon->create_objects();
1426 output->append(picon);
1430 void AWindowGUI::create_label_folder()
1433 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1434 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1435 picon->create_objects();
1436 labellist.append(picon);
1441 void AWindowGUI::update_asset_list()
1443 ArrayList<AssetPicon *> new_assets;
1444 for( int i = 0; i < assets.total; i++ ) {
1445 AssetPicon *picon = (AssetPicon*)assets.values[i];
1449 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1450 // Synchronize EDL clips
1451 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1454 // Look for clip in existing listitems
1455 for( int j = 0; j < assets.total && !exists; j++ ) {
1456 AssetPicon *picon = (AssetPicon*)assets.values[j];
1458 if( picon->id == mwindow->edl->clips[i]->id ) {
1459 picon->edl = mwindow->edl->clips[i];
1460 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1466 // Create new listitem
1468 AssetPicon *picon = new AssetPicon(mwindow,
1469 this, mwindow->edl->clips[i]);
1470 new_assets.append(picon);
1474 // Synchronize EDL assets
1475 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1478 // Look for asset in existing listitems
1479 for( int j = 0; j < assets.total && !exists; j++ ) {
1480 AssetPicon *picon = (AssetPicon*)assets.values[j];
1482 if( picon->id == current->id ) {
1483 picon->indexable = current;
1489 // Create new listitem
1491 AssetPicon *picon = new AssetPicon(mwindow,
1493 new_assets.append(picon);
1497 // Synchronize nested EDLs
1498 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1500 EDL *nested_edl = mwindow->edl->nested_edls[i];
1502 // Look for asset in existing listitems
1503 for( int j=0; j<assets.total && !exists; ++j ) {
1504 AssetPicon *picon = (AssetPicon*)assets.values[j];
1506 if( picon->id == nested_edl->id ) {
1507 picon->indexable = nested_edl;
1513 // Create new listitem
1515 AssetPicon *picon = new AssetPicon(mwindow,
1516 this, (Indexable*)nested_edl);
1517 new_assets.append(picon);
1520 mwindow->gui->unlock_window();
1522 for( int i=0; i<new_assets.size(); ++i ) {
1523 AssetPicon *picon = new_assets[i];
1524 picon->create_objects();
1525 assets.append(picon);
1528 mwindow->gui->lock_window();
1529 mwindow->gui->default_message();
1530 mwindow->gui->unlock_window();
1532 for( int i = assets.size() - 1; i >= 0; i-- ) {
1533 AssetPicon *picon = (AssetPicon*)assets.get(i);
1534 if( !picon->in_use ) {
1536 assets.remove_number(i);
1539 if( !picon->indexable || !picon->indexable->is_asset ) continue;
1541 picon->mtime = !stat(picon->indexable->path, &st) ? st.st_mtime : 0;
1545 void AWindowGUI::update_picon(Indexable *indexable)
1548 for( int i = 0; i < assets.total; i++ ) {
1549 AssetPicon *picon = (AssetPicon*)assets.values[i];
1550 if( picon->indexable == indexable ||
1551 picon->edl == (EDL *)indexable ) {
1552 char name[BCTEXTLEN];
1554 fs.extract_name(name, indexable->path);
1555 picon->set_text(name);
1556 vicon = picon->vicon;
1561 stop_vicon_drawing();
1562 vicon->clear_images();
1563 vicon->reset(indexable->get_frame_rate());
1564 start_vicon_drawing();
1568 void AWindowGUI::sort_assets(int use_mtime)
1570 folder_lock->lock("AWindowGUI::sort_assets");
1571 switch( mwindow->edl->session->awindow_folder ) {
1572 case AW_AEFFECT_FOLDER:
1573 sort_picons(&aeffects);
1575 case AW_VEFFECT_FOLDER:
1576 sort_picons(&veffects);
1578 case AW_ATRANSITION_FOLDER:
1579 sort_picons(&atransitions);
1581 case AW_VTRANSITION_FOLDER:
1582 sort_picons(&vtransitions);
1584 case AW_LABEL_FOLDER:
1585 sort_picons(&labellist);
1588 sort_picons(&assets, use_mtime);
1592 asset_list->update_format(asset_list->get_format(), 0);
1593 folder_lock->unlock();
1597 void AWindowGUI::sort_folders()
1599 folder_lock->lock("AWindowGUI::update_assets");
1600 sort_picons(&folders);
1601 folder_list->update_format(folder_list->get_format(), 0);
1602 folder_lock->unlock();
1606 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1608 Asset *proxy_asset = (Asset *)indexable;
1609 char path[BCTEXTLEN];
1610 int proxy_scale = mwindow->edl->session->proxy_scale;
1611 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1612 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1613 if( !unproxy_asset || !unproxy_asset->channels ) return 0;
1614 // make a clip from proxy video tracks and unproxy audio tracks
1615 EDL *proxy_edl = new EDL(mwindow->edl);
1616 proxy_edl->create_objects();
1617 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1618 proxy_edl->set_path(path);
1619 strcpy(proxy_edl->local_session->clip_title, path);
1620 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1621 proxy_edl->session->video_tracks = proxy_asset->layers;
1622 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1623 proxy_edl->create_default_tracks();
1624 double length = proxy_asset->frame_rate > 0 ?
1625 (double)proxy_asset->video_length / proxy_asset->frame_rate :
1626 1.0 / mwindow->edl->session->frame_rate;
1627 Track *current = proxy_edl->tracks->first;
1628 for( int vtrack=0; current; current=NEXT ) {
1629 if( current->data_type != TRACK_VIDEO ) continue;
1630 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1632 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1633 current = proxy_edl->tracks->first;
1634 for( int atrack=0; current; current=NEXT ) {
1635 if( current->data_type != TRACK_AUDIO ) continue;
1636 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1642 void AWindowGUI::collect_assets(int proxy)
1644 mwindow->session->drag_assets->remove_all();
1645 mwindow->session->drag_clips->remove_all();
1646 mwindow->session->clear_drag_proxy();
1647 int i = 0; AssetPicon *result;
1648 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1649 Indexable *indexable = result->indexable; EDL *drag_edl;
1650 if( proxy && (drag_edl=collect_proxy(indexable)) ) {
1651 mwindow->session->drag_clips->append(drag_edl);
1652 mwindow->session->drag_proxy->append(drag_edl);
1656 mwindow->session->drag_assets->append(indexable);
1660 mwindow->session->drag_clips->append(result->edl);
1666 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
1667 ArrayList<BC_ListBoxItem*> *src, int folder)
1669 // Remove current pointers
1670 dst[0].remove_all();
1671 dst[1].remove_all_objects();
1673 // Create new pointers
1674 for( int i = 0; i < src->total; i++ ) {
1675 AssetPicon *picon = (AssetPicon*)src->values[i];
1677 (picon->indexable && picon->indexable->awindow_folder == folder) ||
1678 (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
1679 const char *text = search_text->get_text();
1680 int hidden = text && text[0] && !bstrcasestr(picon->get_text(), text);
1681 if( picon->vicon ) picon->vicon->hidden = hidden;
1682 if( hidden ) continue;
1683 BC_ListBoxItem *item2, *item1;
1684 dst[0].append(item1 = picon);
1686 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
1689 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
1690 else if( picon->mtime ) {
1691 char date_time[BCSTRLEN];
1692 struct tm stm; localtime_r(&picon->mtime, &stm);
1693 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
1694 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
1695 stm.tm_hour, stm.tm_min, stm.tm_sec);
1696 dst[1].append(item2 = new BC_ListBoxItem(date_time));
1699 dst[1].append(item2 = new BC_ListBoxItem(""));
1700 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
1701 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
1706 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, int use_mtime)
1708 int done = 0, changed = 0;
1711 for( int i=0; i<src->total-1; ++i ) {
1712 AssetPicon *item1 = (AssetPicon *)src->values[i];
1713 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
1714 if( use_mtime ? item1->mtime > item2->mtime :
1715 strcmp(item1->get_text(), item2->get_text()) > 0 ) {
1716 src->values[i + 1] = item1;
1717 src->values[i] = item2;
1718 done = 0; changed = 1;
1723 for( int i=0; i<src->total; ++i ) {
1724 AssetPicon *item = (AssetPicon *)src->values[i];
1725 item->set_autoplace_icon(1);
1726 item->set_autoplace_text(1);
1732 void AWindowGUI::filter_displayed_assets()
1734 //allow_iconlisting = 1;
1735 asset_titles[0] = C_("Title");
1736 asset_titles[1] = _("Comments");
1738 switch( mwindow->edl->session->awindow_folder ) {
1739 case AW_AEFFECT_FOLDER:
1740 copy_picons(displayed_assets, &aeffects, AW_NO_FOLDER);
1742 case AW_VEFFECT_FOLDER:
1743 copy_picons(displayed_assets, &veffects, AW_NO_FOLDER);
1745 case AW_ATRANSITION_FOLDER:
1746 copy_picons(displayed_assets, &atransitions, AW_NO_FOLDER);
1748 case AW_VTRANSITION_FOLDER:
1749 copy_picons(displayed_assets, &vtransitions, AW_NO_FOLDER);
1751 case AW_LABEL_FOLDER:
1752 copy_picons(displayed_assets, &labellist, AW_NO_FOLDER);
1753 asset_titles[0] = _("Time Stamps");
1754 asset_titles[1] = C_("Title");
1755 //allow_iconlisting = 0;
1758 copy_picons(displayed_assets, &assets, mwindow->edl->session->awindow_folder);
1762 // Ensure the current folder icon is highlighted
1763 int selected_folder = mwindow->edl->session->awindow_folder;
1764 for( int i = 0; i < folders.total; i++ ) {
1765 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
1766 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
1767 folder_item->set_selected(selected);
1772 void AWindowGUI::update_assets()
1774 stop_vicon_drawing();
1775 folder_lock->lock("AWindowGUI::update_assets");
1776 update_folder_list();
1777 update_asset_list();
1778 labellist.remove_all_objects();
1779 create_label_folder();
1781 if( displayed_folder != mwindow->edl->session->awindow_folder )
1782 search_text->clear();
1783 filter_displayed_assets();
1784 folder_lock->unlock();
1786 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
1787 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
1789 int folder_xposition = folder_list->get_xposition();
1790 int folder_yposition = folder_list->get_yposition();
1791 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
1793 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
1794 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
1796 int x1 = asset_list->get_w();
1797 int y0 = asset_list->get_title_h();
1798 int y1 = asset_list->get_h();
1799 vicon_thread->set_drawing_area(x0,y0, x1,y1);
1801 int asset_xposition = asset_list->get_xposition();
1802 int asset_yposition = asset_list->get_yposition();
1803 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
1804 displayed_folder = mwindow->edl->session->awindow_folder;
1805 asset_xposition = asset_yposition = 0;
1807 asset_list->update(displayed_assets, asset_titles,
1808 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
1809 asset_xposition, asset_yposition, -1, 0);
1810 asset_list->center_selection();
1813 start_vicon_drawing();
1817 void AWindowGUI::update_effects()
1819 aeffects.remove_all_objects();
1820 create_persistent_folder(&aeffects, 1, 0, 1, 0);
1821 veffects.remove_all_objects();
1822 create_persistent_folder(&veffects, 0, 1, 1, 0);
1823 atransitions.remove_all_objects();
1824 create_persistent_folder(&atransitions, 1, 0, 0, 1);
1825 vtransitions.remove_all_objects();
1826 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
1829 int AWindowGUI::folder_number(const char *name)
1831 for( int i = 0; i < AWINDOW_FOLDERS; i++ ) {
1832 if( !strcasecmp(name, folder_names[i]) ) return i;
1834 return AW_NO_FOLDER;
1837 int AWindowGUI::drag_motion()
1839 if( get_hidden() ) return 0;
1845 int AWindowGUI::drag_stop()
1847 if( get_hidden() ) return 0;
1851 Indexable* AWindowGUI::selected_asset()
1853 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1854 return picon ? picon->indexable : 0;
1857 PluginServer* AWindowGUI::selected_plugin()
1859 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
1860 return picon ? picon->plugin : 0;
1863 AssetPicon* AWindowGUI::selected_folder()
1865 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
1876 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1877 : BC_SubWindow(x, y, w, h)
1879 this->mwindow = mwindow;
1882 AWindowDivider::~AWindowDivider()
1886 int AWindowDivider::button_press_event()
1888 if( is_event_win() && cursor_inside() ) {
1889 mwindow->session->current_operation = DRAG_PARTITION;
1895 int AWindowDivider::cursor_motion_event()
1897 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1899 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
1900 int fw = gui->get_relative_cursor_x();
1901 if( fw > wmax ) fw = wmax;
1902 if( fw < wmin ) fw = wmin;
1903 mwindow->session->afolders_w = fw;
1904 mwindow->theme->get_awindow_sizes(gui);
1905 gui->reposition_objects();
1911 int AWindowDivider::button_release_event()
1913 if( mwindow->session->current_operation == DRAG_PARTITION ) {
1914 mwindow->session->current_operation = NO_OPERATION;
1925 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1926 : BC_ListBox(x, y, w, h,
1927 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
1928 LISTBOX_ICONS : LISTBOX_TEXT,
1929 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
1930 0, // Titles for columns. Set to 0 for no titles
1931 0, // width of each column
1932 1, // Total columns.
1933 0, // Pixel of top of window.
1934 0, // If this listbox is a popup window
1935 LISTBOX_SINGLE, // Select one item or multiple items
1936 ICON_TOP, // Position of icon relative to text of each item
1939 this->mwindow = mwindow;
1944 AWindowFolders::~AWindowFolders()
1948 int AWindowFolders::selection_changed()
1950 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
1952 gui->stop_vicon_drawing();
1954 if( get_button_down() && get_buttonpress() == 3 ) {
1955 gui->folderlist_menu->update_titles();
1956 gui->folderlist_menu->activate_menu();
1959 mwindow->edl->session->awindow_folder = picon->foldernum;
1960 gui->asset_list->draw_background();
1961 gui->async_update_assets();
1963 gui->start_vicon_drawing();
1968 int AWindowFolders::button_press_event()
1972 result = BC_ListBox::button_press_event();
1975 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
1976 gui->folderlist_menu->update_titles();
1977 gui->folderlist_menu->activate_menu();
1992 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1993 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
1994 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
1995 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
1996 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
1998 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
1999 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2000 mwindow->edl->session->asset_columns, // width of each column
2001 1, // Total columns.
2002 0, // Pixel of top of window.
2003 0, // If this listbox is a popup window
2004 LISTBOX_MULTIPLE, // Select one item or multiple items
2005 ICON_TOP, // Position of icon relative to text of each item
2006 -1) // Allow drags, require shift for scrolling
2008 this->mwindow = mwindow;
2011 set_scroll_stretch(1, 1);
2014 AWindowAssets::~AWindowAssets()
2018 int AWindowAssets::button_press_event()
2022 result = BC_ListBox::button_press_event();
2024 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2025 BC_ListBox::deactivate_selection();
2026 int folder = mwindow->edl->session->awindow_folder;
2028 case AW_AEFFECT_FOLDER:
2029 case AW_VEFFECT_FOLDER:
2030 case AW_ATRANSITION_FOLDER:
2031 case AW_VTRANSITION_FOLDER:
2032 gui->effectlist_menu->update();
2033 gui->effectlist_menu->activate_menu();
2035 case AW_LABEL_FOLDER:
2036 gui->labellist_menu->update();
2037 gui->labellist_menu->activate_menu();
2039 case AW_CLIP_FOLDER:
2040 gui->cliplist_menu->update();
2041 gui->cliplist_menu->activate_menu();
2043 case AW_PROXY_FOLDER:
2044 gui->proxylist_menu->update();
2045 gui->proxylist_menu->activate_menu();
2047 case AW_MEDIA_FOLDER:
2048 gui->assetlist_menu->update_titles(folder==AW_MEDIA_FOLDER);
2049 gui->assetlist_menu->activate_menu();
2059 int AWindowAssets::handle_event()
2061 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2062 if( !asset_picon ) return 0;
2063 Indexable *picon_idxbl = asset_picon->indexable;
2064 EDL *picon_edl = asset_picon->edl;
2066 VWindow *vwindow = 0;
2067 switch( mwindow->edl->session->awindow_folder ) {
2068 case AW_AEFFECT_FOLDER:
2069 case AW_VEFFECT_FOLDER:
2070 case AW_ATRANSITION_FOLDER:
2071 case AW_VTRANSITION_FOLDER: return 1;
2072 case AW_PROXY_FOLDER:
2073 proxy = 1; // fall thru
2075 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2076 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2079 if( !vwindow || !vwindow->is_running() ) return 1;
2080 if( proxy && picon_idxbl ) {
2081 picon_edl = gui->collect_proxy(picon_idxbl);
2085 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2086 else if( picon_edl ) vwindow->change_source(picon_edl);
2090 int AWindowAssets::selection_changed()
2092 // Show popup window
2094 if( get_button_down() && get_buttonpress() == 3 &&
2095 (item = (AssetPicon*)get_selection(0, 0)) ) {
2096 int folder = mwindow->edl->session->awindow_folder;
2098 case AW_AEFFECT_FOLDER:
2099 case AW_VEFFECT_FOLDER:
2100 case AW_ATRANSITION_FOLDER:
2101 case AW_VTRANSITION_FOLDER:
2102 gui->effectlist_menu->update();
2103 gui->effectlist_menu->activate_menu();
2105 case AW_LABEL_FOLDER:
2106 if( !item->label ) break;
2107 gui->label_menu->activate_menu();
2109 case AW_CLIP_FOLDER:
2110 if( !item->indexable && !item->edl ) break;
2111 gui->clip_menu->update();
2112 gui->clip_menu->activate_menu();
2114 case AW_PROXY_FOLDER:
2115 if( !item->indexable && !item->edl ) break;
2116 gui->proxy_menu->update();
2117 gui->proxy_menu->activate_menu();
2120 if( !item->indexable && !item->edl ) break;
2121 gui->asset_menu->update();
2122 gui->asset_menu->activate_menu();
2126 BC_ListBox::deactivate_selection();
2129 else if( gui->vicon_drawing &&
2130 get_button_down() && get_buttonpress() == 1 &&
2131 (item = (AssetPicon*)get_selection(0, 0)) ) {
2133 if( !gui->vicon_thread->viewing ) {
2134 vicon = item->vicon;
2136 gui->vicon_thread->set_view_popup(vicon);
2142 void AWindowAssets::draw_background()
2144 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2145 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2146 set_font(LARGEFONT);
2147 int aw_folder = mwindow->edl->session->awindow_folder;
2148 if( aw_folder < 0 ) return;
2149 const char *aw_name = _(AWindowGUI::folder_names[aw_folder]);
2150 draw_text(get_w() - get_text_width(LARGEFONT, aw_name) - 4, 30,
2151 aw_name, -1, get_bg_surface());
2154 int AWindowAssets::drag_start_event()
2156 int collect_pluginservers = 0;
2157 int collect_assets = 0, proxy = 0;
2159 if( BC_ListBox::drag_start_event() ) {
2160 switch( mwindow->edl->session->awindow_folder ) {
2161 case AW_AEFFECT_FOLDER:
2162 mwindow->session->current_operation = DRAG_AEFFECT;
2163 collect_pluginservers = 1;
2165 case AW_VEFFECT_FOLDER:
2166 mwindow->session->current_operation = DRAG_VEFFECT;
2167 collect_pluginservers = 1;
2169 case AW_ATRANSITION_FOLDER:
2170 mwindow->session->current_operation = DRAG_ATRANSITION;
2171 collect_pluginservers = 1;
2173 case AW_VTRANSITION_FOLDER:
2174 mwindow->session->current_operation = DRAG_VTRANSITION;
2175 collect_pluginservers = 1;
2177 case AW_LABEL_FOLDER:
2180 case AW_PROXY_FOLDER:
2183 case AW_MEDIA_FOLDER:
2185 mwindow->session->current_operation = DRAG_ASSET;
2190 if( collect_pluginservers ) {
2192 mwindow->session->drag_pluginservers->remove_all();
2195 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2196 if( !result ) break;
2198 mwindow->session->drag_pluginservers->append(result->plugin);
2202 if( collect_assets ) {
2203 gui->collect_assets(proxy);
2211 int AWindowAssets::drag_motion_event()
2213 BC_ListBox::drag_motion_event();
2216 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2217 mwindow->gui->drag_motion();
2218 mwindow->gui->unlock_window();
2220 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2221 VWindow *vwindow = mwindow->vwindows.get(i);
2222 if( !vwindow->is_running() ) continue;
2223 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2224 vwindow->gui->drag_motion();
2225 vwindow->gui->unlock_window();
2228 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2229 mwindow->cwindow->gui->drag_motion();
2230 mwindow->cwindow->gui->unlock_window();
2232 lock_window("AWindowAssets::drag_motion_event");
2236 int AWindowAssets::drag_stop_event()
2240 result = gui->drag_stop();
2245 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2246 result = mwindow->gui->drag_stop();
2247 mwindow->gui->unlock_window();
2251 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2252 VWindow *vwindow = mwindow->vwindows.get(i);
2253 if( !vwindow ) continue;
2254 if( !vwindow->is_running() ) continue;
2255 if( vwindow->gui->is_hidden() ) continue;
2256 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2257 if( vwindow->gui->cursor_above() &&
2258 vwindow->gui->get_cursor_over_window() ) {
2259 result = vwindow->gui->drag_stop();
2261 vwindow->gui->unlock_window();
2266 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2267 result = mwindow->cwindow->gui->drag_stop();
2268 mwindow->cwindow->gui->unlock_window();
2271 lock_window("AWindowAssets::drag_stop_event");
2274 get_drag_popup()->set_animation(0);
2276 BC_ListBox::drag_stop_event();
2277 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2278 mwindow->session->current_operation = ::NO_OPERATION;
2279 mwindow->session->clear_drag_proxy();
2284 int AWindowAssets::column_resize_event()
2286 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2287 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2291 int AWindowAssets::focus_in_event()
2293 gui->start_vicon_drawing();
2297 int AWindowAssets::focus_out_event()
2299 gui->stop_vicon_drawing();
2300 return BC_ListBox::focus_out_event();
2303 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2304 : BC_TextBox(x, y, w, 1, "")
2306 this->search_text = search_text;
2309 int AWindowSearchTextBox::handle_event()
2311 return search_text->handle_event();
2314 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2316 this->mwindow = mwindow;
2322 void AWindowSearchText::create_objects()
2324 int x1 = x, y1 = y, margin = 10;
2325 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2326 x1 += text_title->get_w() + margin;
2327 int w1 = gui->get_w() - x1 - 2*margin;
2328 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2331 int AWindowSearchText::handle_event()
2333 gui->async_update_assets();
2337 int AWindowSearchText::get_w()
2339 return text_box->get_w() + text_title->get_w() + 10;
2342 int AWindowSearchText::get_h()
2344 return bmax(text_box->get_h(),text_title->get_h());
2347 void AWindowSearchText::reposition_window(int x, int y, int w)
2349 int x1 = x, y1 = y, margin = 10;
2350 text_title->reposition_window(x1, y1);
2351 x1 += text_title->get_w() + margin;
2352 int w1 = gui->get_w() - x1 - 2*margin;
2353 text_box->reposition_window(x1, y1, w1);
2356 const char *AWindowSearchText::get_text()
2358 return text_box->get_text();
2361 void AWindowSearchText::clear()
2363 text_box->update("");
2366 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2367 : BC_Button(x, y, mwindow->theme->newbin_data)
2369 this->mwindow = mwindow;
2371 set_tooltip(_("New bin"));
2374 int AWindowNewFolder::handle_event()
2376 gui->newfolder_thread->start_new_folder();
2380 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2381 : BC_Button(x, y, mwindow->theme->deletebin_data)
2383 this->mwindow = mwindow;
2385 set_tooltip(_("Delete bin"));
2388 int AWindowDeleteFolder::handle_event()
2390 if( gui->folder_list->get_selection(0, 0) ) {
2391 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
2392 mwindow->delete_folder(folder->get_text());
2397 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2398 : BC_Button(x, y, mwindow->theme->renamebin_data)
2400 this->mwindow = mwindow;
2402 set_tooltip(_("Rename bin"));
2405 int AWindowRenameFolder::handle_event()
2410 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2411 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2413 this->mwindow = mwindow;
2415 set_tooltip(_("Delete asset from disk"));
2418 int AWindowDeleteDisk::handle_event()
2423 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2424 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2426 this->mwindow = mwindow;
2428 set_tooltip(_("Delete asset from project"));
2431 int AWindowDeleteProject::handle_event()
2436 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2437 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2439 // this->mwindow = mwindow;
2441 // set_tooltip(_("Edit information on asset"));
2444 // int AWindowInfo::handle_event()
2446 // int cur_x, cur_y;
2447 // gui->get_abs_cursor(cur_x, cur_y, 0);
2448 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2452 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2453 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2455 this->mwindow = mwindow;
2457 set_tooltip(_("Redraw index"));
2460 int AWindowRedrawIndex::handle_event()
2465 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2466 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2468 this->mwindow = mwindow;
2470 set_tooltip(_("Paste asset on recordable tracks"));
2473 int AWindowPaste::handle_event()
2478 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2479 : BC_Button(x, y, mwindow->theme->appendasset_data)
2481 this->mwindow = mwindow;
2483 set_tooltip(_("Append asset in new tracks"));
2486 int AWindowAppend::handle_event()
2491 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2492 : BC_Button(x, y, mwindow->theme->viewasset_data)
2494 this->mwindow = mwindow;
2496 set_tooltip(_("View asset"));
2499 int AWindowView::handle_event()
2504 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
2505 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
2507 this->mwindow = mwindow;
2511 void AddTools::create_objects()
2514 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
2515 vis |= 1 << PLUGIN_FFMPEG_ID;
2516 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
2517 vis |= 1 << PLUGIN_LADSPA_ID;
2519 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
2520 vis |= 1 << PLUGIN_LV2_ID;
2522 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
2523 PluginServer *plugin = MWindow::plugindb->get(i);
2524 if( !plugin->audio && !plugin->video ) continue;
2525 int idx = plugin->dir_idx;
2526 uint32_t msk = 1 << idx;
2527 if( (msk & vis) != 0 ) continue;
2529 char parent[BCTEXTLEN];
2530 strcpy(parent, plugin->path);
2531 char *bp = strrchr(parent, '/');
2532 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
2533 if( !bp ) bp = parent; else ++bp;
2534 add_item(new AddPluginItem(this, bp, idx));
2539 // plugin_dirs list from toplevel makefile include plugin_defs
2544 N_("audio_transitions")
2551 N_("video_transitions")
2554 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
2555 : BC_MenuItem(_(text))
2559 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2560 int chk = (msk & vis) ? 1 : 0;
2564 int AddPluginItem::handle_event()
2566 int chk = get_checked() ^ 1;
2568 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
2569 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
2570 menu->gui->update_effects();
2571 menu->gui->save_defaults(menu->mwindow->defaults);
2572 menu->gui->async_update_assets();
2576 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
2577 : BC_Toggle(x, y, images, agui->vicon_drawing)
2580 set_tooltip(_("draw vicons"));
2583 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
2585 int text_line = -1, toggle_x = -1, toggle_y = -1;
2586 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
2587 BC_Toggle::calculate_extents(agui, images, 1,
2588 &text_line, ww, hh, &toggle_x, &toggle_y,
2589 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
2592 AVIconDrawing::~AVIconDrawing()
2596 int AVIconDrawing::handle_event()
2598 agui->vicon_drawing = get_value();
2599 if( agui->vicon_drawing )
2600 agui->start_vicon_drawing();
2602 agui->stop_vicon_drawing();
2607 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
2610 this->mwindow = mwindow;
2614 int AWindowListFormat::handle_event()
2616 gui->stop_vicon_drawing();
2618 EDLSession *session = mwindow->edl->session;
2619 if( mwindow->awindow->gui->allow_iconlisting ) {
2620 switch( session->assetlist_format ) {
2622 session->assetlist_format = ASSETS_ICONS;
2625 session->assetlist_format = ASSETS_ICONS_PACKED;
2627 case ASSETS_ICONS_PACKED:
2628 session->assetlist_format = ASSETS_ICON_LIST;
2630 case ASSETS_ICON_LIST:
2631 session->assetlist_format = ASSETS_TEXT;
2636 mwindow->edl->session->assetlist_format = ASSETS_TEXT;
2637 gui->asset_list->update_format(session->assetlist_format, 0);
2639 int x1 = gui->asset_list->get_w();
2640 int y0 = gui->asset_list->get_title_h();
2641 int y1 = gui->asset_list->get_h();
2642 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2644 gui->async_update_assets();
2645 gui->start_vicon_drawing();
2649 void AWindowListFormat::update()
2651 EDLSession *session = mwindow->edl->session;
2652 const char *text = 0;
2653 switch( session->assetlist_format ) {
2655 text = _("Display icons");
2658 text = _("Display icons packed");
2660 case ASSETS_ICONS_PACKED:
2661 text = _("Display icon list");
2663 case ASSETS_ICON_LIST:
2664 text = _("Display text");
2670 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
2671 : BC_MenuItem(_("Sort items"))
2673 this->mwindow = mwindow;
2677 int AWindowListSort::handle_event()
2679 gui->sort_assets(0);