Esempio n. 1
0
void CollectionsPanel::OnMyCollectionsMenu( wxTreeEvent& event )
{
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;

    wxTreeItemId item = event.GetItem();
    if ( !item )
    {
        return;
    }

    wxTreeItemId rootID = treeCtrl->GetRootItem();
    if( item != rootID )
    {
        treeCtrl->SelectItem( item );

        AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
        if ( !baseData )
        {
            return;
        }

        AssetCollection* collection = baseData->GetCollection<AssetCollection>();
        if ( collection )
        {
            std::set< Helium::Path > paths;
            m_VaultFrame->GetSelectedPaths( paths );

            wxMenu menu;

            menu.Append( ID_ShowCollection, VaultMenu::Label( ID_ShowCollection ), VaultMenu::Label( ID_ShowCollection ), wxITEM_NORMAL );
            menu.AppendSeparator();
            menu.Append( ID_AddToCollection, VaultMenu::Label( ID_AddToCollection ), VaultMenu::Label( ID_AddToCollection ), wxITEM_NORMAL );
            menu.Append( ID_RemoveFromCollection, VaultMenu::Label( ID_RemoveFromCollection ), VaultMenu::Label( ID_RemoveFromCollection ), wxITEM_NORMAL );
            menu.AppendSeparator();
            menu.Append( ID_ImportIntoCollection, VaultMenu::Label( ID_ImportIntoCollection ), VaultMenu::Label( ID_ImportIntoCollection ), wxITEM_NORMAL );
            menu.Append( ID_SaveCollection, VaultMenu::Label( ID_SaveCollection ), VaultMenu::Label( ID_SaveCollection ), wxITEM_NORMAL );
            menu.AppendSeparator();
            menu.Append( ID_RenameCollection, VaultMenu::Label( ID_RenameCollection ), VaultMenu::Label( ID_RenameCollection ), wxITEM_NORMAL );
            //menu.Append( ID_CloseCollection, VaultMenu::Label( ID_CloseCollection ), VaultMenu::Label( ID_CloseCollection ), wxITEM_NORMAL );
            menu.Append( ID_DeleteCollection, VaultMenu::Label( ID_DeleteCollection ), VaultMenu::Label( ID_DeleteCollection ), wxITEM_NORMAL );


            menu.Enable( ID_AddToCollection, !collection->IsDynamic() && !paths.empty() );
            menu.Enable( ID_RemoveFromCollection, !collection->IsDynamic() && !paths.empty() );

            menu.Enable( ID_ImportIntoCollection, !collection->IsDynamic() );
            menu.Enable( ID_SaveCollection, true );

            menu.Enable( ID_RenameCollection, collection->CanRename() );
            //menu.Enable( ID_CloseCollection, !collection->IsTemporary() );
            menu.Enable( ID_DeleteCollection, !collection->IsTemporary() );

            // Show the menu
            PopupMenu( &menu );
        }
    } 
}
Esempio n. 2
0
void CollectionsPanel::UpdateCollection( CollectionAction action )
{
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;
    wxTreeItemId rootID = treeCtrl->GetRootItem();

    wxTreeItemId item = treeCtrl->GetSelection();
    if( !item || item == rootID )
    {
        return;
    }

    AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
    if ( !baseData )
    {
        return;
    }

    AssetCollection* collection = baseData->GetCollection<AssetCollection>();
    if ( !collection || collection->IsDynamic() )
    {
        return;
    }

    std::set< Helium::Path > paths;
    m_VaultFrame->GetSelectedPaths( paths );

    if ( !paths.empty() )
    {
        collection->Freeze();
        for ( std::set< Helium::Path >::const_iterator itr = paths.begin(), end = paths.end(); itr != end; ++itr )
        {
            if ( (*itr).IsFile() )
            {
                switch ( action )
                {
                case CollectionActions::Add:
                    collection->AddAsset( *itr );
                    break;
                case CollectionActions::Remove:
                    collection->RemoveAsset( *itr );
                    break;
                default:
                    HELIUM_BREAK();
                    break;
                }
            }
        }
        collection->Thaw();
    }
}
Esempio n. 3
0
void CollectionsPanel::OnImportIntoCollection( wxCommandEvent& event )
{
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;
    wxTreeItemId rootID = treeCtrl->GetRootItem();

    wxTreeItemId item = treeCtrl->GetSelection();
    if( !item || item == rootID )
    {
        return;
    }

    AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
    if ( !baseData )
    {
        return;
    }

    AssetCollection* collection = baseData->GetCollection<AssetCollection>();
    if ( !collection || collection->IsDynamic() )
    {
        return;
    }

    Helium::FileDialog browserDlg( this, VaultMenu::Label( ID_ImportIntoCollection ), TXT( "" ), TXT( "" ), TXT( "" ),
        Helium::FileDialogStyles::DefaultOpen | Helium::FileDialogStyles::ShowAllFilesFilter | Helium::FileDialogStyles::ExportFile );

    std::vector< tstring > filters;
    AssetCollection::GetFileFilters( filters );
    browserDlg.AddFilters( filters );

    if ( browserDlg.ShowModal() == wxID_OK )
    {
        collection->Freeze();
        m_CollectionManager->ImportIntoStaticCollection( collection, (const wxChar*)browserDlg.GetPath().c_str() );
        collection->Thaw();
    }
}