merged hv7 mod
[goodguy/history.git] / cinelerra-5.1 / cinelerra / awindowgui.C
index 9a39a6fbe3094acb365242507ea6155a9f65de3a..1267c001cd289b43079c538f58a189be1be54259 100644 (file)
@@ -35,6 +35,7 @@
 #include "cwindow.h"
 #include "edl.h"
 #include "edlsession.h"
+#include "effectlist.h"
 #include "file.h"
 #include "filesystem.h"
 #include "folderlistmenu.h"
@@ -75,7 +76,7 @@ const char *AWindowGUI::folder_names[] =
        N_("Labels"),
        N_("Clips"),
        N_("Media"),
-       N_("User")
+       N_("Proxy"),
 };
 
 
@@ -135,9 +136,9 @@ int AssetVIcon::get_vy()
        return lbox->get_item_y(picon) + lbox->get_title_h();
 }
 
+
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui,
-       Indexable *indexable)
+       AWindowGUI *gui, Indexable *indexable)
  : BC_ListBoxItem()
 {
        reset();
@@ -149,8 +150,7 @@ AssetPicon::AssetPicon(MWindow *mwindow,
 }
 
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui,
-       EDL *edl)
+       AWindowGUI *gui, EDL *edl)
  : BC_ListBoxItem()
 {
        reset();
@@ -162,28 +162,20 @@ AssetPicon::AssetPicon(MWindow *mwindow,
 }
 
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui, int folder)
- : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]), gui->folder_icon)
+       AWindowGUI *gui, int folder, int persist)
+ : BC_ListBoxItem(_(AWindowGUI::folder_names[folder]),
+       folder>=0 && folder<AWINDOW_FOLDERS ?
+               gui->folder_icons[folder]: gui->folder_icon)
 {
        reset();
        foldernum = folder;
        this->mwindow = mwindow;
        this->gui = gui;
+       persistent = persist;
 }
 
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui, const char *folder_name, int folder_num)
- : BC_ListBoxItem(folder_name, gui->folder_icon)
-{
-       reset();
-       foldernum = folder_num;
-       this->mwindow = mwindow;
-       this->gui = gui;
-}
-
-AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui,
-       PluginServer *plugin)
+       AWindowGUI *gui, PluginServer *plugin)
  : BC_ListBoxItem()
 {
        reset();
@@ -192,10 +184,8 @@ AssetPicon::AssetPicon(MWindow *mwindow,
        this->plugin = plugin;
 }
 
-
 AssetPicon::AssetPicon(MWindow *mwindow,
-       AWindowGUI *gui,
-       Label *label)
+       AWindowGUI *gui, Label *label)
  : BC_ListBoxItem()
 {
        reset();
@@ -225,6 +215,7 @@ void AssetPicon::reset()
        label = 0;
        indexable = 0;
        edl = 0;
+       foldernum = AW_NO_FOLDER;
        icon = 0;
        icon_vframe = 0;
        vicon = 0;
@@ -238,27 +229,22 @@ void AssetPicon::create_objects()
        FileSystem fs;
        char name[BCTEXTLEN];
        int pixmap_w, pixmap_h;
-       const int debug = 0;
 
        pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
 
-       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
        if( indexable ) {
                fs.extract_name(name, indexable->path);
                set_text(name);
        }
 
        if( indexable && indexable->is_asset ) {
-               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                Asset *asset = (Asset*)indexable;
                if( asset->video_data ) {
                        if( mwindow->preferences->use_thumbnails ) {
                                gui->unlock_window();
-                               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                                File *file = mwindow->video_cache->check_out(asset,
                                        mwindow->edl,
                                        1);
-                               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
 
                                if( file ) {
                                        int height = asset->height > 0 ? asset->height : 1;
@@ -285,27 +271,26 @@ void AssetPicon::create_objects()
                                        mwindow->gui->show_message(string);
                                        mwindow->gui->unlock_window(); }
                                        file->read_frame(gui->temp_picon);
-                                       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
                                        mwindow->video_cache->check_in(asset);
 
                                        gui->lock_window("AssetPicon::create_objects 1");
                                        icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
                                        icon->draw_vframe(gui->temp_picon,
                                                0, 0, pixmap_w, pixmap_h, 0, 0);
-//printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h());
                                        icon_vframe = new VFrame(0,
                                                -1, pixmap_w, pixmap_h, BC_RGB888, -1);
                                        icon_vframe->transfer_from(gui->temp_picon);
+                                       if( asset->awindow_folder == AW_MEDIA_FOLDER ) {
 // vicon images
-                                       double framerate = asset->get_frame_rate();
-                                       if( !framerate ) framerate = VICON_RATE;
-                                       int64_t frames = asset->get_video_frames();
-                                       double secs = frames / framerate;
-                                       if( secs > 5 ) secs = 5;
-                                       int64_t length = secs * gui->vicon_thread->refresh_rate;
-                                       vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
-                                       gui->vicon_thread->add_vicon(vicon);
-                                       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
+                                               double framerate = asset->get_frame_rate();
+                                               if( !framerate ) framerate = VICON_RATE;
+                                               int64_t frames = asset->get_video_frames();
+                                               double secs = frames / framerate;
+                                               if( secs > 5 ) secs = 5;
+                                               int64_t length = secs * gui->vicon_thread->refresh_rate;
+                                               vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
+                                               gui->vicon_thread->add_vicon(vicon);
+                                       }
 
                                }
                                else {
@@ -324,9 +309,7 @@ void AssetPicon::create_objects()
                        icon = gui->audio_icon;
                        icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
                }
-//printf("AssetPicon::create_objects 2\n");
 
-               if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
        }
        else
        if( indexable && !indexable->is_asset ) {
@@ -335,14 +318,13 @@ void AssetPicon::create_objects()
        }
        else
        if( edl ) {
-//printf("AssetPicon::create_objects 4 %s\n", edl->local_session->clip_title);
                set_text(strcpy(name, edl->local_session->clip_title));
                icon = gui->clip_icon;
                icon_vframe = mwindow->theme->get_image("clip_icon");
        }
        else
        if( plugin ) {
-               strcpy(name, _(plugin->title));
+               strcpy(name,  plugin->title);
                set_text(name);
                icon_vframe = plugin->get_picon();
                if( icon_vframe )
@@ -400,26 +382,14 @@ void AssetPicon::create_objects()
        }
        set_icon(icon);
        set_icon_vframe(icon_vframe);
-
-       if( debug ) printf("AssetPicon::create_objects %d\n", __LINE__);
 }
 
-
-
-
-
-
 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
  : BC_Window(_(PROGRAM_NAME ": Resources"),
        mwindow->session->awindow_x, mwindow->session->awindow_y,
        mwindow->session->awindow_w, mwindow->session->awindow_h,
        100, 100, 1, 1, 1)
 {
-// printf("AWindowGUI::AWindowGUI %d %d %d %d\n",
-// mwindow->session->awindow_x,
-// mwindow->session->awindow_y,
-// mwindow->session->awindow_w,
-// mwindow->session->awindow_h);
        this->mwindow = mwindow;
        this->awindow = awindow;
        file_icon = 0;
@@ -438,6 +408,7 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
        plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
        newfolder_thread = 0;
        asset_menu = 0;
+       effectlist_menu = 0;
        assetlist_menu = 0;
        cliplist_menu = 0;
        labellist_menu = 0;
@@ -447,6 +418,7 @@ AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
        remove_plugin = 0;
        vicon_thread = 0;
        vicon_drawing = 1;
+       displayed_folder = AW_NO_FOLDER;
 }
 
 AWindowGUI::~AWindowGUI()
@@ -470,22 +442,20 @@ AWindowGUI::~AWindowGUI()
        delete atransition_icon;
        delete vtransition_icon;
        delete aeffect_icon;
+       delete veffect_icon;
        delete ladspa_icon;
-       delete ladspa_vframe;
        delete ff_aud_icon;
-       delete ff_aud_vframe;
        delete ff_vid_icon;
-       delete ff_vid_vframe;
-       delete veffect_icon;
        delete newfolder_thread;
        delete asset_menu;
        delete clip_menu;
        delete label_menu;
+       delete effectlist_menu;
        delete assetlist_menu;
        delete cliplist_menu;
        delete labellist_menu;
        delete folderlist_menu;
-       if( temp_picon ) delete temp_picon;
+       delete temp_picon;
        delete remove_plugin;
 }
 
