Plugged memleaks in sf2player and lcdSpinbox, reapplied lmmsStyle, enhanced drawing of LCDs, added ignore property for SVN

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@800 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-03-17 06:14:06 +00:00
parent 33937e8799
commit ca8d394905
11 changed files with 553 additions and 120 deletions

View File

@@ -369,7 +369,9 @@ fxMixerView::fxMixerView() :
lcdSpinBox * l = new lcdSpinBox( 2, cv->m_fxLine );
l->model()->setRange( i, i );
l->model()->setValue( i );
l->update();
l->move( 2, 4 );
l->setMarginWidth( 1 );
cv->m_fader = new fader( &m->m_fxChannels[i]->m_volumeModel,
cv->m_fxLine );
cv->m_fader->move( 15-cv->m_fader->width()/2, 80 );

110
src/core/lmms_style.cpp Normal file
View File

@@ -0,0 +1,110 @@
#include <QtGui/QPlastiqueStyle>
#include <QtGui/QStyleOption>
#include <QtGui/QPainter>
#include <QtGui/QWidget>
#include <QtGui/QFrame>
#include "lmms_style.h"
void lmmsStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget) const
{
QPlastiqueStyle::drawPrimitive( element, option, painter, widget );
/*
if( element == QStyle::PE_Frame ) {
printf("Frame\n");
QFrame::Shadow shadow = QFrame::Plain;
if (option->state & State_Sunken)
shadow = QFrame::Sunken;
else if (option->state & State_Raised)
shadow = QFrame::Raised;
QPen oldPen = painter->pen();
QBrush border;
QBrush corner;
QBrush innerTopLeft;
QBrush innerBottomRight;
if (shadow != QFrame::Plain && (option->state & QStyle::State_HasFocus)) {
border = option->palette.highlight();
qBrushSetAlphaF(&border, 0.8);
corner = option->palette.highlight();
qBrushSetAlphaF(&corner, 0.5);
innerTopLeft = qBrushDark(option->palette.highlight(), 125);
innerBottomRight = option->palette.highlight();
qBrushSetAlphaF(&innerBottomRight, 0.65);
} else {
border = option->palette.shadow();
qBrushSetAlphaF(&border, 0.4);
corner = option->palette.shadow();
qBrushSetAlphaF(&corner, 0.25);
innerTopLeft = option->palette.shadow();
innerBottomRight = option->palette.highlight();
if (shadow == QFrame::Sunken) {
qBrushSetAlphaF(&innerTopLeft, 0.23);
qBrushSetAlphaF(&innerBottomRight, 0.075);
} else {
qBrushSetAlphaF(&innerTopLeft, 0.075);
qBrushSetAlphaF(&innerBottomRight, 0.23);
}
}
QLine lines[4];
QPoint points[8];
// Opaque corner lines
painter->setPen(QPen(border, 0));
lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top());
lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom());
lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2);
lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2);
painter->drawLines(lines, 4);
// Opaque corner dots
points[0] = QPoint(rect.left() + 1, rect.top() + 1);
points[1] = QPoint(rect.left() + 1, rect.bottom() - 1);
points[2] = QPoint(rect.right() - 1, rect.top() + 1);
points[3] = QPoint(rect.right() - 1, rect.bottom() - 1);
painter->drawPoints(points, 4);
// Shaded corner dots
painter->setPen(QPen(corner, 0));
points[0] = QPoint(rect.left(), rect.top() + 1);
points[1] = QPoint(rect.left(), rect.bottom() - 1);
points[2] = QPoint(rect.left() + 1, rect.top());
points[3] = QPoint(rect.left() + 1, rect.bottom());
points[4] = QPoint(rect.right(), rect.top() + 1);
points[5] = QPoint(rect.right(), rect.bottom() - 1);
points[6] = QPoint(rect.right() - 1, rect.top());
points[7] = QPoint(rect.right() - 1, rect.bottom());
painter->drawPoints(points, 8);
// Shadows
if (shadow != QFrame::Plain) {
painter->setPen(QPen(innerTopLeft, 0));
lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1);
lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2);
painter->drawLines(lines, 2);
painter->setPen(QPen(innerBottomRight, 0));
lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1);
lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2);
painter->drawLines(lines, 2);
}
painter->setPen(oldPen);
}
else {
QPlastiqueStyle::drawPrimitive( element, option, painter, widget );
}
// brighter line at bottom/right
p.setPen( QColor( 160, 160, 160 ) );
p.drawLine( width() - 1, 0, width() - 1, height() - 1 );
p.drawLine( 0, height() - 1, width() - 1, height() - 1 );
*/
}

