From 9ad71a975e09f6bdf95201e46fbebb9b83b0c18d Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 21 Nov 2007 21:41:36 +0000 Subject: [PATCH] various GUI-fixes and other stuff git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@605 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 34 +++++++++++++++++++++++++ data/locale/de.qm | Bin 172635 -> 172627 bytes data/locale/de.ts | 2 +- src/core/arp_and_chords_tab_widget.cpp | 3 --- src/core/envelope_and_lfo_widget.cpp | 2 +- src/core/main.cpp | 2 +- src/lib/sample_buffer.cpp | 13 ++++++---- src/tracks/sample_track.cpp | 32 ++++++++--------------- src/widgets/combobox.cpp | 6 ++--- src/widgets/knob.cpp | 33 ++++++++++++------------ src/widgets/led_checkbox.cpp | 7 ++--- src/widgets/tab_widget.cpp | 3 ++- 12 files changed, 82 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47133afa88..9ebb29ca03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2007-11-21 Tobias Doerffel + + * src/lib/sample_buffer.cpp: + - duplicate ASCII-string from file.toAscii().constData() in order to not + get corrupted - fixes random problems with loading OGG-files + - sample-visualization now floating-point-based + + * src/widgets/combobox.cpp: + fixed text-drawing + + * src/widgets/led_checkbox.cpp: + * src/widgets/tab_widget.cpp: + added workarounds for obviously non-working font-property + + * src/widgets/knob.cpp: + - knob::drawKnob( ... ) now completely works with floats + - use anti-aliasing when drawing tick + + * src/tracks/sample_track.cpp: + fixed painting of sample-TCO's + + * src/core/arp_and_chords_tab_widget.cpp: + removed obviously non-working comboBox::setFont( ... )-calls + + * src/core/envelope_and_lfo_widget.cpp: + use line-width of 1.5 instead of 2 for drawing LFO + + * src/core/main.cpp: + do not set default font-size + + * data/locale/de.ts: + * data/locale/de.qm: + fixed German localization + 2007-11-20 Javier Serrano Polo * include/drumsynth.h: diff --git a/data/locale/de.qm b/data/locale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cKj$R998N<*g zOjCXyl+I6C_uggbQr5jsm;bVU1=*my^)k7Ix%5v|aiD>@ZPI}9E{?f7ze1~+dmEO( zV8^_?!qFh+rB46?giX$xk7lzlgAEX(XOY@SAZ8O;WMe+Ml0{v~1JcdTWH^f*-qk)vUNp*_SQXS_{1}s!>}ufe zK)5ZdQMKE#(aP#_E&&nItbXJMw20NO{21+Ijim>G$oZ^kra+5Wt33vj?^tKXdmz@^ zxw#wmtt+`@dNGjhuH5pB8M>TnFYf}#)S9FzBc#%FIW1@fUYpEIi(UBMT4Hlb&ET+(JB z4k};d8jHT=skwLpP6K%A4_zkkv=9vLbcKH(+8u~9=NmI`ptE?^rt@fpYHYZ;@Ev71 zvCBH1`=$(S<%iRT0QqDmIuvc-$MG7H0a|{}U^l940RAR zuMNoXDA8+I%|&B`qaI5#szvnOiVKhS z7yU04pudTM>wW^_byy5OiUGVHiXl^Q9(C+=;c=h?$k;M5Dg}>v++Yz1&FBshScooq^_v6GNTQT2cDzSs>G71WTd2A^s`x2NK~d+6{?7B3(phS|O0xr-i{B$LCl|qQUDo z*IHV>D?@eCE-xKOOoDXST%cm(URMLi!X8Fr{iNfR*FfUZ(N45lYLju{MSbOnOViMN zql+!1X9osZ93>}YIs#dGOit*)oyUJ5y|3fWTEmMcU1 zA4FT_46gP8vV4ZraeQHUv0T_R3`l~bR5xxx)1-PL6n!aE_hKzq_{+3iEohG196S}R zlG$5AfUJBkcV;~Wl5|M!?uOSgsaEbCcmzoDCV8YK94(hcR(PT*QLf10;FBSp%KIb#1HcU MODULATE ENV-AMOUNT - HK.INTENS. MODULIEREN + HÜLLK. MODULIEREN diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index 85198c1fe8..249a5f66df 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -190,7 +190,6 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( m_chordsComboBox = new comboBox( m_chordsGroupBox, tr( "Chord type" ), _instrument_track ); - m_chordsComboBox->setFont( pointSize<8>( m_chordsComboBox->font() ) ); m_chordsComboBox->setGeometry( 10, 25, 140, 22 ); for( int i = 0; s_chords[i].interval[0] != -1; ++i ) @@ -233,7 +232,6 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( "possible chords, you can select." ) ); m_arpComboBox = new comboBox( m_arpGroupBox, tr( "Arpeggio type" ), _instrument_track ); - m_arpComboBox->setFont( pointSize<8>( m_arpComboBox->font() ) ); m_arpComboBox->setGeometry( 10, 25, 140, 22 ); for( int i = 0; s_chords[i].interval[0] != -1; ++i ) @@ -345,7 +343,6 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( m_arpModeComboBox = new comboBox( m_arpGroupBox, tr( "Arpeggio mode" ), _instrument_track ); - m_arpModeComboBox->setFont( pointSize<8>( m_arpModeComboBox->font() ) ); m_arpModeComboBox->setGeometry( 10, 118, 128, 22 ); m_arpModeComboBox->addItem( tr( "Free" ), diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 9151e71384..c76972115e 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -773,7 +773,7 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * ) static_cast( 255 - 159 * lfo_gray_amount ), static_cast( 128 - 32 * lfo_gray_amount ) ), - 2 ) ); + 1.5 ) ); float osc_frames = m_lfoOscillationFrames; diff --git a/src/core/main.cpp b/src/core/main.cpp index 474456728f..18b7e28d1d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -161,7 +161,7 @@ int main( int argc, char * * argv ) // load actual translation for LMMS loadTranslation( pos ); - app.setFont( pointSize<10>( app.font() ) ); +// app.setFont( pointSize<10>( app.font() ) ); if( !configManager::inst()->loadConfigFile() ) diff --git a/src/lib/sample_buffer.cpp b/src/lib/sample_buffer.cpp index 71d5cfcc6f..6d3a2a69c1 100644 --- a/src/lib/sample_buffer.cpp +++ b/src/lib/sample_buffer.cpp @@ -200,7 +200,7 @@ void sampleBuffer::update( bool _keep_settings ) else if( m_audioFile != "" ) { QString file = tryToMakeAbsolute( m_audioFile ); - const char * f = file.toAscii().constData(); + char * f = qstrdup( file.toAscii().constData() ); int_sample_t * buf = NULL; ch_cnt_t channels = DEFAULT_CHANNELS; sample_rate_t samplerate = SAMPLE_RATES[DEFAULT_QUALITY_LEVEL]; @@ -234,6 +234,8 @@ void sampleBuffer::update( bool _keep_settings ) samplerate ); } + delete[] f; + if( m_frames > 0 && buf != NULL ) { // following code transforms int-samples into @@ -764,24 +766,25 @@ void sampleBuffer::visualize( QPainter & _p, const QRect & _dr, const int w = _dr.width(); const int h = _dr.height(); - const Uint16 y_base = h / 2 + _dr.y(); + const float y_base = h / 2 + _dr.y(); const float y_space = h / 2; const QRect isect = _dr.intersect( _clip ); int old_y[DEFAULT_CHANNELS] = { y_base, y_base }; + _p.setPen( QPen( _p.pen().color(), 0.5 ) ); const f_cnt_t fpp = tLimit( m_frames / w, 1, 20 ); int old_x = _clip.x(); for( f_cnt_t frame = 0; frame < m_frames; frame += fpp ) { - const int x = _dr.x() + static_cast( frame / + const float x = _dr.x() + ( frame / (float) m_frames * _dr.width() ); for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { - const Uint16 y = y_base - static_cast( + const Uint16 y = y_base - ( m_data[frame][chnl] * y_space ); - _p.drawLine( old_x, old_y[chnl], x, y ); + _p.drawLine( QLineF( old_x, old_y[chnl], x, y+0.5 ) ); old_y[chnl] = y; } old_x = x; diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index d6dbf29b0a..6e27138670 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -164,32 +164,22 @@ void sampleTCO::mouseDoubleClickEvent( QMouseEvent * ) void sampleTCO::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); -#warning TODO: set according brush for gradient! - p.fillRect( _pe->rect(), QColor( 64, 64, 64 ) ); -#if 0 - // create pixmap for our widget - QPixmap pm( _pe->rect().size() ); - // and a painter for it - QPainter p( &pm ); - p.translate( -_pe->rect().x(), -_pe->rect().y() ); - for( int y = 1; y < height() - 1; ++y ) + QLinearGradient grad( 0, 0, 0, height() ); + if( isSelected() ) { - const int gray = 96 - y * 96 / height(); - if( isSelected() == TRUE ) - { - p.setPen( QColor( 0, 0, 128 + gray ) ); - } - else - { - p.setPen( QColor( gray, gray, gray ) ); - } - p.drawLine( 1, y, width() - 1, y ); + grad.setColorAt( 1, QColor( 0, 0, 224 ) ); + grad.setColorAt( 0, QColor( 0, 0, 128 ) ); } -#endif + else + { + grad.setColorAt( 0, QColor( 96, 96, 96 ) ); + grad.setColorAt( 1, QColor( 16, 16, 16 ) ); + } + p.fillRect( _pe->rect(), grad ); p.setPen( QColor( 0, 0, 0 ) ); - p.drawRect( 0, 0, width(), height() ); + p.drawRect( 0, 0, width()-1, height()-1 ); if( getTrack()->muted() || muted() ) { p.setPen( QColor( 128, 128, 128 ) ); diff --git a/src/widgets/combobox.cpp b/src/widgets/combobox.cpp index 0e30135e35..edfb51ffda 100644 --- a/src/widgets/combobox.cpp +++ b/src/widgets/combobox.cpp @@ -64,7 +64,7 @@ comboBox::comboBox( QWidget * _parent, const QString & _name, track * _track ) : "combobox_arrow" ) ); } - setFont( pointSize<8>( font() ) ); + setFont( pointSize<9>( font() ) ); m_menu.setFont( pointSize<8>( m_menu.font() ) ); connect( &m_menu, SIGNAL( triggered( QAction * ) ), @@ -243,10 +243,10 @@ void comboBox::paintEvent( QPaintEvent * _pe ) tx += item_pm.width() + 2; } p.setPen( QColor( 64, 64, 64 ) ); - p.drawText( tx+1, p.fontMetrics().height()+1, + p.drawText( tx+1, p.fontMetrics().height()-1, m_items[value()].first ); p.setPen( QColor( 224, 224, 224 ) ); - p.drawText( tx, p.fontMetrics().height(), + p.drawText( tx, p.fontMetrics().height()-2, m_items[value()].first ); } } diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index 2028fa3284..1f319690f7 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -159,9 +159,9 @@ void knob::setTotalAngle( float _angle ) void knob::drawKnob( QPainter * _p ) { - const float radius = m_knobPixmap->width() / 2 - 1; - const float xm = m_knobPixmap->width() / 2;//radius + 1; - const float ym = m_knobPixmap->height() / 2;//radius+1; + const float radius = m_knobPixmap->width() / 2.0f - 1; + const float xm = m_knobPixmap->width() / 2.0f;//radius + 1; + const float ym = m_knobPixmap->height() / 2.0f;//radius+1; const float rarc = m_angle * M_PI / 180.0; const float ca = cos( rarc ); @@ -171,21 +171,22 @@ void knob::drawKnob( QPainter * _p ) *m_knobPixmap ); _p->setPen( QPen( QColor( 200, 0, 0 ), 2 ) ); + _p->setRenderHint( QPainter::Antialiasing ); switch( m_knobNum ) { case knobSmall_17: { - _p->drawLine( (int)( xm-sa ), (int)( ym-ca ), - (int)( xm - sa*radius ), - (int)( ym - ca*radius ) ); + _p->drawLine( QLineF( xm-sa, ym-ca, + xm - sa*radius, + ym - ca*radius ) ); break; } case knobBright_26: { - _p->drawLine( (int)( xm-sa ), (int)( ym-ca ), - (int)( xm - sa*( radius-5 ) ), - (int)( ym - ca*( radius-5 ) ) ); + _p->drawLine( QLineF( xm-sa, ym-ca, + xm - sa*( radius-5 ), + ym - ca*( radius-5 ) ) ); break; } case knobDark_28: @@ -193,18 +194,18 @@ void knob::drawKnob( QPainter * _p ) const float rb = tMax( ( radius - 10 ) / 3.0, 0.0 ); const float re = tMax( ( radius - 4 ), 0.0 ); - _p->drawLine( (int)( xm-sa*rb ) + 1, - (int)( ym - ca*rb ) + 1, - (int)( xm - sa*re ) + 1, - (int)( ym - ca*re ) + 1 ); + _p->drawLine( QLineF( xm-sa*rb + 1, + ym - ca*rb + 1, + xm - sa*re + 1, + ym - ca*re + 1 ) ); break; } case knobGreen_17: { _p->setPen( QPen( QColor( 0, 200, 0 ), 2 ) ); - _p->drawLine( (int)( xm-sa ), (int)( ym-ca ), - (int)( xm - sa*radius ), - (int)( ym - ca*radius ) ); + _p->drawLine( QLineF( xm-sa, ym-ca, + xm - sa*radius, + ym - ca*radius ) ); break; } } diff --git a/src/widgets/led_checkbox.cpp b/src/widgets/led_checkbox.cpp index f841bc0a8e..07f42a61ce 100644 --- a/src/widgets/led_checkbox.cpp +++ b/src/widgets/led_checkbox.cpp @@ -59,7 +59,7 @@ ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent, names[_color].toAscii().constData() ) ); m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) ); - setFont( pointSizeF( font(), 7.5f ) ); + setFont( pointSize<7>( font() ) ); setFixedSize( m_ledOffPixmap->width() + 4 + QFontMetrics( font() ).width( text() ), m_ledOffPixmap->height() ); @@ -80,6 +80,7 @@ ledCheckBox::~ledCheckBox() void ledCheckBox::paintEvent( QPaintEvent * ) { QPainter p( this ); + p.setFont( pointSize<7>( font() ) ); if( isChecked() == TRUE ) { @@ -91,9 +92,9 @@ void ledCheckBox::paintEvent( QPaintEvent * ) } p.setPen( QColor( 64, 64, 64 ) ); - p.drawText( m_ledOffPixmap->width() + 3, 9, text() ); + p.drawText( m_ledOffPixmap->width() + 3, 10, text() ); p.setPen( QColor( 255, 255, 255 ) ); - p.drawText( m_ledOffPixmap->width() + 2, 8, text() ); + p.drawText( m_ledOffPixmap->width() + 2, 9, text() ); } diff --git a/src/widgets/tab_widget.cpp b/src/widgets/tab_widget.cpp index a93af227d6..070ea35104 100644 --- a/src/widgets/tab_widget.cpp +++ b/src/widgets/tab_widget.cpp @@ -64,6 +64,7 @@ tabWidget::~tabWidget() void tabWidget::addTab( QWidget * _w, const QString & _name, int _idx ) { + setFont( pointSize<7>( font() ) ); widgetDesc d = { _w, _name, fontMetrics().width( _name ) + 10 } ; if( _idx < 0/* || m_widgets.contains( _idx ) == TRUE*/ ) { @@ -145,6 +146,7 @@ void tabWidget::resizeEvent( QResizeEvent * ) void tabWidget::paintEvent( QPaintEvent * _pe ) { + setFont( pointSize<7>( font() ) ); QPainter p( this ); p.fillRect( 0, 0, width() - 1, height() - 1, QColor( 96, 96, 96 ) ); @@ -169,7 +171,6 @@ void tabWidget::paintEvent( QPaintEvent * _pe ) if( !big_tab_captions ) { p.setPen( QColor( 255, 255, 255 ) ); - p.setFont( font() ); p.drawText( 5, 10, m_caption ); }