@@ -503,86 +473,109 @@ bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
                icon == aeffect_icon ||
                icon == ladspa_icon ||
                icon == ff_aud_icon ||
-               icon == ff_vid_icon;
+               icon == ff_vid_icon ||
+               icon == aeffect_folder_icon ||
+               icon == veffect_folder_icon ||
+               icon == atransition_folder_icon ||
+               icon == vtransition_folder_icon ||
+               icon == label_folder_icon ||
+               icon == clip_folder_icon ||
+               icon == media_folder_icon ||
+               icon == proxy_folder_icon;
 }
 
-void AWindowGUI::create_objects()
+VFrame *AWindowGUI::get_picon(const char *name, const char *plugin_icons)
+{
+       char png_path[BCTEXTLEN];
+       char *pp = png_path, *ep = pp + sizeof(png_path)-1;
+       snprintf(pp, ep-pp, "%s/picon_%s/%s.png",
+               File::get_plugin_path(), plugin_icons, name);
+       return VFramePng::vframe_png(png_path,0,0);
+}
+
+VFrame *AWindowGUI::get_picon(const char *name)
+{
+       VFrame *vframe = get_picon(name, mwindow->preferences->plugin_icons);
+       if( !vframe ) vframe = get_picon(name, DEFAULT_PICON);
+       return vframe;
+}
+
+void AWindowGUI::resource_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, int idx)
 {
-       AssetPicon *picon;
+       vfrm = get_picon(fn);
+       if( !vfrm ) vfrm = BC_WindowBase::get_resources()->type_to_icon[idx];
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+}
+void AWindowGUI::theme_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn)
+{
+       vfrm = get_picon(fn);
+       if( !vfrm ) vfrm = mwindow->theme->get_image(fn);
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+}
+void AWindowGUI::plugin_icon(VFrame *&vfrm, BC_Pixmap *&icon, const char *fn, unsigned char *png)
+{
+       vfrm = get_picon(fn);
+       if( !vfrm ) vfrm = new VFramePng(png);
+       icon = new BC_Pixmap(this, vfrm, PIXMAP_ALPHA);
+}
 
