Merge branch 'stable-0.4' into stable-0.4-new-fx-mixer

Conflicts:
	src/gui/FxMixerView.cpp
This commit is contained in:
Tobias Doerffel
2014-01-15 22:59:49 +01:00
22 changed files with 447 additions and 322 deletions

View File

@@ -2,7 +2,7 @@
* Piano.cpp - implementation of piano-widget used in instrument-track-window
* for testing + according model class
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -45,10 +45,10 @@
*
* \param _it the InstrumentTrack window to attach to
*/
Piano::Piano( InstrumentTrack * _it ) :
Piano::Piano( InstrumentTrack* track ) :
Model( NULL ), /*!< base class ctor */
m_instrumentTrack( _it ),
m_midiEvProc( _it ) /*!< the InstrumentTrack Model */
m_instrumentTrack( track ),
m_midiEvProc( track ) /*!< the InstrumentTrack Model */
{
for( int i = 0; i < NumKeys; ++i )
{
@@ -72,13 +72,17 @@ Piano::~Piano()
/*! \brief Turn a key on or off
*
* \param _key the key number to change
* \param _on the state to set the key to
* \param key the key number to change
* \param state the state to set the key to
*/
void Piano::setKeyState( int _key, bool _on )
void Piano::setKeyState( int key, bool state )
{
m_pressedKeys[tLimit( _key, 0, NumKeys-1 )] = _on;
emit dataChanged();
if( isValidKey( key ) )
{
m_pressedKeys[key] = state;
emit dataChanged();
}
}
@@ -86,13 +90,15 @@ void Piano::setKeyState( int _key, bool _on )
/*! \brief Handle a note being pressed on our keyboard display
*
* \param _key the key being pressed
* \param key the key being pressed
*/
void Piano::handleKeyPress( int _key )
void Piano::handleKeyPress( int key, int midiVelocity )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOn, 0, _key,
MidiMaxVelocity ), midiTime() );
m_pressedKeys[_key] = true;
if( isValidKey( key ) )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOn, 0, key, midiVelocity ), midiTime() );
m_pressedKeys[key] = true;
}
}
@@ -101,13 +107,15 @@ void Piano::handleKeyPress( int _key )
/*! \brief Handle a note being released on our keyboard display
*
* \param _key the key being releassed
* \param key the key being releassed
*/
void Piano::handleKeyRelease( int _key )
void Piano::handleKeyRelease( int key )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOff, 0, _key, 0 ),
midiTime() );
m_pressedKeys[_key] = false;
if( isValidKey( key ) )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOff, 0, key, 0 ), midiTime() );
m_pressedKeys[key] = false;
}
}

View File

@@ -48,6 +48,7 @@
#include "song.h"
#include "bb_track_container.h"
FxMixerView::FxMixerView() :
QWidget(),
ModelView( NULL, this ),
@@ -59,6 +60,7 @@ FxMixerView::FxMixerView() :
//QPalette pal = palette();
//pal.setColor( QPalette::Background, QColor( 72, 76, 88 ) );
//setPalette( pal );
setAutoFillBackground( true );
setWindowTitle( tr( "FX-Mixer" ) );
@@ -137,7 +139,7 @@ FxMixerView::FxMixerView() :
// add ourself to workspace
QMdiSubWindow * subWin =
QMdiSubWindow * subWin =
engine::mainWindow()->workspace()->addSubWindow( this );
Qt::WindowFlags flags = subWin->windowFlags();
flags &= ~Qt::WindowMaximizeButtonHint;

View File

