Improve graph and bitinvader
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1105 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
2008-06-08 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* src/gui/widgets/graph.h:
|
||||
* src/gui/widgets/graph.cpp:
|
||||
Fix graph widget
|
||||
- Fix graph widget "scrolling"
|
||||
- Add styles so it can be drawn un-interpolated
|
||||
|
||||
* include/mv_base.h:
|
||||
* src/core/mv_base.cpp:
|
||||
@@ -34,6 +36,9 @@
|
||||
* src/gui/controller_connection_dialog.cpp:
|
||||
improve interface slightly
|
||||
|
||||
* plugins/bit_invader/bit_invader.cpp:
|
||||
change graph style mode when toggling interpolation
|
||||
|
||||
2008-06-08 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/ladspa_effect/tap/tap_deesser.c:
|
||||
|
||||
@@ -41,7 +41,14 @@ class EXPORT graph : public QWidget, public modelView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
graph( QWidget * _parent );
|
||||
enum graphStyle
|
||||
{
|
||||
NearestStyle,
|
||||
LinearStyle,
|
||||
NumGraphStyles
|
||||
};
|
||||
|
||||
graph( QWidget * _parent, graphStyle _style = graph::LinearStyle );
|
||||
virtual ~graph();
|
||||
|
||||
void setForeground( const QPixmap & _pixmap );
|
||||
@@ -51,6 +58,17 @@ public:
|
||||
return castModel<graphModel>();
|
||||
}
|
||||
|
||||
inline graphStyle getGraphStyle( void )
|
||||
{
|
||||
return m_graphStyle;
|
||||
}
|
||||
|
||||
inline void setGraphStyle( graphStyle _s )
|
||||
{
|
||||
m_graphStyle = _s;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * _pe );
|
||||
@@ -73,6 +91,7 @@ private:
|
||||
QPixmap m_foreground;
|
||||
|
||||
graphModel * m_graphModel;
|
||||
graphStyle m_graphStyle;
|
||||
|
||||
bool m_mouseDown;
|
||||
int m_lastCursorX;
|
||||
|
||||
@@ -330,7 +330,7 @@ bitInvaderView::bitInvaderView( instrument * _instrument,
|
||||
m_sampleLengthKnob->move( 10, 120 );
|
||||
m_sampleLengthKnob->setHintText( tr( "Sample Length" ) + " ", "" );
|
||||
|
||||
m_graph = new graph( this );
|
||||
m_graph = new graph( this, graph::NearestStyle );
|
||||
m_graph->move(53,118); // 55,120 - 2px border
|
||||
m_graph->setAutoFillBackground( TRUE );
|
||||
|
||||
@@ -536,6 +536,7 @@ void bitInvaderView::smoothClicked( void )
|
||||
|
||||
void bitInvaderView::interpolationToggled( bool value )
|
||||
{
|
||||
m_graph->setGraphStyle( value ? graph::LinearStyle : graph::NearestStyle);
|
||||
engine::getSong()->setModified();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,11 @@ using namespace std;
|
||||
|
||||
|
||||
|
||||
graph::graph( QWidget * _parent ) :
|
||||
graph::graph( QWidget * _parent, graphStyle _style ) :
|
||||
QWidget( _parent ),
|
||||
/* TODO: size, background? */
|
||||
modelView( new graphModel( -1.0, 1.0, 128, NULL, NULL, TRUE ) )
|
||||
modelView( new graphModel( -1.0, 1.0, 128, NULL, NULL, TRUE ) ),
|
||||
m_graphStyle( _style )
|
||||
{
|
||||
m_mouseDown = false;
|
||||
|
||||
@@ -227,30 +228,64 @@ void graph::paintEvent( QPaintEvent * )
|
||||
// Max index, more useful below
|
||||
length--;
|
||||
|
||||
p.setRenderHints( QPainter::Antialiasing, TRUE );
|
||||
for( int i=0; i < length; i++ )
|
||||
|
||||
switch( m_graphStyle )
|
||||
{
|
||||
// Needs to be rewritten
|
||||
p.drawLine(2+static_cast<int>(i*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
|
||||
2+static_cast<int>((i+1)*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i+1] - maxVal ) * yscale )
|
||||
);
|
||||
case graph::LinearStyle:
|
||||
p.setRenderHints( QPainter::Antialiasing, TRUE );
|
||||
|
||||
for( int i=0; i < length; i++ )
|
||||
{
|
||||
// Needs to be rewritten
|
||||
p.drawLine(2+static_cast<int>(i*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
|
||||
2+static_cast<int>((i+1)*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i+1] - maxVal ) * yscale )
|
||||
);
|
||||
}
|
||||
|
||||
// Draw last segment flat
|
||||
p.drawLine(2+static_cast<int>(length*xscale),
|
||||
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ),
|
||||
width()-2,
|
||||
2+static_cast<int>( ( (*samps)[0] - maxVal ) * yscale ) );
|
||||
|
||||
p.setRenderHints( QPainter::Antialiasing, FALSE );
|
||||
break;
|
||||
|
||||
|
||||
case graph::NearestStyle:
|
||||
printf("GAY MODE\n");
|
||||
for( int i=0; i < length; i++ )
|
||||
{
|
||||
p.drawLine(2+static_cast<int>(i*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
|
||||
2+static_cast<int>((i+1)*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale )
|
||||
);
|
||||
p.drawLine(2+static_cast<int>((i+1)*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i] - maxVal ) * yscale ),
|
||||
2+static_cast<int>((i+1)*xscale),
|
||||
2+static_cast<int>( ( (*samps)[i+1] - maxVal ) * yscale )
|
||||
);
|
||||
}
|
||||
|
||||
p.drawLine(2+static_cast<int>(length*xscale),
|
||||
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ),
|
||||
width()-2,
|
||||
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw last segment flat
|
||||
p.drawLine(2+static_cast<int>(length*xscale),
|
||||
2+static_cast<int>( ( (*samps)[length] - maxVal ) * yscale ),
|
||||
width()-2,
|
||||
2+static_cast<int>( ( (*samps)[0] - maxVal ) * yscale ) );
|
||||
|
||||
p.setRenderHints( QPainter::Antialiasing, FALSE );
|
||||
|
||||
// draw Pointer
|
||||
if( m_mouseDown )
|
||||
{
|
||||
QPoint cursor = mapFromGlobal( QCursor::pos() );
|
||||
p.setPen( QColor( 0xAA, 0xFF, 0x00 ) );
|
||||
p.setPen( QColor( 0xAA, 0xFF, 0x00, 0x70 ) );
|
||||
p.drawLine( 2, cursor.y(), width()-2, cursor.y() );
|
||||
p.drawLine( cursor.x(), 2, cursor.x(), height()-2 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user