r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / awindowgui.C
blob18f4c6a7602557e8ed200a13f537315459b4f995
1 #include "assetedit.h"
2 #include "assetpopup.h"
3 #include "assets.h"
4 #include "awindowgui.h"
5 #include "awindowgui.inc"
6 #include "awindow.h"
7 #include "awindowmenu.h"
8 #include "cache.h"
9 #include "colormodels.h"
10 #include "cursors.h"
11 #include "cwindowgui.h"
12 #include "cwindow.h"
13 #include "edl.h"
14 #include "edlsession.h"
15 #include "file.h"
16 #include "filesystem.h"
17 #include "localsession.h"
18 #include "mainmenu.h"
19 #include "mainsession.h"
20 #include "mwindowgui.h"
21 #include "mwindow.h"
22 #include "newfolder.h"
23 #include "preferences.h"
24 #include "theme.h"
25 #include "vframe.h"
26 #include "vwindowgui.h"
27 #include "vwindow.h"
30 #include <libintl.h>
31 #define _(String) gettext(String)
32 #define gettext_noop(String) String
33 #define N_(String) gettext_noop (String)
36 AssetPicon::AssetPicon(MWindow *mwindow, 
37         AWindowGUI *gui, 
38         Asset *asset)
39  : BC_ListBoxItem()
41         reset();
42         this->mwindow = mwindow;
43         this->gui = gui;
44         this->asset = asset;
45         this->id = asset->id;
48 AssetPicon::AssetPicon(MWindow *mwindow, 
49         AWindowGUI *gui, 
50         EDL *edl)
51  : BC_ListBoxItem()
53         reset();
54         this->mwindow = mwindow;
55         this->gui = gui;
56         this->edl = edl;
57         this->id = edl->id;
60 AssetPicon::AssetPicon(MWindow *mwindow, 
61         AWindowGUI *gui, 
62         char *folder)
63  : BC_ListBoxItem(folder, gui->folder_icon)
65         reset();
66         this->mwindow = mwindow;
67         this->gui = gui;
70 AssetPicon::AssetPicon(MWindow *mwindow, 
71         AWindowGUI *gui, 
72         PluginServer *plugin)
73  : BC_ListBoxItem()
75         reset();
76         this->mwindow = mwindow;
77         this->gui = gui;
78         this->plugin = plugin;
79         asset = 0;
80         icon = 0;
81         id = 0;
84 AssetPicon::~AssetPicon()
86         if(icon)
87         {
88                 if(icon != gui->file_icon &&
89                         icon != gui->audio_icon &&
90                         icon != gui->folder_icon &&
91                         icon != gui->clip_icon &&
92                         icon != gui->video_icon) delete icon;
93         }
96 void AssetPicon::reset()
98         plugin = 0;
99         asset = 0;
100         edl = 0;
101         icon = 0;
102         in_use = 1;
103         id = 0;
104         persistent = 0;
107 void AssetPicon::create_objects()
109         FileSystem fs;
110         char name[BCTEXTLEN];
111         VFrame *frame = 0;
112         int pixmap_w, pixmap_h;
115         pixmap_h = 50;
117         if(asset)
118         {
119                 fs.extract_name(name, asset->path);
120                 set_text(name);
121                 if(asset->video_data)
122                 {
123                         if(mwindow->preferences->use_thumbnails)
124                         {
125 //printf("AssetPicon::create_objects 1\n");
126                                 File *file = mwindow->video_cache->check_out(asset);
127 //printf("AssetPicon::create_objects 2\n");
129                                 if(file)
130                                 {
131                                         pixmap_w = pixmap_h * asset->width / asset->height;
133 //printf("AssetPicon::create_objects 3\n");
134                                         file->set_layer(0);
135                                         file->set_video_position(0, mwindow->edl->session->frame_rate);
136                                         frame = file->read_frame(BC_RGB888);
137 //printf("AssetPicon::create_objects 4\n");
139                                         if(frame)
140                                         {
141                                                 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
142                                                 icon->draw_vframe(frame,
143                                                         0, 
144                                                         0, 
145                                                         pixmap_w, 
146                                                         pixmap_h,
147                                                         0,
148                                                         0);
149                                         }
150 //printf("AssetPicon::create_objects 5\n");
152                                         mwindow->video_cache->check_in(asset);
153 //printf("AssetPicon::create_objects 6\n");
154                                 }
155                                 else
156                                 {
157                                         icon = gui->video_icon;
158                                 }
159                         }
160                         else
161                         {
162                                 icon = gui->video_icon;
163                         }
164                 }
165                 else
166                 if(asset->audio_data)
167                 {
168                         icon = gui->audio_icon;
169                 }
170 //printf("AssetPicon::create_objects 2\n");
172                 set_icon(icon);
173 //printf("AssetPicon::create_objects 4\n");
174         }
175         else
176         if(edl)
177         {
178 //printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
179                 strcpy(name, edl->local_session->clip_title);
180                 set_text(name);
181                 set_icon(gui->clip_icon);
182         }
183         else
184         if(plugin)
185         {
186                 strcpy(name, plugin->title);
187                 set_text(name);
188                 if(plugin->picon)
189                 {
190                         if(plugin->picon->get_color_model() == BC_RGB888)
191                         {
192                                 icon = new BC_Pixmap(gui, 
193                                         plugin->picon->get_w(), 
194                                         plugin->picon->get_h());
195                                 icon->draw_vframe(plugin->picon,
196                                         0,
197                                         0,
198                                         plugin->picon->get_w(), 
199                                         plugin->picon->get_h(),
200                                         0,
201                                         0);
202                         }
203                         else
204                         {
205                                 icon = new BC_Pixmap(gui, 
206                                         plugin->picon, 
207                                         PIXMAP_ALPHA);
208                         }
209                 }
210                 else
211                 {
212                         icon = gui->file_icon;
213                 }
214                 set_icon(icon);
215         }
224 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
225  : BC_Window(PROGRAM_NAME ": Resources",
226         mwindow->session->awindow_x, 
227     mwindow->session->awindow_y, 
228     mwindow->session->awindow_w, 
229     mwindow->session->awindow_h,
230     100,
231     100,
232     1,
233     1,
234     1)
236 // printf("AWindowGUI::AWindowGUI %d %d %d %d\n",
237 // mwindow->session->awindow_x, 
238 // mwindow->session->awindow_y, 
239 // mwindow->session->awindow_w, 
240 // mwindow->session->awindow_h);
241         this->mwindow = mwindow;
242         this->awindow = awindow;
245 AWindowGUI::~AWindowGUI()
247         assets.remove_all_objects();
248         folders.remove_all_objects();
249         aeffects.remove_all_objects();
250         veffects.remove_all_objects();
251         atransitions.remove_all_objects();
252         vtransitions.remove_all_objects();
253         displayed_assets[1].remove_all_objects();
254         delete file_icon;
255         delete audio_icon;
256         delete folder_icon;
257         delete clip_icon;
258         delete newfolder_thread;
259         delete asset_menu;
260         delete assetlist_menu;
261         delete folderlist_menu;
264 int AWindowGUI::create_objects()
266         int x, y;
267         AssetPicon *picon;
269 //printf("AWindowGUI::create_objects 1\n");
270         asset_titles[0] = _("Title");
271         asset_titles[1] = _("Comments");
273         set_icon(mwindow->theme->awindow_icon);
274         file_icon = new BC_Pixmap(this, 
275                 BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
276                 PIXMAP_ALPHA);
278         folder_icon = new BC_Pixmap(this, 
279                 BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
280                 PIXMAP_ALPHA);
282         audio_icon = new BC_Pixmap(this, 
283                 BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
284                 PIXMAP_ALPHA);
286         video_icon = new BC_Pixmap(this, 
287                 BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
288                 PIXMAP_ALPHA);
290         clip_icon = new BC_Pixmap(this, 
291                 mwindow->theme->clip_icon,
292                 PIXMAP_ALPHA);
294 // Mandatory folders
295         folders.append(picon = new AssetPicon(mwindow,
296                 this,
297                 AEFFECT_FOLDER));
298         picon->persistent = 1;
299         folders.append(picon = new AssetPicon(mwindow,
300                 this,
301                 VEFFECT_FOLDER));
302         picon->persistent = 1;
303         folders.append(picon = new AssetPicon(mwindow,
304                 this,
305                 ATRANSITION_FOLDER));
306         picon->persistent = 1;
307         folders.append(picon = new AssetPicon(mwindow,
308                 this,
309                 VTRANSITION_FOLDER));
310         picon->persistent = 1;
312         create_persistent_folder(&aeffects, 1, 0, 1, 0);
313         create_persistent_folder(&veffects, 0, 1, 1, 0);
314         create_persistent_folder(&atransitions, 1, 0, 0, 1);
315         create_persistent_folder(&vtransitions, 0, 1, 0, 1);
317         mwindow->theme->get_awindow_sizes(this);
318         add_subwindow(asset_list = new AWindowAssets(mwindow,
319                 this,
320                 mwindow->theme->alist_x, 
321         mwindow->theme->alist_y, 
322         mwindow->theme->alist_w, 
323         mwindow->theme->alist_h));
324         add_subwindow(divider = new AWindowDivider(mwindow,
325                 this,
326                 mwindow->theme->adivider_x,
327                 mwindow->theme->adivider_y,
328                 mwindow->theme->adivider_w,
329                 mwindow->theme->adivider_h));
330         divider->set_cursor(HSEPARATE_CURSOR);
331         add_subwindow(folder_list = new AWindowFolders(mwindow,
332                 this,
333                 mwindow->theme->afolders_x, 
334         mwindow->theme->afolders_y, 
335         mwindow->theme->afolders_w, 
336         mwindow->theme->afolders_h));
337         
338         x = mwindow->theme->abuttons_x;
339         y = mwindow->theme->abuttons_y;
341         newfolder_thread = new NewFolderThread(mwindow, this);
343         add_subwindow(asset_menu = new AssetPopup(mwindow, this));
344         asset_menu->create_objects();
346         add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
347         assetlist_menu->create_objects();
349         add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
350         folderlist_menu->create_objects();
351 //printf("AWindowGUI::create_objects 2\n");
353         return 0;
356 int AWindowGUI::resize_event(int w, int h)
358         mwindow->session->awindow_x = get_x();
359         mwindow->session->awindow_y = get_y();
360         mwindow->session->awindow_w = w;
361         mwindow->session->awindow_h = h;
363         mwindow->theme->get_awindow_sizes(this);
364         mwindow->theme->draw_awindow_bg(this);
366         asset_list->reposition_window(mwindow->theme->alist_x, 
367         mwindow->theme->alist_y, 
368         mwindow->theme->alist_w, 
369         mwindow->theme->alist_h);
370         divider->reposition_window(mwindow->theme->adivider_x,
371                 mwindow->theme->adivider_y,
372                 mwindow->theme->adivider_w,
373                 mwindow->theme->adivider_h);
374         folder_list->reposition_window(mwindow->theme->afolders_x, 
375         mwindow->theme->afolders_y, 
376         mwindow->theme->afolders_w, 
377         mwindow->theme->afolders_h);
378         
379         int x = mwindow->theme->abuttons_x;
380         int y = mwindow->theme->abuttons_y;
382 //      new_bin->reposition_window(x, y);
383 //      x += new_bin->get_w();
384 //      delete_bin->reposition_window(x, y);
385 //      x += delete_bin->get_w();
386 //      rename_bin->reposition_window(x, y);
387 //      x += rename_bin->get_w();
388 //      delete_disk->reposition_window(x, y);
389 //      x += delete_disk->get_w();
390 //      delete_project->reposition_window(x, y);
391 //      x += delete_project->get_w();
392 //      info->reposition_window(x, y);
393 //      x += info->get_w();
394 //      redraw_index->reposition_window(x, y);
395 //      x += redraw_index->get_w();
396 //      paste->reposition_window(x, y);
397 //      x += paste->get_w();
398 //      append->reposition_window(x, y);
399 //      x += append->get_w();
400 //      view->reposition_window(x, y);
402         BC_WindowBase::resize_event(w, h);
403         return 1;
406 int AWindowGUI::translation_event()
408         mwindow->session->awindow_x = get_x();
409         mwindow->session->awindow_y = get_y();
410         return 0;
413 void AWindowGUI::reposition_objects()
415         mwindow->theme->get_awindow_sizes(this);
416         asset_list->reposition_window(mwindow->theme->alist_x, 
417         mwindow->theme->alist_y, 
418         mwindow->theme->alist_w, 
419         mwindow->theme->alist_h);
420         divider->reposition_window(mwindow->theme->adivider_x,
421                 mwindow->theme->adivider_y,
422                 mwindow->theme->adivider_w,
423                 mwindow->theme->adivider_h);
424         folder_list->reposition_window(mwindow->theme->afolders_x, 
425         mwindow->theme->afolders_y, 
426         mwindow->theme->afolders_w, 
427         mwindow->theme->afolders_h);
428         flush();
431 int AWindowGUI::close_event()
433         hide_window();
434         mwindow->session->show_awindow = 0;
435         mwindow->gui->lock_window();
436         mwindow->gui->mainmenu->show_awindow->set_checked(0);
437         mwindow->gui->unlock_window();
438         mwindow->save_defaults();
439         return 1;
443 int AWindowGUI::keypress_event()
445         switch(get_keypress())
446         {
447                 case 'w':
448                 case 'W':
449                         if(ctrl_down())
450                         {
451                                 close_event();
452                                 return 1;
453                         }
454                         break;
455         }
456         return 0;
459 void AWindowGUI::update_folder_list()
461 //printf("AWindowGUI::update_folder_list 1\n");
462         for(int i = 0; i < folders.total; i++)
463         {
464                 AssetPicon *picon = (AssetPicon*)folders.values[i];
465                 picon->in_use--;
466         }
467 //printf("AWindowGUI::update_folder_list 1\n");
469 // Search assets for folders
470         for(int i = 0; i < mwindow->edl->folders.total; i++)
471         {
472                 char *folder = mwindow->edl->folders.values[i];
473                 int exists = 0;
474 //printf("AWindowGUI::update_folder_list 1.1\n");
476                 for(int j = 0; j < folders.total; j++)
477                 {
478                         AssetPicon *picon = (AssetPicon*)folders.values[j];
479                         if(!strcasecmp(picon->get_text(), folder))
480                         {
481                                 exists = 1;
482                                 picon->in_use = 1;
483                                 break;
484                         }
485                 }
487                 if(!exists)
488                 {
489                         AssetPicon *picon = new AssetPicon(mwindow, this, folder);
490                         picon->create_objects();
491                         folders.append(picon);
492                 }
493 //printf("AWindowGUI::update_folder_list 1.3\n");
494         }
495 //printf("AWindowGUI::update_folder_list 1\n");
496 //for(int i = 0; i < folders.total; i++)
497 //      printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
499 // Delete excess
500         for(int i = folders.total - 1; i >= 0; i--)
501         {
502                 AssetPicon *picon = (AssetPicon*)folders.values[i];
503                 if(!picon->in_use && !picon->persistent)
504                 {
505                         delete picon;
506                         folders.remove_number(i);
507                 }
508         }
509 //for(int i = 0; i < folders.total; i++)
510 //      printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
511 //printf("AWindowGUI::update_folder_list 2\n");
514 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output, 
515         int do_audio, 
516         int do_video, 
517         int is_realtime, 
518         int is_transition)
520         ArrayList<PluginServer*> plugindb;
522 // Get pointers to plugindb entries
523         mwindow->create_plugindb(do_audio, 
524                         do_video, 
525                         is_realtime, 
526                         is_transition,
527                         0,
528                         plugindb);
530         for(int i = 0; i < plugindb.total; i++)
531         {
532                 PluginServer *server = plugindb.values[i];
533                 int exists = 0;
535 // Create new listitem
536                 if(!exists)
537                 {
538                         AssetPicon *picon = new AssetPicon(mwindow, this, server);
539                         picon->create_objects();
540                         output->append(picon);
541                 }
542         }
545 void AWindowGUI::update_asset_list()
547 //printf("AWindowGUI::update_asset_list 1\n");
548         for(int i = 0; i < assets.total; i++)
549         {
550                 AssetPicon *picon = (AssetPicon*)assets.values[i];
551                 picon->in_use--;
552         }
558 //printf("AWindowGUI::update_asset_list 1\n");
561 // Synchronize EDL clips
562         for(int i = 0; i < mwindow->edl->clips.total; i++)
563         {
564                 int exists = 0;
565                 
566 // Look for clip in existing listitems
567                 for(int j = 0; j < assets.total && !exists; j++)
568                 {
569                         AssetPicon *picon = (AssetPicon*)assets.values[j];
570                         
571                         if(picon->id == mwindow->edl->clips.values[i]->id)
572                         {
573                                 picon->edl = mwindow->edl->clips.values[i];
574                                 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
575                                 exists = 1;
576                                 picon->in_use = 1;
577                         }
578                 }
580 // Create new listitem
581                 if(!exists)
582                 {
583                         AssetPicon *picon = new AssetPicon(mwindow, 
584                                 this, 
585                                 mwindow->edl->clips.values[i]);
586                         picon->create_objects();
587                         assets.append(picon);
588                 }
589         }
597 //printf("AWindowGUI::update_asset_list 2 %d\n", assets.total);
598 // Synchronize EDL assets
599         for(Asset *current = mwindow->edl->assets->first; 
600                 current; 
601                 current = NEXT)
602         {
603                 int exists = 0;
605 //printf("AWindowGUI::update_asset_list 3 %s\n", current->path);
606 // Look for asset in existing listitems
607                 for(int j = 0; j < assets.total && !exists; j++)
608                 {
609                         AssetPicon *picon = (AssetPicon*)assets.values[j];
611                         if(picon->id == current->id)
612                         {
613 //printf("AWindowGUI::update_asset_list 4 %p %d %d\n", picon->asset, picon->get_icon_x(), picon->get_icon_y());
614                                 picon->asset = current;
615                                 exists = 1;
616                                 picon->in_use = 1;
617                                 break;
618                         }
619                 }
621 //printf("AWindowGUI::update_asset_list 5\n");
622 // Create new listitem
623                 if(!exists)
624                 {
625 //printf("AWindowGUI::update_asset_list 4.1 %s\n", current->path);
626                         AssetPicon *picon = new AssetPicon(mwindow, this, current);
627 //printf("AWindowGUI::update_asset_list 4.2 %s\n", current->path);
628                         picon->create_objects();
629 //printf("AWindowGUI::update_asset_list 4.3 %s\n", current->path);
630                         assets.append(picon);
631 //printf("AWindowGUI::update_asset_list 4.4 %s\n", current->path);
632                 }
633         }
643 //printf("AWindowGUI::update_asset_list 6\n");
644         for(int i = assets.total - 1; i >= 0; i--)
645         {
646                 AssetPicon *picon = (AssetPicon*)assets.values[i];
647 //printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
648                 if(!picon->in_use)
649                 {
650                         delete picon;
651                         assets.remove_number(i);
652                 }
653         }
654 //printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
661 void AWindowGUI::sort_assets()
663 //printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
664         if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
665                 sort_picons(&aeffects, 
666                         0);
667         else
668         if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
669                 sort_picons(&veffects, 
670                         0);
671         else
672         if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
673                 sort_picons(&atransitions, 
674                         0);
675         else
676         if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
677                 sort_picons(&vtransitions, 
678                         0);
679         else
680                 sort_picons(&assets, 
681                         mwindow->edl->session->current_folder);
683         update_assets();
696 void AWindowGUI::collect_assets()
698         int i = 0;
699         mwindow->session->drag_assets->remove_all();
700         mwindow->session->drag_clips->remove_all();
701         while(1)
702         {
703                 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
704                 if(!result) break;
706                 if(result->asset) mwindow->session->drag_assets->append(result->asset);
707                 if(result->edl) mwindow->session->drag_clips->append(result->edl);
708         }
711 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst, 
712         ArrayList<BC_ListBoxItem*> *src, 
713         char *folder)
715 // Remove current pointers
716         dst[0].remove_all();
717         dst[1].remove_all_objects();
719 // Create new pointers
720 //if(folder) printf("AWindowGUI::copy_picons 1 %s\n", folder);
721         for(int i = 0; i < src->total; i++)
722         {
723                 AssetPicon *picon = (AssetPicon*)src->values[i];
724 //printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
725                 if(!folder ||
726                         (folder && picon->asset && !strcasecmp(picon->asset->folder, folder)) ||
727                         (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
728                 {
729                         BC_ListBoxItem *item2, *item1;
730                         dst[0].append(item1 = picon);
731                         if(picon->edl)
732                                 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
733                         else
734                                 dst[1].append(item2 = new BC_ListBoxItem(""));
735                         item1->set_autoplace_text(1);
736                         item2->set_autoplace_text(1);
737 //printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
738                 }
739         }
742 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src, 
743                 char *folder)
745 //printf("AWindowGUI::sort_picons 1\n")
746         int done = 0;
747         while(!done)
748         {
749                 done = 1;
750                 for(int i = 0; i < src->total - 1; i++)
751                 {
752                         BC_ListBoxItem *item1 = src->values[i];
753                         BC_ListBoxItem *item2 = src->values[i + 1];
754                         item1->set_autoplace_icon(1);
755                         item2->set_autoplace_icon(1);
756                         item1->set_autoplace_text(1);
757                         item2->set_autoplace_text(1);
758                         if(strcmp(item1->get_text(), item2->get_text()) > 0)
759                         {
760                                 src->values[i + 1] = item1;
761                                 src->values[i] = item2;
762                                 done = 0;
763                         }
764                 }
765         }
769 void AWindowGUI::filter_displayed_assets()
771         if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
772                 copy_picons(displayed_assets, 
773                         &aeffects, 
774                         0);
775         else
776         if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
777                 copy_picons(displayed_assets, 
778                         &veffects, 
779                         0);
780         else
781         if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
782                 copy_picons(displayed_assets, 
783                         &atransitions, 
784                         0);
785         else
786         if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
787                 copy_picons(displayed_assets, 
788                         &vtransitions, 
789                         0);
790         else
791                 copy_picons(displayed_assets, 
792                         &assets, 
793                         mwindow->edl->session->current_folder);
797 void AWindowGUI::update_assets()
799 //printf("AWindowGUI::update_assets 1\n");
800         update_folder_list();
801 //printf("AWindowGUI::update_assets 2\n");
802         update_asset_list();
803 //printf("AWindowGUI::update_assets 3\n");
804         filter_displayed_assets();
806 //for(int i = 0; i < folders.total; i++)
807 //printf("AWindowGUI::update_assets 4\n");
808 //      printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
809         if(mwindow->edl->session->folderlist_format != folder_list->get_format())
810                 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
811         folder_list->update(&folders,
812                 0,
813                 0,
814                 1,
815                 folder_list->get_xposition(),
816                 folder_list->get_yposition(),
817                 -1);
818 //printf("AWindowGUI::update_assets 5\n");
820         if(mwindow->edl->session->assetlist_format != asset_list->get_format())
821                 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
824 //printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
825         asset_list->update(displayed_assets,
826                 asset_titles,
827                 mwindow->edl->session->asset_columns,
828                 ASSET_COLUMNS, 
829                 asset_list->get_xposition(),
830                 asset_list->get_yposition(),
831                 -1,
832                 0);
833 //printf("AWindowGUI::update_assets 7\n");
835         flush();
836 //printf("AWindowGUI::update_assets 8\n");
837         return;
840 int AWindowGUI::current_folder_number()
842         int result = -1;
843         for(int i = 0; i < folders.total; i++)
844         {
845                 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
846                 {
847                         result = i;
848                         break;
849                 }
850         }
851         return result;
854 int AWindowGUI::drag_motion()
856         if(get_hidden()) return 0;
858         int result = 0;
859         return result;
862 int AWindowGUI::drag_stop()
864         if(get_hidden()) return 0;
866         return 0;
869 Asset* AWindowGUI::selected_asset()
871         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
872         if(picon) return picon->asset;
875 PluginServer* AWindowGUI::selected_plugin()
877         AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
878         if(picon) return picon->plugin;
881 AssetPicon* AWindowGUI::selected_folder()
883         AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
884     return picon;
896 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
897  : BC_SubWindow(x, y, w, h)
899         this->mwindow = mwindow;
900         this->gui = gui;
902 AWindowDivider::~AWindowDivider()
906 int AWindowDivider::button_press_event()
908         if(is_event_win() && cursor_inside())
909         {
910                 mwindow->session->current_operation = DRAG_PARTITION;
911                 return 1;
912         }
913         return 0;
916 int AWindowDivider::cursor_motion_event()
918         if(mwindow->session->current_operation == DRAG_PARTITION)
919         {
920                 mwindow->session->afolders_w = gui->get_relative_cursor_x();
921                 gui->reposition_objects();
922         }
923         return 0;
926 int AWindowDivider::button_release_event()
928         if(mwindow->session->current_operation == DRAG_PARTITION)
929         {
930                 mwindow->session->current_operation = NO_OPERATION;
931                 return 1;
932         }
933         return 0;
941 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
942  : BC_ListBox(x, 
943                 y, 
944                 w, 
945                 h,
946                 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ? 
947                         LISTBOX_ICONS : LISTBOX_TEXT, 
948                 &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
949                 0,             // Titles for columns.  Set to 0 for no titles
950                 0,                // width of each column
951                 1,                      // Total columns.
952                 0,                    // Pixel of top of window.
953                 0,                        // If this listbox is a popup window
954                 LISTBOX_SINGLE,  // Select one item or multiple items
955                 ICON_TOP,        // Position of icon relative to text of each item
956                 1)               // Allow drags
958         this->mwindow = mwindow;
959         this->gui = gui;
960         set_drag_scroll(0);
963 AWindowFolders::~AWindowFolders()
966         
967 int AWindowFolders::selection_changed()
969         AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
970         if(picon)
971         {
972                 strcpy(mwindow->edl->session->current_folder, picon->get_text());
973 //printf("AWindowFolders::selection_changed 1\n");
974                 gui->asset_list->draw_background();
975                 gui->update_assets();
976         }
977         return 1;
980 int AWindowFolders::button_press_event()
982         int result = 0;
984         result = BC_ListBox::button_press_event();
986         if(!result)
987         {
988                 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
989                 {
990                         gui->folderlist_menu->update_titles();
991                         gui->folderlist_menu->activate_menu();
992                         result = 1;
993                 }
994         }
997         return result;
1006 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
1007  : BC_ListBox(x, 
1008                 y, 
1009                 w, 
1010                 h,
1011                 mwindow->edl->session->assetlist_format == ASSETS_ICONS ? 
1012                         LISTBOX_ICONS : LISTBOX_TEXT,
1013                 &gui->assets,     // Each column has an ArrayList of BC_ListBoxItems.
1014                 gui->asset_titles,             // Titles for columns.  Set to 0 for no titles
1015                 mwindow->edl->session->asset_columns,                // width of each column
1016                 1,                      // Total columns.
1017                 0,                    // Pixel of top of window.
1018                 0,                        // If this listbox is a popup window
1019                 LISTBOX_MULTIPLE,  // Select one item or multiple items
1020                 ICON_TOP,        // Position of icon relative to text of each item
1021                 1)               // Allow drag
1023         this->mwindow = mwindow;
1024         this->gui = gui;
1025         set_drag_scroll(0);
1028 AWindowAssets::~AWindowAssets()
1032 int AWindowAssets::button_press_event()
1034         int result = 0;
1036         result = BC_ListBox::button_press_event();
1038         if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
1039         {
1040                 BC_ListBox::deactivate_selection();
1041                 gui->assetlist_menu->update_titles();
1042                 gui->assetlist_menu->activate_menu();
1043                 result = 1;
1044         }
1047         return result;
1051 int AWindowAssets::handle_event()
1053 //printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
1054         if(get_selection(0, 0))
1055         {
1056                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1057                 {
1058                 }
1059                 else
1060                 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1061                 {
1062                 }
1063                 else
1064                 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1065                 {
1066                 }
1067                 else
1068                 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1069                 {
1070                 }
1071                 else
1072                 {
1073 //printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
1074                         mwindow->vwindow->gui->lock_window();
1075                         
1076                         if(((AssetPicon*)get_selection(0, 0))->asset)
1077                                 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->asset);
1078                         else
1079                         if(((AssetPicon*)get_selection(0, 0))->edl)
1080                                 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->edl);
1082                         mwindow->vwindow->gui->unlock_window();
1083                 }
1084                 return 1;
1085         }
1087         return 0;
1090 int AWindowAssets::selection_changed()
1092 // Show popup window
1093         if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
1094         {
1095                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) || 
1096                         !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
1097                         !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
1098                         !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1099                 {
1100                         gui->assetlist_menu->update_titles();
1101                         gui->assetlist_menu->activate_menu();
1102                 }
1103                 else
1104                 {
1105                         if(((AssetPicon*)get_selection(0, 0))->asset)
1106                                 gui->asset_menu->update();
1107                         else
1108                         if(((AssetPicon*)get_selection(0, 0))->edl)
1109                                 gui->asset_menu->update();
1113                         gui->asset_menu->activate_menu();
1114                 }
1116                 BC_ListBox::deactivate_selection();
1117                 return 1;
1118         }
1119         return 0;
1122 void AWindowAssets::draw_background()
1124 //printf("AWindowAssets::draw_background %s\n", mwindow->edl->session->current_folder);
1125         BC_ListBox::draw_background();
1126         set_color(RED);
1127         set_font(LARGEFONT);
1128         draw_text(get_w() - 
1129                         get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4, 
1130                 30, 
1131                 mwindow->edl->session->current_folder, 
1132                 -1, 
1133                 get_bg_surface());
1136 int AWindowAssets::drag_start_event()
1138         int collect_pluginservers = 0;
1139         int collect_assets = 0;
1141         if(BC_ListBox::drag_start_event())
1142         {
1143                 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
1144                 {
1145                         mwindow->session->current_operation = DRAG_AEFFECT;
1146                         collect_pluginservers = 1;
1147                 }
1148                 else
1149                 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
1150                 {
1151                         mwindow->session->current_operation = DRAG_VEFFECT;
1152                         collect_pluginservers = 1;
1153                 }
1154                 else
1155                 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
1156                 {
1157                         mwindow->session->current_operation = DRAG_ATRANSITION;
1158                         collect_pluginservers = 1;
1159                 }
1160                 else
1161                 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
1162                 {
1163                         mwindow->session->current_operation = DRAG_VTRANSITION;
1164                         collect_pluginservers = 1;
1165                 }
1166                 else
1167                 {
1168                         mwindow->session->current_operation = DRAG_ASSET;
1169                         collect_assets = 1;
1170                 }
1171                 
1172                 
1173                 if(collect_pluginservers)
1174                 {
1175                         int i = 0;
1176                         mwindow->session->drag_pluginservers->remove_all();
1177                         while(1)
1178                         {
1179                                 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
1180                                 if(!result) break;
1181                                 
1182                                 mwindow->session->drag_pluginservers->append(result->plugin);
1183                         }
1184                 }
1185                 
1186                 if(collect_assets)
1187                 {
1188                         gui->collect_assets();
1189                 }
1191                 return 1;
1192         }
1193         return 0;
1196 int AWindowAssets::drag_motion_event()
1198         BC_ListBox::drag_motion_event();
1200         mwindow->gui->lock_window();
1201         mwindow->gui->drag_motion();
1202         mwindow->gui->unlock_window();
1204         mwindow->vwindow->gui->lock_window();
1205         mwindow->vwindow->gui->drag_motion();
1206         mwindow->vwindow->gui->unlock_window();
1208         mwindow->cwindow->gui->lock_window();
1209         mwindow->cwindow->gui->drag_motion();
1210         mwindow->cwindow->gui->unlock_window();
1211         return 0;
1214 int AWindowAssets::drag_stop_event()
1216         int result = 0;
1218         result = gui->drag_stop();
1221         if(!result)
1222         {
1223                 mwindow->gui->lock_window();
1224                 result = mwindow->gui->drag_stop();
1225                 mwindow->gui->unlock_window();
1226         }
1228         if(!result) 
1229         {
1230                 mwindow->vwindow->gui->lock_window();
1231                 result = mwindow->vwindow->gui->drag_stop();
1232                 mwindow->vwindow->gui->unlock_window();
1233         }
1235         if(!result) 
1236         {
1237                 mwindow->cwindow->gui->lock_window();
1238                 result = mwindow->cwindow->gui->drag_stop();
1239                 mwindow->cwindow->gui->unlock_window();
1240         }
1244         if(result) get_drag_popup()->set_animation(0);
1246         BC_ListBox::drag_stop_event();
1247         return 0;
1250 int AWindowAssets::column_resize_event()
1252         mwindow->edl->session->asset_columns[0] = get_column_width(0);
1253         mwindow->edl->session->asset_columns[1] = get_column_width(1);
1254         return 1;
1268 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1269  : BC_Button(x, y, mwindow->theme->newbin_data)
1271         this->mwindow = mwindow;
1272         this->gui = gui;
1273         set_tooltip(_("New bin"));
1276 int AWindowNewFolder::handle_event()
1278         gui->newfolder_thread->start_new_folder();
1279         return 1;
1282 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1283  : BC_Button(x, y, mwindow->theme->deletebin_data)
1285         this->mwindow = mwindow;
1286         this->gui = gui;
1287         set_tooltip(_("Delete bin"));
1290 int AWindowDeleteFolder::handle_event()
1292         if(gui->folder_list->get_selection(0, 0))
1293         {
1294                 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
1295                 mwindow->delete_folder(folder->get_text());
1296         }
1297         return 1;
1300 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1301  : BC_Button(x, y, mwindow->theme->renamebin_data)
1303         this->mwindow = mwindow;
1304         this->gui = gui;
1305         set_tooltip(_("Rename bin"));
1308 int AWindowRenameFolder::handle_event()
1310         return 1;
1313 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1314  : BC_Button(x, y, mwindow->theme->deletedisk_data)
1316         this->mwindow = mwindow;
1317         this->gui = gui;
1318         set_tooltip(_("Delete asset from disk"));
1321 int AWindowDeleteDisk::handle_event()
1323         return 1;
1326 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1327  : BC_Button(x, y, mwindow->theme->deleteproject_data)
1329         this->mwindow = mwindow;
1330         this->gui = gui;
1331         set_tooltip(_("Delete asset from project"));
1334 int AWindowDeleteProject::handle_event()
1336         return 1;
1339 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1340  : BC_Button(x, y, mwindow->theme->infoasset_data)
1342         this->mwindow = mwindow;
1343         this->gui = gui;
1344         set_tooltip(_("Edit information on asset"));
1347 int AWindowInfo::handle_event()
1349         gui->awindow->asset_edit->edit_asset(gui->selected_asset());
1350         return 1;
1353 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1354  : BC_Button(x, y, mwindow->theme->redrawindex_data)
1356         this->mwindow = mwindow;
1357         this->gui = gui;
1358         set_tooltip(_("Redraw index"));
1361 int AWindowRedrawIndex::handle_event()
1363         return 1;
1366 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1367  : BC_Button(x, y, mwindow->theme->pasteasset_data)
1369         this->mwindow = mwindow;
1370         this->gui = gui;
1371         set_tooltip(_("Paste asset on recordable tracks"));
1374 int AWindowPaste::handle_event()
1376         return 1;
1379 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1380  : BC_Button(x, y, mwindow->theme->appendasset_data)
1382         this->mwindow = mwindow;
1383         this->gui = gui;
1384         set_tooltip(_("Append asset in new tracks"));
1387 int AWindowAppend::handle_event()
1389         return 1;
1392 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
1393  : BC_Button(x, y, mwindow->theme->viewasset_data)
1395         this->mwindow = mwindow;
1396         this->gui = gui;
1397         set_tooltip(_("View asset"));
1400 int AWindowView::handle_event()
1402         return 1;