+void AWindowGUI::create_objects()
+{
        lock_window("AWindowGUI::create_objects");
-SET_TRACE
-//printf("AWindowGUI::create_objects 1\n");
        asset_titles[0] = _("Title");
        asset_titles[1] = _("Comments");
 
-SET_TRACE
-
        set_icon(mwindow->theme->get_image("awindow_icon"));
-       file_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
-               PIXMAP_ALPHA);
-
-       folder_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
-               PIXMAP_ALPHA);
-
-       audio_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
-               PIXMAP_ALPHA);
-
-       video_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
-               PIXMAP_ALPHA);
-
-       label_icon = new BC_Pixmap(this,
-               BC_WindowBase::get_resources()->type_to_icon[ICON_LABEL],
-               PIXMAP_ALPHA);
-
-SET_TRACE
-
-       clip_vframe = mwindow->theme->get_image("clip_icon");
-       clip_icon = new BC_Pixmap(this, clip_vframe, PIXMAP_ALPHA);
-       atransition_vframe = mwindow->theme->get_image("atransition_icon");
-       atransition_icon = new BC_Pixmap(this, atransition_vframe, PIXMAP_ALPHA);
-       vtransition_vframe = mwindow->theme->get_image("vtransition_icon");
-       vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA);
-       aeffect_vframe = mwindow->theme->get_image("aeffect_icon");
-       aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA);
-       ladspa_vframe = new VFramePng(lad_picon_png);
-       ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA);
-       ff_aud_vframe = new VFramePng(ff_audio_png);
-       ff_aud_icon = new BC_Pixmap(this, ff_aud_vframe, PIXMAP_ALPHA);
-       ff_vid_vframe = new VFramePng(ff_video_png);
-       ff_vid_icon = new BC_Pixmap(this, ff_vid_vframe, PIXMAP_ALPHA);
-       veffect_vframe = mwindow->theme->get_image("veffect_icon");
-       veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA);
-
-SET_TRACE
+
+       resource_icon(file_vframe,   file_icon,   "film_icon",   ICON_UNKNOWN);
+       resource_icon(folder_vframe, folder_icon, "folder_icon", ICON_FOLDER);
+       resource_icon(audio_vframe,  audio_icon,  "audio_icon",  ICON_SOUND);
+       resource_icon(video_vframe,  video_icon,  "video_icon",  ICON_FILM);
+       resource_icon(label_vframe,  label_icon,  "label_icon",  ICON_LABEL);
+
+       theme_icon(aeffect_folder_vframe,      aeffect_folder_icon,     "aeffect_folder");
+       theme_icon(atransition_folder_vframe,  atransition_folder_icon, "atransition_folder");
+       theme_icon(clip_folder_vframe,         clip_folder_icon,        "clip_folder");
+       theme_icon(label_folder_vframe,        label_folder_icon,       "label_folder");
+       theme_icon(media_folder_vframe,        media_folder_icon,       "media_folder");
+       theme_icon(proxy_folder_vframe,        proxy_folder_icon,       "proxy_folder");
+       theme_icon(veffect_folder_vframe,      veffect_folder_icon,     "veffect_folder");
+       theme_icon(vtransition_folder_vframe,  vtransition_folder_icon, "vtransition_folder");
+
+       folder_icons[AW_AEFFECT_FOLDER] = aeffect_folder_icon;
+       folder_icons[AW_VEFFECT_FOLDER] = veffect_folder_icon;
+       folder_icons[AW_ATRANSITION_FOLDER] = atransition_folder_icon;
+       folder_icons[AW_VTRANSITION_FOLDER] = vtransition_folder_icon;
+       folder_icons[AW_LABEL_FOLDER] = label_folder_icon;
+       folder_icons[AW_CLIP_FOLDER] = clip_folder_icon;
+       folder_icons[AW_MEDIA_FOLDER] = media_folder_icon;
+       folder_icons[AW_PROXY_FOLDER] = proxy_folder_icon;
+
+       theme_icon(clip_vframe,        clip_icon,        "clip_icon");
+       theme_icon(atransition_vframe, atransition_icon, "atransition_icon");
+       theme_icon(vtransition_vframe, vtransition_icon, "vtransition_icon");
+       theme_icon(aeffect_vframe,     aeffect_icon,     "aeffect_icon");
+       theme_icon(veffect_vframe,     veffect_icon,     "veffect_icon");
+
+       plugin_icon(ladspa_vframe, ladspa_icon, "lad_picon", lad_picon_png);
+       plugin_icon(ff_aud_vframe, ff_aud_icon, "ff_audio",  ff_audio_png);
+       plugin_icon(ff_vid_vframe, ff_vid_icon, "ff_video",  ff_video_png);
 
 // Mandatory folders
