Changeset 518

Show
Ignore:
Timestamp:
09/25/08 11:16:07 (2 months ago)
Author:
wolke
Message:

soundlibrary panel background change color enhancement. now works if playlist load a new song and also work at 'new song' and 'open song' from mainform.cpp

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gui/src/MainForm.cpp

    r503 r518  
    454454        h2app->setSong(song); 
    455455        Hydrogen::get_instance()->setSelectedPatternNumber( 0 ); 
     456        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
    456457} 
    457458 
     
    631632        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 
    632633} 
     634 
     635 
    633636 
    634637void MainForm::action_file_open() { 
     
    695698                openSongFile( filename ); 
    696699        } 
     700 
     701        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
    697702} 
    698703 
  • trunk/gui/src/PlaylistEditor/PlaylistDialog.cpp

    r517 r518  
    2424#include "PlaylistDialog.h" 
    2525#include "../HydrogenApp.h" 
     26#include "../InstrumentRack.h" 
     27#include "SoundLibrary/SoundLibraryPanel.h" 
    2628 
    2729#include <hydrogen/LocalFileMng.h> 
     
    725727        pH2App->setStatusBarMessage( trUtf8( "Playlist: Set song No. %1" ).arg( index +1 ), 5000 ); 
    726728 
     729        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
     730 
    727731///exec script 
    728732///this is very very simple and only an experiment 
  • trunk/gui/src/SoundLibrary/SoundLibraryPanel.cpp

    r517 r518  
    474474void SoundLibraryPanel::on_drumkitLoadAction() 
    475475{ 
     476        restore_background_color(); 
     477 
     478        QString sDrumkitName = __sound_library_tree->currentItem()->text(0); 
     479 
     480        Drumkit *drumkitInfo = NULL; 
     481 
     482        // find the drumkit in the list 
     483        for ( uint i = 0; i < __system_drumkit_info_list.size(); i++ ) { 
     484                Drumkit *pInfo = __system_drumkit_info_list[i]; 
     485                if ( pInfo->getName() == sDrumkitName ) { 
     486                        drumkitInfo = pInfo; 
     487                        break; 
     488                } 
     489        } 
     490        for ( uint i = 0; i < __user_drumkit_info_list.size(); i++ ) { 
     491                Drumkit *pInfo = __user_drumkit_info_list[i]; 
     492                if ( pInfo->getName() == sDrumkitName ) { 
     493                        drumkitInfo = pInfo; 
     494                        break; 
     495                } 
     496        } 
     497        assert( drumkitInfo ); 
     498 
     499        setCursor( QCursor( Qt::WaitCursor ) ); 
     500 
     501        Hydrogen::get_instance()->loadDrumkit( drumkitInfo ); 
     502        Hydrogen::get_instance()->getSong()->__is_modified = true; 
     503        HydrogenApp::getInstance()->onDrumkitLoad( drumkitInfo->getName() ); 
     504 
     505        __sound_library_tree->currentItem()->setBackgroundColor ( 0, QColor( 50, 50, 50) ); 
     506 
     507        setCursor( QCursor( Qt::ArrowCursor ) ); 
     508 
     509        // update drumkit info in save tab 
     510        //saveTab_nameTxt ->setText( QString( drumkitInfo->getName().c_str() ) ); 
     511        //saveTab_authorTxt->setText( QString( drumkitInfo->getAuthor().c_str() ) ); 
     512        //saveTab_infoTxt->append( QString( drumkitInfo->getInfo().c_str() ) ); 
     513 
     514//      HydrogenApp::getInstance()->getPatternEditorPanel()->getPatternEditor()->updateEditor( true ); 
     515 
     516//HydrogenApp::getInstance()->getPatternEditorPanel()->getDrumPatternEditor()->updateEditor(); 
     517} 
     518 
     519 
     520 
     521void SoundLibraryPanel::update_background_color() 
     522{ 
     523        restore_background_color(); 
     524        change_background_color(); 
     525} 
     526 
     527 
     528 
     529void SoundLibraryPanel::restore_background_color() 
     530{ 
    476531        std::vector<QString> systemList = Drumkit::getSystemDrumkitList(); 
    477532        std::vector<QString> userList = Drumkit::getUserDrumkitList(); 
     
    481536                if (  !__system_drumkits_item->child( i ) ) 
    482537                        break; 
    483                 if ( ( __system_drumkits_item->child( i ) )->text( 0 ) == curlib ){ 
    484                         ( __system_drumkits_item->child( i ) )->setBackground( 0, QBrush() ); 
    485                         break; 
    486                 } 
     538                ( __system_drumkits_item->child( i ) )->setBackground( 0, QBrush() ); 
     539                 
     540                 
    487541        } 
    488542 
     
    490544                if (  !__user_drumkits_item->child( i ) ) 
    491545                        break; 
     546                ( __user_drumkits_item->child( i ) )->setBackground(0, QBrush() ); 
     547        } 
     548} 
     549 
     550 
     551 
     552void SoundLibraryPanel::change_background_color() 
     553{ 
     554        std::vector<QString> systemList = Drumkit::getSystemDrumkitList(); 
     555        std::vector<QString> userList = Drumkit::getUserDrumkitList(); 
     556        QString curlib =  Hydrogen::get_instance()->m_currentDrumkit; 
     557  
     558        for (uint i = 0; i < systemList.size() ; i++){ 
     559                if (  !__system_drumkits_item->child( i ) ) 
     560                        break; 
     561                if ( ( __system_drumkits_item->child( i ) )->text( 0 ) == curlib ){ 
     562                        ( __system_drumkits_item->child( i ) )->setBackgroundColor ( 0, QColor( 50, 50, 50)  ); 
     563                        break; 
     564                } 
     565        } 
     566 
     567        for (uint i = 0; i < userList.size() ; i++){ 
     568                if (  !__user_drumkits_item->child( i ) ) 
     569                        break; 
    492570                if ( ( __user_drumkits_item->child( i ))->text( 0 ) == curlib ){ 
    493                         ( __user_drumkits_item->child( i ) )->setBackground(0, QBrush() ); 
    494                         break; 
    495                 } 
    496         } 
    497  
     571                        ( __user_drumkits_item->child( i ) )->setBackgroundColor ( 0, QColor( 50, 50, 50)  ); 
     572                        break; 
     573                } 
     574        } 
     575
     576 
     577 
     578 
     579void SoundLibraryPanel::on_drumkitDeleteAction() 
     580
     581        QString sSoundLibrary = __sound_library_tree->currentItem()->text( 0 ); 
     582 
     583        //if we delete the current loaded drumkit we can get truble with some empty pointers 
     584        if ( sSoundLibrary == Hydrogen::get_instance()->getCurrentDrumkitname() ){ 
     585                QMessageBox::warning( this, "Hydrogen", QString( "You try to delet the current loaded drumkit.\nThis is not possible!") ); 
     586                return; 
     587        } 
     588 
     589        bool bIsUserSoundLibrary = false; 
     590        std::vector<QString> userList = Drumkit::getUserDrumkitList(); 
     591        for ( uint i = 0; i < userList.size(); ++i ) { 
     592                if ( userList[ i ].endsWith( sSoundLibrary ) ) { 
     593                        bIsUserSoundLibrary = true; 
     594                        break; 
     595                } 
     596        } 
     597 
     598        if ( bIsUserSoundLibrary == false ) { 
     599                QMessageBox::warning( this, "Hydrogen", QString( "A system drumkit can't be deleted.") ); 
     600                return; 
     601        } 
     602 
     603        int res = QMessageBox::information( this, "Hydrogen", tr( "Warning, the selected drumkit will be deleted from disk.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 ); 
     604        if ( res == 1 ) { 
     605                return; 
     606        } 
     607 
     608        Drumkit::removeDrumkit( sSoundLibrary ); 
     609        test_expandedItems(); 
     610        updateDrumkitList(); 
     611
     612 
     613 
     614 
     615void SoundLibraryPanel::on_drumkitExportAction() 
     616
     617        SoundLibraryExportDialog exportDialog( this ); 
     618        exportDialog.exec(); 
     619
     620 
     621 
     622 
     623void SoundLibraryPanel::on_drumkitPropertiesAction() 
     624
    498625        QString sDrumkitName = __sound_library_tree->currentItem()->text(0); 
    499626 
     
    509636        } 
    510637        for ( uint i = 0; i < __user_drumkit_info_list.size(); i++ ) { 
    511                 Drumkit *pInfo = __user_drumkit_info_list[i]; 
    512                 if ( pInfo->getName() == sDrumkitName ) { 
    513                         drumkitInfo = pInfo; 
    514                         break; 
    515                 } 
    516         } 
    517         assert( drumkitInfo ); 
    518  
    519         setCursor( QCursor( Qt::WaitCursor ) ); 
    520  
    521         Hydrogen::get_instance()->loadDrumkit( drumkitInfo ); 
    522         Hydrogen::get_instance()->getSong()->__is_modified = true; 
    523         HydrogenApp::getInstance()->onDrumkitLoad( drumkitInfo->getName() ); 
    524  
    525         __sound_library_tree->currentItem()->setBackgroundColor ( 0, QColor( 50, 50, 50) ); 
    526  
    527         setCursor( QCursor( Qt::ArrowCursor ) ); 
    528  
    529         // update drumkit info in save tab 
    530         //saveTab_nameTxt ->setText( QString( drumkitInfo->getName().c_str() ) ); 
    531         //saveTab_authorTxt->setText( QString( drumkitInfo->getAuthor().c_str() ) ); 
    532         //saveTab_infoTxt->append( QString( drumkitInfo->getInfo().c_str() ) ); 
    533  
    534 //      HydrogenApp::getInstance()->getPatternEditorPanel()->getPatternEditor()->updateEditor( true ); 
    535  
    536 //HydrogenApp::getInstance()->getPatternEditorPanel()->getDrumPatternEditor()->updateEditor(); 
    537 } 
    538  
    539  
    540  
    541 void SoundLibraryPanel::on_drumkitDeleteAction() 
    542 { 
    543         QString sSoundLibrary = __sound_library_tree->currentItem()->text( 0 ); 
    544  
    545         //if we delete the current loaded drumkit we can get truble with some empty pointers 
    546         if ( sSoundLibrary == Hydrogen::get_instance()->getCurrentDrumkitname() ){ 
    547                 QMessageBox::warning( this, "Hydrogen", QString( "You try to delet the current loaded drumkit.\nThis is not possible!") ); 
    548                 return; 
    549         } 
    550  
    551         bool bIsUserSoundLibrary = false; 
    552         std::vector<QString> userList = Drumkit::getUserDrumkitList(); 
    553         for ( uint i = 0; i < userList.size(); ++i ) { 
    554                 if ( userList[ i ].endsWith( sSoundLibrary ) ) { 
    555                         bIsUserSoundLibrary = true; 
    556                         break; 
    557                 } 
    558         } 
    559  
    560         if ( bIsUserSoundLibrary == false ) { 
    561                 QMessageBox::warning( this, "Hydrogen", QString( "A system drumkit can't be deleted.") ); 
    562                 return; 
    563         } 
    564  
    565         int res = QMessageBox::information( this, "Hydrogen", tr( "Warning, the selected drumkit will be deleted from disk.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 ); 
    566         if ( res == 1 ) { 
    567                 return; 
    568         } 
    569  
    570         Drumkit::removeDrumkit( sSoundLibrary ); 
    571         test_expandedItems(); 
    572         updateDrumkitList(); 
    573 } 
    574  
    575  
    576  
    577 void SoundLibraryPanel::on_drumkitExportAction() 
    578 { 
    579         SoundLibraryExportDialog exportDialog( this ); 
    580         exportDialog.exec(); 
    581 } 
    582  
    583  
    584  
    585 void SoundLibraryPanel::on_drumkitPropertiesAction() 
    586 { 
    587         QString sDrumkitName = __sound_library_tree->currentItem()->text(0); 
    588  
    589         Drumkit *drumkitInfo = NULL; 
    590  
    591         // find the drumkit in the list 
    592         for ( uint i = 0; i < __system_drumkit_info_list.size(); i++ ) { 
    593                 Drumkit *pInfo = __system_drumkit_info_list[i]; 
    594                 if ( pInfo->getName() == sDrumkitName ) { 
    595                         drumkitInfo = pInfo; 
    596                         break; 
    597                 } 
    598         } 
    599         for ( uint i = 0; i < __user_drumkit_info_list.size(); i++ ) { 
    600638                Drumkit*pInfo = __user_drumkit_info_list[i]; 
    601639                if ( pInfo->getName() == sDrumkitName ) { 
  • trunk/gui/src/SoundLibrary/SoundLibraryPanel.h

    r439 r518  
    5151        void updateDrumkitList(); 
    5252        void test_expandedItems(); 
     53        void update_background_color(); 
    5354 
    5455private slots: 
     
    8990        bool __expand_pattern_list; 
    9091        bool __expand_songs_list; 
     92        void restore_background_color(); 
     93        void change_background_color(); 
     94 
    9195}; 
    9296 
  • trunk/libs/hydrogen/src/playlist.cpp

    r326 r518  
    2121 */ 
    2222 
    23 //#include "PlaylistDialog.h" 
    24  
     23#include "gui/src/HydrogenApp.h" 
     24#include "gui/src/InstrumentRack.h" 
     25#include "gui/src/SoundLibrary/SoundLibraryPanel.h" 
    2526 
    2627#include <hydrogen/LocalFileMng.h> 
     
    2930#include <hydrogen/hydrogen.h> 
    3031#include <hydrogen/playlist.h> 
    31 #include "gui/src/HydrogenApp.h" 
    3232 
    3333#include <vector> 
     
    9494        loadSong( selected ); 
    9595        execScript( realNumber ); 
     96 
     97        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
    9698} 
    9799 
     
    123125        loadSong( selected ); 
    124126        execScript( index ); 
     127 
     128        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
    125129} 
    126130 
     
    153157        loadSong( selected ); 
    154158        execScript( index ); 
     159 
     160        HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->update_background_color(); 
    155161} 
    156162