vicon drag tweaks, proxy drag fix, vicon mouseover, binfolder around sort fix, draw_r...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetpopup.C
index 07cc8eb4dd1ded8c0f336bd1616bce654247bd32..fe52bbd6936336a0ac2a848ae37606f0cac296e7 100644 (file)
 #include "edl.h"
 #include "edlsession.h"
 #include "file.h"
+#include "filesystem.h"
 #include "filexml.h"
 #include "language.h"
+#include "loadfile.h"
 #include "localsession.h"
 #include "mainerror.h"
 #include "mainindexes.h"
+#include "mainmenu.h"
 #include "mainsession.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
@@ -73,10 +76,7 @@ void AssetPopup::create_objects()
        BC_SubMenu *submenu;
        add_item(info = new AssetPopupInfo(mwindow, this));
        add_item(format = new AWindowListFormat(mwindow, gui));
-       add_item(menu_item = new BC_MenuItem(_("Sort...")));
-       menu_item->add_submenu(submenu = new BC_SubMenu());
-       submenu->add_submenuitem(new AssetPopupSortNames(mwindow, this));
-       submenu->add_submenuitem(new AssetPopupSortTimes(mwindow, this));
+       add_item(new AssetPopupSort(mwindow, this));
        add_item(index = new AssetPopupBuildIndex(mwindow, this));
        add_item(view = new AssetPopupView(mwindow, this));
        add_item(view_window = new AssetPopupViewWindow(mwindow, this));
@@ -100,10 +100,10 @@ void AssetPopup::paste_assets()
        mwindow->gui->lock_window("AssetPopup::paste_assets");
        mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
 
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
-               mwindow->edl->tracks->first,
-               0);   // do not overwrite
+               mwindow->edl->tracks->first, 0);   // do not overwrite
 
        gui->unlock_window();
        mwindow->gui->unlock_window();
@@ -140,7 +140,8 @@ void AssetPopup::match_all()
 int AssetPopup::update()
 {
        format->update();
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        return 0;
 }
 
@@ -195,37 +196,20 @@ int AssetPopupBuildIndex::handle_event()
 }
 
 
-AssetPopupSortNames::AssetPopupSortNames(MWindow *mwindow, AssetPopup *popup)
- : BC_MenuItem(_("Sort names"))
-{
-       this->mwindow = mwindow;
-       this->popup = popup;
-}
-
-AssetPopupSortNames::~AssetPopupSortNames()
-{
-}
-
-int AssetPopupSortNames::handle_event()
-{
-       mwindow->awindow->gui->sort_assets(0);
-       return 1;
-}
-
-AssetPopupSortTimes::AssetPopupSortTimes(MWindow *mwindow, AssetPopup *popup)
- : BC_MenuItem(_("Sort times"))
+AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
+ : BC_MenuItem(_("Sort"))
 {
        this->mwindow = mwindow;
        this->popup = popup;
 }
 
-AssetPopupSortTimes::~AssetPopupSortTimes()
+AssetPopupSort::~AssetPopupSort()
 {
 }
 
-int AssetPopupSortTimes::handle_event()
+int AssetPopupSort::handle_event()
 {
-       mwindow->awindow->gui->sort_assets(1);
+       mwindow->awindow->gui->sort_assets();
        return 1;
 }
 
@@ -418,6 +402,7 @@ AssetListMenu::~AssetListMenu()
 
 void AssetListMenu::create_objects()
 {
+       add_item(load_file = new AssetPopupLoadFile(mwindow, gui));
        add_item(format = new AWindowListFormat(mwindow, gui));
        add_item(new AWindowListSort(mwindow, gui));
        add_item(new AssetListCopy(mwindow, gui));
@@ -439,6 +424,23 @@ void AssetListMenu::create_objects()
        update_titles(shots_displayed = 1);
 }
 
+AssetPopupLoadFile::AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui)
+ : BC_MenuItem(_("Load files..."), "o", 'o')
+{
+       this->mwindow = mwindow;
+       this->gui = gui;
+}
+
+AssetPopupLoadFile::~AssetPopupLoadFile()
+{
+}
+
+int AssetPopupLoadFile::handle_event()
+{
+       mwindow->gui->mainmenu->load_file->thread->start();
+       return 1;
+}
+
 void AssetListMenu::update_titles(int shots)
 {
        format->update();
@@ -557,6 +559,7 @@ AssetCopyWindow::~AssetCopyWindow()
 
 void AssetCopyWindow::create_objects()
 {
+       lock_window("AssetCopyWindow::create_objects");
        BC_Title *title;
        int x = 10, y = 10, pad = 5;
        add_subwindow(title = new BC_Title(x, y, _("List of asset paths:")));
@@ -571,6 +574,7 @@ void AssetCopyWindow::create_objects()
 
        add_subwindow(new BC_OKButton(this));
        show_window();
+       unlock_window();
 }
 
 int AssetCopyWindow::resize_event(int w, int h)
@@ -682,6 +686,7 @@ AssetPasteWindow::~AssetPasteWindow()
 
 void AssetPasteWindow::create_objects()
 {
+       lock_window("AssetPasteWindow::create_objects()");
        BC_Title *title;
        int x = 10, y = 10, pad = 5;
        add_subwindow(title = new BC_Title(x, y, _("Enter list of asset paths:")));
@@ -694,6 +699,7 @@ void AssetPasteWindow::create_objects()
        add_subwindow(new BC_OKButton(this));
        add_subwindow(new BC_CancelButton(this));
        show_window();
+       unlock_window();
 }
 
 int AssetPasteWindow::resize_event(int w, int h)
@@ -754,10 +760,13 @@ int SnapshotMenuItem::handle_event()
                preferences->snapshot_path, _("snap"),
                1900+tm.tm_year,1+tm.tm_mon,tm.tm_mday,
                tm.tm_hour,tm.tm_min,tm.tm_sec, exts[mode]);
+       char *asset_path = FileSystem::basepath(filename);
+       Asset *asset = new Asset(asset_path);
+       delete [] asset_path;
+
        int fw = edl->get_w(), fh = edl->get_h();
        int fcolor_model = edl->session->color_model;
 
-       Asset *asset = new Asset(filename);
        switch( mode ) {
        case SNAPSHOT_PNG:
                asset->format = FILE_PNG;
@@ -976,8 +985,9 @@ int GrabshotPopup::grab_event(XEvent *event)
                preferences->snapshot_path, _("grab"),
                1900+tm.tm_year,1+tm.tm_mon,tm.tm_mday,
                tm.tm_hour,tm.tm_min,tm.tm_sec, exts[mode]);
-
-       Asset *asset = new Asset(filename);
+       char *asset_path = FileSystem::basepath(filename);
+       Asset *asset = new Asset(asset_path);
+       delete [] asset_path;
        switch( mode ) {
        case GRABSHOT_PNG:
                asset->format = FILE_PNG;