Example #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 );
        }
    } 
}
Example #2
0
void CollectionsPanel::UpdateCollections()
{
    m_CollectionToItemIDs.clear();

    PrePopulateTreeCtrl( m_TempCollectionsTreeCtrl );
    PrePopulateTreeCtrl( m_MyCollectionsTreeCtrl );
    {   
        u32 tempItemsAdded = 0;
        u32 myItemsAdded = 0;
        for ( M_AssetCollections::const_iterator itr = m_CollectionManager->GetCollections().begin(),
            end = m_CollectionManager->GetCollections().end(); itr != end; ++itr )
        {    
            AssetCollection* collection = itr->second;
            HELIUM_ASSERT( collection );

            if ( !collection )
                continue;

            int iconIndex = m_ContainerImageIndex;
            if ( collection->GetType() == Reflect::GetType< Editor::AssetCollection >() )
            {
                iconIndex = m_ContainerImageIndex;
            }

            SortTreeCtrl* treeCtrl = NULL;
            if ( collection->IsTemporary() )
            {
                treeCtrl = m_TempCollectionsTreeCtrl;
                ++tempItemsAdded;
            }
            else
            {
                treeCtrl = m_MyCollectionsTreeCtrl;
                ++myItemsAdded;
            }

            wxTreeItemId itemID = treeCtrl->AppendItem(
                treeCtrl->GetRootItem(),
                collection->GetDisplayName(),
                iconIndex,
                -1,
                new AssetCollectionItemData( collection ) );

            m_CollectionToItemIDs.insert( M_CollectionToItemID::value_type( collection->GetPath().Hash(), itemID ) );
        }

        m_TempCollectionsTreeCtrl->Enable( tempItemsAdded > 0 );
        if ( tempItemsAdded < 1 )
        {
            wxTreeItemId itemID = m_TempCollectionsTreeCtrl->AppendItem( m_TempCollectionsTreeCtrl->GetRootItem(), TXT( "None Available" ) );
        }
    }
    PostPopulateTreeCtrl( m_MyCollectionsTreeCtrl );
    PostPopulateTreeCtrl( m_TempCollectionsTreeCtrl );
}
Example #3
0
void CollectionsPanel::OnCloseCollection( 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->IsTemporary() )
    {
        if ( event.GetId() == ID_DeleteCollection )
        {
            tstring warning = TXT( "Are you sure you'd like permenantly delete your collection \"" );
            warning += collection->GetName() + TXT( "\"?" );

            if ( wxYES == 
                wxMessageBox( warning,
                TXT( "Delete Colleciton?" ), 
                wxCENTER | wxYES_NO | wxICON_WARNING,
                this ) )
            {
                m_CollectionManager->DeleteCollection( collection );
            }
        }
        else
        {
            m_CollectionManager->CloseCollection( collection );
        }
    }
}