-       folders.append(picon = new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_LABEL_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_CLIP_FOLDER));
-       picon->persistent = 1;
-       folders.append(picon = new AssetPicon(mwindow, this, AW_MEDIA_FOLDER));
-       picon->persistent = 1;
+       folders.append(new AssetPicon(mwindow, this, AW_AEFFECT_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_VEFFECT_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_ATRANSITION_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_VTRANSITION_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_LABEL_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_CLIP_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_PROXY_FOLDER, 1));
+       folders.append(new AssetPicon(mwindow, this, AW_MEDIA_FOLDER, 1));
 
        create_label_folder();
-SET_TRACE
 
        mwindow->theme->get_awindow_sizes(this);
        load_defaults(mwindow->defaults);
 
-SET_TRACE
        add_subwindow(asset_list = new AWindowAssets(mwindow,
                this,
                mwindow->theme->alist_x,
@@ -593,7 +586,6 @@ SET_TRACE
        vicon_thread = new VIconThread(asset_list);
        vicon_thread->start();
 
-SET_TRACE
        add_subwindow(divider = new AWindowDivider(mwindow,
                this,
                mwindow->theme->adivider_x,
@@ -601,10 +593,8 @@ SET_TRACE
                mwindow->theme->adivider_w,
                mwindow->theme->adivider_h));
 
-SET_TRACE
        divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
 
-SET_TRACE
        int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
        int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
        VFrame **images = mwindow->theme->get_image_set("playpatch_data");
@@ -613,17 +603,13 @@ SET_TRACE
        add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, _("Visibility")));
        add_tools->create_objects();
        fy += add_tools->get_h();  fh -= add_tools->get_h();
-SET_TRACE
        add_subwindow(folder_list = new AWindowFolders(mwindow,
                this, fx, fy, fw, fh));
-SET_TRACE
        update_effects();
-SET_TRACE
 
        //int x = mwindow->theme->abuttons_x;
        //int y = mwindow->theme->abuttons_y;
 
-SET_TRACE
 
        newfolder_thread = new NewFolderThread(mwindow, this);
 
@@ -634,18 +620,17 @@ SET_TRACE
        add_subwindow(label_menu = new LabelPopup(mwindow, this));
        label_menu->create_objects();
 
+       add_subwindow(effectlist_menu = new EffectListMenu(mwindow, this));
+       effectlist_menu->create_objects();
        add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
        assetlist_menu->create_objects();
        add_subwindow(cliplist_menu = new ClipListMenu(mwindow, this));
        cliplist_menu->create_objects();
        add_subwindow(labellist_menu = new LabelListMenu(mwindow, this));
        labellist_menu->create_objects();
-SET_TRACE
 
        add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
        folderlist_menu->create_objects();
-SET_TRACE
-//printf("AWindowGUI::create_objects 2\n");
 
        create_custom_xatoms();
        unlock_window();
@@ -826,13 +811,21 @@ void AWindowRemovePlugin::handle_close_event(int result)
                mwindow->plugindb->remove(plugin);
                remove(plugin_path);
                char index_path[BCTEXTLEN];
-               sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
+               snprintf(index_path, sizeof(index_path), "%s/%s",
+                       mwindow->preferences->plugin_dir, PLUGIN_FILE);
                remove(index_path);