@@ -2,7 +2,7 @@
* Piano.cpp - implementation of piano-widget used in instrument-track-window
* for testing + according model class
*
* Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -306,8 +306,8 @@ void PianoView::modelChanged()
m_piano = castModel<Piano>();
if( m_piano != NULL )
{
connect( m_piano->m_instrumentTrack->baseNoteModel(),
SIGNAL( dataChanged() ), this, SLOT( update() ) );
connect( m_piano->instrumentTrack()->baseNoteModel(), SIGNAL( dataChanged() ),
this, SLOT( update() ) );
}
}
@@ -413,8 +413,7 @@ void PianoView::contextMenuEvent( QContextMenuEvent * _me )
}
captionMenu contextMenu( tr( "Base note" ) );
AutomatableModelView amv( m_piano->m_instrumentTrack->baseNoteModel(),
&contextMenu );
AutomatableModelView amv( m_piano->instrumentTrack()->baseNoteModel(), &contextMenu );
amv.addDefaultActions( &contextMenu );
contextMenu.exec( QCursor::pos() );
}
@@ -466,11 +465,8 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
velocity = MidiMaxVelocity;
}
// set note on
m_piano->m_instrumentTrack->processInEvent(
midiEvent( MidiNoteOn, 0, key_num,
velocity ),
midiTime() );
m_piano->m_pressedKeys[key_num] = true;
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOn, 0, key_num, velocity ), midiTime() );
m_piano->setKeyState( key_num, true );
m_lastKey = key_num;
emit keyPressed( key_num );
@@ -480,17 +476,13 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
if( _me->modifiers() & Qt::ControlModifier )
{
new stringPairDrag( "automatable_model",
QString::number( m_piano->
m_instrumentTrack->
baseNoteModel()->id() ),
QString::number( m_piano->instrumentTrack()->baseNoteModel()->id() ),
QPixmap(), this );
_me->accept();
}
else
{
m_piano->m_instrumentTrack->
baseNoteModel()->
setInitValue( (float) key_num );
m_piano->instrumentTrack()->baseNoteModel()->setInitValue( (float) key_num );
emit baseNoteChanged();
}
@@ -518,10 +510,8 @@ void PianoView::mouseReleaseEvent( QMouseEvent * )
{
if( m_piano != NULL )
{
m_piano->m_midiEvProc->processInEvent(
midiEvent( MidiNoteOff, 0, m_lastKey, 0 ),
midiTime() );
m_piano->m_pressedKeys[m_lastKey] = false;
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, m_lastKey, 0 ), midiTime() );
m_piano->setKeyState( m_lastKey, false );
}
// and let the user see that he released a key... :)
@@ -581,39 +571,29 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
{
if( m_lastKey != -1 )
{
m_piano->m_midiEvProc->processInEvent(
midiEvent( MidiNoteOff, 0, m_lastKey, 0 ),
midiTime() );
m_piano->m_pressedKeys[m_lastKey] = false;
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, m_lastKey, 0 ), midiTime() );
m_piano->setKeyState( m_lastKey, false );
m_lastKey = -1;
}
if( _me->buttons() & Qt::LeftButton )
{
if( _me->pos().y() > PIANO_BASE )
{
m_piano->m_midiEvProc->processInEvent(
midiEvent( MidiNoteOn, 0, key_num,
velocity ),
midiTime() );
m_piano->m_pressedKeys[key_num] = true;
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOn, 0, key_num, velocity ), midiTime() );
m_piano->setKeyState( key_num, true );
m_lastKey = key_num;
}
else
{
m_piano->m_instrumentTrack->
baseNoteModel()->
setInitValue( (float) key_num );
m_piano->instrumentTrack()->baseNoteModel()->setInitValue( (float) key_num );
}
}
// and let the user see that he pressed a key... :)
update();
}
else if( m_piano->m_pressedKeys[key_num] == true )
else if( m_piano->isKeyPressed( key_num ) )
{
m_piano->m_midiEvProc->processInEvent(
midiEvent( MidiKeyPressure, 0, key_num,
velocity ),
midiTime() );
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiKeyPressure, 0, key_num, velocity ), midiTime() );
}
}
@@ -710,10 +690,8 @@ void PianoView::focusOutEvent( QFocusEvent * )
// hang otherwise
for( int i = 0; i < NumKeys; ++i )
{
m_piano->m_midiEvProc->processInEvent(
midiEvent( MidiNoteOff, 0, i, 0 ),
midiTime() );
m_piano->m_pressedKeys[i] = false;
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, i, 0 ), midiTime() );
m_piano->setKeyState( i, false );
}
update();
}
@@ -826,7 +804,7 @@ void PianoView::paintEvent( QPaintEvent * )
p.setPen( Qt::white );
const int base_key = ( m_piano != NULL ) ?
m_piano->m_instrumentTrack->baseNoteModel()->value() : 0;
m_piano->instrumentTrack()->baseNoteModel()->value() : 0;
g.setColorAt( 0, QColor( 0, 96, 0 ) );
g.setColorAt( 0.1, QColor( 64, 255, 64 ) );
g.setColorAt( 1, QColor( 0, 96, 0 ) );
@@ -854,7 +832,7 @@ void PianoView::paintEvent( QPaintEvent * )
// draw pressed or not pressed key, depending on state of
// current key
if( m_piano && m_piano->m_pressedKeys[cur_key] == true )
if( m_piano && m_piano->isKeyPressed( cur_key ) )
{
p.drawPixmap( x, PIANO_BASE, *s_whiteKeyPressedPm );
}
@@ -881,19 +859,17 @@ void PianoView::paintEvent( QPaintEvent * )
cur_key = m_startKey;
int white_cnt = 0;
int s_key = m_startKey;
if( s_key > 0 &&
KEY_ORDER[(Keys)(--s_key) % KeysPerOctave] == Piano::BlackKey )
int startKey = m_startKey;
if( startKey > 0 &&
KEY_ORDER[(Keys)(--startKey) % KeysPerOctave] == Piano::BlackKey )
{
if( m_piano && m_piano->m_pressedKeys[s_key] == true )
if( m_piano && m_piano->isKeyPressed( startKey ) )
{
p.drawPixmap( 0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE,
*s_blackKeyPressedPm );
p.drawPixmap( 0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm );
}
else
{
p.drawPixmap( 0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE,
*s_blackKeyPm );
p.drawPixmap( 0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm );
}
}
@@ -904,16 +880,13 @@ void PianoView::paintEvent( QPaintEvent * )
{
// draw pressed or not pressed key, depending on
// state of current key
if( m_piano && m_piano->m_pressedKeys[cur_key] == true )
if( m_piano && m_piano->isKeyPressed( cur_key ) )
{
p.drawPixmap( x + PW_WHITE_KEY_WIDTH / 2,
PIANO_BASE,
*s_blackKeyPressedPm );
p.drawPixmap( x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm );
}
else
{
p.drawPixmap( x + PW_WHITE_KEY_WIDTH / 2,
PIANO_BASE, *s_blackKeyPm );
p.drawPixmap( x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm );
}
x += PW_WHITE_KEY_WIDTH;
white_cnt = 0;

View File

@@ -3,7 +3,7 @@
* interface
*
* Copyright (c) 2007-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
@@ -33,9 +33,8 @@
#include "lmms_style.h"
lmmsStyle::lmmsStyle() :
QPlastiqueStyle()
lmmsStyle::lmmsStyle() :
QPlastiqueStyle()
{
QFile file( "resources:style.css" );
file.open( QIODevice::ReadOnly );
@@ -50,16 +49,32 @@ lmmsStyle::lmmsStyle() :
QPalette lmmsStyle::standardPalette( void ) const
{
QPalette pal = QPlastiqueStyle::standardPalette();
pal.setColor( QPalette::Background, QColor( 72, 76, 88 ) );
/* pal.setColor( QPalette::Background, QColor( 91, 101, 113 ) );
pal.setColor( QPalette::WindowText, QColor( 240, 240, 240 ) );
pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) );
pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) );
pal.setColor( QPalette::Button, QColor( 172, 176, 188 ) );
pal.setColor( QPalette::Button, QColor( 201, 201, 201 ) );
pal.setColor( QPalette::Shadow, QColor( 0, 0, 0 ) );
pal.setColor( QPalette::ButtonText, QColor( 255, 255, 255 ) );
pal.setColor( QPalette::BrightText, QColor( 0, 255, 0 ) );
pal.setColor( QPalette::Highlight, QColor( 224, 224, 224 ) );
pal.setColor( QPalette::HighlightedText, QColor( 0, 0, 0 ) );
pal.setColor( QPalette::ButtonText, QColor( 0, 0, 0 ) );
pal.setColor( QPalette::BrightText, QColor( 74, 253, 133 ) );
pal.setColor( QPalette::Highlight, QColor( 100, 100, 100 ) );
pal.setColor( QPalette::HighlightedText, QColor( 255, 255, 255 ) );*/
QStringList paletteData = qApp->styleSheet().split( '\n' ).filter( QRegExp( "^palette:*" ) );
foreach( QString s, paletteData )
{
if (s.contains("background")) { pal.setColor( QPalette::Background, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("windowtext")) { pal.setColor( QPalette::WindowText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("base")) { pal.setColor( QPalette::Base, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("buttontext")) { pal.setColor( QPalette::ButtonText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("brighttext")) { pal.setColor( QPalette::BrightText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("text")) { pal.setColor( QPalette::Text, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("button")) { pal.setColor( QPalette::Button, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("shadow")) { pal.setColor( QPalette::Shadow, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("highlightedtext")) { pal.setColor( QPalette::HighlightedText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }
else if (s.contains("highlight")) { pal.setColor( QPalette::Highlight, QColor( s.mid( s.indexOf("#"), 7 ) ) ); };
}
return( pal );
}
@@ -97,8 +112,8 @@ void lmmsStyle::drawComplexControl( ComplexControl control,
void lmmsStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
void lmmsStyle::drawPrimitive( PrimitiveElement element,
const QStyleOption *option, QPainter *painter,
const QWidget *widget) const
{
if( element == QStyle::PE_Frame ||
@@ -152,7 +167,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
lines[1] = QLine(rect.left(), rect.top() + 2,
rect.left(), rect.bottom() - 2);
painter->drawLines(lines, 2);
// outside corner dots - shadow
// 75%
shadow.setAlpha(a50);
@@ -160,7 +175,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
points[0] = QPoint(rect.left() + 1, rect.top() + 1);
points[1] = QPoint(rect.right() - 1, rect.top() + 1);
painter->drawPoints(points, 2);
// outside end dots - shadow
// 50%
shadow.setAlpha(a25);
@@ -170,7 +185,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
points[2] = QPoint(rect.right() - 1, rect.top());
points[3] = QPoint(rect.left(), rect.bottom() - 1);
painter->drawPoints(points, 4);
// outside lines - highlight
// 100%
@@ -181,7 +196,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
lines[1] = QLine(rect.right(), rect.top() + 2,
rect.right(), rect.bottom() - 2);
painter->drawLines(lines, 2);
// outside corner dots - highlight
// 75%
highlight.setAlpha(a50);
@@ -189,7 +204,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
points[0] = QPoint(rect.left() + 1, rect.bottom() - 1);
points[1] = QPoint(rect.right() - 1, rect.bottom() - 1);
painter->drawPoints(points, 2);
// outside end dots - highlight
// 50%
highlight.setAlpha(a25);
@@ -200,7 +215,7 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element,
points[3] = QPoint(rect.right(), rect.top() + 1);
painter->drawPoints(points, 4);
}
else
else
{
QPlastiqueStyle::drawPrimitive( element, option, painter,
widget );

View File

@@ -2,7 +2,7 @@
* piano_roll.cpp - implementation of piano-roll which is used for actual
* writing of melodies
*
* Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008 Andrew Kelley <superjoe30/at/gmail/dot/com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
@@ -115,8 +115,11 @@ const int NUM_TRIPLET_LENGTHS = 5;
QPixmap * pianoRoll::s_whiteKeySmallPm = NULL;
QPixmap * pianoRoll::s_whiteKeySmallPressedPm = NULL;
QPixmap * pianoRoll::s_whiteKeyBigPm = NULL;
QPixmap * pianoRoll::s_whiteKeyBigPressedPm = NULL;
QPixmap * pianoRoll::s_blackKeyPm = NULL;
QPixmap * pianoRoll::s_blackKeyPressedPm = NULL;
QPixmap * pianoRoll::s_toolDraw = NULL;
QPixmap * pianoRoll::s_toolErase = NULL;
QPixmap * pianoRoll::s_toolSelect = NULL;
@@ -222,16 +225,31 @@ pianoRoll::pianoRoll() :
s_whiteKeySmallPm = new QPixmap( embed::getIconPixmap(
"pr_white_key_small" ) );
}
if( s_whiteKeySmallPressedPm == NULL )
{
s_whiteKeySmallPressedPm = new QPixmap( embed::getIconPixmap(
"pr_white_key_small_pressed" ) );
}
if( s_whiteKeyBigPm == NULL )
{
s_whiteKeyBigPm = new QPixmap( embed::getIconPixmap(
"pr_white_key_big" ) );
}
if( s_whiteKeyBigPressedPm == NULL )
{
s_whiteKeyBigPressedPm = new QPixmap( embed::getIconPixmap(
"pr_white_key_big_pressed" ) );
}
if( s_blackKeyPm == NULL )
{
s_blackKeyPm = new QPixmap( embed::getIconPixmap(
"pr_black_key" ) );
}
if( s_blackKeyPressedPm == NULL )
{
s_blackKeyPressedPm = new QPixmap( embed::getIconPixmap(
"pr_black_key_pressed" ) );
}
if( s_toolDraw == NULL )
{
s_toolDraw = new QPixmap( embed::getIconPixmap(
@@ -753,6 +771,9 @@ void pianoRoll::setCurrentPattern( pattern * _new_pattern )
connect( m_pattern->instrumentTrack(),
SIGNAL( noteOff( const note & ) ),
this, SLOT( finishRecordNote( const note & ) ) );
connect( m_pattern->instrumentTrack()->pianoModel(),
SIGNAL( dataChanged() ),
this, SLOT( update() ) );
setWindowTitle( tr( "Piano-Roll - %1" ).arg( m_pattern->name() ) );
@@ -1031,8 +1052,7 @@ void pianoRoll::shiftPos( int amount ) //shift notes pos by amount
bool pianoRoll::isSelection() const // are any notes selected?
{
const NoteVector & notes = m_pattern->notes();
for( NoteVector::ConstIterator it = notes.begin(); it != notes.end();
++it )
for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it )
{
if( ( *it )->selected() )
{
@@ -1050,8 +1070,7 @@ int pianoRoll::selectionCount() const // how many notes are selected?
int sum = 0;
const NoteVector & notes = m_pattern->notes();
for( NoteVector::ConstIterator it = notes.begin(); it != notes.end();
++it )
for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it )
{
if( ( *it )->selected() )
{
@@ -1064,26 +1083,23 @@ int pianoRoll::selectionCount() const // how many notes are selected?
void pianoRoll::keyPressEvent( QKeyEvent * _ke )
void pianoRoll::keyPressEvent( QKeyEvent* event )
{
if( validPattern() && _ke->modifiers() == Qt::NoModifier )
if( validPattern() && event->modifiers() == Qt::NoModifier )
{
const int key_num = PianoView::getKeyFromKeyEvent( _ke ) +
( DefaultOctave - 1 ) * KeysPerOctave;
const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave;
if( _ke->isAutoRepeat() == false && key_num > -1 )
if( event->isAutoRepeat() == false && key_num > -1 )
{
m_pattern->instrumentTrack()->pianoModel()->
handleKeyPress( key_num );
_ke->accept();
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num );
event->accept();
}
}
switch( _ke->key() )
switch( event->key() )
{
case Qt::Key_Up:
if( ( _ke->modifiers() & Qt::ControlModifier )
&& m_action == ActionNone )
if( ( event->modifiers() & Qt::ControlModifier ) && m_action == ActionNone )
{
// shift selection up an octave
// if nothing selected, shift _everything_
@@ -1102,16 +1118,15 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
_ke->modifiers() & Qt::AltModifier,
_ke->modifiers() & Qt::ShiftModifier );
event->modifiers() & Qt::AltModifier,
event->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
event->accept();
break;
case Qt::Key_Down:
if( _ke->modifiers() & Qt::ControlModifier
&& m_action == ActionNone )
if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone )
{
// shift selection down an octave
// if nothing selected, shift _everything_
@@ -1130,16 +1145,15 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
_ke->modifiers() & Qt::AltModifier,
_ke->modifiers() & Qt::ShiftModifier );
event->modifiers() & Qt::AltModifier,
event->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
event->accept();
break;
case Qt::Key_Left:
if( _ke->modifiers() & Qt::ControlModifier &&
m_action == ActionNone )
if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone )
{
// move time ticker
if( ( m_timeLine->pos() -= 16 ) < 0 )
@@ -1148,12 +1162,10 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
}
m_timeLine->updatePosition();
}
else if( _ke->modifiers() & Qt::ShiftModifier
&& m_action == ActionNone)
else if( event->modifiers() & Qt::ShiftModifier && m_action == ActionNone)
{
// move notes
bool quantized = ! ( _ke->modifiers() &
Qt::AltModifier );
bool quantized = ! ( event->modifiers() & Qt::AltModifier );
int amt = quantized ? quantization() : 1;
shiftPos( -amt );
}
@@ -1170,28 +1182,25 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
_ke->modifiers() & Qt::AltModifier,
_ke->modifiers() & Qt::ShiftModifier );
event->modifiers() & Qt::AltModifier,
event->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
event->accept();
break;
case Qt::Key_Right:
if( _ke->modifiers() & Qt::ControlModifier
&& m_action == ActionNone)
if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone)
{
// move time ticker
m_timeLine->pos() += 16;
m_timeLine->updatePosition();
}
else if( _ke->modifiers() & Qt::ShiftModifier
&& m_action == ActionNone)
else if( event->modifiers() & Qt::ShiftModifier && m_action == ActionNone)
{
// move notes
bool quantized = !( _ke->modifiers() &
Qt::AltModifier );
bool quantized = !( event->modifiers() & Qt::AltModifier );
int amt = quantized ? quantization() : 1;
shiftPos( +amt );
}
@@ -1208,42 +1217,42 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
_ke->modifiers() & Qt::AltModifier,
_ke->modifiers() & Qt::ShiftModifier );
event->modifiers() & Qt::AltModifier,
event->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
event->accept();
break;
case Qt::Key_C:
if( _ke->modifiers() & Qt::ControlModifier )
if( event->modifiers() & Qt::ControlModifier )
{
_ke->accept();
event->accept();
copySelectedNotes();
}
break;
case Qt::Key_X:
if( _ke->modifiers() & Qt::ControlModifier )
if( event->modifiers() & Qt::ControlModifier )
{
_ke->accept();
event->accept();
cutSelectedNotes();
}
break;
case Qt::Key_V:
if( _ke->modifiers() & Qt::ControlModifier )
if( event->modifiers() & Qt::ControlModifier )
{
_ke->accept();
event->accept();
pasteNotes();
}
break;
case Qt::Key_A:
if( _ke->modifiers() & Qt::ControlModifier )
if( event->modifiers() & Qt::ControlModifier )
{
_ke->accept();
event->accept();
m_selectButton->setChecked( true );
selectAll();
update();
@@ -1251,40 +1260,40 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
break;
case Qt::Key_D:
if( _ke->modifiers() & Qt::ShiftModifier )
if( event->modifiers() & Qt::ShiftModifier )
{
_ke->accept();
event->accept();
m_drawButton->setChecked( true );
}
break;
case Qt::Key_E:
if( _ke->modifiers() & Qt::ShiftModifier )
if( event->modifiers() & Qt::ShiftModifier )
{
_ke->accept();
event->accept();
m_eraseButton->setChecked( true );
}
break;
case Qt::Key_S:
if( _ke->modifiers() & Qt::ShiftModifier )
if( event->modifiers() & Qt::ShiftModifier )
{
_ke->accept();
event->accept();
m_selectButton->setChecked( true );
}
break;
case Qt::Key_T:
if( _ke->modifiers() & Qt::ShiftModifier )
if( event->modifiers() & Qt::ShiftModifier )
{
_ke->accept();
event->accept();
m_detuneButton->setChecked( true );
}
break;
case Qt::Key_Delete:
deleteSelectedNotes();
_ke->accept();
event->accept();
break;
case Qt::Key_Space:
@@ -1296,13 +1305,13 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
{
play();
}
_ke->accept();
event->accept();
break;
case Qt::Key_Home:
m_timeLine->pos().setTicks( 0 );
m_timeLine->updatePosition();
_ke->accept();
event->accept();
break;
case Qt::Key_0:
@@ -1316,19 +1325,20 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
case Qt::Key_8:
case Qt::Key_9:
{
int len = 1 + _ke->key() - Qt::Key_0;
if( len == 10 )
int len = 1 + event->key() - Qt::Key_0;
if( len == 10 )
{
len = 0;
if( _ke->modifiers() &
( Qt::ControlModifier | Qt::KeypadModifier ) )
}
if( event->modifiers() & ( Qt::ControlModifier | Qt::KeypadModifier ) )
{
m_noteLenModel.setValue( len );
_ke->accept();
event->accept();
}
else if( _ke->modifiers() & Qt::AltModifier )
else if( event->modifiers() & Qt::AltModifier )
{
m_quantizeModel.setValue( len );
_ke->accept();
event->accept();
}
break;
}
@@ -1337,40 +1347,41 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_ctrlMode = m_editMode;
m_editMode = ModeSelect;
QApplication::changeOverrideCursor( Qt::ArrowCursor );
update();
_ke->accept();
event->accept();
break;
default:
break;
}
update();
}
void pianoRoll::keyReleaseEvent( QKeyEvent * _ke )
void pianoRoll::keyReleaseEvent( QKeyEvent* event )
{
if( validPattern() && _ke->modifiers() == Qt::NoModifier )
if( validPattern() && event->modifiers() == Qt::NoModifier )
{
const int key_num = PianoView::getKeyFromKeyEvent( _ke ) +
( DefaultOctave - 1 ) * KeysPerOctave;
const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave;
if( _ke->isAutoRepeat() == false && key_num > -1 )
if( event->isAutoRepeat() == false && key_num > -1 )
{
m_pattern->instrumentTrack()->pianoModel()->
handleKeyRelease( key_num );
_ke->accept();
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( key_num );
event->accept();
}
}
switch( _ke->key() )
switch( event->key() )
{
case Qt::Key_Control:
computeSelectedNotes( _ke->modifiers() &
Qt::ShiftModifier);
computeSelectedNotes( event->modifiers() & Qt::ShiftModifier);
m_editMode = m_ctrlMode;
update();
break;
}
update();
}
@@ -1456,8 +1467,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
{
m_ctrlMode = m_editMode;
m_editMode = ModeSelect;
QApplication::changeOverrideCursor(
QCursor( Qt::ArrowCursor ) );
QApplication::changeOverrideCursor( QCursor( Qt::ArrowCursor ) );
update();
}
@@ -1672,10 +1682,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// clicked at the "tail" of the note?
if( pos_ticks*m_ppt/midiTime::ticksPerTact() >
( m_currentNote->pos() +
m_currentNote->length() )*m_ppt/
midiTime::ticksPerTact() -
RESIZE_AREA_WIDTH &&
( m_currentNote->pos() + m_currentNote->length() )*m_ppt/ midiTime::ticksPerTact() - RESIZE_AREA_WIDTH &&
m_currentNote->length() > 0 )
{
// then resize the note
@@ -1787,10 +1794,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
m_lastKey = key_num;
if( ! m_recording && ! engine::getSong()->isPlaying() )
{
int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * 127;
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOn, 0, key_num, v ),
midiTime() );
int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiMaxVelocity;
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v );
}
}
}
@@ -1844,12 +1849,9 @@ void pianoRoll::testPlayNote( note * n )
! engine::getSong()->isPlaying() )
{
n->setIsPlaying( true );
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOn, 0, n->key(),
n->getVolume() * 127 / 100 ), midiTime() );
midiEvent evt( MidiMetaEvent, 0, n->key(),
panningToMidi( n->getPanning() ) );
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( n->key(), volumeToMidi( n->getVolume() ) );
midiEvent evt( MidiMetaEvent, 0, n->key(), panningToMidi( n->getPanning() ) );
evt.m_metaEvent = MidiNotePanning;
m_pattern->instrumentTrack()->processInEvent( evt, midiTime() );
@@ -1870,11 +1872,7 @@ void pianoRoll::pauseTestNotes( bool _pause )
if( _pause )
{
// stop note
m_pattern->instrumentTrack()->
processInEvent(
midiEvent( MidiNoteOff, 0,
( *it )->key(), 0 ),
midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() );
}
else
{
@@ -1891,23 +1889,19 @@ void pianoRoll::pauseTestNotes( bool _pause )
void pianoRoll::testPlayKey( int _key, int _vol, int _pan )
void pianoRoll::testPlayKey( int key, int velocity, int pan )
{
// turn off old key
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOff, 0, m_lastKey, 0 ),
midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( m_lastKey );
// remember which one we're playing
m_lastKey = _key;
m_lastKey = key;
// play new key
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOn, 0, _key, _vol ),
midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key, velocity );
// set panning of newly played key
midiEvent evt( MidiMetaEvent, 0, _key, _pan );
midiEvent evt( MidiMetaEvent, 0, key, pan );
evt.m_metaEvent = MidiNotePanning;
}
@@ -2052,11 +2046,7 @@ void pianoRoll::mouseReleaseEvent( QMouseEvent * _me )
{
if( ( *it )->isPlaying() )
{
m_pattern->instrumentTrack()->
processInEvent(
midiEvent( MidiNoteOff, 0,
( *it )->key(), 0 ),
midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() );
( *it )->setIsPlaying( false );
}
@@ -2064,10 +2054,7 @@ void pianoRoll::mouseReleaseEvent( QMouseEvent * _me )
}
// stop playing keys that we let go of
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOff, 0, m_lastKey, 0 ),
midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( m_lastKey );
}
m_currentNote = NULL;
@@ -2132,9 +2119,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
&& _me->buttons() & Qt::LeftButton )
{
// clicked on a key, play the note
testPlayKey( key_num,
( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * 127,
0 );
testPlayKey( key_num, ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiMaxVelocity, 0 );
update();
return;
}
@@ -2224,26 +2209,19 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// play the note so that the user can tell how loud it is
// and where it is panned
testPlayNote( n );
if( m_noteEditMode == NoteEditVolume )
{
n->setVolume( vol );
m_pattern->instrumentTrack()->processInEvent(
midiEvent(
MidiKeyPressure,
0,
n->key(),
vol * 127 / 100),
midiTime() );
midiEvent( MidiKeyPressure, 0, n->key(), volumeToMidi( vol ) ), midiTime() );
}
else if( m_noteEditMode == NoteEditPanning )
{
n->setPanning( pan );
midiEvent evt( MidiMetaEvent, 0,
n->key(), panningToMidi( pan ) );
midiEvent evt( MidiMetaEvent, 0, n->key(), panningToMidi( pan ) );
evt.m_metaEvent = MidiNotePanning;
m_pattern->instrumentTrack()->processInEvent(
evt, midiTime() );
m_pattern->instrumentTrack()->processInEvent( evt, midiTime() );
}
}
else
@@ -2251,10 +2229,8 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
if( n->isPlaying() )
{
// mouse not over this note, stop playing it.
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiNoteOff, 0,
n->key(), 0 ), midiTime() );
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( n->key() );
n->setIsPlaying( false );
}
}
@@ -2739,7 +2715,6 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
}
break;
}
// start drawing at the bottom
int key_line_y = keyAreaBottom() - 1;
// used for aligning black-keys later
@@ -2793,9 +2768,15 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
// check whether to draw a big or a small white key
if( prKeyOrder[key % KeysPerOctave] == PR_WHITE_KEY_SMALL )
{
// draw a small one...
p.drawPixmap( PIANO_X, y - WHITE_KEY_SMALL_HEIGHT,
*s_whiteKeySmallPm );
// draw a small one while checking if it is pressed or not
if( m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - WHITE_KEY_SMALL_HEIGHT, *s_whiteKeySmallPressedPm );
}
else
{
p.drawPixmap( PIANO_X, y - WHITE_KEY_SMALL_HEIGHT, *s_whiteKeySmallPm );
}
// update y-pos
y -= WHITE_KEY_SMALL_HEIGHT;
@@ -2803,9 +2784,15 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
else if( prKeyOrder[key % KeysPerOctave] ==
PR_WHITE_KEY_BIG )
{
// draw a big one...
p.drawPixmap( PIANO_X, y-WHITE_KEY_BIG_HEIGHT,
*s_whiteKeyBigPm );
// draw a big one while checking if it is pressed or not
if(m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - WHITE_KEY_BIG_HEIGHT, *s_whiteKeyBigPressedPm );
}
else
{
p.drawPixmap( PIANO_X, y-WHITE_KEY_BIG_HEIGHT, *s_whiteKeyBigPm );
}
// if a big white key has been the first key,
// black keys needs to be lifted up
if( keys_processed == 0 )
@@ -2868,15 +2855,25 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
}
}
// current key black?
if( prKeyOrder[key % KeysPerOctave] == PR_BLACK_KEY )
if( prKeyOrder[key % KeysPerOctave] == PR_BLACK_KEY)
{
// then draw it (calculation of y very complicated,
// but that's the only working solution, sorry...)
p.drawPixmap( PIANO_X, y - ( first_white_key_height -
WHITE_KEY_SMALL_HEIGHT ) -
WHITE_KEY_SMALL_HEIGHT/2 - 1 -
BLACK_KEY_HEIGHT, *s_blackKeyPm );
// check if the key is pressed or not
if( m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - ( first_white_key_height -
WHITE_KEY_SMALL_HEIGHT ) -
WHITE_KEY_SMALL_HEIGHT/2 - 1 -
BLACK_KEY_HEIGHT, *s_blackKeyPressedPm );
}
else
{
p.drawPixmap( PIANO_X, y - ( first_white_key_height -
WHITE_KEY_SMALL_HEIGHT ) -
WHITE_KEY_SMALL_HEIGHT/2 - 1 -
BLACK_KEY_HEIGHT, *s_blackKeyPm );
}
// update y-pos
y -= WHITE_KEY_BIG_HEIGHT;
// reset white-counter

