r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / awindowgui.C
blob92dd41993fa9925d24b5af78400dfe10b8803307
1 #include "asset.h"
2 #include "assetedit.h"
3 #include "assetpopup.h"
4 #include "assets.h"
5 #include "awindowgui.h"
6 #include "awindowgui.inc"
7 #include "awindow.h"
8 #include "awindowmenu.h"
9 #include "cache.h"
10 #include "colormodels.h"
11 #include "cursors.h"
12 #include "cwindowgui.h"
13 #include "cwindow.h"
14 #include "edl.h"
15 #include "edlsession.h"
16 #include "file.h"
17 #include "filesystem.h"
18 #include "language.h"
19 #include "localsession.h"
20 #include "mainmenu.h"
21 #include "mainsession.h"
22 #include "mwindowgui.h"
23 #include "mwindow.h"
24 #include "newfolder.h"
25 #include "preferences.h"
26 #include "theme.h"
27 #include "vframe.h"
28 #include "vwindowgui.h"
29 #include "vwindow.h"
34 AssetPicon::AssetPicon(MWindow *mwindow, 
35         AWindowGUI *gui, 
36         Asset *asset)
37  : BC_ListBoxItem()
39         reset();
40         this->mwindow = mwindow;
41         this->gui = gui;
42         this->asset = asset;
43         this->id = asset->id;
46 AssetPicon::AssetPicon(MWindow *mwindow, 
47         AWindowGUI *gui, 
48         EDL *edl)
49  : BC_ListBoxItem()
51         reset();
52         this->mwindow = mwindow;
53         this->gui = gui;
54         this->edl = edl;
55         this->id = edl->id;
58 AssetPicon::AssetPicon(MWindow *mwindow, 
59         AWindowGUI *gui, 
60         char *folder)
61  : BC_ListBoxItem(folder, gui->folder_icon)
63         reset();
64         this->mwindow = mwindow;
65         this->gui = gui;
68 AssetPicon::AssetPicon(MWindow *mwindow, 
69         AWindowGUI *gui, 
70         PluginServer *plugin)
71  : BC_ListBoxItem()
73         reset();
74         this->mwindow = mwindow;
75         this->gui = gui;
76         this->plugin = plugin;
77         asset = 0;
78         icon = 0;
79         id = 0;
82 AssetPicon::~AssetPicon()
84         if(icon)
85         {
86                 if(icon != gui->file_icon &&
87                         icon != gui->audio_icon &&
88                         icon != gui->folder_icon &&
89                         icon != gui->clip_icon &&
90                         icon != gui->video_icon) delete icon;
91         }
94 void AssetPicon::reset()
96         plugin = 0;
97         asset = 0;
98         edl = 0;
99         icon = 0;
100         in_use = 1;
101         id = 0;
102         persistent = 0;
105 void AssetPicon::create_objects()
107         FileSystem fs;
108         char name[BCTEXTLEN];
109         VFrame *frame = 0;
110         int pixmap_w, pixmap_h;
113         pixmap_h = 50;
115         if(asset)
116         {
117                 fs.extract_name(name, asset->path);
118                 set_text(name);
119                 if(asset->video_data)
120                 {
121                         if(mwindow->preferences->use_thumbnails)
122                         {
123 //printf("AssetPicon::create_objects 1\n");
124                                 File *file = mwindow->video_cache->check_out(asset);
125 //printf("AssetPicon::create_objects 2\n");
127                                 if(file)
128                                 {
129                                         pixmap_w = pixmap_h * asset->width / asset->height;
131 //printf("AssetPicon::create_objects 3\n");
132                                         file->set_layer(0);
133                                         file->set_video_position(0, mwindow->edl->session->frame_rate);
134                                         frame = file->read_frame(BC_RGB888);
135 //printf("AssetPicon::create_objects 4\n");
137                                         if(frame)
138                                         {
139                                                 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
140                                                 icon->draw_vframe(frame,
141                                                         0, 
142                                                         0, 
143                                                         pixmap_w, 
144                                                         pixmap_h,
145                                                         0,
146                                                         0);
147                                         }
148 //printf("AssetPicon::create_objects 5\n");
150                                         mwindow->video_cache->check_in(asset);
151 //printf("AssetPicon::create_objects 6\n");
152                                 }
153                                 else
154                                 {
155                                         icon = gui->video_icon;
156                                 }
157                         }
158                         else
159                         {
160                                 icon = gui->video_icon;
161                         }
162                 }
163                 else
164                 if(asset->audio_data)
165                 {
166                         icon = gui->audio_icon;
167                 }
168 //printf("AssetPicon::create_objects 2\n");
170                 set_icon(icon);
171 //printf("AssetPicon::create_objects 4\n");
172         }
173         else
174         if(edl)
175         {
176 //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
177                 strcpy(name, edl->local_session->clip_title);
178                 set_text(name);
179                 set_icon(gui->clip_icon);
180         }
181         else
182         if(plugin)
183         {
184                 strcpy(name, plugin->title);
185                 set_text(name);
186                 if(plugin->picon)
187                 {
188                         if(plugin->picon->get_color_model() == BC_RGB888)
189                         {
190                                 icon = new BC_Pixmap(gui, 
191                                         plugin->picon->get_w(), 
192                                         plugin->picon->get_h());
193                                 icon->draw_vframe(plugin->picon,
194                                         0,
195                                         0,
196                                         plugin->picon->get_w(), 
197                                         plugin->picon->get_h(),
198                                         0,
199                                         0);
200                         }
201                         else
202                         {
203                                 icon = new BC_Pixmap(gui, 
204                                         plugin->picon, 
205                                         PIXMAP_ALPHA);
206                         }
207                 }
208                 else
209                 {
210                         icon = gui->file_icon;
211                 }
212                 set_icon(icon);
213         }
222 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
223  : BC_Window(PROGRAM_NAME ": Resources",
224         mwindow->session->awindow_x, 
225     mwindow->session->awindow_y, 
226     mwindow->session->awindow_w, 
227     mwindow->session->awindow_h,
228     100,
229     100,
230     1,
231     1,
232     1)
234 // printf("AWindowGUI::AWindowGUI %d %d %d %d\n",
235 // mwindow->session->awindow_x, 
236 // mwindow->session->awindow_y, 
237 // mwindow->session->awindow_w, 
238 // mwindow->session->awindow_h);
239         this->mwindow = mwindow;
240         this->awindow = awindow;
243 AWindowGUI::~AWindowGUI()
245         assets.remove_all_objects();
246         folders.remove_all_objects();
247         aeffects.remove_all_objects();
248         veffects.remove_all_objects();
249         atransitions.remove_all_objects();
250         vtransitions.remove_all_objects();
251         displayed_assets[1].remove_all_objects();
252         delete file_icon;
253         delete audio_icon;
254         delete folder_icon;
255         delete clip_icon;
256         delete newfolder_thread;
257         delete asset_menu;
258         delete assetlist_menu;
259         delete folderlist_menu;
262 int AWindowGUI::create_objects()
264         int x, y;
265         AssetPicon *picon;
267 //printf("AWindowGUI::create_objects 1\n");
268         asset_titles[0] = _("Title");
269         asset_titles[1] = _("Comments");
271         set_icon(mwindow->theme->awindow_icon);
272         file_icon = new BC_Pixmap(this, 
273                 BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
274                 PIXMAP_ALPHA);
276         folder_icon = new BC_Pixmap(this, 
277                 BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
278                 PIXMAP_ALPHA);
280         audio_icon = new BC_Pixmap(this, 
281                 BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
282                 PIXMAP_ALPHA);
284         video_icon = new BC_Pixmap(this, 
285                 BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
286                 PIXMAP_ALPHA);
288         clip_icon = new BC_Pixmap(this, 
289                 mwindow->theme->clip_icon,
290                 PIXMAP_ALPHA);
292 // Mandatory folders
293         folders.append(picon = new AssetPicon(mwindow,
294                 this,
295                 AEFFECT_FOLDER));
296         picon->persistent = 1;
297         folders.append(picon = new AssetPicon(mwindow,
298                 this,
299                 VEFFECT_FOLDER));
300         picon->persistent = 1;
301         folders.append(picon = new AssetPicon(mwindow,
302                 this,
303                 ATRANSITION_FOLDER));
304         picon->persistent = 1;
305         folders.append(picon = new AssetPicon(mwindow,
306                 this,
307                 VTRANSITION_FOLDER));
308         picon->persistent = 1;
310         create_persistent_folder(&aeffects, 1, 0, 1, 0);
311         create_persistent_folder(&veffects, 0, 1, 1, 0);
312         create_persistent_folder(&atransitions, 1, 0, 0, 1);
313         create_persistent_folder(&vtransitions, 0, 1, 0, 1);
315         mwindow->theme->get_awindow_sizes(this);
316         add_subwindow(asset_list = new AWindowAssets(mwindow,
317                 this,
318                 mwindow->theme->alist_x, 
319         mwindow->theme->alist_y, 
320         mwindow->theme->alist_w, 
321         mwindow->theme->alist_h));
322         add_subwindow(divider = new AWindowDivider(mwindow,
323                 this,
324                 mwindow->theme->adivider_x,
325                 mwindow->theme->adivider_y,
326                 mwindow->theme->adivider_w,
327                 mwindow->theme->adivider_h));
328         divider->set_cursor(HSEPARATE_CURSOR);
329         add_subwindow(folder_list = new AWindowFolders(mwindow,
330                 this,
331                 mwindow->theme->afolders_x, 
332         mwindow->theme->afolders_y, 
333         mwindow->theme->afolders_w, 
334         mwindow->theme->afolders_h));
335         
336         x = mwindow->theme->abuttons_x;
337         y = mwindow->theme->abuttons_y;
339         newfolder_thread = new NewFolderThread(mwindow, this);
341         add_subwindow(asset_menu = new AssetPopup(mwindow, this));
342         asset_menu->create_objects();
344         add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
345         assetlist_menu->create_objects();
347         add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
348         folderlist_menu->create_objects();
349 //printf("AWindowGUI::create_objects 2\n");
351         return 0;
354 int AWindowGUI::resize_event(int w, int h)
356         mwindow->session->awindow_x = get_x();
357         mwindow->session->awindow_y = get_y();
358         mwindow->session->awindow_w = w;
359         mwindow->session->awindow_h = h;
361         mwindow->theme->get_awindow_sizes(this);
362         mwindow->theme->draw_awindow_bg(this);
364         asset_list->reposition_window(mwindow->theme->alist_x, 
365         mwindow->theme->alist_y, 
366         mwindow->theme->alist_w, 
367         mwindow->theme->alist_h);
368         divider->reposition_window(mwindow->theme->adivider_x,
369                 mwindow->theme->adivider_y,
370                 mwindow->theme->adivider_w,
371                 mwindow->theme->adivider_h);
372         folder_list->reposition_window(mwindow->theme->afolders_x, 
373         mwindow->theme->afolders_y, 
374         mwindow->theme->afolders_w, 
375         mwindow->theme->afolders_h);
376         
377         int x = mwindow->theme->abuttons_x;
378         int y = mwindow->theme->abuttons_y;
380 //      new_bin->reposition_window(x, y);
381 //      x += new_bin->get_w();
382 //      delete_bin->reposition_window(x, y);
383 //      x += delete_bin->get_w();
384 //      rename_bin->reposition_window(x, y);
385 //      x += rename_bin->get_w();
386 //      delete_disk->reposition_window(x, y);
387 //      x += delete_disk->get_w();
388 //      delete_project->reposition_window(x, y);
389 //      x += delete_project->get_w();
390 //      info->reposition_window(x, y);
391 //      x += info->get_w();
392 //      redraw_index->reposition_window(x, y);
393 //      x += redraw_index->get_w();
394 //      paste->reposition_window(x, y);
395 //      x += paste->get_w();
396 //      append->reposition_window(x, y);
397 //      x += append->get_w();
398 //      view->reposition_window(x, y);
400         BC_WindowBase::resize_event(w, h);
401         return 1;
404 int AWindowGUI::translation_event()
406         mwindow->session->awindow_x = get_x();
407         mwindow->session->awindow_y = get_y();
408         return 0;
411 void AWindowGUI::reposition_objects()
413         mwindow->theme->get_awindow_sizes(this);
414         asset_list->reposition_window(mwindow->theme->alist_x, 
415         mwindow->theme->alist_y, 
416         mwindow->theme->alist_w, 
417         mwindow->theme->alist_h);
418         divider->reposition_window(mwindow->theme->adivider_x,
419                 mwindow->theme->adivider_y,
420                 mwindow->theme->adivider_w,
421                 mwindow->theme->adivider_h);
422         folder_list->reposition_window(mwindow->theme->afolders_x, 
423         mwindow->theme->afolders_y, 
424         mwindow->theme->afolders_w, 
425         mwindow->theme->afolders_h);
426         flush();
429 int AWindowGUI::close_event()
431         hide_window();
432         mwindow->session->show_awindow = 0;
433         mwindow->gui->lock_window("AWindowGUI::close_event");
434         mwindow->gui->mainmenu->show_awindow->set_checked(0);
435         mwindow->gui->unlock_window();
436         mwindow->save_defaults();
437         return 1;
441 int AWindowGUI::keypress_event()
443         switch(get_keypress())
444         {
445                 case 'w':
446                 case 'W':
447                         if(ctrl_down())
448                         {
449                                 close_event();
450                                 return 1;
451                         }
452                         break;
453         }
454         return 0;
457 void AWindowGUI::update_folder_list()
459 //printf("AWindowGUI::update_folder_list 1\n");
460         for(int i = 0; i < folders.total; i++)
461         {
462                 AssetPicon *picon = (AssetPicon*)folders.values[i];
463                 picon->in_use--;
464         }
465 //printf("AWindowGUI::update_folder_list 1\n");
467 // Search assets for folders
468         for(int i = 0; i < mwindow->edl->folders.total; i++)
469         {
470                 char *folder = mwindow->edl->folders.values[i];
471                 int exists = 0;
472 //printf("AWindowGUI::update_folder_list 1.1\n");
474                 for(int j = 0; j < folders.total; j++)
475                 {
476                         AssetPicon *picon = (AssetPicon*)folders.values[j];
477                         if(!strcasecmp(picon->get_text(), folder))
478                         {
479                                 exists = 1;
480                                 picon->in_use = 1;
481                                 break;
482                         }
483                 }
485                 if(!exists)
486                 {
487                         AssetPicon *picon = new AssetPicon(mwindow, this, folder);
488                         picon->create_objects();
489                         folders.append(picon);
490                 }
491 //printf("AWindowGUI::update_folder_list 1.3\n");
492         }
493 //printf("AWindowGUI::update_folder_list 1\n");
494 //for(int i = 0; i < folders.total; i++)
495 //      printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
497 // Delete excess
498         for(int i = folders.total - 1; i >= 0; i--)
499         {
500                 AssetPicon *picon = (AssetPicon*)folders.values[i];
501                 if(!picon->in_use && !picon->persistent)
502                 {
503                         delete picon;
504                         folders.remove_number(i);
505                 }
506         }
507 //for(int i = 0; i < folders.total; i++)
508 //      printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
509 //printf("AWindowGUI::update_folder_list 2\n");
512 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output, 
513         int do_audio, 
514         int do_video, 
515         int is_realtime, 
516         int is_transition)
518         ArrayList<PluginServer*> plugindb;
520 // Get pointers to plugindb entries
521         mwindow->create_plugindb(do_audio, 
522                         do_video, 
523                         is_realtime, 
524                         is_transition,
525                         0,
526                         plugindb);
528         for(int i = 0; i < plugindb.total; i++)
529         {
530                 PluginServer *server = plugindb.values[i];
531                 int exists = 0;
533 // Create new listitem
534                 if(!exists)
535                 {
536                         AssetPicon *picon = new AssetPicon(mwindow, this, server);
537                         picon->create_objects();
538                         output->append(picon);
539                 }
540         }
543 void AWindowGUI::update_asset_list()
545 //printf("AWindowGUI::update_asset_list 1\n");
546         for(int i = 0; i < assets.total; i++)
547         {
548                 AssetPicon *picon = (AssetPicon*)assets.values[i];
549                 picon->in_use--;
550         }
556 //printf("AWindowGUI::update_asset_list 1\n");
559 // Synchronize EDL clips
560         for(int i = 0; i < mwindow->edl->clips.total; i++)
561         {
562                 int exists = 0;
563                 
564 // Look for clip in existing listitems
565                 for(int j = 0; j < assets.total && !exists; j++)
566                 {
567                         AssetPicon *picon = (AssetPicon*)assets.values[j];
568                         
569                         if(picon->id == mwindow->edl->clips.values[i]->id)
570                         {
571                                 picon->edl = mwindow->edl->clips.values[i];
572                                 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
573                                 exists = 1;
574                                 picon->in_use = 1;
575                         }
576                 }
578 // Create new listitem
579                 if(!exists)
580                 {
581                         AssetPicon *picon = new AssetPicon(mwindow, 
582                                 this, 
583                                 mwindow->edl->clips.values[i]);
584                         picon->create_objects();
585                         assets.append(picon);
586                 }
587         }
595 //printf("AWindowGUI::update_asset_list 2 %d\n", assets.total);
596 // Synchronize EDL assets
597         for(Asset *current = mwindow->edl->assets->first; 
598                 current; 
599                 current = NEXT)
600         {
601                 int exists = 0;
603 //printf("AWindowGUI::update_asset_list 3 %s\n", current->path);
604 // Look for asset in existing listitems
605                 for(int j = 0; j < assets.total && !exists; j++)
606                 {
607                         AssetPicon *picon = (AssetPicon*)assets.values[j];
609                         if(picon->id == current->id)
610                         {
611 //printf("AWindowGUI::update_asset_list 4 %p %d %d\n", picon->asset, picon->get_icon_x(), picon->get_icon_y());
612                                 picon->asset = current;
613                                 exists = 1;
614                                 picon->in_use = 1;
615                                 break;
616                         }
617                 }
619 //printf("AWindowGUI::update_asset_list 5\n");
620 // Create new listitem
621                 if(!exists)
622                 {
623 //printf("AWindowGUI::update_asset_list 4.1 %s\n", current->path);
624                         AssetPicon *picon = new AssetPicon(mwindow, this, current);
625 //printf("AWindowGUI::update_asset_list 4.2 %s\n", current->path);
626                         picon->create_objects();
627 //printf("AWindowGUI::update_asset_list 4.3 %s\n", current->path);
628                         assets.append(picon);
629 //printf("AWindowGUI::update_asset_list 4.4 %s\n", current->path);
630                 }
631         }
641 //printf("AWindowGUI::update_asset_list 6\n");
642         for(int i = assets.total - 1; i >= 0; i--)
643         {
644                 AssetPicon *picon = (AssetPicon*)assets.values[i];
645 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
646                 if(!picon->in_use)
647                 {
648                         delete picon;
649                         assets.remove_number(i);
650                 }
651         }
652 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
659 void AWindowGUI::sort_assets()
661 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
662         if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
663                 sort_picons(&aeffects, 
664                         0);
665         else
666         if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
667                 sort_picons(&veffects, 
668                         0);
669         else
670         if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
671                 sort_picons(&atransitions, 
672                         0);
673         else
674         if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
675                 sort_picons(&vtransitions, 
676                         0);
677         else
678                 sort_picons(&assets, 
679                         mwindow->edl->session->current_folder);
681         update_assets();
694 void AWindowGUI::collect_assets()
696         int i = 0;
697         mwindow->session->drag_assets->remove_all();
698         mwindow->session->drag_clips->remove_all();
699         while(1)
700         {
701                 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
702                 if(!result) break;
704                 if(result->asset) mwindow->session->drag_assets->append(result->asset);
705                 if(result->edl) mwindow->session->drag_clips->append(result->edl);
706         }
709 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst, 
710         ArrayList<BC_ListBoxItem*> *src, 
711         char *folder)
713 // Remove current pointers
714         dst[0].remove_all();
715         dst[1].remove_all_objects();
717 // Create new pointers
718 //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
719         for(int i = 0; i < src->total; i++)
720         {
721                 AssetPicon *picon = (AssetPicon*)src->values[i];
722 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
723                 if(!folder ||
724                         (folder && picon->asset && !strcasecmp(picon->asset->folder, folder)) ||
725                         (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
726                 {
727                         BC_ListBoxItem *item2, *item1;
728                         dst[0].append(item1 = picon);
729                         if(picon->edl)
730                                 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
731                         else
732                                 dst[1].append(item2 = new BC_ListBoxItem(""));
733                         item1->set_autoplace_text(1);
734                         item2->set_autoplace_text(1);
735 //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
736                 }
737         }
740 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, 
741                 char *folder)
743 //printf("AWindowGUI::sort_picons 1\n")
744         int done = 0;
745         while(!done)
746         {
747                 done = 1;
748                 for(int i = 0; i < src->total - 1; i++)
749                 {
750                         BC_ListBoxItem *item1 = src->values[i];
751                         BC_ListBoxItem *item2 = src->values[i + 1];
752                         item1->set_autoplace_icon(1);
753                         item2->set_autoplace_icon(1);
754                         item1->set_autoplace_text(1);
755                         item2->set_autoplace_text(1);
756                         if(strcmp(item1->get_text(), item2->get_text()) > 0)
757                         {
758                                 src->values[i + 1] = item1;
759                                 src->values[i] = item2;
760                                 done = 0;
761                         }
762                 }
763         }
767 void AWindowGUI::filter_displayed_assets()
769         if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
770                 copy_picons(displayed_assets, 
771                         &aeffects, 
772                         0);
773         else
774         if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
775                 copy_picons(displayed_assets, 
776                         &veffects, 
777                         0);
778         else
779         if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
780                 copy_picons(displayed_assets, 
781                         &atransitions, 
782                         0);
783         else
784         if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
785                 copy_picons(displayed_assets, 
786                         &vtransitions, 
787                         0);
788         else
789                 copy_picons(displayed_assets, 
790                         &assets, 
791                         mwindow->edl->session->current_folder);
795 void AWindowGUI::update_assets()
797 //printf("AWindowGUI::update_assets 1\n");
798         update_folder_list();
799 //printf("AWindowGUI::update_assets 2\n");
800         update_asset_list();
801 //printf("AWindowGUI::update_assets 3\n");
802         filter_displayed_assets();
804 //for(int i = 0; i < folders.total; i++)
805 //printf("AWindowGUI::update_assets 4\n");
806 //      printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
807         if(mwindow->edl->session->folderlist_format != folder_list->get_format())
808                 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
809         folder_list->update(&folders,
810                 0,
811                 0,
812                 1,
813                 folder_list->get_xposition(),
814                 folder_list->get_yposition(),
815                 -1);
816 //printf("AWindowGUI::update_assets 5\n");
818         if(mwindow->edl->session->assetlist_format != asset_list->get_format())
819                 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
822 //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
823         asset_list->update(displayed_assets,
824                 asset_titles,
825                 mwindow->edl->session->asset_columns,
826                 ASSET_COLUMNS, 
827                 asset_list->get_xposition(),
828                 asset_list->get_yposition(),
829                 -1,
830                 0);
831 //printf("AWindowGUI::update_assets 7\n");
833         flush();
834 //printf("AWindowGUI::update_assets 8\n");
835         return;
838 int AWindowGUI::current_folder_number()
840         int result = -1;
841         for(int i = 0; i < folders.total; i++)
842         {
843                 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
844                 {
845                         result = i;
846                         break;
847                 }
848         }
849         return result;
852 int AWindowGUI::drag_motion()
854         if(get_hidden()) return 0;
856         int result = 0;
857         return result;
860 int AWindowGUI::drag_stop()
862         if(get_hidden()) return 0;
864         return 0;
867 Asset* AWindowGUI::selected_asset()
869         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
870         if(picon) return picon->asset;
873 PluginServer* AWindowGUI::selected_plugin()
875         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
876         if(picon) return picon->plugin;
879 AssetPicon* AWindowGUI::selected_folder()
881         AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
882     return picon;
894 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
895  : BC_SubWindow(x, y, w, h)
897         this->mwindow = mwindow;
898         this->gui = gui;
900 AWindowDivider::~AWindowDivider()
904 int AWindowDivider::button_press_event()
906         if(is_event_win() && cursor_inside())
907         {
908                 mwindow->session->current_operation = DRAG_PARTITION;
909                 return 1;
910         }
911         return 0;
914 int AWindowDivider::cursor_motion_event()
916         if(mwindow->session->current_operation == DRAG_PARTITION)
917         {
918                 mwindow->session->afolders_w = gui->get_relative_cursor_x();
919                 gui->reposition_objects();
920         }
921         return 0;
924 int AWindowDivider::button_release_event()
926         if(mwindow->session->current_operation == DRAG_PARTITION)
927         {
928                 mwindow->session->current_operation = NO_OPERATION;
929                 return 1;
930         }
931         return 0;
939 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
940  : BC_ListBox(x, 
941                 y, 
942                 w, 
943                 h,
944                 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ? 
945                         LISTBOX_ICONS : LISTBOX_TEXT, 
946                 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
947                 0,             // Titles for columns.  Set to 0 for no titles
948                 0,                // width of each column
949                 1,                      // Total columns.
950                 0,                    // Pixel of top of window.
951                 0,                        // If this listbox is a popup window
952                 LISTBOX_SINGLE,  // Select one item or multiple items
953                 ICON_TOP,        // Position of icon relative to text of each item
954                 1)               // Allow drags
956         this->mwindow = mwindow;
957         this->gui = gui;
958         set_drag_scroll(0);
961 AWindowFolders::~AWindowFolders()
964         
965 int AWindowFolders::selection_changed()
967         AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
968         if(picon)
969         {
970                 strcpy(mwindow->edl->session->current_folder, picon->get_text());
971 //printf("AWindowFolders::selection_changed 1\n");
972                 gui->asset_list->draw_background();
973                 gui->update_assets();
974         }
975         return 1;
978 int AWindowFolders::button_press_event()
980         int result = 0;
982         result = BC_ListBox::button_press_event();
984         if(!result)
985         {
986                 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
987                 {
988                         gui->folderlist_menu->update_titles();
989                         gui->folderlist_menu->activate_menu();
990                         result = 1;
991                 }
992         }
995         return result;
1004 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1005  : BC_ListBox(x, 
1006                 y, 
1007                 w, 
1008                 h,
1009                 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? 
1010                         LISTBOX_ICONS : LISTBOX_TEXT,
1011                 &gui->assets,     // Each column has an ArrayList of BC_ListBoxItems.
1012                 gui->asset_titles,             // Titles for columns.  Set to 0 for no titles
1013                 mwindow->edl->session->asset_columns,                // width of each column
1014                 1,                      // Total columns.
1015                 0,                    // Pixel of top of window.
1016                 0,                        // If this listbox is a popup window
1017                 LISTBOX_MULTIPLE,  // Select one item or multiple items
1018                 ICON_TOP,        // Position of icon relative to text of each item
1019                 1)               // Allow drag
1021         this->mwindow = mwindow;
1022         this->gui = gui;
1023         set_drag_scroll(0);
1026 AWindowAssets::~AWindowAssets()
1030 int AWindowAssets::button_press_event()
1032         int result = 0;
1034         result = BC_ListBox::button_press_event();
1036         if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
1037         {
1038                 BC_ListBox::deactivate_selection();
1039                 gui->assetlist_menu->update_titles();
1040                 gui->assetlist_menu->activate_menu();
1041                 result = 1;
1042         }
1045         return result;
1049 int AWindowAssets::handle_event()
1051 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
1052         if(get_selection(0, 0))
1053         {
1054                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1055                 {
1056                 }
1057                 else
1058                 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1059                 {
1060                 }
1061                 else
1062                 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1063                 {
1064                 }
1065                 else
1066                 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1067                 {
1068                 }
1069                 else
1070                 {
1071 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1072                         mwindow->vwindow->gui->lock_window("AWindowAssets::handle_event");
1073                         
1074                         if(((AssetPicon*)get_selection(0, 0))->asset)
1075                                 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->asset);
1076                         else
1077                         if(((AssetPicon*)get_selection(0, 0))->edl)
1078                                 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1080                         mwindow->vwindow->gui->unlock_window();
1081                 }
1082                 return 1;
1083         }
1085         return 0;
1088 int AWindowAssets::selection_changed()
1090 // Show popup window
1091         if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1092         {
1093                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) || 
1094                         !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1095                         !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1096                         !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1097                 {
1098                         gui->assetlist_menu->update_titles();
1099                         gui->assetlist_menu->activate_menu();
1100                 }
1101                 else
1102                 {
1103                         if(((AssetPicon*)get_selection(0, 0))->asset)
1104                                 gui->asset_menu->update();
1105                         else
1106                         if(((AssetPicon*)get_selection(0, 0))->edl)
1107                                 gui->asset_menu->update();
1111                         gui->asset_menu->activate_menu();
1112                 }
1114                 BC_ListBox::deactivate_selection();
1115                 return 1;
1116         }
1117         return 0;
1120 void AWindowAssets::draw_background()
1122 //printf("AWindowAssets::draw_background %s\n", mwindow->edl->session->current_folder);
1123         BC_ListBox::draw_background();
1124         set_color(RED);
1125         set_font(LARGEFONT);
1126         draw_text(get_w() - 
1127                         get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4, 
1128                 30, 
1129                 mwindow->edl->session->current_folder, 
1130                 -1, 
1131                 get_bg_surface());
1134 int AWindowAssets::drag_start_event()
1136         int collect_pluginservers = 0;
1137         int collect_assets = 0;
1139         if(BC_ListBox::drag_start_event())
1140         {
1141                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1142                 {
1143                         mwindow->session->current_operation = DRAG_AEFFECT;
1144                         collect_pluginservers = 1;
1145                 }
1146                 else
1147                 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1148                 {
1149                         mwindow->session->current_operation = DRAG_VEFFECT;
1150                         collect_pluginservers = 1;
1151                 }
1152                 else
1153                 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1154                 {
1155                         mwindow->session->current_operation = DRAG_ATRANSITION;
1156                         collect_pluginservers = 1;
1157                 }
1158                 else
1159                 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1160                 {
1161                         mwindow->session->current_operation = DRAG_VTRANSITION;
1162                         collect_pluginservers = 1;
1163                 }
1164                 else
1165                 {
1166                         mwindow->session->current_operation = DRAG_ASSET;
1167                         collect_assets = 1;
1168                 }
1169                 
1170                 
1171                 if(collect_pluginservers)
1172                 {
1173                         int i = 0;
1174                         mwindow->session->drag_pluginservers->remove_all();
1175                         while(1)
1176                         {
1177                                 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1178                                 if(!result) break;
1179                                 
1180                                 mwindow->session->drag_pluginservers->append(result->plugin);
1181                         }
1182                 }
1183                 
1184                 if(collect_assets)
1185                 {
1186                         gui->collect_assets();
1187                 }
1189                 return 1;
1190         }
1191         return 0;
1194 int AWindowAssets::drag_motion_event()
1196         BC_ListBox::drag_motion_event();
1198         mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1199         mwindow->gui->drag_motion();
1200         mwindow->gui->unlock_window();
1202         mwindow->vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1203         mwindow->vwindow->gui->drag_motion();
1204         mwindow->vwindow->gui->unlock_window();
1206         mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
1207         mwindow->cwindow->gui->drag_motion();
1208         mwindow->cwindow->gui->unlock_window();
1209         return 0;
1212 int AWindowAssets::drag_stop_event()
1214         int result = 0;
1216         result = gui->drag_stop();
1219         if(!result)
1220         {
1221                 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1222                 result = mwindow->gui->drag_stop();
1223                 mwindow->gui->unlock_window();
1224         }
1226         if(!result) 
1227         {
1228                 mwindow->vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1229                 result = mwindow->vwindow->gui->drag_stop();
1230                 mwindow->vwindow->gui->unlock_window();
1231         }
1233         if(!result) 
1234         {
1235                 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
1236                 result = mwindow->cwindow->gui->drag_stop();
1237                 mwindow->cwindow->gui->unlock_window();
1238         }
1242         if(result) get_drag_popup()->set_animation(0);
1244         BC_ListBox::drag_stop_event();
1245         return 0;
1248 int AWindowAssets::column_resize_event()
1250         mwindow->edl->session->asset_columns[0] = get_column_width(0);
1251         mwindow->edl->session->asset_columns[1] = get_column_width(1);
1252         return 1;
1266 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1267  : BC_Button(x, y, mwindow->theme->newbin_data)
1269         this->mwindow = mwindow;
1270         this->gui = gui;
1271         set_tooltip(_("New bin"));
1274 int AWindowNewFolder::handle_event()
1276         gui->newfolder_thread->start_new_folder();
1277         return 1;
1280 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1281  : BC_Button(x, y, mwindow->theme->deletebin_data)
1283         this->mwindow = mwindow;
1284         this->gui = gui;
1285         set_tooltip(_("Delete bin"));
1288 int AWindowDeleteFolder::handle_event()
1290         if(gui->folder_list->get_selection(0, 0))
1291         {
1292                 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1293                 mwindow->delete_folder(folder->get_text());
1294         }
1295         return 1;
1298 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1299  : BC_Button(x, y, mwindow->theme->renamebin_data)
1301         this->mwindow = mwindow;
1302         this->gui = gui;
1303         set_tooltip(_("Rename bin"));
1306 int AWindowRenameFolder::handle_event()
1308         return 1;
1311 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1312  : BC_Button(x, y, mwindow->theme->deletedisk_data)
1314         this->mwindow = mwindow;
1315         this->gui = gui;
1316         set_tooltip(_("Delete asset from disk"));
1319 int AWindowDeleteDisk::handle_event()
1321         return 1;
1324 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1325  : BC_Button(x, y, mwindow->theme->deleteproject_data)
1327         this->mwindow = mwindow;
1328         this->gui = gui;
1329         set_tooltip(_("Delete asset from project"));
1332 int AWindowDeleteProject::handle_event()
1334         return 1;
1337 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1338  : BC_Button(x, y, mwindow->theme->infoasset_data)
1340         this->mwindow = mwindow;
1341         this->gui = gui;
1342         set_tooltip(_("Edit information on asset"));
1345 int AWindowInfo::handle_event()
1347         gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1348         return 1;
1351 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1352  : BC_Button(x, y, mwindow->theme->redrawindex_data)
1354         this->mwindow = mwindow;
1355         this->gui = gui;
1356         set_tooltip(_("Redraw index"));
1359 int AWindowRedrawIndex::handle_event()
1361         return 1;
1364 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1365  : BC_Button(x, y, mwindow->theme->pasteasset_data)
1367         this->mwindow = mwindow;
1368         this->gui = gui;
1369         set_tooltip(_("Paste asset on recordable tracks"));
1372 int AWindowPaste::handle_event()
1374         return 1;
1377 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1378  : BC_Button(x, y, mwindow->theme->appendasset_data)
1380         this->mwindow = mwindow;
1381         this->gui = gui;
1382         set_tooltip(_("Append asset in new tracks"));
1385 int AWindowAppend::handle_event()
1387         return 1;
1390 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1391  : BC_Button(x, y, mwindow->theme->viewasset_data)
1393         this->mwindow = mwindow;
1394         this->gui = gui;
1395         set_tooltip(_("View asset"));
1398 int AWindowView::handle_event()
1400         return 1;