-               char png_path[BCTEXTLEN];
-               if( plugin->get_theme_png_path(png_path, mwindow->preferences->theme) )
-                       remove(png_path);
-               if( plugin->get_theme_png_path(png_path, "picon") )
-                       remove(png_path);
+               FileSystem fs;
+               fs.update(File::get_plugin_path());
+               for( int i=0; i<fs.dir_list.total; ++i ) {
+                       char *fs_path = fs.dir_list[i]->path;
+                       if( !fs.is_dir(fs_path) ) continue;
+                       char *cp = strrchr(fs_path,'/');
+                       cp = !cp ? fs_path : cp+1;
+                       if( strncmp("picon_", cp, 6) ) continue;
+                       char png_path[BCTEXTLEN];
+                       if( !plugin->get_plugin_png_path(png_path, cp+6) )
+                               remove(png_path);
+               }
                delete plugin;  plugin = 0;
                awindow->gui->async_update_assets();
        }
@@ -907,26 +900,18 @@ void AWindowGUI::async_update_assets()
 }
 
 
-
-
-
-
-
 void AWindowGUI::update_folder_list()
 {
        stop_vicon_drawing();
-//printf("AWindowGUI::update_folder_list 1\n");
        for( int i = 0; i < folders.total; i++ ) {
                AssetPicon *picon = (AssetPicon*)folders.values[i];
-               picon->in_use--;
+               picon->in_use = 0;
        }
-//printf("AWindowGUI::update_folder_list 1\n");
 
 // Search assets for folders
        for( int i = 0; i < mwindow->edl->folders.total; i++ ) {
                const char *folder = mwindow->edl->folders.values[i];
                int exists = 0;
-//printf("AWindowGUI::update_folder_list 1.1\n");
 
                for( int j = 0; j < folders.total; j++ ) {
                        AssetPicon *picon = (AssetPicon*)folders.values[j];
@@ -939,29 +924,23 @@ void AWindowGUI::update_folder_list()
 
                if( !exists ) {
                        int aw_folder = folder_number(folder);
-                       AssetPicon *picon = aw_folder >= 0 ?
-                               new AssetPicon(mwindow, this, aw_folder) :
-                               new AssetPicon(mwindow, this, folder, AW_USER_FOLDER);
-                       picon->create_objects();
-                       folders.append(picon);
+                       if( aw_folder >= 0 ) {
+                               AssetPicon *picon = new AssetPicon(mwindow, this, aw_folder, 1);
+                               picon->create_objects();
+                               folders.append(picon);
+                       }
                }
-//printf("AWindowGUI::update_folder_list 1.3\n");
        }
-//printf("AWindowGUI::update_folder_list 1\n");
-//for( int i = 0; i < folders.total; i++ )
-//     printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
 
-// Delete excess
-       for( int i = folders.total - 1; i >= 0; i-- ) {
+// Delete unused non-persistent folders
+       for( int i=folders.total; --i>=0; ) {
                AssetPicon *picon = (AssetPicon*)folders.values[i];
                if( !picon->in_use && !picon->persistent ) {
                        delete picon;
                        folders.remove_number(i);
                }
        }
-//for( int i = 0; i < folders.total; i++ )
-//     printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
-//printf("AWindowGUI::update_folder_list 2\n");
+
        start_vicon_drawing();
 }
 
@@ -997,19 +976,11 @@ void AWindowGUI::create_label_folder()
 
 void AWindowGUI::update_asset_list()
 {
-//printf("AWindowGUI::update_asset_list 1\n");
        for( int i = 0; i < assets.total; i++ ) {
                AssetPicon *picon = (AssetPicon*)assets.values[i];
-               picon->in_use--;
+               picon->in_use = 0;
        }
 
-
-
-
-
-//printf("AWindowGUI::update_asset_list 2\n");
-
-
 // Synchronize EDL clips
        for( int i = 0; i < mwindow->edl->clips.total; i++ ) {
                int exists = 0;
@@ -1029,20 +1000,12 @@ void AWindowGUI::update_asset_list()
 // Create new listitem
                if( !exists ) {
                        AssetPicon *picon = new AssetPicon(mwindow,
-                               this,
-                               mwindow->edl->clips.values[i]);
+                               this, mwindow->edl->clips.values[i]);
                        picon->create_objects();
                        assets.append(picon);
                }
        }
 
-
-
-
-
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
-
-
 // Synchronize EDL assets
        for( Asset *current = mwindow->edl->assets->first;
                current;
@@ -1063,11 +1026,9 @@ void AWindowGUI::update_asset_list()
 
 // Create new listitem
                if( !exists ) {
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
-                       AssetPicon *picon = new AssetPicon(mwindow, this, current);
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
+                       AssetPicon *picon = new AssetPicon(mwindow,
+                               this, current);
                        picon->create_objects();
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
                        assets.append(picon);
                }
        }
@@ -1076,9 +1037,6 @@ void AWindowGUI::update_asset_list()
        mwindow->gui->default_message();
        mwindow->gui->unlock_window();
 
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
-
-
 // Synchronize nested EDLs
        for( int i = 0; i < mwindow->edl->nested_edls->size(); i++ ) {
                int exists = 0;
@@ -1099,36 +1057,23 @@ void AWindowGUI::update_asset_list()
 // Create new listitem
                if( !exists ) {
                        AssetPicon *picon = new AssetPicon(mwindow,
-                               this,
-                               indexable);
+                               this, indexable);
                        picon->create_objects();
                        assets.append(picon);
                }
        }
 
-
-
-
-
-
-
-
-
-//printf("AWindowGUI::update_asset_list %d\n", __LINE__);
        for( int i = assets.size() - 1; i >= 0; i-- ) {
                AssetPicon *picon = (AssetPicon*)assets.get(i);
-//printf("AWindowGUI::update_asset_list %s %d\n", picon->asset->path, picon->in_use);
                if( !picon->in_use ) {
                        delete picon;
                        assets.remove_number(i);
                }
        }
-//printf("AWindowGUI::update_asset_list 7 %d\n", assets.total);
 }
 
 void AWindowGUI::update_picon(Indexable *indexable)
 {
-//printf("AWindowGUI::update_asset_list 1\n");
        VIcon *vicon = 0;
        for( int i = 0; i < assets.total; i++ ) {
                AssetPicon *picon = (AssetPicon*)assets.values[i];
@@ -1152,7 +1097,6 @@ void AWindowGUI::update_picon(Indexable *indexable)
 
 void AWindowGUI::sort_assets()
 {
-//printf("AWindowGUI::sort_assets 1 %s\n", mwindow->edl->session->current_folder);
        switch( mwindow->edl->session->awindow_folder ) {
        case AW_AEFFECT_FOLDER:
                sort_picons(&aeffects);
@@ -1176,6 +1120,12 @@ void AWindowGUI::sort_assets()
        update_assets();
 }
 
+void AWindowGUI::sort_folders()
+{
+       sort_picons(&folders);
+       update_assets();
+}
+
 void AWindowGUI::collect_assets()
 {
        int i = 0;
@@ -1199,10 +1149,8 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
        dst[1].remove_all_objects();
 
 // Create new pointers
-//if( folder ) printf("AWindowGUI::copy_picons 1 %s\n", folder);
        for( int i = 0; i < src->total; i++ ) {
                AssetPicon *picon = (AssetPicon*)src->values[i];
-//printf("AWindowGUI::copy_picons 2 %s\n", picon->asset->folder);
                if( folder < 0 ||
                    (picon->indexable && picon->indexable->awindow_folder == folder) ||
                    (picon->edl && picon->edl->local_session->awindow_folder == folder) ) {
@@ -1217,14 +1165,12 @@ void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
                                dst[1].append(item2 = new BC_ListBoxItem(""));
                        item1->set_autoplace_text(1);
                        item2->set_autoplace_text(1);
-//printf("AWindowGUI::copy_picons 3 %s\n", picon->get_text());
                }
        }
 }
 
 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src)
 {
-//printf("AWindowGUI::sort_picons 1\n")
        int done = 0;
        while(!done)
        {
@@ -1277,50 +1223,45 @@ void AWindowGUI::filter_displayed_assets()
        }
 
        // Ensure the current folder icon is highlighted
-       for( int i = 0; i < folders.total; i++ )
-               folders.values[i]->set_selected(0);
-
-       folders.values[mwindow->edl->session->awindow_folder]->set_selected(1);
+       int selected_folder = mwindow->edl->session->awindow_folder;
+       for( int i = 0; i < folders.total; i++ ) {
+               AssetPicon *folder_item = (AssetPicon *)folders.values[i];
+               int selected = folder_item->foldernum == selected_folder ? 1 : 0;
+               folder_item->set_selected(selected);
+       }
 }
 
 
 void AWindowGUI::update_assets()
 {
-//printf("AWindowGUI::update_assets 1\n");
        update_folder_list();
-//printf("AWindowGUI::update_assets 2\n");
        update_asset_list();
        labellist.remove_all_objects();
        create_label_folder();
-//printf("AWindowGUI::update_assets 3\n");
        filter_displayed_assets();
 
-//for( int i = 0; i < folders.total; i++ )
-//printf("AWindowGUI::update_assets 4\n");
-//     printf("AWindowGUI::update_assets %s\n", folders.values[i]->get_text());
-       if( mwindow->edl->session->folderlist_format != folder_list->get_format() )
+       if( mwindow->edl->session->folderlist_format != folder_list->get_format() ) {
                folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
-       folder_list->update(&folders, 0, 0, 1,
-               folder_list->get_xposition(),
-               folder_list->get_yposition(),
-               -1);
-//printf("AWindowGUI::update_assets 5\n");
+       }
+       int folder_xposition = folder_list->get_xposition();
+       int folder_yposition = folder_list->get_yposition();
+       folder_list->update(&folders, 0, 0, 1, folder_xposition, folder_yposition, -1);
 
-       if( mwindow->edl->session->assetlist_format != asset_list->get_format() )
+       if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
                asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
-
-
-//printf("AWindowGUI::update_assets 6 %d\n", displayed_assets[0].total);
+       }
+       int asset_xposition = asset_list->get_xposition();
+       int asset_yposition = asset_list->get_yposition();
+       if( displayed_folder != mwindow->edl->session->awindow_folder ) {
+               displayed_folder = mwindow->edl->session->awindow_folder;
+               asset_xposition = asset_yposition = 0;
+       }
        asset_list->update(displayed_assets, asset_titles,
                mwindow->edl->session->asset_columns, ASSET_COLUMNS,
-               asset_list->get_xposition(),
-               asset_list->get_yposition(),
-               -1, 0);
+               asset_xposition, asset_yposition, -1, 0);
        asset_list->center_selection();
-//printf("AWindowGUI::update_assets 7\n");
 
        flush();
-//printf("AWindowGUI::update_assets 8\n");
        return;
 }
 
