From ac2003ca70270b7dcf293f5b7395d4034a7e963e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 7 Sep 2008 14:34:43 +0000 Subject: [PATCH] integrated patch by Attila Herman which adds support for colorized graph and quantized values git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1578 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 8 ++++++++ include/graph.h | 7 ++++++- src/gui/widgets/graph.cpp | 15 +++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 667e2fffb..ba426771a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-09-07 Tobias Doerffel + * include/graph.h: + * src/gui/widgets/graph.cpp: + integrated patch by Attila Herman which adds support for colorized + graph and quantized values + + * src/core/config_mgr.cpp: + made default VST path to be inside LMMS working directory + * src/gui/track_container_view.cpp: changed size constraint for scrollArea-widget layout - fixes messed up Song Editor after loading various projects diff --git a/include/graph.h b/include/graph.h index 8e50dd45a..8b9929595 100644 --- a/include/graph.h +++ b/include/graph.h @@ -53,6 +53,8 @@ public: void setForeground( const QPixmap & _pixmap ); + void setGraphColor( const QColor ); + inline graphModel * model( void ) { return castModel(); @@ -89,6 +91,7 @@ private: QPixmap m_foreground; + QColor m_graphColor; graphModel * m_graphModel; graphStyle m_graphStyle; @@ -107,7 +110,8 @@ public: float _max, int _size, :: model * _parent, - bool _default_constructed = FALSE ); + bool _default_constructed = FALSE, + float _step = 0.0 ); virtual ~graphModel(); @@ -161,6 +165,7 @@ private: QVector m_samples; float m_minValue; float m_maxValue; + float m_step; friend class graph; diff --git a/src/gui/widgets/graph.cpp b/src/gui/widgets/graph.cpp index 2b078d2c1..5a5299cc9 100644 --- a/src/gui/widgets/graph.cpp +++ b/src/gui/widgets/graph.cpp @@ -46,6 +46,7 @@ graph::graph( QWidget * _parent, graphStyle _style ) : m_graphStyle( _style ) { m_mouseDown = false; + m_graphColor = QColor( 0xFF, 0xAA, 0x00 ); resize( 132, 104 ); setAcceptDrops( TRUE ); @@ -72,7 +73,10 @@ void graph::setForeground( const QPixmap &_pixmap ) m_foreground = _pixmap; } - +void graph::setGraphColor( QColor _graphcol ) +{ + m_graphColor = _graphcol; +} /* void graph::loadSampleFromFile( const QString & _filename ) @@ -217,7 +221,7 @@ void graph::paintEvent( QPaintEvent * ) { QPainter p( this ); - p.setPen( QPen(QColor( 0xFF, 0xAA, 0x00 ), 1) ); + p.setPen( QPen( m_graphColor, 1 ) ); QVector * samps = &(model()->m_samples); int length = model()->length(); @@ -344,11 +348,12 @@ void graph::updateGraph( void ) graphModel::graphModel( float _min, float _max, int _length, - ::model * _parent, bool _default_constructed ) : + ::model * _parent, bool _default_constructed, float _step ) : model( _parent, tr( "Graph" ), _default_constructed ), m_samples( _length ), m_minValue( _min ), - m_maxValue( _max ) + m_maxValue( _max ), + m_step( _step ) { } @@ -395,6 +400,8 @@ void graphModel::setLength( int _length ) void graphModel::setSampleAt( int _x, float _val ) { + //snap to the grid + _val -= ( m_step != 0.0 ) ? fmod( _val, m_step ) * m_step : 0; // boundary check if ( _x >= 0 && _x < length() && _val >= minValue() && _val < maxValue() )