More LmmsStyle usages and leak fix
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1979 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* graph.h - a QT widget for displaying and manipulating waveforms
|
||||
*
|
||||
* Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
|
||||
* 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
* Copyright (c) 2008-2009 Paul Giblock <pgib/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
|
||||
@@ -245,6 +245,7 @@ public:
|
||||
|
||||
midiTime endPosition( const midiTime & _pos_start );
|
||||
|
||||
void updateBackground( void );
|
||||
|
||||
public slots:
|
||||
void update( void );
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* timeline.cpp - class timeLine, representing a time-line with position marker
|
||||
*
|
||||
* Copyright (c) 2004-2008 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
|
||||
@@ -32,16 +32,14 @@
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
|
||||
#include "timeline.h"
|
||||
#include "embed.h"
|
||||
#include "engine.h"
|
||||
#include "templates.h"
|
||||
#include "nstate_button.h"
|
||||
#include "lmms_style.h"
|
||||
#include "main_window.h"
|
||||
#include "nstate_button.h"
|
||||
#include "templates.h"
|
||||
#include "text_float.h"
|
||||
|
||||
|
||||
#include "timeline.h"
|
||||
|
||||
QPixmap * timeLine::s_timeLinePixmap = NULL;
|
||||
QPixmap * timeLine::s_posMarkerPixmap = NULL;
|
||||
@@ -246,7 +244,8 @@ void timeLine::paintEvent( QPaintEvent * )
|
||||
midiTime::ticksPerTact() ) %
|
||||
static_cast<int>( m_ppt ) );
|
||||
|
||||
p.setPen( QColor( 192, 192, 192 ) );
|
||||
QColor adas = engine::getLmmsStyle()->color(LmmsStyle::TimelineForecolor);
|
||||
p.setPen(adas);
|
||||
for( int i = 0; x + i * m_ppt < width(); ++i )
|
||||
{
|
||||
const int cx = x + qRound( i * m_ppt );
|
||||
@@ -352,7 +351,7 @@ void timeLine::mouseMoveEvent( QMouseEvent * _me )
|
||||
{
|
||||
// Note, swap 1 and 0 below and the behavior "skips" the other
|
||||
// marking instead of pushing it.
|
||||
if( m_action == MoveLoopBegin )
|
||||
if( m_action == MoveLoopBegin )
|
||||
m_loopPos[0] -= midiTime::ticksPerTact();
|
||||
else
|
||||
m_loopPos[1] += midiTime::ticksPerTact();
|
||||
|
||||
@@ -1154,59 +1154,33 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe )
|
||||
*/
|
||||
void trackContentWidget::resizeEvent( QResizeEvent * _re )
|
||||
{
|
||||
// Update backgroud
|
||||
if( _re->oldSize().height() != _re->size().height() )
|
||||
{
|
||||
updateBackground();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void trackContentWidget::updateBackground( void )
|
||||
{
|
||||
const int tactsPerBar = 4;
|
||||
const trackContainerView * tcv = m_trackView->getTrackContainerView();
|
||||
|
||||
// Assume even-pixels-per-tact. Makes sense, should be like this anyways
|
||||
int ppt = static_cast<int>( tcv->pixelsPerTact() );
|
||||
int width = ppt * tactsPerBar;
|
||||
|
||||
int w = ppt * tactsPerBar;
|
||||
int h = height();
|
||||
m_background = QPixmap( w * 2, height() );
|
||||
m_background = QPixmap( width * 2, height() );
|
||||
QPainter pmp( &m_background );
|
||||
|
||||
QLinearGradient grad( 0, 1, 0, h-2 );
|
||||
pmp.fillRect( 0, 0, 1, h, QColor( 96, 96, 96 ) );
|
||||
pmp.fillRect( 1, 0, w+1, h, QColor( 128, 128, 128 ) );
|
||||
grad.setColorAt( 0.0, QColor( 64, 64, 64 ) );
|
||||
grad.setColorAt( 0.3, QColor( 128, 128, 128 ) );
|
||||
grad.setColorAt( 0.5, QColor( 128, 128, 128 ) );
|
||||
grad.setColorAt( 0.95, QColor( 160, 160, 160 ) );
|
||||
pmp.fillRect( 0, 1, w, h-2, grad );
|
||||
|
||||
QLinearGradient grad2( 0,1, 0, h-2 );
|
||||
pmp.fillRect( w+1, 0, w , h, QColor( 96, 96, 96 ) );
|
||||
grad2.setColorAt( 0.0, QColor( 48, 48, 48 ) );
|
||||
grad2.setColorAt( 0.3, QColor( 96, 96, 96 ) );
|
||||
grad2.setColorAt( 0.5, QColor( 96, 96, 96 ) );
|
||||
grad2.setColorAt( 0.95, QColor( 120, 120, 120 ) );
|
||||
pmp.fillRect( w, 1, w , h-2, grad2 );
|
||||
|
||||
// draw vertical lines
|
||||
pmp.setPen( QPen( QColor( 0, 0, 0, 112 ), 1 ) );
|
||||
for( float x = 0.5; x < w * 2; x += ppt )
|
||||
{
|
||||
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
|
||||
}
|
||||
pmp.drawLine( 0, 1, w*2, 1 );
|
||||
|
||||
pmp.setPen( QPen( QColor( 255, 255, 255, 32 ), 1 ) );
|
||||
for( float x = 1.5; x < w * 2; x += ppt )
|
||||
{
|
||||
pmp.drawLine( QLineF( x, 1.0, x, h-2.0 ) );
|
||||
}
|
||||
pmp.drawLine( 0, h-2, w*2, h-2 );
|
||||
|
||||
pmp.end();
|
||||
|
||||
// Force redraw
|
||||
update();
|
||||
engine::getLmmsStyle()->drawTrackContentBackground( &pmp,
|
||||
QSize( width, height() ), ppt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \brief Undo an action on the trackContentWidget
|
||||
*
|
||||
* \param _je the details of the edit journal
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/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
|
||||
@@ -309,15 +309,13 @@ automationEditor::automationEditor( void ) :
|
||||
m_quantizeComboBox = new comboBox( m_toolBar );
|
||||
m_quantizeComboBox->setFixedSize( 60, 22 );
|
||||
|
||||
// TODO: leak
|
||||
comboBoxModel * quantize_model = new comboBoxModel( /* this */ );
|
||||
for( int i = 0; i < 7; ++i )
|
||||
{
|
||||
quantize_model->addItem( "1/" + QString::number( 1 << i ) );
|
||||
m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) );
|
||||
}
|
||||
quantize_model->setValue( quantize_model->findText( "1/16" ) );
|
||||
m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) );
|
||||
|
||||
m_quantizeComboBox->setModel( quantize_model );
|
||||
m_quantizeComboBox->setModel( &m_quantizeModel );
|
||||
|
||||
|
||||
tb_layout->addSpacing( 5 );
|
||||
@@ -435,19 +433,15 @@ inline void automationEditor::drawValueRect( QPainter & _p,
|
||||
int _width, int _height,
|
||||
const bool _is_selected )
|
||||
{
|
||||
QColor current_color( 0xFF, 0xB0, 0x00 );
|
||||
if( _is_selected == TRUE )
|
||||
{
|
||||
current_color.setRgb( 0x00, 0x40, 0xC0 );
|
||||
}
|
||||
_p.fillRect( _x, _y, _width, _height, current_color );
|
||||
_p.fillRect( _x, _y, _width, _height, engine::getLmmsStyle()->color(
|
||||
_is_selected ?
|
||||
LmmsStyle::AutomationSelectedBarFill :
|
||||
LmmsStyle::AutomationBarFill ) );
|
||||
|
||||
_p.setPen( QColor( 0xFF, 0xDF, 0x20 ) );
|
||||
_p.setPen( engine::getLmmsStyle()->color(
|
||||
LmmsStyle::AutomationBarValue ) );
|
||||
_p.drawLine( _x - 1, _y, _x + 1, _y );
|
||||
_p.drawLine( _x, _y - 1, _x, _y + 1 );
|
||||
// _p.setPen( QColor( 0xFF, 0x9F, 0x00 ) );
|
||||
|
||||
// _p.setPen( QColor( 0xFF, 0xFF, 0x40 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -659,20 +653,20 @@ void automationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 )
|
||||
|
||||
float yscale = deltay / ( deltax );
|
||||
|
||||
if( _x0 < _x1)
|
||||
if( _x0 < _x1)
|
||||
{
|
||||
xstep = quantization();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
xstep = -( quantization() );
|
||||
}
|
||||
|
||||
if( _y0 < _y1 )
|
||||
{
|
||||
ystep = 1;
|
||||
ystep = 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
ystep = -1;
|
||||
}
|
||||
@@ -760,7 +754,7 @@ void automationEditor::mousePressEvent( QMouseEvent * _me )
|
||||
{
|
||||
// then set new value
|
||||
midiTime value_pos( pos_ticks );
|
||||
|
||||
|
||||
midiTime new_time =
|
||||
m_pattern->putValue( value_pos,
|
||||
level );
|
||||
@@ -1220,7 +1214,7 @@ inline void automationEditor::drawCross( QPainter & _p )
|
||||
/ (float)( m_maxLevel - m_minLevel ) ) :
|
||||
grid_bottom - ( level - m_bottomLevel ) * m_y_delta;
|
||||
|
||||
_p.setPen( QColor( 0xFF, 0x33, 0x33 ) );
|
||||
_p.setPen( engine::getLmmsStyle()->color( LmmsStyle::AutomationCrosshair ) );
|
||||
_p.drawLine( VALUES_WIDTH, (int) cross_y, width(), (int) cross_y );
|
||||
_p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(),
|
||||
height() - SCROLLBAR_SIZE );
|
||||
@@ -1632,7 +1626,7 @@ void automationEditor::wheelEvent( QWheelEvent * _we )
|
||||
m_timeLine->setPixelsPerTact( m_ppt );
|
||||
update();
|
||||
}
|
||||
else if( _we->modifiers() & Qt::ShiftModifier
|
||||
else if( _we->modifiers() & Qt::ShiftModifier
|
||||
|| _we->orientation() == Qt::Horizontal )
|
||||
{
|
||||
m_leftRightScroll->setValue( m_leftRightScroll->value() -
|
||||
@@ -1858,7 +1852,7 @@ void automationEditor::selectAll( void )
|
||||
const float level = it.value();
|
||||
if( level < m_selectStartLevel )
|
||||
{
|
||||
// if we move start-level down, we have to add
|
||||
// if we move start-level down, we have to add
|
||||
// the difference between old and new start-level
|
||||
// to m_selectedLevels, otherwise the selection
|
||||
// is just moved down...
|
||||
|
||||
@@ -632,19 +632,19 @@ inline void pianoRoll::drawNoteRect( QPainter & _p, int _x, int _y,
|
||||
( (float)( PanningRight - _n->getPanning() ) ) /
|
||||
( (float)( PanningRight - PanningLeft ) ) * 2.0f );
|
||||
|
||||
const QColor defaultNoteColor( 0x00, 0xAA, 0x00 );
|
||||
const QColor defaultNoteColor =
|
||||
engine::getLmmsStyle()->color( LmmsStyle::PianoRollDefaultNote );
|
||||
QColor col = defaultNoteColor;
|
||||
|
||||
col = QColor( 0x00, 0xAA, 0x00 );
|
||||
if( _n->length() < 0 )
|
||||
{
|
||||
//step note
|
||||
col.setRgb( 0, 255, 0 );
|
||||
col = engine::getLmmsStyle()->color( LmmsStyle::PianoRollStepNote );
|
||||
_p.fillRect( _x, _y, _width, KEY_LINE_HEIGHT - 2, col );
|
||||
}
|
||||
else if( _n->selected() )
|
||||
{
|
||||
col.setRgb( 0x00, 0x40, 0xC0 );
|
||||
col = engine::getLmmsStyle()->color( LmmsStyle::PianoRollSelectedNote );
|
||||
_p.fillRect( _x, _y, _width, KEY_LINE_HEIGHT - 2, col );
|
||||
}
|
||||
else
|
||||
@@ -2683,6 +2683,13 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
const int visible_keys = ( keyAreaBottom()-keyAreaTop() ) /
|
||||
KEY_LINE_HEIGHT + 2;
|
||||
|
||||
// horizontal line for the key under the cursor
|
||||
int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() );
|
||||
p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT *
|
||||
( key_num - m_startKey + 1 ),
|
||||
width() - 10, KEY_LINE_HEIGHT - 7,
|
||||
QColor( 64, 64, 64 ) );
|
||||
|
||||
QPolygon editHandles;
|
||||
|
||||
for( noteVector::const_iterator it = notes.begin();
|
||||
@@ -2729,13 +2736,12 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
int editHandleTop = 0;
|
||||
if( m_noteEditMode == NoteEditVolume )
|
||||
{
|
||||
QColor color = QColor::fromHsv( 120, 221,
|
||||
qMin(255, 60 + ( *it )->getVolume() ) );
|
||||
if( ( *it )->selected() )
|
||||
{
|
||||
color.setRgb( 0x00, 0x40, 0xC0 );
|
||||
}
|
||||
p.setPen( QPen( color, NE_LINE_WIDTH ) );
|
||||
QColor color = engine::getLmmsStyle()->color(
|
||||
( *it )->selected() ?
|
||||
LmmsStyle::PianoRollSelectedLevel :
|
||||
LmmsStyle::PianoRollVolumeLevel );
|
||||
p.setPen( QPen( color.lighter(
|
||||
(*it)->getVolume() / 2.0f ), NE_LINE_WIDTH ) );
|
||||
|
||||
editHandleTop = noteEditBottom() -
|
||||
( (float)( ( *it )->getVolume() - MinVolume ) ) /
|
||||
@@ -2748,11 +2754,10 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
}
|
||||
else if( m_noteEditMode == NoteEditPanning )
|
||||
{
|
||||
QColor color( 0xFF, 0xB0, 0x00 );
|
||||
if( ( *it )->selected() )
|
||||
{
|
||||
color.setRgb( 0x00, 0x40, 0xC0 );
|
||||
}
|
||||
QColor color = engine::getLmmsStyle()->color(
|
||||
( *it )->selected() ?
|
||||
LmmsStyle::PianoRollSelectedLevel :
|
||||
LmmsStyle::PianoRollPanningLevel );
|
||||
|
||||
p.setPen( QPen( color, NE_LINE_WIDTH ) );
|
||||
|
||||
@@ -2776,7 +2781,7 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
}
|
||||
}
|
||||
|
||||
p.setPen( QPen( QColor( 0xEA, 0xA1, 0x00 ),
|
||||
p.setPen( QPen(engine::getLmmsStyle()->color( LmmsStyle::PianoRollEditHandle ),
|
||||
NE_LINE_WIDTH+2 ) );
|
||||
p.drawPoints( editHandles );
|
||||
|
||||
@@ -2816,16 +2821,6 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
m_leftRightScroll->setPageStep( l );
|
||||
}
|
||||
|
||||
// horizontal line for the key under the cursor
|
||||
if( validPattern() == true )
|
||||
{
|
||||
int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() );
|
||||
p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT *
|
||||
( key_num - m_startKey + 1 ),
|
||||
width() - 10, KEY_LINE_HEIGHT - 7,
|
||||
QColor( 64, 64, 64 ) );
|
||||
}
|
||||
|
||||
// bar to resize note edit area
|
||||
p.setClipRect( 0, 0, width(), height() );
|
||||
p.fillRect( QRect( 0, keyAreaBottom(),
|
||||
|
||||
@@ -223,6 +223,7 @@ void trackContainerView::realignTracks( void )
|
||||
{
|
||||
( *it )->show();
|
||||
( *it )->update();
|
||||
( *it )->getTrackContentWidget()->updateBackground();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user