@@ -1434,21 +1375,18 @@ int AWindowDivider::button_release_event()
 
 
 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
- : BC_ListBox(x,
-               y,
-               w,
-               h,
+ : BC_ListBox(x, y, w, h,
                mwindow->edl->session->folderlist_format == ASSETS_ICONS ?
                        LISTBOX_ICONS : LISTBOX_TEXT,
-               &gui->folders, // Each column has an ArrayList of BC_ListBoxItems.
-               0,             // Titles for columns.  Set to 0 for no titles
+               &gui->folders,    // Each column has an ArrayList of BC_ListBoxItems.
+               0,                // Titles for columns.  Set to 0 for no titles
                0,                // width of each column
-               1,                      // Total columns.
-               0,                    // Pixel of top of window.
-               0,                        // If this listbox is a popup window
-               LISTBOX_SINGLE,  // Select one item or multiple items
-               ICON_TOP,        // Position of icon relative to text of each item
-               1)               // Allow drags
+               1,                // Total columns.
+               0,                // Pixel of top of window.
+               0,                // If this listbox is a popup window
+               LISTBOX_SINGLE,   // Select one item or multiple items
+               ICON_TOP,         // Position of icon relative to text of each item
+               1)                // Allow drags
 {
        this->mwindow = mwindow;
        this->gui = gui;
@@ -1470,8 +1408,7 @@ int AWindowFolders::selection_changed()
                        gui->folderlist_menu->activate_menu();
                }
 