View File

@@ -182,7 +182,7 @@ void comboBox::paintEvent( QPaintEvent * _pe )
// Border
QStyleOptionFrame opt;
opt.initFrom( this );
opt.state = QStyle::State_Sunken;
opt.state = 0;
style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this );

View File

@@ -4,6 +4,7 @@
* lcd_spinbox.cpp - class lcdSpinBox, an improved QLCDNumber
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Paul Giblock <pgllama/at/gmail.com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -34,7 +35,6 @@
#include <QtGui/QFontMetrics>
#include <QtGui/QStyleOptionFrameV2>
#include "automatable_model_templates.h"
#include "caption_menu.h"
#include "embed.h"
@@ -43,29 +43,29 @@
lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
const QString & _name ) :
const QString & _name ) :
QWidget( _parent ),
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
m_label(),
m_numDigits( _num_digits ),
m_origMousePos()
{
{
setEnabled( TRUE );
setAccessibleName( _name );
m_lcdPixmap = new QPixmap( embed::getIconPixmap( "lcd_19green" ) );
int margin = 1; //QStyle::PM_DefaultFrameWidth;
m_cellWidth = m_lcdPixmap->size().width() / lcdSpinBox::charsPerPixmap;
m_cellHeight = m_lcdPixmap->size().height() / 2;
setFixedSize( m_cellWidth * (_num_digits+1) + (2*margin),
m_cellHeight + (2*margin) );
m_marginWidth = m_cellWidth / 2;
updateSize();
}
lcdSpinBox::lcdSpinBox( int _num_digits, const QString & _lcd_style,
lcdSpinBox::lcdSpinBox( int _num_digits, const QString & _lcd_style,
QWidget * _parent, const QString & _name ) :
QWidget( _parent ),
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
@@ -77,23 +77,22 @@ lcdSpinBox::lcdSpinBox( int _num_digits, const QString & _lcd_style,
setAccessibleName( _name );
// We should make a factory for these or something.
m_lcdPixmap = new QPixmap( embed::getIconPixmap( QString( "lcd_" +
_lcd_style ).toAscii().constData() ) );
int margin = 1; //QStyle::PM_DefaultFrameWidth;
m_cellWidth = m_lcdPixmap->size().width() / lcdSpinBox::charsPerPixmap;
m_cellHeight = m_lcdPixmap->size().height() / 2;
setFixedSize( m_cellWidth * (_num_digits+1) + (2*margin),
m_cellHeight + (2*margin) );
m_marginWidth = m_cellWidth / 2;
updateSize();
}
lcdSpinBox::~lcdSpinBox()
{
delete m_lcdPixmap;
}
@@ -102,17 +101,17 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me )
QRect ur = _me->rect();
QPainter p( this );
QSize cellSize( m_cellWidth, m_cellHeight );
QRect cellRect( 0, 0, m_cellWidth, m_cellHeight );
int margin = 1;// QStyle::PM_DefaultFrameWidth;
int lcdWidth = m_cellWidth * (m_numDigits+1) + (margin*2);
int margin = 1; // QStyle::PM_DefaultFrameWidth;
int lcdWidth = m_cellWidth * m_numDigits + (margin*m_marginWidth)*2;
p.translate( width() / 2 - lcdWidth / 2, 0 );
p.save();
p.translate( margin, margin );
// Left Margin
@@ -120,8 +119,8 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me )
QRect( QPoint( charsPerPixmap*m_cellWidth,
isEnabled()?0:m_cellHeight ),
cellSize ) );
p.translate( (m_cellWidth+1) / 2, 0 );
p.translate( m_marginWidth, 0 );
// Padding
for( int i=0; i < m_numDigits - m_display.length(); i++ )
@@ -150,7 +149,7 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me )
}
// Right Margin
p.drawPixmap( QRect( 0, 0, m_cellWidth / 2, m_cellHeight ), *m_lcdPixmap,
p.drawPixmap( QRect( 0, 0, m_marginWidth-1, m_cellHeight ), *m_lcdPixmap,
QRect( charsPerPixmap*m_cellWidth, isEnabled()?0:m_cellHeight,
m_cellWidth / 2, m_cellHeight ) );
@@ -161,7 +160,7 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me )
QStyleOptionFrame opt;
opt.initFrom( this );
opt.state = QStyle::State_Sunken;
opt.rect = QRect( 0, 0, m_cellWidth * (m_numDigits+1) + (margin*2),
opt.rect = QRect( 0, 0, m_cellWidth * m_numDigits + (margin+m_marginWidth)*2 - 1,
m_cellHeight + (margin*2) );
style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this );
@@ -185,7 +184,6 @@ void lcdSpinBox::paintEvent( QPaintEvent * _me )
}
void lcdSpinBox::update( void )
{
QString s = m_textForValue[model()->value()];
@@ -201,36 +199,50 @@ void lcdSpinBox::update( void )
*/
}
m_display = s;
QWidget::update();
}
void lcdSpinBox::setLabel( const QString & _txt )
{
int margin = 1;
m_label = _txt;
setFixedSize( m_cellWidth * (m_numDigits+1) + (2*margin),
m_cellHeight + (2*margin) );
setFixedSize( tMax<int>( m_cellWidth*(m_numDigits+1) + (2*margin),
QFontMetrics( pointSize<6>( font() ) ).width( m_label ) ),
m_cellHeight + (2*margin) + 10 );
update();
updateSize();
}
void lcdSpinBox::setEnabled( bool _on )
{
QWidget::setEnabled( _on );
}
void lcdSpinBox::setMarginWidth( int _width )
{
m_marginWidth = _width;
updateSize();
}
void lcdSpinBox::updateSize()
{
int margin = 1;
if (m_label.isEmpty()) {
setFixedSize( m_cellWidth * m_numDigits + 2*(margin+m_marginWidth),
m_cellHeight + (2*margin) );
}
else {
setFixedSize( tMax<int>(
m_cellWidth * m_numDigits + 2*(margin+m_marginWidth),
QFontMetrics( pointSize<6>( font() ) ).width( m_label ) ),
m_cellHeight + (2*margin) + 10 );
}
update();
}
void lcdSpinBox::contextMenuEvent( QContextMenuEvent * _me )
@@ -258,8 +270,6 @@ void lcdSpinBox::contextMenuEvent( QContextMenuEvent * _me )
}
void lcdSpinBox::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton && _me->y() < m_cellHeight + 2 )
@@ -271,8 +281,6 @@ void lcdSpinBox::mousePressEvent( QMouseEvent * _me )
}
void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
{
if( _me->buttons() & Qt::LeftButton )
@@ -289,8 +297,6 @@ void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
}
void lcdSpinBox::mouseReleaseEvent( QMouseEvent * _me )
{
model()->addJournalEntryFromOldToCurVal();
@@ -300,8 +306,6 @@ void lcdSpinBox::mouseReleaseEvent( QMouseEvent * _me )
}
void lcdSpinBox::wheelEvent( QWheelEvent * _we )
{
_we->accept();
@@ -312,7 +316,6 @@ void lcdSpinBox::wheelEvent( QWheelEvent * _we )
#include "lcd_spinbox.moc"