View File

@@ -70,7 +70,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
m_autoQuit->setLabel( tr( "DECAY" ) );
m_autoQuit->move( 60, 5 );
m_autoQuit->setHintText( tr( "Time:" ) + " ", "ms" );
m_autoQuit->setWhatsThis( tr(
m_autoQuit->setWhatsThis( tr(
"The Decay knob controls how many buffers of silence must pass before the "
"plugin stops processing. Smaller values will reduce the CPU overhead but "
"run the risk of clipping the tail on delay and reverb effects." ) );
@@ -80,7 +80,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
m_gate->setLabel( tr( "GATE" ) );
m_gate->move( 93, 5 );
m_gate->setHintText( tr( "Gate:" ) + " ", "" );
m_gate->setWhatsThis( tr(
m_gate->setWhatsThis( tr(
"The Gate knob controls the signal level that is considered to be 'silence' "
"while deciding when to stop processing signals." ) );
@@ -94,7 +94,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
QFont f = ctls_btn->font();
ctls_btn->setFont( pointSize<7>( f ) );
ctls_btn->setGeometry( 140, 14, 50, 20 );
connect( ctls_btn, SIGNAL( clicked() ),
connect( ctls_btn, SIGNAL( clicked() ),
this, SLOT( editControls() ) );
m_controlView = effect()->controls()->createView();
@@ -115,7 +115,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
}
setWhatsThis( tr(
setWhatsThis( tr(
"Effect plugins function as a chained series of effects where the signal will "
"be processed from top to bottom.\n\n"
@@ -264,7 +264,7 @@ void EffectView::paintEvent( QPaintEvent * )
f.setBold( true );
p.setFont( f );
p.setPen( QColor( 64, 64, 64 ) );
p.setPen( palette().shadow().color() );
p.drawText( 6, 55, model()->displayName() );
p.setPen( palette().text().color() );
p.drawText( 5, 54, model()->displayName() );

View File

@@ -46,7 +46,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
m_led = new pixmapButton( this, _caption );
m_led->setCheckable( true );
m_led->move( 3, 3 );
m_led->move( 3, 0 );
m_led->setActiveGraphic( embed::getIconPixmap( "led_green" ) );
m_led->setInactiveGraphic( embed::getIconPixmap( "led_off" ) );
@@ -127,7 +127,7 @@ void groupBox::updatePixmap()
//p.setPen( QColor( 255, 255, 255 ) );
p.setPen( palette().color( QPalette::Active, QPalette::ButtonText ) );
p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
p.setFont( pointSize<7>( font() ) );
p.drawText( 22, 10, m_caption );