-               mwindow->edl->session->awindow_folder =  picon->foldernum;
-//printf("AWindowFolders::selection_changed 1\n");
+               mwindow->edl->session->awindow_folder = picon->foldernum;
                gui->asset_list->draw_background();
                gui->async_update_assets();
 
@@ -1509,18 +1446,19 @@ AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, in
                (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
                        LISTBOX_ICONS : LISTBOX_TEXT,
                &gui->assets,     // Each column has an ArrayList of BC_ListBoxItems.
-               gui->asset_titles,             // Titles for columns.  Set to 0 for no titles
-               mwindow->edl->session->asset_columns,                // width of each column
-               1,                      // Total columns.
-               0,                    // Pixel of top of window.
-               0,                        // If this listbox is a popup window
-               LISTBOX_MULTIPLE,  // Select one item or multiple items
-               ICON_TOP,        // Position of icon relative to text of each item
-               1)               // Allow drag
+               gui->asset_titles,// Titles for columns.  Set to 0 for no titles
+               mwindow->edl->session->asset_columns, // width of each column
+               1,                // Total columns.
+               0,                // Pixel of top of window.
+               0,                // If this listbox is a popup window
+               LISTBOX_MULTIPLE, // Select one item or multiple items
+               ICON_TOP,         // Position of icon relative to text of each item
+               1)                // Allow drag
 {
        this->mwindow = mwindow;
        this->gui = gui;
        set_drag_scroll(0);
+       set_scroll_stretch(1, 1);
 }
 
 AWindowAssets::~AWindowAssets()
