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"
26 #include "assetremove.h"
28 #include "audiodevice.h"
30 #include "awindowgui.h"
31 #include "bccmodels.h"
32 #include "bcsignals.h"
34 #include "binfolder.h"
39 #include "clippopup.h"
41 #include "cwindowgui.h"
46 #include "edlsession.h"
47 #include "effectlist.h"
49 #include "filesystem.h"
50 #include "folderlistmenu.h"
51 #include "indexable.h"
55 #include "labelpopup.h"
56 #include "localsession.h"
58 #include "mainsession.h"
59 #include "mwindowgui.h"
61 #include "preferences.h"
63 #include "proxypopup.h"
64 #include "renderengine.h"
69 #include "transportque.h"
73 #include "vwindowgui.h"
76 #include "data/lad_picon_png.h"
77 #include "data/ff_audio_png.h"
78 #include "data/ff_video_png.h"
85 const char *AWindowGUI::folder_names[] =
89 N_("Audio Transitions"),
90 N_("Video Transitions"),
98 AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
99 : VIcon(w, h, framerate), Garbage("AssetVIcon")
102 this->length = length;
106 AssetVIcon::~AssetVIcon()
108 picon->gui->vicon_thread->del_vicon(this);
112 VFrame *AssetVIcon::frame()
114 Asset *asset = (Asset *)picon->indexable;
115 if( !asset->video_data && audio_data && audio_size && length > 0 ) {
116 if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1);
118 int sample_rate = asset->get_sample_rate();
119 int64_t audio_samples = asset->get_audio_samples();
120 double duration = (double)audio_samples / sample_rate;
121 picon->draw_hue_bar(temp, duration);
122 int secs = length / frame_rate + 0.5;
123 if( !secs ) secs = 1;
124 int bfrsz = VICON_SAMPLE_RATE;
125 int samples = audio_size/sizeof(vicon_audio_t);
126 double line_pos = (double)seq_no/(length-1);
127 int audio_pos = samples * line_pos * (secs-1)/secs;
128 vicon_audio_t *audio_data = ((vicon_audio_t *)this->audio_data) + audio_pos;
129 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
130 double data[bfrsz], sample_scale = 1./mx;
131 int len = samples - audio_pos;
132 if( len > bfrsz ) len = bfrsz;
134 while( i < len ) data[i++] = *audio_data++ * sample_scale;
135 while( i < bfrsz ) data[i++] = 0;
136 picon->draw_wave(temp, data, bfrsz, RED, GREEN);
137 int x = (vw-1) * line_pos;
138 temp->pixel_rgb = RED;
139 temp->draw_line(x,0, x,vh);
142 int ww = picon->gui->vicon_thread->view_w;
143 int hh = picon->gui->vicon_thread->view_h;
144 if( !asset->video_data ) {
146 temp = new VFrame(0, -1, ww, hh, BC_RGB888, -1);
151 if( seq_no >= images.size() ) {
152 MWindow *mwindow = picon->mwindow;
153 File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
154 if( !file ) return 0;
155 if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
156 delete temp; temp = 0;
159 temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1);
160 while( seq_no >= images.size() ) {
161 mwindow->video_cache->check_in(asset);
163 file = mwindow->video_cache->check_out(asset, mwindow->edl, 0);
164 if( !file ) { usleep(1000); continue; }
166 int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
167 file->set_video_position(pos,0);
168 if( file->read_frame(temp) ) temp->clear_frame();
169 add_image(temp, ww, hh, BC_RGB8);
171 mwindow->video_cache->check_in(asset);
173 return *images[seq_no];
176 int64_t AssetVIcon::set_seq_no(int64_t no)
178 if( no >= length ) no = 0;
182 int AssetVIcon::get_vx()
184 BC_ListBox *lbox = picon->gui->asset_list;
185 return lbox->get_icon_x(picon);
187 int AssetVIcon::get_vy()
189 BC_ListBox *lbox = picon->gui->asset_list;
190 return lbox->get_icon_y(picon);
193 void AssetVIcon::load_audio()
195 MWindow *mwindow = picon->mwindow;
196 Asset *asset = (Asset *)picon->indexable;
197 File *file = mwindow->audio_cache->check_out(asset, mwindow->edl, 1);
198 int channels = asset->get_audio_channels();
199 if( channels > 2 ) channels = 2;
200 int sample_rate = asset->get_sample_rate();
201 int bfrsz = sample_rate;
202 Samples samples(bfrsz);
203 double time_scale = (double)sample_rate / VICON_SAMPLE_RATE;
204 vicon_audio_t *audio_data = (vicon_audio_t *)this->audio_data;
205 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
206 double sample_scale = (double)mx / channels;
207 int audio_pos = 0, audio_len = audio_size/sizeof(vicon_audio_t);
208 while( audio_pos < audio_len ) {
209 int64_t pos = audio_pos * time_scale;
210 for( int ch=0; ch<channels; ++ch ) {
211 file->set_channel(ch);
212 file->set_audio_position(pos);
213 file->read_samples(&samples, bfrsz);
214 double *data = samples.get_data();
215 for( int64_t k=audio_pos; k<audio_len; ++k ) {
216 int i = k * time_scale - pos;
217 if( i >= bfrsz ) break;
218 int v = audio_data[k] + data[i] * sample_scale;
219 audio_data[k] = CLIP(v, -mx,mx);
222 audio_pos = (pos + bfrsz) / time_scale;
224 mwindow->audio_cache->check_in(asset);
228 AssetVIconAudio::AssetVIconAudio(AWindowGUI *gui)
232 audio = new AudioDevice(gui->mwindow);
236 AssetVIconAudio::~AssetVIconAudio()
241 void AssetVIconAudio::run()
244 int64_t bfrsz = VICON_SAMPLE_RATE;
245 MWindow *mwindow = gui->mwindow;
246 EDL *edl = mwindow->edl;
247 EDLSession *session = edl->session;
248 AudioOutConfig *aconfig = session->playback_config->aconfig;
249 audio->open_output(aconfig, VICON_SAMPLE_RATE, bfrsz, channels, 0);
250 audio->start_playback();
251 double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
252 vicon_audio_t *audio_data = (vicon_audio_t *)vicon->audio_data;
253 static const int mx = (1<<(8*sizeof(*audio_data)-1)) - 1;
255 int audio_len = vicon->audio_size/sizeof(vicon_audio_t);
256 while( !interrupted ) {
257 int len = audio_len - audio_pos;
258 if( len <= 0 ) break;
259 if( len > bfrsz ) len = bfrsz;
261 for( int i=0; i<len; ++i,++k )
262 out0[i] = out1[i] = (double)audio_data[k] / mx;
264 audio->write_buffer(out, channels, len);
268 audio->set_last_buffer();
269 audio->stop_audio(interrupted ? 0 : 1);
273 void AssetVIconAudio::start(AssetVIcon *vicon)
275 if( running() ) return;
282 void AssetVIconAudio::stop(int wait)
284 if( running() && !interrupted ) {
286 audio->stop_audio(wait);
290 vicon->playing_audio = 0;
295 void AssetVIcon::start_audio()
297 if( playing_audio < 0 ) return;
298 picon->gui->vicon_audio->stop(0);
300 picon->gui->vicon_audio->start(this);
303 void AssetVIcon::stop_audio()
305 if( playing_audio > 0 )
306 picon->gui->vicon_audio->stop(0);
311 AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list)
312 : VIconThread(asset_list)
317 AssetVIconThread::~AssetVIconThread()
321 int AssetVIconThread::popup_button_press(int x, int y)
323 if( !view_win || !view_win->is_event_win() ) return 0;
324 if( !vicon || vicon->playing_audio >= 0 ) return 0;
326 int view_w = view_win->get_w(), view_h = view_win->get_h();
327 AssetVIcon *vicon = (AssetVIcon *)this->vicon;
328 AssetPicon *picon = vicon->picon;
329 MWindow *mwindow = picon->mwindow;
330 EDL *edl = mwindow->edl;
331 if( y < VIEW_POPUP_BAR_H ) {
333 picon->indexable ? picon->indexable :
334 picon->edl ? picon->edl : 0;
335 if( !idxbl ) return 0;
336 double sample_rate = idxbl->get_sample_rate();
337 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
338 idxbl->get_audio_samples() / sample_rate : 0;
339 double frame_rate = idxbl->get_frame_rate();
340 double video_length = frame_rate > 0 && idxbl->have_video() ?
341 idxbl->get_video_frames() / frame_rate : 0;
342 double idxbl_length = bmax(audio_length, video_length);
343 double pos = x * idxbl_length / view_w;
344 double start = 0, end = idxbl_length;
345 double lt = DBL_MAX, rt = DBL_MAX;
346 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
347 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
348 Indexable *indexable = (Indexable *)edit->asset;
349 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
350 if( !indexable ) continue;
351 if( indexable->id == idxbl->id ||
352 (!indexable->is_asset == !idxbl->is_asset &&
353 !strcmp(indexable->path, idxbl->path)) ) {
354 double start_pos = track->from_units(edit->startsource);
355 double end_pos = track->from_units(edit->startsource + edit->length);
356 double dlt = pos - start_pos, drt = end_pos - pos;
357 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
358 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
359 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
360 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
364 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
365 VWindow *vwindow = mwindow->get_viewer(1, 0);
366 vwindow->change_source(idxbl);
367 mwindow->gui->unlock_window();
368 EDL *vedl = vwindow->get_edl();
369 vedl->set_inpoint(start);
370 vedl->set_outpoint(end);
371 vedl->local_session->set_selectionstart(start);
372 vedl->local_session->set_selectionend(end);
373 vwindow->update_position(CHANGE_NONE, 0, 1, 0);
376 if( y >= view_h-VIEW_POPUP_BAR_H ) {
378 if( !view_win->ctrl_down() )
379 return popup_cursor_motion(x, y);
381 picon->indexable ? picon->indexable :
382 picon->edl ? picon->edl : 0;
383 if( !idxbl ) return 0;
384 double total_length = mwindow->edl->tracks->total_length();
385 double pos = x * total_length / view_w;
386 double start = 0, end = total_length;
387 double lt = DBL_MAX, rt = DBL_MAX;
388 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
389 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
390 Indexable *indexable = (Indexable *)edit->asset;
391 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
392 if( !indexable ) continue;
393 if( indexable->id == idxbl->id ||
394 (!indexable->is_asset == !idxbl->is_asset &&
395 !strcmp(indexable->path, idxbl->path)) ) {
396 double start_pos = track->from_units(edit->startproject);
397 double end_pos = track->from_units(edit->startproject + edit->length);
398 double dlt = pos - start_pos, drt = end_pos - pos;
399 if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
400 else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
401 if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
402 else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
406 mwindow->gui->lock_window("AssetVIcon::popup_button_press");
407 edl->local_session->set_selectionstart(pos);
408 edl->local_session->set_selectionend(pos);
409 mwindow->find_cursor();
410 edl->local_session->set_selectionstart(start);
411 edl->local_session->set_selectionend(end);
412 mwindow->zoom_sample(edl->local_session->zoom_sample);
413 mwindow->gui->unlock_window();
419 int AssetVIconThread::popup_button_release(int x, int y)
421 if( !view_win || !view_win->is_event_win() ) return 0;
422 if( !vicon || vicon->playing_audio >= 0 ) return 0;
427 int AssetVIconThread::popup_cursor_motion(int x, int y)
429 if( !view_win || !view_win->is_event_win() ) return 0;
430 if( !vicon || vicon->playing_audio >= 0 ) return 0;
431 if( !view_win->get_button_down() || view_win->get_buttonpress() != 1 ||
432 view_win->ctrl_down() || view_win->alt_down() || view_win->shift_down() )
434 AssetVIcon *vicon = (AssetVIcon *)this->vicon;
435 MWindow *mwindow = vicon->picon->mwindow;
436 EDL *edl = mwindow->edl;
437 if( popup_dragging ) {
438 double total_length = edl->tracks->total_length();
439 int view_w = view_win->get_w();
440 double pos = x * total_length / view_w;
441 mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
442 mwindow->select_point(pos);
443 mwindow->zoom_sample(edl->local_session->zoom_sample);
444 mwindow->gui->unlock_window();
451 AWindowFolderItem::AWindowFolderItem()
457 AWindowFolderItem::AWindowFolderItem(const char *text, int color)
458 : BC_ListBoxItem(text, color)
463 AWindowFolderItem::AWindowFolderItem(const char *text, BC_Pixmap *icon, int color)
464 : BC_ListBoxItem(text, icon, color)
469 AssetPicon *AWindowFolderItem::get_picon()
471 AWindowFolderItem *item = this;
472 while( item->parent ) { item = (AWindowFolderItem*)item->parent; }
473 return (AssetPicon*)item;
476 int AWindowFolderSubItems::matches(const char *text)
478 int i = names.size();
479 while( --i >= 0 && strcmp(names[i], text) );
481 ArrayList<BC_ListBoxItem *> *sublist = get_sublist();
482 i = sublist ? sublist->size() : 0;
484 AWindowFolderSubItems *item = (AWindowFolderSubItems *)sublist->get(i);
485 if( item->matches(text) ) break;
488 return i >= 0 ? 1 : 0;
492 AssetPicon::AssetPicon(MWindow *mwindow,
493 AWindowGUI *gui, Indexable *indexable)
494 : AWindowFolderItem()
497 this->mwindow = mwindow;
499 this->indexable = indexable;
500 indexable->add_user();
501 this->id = indexable->id;
504 AssetPicon::AssetPicon(MWindow *mwindow,
505 AWindowGUI *gui, EDL *edl)
506 : AWindowFolderItem()
509 this->mwindow = mwindow;
516 AssetPicon::AssetPicon(MWindow *mwindow,
517 AWindowGUI *gui, int folder, int persist)
518 : AWindowFolderItem(_(AWindowGUI::folder_names[folder]),
519 folder>=0 && folder<AWINDOW_FOLDERS ?
520 gui->folder_icons[folder] : gui->folder_icon)
524 this->mwindow = mwindow;
526 persistent = persist;
529 AssetPicon::AssetPicon(MWindow *mwindow,
530 AWindowGUI *gui, int folder, const char *title)
531 : AWindowFolderItem(title, gui->folder_icon)
535 this->mwindow = mwindow;
540 AssetPicon::AssetPicon(MWindow *mwindow,
541 AWindowGUI *gui, PluginServer *plugin)
542 : AWindowFolderItem()
545 this->mwindow = mwindow;
547 this->plugin = plugin;
550 AssetPicon::AssetPicon(MWindow *mwindow,
551 AWindowGUI *gui, Label *label)
552 : AWindowFolderItem()
555 this->mwindow = mwindow;
563 AssetPicon::~AssetPicon()
565 if( vicon ) vicon->remove_user();
567 if( indexable ) indexable->remove_user();
568 if( edl ) edl->remove_user();
569 if( icon && !gui->protected_pixmap(icon) ) {
571 if( !plugin ) delete icon_vframe;
575 void AssetPicon::draw_hue_bar(VFrame *frame, double duration)
577 float t = duration > 1 ? (log(duration) / log(3600.f)) : 0;
579 float h = 300 * t, s = 1., v = 1.;
580 float r, g, b; // duration, 0..1hr == hue red..magenta
581 HSV::hsv_to_rgb(r,g,b, h,s,v);
582 int ih = frame->get_h()/8, iw = frame->get_w();
583 int ir = r * 256; CLAMP(ir, 0,255);
584 int ig = g * 256; CLAMP(ig, 0,255);
585 int ib = b * 256; CLAMP(ib, 0,255);
586 unsigned char **rows = frame->get_rows();
587 for( int y=0; y<ih; ++y ) {
588 unsigned char *rp = rows[y];
589 for( int x=0; x<iw; rp+=3,++x ) {
590 rp[0] = ir; rp[1] = ig; rp[2] = ib;
595 void AssetPicon::draw_wave(VFrame *frame, double *dp, int len,
596 int base_color, int line_color, int x, int y, int w, int h)
598 int h1 = h-1, h2 = h/2, iy = h2;
599 int rgb_color = frame->pixel_rgb;
600 for( int ix=0,x1=0,x2=0; ix<w; ++ix,x1=x2 ) {
601 double min = *dp, max = min;
602 x2 = (len * (ix+1))/w;
603 for( int i=x1; i<x2; ++i ) {
604 double value = *dp++;
605 if( value < min ) min = value;
606 if( value > max ) max = value;
608 int ctr = (min + max) / 2;
609 int y0 = (int)(h2 - ctr*h2); CLAMP(y0, 0,h1);
610 int y1 = (int)(h2 - min*h2); CLAMP(y1, 0,h1);
611 int y2 = (int)(h2 - max*h2); CLAMP(y2, 0,h1);
612 frame->pixel_rgb = line_color;
613 frame->draw_line(ix+x,y1+y, ix+x,y2+y);
614 frame->pixel_rgb = base_color;
615 frame->draw_line(ix+x,iy+y, ix+x,y0+y);
618 frame->pixel_rgb = rgb_color;
621 void AssetPicon::reset()
629 foldernum = AW_NO_FOLDER;
641 void AssetPicon::open_render_engine(EDL *edl, int is_audio)
643 TransportCommand command;
644 command.command = is_audio ? NORMAL_FWD : CURRENT_FRAME;
645 command.get_edl()->copy_all(edl);
646 command.change_type = CHANGE_ALL;
647 command.realtime = 0;
648 render_engine = new RenderEngine(0, mwindow->preferences, 0, 0);
649 render_engine->set_vcache(mwindow->video_cache);
650 render_engine->set_acache(mwindow->audio_cache);
651 render_engine->arm_command(&command);
653 void AssetPicon::close_render_engine()
655 delete render_engine; render_engine = 0;
657 void AssetPicon::render_video(int64_t pos, VFrame *vfrm)
659 if( !render_engine || !render_engine->vrender ) return;
660 render_engine->vrender->process_buffer(vfrm, pos, 0);
662 void AssetPicon::render_audio(int64_t pos, Samples **samples, int len)
664 if( !render_engine || !render_engine->arender ) return;
665 render_engine->arender->process_buffer(samples, len, pos);
668 void AssetPicon::create_objects()
671 char name[BCTEXTLEN];
672 int pixmap_w, pixmap_h;
674 pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
677 fs.extract_name(name, indexable->path);
681 set_text(strcpy(name, edl->local_session->clip_title));
685 if( indexable && indexable->is_asset ) {
686 Asset *asset = (Asset*)indexable;
687 if( asset->video_data ) {
688 if( mwindow->preferences->use_thumbnails ) {
689 gui->unlock_window();
690 File *file = mwindow->video_cache->check_out(asset,
695 int height = asset->height > 0 ? asset->height : 1;
696 pixmap_w = pixmap_h * asset->width / height;
699 file->set_video_position(0, 0);
701 if( gui->temp_picon &&
702 (gui->temp_picon->get_w() != asset->width ||
703 gui->temp_picon->get_h() != asset->height) ) {
704 delete gui->temp_picon;
708 if( !gui->temp_picon ) {
709 gui->temp_picon = new VFrame(0, -1,
710 asset->width, asset->height,
713 { char string[BCTEXTLEN];
714 sprintf(string, _("Reading %s"), name);
715 mwindow->gui->lock_window("AssetPicon::create_objects");
716 mwindow->gui->show_message(string);
717 mwindow->gui->unlock_window(); }
718 file->read_frame(gui->temp_picon);
719 mwindow->video_cache->check_in(asset);
721 gui->lock_window("AssetPicon::create_objects 0");
722 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
723 icon->draw_vframe(gui->temp_picon,
724 0, 0, pixmap_w, pixmap_h, 0, 0);
725 icon_vframe = new VFrame(0,
726 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
727 icon_vframe->transfer_from(gui->temp_picon);
728 if( asset->folder_no == AW_MEDIA_FOLDER ) {
730 double framerate = asset->get_frame_rate();
731 if( !framerate ) framerate = VICON_RATE;
732 int64_t frames = asset->get_video_frames();
733 double secs = frames / framerate;
734 if( secs > 5 ) secs = 5;
735 int64_t length = secs * gui->vicon_thread->refresh_rate;
736 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
737 if( asset->audio_data && secs > 0 ) {
738 gui->unlock_window();
739 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
740 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
742 gui->lock_window("AssetPicon::create_objects 1");
744 gui->vicon_thread->add_vicon(vicon);
746 else if( asset->folder_no == AW_PROXY_FOLDER ) {
747 char unproxy_path[BCTEXTLEN];
748 int proxy_scale = mwindow->edl->session->proxy_scale;
749 if( !ProxyRender::from_proxy_path(unproxy_path, asset, proxy_scale) ) {
750 Asset *unproxy = mwindow->edl->assets->get_asset(unproxy_path);
752 int i = gui->assets.total;
754 AssetPicon *picon = (AssetPicon*)gui->assets[i];
755 if( picon->id == unproxy->id ) {
756 vicon = picon->vicon;
757 if( vicon ) vicon->add_user();
767 gui->lock_window("AssetPicon::create_objects 2");
768 icon = gui->video_icon;
769 icon_vframe = gui->video_vframe;
773 icon = gui->video_icon;
774 icon_vframe = gui->video_vframe;
778 if( asset->audio_data ) {
779 if( mwindow->preferences->use_thumbnails ) {
780 gui->unlock_window();
781 File *file = mwindow->audio_cache->check_out(asset,
785 pixmap_w = pixmap_h * 16/9;
786 icon_vframe = new VFrame(0,
787 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
788 icon_vframe->clear_frame();
789 { char string[BCTEXTLEN];
790 sprintf(string, _("Reading %s"), name);
791 mwindow->gui->lock_window("AssetPicon::create_objects 3");
792 mwindow->gui->show_message(string);
793 mwindow->gui->unlock_window(); }
794 int sample_rate = asset->get_sample_rate();
795 int channels = asset->get_audio_channels();
796 if( channels > 2 ) channels = 2;
797 int64_t audio_samples = asset->get_audio_samples();
798 double duration = (double)audio_samples / sample_rate;
799 draw_hue_bar(icon_vframe, duration);
800 int bfrsz = sample_rate;
801 Samples samples(bfrsz);
802 static int line_colors[2] = { GREEN, YELLOW };
803 static int base_colors[2] = { RED, PINK };
804 for( int i=channels; --i>=0; ) {
805 file->set_channel(i);
806 file->set_audio_position(0);
807 file->read_samples(&samples, bfrsz);
808 draw_wave(icon_vframe, samples.get_data(), bfrsz,
809 base_colors[i], line_colors[i]);
811 mwindow->audio_cache->check_in(asset);
812 if( asset->folder_no == AW_MEDIA_FOLDER ) {
813 double secs = duration;
814 if( secs > 5 ) secs = 5;
815 double refresh_rate = gui->vicon_thread->refresh_rate;
816 int64_t length = secs * refresh_rate;
817 vicon = new AssetVIcon(this, pixmap_w, pixmap_h, refresh_rate, length);
818 int audio_len = VICON_SAMPLE_RATE*secs+0.5;
819 vicon->init_audio(audio_len*sizeof(vicon_audio_t));
821 gui->vicon_thread->add_vicon(vicon);
823 gui->lock_window("AssetPicon::create_objects 4");
824 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
825 icon->draw_vframe(icon_vframe,
826 0, 0, pixmap_w, pixmap_h, 0, 0);
829 gui->lock_window("AssetPicon::create_objects 5");
830 icon = gui->audio_icon;
831 icon_vframe = gui->audio_vframe;
835 icon = gui->audio_icon;
836 icon_vframe = gui->audio_vframe;
841 comments_time = !stat(asset->path, &st) ? st.st_mtime : 0;
844 if( indexable && !indexable->is_asset ) {
845 icon = gui->video_icon;
846 icon_vframe = gui->video_vframe;
850 if( edl->tracks->playable_video_tracks() ) {
851 if( mwindow->preferences->use_thumbnails ) {
852 gui->unlock_window();
853 char clip_icon_path[BCTEXTLEN];
854 char *clip_icon = edl->local_session->clip_icon;
856 snprintf(clip_icon_path, sizeof(clip_icon_path),
857 "%s/%s", File::get_config_path(), clip_icon);
858 icon_vframe = VFramePng::vframe_png(clip_icon_path);
861 //printf("render clip: %s\n", name);
862 int edl_h = edl->get_h(), edl_w = edl->get_w();
863 int height = edl_h > 0 ? edl_h : 1;
864 int width = edl_w > 0 ? edl_w : 1;
865 int color_model = edl->session->color_model;
866 pixmap_w = pixmap_h * width / height;
868 if( gui->temp_picon &&
869 (gui->temp_picon->get_color_model() != color_model ||
870 gui->temp_picon->get_w() != width ||
871 gui->temp_picon->get_h() != height) ) {
872 delete gui->temp_picon; gui->temp_picon = 0;
875 if( !gui->temp_picon ) {
876 gui->temp_picon = new VFrame(0, -1,
877 width, height, color_model, -1);
879 char string[BCTEXTLEN];
880 sprintf(string, _("Rendering %s"), name);
881 mwindow->gui->lock_window("AssetPicon::create_objects");
882 mwindow->gui->show_message(string);
883 mwindow->gui->unlock_window();
884 open_render_engine(edl, 0);
885 render_video(0, gui->temp_picon);
886 close_render_engine();
887 icon_vframe = new VFrame(0,
888 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
889 icon_vframe->transfer_from(gui->temp_picon);
890 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
893 pixmap_w = icon_vframe->get_w();
894 pixmap_h = icon_vframe->get_h();
896 gui->lock_window("AssetPicon::create_objects 0");
897 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
898 icon->draw_vframe(icon_vframe,
899 0, 0, pixmap_w, pixmap_h, 0, 0);
902 icon = gui->clip_icon;
903 icon_vframe = gui->clip_vframe;
907 if( edl->tracks->playable_audio_tracks() ) {
908 if( mwindow->preferences->use_thumbnails ) {
909 gui->unlock_window();
910 char clip_icon_path[BCTEXTLEN];
911 char *clip_icon = edl->local_session->clip_icon;
913 snprintf(clip_icon_path, sizeof(clip_icon_path),
914 "%s/%s", File::get_config_path(), clip_icon);
915 icon_vframe = VFramePng::vframe_png(clip_icon_path);
918 pixmap_w = pixmap_h * 16/9;
919 icon_vframe = new VFrame(0,
920 -1, pixmap_w, pixmap_h, BC_RGB888, -1);
921 icon_vframe->clear_frame();
922 char string[BCTEXTLEN];
923 sprintf(string, _("Rendering %s"), name);
924 mwindow->gui->lock_window("AssetPicon::create_objects 3");
925 mwindow->gui->show_message(string);
926 mwindow->gui->unlock_window();
927 int sample_rate = edl->get_sample_rate();
928 int channels = edl->get_audio_channels();
929 if( channels > 2 ) channels = 2;
930 int64_t audio_samples = edl->get_audio_samples();
931 double duration = (double)audio_samples / sample_rate;
932 draw_hue_bar(icon_vframe, duration);
933 Samples *samples[MAX_CHANNELS];
934 int bfrsz = sample_rate;
935 for( int i=0; i<MAX_CHANNELS; ++i )
936 samples[i] = i<channels ? new Samples(bfrsz) : 0;
937 open_render_engine(edl, 1);
938 render_audio(0, samples, bfrsz);
939 close_render_engine();
940 gui->lock_window("AssetPicon::create_objects 4");
941 static int line_colors[2] = { GREEN, YELLOW };
942 static int base_colors[2] = { RED, PINK };
943 for( int i=channels; --i>=0; ) {
944 draw_wave(icon_vframe, samples[i]->get_data(), bfrsz,
945 base_colors[i], line_colors[i]);
947 for( int i=0; i<channels; ++i ) delete samples[i];
948 if( clip_icon[0] ) icon_vframe->write_png(clip_icon_path);
951 pixmap_w = icon_vframe->get_w();
952 pixmap_h = icon_vframe->get_h();
954 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
955 icon->draw_vframe(icon_vframe,
956 0, 0, pixmap_w, pixmap_h, 0, 0);
959 icon = gui->clip_icon;
960 icon_vframe = gui->clip_vframe;
966 strcpy(name, _(plugin->title));
968 icon_vframe = plugin->get_picon();
970 icon = gui->create_pixmap(icon_vframe);
971 else if( plugin->audio ) {
972 if( plugin->transition ) {
973 icon = gui->atransition_icon;
974 icon_vframe = gui->atransition_vframe;
976 else if( plugin->is_ffmpeg() ) {
977 icon = gui->ff_aud_icon;
978 icon_vframe = gui->ff_aud_vframe;
980 else if( plugin->is_ladspa() ) {
981 icon = gui->ladspa_icon;
982 icon_vframe = gui->ladspa_vframe;
985 icon = gui->aeffect_icon;
986 icon_vframe = gui->aeffect_vframe;
989 else if( plugin->video ) {
990 if( plugin->transition ) {
991 icon = gui->vtransition_icon;
992 icon_vframe = gui->vtransition_vframe;
994 else if( plugin->is_ffmpeg() ) {
995 icon = gui->ff_vid_icon;
996 icon_vframe = gui->ff_vid_vframe;
999 icon = gui->veffect_icon;
1000 icon_vframe = gui->veffect_vframe;
1008 mwindow->edl->session->time_format,
1009 mwindow->edl->session->sample_rate,
1010 mwindow->edl->session->frame_rate,
1011 mwindow->edl->session->frames_per_foot);
1013 icon = gui->label_icon;
1014 icon_vframe = gui->label_vframe;
1017 icon = gui->file_icon;
1018 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
1021 set_icon_vframe(icon_vframe);
1024 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
1025 : BC_Window(_(PROGRAM_NAME ": Resources"),
1026 mwindow->session->awindow_x, mwindow->session->awindow_y,
1027 mwindow->session->awindow_w, mwindow->session->awindow_h,
1030 this->mwindow = mwindow;
1031 this->awindow = awindow;
1033 file_vframe = 0; file_icon = 0;
1034 folder_vframe = 0; folder_icon = 0;
1035 audio_vframe = 0; audio_icon = 0;
1036 video_vframe = 0; video_icon = 0;
1037 label_vframe = 0; label_icon = 0;
1039 atransition_vframe = 0; atransition_icon = 0;
1040 vtransition_vframe = 0; vtransition_icon = 0;
1041 aeffect_vframe = 0; aeffect_icon = 0;
1042 ladspa_vframe = 0; ladspa_icon = 0;
1043 veffect_vframe = 0; veffect_icon = 0;
1044 ff_aud_vframe = 0; ff_aud_icon = 0;
1045 ff_vid_vframe = 0; ff_vid_icon = 0;
1047 aeffect_folder_vframe = 0; aeffect_folder_icon = 0;
1048 atransition_folder_vframe = 0; atransition_folder_icon = 0;
1049 clip_folder_vframe = 0; clip_folder_icon = 0;
1050 label_folder_vframe = 0; label_folder_icon = 0;
1051 media_folder_vframe = 0; media_folder_icon = 0;
1052 proxy_folder_vframe = 0; proxy_folder_icon = 0;
1053 veffect_folder_vframe = 0; veffect_folder_icon = 0;
1054 vtransition_folder_vframe = 0; vtransition_folder_icon = 0;
1056 ladspa_vframe = 0; ladspa_icon = 0;
1057 ff_aud_vframe = 0; ff_aud_icon = 0;
1058 ff_vid_vframe = 0; ff_vid_icon = 0;
1060 clip_vframe = 0; clip_icon = 0;
1061 atransition_vframe = 0; atransition_icon = 0;
1062 vtransition_vframe = 0; vtransition_icon = 0;
1063 aeffect_vframe = 0; aeffect_icon = 0;
1064 veffect_vframe = 0; veffect_icon = 0;
1066 plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
1068 effectlist_menu = 0;
1073 folderlist_menu = 0;
1076 allow_iconlisting = 1;
1081 displayed_folder = AW_NO_FOLDER;
1082 new_folder_thread = 0;
1083 modify_folder_thread = 0;
1084 folder_lock = new Mutex("AWindowGUI::folder_lock");
1087 AWindowGUI::~AWindowGUI()
1089 assets.remove_all_objects();
1090 folders.remove_all_objects();
1091 aeffects.remove_all_objects();
1092 veffects.remove_all_objects();
1093 atransitions.remove_all_objects();
1094 vtransitions.remove_all_objects();
1095 labellist.remove_all_objects();
1096 displayed_assets[1].remove_all_objects();
1098 delete new_folder_thread;
1099 delete modify_folder_thread;
1100 delete vicon_thread;
1105 delete remove_plugin;
1107 delete file_vframe; delete file_icon;
1108 delete folder_vframe; delete folder_icon;
1109 delete audio_vframe; delete audio_icon;
1110 delete video_vframe; delete video_icon;
1111 delete label_vframe; delete label_icon;
1112 delete clip_vframe; delete clip_icon;
1113 delete aeffect_folder_vframe; delete aeffect_folder_icon;
1114 delete atransition_folder_vframe; delete atransition_folder_icon;
1115 delete veffect_folder_vframe; delete veffect_folder_icon;
1116 delete vtransition_folder_vframe; delete vtransition_folder_icon;
1117 delete clip_folder_vframe; delete clip_folder_icon;
1118 delete label_folder_vframe; delete label_folder_icon;
1119 delete media_folder_vframe; delete media_folder_icon;
1120 delete proxy_folder_vframe; delete proxy_folder_icon;
1121 delete ladspa_vframe; delete ladspa_icon;
1122 delete ff_aud_vframe; delete ff_aud_icon;
1123 delete ff_vid_vframe; delete ff_vid_icon;
1124 delete atransition_vframe; delete atransition_icon;
1125 delete vtransition_vframe; delete vtransition_icon;
1126 delete aeffect_vframe; delete aeffect_icon;
1127 delete veffect_vframe; delete veffect_icon;
1131 bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
1133 return icon == file_icon ||
1134 icon == folder_icon ||
1135 icon == audio_icon ||
1136 icon == video_icon ||
1137 icon == clip_icon ||
1138 icon == label_icon ||
1139 icon == vtransition_icon ||
1140 icon == atransition_icon ||
1141 icon == veffect_icon ||
1142 icon == aeffect_icon ||
1143 icon == ladspa_icon ||
1144 icon == ff_aud_icon ||
1145 icon == ff_vid_icon ||
1146 icon == aeffect_folder_icon ||
1147 icon == veffect_folder_icon ||
1148 icon == atransition_folder_icon ||
1149 icon == vtransition_folder_icon ||
1150 icon == label_folder_icon ||
1151 icon == clip_folder_icon ||
1152 icon == media_folder_icon ||
1153 icon == proxy_folder_icon;
1156 VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
1158 char png_path[BCTEXTLEN];
1159 char *pp = png_path, *ep = pp + sizeof(png_path)-1;
1160 snprintf(pp, ep-pp, "%s/picon/%s/%s.png",
1161 File::get_plugin_path(), plugin_icons, name);
1162 if( access(png_path, R_OK) ) return 0;
1163 return VFramePng::vframe_png(png_path,0,0);
1166 VFrame *AWindowGUI::get_picon(const char *name)
1168 VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
1170 char png_name[BCSTRLEN], *pp = png_name, *ep = pp + sizeof(png_name)-1;
1171 snprintf(pp, ep-pp, "%s.png", name);
1172 unsigned char *data = mwindow->theme->get_image_data(png_name);
1173 if( data ) vframe = new VFramePng(data, 0.);
1178 void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
1180 vfrm = get_picon(fn);
1181 if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
1182 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1184 void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
1186 vfrm = get_picon(fn);
1187 if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
1188 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1190 void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
1192 vfrm = get_picon(fn);
1193 if( !vfrm ) vfrm = new VFramePng(png);
1194 icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
1197 void AWindowGUI::create_objects()
1199 lock_window("AWindowGUI::create_objects");
1200 asset_titles[0] = C_("Title");
1201 asset_titles[1] = _("Comments");
1203 set_icon(mwindow->theme->get_image("awindow_icon"));
1205 resource_icon(file_vframe, file_icon, "film_icon", ICON_UNKNOWN);
1206 resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
1207 resource_icon(audio_vframe, audio_icon, "audio_icon", ICON_SOUND);
1208 resource_icon(video_vframe, video_icon, "video_icon", ICON_FILM);
1209 resource_icon(label_vframe, label_icon, "label_icon", ICON_LABEL);
1211 theme_icon(aeffect_folder_vframe, aeffect_folder_icon, "aeffect_folder");
1212 theme_icon(atransition_folder_vframe, atransition_folder_icon, "atransition_folder");
1213 theme_icon(clip_folder_vframe, clip_folder_icon, "clip_folder");
1214 theme_icon(label_folder_vframe, label_folder_icon, "label_folder");
1215 theme_icon(media_folder_vframe, media_folder_icon, "media_folder");
1216 theme_icon(proxy_folder_vframe, proxy_folder_icon, "proxy_folder");
1217 theme_icon(veffect_folder_vframe, veffect_folder_icon, "veffect_folder");
1218 theme_icon(vtransition_folder_vframe, vtransition_folder_icon, "vtransition_folder");
1220 folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
1221 folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
1222 folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
1223 folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
1224 folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
1225 folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
1226 folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
1227 folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
1229 theme_icon(clip_vframe, clip_icon, "clip_icon");
1230 theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
1231 theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
1232 theme_icon(aeffect_vframe, aeffect_icon, "aeffect_icon");
1233 theme_icon(veffect_vframe, veffect_icon, "veffect_icon");
1235 plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
1236 plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio", ff_audio_png);
1237 plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video", ff_video_png);
1238 folder_lock->lock("AWindowGUI::create_objects");
1239 // Mandatory folders
1240 folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
1241 folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
1242 folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
1243 folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
1244 folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
1245 folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
1246 folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
1247 folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
1249 create_label_folder();
1250 folder_lock->unlock();
1252 mwindow->theme->get_awindow_sizes(this);
1253 load_defaults(mwindow->defaults);
1254 new_folder_thread = new NewFolderThread(this);
1255 modify_folder_thread = new ModifyFolderThread(this);
1257 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1258 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1259 search_text = new AWindowSearchText(mwindow, this, x1, y1+5);
1260 search_text->create_objects();
1261 int dy = search_text->get_h() + 10;
1263 add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
1265 vicon_thread = new AssetVIconThread(asset_list);
1266 asset_list->update_vicon_area();
1267 vicon_thread->start();
1268 vicon_audio = new AssetVIconAudio(this);
1270 add_subwindow(divider = new AWindowDivider(mwindow, this,
1271 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1272 mwindow->theme->adivider_w, mwindow->theme->adivider_h));
1274 divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
1276 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1277 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1278 VFrame **images = mwindow->theme->get_image_set("playpatch_data");
1279 AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
1280 add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
1281 add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
1282 add_tools->create_objects();
1283 fy += add_tools->get_h(); fh -= add_tools->get_h();
1284 add_subwindow(folder_list = new AWindowFolders(mwindow,
1285 this, fx, fy, fw, fh));
1287 folder_list->load_expanders();
1289 //int x = mwindow->theme->abuttons_x;
1290 //int y = mwindow->theme->abuttons_y;
1292 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
1293 asset_menu->create_objects();
1294 add_subwindow(clip_menu = new ClipPopup(mwindow, this));
1295 clip_menu->create_objects();
1296 add_subwindow(label_menu = new LabelPopup(mwindow, this));
1297 label_menu->create_objects();
1298 add_subwindow(proxy_menu = new ProxyPopup(mwindow, this));
1299 proxy_menu->create_objects();
1301 add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
1302 effectlist_menu->create_objects();
1303 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
1304 assetlist_menu->create_objects();
1305 add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
1306 cliplist_menu->create_objects();
1307 add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
1308 labellist_menu->create_objects();
1309 add_subwindow(proxylist_menu = new ProxyListMenu(mwindow, this));
1310 proxylist_menu->create_objects();
1312 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
1313 folderlist_menu->create_objects();
1315 create_custom_xatoms();
1319 int AWindowGUI::resize_event(int w, int h)
1321 mwindow->session->awindow_x = get_x();
1322 mwindow->session->awindow_y = get_y();
1323 mwindow->session->awindow_w = w;
1324 mwindow->session->awindow_h = h;
1326 mwindow->theme->get_awindow_sizes(this);
1327 mwindow->theme->draw_awindow_bg(this);
1328 reposition_objects();
1330 // int x = mwindow->theme->abuttons_x;
1331 // int y = mwindow->theme->abuttons_y;
1332 // new_bin->reposition_window(x, y);
1333 // x += new_bin->get_w();
1334 // delete_bin->reposition_window(x, y);
1335 // x += delete_bin->get_w();
1336 // rename_bin->reposition_window(x, y);
1337 // x += rename_bin->get_w();
1338 // delete_disk->reposition_window(x, y);
1339 // x += delete_disk->get_w();
1340 // delete_project->reposition_window(x, y);
1341 // x += delete_project->get_w();
1342 // info->reposition_window(x, y);
1343 // x += info->get_w();
1344 // redraw_index->reposition_window(x, y);
1345 // x += redraw_index->get_w();
1346 // paste->reposition_window(x, y);
1347 // x += paste->get_w();
1348 // append->reposition_window(x, y);
1349 // x += append->get_w();
1350 // view->reposition_window(x, y);
1352 BC_WindowBase::resize_event(w, h);
1353 asset_list->update_vicon_area();
1357 int AWindowGUI::translation_event()
1359 mwindow->session->awindow_x = get_x();
1360 mwindow->session->awindow_y = get_y();
1364 void AWindowGUI::reposition_objects()
1366 int x1 = mwindow->theme->alist_x, y1 = mwindow->theme->alist_y;
1367 int w1 = mwindow->theme->alist_w, h1 = mwindow->theme->alist_h;
1368 search_text->reposition_window(x1, y1+5, w1);
1369 int dy = search_text->get_h() + 10;
1371 asset_list->reposition_window(x1, y1, w1, h1);
1372 divider->reposition_window(
1373 mwindow->theme->adivider_x, mwindow->theme->adivider_y,
1374 mwindow->theme->adivider_w, mwindow->theme->adivider_h);
1375 int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
1376 int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
1377 add_tools->resize_event(fw-avicon_w, add_tools->get_h());
1378 avicon_drawing->reposition_window(fw-avicon_w, fy);
1379 fy += add_tools->get_h(); fh -= add_tools->get_h();
1380 folder_list->reposition_window(fx, fy, fw, fh);
1383 int AWindowGUI::save_defaults(BC_Hash *defaults)
1385 defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
1386 defaults->update("VICON_DRAWING", vicon_drawing);
1390 int AWindowGUI::load_defaults(BC_Hash *defaults)
1392 plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
1393 vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
1397 int AWindowGUI::close_event()
1400 mwindow->session->show_awindow = 0;
1403 mwindow->gui->lock_window("AWindowGUI::close_event");
1404 mwindow->gui->mainmenu->show_awindow->set_checked(0);
1405 mwindow->gui->unlock_window();
1407 lock_window("AWindowGUI::close_event");
1408 save_defaults(mwindow->defaults);
1409 mwindow->save_defaults();
1413 void AWindowGUI::start_vicon_drawing()
1415 if( !vicon_drawing || !vicon_thread->interrupted ) return;
1416 if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
1417 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
1418 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
1419 switch( mwindow->edl->session->assetlist_format ) {
1421 case ASSETS_ICONS_PACKED:
1422 case ASSETS_ICON_LIST:
1423 asset_list->update_vicon_area();
1424 vicon_thread->start_drawing();
1432 void AWindowGUI::stop_vicon_drawing()
1434 if( vicon_thread->interrupted ) return;
1435 vicon_thread->stop_drawing();
1438 VFrame *AssetPicon::get_vicon_frame()
1440 if( !vicon ) return 0;
1441 if( gui->vicon_thread->interrupted ) return 0;
1442 VFrame *frame = vicon->frame();
1443 if( !frame ) return 0;
1445 vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model());
1446 vicon_frame->transfer_from(frame);
1450 int AWindowGUI::cycle_assetlist_format()
1452 EDLSession *session = mwindow->edl->session;
1453 int format = ASSETS_TEXT;
1454 if( allow_iconlisting ) {
1455 switch( session->assetlist_format ) {
1457 format = ASSETS_ICONS;
1460 format = ASSETS_ICONS_PACKED;
1462 case ASSETS_ICONS_PACKED:
1463 format = ASSETS_ICON_LIST;
1465 case ASSETS_ICON_LIST:
1466 format = ASSETS_TEXT;
1470 stop_vicon_drawing();
1471 session->assetlist_format = format;
1472 asset_list->update_format(session->assetlist_format, 0);
1473 async_update_assets();
1474 start_vicon_drawing();
1478 AWindowRemovePluginGUI::
1479 AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
1480 int x, int y, PluginServer *plugin)
1481 : BC_Window(_(PROGRAM_NAME ": Remove plugin"), x,y, 500,200, 50, 50, 1, 0, 1, -1, "", 1)
1483 this->awindow = awindow;
1484 this->thread = thread;
1485 this->plugin = plugin;
1486 VFrame *vframe = plugin->get_picon();
1487 icon = vframe ? create_pixmap(vframe) : 0;
1488 plugin_list.append(new BC_ListBoxItem(plugin->title, icon));
1491 AWindowRemovePluginGUI::
1492 ~AWindowRemovePluginGUI()
1494 if( !awindow->gui->protected_pixmap(icon) )
1496 plugin_list.remove_all();
1499 void AWindowRemovePluginGUI::create_objects()
1501 lock_window("AWindowRemovePluginGUI::create_objects");
1502 BC_Button *ok_button = new BC_OKButton(this);
1503 add_subwindow(ok_button);
1504 BC_Button *cancel_button = new BC_CancelButton(this);
1505 add_subwindow(cancel_button);
1507 BC_Title *title = new BC_Title(x, y, _("remove plugin?"));
1508 add_subwindow(title);
1509 y += title->get_h() + 5;
1510 list = new BC_ListBox(x, y,
1511 get_w() - 20, ok_button->get_y() - y - 5, LISTBOX_TEXT, &plugin_list,
1512 0, 0, 1, 0, 0, LISTBOX_SINGLE, ICON_LEFT, 0);
1513 add_subwindow(list);
1518 int AWindowRemovePlugin::remove_plugin(PluginServer *plugin, ArrayList<BC_ListBoxItem*> &folder)
1521 for( int i=0; i<folder.size(); ) {
1522 AssetPicon *picon = (AssetPicon *)folder[i];
1523 if( picon->plugin == plugin ) {
1524 folder.remove_object_number(i);
1533 void AWindowRemovePlugin::handle_close_event(int result)
1536 printf(_("remove %s\n"), plugin->path);
1537 awindow->gui->lock_window("AWindowRemovePlugin::handle_close_event");
1538 ArrayList<BC_ListBoxItem*> *folder =
1539 plugin->audio ? plugin->transition ?
1540 &awindow->gui->atransitions :
1541 &awindow->gui->aeffects :
1542 plugin->video ? plugin->transition ?
1543 &awindow->gui->vtransitions :
1544 &awindow->gui->veffects :
1546 if( folder ) remove_plugin(plugin, *folder);
1547 MWindow *mwindow = awindow->mwindow;
1548 awindow->gui->unlock_window();
1549 char plugin_path[BCTEXTLEN];
1550 strcpy(plugin_path, plugin->path);
1551 mwindow->plugindb->remove(plugin);
1552 remove(plugin_path);
1553 char index_path[BCTEXTLEN];
1554 mwindow->create_defaults_path(index_path, PLUGIN_FILE);
1556 char picon_path[BCTEXTLEN];
1558 snprintf(picon_path, sizeof(picon_path), "%s/picon",
1559 File::get_plugin_path());
1560 char png_name[BCSTRLEN], png_path[BCTEXTLEN];
1561 plugin->get_plugin_png_name(png_name);
1562 fs.update(picon_path);
1563 for( int i=0; i<fs.dir_list.total; ++i ) {
1564 char *fs_path = fs.dir_list[i]->path;
1565 if( !fs.is_dir(fs_path) ) continue;
1566 snprintf(png_path, sizeof(picon_path), "%s/%s",
1570 delete plugin; plugin = 0;
1571 awindow->gui->async_update_assets();
1575 AWindowRemovePlugin::
1576 AWindowRemovePlugin(AWindow *awindow, PluginServer *plugin)
1579 this->awindow = awindow;
1580 this->plugin = plugin;
1583 AWindowRemovePlugin::
1584 ~AWindowRemovePlugin()
1589 BC_Window* AWindowRemovePlugin::new_gui()
1591 int x = awindow->gui->get_abs_cursor_x(0);
1592 int y = awindow->gui->get_abs_cursor_y(0);
1593 AWindowRemovePluginGUI *gui = new AWindowRemovePluginGUI(awindow, this, x, y, plugin);
1594 gui->create_objects();
1598 int AWindowGUI::keypress_event()
1600 switch( get_keypress() ) {
1608 if( !ctrl_down() && !shift_down() ) {
1609 assetlist_menu->load_file->handle_event();
1614 return cycle_assetlist_format();
1616 if( shift_down() && ctrl_down() ) {
1617 PluginServer* plugin = selected_plugin();
1618 if( !plugin ) break;
1619 remove_plugin = new AWindowRemovePlugin(awindow, plugin);
1621 remove_plugin->start();
1622 lock_window("AWindowGUI::keypress_event 1");
1626 if( shift_down() ) {
1627 mwindow->awindow->asset_remove->start();
1631 mwindow->remove_assets_from_project(1, 1,
1632 mwindow->session->drag_assets,
1633 mwindow->session->drag_clips);
1634 lock_window("AWindowGUI::keypress_event 2");
1640 if( shift_down() && ctrl_down() ) {
1641 resend_event(mwindow->gui);
1651 int AWindowGUI::create_custom_xatoms()
1653 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
1656 int AWindowGUI::receive_custom_xatoms(xatom_event *event)
1658 if( event->message_type == UpdateAssetsXAtom ) {
1665 void AWindowGUI::async_update_assets()
1668 event.message_type = UpdateAssetsXAtom;
1669 send_custom_xatom(&event);
1673 void AWindowGUI::update_folder_list()
1675 for( int i = 0; i < folders.total; i++ ) {
1676 AssetPicon *picon = (AssetPicon*)folders.values[i];
1680 // Search assets for folders
1681 for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
1682 BinFolder *bin_folder = mwindow->edl->folders[i];
1685 for( int j = 0; j < folders.total; j++ ) {
1686 AssetPicon *picon = (AssetPicon*)folders[j];
1687 if( !strcasecmp(picon->get_text(), bin_folder->title) ) {
1695 const char *title = bin_folder->title;
1696 int folder = bin_folder->awindow_folder;
1697 AssetPicon *picon = new AssetPicon(mwindow, this, folder, title);
1698 picon->create_objects();
1699 folders.append(picon);
1703 // Delete unused non-persistent folders
1704 int do_autoplace = 0;
1705 for( int i=folders.total; --i>=0; ) {
1706 AssetPicon *picon = (AssetPicon*)folders.values[i];
1707 if( !picon->in_use && !picon->persistent ) {
1709 folders.remove_number(i);
1714 folder_list->set_autoplacement(&folders, 0, 1);
1717 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
1718 int do_audio, int do_video, int is_realtime, int is_transition)
1720 ArrayList<PluginServer*> plugin_list;
1721 // Get pointers to plugindb entries
1722 mwindow->search_plugindb(do_audio, do_video, is_realtime, is_transition,
1725 for( int i = 0; i < plugin_list.total; i++ ) {
1726 PluginServer *server = plugin_list.values[i];
1727 int visible = plugin_visibility & (1<<server->dir_idx);
1728 if( !visible ) continue;
1729 // Create new listitem
1730 AssetPicon *picon = new AssetPicon(mwindow, this, server);
1731 picon->create_objects();
1732 output->append(picon);
1736 void AWindowGUI::create_label_folder()
1739 for( current = mwindow->edl->labels->first; current; current = NEXT ) {
1740 AssetPicon *picon = new AssetPicon(mwindow, this, current);
1741 picon->create_objects();
1742 labellist.append(picon);
1747 void AWindowGUI::update_asset_list()
1749 ArrayList<AssetPicon *> new_assets;
1750 for( int i = 0; i < assets.total; i++ ) {
1751 AssetPicon *picon = (AssetPicon*)assets.values[i];
1755 mwindow->gui->lock_window("AWindowGUI::update_asset_list");
1756 // Synchronize EDL clips
1757 for( int i=0; i<mwindow->edl->clips.size(); ++i ) {
1760 // Look for clip in existing listitems
1761 for( int j = 0; j < assets.total && !exists; j++ ) {
1762 AssetPicon *picon = (AssetPicon*)assets.values[j];
1764 if( picon->id == mwindow->edl->clips[i]->id ) {
1765 picon->edl = mwindow->edl->clips[i];
1766 picon->set_text(mwindow->edl->clips[i]->local_session->clip_title);
1772 // Create new listitem
1774 AssetPicon *picon = new AssetPicon(mwindow,
1775 this, mwindow->edl->clips[i]);
1776 new_assets.append(picon);
1780 // Synchronize EDL assets
1781 for( Asset *current=mwindow->edl->assets->first; current; current=NEXT ) {
1784 // Look for asset in existing listitems
1785 for( int j = 0; j < assets.total && !exists; j++ ) {
1786 AssetPicon *picon = (AssetPicon*)assets.values[j];
1788 if( picon->id == current->id ) {
1789 picon->indexable = current;
1795 // Create new listitem
1797 AssetPicon *picon = new AssetPicon(mwindow,
1799 new_assets.append(picon);
1803 // Synchronize nested EDLs
1804 for( int i=0; i<mwindow->edl->nested_edls.size(); ++i ) {
1806 EDL *nested_edl = mwindow->edl->nested_edls[i];
1808 // Look for asset in existing listitems
1809 for( int j=0; j<assets.total && !exists; ++j ) {
1810 AssetPicon *picon = (AssetPicon*)assets.values[j];
1812 if( picon->id == nested_edl->id ) {
1813 picon->indexable = nested_edl;
1819 // Create new listitem
1821 AssetPicon *picon = new AssetPicon(mwindow,
1822 this, (Indexable*)nested_edl);
1823 new_assets.append(picon);
1826 mwindow->gui->unlock_window();
1828 for( int i=0; i<new_assets.size(); ++i ) {
1829 AssetPicon *picon = new_assets[i];
1830 picon->create_objects();
1831 if( picon->indexable )
1832 picon->foldernum = AW_MEDIA_FOLDER;
1833 else if( picon->edl )
1834 picon->foldernum = AW_CLIP_FOLDER;
1835 assets.append(picon);
1838 mwindow->gui->lock_window();
1839 mwindow->gui->default_message();
1840 mwindow->gui->unlock_window();
1842 for( int i = assets.size() - 1; i >= 0; i-- ) {
1843 AssetPicon *picon = (AssetPicon*)assets.get(i);
1844 if( !picon->in_use ) {
1846 assets.remove_number(i);
1849 if( picon->indexable && picon->indexable->is_asset ) {
1851 picon->comments_time = !stat(picon->indexable->path, &st) ?
1857 void AWindowGUI::update_picon(Indexable *indexable)
1860 for( int i = 0; i < assets.total; i++ ) {
1861 AssetPicon *picon = (AssetPicon*)assets.values[i];
1862 if( picon->indexable == indexable ||
1863 picon->edl == (EDL *)indexable ) {
1864 char name[BCTEXTLEN];
1866 fs.extract_name(name, indexable->path);
1867 picon->set_text(name);
1868 vicon = picon->vicon;
1873 stop_vicon_drawing();
1874 vicon->clear_images();
1875 vicon->reset(indexable->get_frame_rate());
1876 start_vicon_drawing();
1880 void AWindowGUI::sort_assets()
1882 folder_lock->lock("AWindowGUI::sort_assets");
1883 switch( mwindow->edl->session->awindow_folder ) {
1884 case AW_AEFFECT_FOLDER:
1885 sort_picons(&aeffects);
1887 case AW_VEFFECT_FOLDER:
1888 sort_picons(&veffects);
1890 case AW_ATRANSITION_FOLDER:
1891 sort_picons(&atransitions);
1893 case AW_VTRANSITION_FOLDER:
1894 sort_picons(&vtransitions);
1896 case AW_LABEL_FOLDER:
1897 sort_picons(&labellist);
1900 sort_picons(&assets);
1904 asset_list->update_format(asset_list->get_format(), 0);
1905 folder_lock->unlock();
1909 void AWindowGUI::sort_folders()
1911 folder_lock->lock("AWindowGUI::update_assets");
1912 // folder_list->collapse_recursive(&folders, 0);
1913 folder_list->set_autoplacement(&folders, 0, 1);
1914 sort_picons(&folders);
1915 folder_list->update_format(folder_list->get_format(), 0);
1916 folder_lock->unlock();
1920 EDL *AWindowGUI::collect_proxy(Indexable *indexable)
1922 Asset *proxy_asset = (Asset *)indexable;
1923 char path[BCTEXTLEN];
1924 int proxy_scale = mwindow->edl->session->proxy_scale;
1925 ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
1926 Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
1927 if( !unproxy_asset || !unproxy_asset->layers ) return 0;
1928 // make a clip from proxy video tracks and unproxy audio tracks
1929 EDL *proxy_edl = new EDL(mwindow->edl);
1930 proxy_edl->create_objects();
1931 proxy_edl->set_path(proxy_asset->path);
1932 FileSystem fs; fs.extract_name(path, proxy_asset->path);
1933 strcpy(proxy_edl->local_session->clip_title, path);
1934 strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
1935 proxy_edl->session->video_tracks = proxy_asset->layers;
1936 proxy_edl->session->audio_tracks = unproxy_asset->channels;
1937 proxy_edl->create_default_tracks();
1938 double length = proxy_asset->frame_rate > 0 ?
1939 ( proxy_asset->video_length >= 0 ?
1940 ( proxy_asset->video_length / proxy_asset->frame_rate ) :
1941 ( proxy_edl->session->si_useduration ?
1942 proxy_edl->session->si_duration :
1943 1.0 / proxy_asset->frame_rate ) ) :
1944 1.0 / proxy_edl->session->frame_rate;
1945 Track *current = proxy_edl->tracks->first;
1946 for( int vtrack=0; current; current=NEXT ) {
1947 if( current->data_type != TRACK_VIDEO ) continue;
1948 current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
1950 length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
1951 current = proxy_edl->tracks->first;
1952 for( int atrack=0; current; current=NEXT ) {
1953 if( current->data_type != TRACK_AUDIO ) continue;
1954 current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
1956 proxy_edl->folder_no = AW_PROXY_FOLDER;
1961 void AWindowGUI::collect_assets(int proxy)
1963 mwindow->session->drag_assets->remove_all();
1964 mwindow->session->drag_clips->remove_all();
1965 int i = 0; AssetPicon *result;
1966 while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
1967 Indexable *indexable = result->indexable;
1968 if( proxy && indexable && indexable->is_asset &&
1969 indexable->folder_no == AW_PROXY_FOLDER ) {
1970 EDL *drag_edl = collect_proxy(indexable);
1971 if( drag_edl ) mwindow->session->drag_clips->append(drag_edl);
1975 mwindow->session->drag_assets->append(indexable);
1979 mwindow->session->drag_clips->append(result->edl);
1985 void AWindowGUI::copy_picons(AssetPicon *picon, ArrayList<BC_ListBoxItem*> *src)
1987 // Remove current pointers
1988 ArrayList<BC_ListBoxItem*> *dst = displayed_assets;
1989 dst[0].remove_all();
1990 dst[1].remove_all_objects();
1992 AWindowFolderSubItems *sub_items = picon ? picon->sub_items : 0;
1993 int folder = mwindow->edl->session->awindow_folder;
1994 BinFolder *bin_folder = folder < AWINDOW_USER_FOLDERS ? 0 :
1995 mwindow->edl->get_folder(folder);
1997 // Create new pointers
1998 for( int i = 0; i < src->total; i++ ) {
1999 int visible = folder >= AW_CLIP_FOLDER ? 0 : 1;
2000 picon = (AssetPicon*)src->values[i];
2001 picon->sort_key = -1;
2002 if( !visible && bin_folder ) {
2003 Indexable *idxbl = bin_folder->is_clips ? (Indexable *)picon->edl :
2004 picon->indexable ? picon->indexable :
2005 picon->edl ? picon->edl->get_proxy_asset() : 0;
2007 picon->sort_key = mwindow->edl->folders.matches_indexable(folder, idxbl);
2008 if( picon->sort_key < 0 ) continue;
2012 if( !visible && picon->indexable && picon->indexable->folder_no == folder )
2014 if( !visible && picon->edl && picon->edl->folder_no == folder )
2016 if( visible && sub_items ) {
2017 if( !sub_items->matches(picon->get_text()) )
2021 const char *text = search_text->get_text();
2022 if( text && text[0] )
2023 visible = bstrcasestr(picon->get_text(), text) ? 1 : 0;
2025 if( visible && picon->vicon && picon->vicon->hidden )
2026 picon->vicon->hidden = 0;
2028 BC_ListBoxItem *item2, *item1;
2029 dst[0].append(item1 = picon);
2031 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
2034 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
2035 else if( picon->comments_time ) {
2036 char date_time[BCSTRLEN];
2037 struct tm stm; localtime_r(&picon->comments_time, &stm);
2038 sprintf(date_time,"%04d.%02d.%02d %02d:%02d:%02d",
2039 stm.tm_year+1900, stm.tm_mon+1, stm.tm_mday,
2040 stm.tm_hour, stm.tm_min, stm.tm_sec);
2041 dst[1].append(item2 = new BC_ListBoxItem(date_time));
2044 dst[1].append(item2 = new BC_ListBoxItem(""));
2045 item1->set_autoplace_text(1); item1->set_autoplace_icon(1);
2046 item2->set_autoplace_text(1); item2->set_autoplace_icon(1);
2051 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
2053 int done = 0, changed = 0;
2056 for( int i=0; i<src->total-1; ++i ) {
2057 AssetPicon *item1 = (AssetPicon *)src->values[i];
2058 AssetPicon *item2 = (AssetPicon *)src->values[i + 1];
2059 double v = item2->sort_key - item1->sort_key;
2060 if( v > 0 ) continue;
2062 const char *cp1 = item1->get_text();
2063 const char *bp1 = strrchr(cp1, '/');
2064 if( bp1 ) cp1 = bp1 + 1;
2065 const char *cp2 = item2->get_text();
2066 const char *bp2 = strrchr(cp2, '/');
2067 if( bp2 ) cp2 = bp2 + 1;
2068 if( strcmp(cp2, cp1) >= 0 ) continue;
2070 src->values[i + 1] = item1;
2071 src->values[i] = item2;
2072 done = 0; changed = 1;
2076 for( int i=0; i<src->total; ++i ) {
2077 AssetPicon *item = (AssetPicon *)src->values[i];
2078 item->set_autoplace_icon(1);
2079 item->set_autoplace_text(1);
2084 void AWindowGUI::filter_displayed_assets()
2086 //allow_iconlisting = 1;
2087 asset_titles[0] = C_("Title");
2088 asset_titles[1] = _("Comments");
2089 AssetPicon *picon = 0;
2090 int selected_folder = mwindow->edl->session->awindow_folder;
2091 // Ensure the current folder icon is highlighted
2092 for( int i = 0; i < folders.total; i++ ) {
2093 AssetPicon *folder_item = (AssetPicon *)folders.values[i];
2094 int selected = folder_item->foldernum == selected_folder ? 1 : 0;
2095 folder_item->set_selected(selected);
2096 if( selected ) picon = folder_item;
2099 ArrayList<BC_ListBoxItem*> *src = &assets;
2100 switch( selected_folder ) {
2101 case AW_AEFFECT_FOLDER: src = &aeffects; break;
2102 case AW_VEFFECT_FOLDER: src = &veffects; break;
2103 case AW_ATRANSITION_FOLDER: src = &atransitions; break;
2104 case AW_VTRANSITION_FOLDER: src = &vtransitions; break;
2105 case AW_LABEL_FOLDER: src = &labellist;
2106 asset_titles[0] = _("Time Stamps");
2107 asset_titles[1] = C_("Title");
2108 //allow_iconlisting = 0;
2111 copy_picons(picon, src);
2115 void AWindowGUI::update_assets()
2117 stop_vicon_drawing();
2118 folder_lock->lock("AWindowGUI::update_assets");
2119 update_folder_list();
2120 update_asset_list();
2121 labellist.remove_all_objects();
2122 create_label_folder();
2124 if( displayed_folder != mwindow->edl->session->awindow_folder )
2125 search_text->clear();
2126 vicon_thread->hide_vicons();
2127 filter_displayed_assets();
2128 folder_lock->unlock();
2130 if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
2131 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
2133 int folder_xposition = folder_list->get_xposition();
2134 int folder_yposition = folder_list->get_yposition();
2135 folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
2137 if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
2138 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
2140 int asset_xposition = asset_list->get_xposition();
2141 int asset_yposition = asset_list->get_yposition();
2142 if( displayed_folder != mwindow->edl->session->awindow_folder ) {
2143 displayed_folder = mwindow->edl->session->awindow_folder;
2144 asset_xposition = asset_yposition = 0;
2146 asset_list->update(displayed_assets, asset_titles,
2147 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
2148 asset_xposition, asset_yposition, -1, 0);
2149 asset_list->center_selection();
2152 start_vicon_drawing();
2156 void AWindowGUI::update_effects()
2158 aeffects.remove_all_objects();
2159 create_persistent_folder(&aeffects, 1, 0, 1, 0);
2160 veffects.remove_all_objects();
2161 create_persistent_folder(&veffects, 0, 1, 1, 0);
2162 atransitions.remove_all_objects();
2163 create_persistent_folder(&atransitions, 1, 0, 0, 1);
2164 vtransitions.remove_all_objects();
2165 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
2168 int AWindowGUI::drag_motion()
2170 if( get_hidden() ) return 0;
2176 int AWindowGUI::drag_stop()
2178 if( get_hidden() ) return 0;
2182 Indexable* AWindowGUI::selected_asset()
2184 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2185 return picon ? picon->indexable : 0;
2188 PluginServer* AWindowGUI::selected_plugin()
2190 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
2191 return picon ? picon->plugin : 0;
2194 AssetPicon* AWindowGUI::selected_folder()
2196 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
2207 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2208 : BC_SubWindow(x, y, w, h)
2210 this->mwindow = mwindow;
2213 AWindowDivider::~AWindowDivider()
2217 int AWindowDivider::button_press_event()
2219 if( is_event_win() && cursor_inside() ) {
2220 mwindow->session->current_operation = DRAG_PARTITION;
2226 int AWindowDivider::cursor_motion_event()
2228 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2230 int wmax = mwindow->session->awindow_w - mwindow->theme->adivider_w - wmin;
2231 int fw = gui->get_relative_cursor_x();
2232 if( fw > wmax ) fw = wmax;
2233 if( fw < wmin ) fw = wmin;
2234 mwindow->session->afolders_w = fw;
2235 mwindow->theme->get_awindow_sizes(gui);
2236 gui->reposition_objects();
2242 int AWindowDivider::button_release_event()
2244 if( mwindow->session->current_operation == DRAG_PARTITION ) {
2245 mwindow->session->current_operation = NO_OPERATION;
2256 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2257 : BC_ListBox(x, y, w, h,
2258 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
2259 LISTBOX_ICONS : LISTBOX_TEXT,
2260 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
2261 0, // Titles for columns. Set to 0 for no titles
2262 0, // width of each column
2263 1, // Total columns.
2264 0, // Pixel of top of window.
2265 0, // If this listbox is a popup window
2266 LISTBOX_SINGLE, // Select one item or multiple items
2267 ICON_TOP, // Position of icon relative to text of each item
2270 this->mwindow = mwindow;
2277 AWindowFolders::~AWindowFolders()
2281 int AWindowFolders::selection_changed()
2283 AWindowFolderItem *item0 = (AWindowFolderItem*)get_selection(0, 0);
2284 AWindowFolderItem *item1 = (AWindowFolderItem*)get_selection(0, 1);
2285 // prefer expanded entry
2286 AWindowFolderItem *item = item1 ? item1 : item0;
2287 if( item0 && item1 && last_item0 == item0 && last_item1 == item1 ) {
2288 item1->set_selected(0);
2295 AssetPicon *picon = item->get_picon();
2296 picon->sub_items = (AWindowFolderSubItems*)(!item->parent ? 0 : item);
2298 gui->stop_vicon_drawing();
2300 if( get_button_down() && get_buttonpress() == 3 ) {
2301 gui->folderlist_menu->update_titles();
2302 gui->folderlist_menu->activate_menu();
2305 mwindow->edl->session->awindow_folder = picon->foldernum;
2306 gui->asset_list->draw_background();
2307 gui->async_update_assets();
2309 gui->start_vicon_drawing();
2314 int AWindowFolders::button_press_event()
2318 result = BC_ListBox::button_press_event();
2321 if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2322 gui->folderlist_menu->update_titles();
2323 gui->folderlist_menu->activate_menu();
2332 int AWindowFolders::drag_stop()
2335 if( get_hidden() ) return 0;
2336 if( mwindow->session->current_operation == DRAG_ASSET &&
2337 gui->folder_list->cursor_above() ) { // check user folder
2338 int item_no = gui->folder_list->get_cursor_data_item_no();
2339 AssetPicon *picon = (AssetPicon *)(item_no < 0 ? 0 : gui->folders[item_no]);
2340 if( picon && picon->foldernum >= AWINDOW_USER_FOLDERS ) {
2341 BinFolder *folder = mwindow->edl->get_folder(picon->foldernum);
2342 ArrayList<Indexable *> *drags = folder->is_clips ?
2343 ((ArrayList<Indexable *> *)mwindow->session->drag_clips) :
2344 ((ArrayList<Indexable *> *)mwindow->session->drag_assets);
2345 if( folder && drags && !folder->add_patterns(drags, shift_down()) )
2347 mwindow->session->current_operation = ::NO_OPERATION;
2354 AWindowFolderSubItems::AWindowFolderSubItems(AWindowFolderItem *parent, const char *text)
2355 : AWindowFolderItem(text)
2357 this->parent = parent;
2360 int AWindowFolders::load_expanders()
2362 char expanders_path[BCTEXTLEN];
2363 mwindow->create_defaults_path(expanders_path, EXPANDERS_FILE);
2364 FILE *fp = fopen(expanders_path, "r");
2366 snprintf(expanders_path, sizeof(expanders_path), "%s/%s",
2367 File::get_cindat_path(), EXPANDERS_FILE);
2368 fp = fopen(expanders_path, "r");
2372 const char tab = '\t';
2373 char line[BCTEXTLEN]; line[0] = 0;
2374 AWindowFolderItem *item = 0, *parent;
2375 AWindowFolderSubItems *sub_items = 0;
2377 while( fgets(line,sizeof(line),fp) ) {
2378 if( line[0] == '#' ) continue;
2379 int i = strlen(line);
2380 if( i > 0 && line[i-1] == '\n' ) line[--i] = 0;
2381 if( i == 0 ) continue;
2383 for( char *cp=line; *cp==tab; ++cp ) ++i;
2385 int i = gui->folders.size();
2387 AssetPicon *folder = (AssetPicon *)gui->folders[i];
2388 if( !strcmp(folder->get_text(),_(line)) ) break;
2390 item = (AWindowFolderItem*)(i >= 0 ? gui->folders[i] : 0);
2395 if( i > k+1 ) continue;
2397 if( line[i] != '-' && sub_items ) {
2398 sub_items->names.append(cstrdup(_(&line[i])));
2406 item = item->parent;
2409 parent = item->parent;
2411 ArrayList<BC_ListBoxItem*> *sublist = parent->get_sublist();
2412 if( !sublist ) sublist = parent->new_sublist(1);
2413 sub_items = new AWindowFolderSubItems(parent, &line[i]);
2414 sublist->append(item = sub_items);
2421 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
2422 : BC_ListBox(x, y, w, h, !gui->allow_iconlisting ? LISTBOX_TEXT :
2423 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? LISTBOX_ICONS :
2424 mwindow->edl->session->assetlist_format == ASSETS_ICONS_PACKED ? LISTBOX_ICONS_PACKED :
2425 mwindow->edl->session->assetlist_format == ASSETS_ICON_LIST ? LISTBOX_ICON_LIST :
2427 &gui->assets, // Each column has an ArrayList of BC_ListBoxItems.
2428 gui->asset_titles,// Titles for columns. Set to 0 for no titles
2429 mwindow->edl->session->asset_columns, // width of each column
2430 1, // Total columns.
2431 0, // Pixel of top of window.
2432 0, // If this listbox is a popup window
2433 LISTBOX_MULTIPLE, // Select one item or multiple items
2434 ICON_TOP, // Position of icon relative to text of each item
2435 -1) // Allow drags, require shift for scrolling
2437 this->mwindow = mwindow;
2440 set_scroll_stretch(1, 1);
2444 AWindowAssets::~AWindowAssets()
2448 int AWindowAssets::button_press_event()
2452 result = BC_ListBox::button_press_event();
2454 if( !result && get_buttonpress() == 3 && is_event_win() && cursor_inside() ) {
2455 BC_ListBox::deactivate_selection();
2456 int folder = mwindow->edl->session->awindow_folder;
2458 case AW_AEFFECT_FOLDER:
2459 case AW_VEFFECT_FOLDER:
2460 case AW_ATRANSITION_FOLDER:
2461 case AW_VTRANSITION_FOLDER:
2462 gui->effectlist_menu->update();
2463 gui->effectlist_menu->activate_menu();
2465 case AW_LABEL_FOLDER:
2466 gui->labellist_menu->update();
2467 gui->labellist_menu->activate_menu();
2469 case AW_CLIP_FOLDER:
2470 gui->cliplist_menu->update();
2471 gui->cliplist_menu->activate_menu();
2473 case AW_PROXY_FOLDER:
2474 gui->proxylist_menu->update();
2475 gui->proxylist_menu->activate_menu();
2478 case AW_MEDIA_FOLDER: {
2479 int shots = folder==AW_MEDIA_FOLDER || folder>=AWINDOW_USER_FOLDERS;
2480 gui->assetlist_menu->update_titles(shots);
2481 gui->assetlist_menu->activate_menu();
2491 int AWindowAssets::handle_event()
2493 AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
2494 if( !asset_picon ) return 0;
2495 Indexable *picon_idxbl = asset_picon->indexable;
2496 EDL *picon_edl = asset_picon->edl;
2498 VWindow *vwindow = 0;
2499 switch( mwindow->edl->session->awindow_folder ) {
2500 case AW_AEFFECT_FOLDER:
2501 case AW_VEFFECT_FOLDER:
2502 case AW_ATRANSITION_FOLDER:
2503 case AW_VTRANSITION_FOLDER: return 1;
2504 case AW_PROXY_FOLDER:
2505 proxy = 1; // fall thru
2507 if( mwindow->vwindows.size() > DEFAULT_VWINDOW )
2508 vwindow = mwindow->vwindows.get(DEFAULT_VWINDOW);
2511 if( !vwindow || !vwindow->is_running() ) return 1;
2512 if( proxy && picon_idxbl ) {
2513 picon_edl = gui->collect_proxy(picon_idxbl);
2517 if( picon_idxbl ) vwindow->change_source(picon_idxbl);
2518 else if( picon_edl ) vwindow->change_source(picon_edl);
2522 int AWindowAssets::selection_changed()
2524 // Show popup window
2526 if( get_button_down() && get_buttonpress() == 3 &&
2527 (item = (AssetPicon*)get_selection(0, 0)) ) {
2528 int folder = mwindow->edl->session->awindow_folder;
2530 case AW_AEFFECT_FOLDER:
2531 case AW_VEFFECT_FOLDER:
2532 case AW_ATRANSITION_FOLDER:
2533 case AW_VTRANSITION_FOLDER:
2534 gui->effectlist_menu->update();
2535 gui->effectlist_menu->activate_menu();
2537 case AW_LABEL_FOLDER:
2538 if( !item->label ) break;
2539 gui->label_menu->activate_menu();
2541 case AW_CLIP_FOLDER:
2542 if( !item->indexable && !item->edl ) break;
2543 gui->clip_menu->update();
2544 gui->clip_menu->activate_menu();
2546 case AW_PROXY_FOLDER:
2547 if( !item->indexable && !item->edl ) break;
2548 gui->proxy_menu->update();
2549 gui->proxy_menu->activate_menu();
2552 if( !item->indexable && !item->edl ) break;
2553 gui->asset_menu->update();
2554 gui->asset_menu->activate_menu();
2558 deactivate_selection();
2560 else if( gui->vicon_drawing && get_button_down() &&
2561 ( get_buttonpress() == 1 || get_buttonpress() == 2 ) &&
2562 ( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
2563 mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ||
2564 mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) &&
2565 (item = (AssetPicon*)get_selection(0, 0)) != 0 ) {
2567 if( !gui->vicon_thread->vicon ) {
2568 vicon = item->vicon;
2570 if( vicon && get_buttonpress() == 2 ) {
2571 vicon->playing_audio = -1;
2572 draw_func = AWindowAssets::draw_vframe;
2576 gui->vicon_thread->set_view_popup(vicon, draw_func);
2581 void AWindowAssets::draw_vframe(BC_WindowBase *wdw, VFrame *vframe)
2583 int y1 = VIEW_POPUP_BAR_H;
2584 int y2 = wdw->get_h()-VIEW_POPUP_BAR_H;
2585 wdw->set_color(BLACK);
2586 wdw->draw_box(0,0,wdw->get_w(),wdw->get_h());
2587 wdw->draw_vframe(vframe, 0,y1, wdw->get_w(),y2-y1);
2588 ViewPopup *view_popup = (ViewPopup *)wdw;
2589 AssetVIconThread *vt = (AssetVIconThread *)view_popup->vt;
2590 AssetVIcon *vicon = (AssetVIcon *)vt->vicon;
2591 AssetPicon *picon = (AssetPicon *)vicon->picon;
2593 picon->indexable ? picon->indexable :
2594 picon->edl ? picon->edl : 0;
2595 if( !idxbl ) return;
2596 double sample_rate = idxbl->get_sample_rate();
2597 double audio_length = sample_rate > 0 && idxbl->have_audio() ?
2598 idxbl->get_audio_samples() / sample_rate : 0;
2599 double frame_rate = idxbl->get_frame_rate();
2600 double video_length = frame_rate > 0 && idxbl->have_video() ?
2601 idxbl->get_video_frames() / frame_rate : 0;
2602 double idxbl_length = bmax(audio_length, video_length);
2603 if( !idxbl_length ) idxbl_length = 1;
2605 EDL *edl = picon->mwindow->edl;
2606 double total_length = edl->tracks->total_length();
2607 if( !total_length ) total_length = 1;
2608 for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
2609 for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
2610 Indexable *indexable = (Indexable *)edit->asset;
2611 if( !indexable ) indexable = (Indexable *)edit->nested_edl;
2612 if( !indexable ) continue;
2613 if( indexable->id == idxbl->id ||
2614 (!indexable->is_asset == !idxbl->is_asset &&
2615 !strcmp(indexable->path, idxbl->path)) ) {
2616 double pos1 = track->from_units(edit->startsource);
2617 double pos2 = track->from_units(edit->startsource + edit->length);
2618 double xscale = wdw->get_w() / idxbl_length;
2619 int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
2620 wdw->set_color(WHITE);
2621 wdw->draw_box(ex1,0, ex2-ex1,y1);
2622 wdw->set_color(BLACK);
2623 wdw->draw_line(ex1,0, ex1,y1);
2624 wdw->draw_line(ex2,0, ex2,y1);
2625 pos1 = track->from_units(edit->startproject);
2626 pos2 = track->from_units(edit->startproject + edit->length);
2627 xscale = wdw->get_w() / total_length;
2628 int px1 = pos1 * xscale, px2 = pos2 * xscale;
2629 wdw->set_color(RED);
2630 wdw->draw_box(px1,y2, px2-px1,wdw->get_h()-y2);
2631 wdw->set_color(BLACK);
2632 wdw->draw_line(px1,y2, px1,wdw->get_h()-1);
2633 wdw->draw_line(px2,y2, px2,wdw->get_h()-1);
2635 wdw->set_color(YELLOW);
2636 wdw->draw_line(ex1,y1, px1,y2);
2637 wdw->draw_line(ex2,y1, px2,y2);
2643 void AWindowAssets::draw_background()
2645 clear_box(0,0,get_w(),get_h(),get_bg_surface());
2646 set_color(BC_WindowBase::get_resources()->audiovideo_color);
2647 set_font(LARGEFONT);
2648 int folder = mwindow->edl->session->awindow_folder;
2649 const char *title = mwindow->edl->get_folder_name(folder);
2650 draw_text(get_w() - get_text_width(LARGEFONT, title) - 4, 30,
2651 title, -1, get_bg_surface());
2654 int AWindowAssets::drag_start_event()
2656 int collect_pluginservers = 0;
2657 int collect_assets = 0, proxy = 0;
2659 if( BC_ListBox::drag_start_event() ) {
2660 switch( mwindow->edl->session->awindow_folder ) {
2661 case AW_AEFFECT_FOLDER:
2662 mwindow->session->current_operation = DRAG_AEFFECT;
2663 collect_pluginservers = 1;
2665 case AW_VEFFECT_FOLDER:
2666 mwindow->session->current_operation = DRAG_VEFFECT;
2667 collect_pluginservers = 1;
2669 case AW_ATRANSITION_FOLDER:
2670 mwindow->session->current_operation = DRAG_ATRANSITION;
2671 collect_pluginservers = 1;
2673 case AW_VTRANSITION_FOLDER:
2674 mwindow->session->current_operation = DRAG_VTRANSITION;
2675 collect_pluginservers = 1;
2677 case AW_LABEL_FOLDER:
2680 case AW_PROXY_FOLDER:
2681 proxy = 1; // fall thru
2682 case AW_MEDIA_FOLDER:
2684 mwindow->session->current_operation = DRAG_ASSET;
2689 if( collect_pluginservers ) {
2691 mwindow->session->drag_pluginservers->remove_all();
2694 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
2695 if( !result ) break;
2697 mwindow->session->drag_pluginservers->append(result->plugin);
2701 if( collect_assets ) {
2702 gui->collect_assets(proxy);
2710 int AWindowAssets::drag_motion_event()
2712 BC_ListBox::drag_motion_event();
2715 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2716 mwindow->gui->drag_motion();
2717 mwindow->gui->unlock_window();
2719 for( int i = 0; i < mwindow->vwindows.size(); i++ ) {
2720 VWindow *vwindow = mwindow->vwindows.get(i);
2721 if( !vwindow->is_running() ) continue;
2722 vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2723 vwindow->gui->drag_motion();
2724 vwindow->gui->unlock_window();
2727 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
2728 mwindow->cwindow->gui->drag_motion();
2729 mwindow->cwindow->gui->unlock_window();
2731 lock_window("AWindowAssets::drag_motion_event");
2732 if( mwindow->session->current_operation == DRAG_ASSET &&
2733 gui->folder_list->cursor_above() ) { // highlight user folder
2734 BC_ListBoxItem *item = 0;
2735 int item_no = gui->folder_list->get_cursor_data_item_no(&item);
2736 if( item_no >= 0 ) {
2737 AssetPicon *folder = (AssetPicon *)gui->folders[item_no];
2738 if( folder->foldernum < AWINDOW_USER_FOLDERS ) item_no = -1;
2741 item_no = gui->folder_list->item_to_index(&gui->folders, item);
2742 int folder_xposition = gui->folder_list->get_xposition();
2743 int folder_yposition = gui->folder_list->get_yposition();
2744 gui->folder_list->update(&gui->folders, 0, 0, 1,
2745 folder_xposition, folder_yposition, item_no, 0, 1);
2750 int AWindowAssets::drag_stop_event()
2754 result = gui->drag_stop();
2759 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2760 result = mwindow->gui->drag_stop();
2761 mwindow->gui->unlock_window();
2765 for( int i = 0; !result && i < mwindow->vwindows.size(); i++ ) {
2766 VWindow *vwindow = mwindow->vwindows.get(i);
2767 if( !vwindow ) continue;
2768 if( !vwindow->is_running() ) continue;
2769 if( vwindow->gui->is_hidden() ) continue;
2770 vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2771 if( vwindow->gui->cursor_above() &&
2772 vwindow->gui->get_cursor_over_window() ) {
2773 result = vwindow->gui->drag_stop();
2775 vwindow->gui->unlock_window();
2780 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
2781 result = mwindow->cwindow->gui->drag_stop();
2782 mwindow->cwindow->gui->unlock_window();
2785 lock_window("AWindowAssets::drag_stop_event");
2787 result = gui->folder_list->drag_stop();
2792 get_drag_popup()->set_animation(0);
2794 BC_ListBox::drag_stop_event();
2795 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
2796 mwindow->session->current_operation = ::NO_OPERATION;
2801 int AWindowAssets::column_resize_event()
2803 mwindow->edl->session->asset_columns[0] = get_column_width(0);
2804 mwindow->edl->session->asset_columns[1] = get_column_width(1);
2808 int AWindowAssets::focus_in_event()
2810 int ret = BC_ListBox::focus_in_event();
2811 gui->start_vicon_drawing();
2815 int AWindowAssets::focus_out_event()
2817 gui->stop_vicon_drawing();
2818 return BC_ListBox::focus_out_event();
2821 int AWindowAssets::cursor_enter_event()
2823 int ret = BC_ListBox::cursor_enter_event();
2824 gui->start_vicon_drawing();
2828 int AWindowAssets::cursor_leave_event()
2830 VIcon *vicon = gui->vicon_thread->vicon;
2831 if( vicon && vicon->playing_audio >= 0 )
2832 gui->stop_vicon_drawing();
2833 return BC_ListBox::cursor_leave_event();
2836 void AWindowAssets::update_vicon_area()
2838 int x0 = 0, x1 = get_w();
2839 int y0 = get_title_h();
2841 if( is_highlighted() ) {
2842 x0 += LISTBOX_BORDER; x1 -= LISTBOX_BORDER;
2843 y0 += LISTBOX_BORDER; y1 -= LISTBOX_BORDER;
2845 gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
2848 int AWindowAssets::mouse_over_event(int no)
2850 if( gui->vicon_thread->viewing &&
2851 no >= 0 && no < gui->displayed_assets[0].size() ) {
2852 AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no];
2853 VIcon *vicon = picon->vicon;
2854 if( gui->vicon_thread->vicon &&
2855 gui->vicon_thread->vicon->playing_audio < 0 )
2856 vicon->playing_audio = -1;
2857 picon->gui->vicon_thread->set_view_popup(vicon, draw_func);
2863 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
2864 : BC_TextBox(x, y, w, 1, "")
2866 this->search_text = search_text;
2869 int AWindowSearchTextBox::handle_event()
2871 return search_text->handle_event();
2874 AWindowSearchText::AWindowSearchText(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2876 this->mwindow = mwindow;
2882 void AWindowSearchText::create_objects()
2884 int x1 = x, y1 = y, margin = 10;
2885 gui->add_subwindow(text_title = new BC_Title(x1, y1, _("Search:")));
2886 x1 += text_title->get_w() + margin;
2887 int w1 = gui->get_w() - x1 - 2*margin;
2888 gui->add_subwindow(text_box = new AWindowSearchTextBox(this, x1, y1, w1));
2891 int AWindowSearchText::handle_event()
2893 gui->async_update_assets();
2897 int AWindowSearchText::get_w()
2899 return text_box->get_w() + text_title->get_w() + 10;
2902 int AWindowSearchText::get_h()
2904 return bmax(text_box->get_h(),text_title->get_h());
2907 void AWindowSearchText::reposition_window(int x, int y, int w)
2909 int x1 = x, y1 = y, margin = 10;
2910 text_title->reposition_window(x1, y1);
2911 x1 += text_title->get_w() + margin;
2912 int w1 = gui->get_w() - x1 - 2*margin;
2913 text_box->reposition_window(x1, y1, w1);
2916 const char *AWindowSearchText::get_text()
2918 return text_box->get_text();
2921 void AWindowSearchText::clear()
2923 text_box->update("");
2926 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2927 : BC_Button(x, y, mwindow->theme->deletedisk_data)
2929 this->mwindow = mwindow;
2931 set_tooltip(_("Delete asset from disk"));
2934 int AWindowDeleteDisk::handle_event()
2939 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2940 : BC_Button(x, y, mwindow->theme->deleteproject_data)
2942 this->mwindow = mwindow;
2944 set_tooltip(_("Delete asset from project"));
2947 int AWindowDeleteProject::handle_event()
2952 // AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2953 // : BC_Button(x, y, mwindow->theme->infoasset_data)
2955 // this->mwindow = mwindow;
2957 // set_tooltip(_("Edit information on asset"));
2960 // int AWindowInfo::handle_event()
2962 // int cur_x, cur_y;
2963 // gui->get_abs_cursor(cur_x, cur_y, 0);
2964 // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
2968 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2969 : BC_Button(x, y, mwindow->theme->redrawindex_data)
2971 this->mwindow = mwindow;
2973 set_tooltip(_("Redraw index"));
2976 int AWindowRedrawIndex::handle_event()
2981 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2982 : BC_Button(x, y, mwindow->theme->pasteasset_data)
2984 this->mwindow = mwindow;
2986 set_tooltip(_("Paste asset on recordable tracks"));
2989 int AWindowPaste::handle_event()
2994 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
2995 : BC_Button(x, y, mwindow->theme->appendasset_data)
2997 this->mwindow = mwindow;
2999 set_tooltip(_("Append asset in new tracks"));
3002 int AWindowAppend::handle_event()
3007 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
3008 : BC_Button(x, y, mwindow->theme->viewasset_data)
3010 this->mwindow = mwindow;
3012 set_tooltip(_("View asset"));
3015 int AWindowView::handle_event()
3020 AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
3021 : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
3023 this->mwindow = mwindow;
3027 void AddTools::create_objects()
3030 add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
3031 vis |= 1 << PLUGIN_FFMPEG_ID;
3032 add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
3033 vis |= 1 << PLUGIN_LADSPA_ID;
3035 add_item(new AddPluginItem(this, "lv2", PLUGIN_LV2_ID));
3036 vis |= 1 << PLUGIN_LV2_ID;
3038 for( int i=0; i<MWindow::plugindb->size(); ++i ) {
3039 PluginServer *plugin = MWindow::plugindb->get(i);
3040 if( !plugin->audio && !plugin->video ) continue;
3041 int idx = plugin->dir_idx;
3042 uint32_t msk = 1 << idx;
3043 if( (msk & vis) != 0 ) continue;
3045 char parent[BCTEXTLEN];
3046 strcpy(parent, plugin->path);
3047 char *bp = strrchr(parent, '/');
3048 if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
3049 if( !bp ) bp = parent; else ++bp;
3050 add_item(new AddPluginItem(this, bp, idx));
3055 // plugin_dirs list from toplevel makefile include plugin_defs
3060 N_("audio_transitions")
3067 N_("video_transitions")
3070 AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
3071 : BC_MenuItem(_(text))
3075 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3076 int chk = (msk & vis) ? 1 : 0;
3080 int AddPluginItem::handle_event()
3082 int chk = get_checked() ^ 1;
3084 uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
3085 menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
3086 menu->gui->update_effects();
3087 menu->gui->save_defaults(menu->mwindow->defaults);
3088 menu->gui->async_update_assets();
3092 AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
3093 : BC_Toggle(x, y, images, agui->vicon_drawing)
3096 set_tooltip(_("Preview"));
3099 void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
3101 int text_line = -1, toggle_x = -1, toggle_y = -1;
3102 int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
3103 BC_Toggle::calculate_extents(agui, images, 1,
3104 &text_line, ww, hh, &toggle_x, &toggle_y,
3105 &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
3108 AVIconDrawing::~AVIconDrawing()
3112 int AVIconDrawing::handle_event()
3114 agui->vicon_drawing = get_value();
3115 if( agui->vicon_drawing )
3116 agui->start_vicon_drawing();
3118 agui->stop_vicon_drawing();
3123 AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
3124 : BC_MenuItem("","v",'v')
3126 this->mwindow = mwindow;
3130 int AWindowListFormat::handle_event()
3132 return gui->cycle_assetlist_format();
3135 void AWindowListFormat::update()
3137 EDLSession *session = mwindow->edl->session;
3138 const char *text = 0;
3139 switch( session->assetlist_format ) {
3141 text = _("Display icons");
3144 text = _("Display icons packed");
3146 case ASSETS_ICONS_PACKED:
3147 text = _("Display icon list");
3149 case ASSETS_ICON_LIST:
3150 text = _("Display text");
3156 AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
3157 : BC_MenuItem(_("Sort items"))
3159 this->mwindow = mwindow;
3163 int AWindowListSort::handle_event()
3169 AssetSelectUsedItem::AssetSelectUsedItem(AssetSelectUsed *select_used, const char *text, int action)
3172 this->select_used = select_used;
3173 this->action = action;
3176 int AssetSelectUsedItem::handle_event()
3178 MWindow *mwindow = select_used->mwindow;
3179 AWindowGUI *gui = select_used->gui;
3180 AWindowAssets *asset_list = gui->asset_list;
3181 ArrayList<BC_ListBoxItem*> *data = gui->displayed_assets;
3186 asset_list->set_all_selected(data, action==SELECT_ALL ? 1 : 0);
3190 asset_list->set_all_selected(data, 0);
3191 for( int i = 0; i < data->total; i++ ) {
3192 AssetPicon *picon = (AssetPicon*)data->values[i];
3193 Indexable *idxbl = picon->indexable ? picon->indexable :
3194 picon->edl ? picon->edl->get_proxy_asset() : 0;
3195 int used = idxbl && mwindow->edl->in_use(idxbl) ? 1 : 0;
3196 asset_list->set_selected(data, i, action==SELECT_USED ? used : !used);
3201 int asset_xposition = asset_list->get_xposition();
3202 int asset_yposition = asset_list->get_yposition();
3203 asset_list->update(gui->displayed_assets, gui->asset_titles,
3204 mwindow->edl->session->asset_columns, ASSET_COLUMNS,
3205 asset_xposition, asset_yposition, -1, 0);
3206 asset_list->center_selection();
3210 AssetSelectUsed::AssetSelectUsed(MWindow *mwindow, AWindowGUI *gui)
3211 : BC_MenuItem(_("Select"))
3213 this->mwindow = mwindow;