From 1451ea80000eb4054bc2280b84c22955dc25f0e3 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 22 Sep 2008 20:54:32 +0000 Subject: [PATCH] added a vertical position line git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1685 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 6 ++++++ include/song_editor.h | 11 +++++++++++ include/timeline.h | 13 ++++++------- src/core/timeline.cpp | 17 +++++++---------- src/gui/song_editor.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa94ea5f3..0d9045e80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-09-22 Tobias Doerffel + * include/song_editor.h: + * include/timeline.h: + * src/core/timeline.cpp: + * src/gui/song_editor.cpp: + added a vertical position line + * src/core/midi/midi_winmm.cpp: added support for MIDI out in WinMM MIDI client diff --git a/include/song_editor.h b/include/song_editor.h index c94aaffd1..041adb304 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -38,8 +38,18 @@ class lcdSpinBox; class meterDialog; class song; class textFloat; +class timeLine; class toolButton; +class positionLine : public QWidget +{ +public: + positionLine( QWidget * _parent ); + +private: + virtual void paintEvent( QPaintEvent * _pe ); + +} ; class songEditor : public trackContainerView @@ -112,6 +122,7 @@ private: comboBox * m_zoomingComboBox; + positionLine * m_positionLine; bool m_scrollBack; diff --git a/include/timeline.h b/include/timeline.h index a1cc788e6..2e9e6abf8 100644 --- a/include/timeline.h +++ b/include/timeline.h @@ -116,6 +116,12 @@ public: return( "timeline" ); } + inline int markerX( const midiTime & _t ) const + { + return( m_xOffset + static_cast( ( _t - m_begin ) * + m_ppt / midiTime::ticksPerTact() ) ); + } + public slots: void updatePosition( const midiTime & ); @@ -136,13 +142,6 @@ protected: private: - inline int markerX( const midiTime & _t ) const - { - return( m_xOffset + static_cast( ( _t - m_begin ) * - m_ppt / midiTime::ticksPerTact() ) ); - } - - static QPixmap * s_timeLinePixmap; static QPixmap * s_posMarkerPixmap; static QPixmap * s_loopPointPixmap; diff --git a/src/core/timeline.cpp b/src/core/timeline.cpp index 3e0025829..a62ddc55a 100644 --- a/src/core/timeline.cpp +++ b/src/core/timeline.cpp @@ -227,7 +227,6 @@ void timeLine::paintEvent( QPaintEvent * ) QColor bg_color = QApplication::palette().color( QPalette::Active, QPalette::Background ); QLinearGradient g( 0, 0, 0, height() ); -// g.setColorAt( 0, bg_color.darker( 250 ) ); g.setColorAt( 0, bg_color.lighter( 150 ) ); g.setColorAt( 1, bg_color.darker( 150 ) ); p.fillRect( 0, 0, width(), height(), g ); @@ -235,11 +234,9 @@ void timeLine::paintEvent( QPaintEvent * ) p.setClipRect( m_xOffset, 0, width() - m_xOffset, height() ); p.setPen( QColor( 0, 0, 0 ) ); - const QPixmap & lpoint = *s_loopPointPixmap; - p.setOpacity( loopPointsEnabled() ? 0.9 : 0.2 ); - p.drawPixmap( markerX( loopBegin() )+2, 2, lpoint ); - p.drawPixmap( markerX( loopEnd() )+2, 2, lpoint ); + p.drawPixmap( markerX( loopBegin() )+2, 2, *s_loopPointPixmap ); + p.drawPixmap( markerX( loopEnd() )+2, 2, *s_loopPointPixmap ); p.setOpacity( 1.0 ); @@ -256,8 +253,8 @@ void timeLine::paintEvent( QPaintEvent * ) p.drawLine( cx, 5, cx, height() - 6 ); ++tact_num; if( ( tact_num - 1 ) % - tMax( 1, qRound( 1.0f / 3.0f * midiTime::ticksPerTact() / - m_ppt ) ) == 0 ) + tMax( 1, qRound( 1.0f / 3.0f * + midiTime::ticksPerTact() / m_ppt ) ) == 0 ) { const QString s = QString::number( tact_num ); p.drawText( cx + qRound( ( m_ppt - p.fontMetrics(). @@ -266,9 +263,9 @@ void timeLine::paintEvent( QPaintEvent * ) } } - p.setOpacity( 0.75 ); - p.drawImage( m_posMarkerX, height() - s_posMarkerPixmap->height(), - s_posMarkerPixmap->toImage() ); + p.setOpacity( 0.6 ); + p.drawPixmap( m_posMarkerX, height() - s_posMarkerPixmap->height(), + *s_posMarkerPixmap ); } diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index ff37924b2..adfb1d267 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,24 @@ +positionLine::positionLine( QWidget * _parent ) : + QWidget( _parent ) +{ + setFixedWidth( 3 ); + setAttribute( Qt::WA_NoSystemBackground, true ); +} + + + + +void positionLine::paintEvent( QPaintEvent * _pe ) +{ + QPainter p( this ); + p.fillRect( rect(), QColor( 0, 0, 0, 153 ) ); +} + + + songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : trackContainerView( _song ), @@ -79,6 +98,8 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : connect( tl, SIGNAL( positionChanged( const midiTime & ) ), this, SLOT( updatePosition( const midiTime & ) ) ); + m_positionLine = new positionLine( this ); + // add some essential widgets to global tool-bar QWidget * tb = engine::getMainWindow()->toolBar(); @@ -228,8 +249,9 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : this, SLOT( record() ), m_toolBar ); m_recordAccompanyButton = new toolButton( embed::getIconPixmap( "record_accompany" ), - tr( "Record samples from Audio-device while playing song or BB track" ), - this, SLOT( recordAccompany() ), m_toolBar ); + tr( "Record samples from Audio-device while playing " + "song or BB track" ), + this, SLOT( recordAccompany() ), m_toolBar ); // FIXME: disable record button while it is not implemented m_recordButton->setDisabled( true ); @@ -643,6 +665,20 @@ void songEditor::updatePosition( const midiTime & _t ) } m_scrollBack = FALSE; } + + const int x = m_s->m_playPos[song::Mode_PlaySong].m_timeLine-> + markerX( _t ) + 7; + if( x >= TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH-1 ) + { + m_positionLine->show(); + m_positionLine->move( x, 50 ); + } + else + { + m_positionLine->hide(); + } + + m_positionLine->setFixedHeight( height() ); }