@@ -1537,6 +1475,13 @@ int AWindowAssets::button_press_event()
                BC_ListBox::deactivate_selection();
                int folder = mwindow->edl->session->awindow_folder;
                switch( folder ) {
+               case AW_AEFFECT_FOLDER:
+               case AW_VEFFECT_FOLDER:
+               case AW_ATRANSITION_FOLDER:
+               case AW_VTRANSITION_FOLDER:
+                       gui->effectlist_menu->update();
+                       gui->effectlist_menu->activate_menu();
+                       break;
                case AW_LABEL_FOLDER:
                        gui->labellist_menu->update();
                        gui->labellist_menu->activate_menu();
@@ -1545,7 +1490,8 @@ int AWindowAssets::button_press_event()
                        gui->cliplist_menu->update();
                        gui->cliplist_menu->activate_menu();
                        break;
-               default:
+               case AW_MEDIA_FOLDER:
+               case AW_PROXY_FOLDER:
                        gui->assetlist_menu->update_titles();
                        gui->assetlist_menu->activate_menu();
                        break;
@@ -1553,14 +1499,12 @@ int AWindowAssets::button_press_event()
                result = 1;
        }
 
-
        return result;
 }
 
 
 int AWindowAssets::handle_event()
 {
-//printf("AWindowAssets::handle_event 1 %d %d\n", get_buttonpress(), get_selection(0, 0));
        AssetPicon *asset_picon = (AssetPicon *)get_selection(0, 0);
        if( !asset_picon ) return 0;
        switch( mwindow->edl->session->awindow_folder ) {
@@ -1572,7 +1516,6 @@ int AWindowAssets::handle_event()
        VWindow *vwindow = mwindow->vwindows.size() > DEFAULT_VWINDOW ?
                mwindow->vwindows.get(DEFAULT_VWINDOW) : 0;
        if( !vwindow || !vwindow->is_running() ) return 1;
-//printf("AWindowAssets::handle_event 2 %d %d\n", get_buttonpress(), get_selection(0, 0));
 
        vwindow->gui->lock_window("AWindowAssets::handle_event");
        if( asset_picon->indexable )
@@ -1595,8 +1538,8 @@ int AWindowAssets::selection_changed()
                case AW_VEFFECT_FOLDER:
                case AW_ATRANSITION_FOLDER:
                case AW_VTRANSITION_FOLDER:
-                       gui->assetlist_menu->update_titles();
-                       gui->assetlist_menu->activate_menu();
+                       gui->effectlist_menu->update();
+                       gui->effectlist_menu->activate_menu();
                        break;
                case AW_LABEL_FOLDER:
                        if( !item->label ) break;
@@ -1863,19 +1806,21 @@ int AWindowDeleteProject::handle_event()
        return 1;
 }
 
-AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
- : BC_Button(x, y, mwindow->theme->infoasset_data)
-{
-       this->mwindow = mwindow;
-       this->gui = gui;
-       set_tooltip(_("Edit information on asset"));
-}
-
-int AWindowInfo::handle_event()
-{
-       gui->awindow->asset_edit->edit_asset(gui->selected_asset());
-       return 1;
-}
+// AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
+//  : BC_Button(x, y, mwindow->theme->infoasset_data)
+// {
+//     this->mwindow = mwindow;
+//     this->gui = gui;
+//     set_tooltip(_("Edit information on asset"));
+// }
+// 
+// int AWindowInfo::handle_event()
+// {
+//     int cur_x, cur_y;
+//     gui->get_abs_cursor_xy(cur_x, cur_y, 0);
+//     gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y);
+//     return 1;
+// }
 
 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
  : BC_Button(x, y, mwindow->theme->redrawindex_data)
@@ -2027,15 +1972,15 @@ int AVIconDrawing::handle_event()
 }
 
 
-AWindowListFormat::AWindowListFormat(MWindow *mwindow)
+AWindowListFormat::AWindowListFormat(MWindow *mwindow, AWindowGUI *gui)
  : BC_MenuItem("")
 {
        this->mwindow = mwindow;
+       this->gui = gui;
 }
 
 int AWindowListFormat::handle_event()
 {
-       AWindowGUI *gui = mwindow->awindow->gui;
        gui->stop_vicon_drawing();
 
        EDLSession *session = mwindow->edl->session;
@@ -2063,17 +2008,16 @@ void AWindowListFormat::update()
                 (char*)_("Display icons") : (char*)_("Display text"));
 }
 
-AWindowListSort::AWindowListSort(MWindow *mwindow)
+AWindowListSort::AWindowListSort(MWindow *mwindow, AWindowGUI *gui)
  : BC_MenuItem(_("Sort items"))
 {
        this->mwindow = mwindow;
+       this->gui = gui;
 }
 
 int AWindowListSort::handle_event()
 {
-       AWindowGUI *gui = mwindow->awindow->gui;
        gui->sort_assets();
        return 1;
 }
 
-