From ab42375731b32eb853fc4039de9ea5ada0aafe63 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Sat, 22 Mar 2008 08:32:06 +0000 Subject: [PATCH] first shot at instrumentTrackWindow cache git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@803 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 17 ++++++++ include/instrument_track.h | 10 +++++ plugins/organic/organic.cpp | 1 - src/core/lmms_style.cpp | 3 +- src/core/main.cpp | 16 +++++++- src/tracks/instrument_track.cpp | 73 +++++++++++++++++++++++++++------ 6 files changed, 103 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 067cc4ec1..915167622 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-03-22 Paul Giblock + + * plugins/organic/organic.cpp: + Removed debug printf + + * include/instrument_track.h: + * src/tracks/instrument_track.cpp: + - First version of cache for hidden instrumentTrackWindows + - Need to delete the cache and any remaining ITW's upon application close + + * src/core/lmms_style.cpp: + Applied border to more primatives. Still some known issues.. + + * src/core/main.cpp: + Just playing around with palette colors. + + 2008-03-16 Paul Giblock * Makefile.am: diff --git a/include/instrument_track.h b/include/instrument_track.h index 2558047f5..ea69f5092 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -45,6 +45,7 @@ class QLineEdit; +template class QQueue; class arpeggiatorView; class chordCreatorView; class effectRackView; @@ -220,6 +221,8 @@ public: } + void freeInstrumentTrackWindow( void ); + private slots: void toggledInstrumentTrackButton( bool _on ); void activityIndicatorPressed( void ); @@ -230,6 +233,8 @@ private slots: private: instrumentTrackWindow * m_window; + + static QQueue s_windows; // widgets in track-settings-widget volumeKnob * m_tswVolumeKnob; @@ -271,6 +276,11 @@ public: return( castModel() ); } + void setInstrumentTrackView( instrumentTrackView * _tv ) + { + m_itv = _tv; + } + public slots: void textChanged( const QString & _new_name ); diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index 45aed3003..c073aebce 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -524,7 +524,6 @@ void oscillatorObject::oscButtonChanged( void ) void oscillatorObject::updateVolume( void ) { - printf("Updating VOL\n"); m_volumeLeft = ( 1.0f - m_panKnob.value() / (float)PANNING_RIGHT ) * m_volKnob.value() / m_numOscillators / 100.0f; m_volumeRight = ( 1.0f + m_panKnob.value() / (float)PANNING_RIGHT ) diff --git a/src/core/lmms_style.cpp b/src/core/lmms_style.cpp index 1f14381ac..810ec2feb 100644 --- a/src/core/lmms_style.cpp +++ b/src/core/lmms_style.cpp @@ -11,7 +11,8 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { - if( element == QStyle::PE_Frame ) + if( element == QStyle::PE_Frame || element == QStyle::PE_FrameLineEdit || + element == QStyle::PE_PanelLineEdit ) { const QRect rect = option->rect; diff --git a/src/core/main.cpp b/src/core/main.cpp index 74d1cf16e..cc0a631cc 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -179,11 +179,23 @@ int main( int argc, char * * argv ) // set palette QPalette pal = app.palette(); - pal.setColor( QPalette::Background, QColor( 128, 128, 128 ) ); + //pal.setColor( QPalette::Background, QColor( 72, 76 ,88 ) ); + pal.setColor( QPalette::Background, QColor( 67, 75 ,97 ) ); + //pal.setColor( QPalette::Background, QColor( 127, 134 ,154 ) ); + //pal.setColor( QPalette::Background, QColor( 105, 110, 120 ) ); + //pal.setColor( QPalette::Background, QColor( 89, 99, 128 ) ); + pal.setColor( QPalette::Foreground, QColor( 240, 240, 240 ) ); + pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) ); + //pal.setColor( QPalette::Base, QColor( 115, 110 , 94 ) ); + //pal.setColor( QPalette::Base, QColor( 128, 112 , 94 ) ); + pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) ); - pal.setColor( QPalette::Button, QColor( 160, 160, 160 ) ); + + pal.setColor( QPalette::Button, QColor( 156, 160, 172 ) ); + //pal.setColor( QPalette::Button, QColor( 172, 177, 191 ) ); + pal.setColor( QPalette::ButtonText, QColor( 255, 255, 255 ) ); pal.setColor( QPalette::Highlight, QColor( 224, 224, 224 ) ); pal.setColor( QPalette::HighlightedText, QColor( 0, 0, 0 ) ); diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 5935bff47..44a464fa6 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -94,6 +95,7 @@ const char * surroundarea_help = QT_TRANSLATE_NOOP( "instrumentTrack", const int INSTRUMENT_WIDTH = 250; const int INSTRUMENT_HEIGHT = INSTRUMENT_WIDTH; const int PIANO_HEIGHT = 84; +const int INSTRUMENT_WINDOW_CACHE_SIZE = 8; // #### IT: @@ -105,10 +107,10 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_audioPort( tr( "unnamed_channel" ), this ), m_notes(), m_baseNoteModel( 0, 0, NOTES_PER_OCTAVE * OCTAVES - 1, 1, this ), - m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, - 1.0f, this ), - m_surroundAreaModel( this, this ), - m_effectChannelModel( 0, 0, NUM_FX_CHANNELS, 1, this ), + m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, + 1.0f, this ), + m_surroundAreaModel( this, this ), + m_effectChannelModel( 0, 0, NUM_FX_CHANNELS, 1, this ), m_instrument( NULL ), m_soundShaping( this ), m_arpeggiator( this ), @@ -119,7 +121,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_baseNoteModel.setTrack( this ); m_baseNoteModel.setInitValue( DEFAULT_OCTAVE * NOTES_PER_OCTAVE + A ); connect( &m_baseNoteModel, SIGNAL( dataChanged() ), - this, SLOT( updateBaseNote() ) ); + this, SLOT( updateBaseNote() ) ); m_volumeModel.setTrack( this ); m_effectChannelModel.setTrack( this ); @@ -826,6 +828,11 @@ void instrumentTrack::invalidateAllMyNPH( void ) // #### ITV: + +QQueue instrumentTrackView::s_windows; + + + instrumentTrackView::instrumentTrackView( instrumentTrack * _it, trackContainerView * _tcv ) : trackView( _it, _tcv ), @@ -918,7 +925,30 @@ instrumentTrackView::instrumentTrackView( instrumentTrack * _it, instrumentTrackView::~instrumentTrackView() { - delete m_window; + freeInstrumentTrackWindow(); +} + + + + +// TODO: Add windows to free list on freeInstrumentTrackWindow. +// But, don't NULL m_window or disconnect signals. This will allow windows +// that are being show/hidden frequently to stay connected. +void instrumentTrackView::freeInstrumentTrackWindow( void ) +{ + if( m_window != NULL ) + { + if( s_windows.count() < INSTRUMENT_WINDOW_CACHE_SIZE ) + { + s_windows.enqueue( m_window ); + } + else + { + delete m_window; + } + + m_window = NULL; + } } @@ -926,12 +956,22 @@ instrumentTrackView::~instrumentTrackView() instrumentTrackWindow * instrumentTrackView::getInstrumentTrackWindow( void ) { - if( m_window == NULL ) + if( m_window != NULL ) + { + } + else if( !s_windows.isEmpty() ) + { + m_window = s_windows.dequeue(); + + m_window->setInstrumentTrackView( this ); + m_window->setModel( model() ); + m_window->updateInstrumentView(); + } + else { m_window = new instrumentTrackWindow( this ); - connect( m_tswInstrumentTrackButton, SIGNAL( toggled( bool ) ), - this, SLOT( toggledInstrumentTrackButton( bool ) ) ); } + return( m_window ); } @@ -941,6 +981,11 @@ instrumentTrackWindow * instrumentTrackView::getInstrumentTrackWindow( void ) void instrumentTrackView::toggledInstrumentTrackButton( bool _on ) { getInstrumentTrackWindow()->toggledInstrumentTrackButton( _on ); + + if( !_on ) + { + freeInstrumentTrackWindow(); + } } @@ -1158,11 +1203,16 @@ void instrumentTrackWindow::modelChanged( void ) m_track = m_itv->model(); m_instrumentNameLE->setText( m_track->name() ); + + disconnect( m_track, SIGNAL( nameChanged() ) ); + disconnect( m_track, SIGNAL( instrumentChanged() ) ); + connect( m_track, SIGNAL( nameChanged() ), this, SLOT( updateName() ) ); connect( m_track, SIGNAL( instrumentChanged() ), this, SLOT( updateInstrumentView() ), Qt::QueuedConnection ); + m_volumeKnob->setModel( &m_track->m_volumeModel ); m_surroundArea->setModel( &m_track->m_surroundAreaModel ); m_effectChannelNumber->setModel( &m_track->m_effectChannelModel ); @@ -1255,10 +1305,7 @@ void instrumentTrackWindow::textChanged( const QString & _new_name ) void instrumentTrackWindow::toggledInstrumentTrackButton( bool _on ) { - if( m_itv->m_tswInstrumentTrackButton->isChecked() != _on ) - { - m_itv->m_tswInstrumentTrackButton->setChecked( _on ); - } + if( _on ) { if( engine::getMainWindow()->workspace() )