various graphical enhancements
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@736 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
||||
2008-02-29 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* include/lcd_spinbox.h:
|
||||
* src/widgets/lcd_spinbox.cpp:
|
||||
* data/themes/default/lcd_19red.png:
|
||||
new non-QLcdSpinBox pixmap-based LCD spinbox
|
||||
|
||||
* include/lmms_style.h:
|
||||
* src/core/main.cpp:
|
||||
* Makefile.am:
|
||||
added lmmsStyle to aim for a consistant interface. Some Qt themes
|
||||
make LMMS look really bad. Hopefully, overtime, we can make a style
|
||||
the unifies all our gui elements
|
||||
|
||||
* src/core/track.cpp:
|
||||
playing with alternating colors per tact
|
||||
|
||||
2008-02-28 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* src/core/plugin.cpp:
|
||||
|
||||
@@ -272,6 +272,7 @@ lmms_SOURCES = \
|
||||
$(srcdir)/include/interpolation.h \
|
||||
$(srcdir)/include/lmms_constants.h \
|
||||
$(srcdir)/include/lmms_math.h \
|
||||
$(srcdir)/include/lmms_style.h \
|
||||
$(srcdir)/include/mixer.h \
|
||||
$(srcdir)/include/pattern.h \
|
||||
$(srcdir)/include/instrument_track.h \
|
||||
|
||||
BIN
data/themes/default/lcd_19red.png
Normal file
BIN
data/themes/default/lcd_19red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@@ -40,7 +40,11 @@ class lcdSpinBox : public QWidget, public automatableModelView<int>
|
||||
Q_OBJECT
|
||||
public:
|
||||
lcdSpinBox( int _num_digits, QWidget * _parent, const QString & _name =
|
||||
QString::null );
|
||||
QString::null );
|
||||
|
||||
lcdSpinBox( int _num_digits, const QString & _lcd_style,
|
||||
QWidget * _parent, const QString & _name = QString::null );
|
||||
|
||||
virtual ~lcdSpinBox();
|
||||
|
||||
void setLabel( const QString & _txt );
|
||||
@@ -69,13 +73,22 @@ protected:
|
||||
virtual void mouseMoveEvent( QMouseEvent * _me );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * _me );
|
||||
virtual void wheelEvent( QWheelEvent * _we );
|
||||
|
||||
virtual void paintEvent( QPaintEvent * _me );
|
||||
|
||||
private:
|
||||
|
||||
static const int charsPerPixmap = 12;
|
||||
|
||||
QMap<int, QString> m_textForValue;
|
||||
|
||||
QLCDNumber * m_number;
|
||||
QLabel * m_label;
|
||||
QString m_display;
|
||||
|
||||
QString m_label;
|
||||
QPixmap * m_lcdPixmap;
|
||||
|
||||
int m_cellWidth;
|
||||
int m_cellHeight;
|
||||
int m_numDigits;
|
||||
|
||||
QPoint m_origMousePos;
|
||||
|
||||
|
||||
44
include/lmms_style.h
Normal file
44
include/lmms_style.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* lmms_style.h - the graphical style used my LMMS to create a consistent interface
|
||||
*
|
||||
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LMMS_STYLE_H
|
||||
#define _LMMS_STYLE_H
|
||||
|
||||
#include <QtGui/QPlastiqueStyle>
|
||||
|
||||
class lmmsStyle : public QPlastiqueStyle
|
||||
{
|
||||
public:
|
||||
lmmsStyle() :
|
||||
QPlastiqueStyle ()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~lmmsStyle()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "song.h"
|
||||
#include "gui_templates.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "lmms_style.h"
|
||||
|
||||
#warning TODO: move somewhere else
|
||||
static inline QString baseName( const QString & _file )
|
||||
@@ -175,6 +176,8 @@ int main( int argc, char * * argv )
|
||||
|
||||
if( gui_startup )
|
||||
{
|
||||
QApplication::setStyle( new lmmsStyle() );
|
||||
|
||||
// set palette
|
||||
QPalette pal = app.palette();
|
||||
pal.setColor( QPalette::Background, QColor( 128, 128, 128 ) );
|
||||
|
||||
@@ -614,10 +614,10 @@ trackContentWidget::trackContentWidget( trackView * _parent ) :
|
||||
QWidget( _parent ),
|
||||
m_trackView( _parent )
|
||||
{
|
||||
setAutoFillBackground( TRUE );
|
||||
QPalette pal;
|
||||
pal.setColor( backgroundRole(), QColor( 96, 96, 96 ) );
|
||||
setPalette( pal );
|
||||
//setAutoFillBackground( TRUE );
|
||||
//QPalette pal;
|
||||
//pal.setColor( backgroundRole(), QColor( 96, 96, 96 ) );
|
||||
//setPalette( pal );
|
||||
setAcceptDrops( TRUE );
|
||||
|
||||
connect( _parent->getTrackContainerView(),
|
||||
@@ -696,6 +696,7 @@ void trackContentWidget::changePosition( const midiTime & _new_pos )
|
||||
{
|
||||
// const int tcos = numOfTCOs();
|
||||
|
||||
|
||||
if( m_trackView->getTrackContainerView() == engine::getBBEditor() )
|
||||
{
|
||||
const int cur_bb = engine::getBBTrackContainer()->currentBB();
|
||||
@@ -759,6 +760,9 @@ void trackContentWidget::changePosition( const midiTime & _new_pos )
|
||||
tcov->hide();
|
||||
}
|
||||
}
|
||||
|
||||
// redraw backgroun
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -833,15 +837,29 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me )
|
||||
void trackContentWidget::paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
QPainter p( this );
|
||||
p.fillRect( rect(), QColor( 96, 96, 96 ) );
|
||||
//p.fillRect( rect(), QColor( 23, 34, 37 ) );
|
||||
|
||||
const trackContainerView * tcv = m_trackView->getTrackContainerView();
|
||||
bool flip = TRUE;
|
||||
if( !tcv->fixedTCOs() )
|
||||
{
|
||||
const int offset = (int)( ( tcv->currentPosition() % 4 ) *
|
||||
tcv->pixelsPerTact() );
|
||||
|
||||
flip = tcv->currentPosition() % 256 < 128;
|
||||
int flipper = (tcv->currentPosition()/64) % 8;
|
||||
|
||||
for( int x = 0; x < width(); x+= (int) tcv->pixelsPerTact() ) {
|
||||
p.fillRect( QRect(x, 0,
|
||||
(int) tcv->pixelsPerTact(), height()),
|
||||
(flipper<4) ?
|
||||
QColor( 23, 34, 37 ) :
|
||||
QColor( 31, 45, 50 ));
|
||||
flipper = (flipper+1)%8;
|
||||
}
|
||||
|
||||
// draw vertical lines
|
||||
p.setPen( QColor( 128, 128, 128 ) );
|
||||
p.setPen( QColor( 54, 65, 69 ) );
|
||||
for( int x = -offset; x < width();
|
||||
x += (int) tcv->pixelsPerTact() )
|
||||
{
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QStyleOptionFrameV2>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
@@ -42,28 +46,47 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
m_number( new QLCDNumber( _num_digits, this ) ),
|
||||
m_label( NULL ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
{
|
||||
m_number->setFrameShape( QFrame::Panel );
|
||||
m_number->setFrameShadow( QFrame::Sunken );
|
||||
m_number->setSegmentStyle( QLCDNumber::Flat );
|
||||
|
||||
QPalette pal;
|
||||
pal.setColor( QPalette::Light, Qt::gray );
|
||||
pal.setColor( QPalette::Mid, Qt::darkGray );
|
||||
pal.setColor( QPalette::Dark, Qt::black );
|
||||
pal.setColor( m_number->backgroundRole(), Qt::black );
|
||||
m_number->setPalette( pal );
|
||||
m_number->setAutoFillBackground( TRUE );
|
||||
|
||||
{
|
||||
setEnabled( TRUE );
|
||||
|
||||
setAccessibleName( _name );
|
||||
|
||||
m_number->setFixedSize( m_number->sizeHint() * 0.9 );
|
||||
setFixedSize( m_number->size() );
|
||||
m_lcdPixmap = new QPixmap( embed::getIconPixmap( "lcd_19red" ) );
|
||||
|
||||
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) );
|
||||
}
|
||||
|
||||
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 ) ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
{
|
||||
setEnabled( TRUE );
|
||||
|
||||
setAccessibleName( _name );
|
||||
|
||||
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) );
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +97,95 @@ lcdSpinBox::~lcdSpinBox()
|
||||
}
|
||||
|
||||
|
||||
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 i;
|
||||
|
||||
int margin = 1;// QStyle::PM_DefaultFrameWidth;
|
||||
int lcdWidth = m_cellWidth * (m_numDigits+1) + (margin*2);
|
||||
|
||||
p.translate( width() / 2 - lcdWidth / 2, 0 );
|
||||
p.save();
|
||||
|
||||
p.translate( margin, margin );
|
||||
|
||||
// Left Margin
|
||||
p.drawPixmap( cellRect, *m_lcdPixmap,
|
||||
QRect( QPoint( charsPerPixmap*m_cellWidth,
|
||||
isEnabled()?0:m_cellHeight ),
|
||||
cellSize ) );
|
||||
|
||||
p.translate( (m_cellWidth+1) / 2, 0 );
|
||||
|
||||
// Padding
|
||||
for( int i=0; i < m_numDigits - m_display.length(); i++ )
|
||||
{
|
||||
p.drawPixmap( cellRect, *m_lcdPixmap,
|
||||
QRect( QPoint( 10 * m_cellWidth, isEnabled()?0:m_cellHeight) , cellSize ) );
|
||||
p.translate( m_cellWidth, 0 );
|
||||
}
|
||||
|
||||
// Digits
|
||||
for( int i=0; i < m_display.length(); i++ )
|
||||
{
|
||||
int val = m_display[i].digitValue();
|
||||
if( val < 0 )
|
||||
{
|
||||
if( m_display[i] == '-' )
|
||||
val = 11;
|
||||
else
|
||||
val = 10;
|
||||
}
|
||||
p.drawPixmap( cellRect, *m_lcdPixmap,
|
||||
QRect( QPoint( val*m_cellWidth,
|
||||
isEnabled()?0:m_cellHeight ),
|
||||
cellSize ) );
|
||||
p.translate( m_cellWidth, 0 );
|
||||
}
|
||||
|
||||
// Right Margin
|
||||
p.drawPixmap( QRect( 0, 0, m_cellWidth / 2, m_cellHeight ), *m_lcdPixmap,
|
||||
QRect( charsPerPixmap*m_cellWidth, isEnabled()?0:m_cellHeight,
|
||||
m_cellWidth / 2, m_cellHeight ) );
|
||||
|
||||
|
||||
p.restore();
|
||||
|
||||
// Border
|
||||
QStyleOptionFrame opt;
|
||||
opt.initFrom( this );
|
||||
opt.state = QStyle::State_Sunken;
|
||||
opt.rect = QRect( 0, 0, m_cellWidth * (m_numDigits+1) + (margin*2),
|
||||
m_cellHeight + (margin*2) );
|
||||
|
||||
style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this );
|
||||
|
||||
p.resetTransform();
|
||||
|
||||
// Label
|
||||
if( !m_label.isEmpty() )
|
||||
{
|
||||
p.setFont( pointSize<6>( p.font() ) );
|
||||
p.setPen( QColor( 64, 64, 64 ) );
|
||||
p.drawText( width() / 2 -
|
||||
p.fontMetrics().width( m_label ) / 2 + 1,
|
||||
height() - 1, m_label );
|
||||
p.setPen( QColor( 255, 255, 255 ) );
|
||||
p.drawText( width() / 2 -
|
||||
p.fontMetrics().width( m_label ) / 2,
|
||||
height() - 2, m_label );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void lcdSpinBox::update( void )
|
||||
@@ -82,12 +194,16 @@ void lcdSpinBox::update( void )
|
||||
if( s == "" )
|
||||
{
|
||||
s = QString::number( model()->value() );
|
||||
while( (int) s.length() < m_number->numDigits() )
|
||||
// TODO: if pad == true
|
||||
/*
|
||||
while( (int) s.length() < m_numDigits )
|
||||
{
|
||||
s = "0" + s;
|
||||
}
|
||||
*/
|
||||
}
|
||||
m_number->display( s );
|
||||
m_display = s;
|
||||
|
||||
QWidget::update();
|
||||
}
|
||||
|
||||
@@ -96,19 +212,16 @@ void lcdSpinBox::update( void )
|
||||
|
||||
void lcdSpinBox::setLabel( const QString & _txt )
|
||||
{
|
||||
if( m_label == NULL )
|
||||
{
|
||||
m_label = new QLabel( _txt, this );
|
||||
m_label->setFont( pointSize<6>( m_label->font() ) );
|
||||
m_label->setGeometry( 0, y() + height(),
|
||||
QFontMetrics( m_label->font() ).width( _txt ), 7 );
|
||||
setFixedSize( tMax( width(), m_label->width() ),
|
||||
height() + m_label->height() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_label->setText( _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();
|
||||
}
|
||||
|
||||
|
||||
@@ -116,16 +229,6 @@ void lcdSpinBox::setLabel( const QString & _txt )
|
||||
|
||||
void lcdSpinBox::setEnabled( bool _on )
|
||||
{
|
||||
QColor fg( 255, 180, 0 );
|
||||
if( _on == FALSE )
|
||||
{
|
||||
fg = QColor( 160, 160, 160 );
|
||||
}
|
||||
QPalette pal = m_number->palette();
|
||||
pal.setColor( QPalette::Background, QColor( 32, 32, 32 ) );
|
||||
pal.setColor( QPalette::Foreground, fg );
|
||||
m_number->setPalette( pal );
|
||||
|
||||
QWidget::setEnabled( _on );
|
||||
}
|
||||
|
||||
@@ -161,7 +264,7 @@ void lcdSpinBox::contextMenuEvent( QContextMenuEvent * _me )
|
||||
|
||||
void lcdSpinBox::mousePressEvent( QMouseEvent * _me )
|
||||
{
|
||||
if( _me->button() == Qt::LeftButton && _me->y() < m_number->height() )
|
||||
if( _me->button() == Qt::LeftButton && _me->y() < m_cellHeight + 2 )
|
||||
{
|
||||
m_origMousePos = _me->globalPos();
|
||||
QApplication::setOverrideCursor( Qt::BlankCursor );
|
||||
|
||||
Reference in New Issue
Block a user