diff --git a/ChangeLog b/ChangeLog index 843728a73..a6dc55873 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-06-14 Tobias Doerffel + * plugins/spectrum_analyzer/background.png: + * plugins/spectrum_analyzer/spectrum_background.png: + * plugins/spectrum_analyzer/spectrum_background_plain.png: + * plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp: + * plugins/spectrum_analyzer/spectrum_analyzer.h: + improved appearence of Spectrum Analzyer + * configure.in: * plugins/Makefile.am: * plugins/spectrum_analyzer/Makefile.am: diff --git a/plugins/spectrum_analyzer/background.png b/plugins/spectrum_analyzer/background.png new file mode 100644 index 000000000..a6d5d5da6 Binary files /dev/null and b/plugins/spectrum_analyzer/background.png differ diff --git a/plugins/spectrum_analyzer/spectrum_analyzer.h b/plugins/spectrum_analyzer/spectrum_analyzer.h index b37521534..b6a89a006 100644 --- a/plugins/spectrum_analyzer/spectrum_analyzer.h +++ b/plugins/spectrum_analyzer/spectrum_analyzer.h @@ -32,7 +32,7 @@ #include "spectrumanalyzer_controls.h" -const int MAX_BANDS = 400; +const int MAX_BANDS = 249; const int BUFFER_SIZE = 2048; diff --git a/plugins/spectrum_analyzer/spectrum_background.png b/plugins/spectrum_analyzer/spectrum_background.png new file mode 100644 index 000000000..d1f1ea65b Binary files /dev/null and b/plugins/spectrum_analyzer/spectrum_background.png differ diff --git a/plugins/spectrum_analyzer/spectrum_background_plain.png b/plugins/spectrum_analyzer/spectrum_background_plain.png new file mode 100644 index 000000000..a4c3aca08 Binary files /dev/null and b/plugins/spectrum_analyzer/spectrum_background_plain.png differ diff --git a/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp b/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp index 3d28325d5..7cd6e557e 100644 --- a/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp +++ b/plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp @@ -29,6 +29,26 @@ #include "spectrum_analyzer.h" #include "song_editor.h" #include "led_checkbox.h" +#include "embed.h" + + +inline void darken( QImage & _i, int _x, int _y, int _w, int _h ) +{ + uchar * d = _i.scanLine( _y ) + _x * sizeof( QRgb ); + const int add = ( _i.width() - _w ) * sizeof( QRgb ); + for( int y = 0; y < _h; ++y ) + { + for( int x = 0; x < _w; ++x ) + { + *d = *d >> 1; ++d; + *d = *d >> 1; ++d; + *d = *d >> 1; ++d; + ++d; + } + d += add; + } +} + class spectrumView : public QWidget @@ -36,11 +56,14 @@ class spectrumView : public QWidget public: spectrumView( spectrumAnalyzer * _s, QWidget * _parent ) : QWidget( _parent ), - m_sa( _s ) + m_sa( _s ), + m_backgroundPlain( PLUGIN_NAME::getIconPixmap( "spectrum_background_plain" ).toImage() ), + m_background( PLUGIN_NAME::getIconPixmap( "spectrum_background" ).toImage() ) { - setFixedSize( 400, 200 ); + setFixedSize( 249, 151 ); connect( engine::getSongEditor(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); + setAttribute( Qt::WA_OpaquePaintEvent, TRUE ); } virtual ~spectrumView() @@ -50,10 +73,13 @@ public: virtual void paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.fillRect( rect(), Qt::black ); + QImage i = m_sa->m_saControls.m_linearSpec.value() ? + m_backgroundPlain : m_background; const double e = m_sa->m_energy; if( e <= 0 ) { + darken( i, 0, 0, i.width(), i.height() ); + p.drawImage( 0, 0, i ); return; } @@ -63,7 +89,6 @@ public: int h; if( m_sa->m_saControls.m_linearSpec.value() ) { - p.setPen( QColor( 0, 255, 0 ) ); for( int x = 0; x < MAX_BANDS; ++x, ++b ) { if( lin_y ) @@ -74,7 +99,15 @@ public: { h = (int)( height() * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); } - p.drawLine( x, height(), x, height()-h ); + if( h < 0 ) + { + h = 0; + } + else if( h > height() ) + { + h = height(); + } + darken( i, x, 0, 1, height()-h ); } } else @@ -89,13 +122,29 @@ public: { h = (int)( height() * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) ); } - p.fillRect( x*13, height()-h, 11, h, QColor( 0, 255, 0 ) ); + if( h < 0 ) + { + h = 0; + } + else if( h > height() ) + { + h = height(); + } + else + { + h = ( h / 3 ) * 3; + } + darken( i, x*8, 0, 8, height()-h ); } + darken( i, 31*8, 0, 1, height() ); } + p.drawImage( 0, 0, i ); } private: spectrumAnalyzer * m_sa; + QImage m_backgroundPlain; + QImage m_background; } ; @@ -104,16 +153,26 @@ spectrumAnalyzerControlDialog::spectrumAnalyzerControlDialog( spectrumAnalyzerControls * _controls ) : effectControlDialog( _controls ) { - QVBoxLayout * l = new QVBoxLayout( this ); + setAutoFillBackground( TRUE ); + QPalette pal; + pal.setBrush( backgroundRole(), + PLUGIN_NAME::getIconPixmap( "background" ) ); + setFixedSize( 280, 243 ); + setPalette( pal ); +/* QVBoxLayout * l = new QVBoxLayout( this );*/ spectrumView * v = new spectrumView( _controls->m_effect, this ); + v->move( 24, 30 ); ledCheckBox * lin_spec = new ledCheckBox( tr( "Linear spectrum" ), this ); - ledCheckBox * lin_y = new ledCheckBox( tr( "Linear Y axis" ), this ); + lin_spec->move( 24, 204 ); lin_spec->setModel( &_controls->m_linearSpec ); + + ledCheckBox * lin_y = new ledCheckBox( tr( "Linear Y axis" ), this ); + lin_y->move( 24, 220 ); lin_y->setModel( &_controls->m_linearYAxis ); - l->addWidget( v ); +/* l->addWidget( v ); l->addWidget( lin_spec ); - l->addWidget( lin_y ); + l->addWidget( lin_y );*/ }