Draw flat, borderless, semi-transparent and sharp-cornered notes (#2827)
* Draw flat, borderless, semi-transparent and sharp-cornered notes; Increase the contrast of the grid * Convert the note gradient to a horizontal one * Increase opacity for better visibility * Reinstate borders, make the fill semi-transparent * Some cosmetic touch-ups * Make border width themeable * Set a boolean for borderless properties * Rename borderlessNotes to noteBorders
This commit is contained in:
@@ -193,13 +193,13 @@ PianoRoll::PianoRoll() :
|
||||
m_noteModeColor( 0, 0, 0 ),
|
||||
m_noteColor( 0, 0, 0 ),
|
||||
m_barColor( 0, 0, 0 ),
|
||||
m_noteBorderRadiusX( 0 ),
|
||||
m_noteBorderRadiusY( 0 ),
|
||||
m_selectedNoteColor( 0, 0, 0 ),
|
||||
m_textColor( 0, 0, 0 ),
|
||||
m_textColorLight( 0, 0, 0 ),
|
||||
m_textShadow( 0, 0, 0 ),
|
||||
m_markedSemitoneColor( 0, 0, 0 )
|
||||
m_markedSemitoneColor( 0, 0, 0 ),
|
||||
m_noteOpacity( 255 ),
|
||||
m_noteBorders( true )
|
||||
{
|
||||
// gui names of edit modes
|
||||
m_nemStr.push_back( tr( "Note Velocity" ) );
|
||||
@@ -749,18 +749,6 @@ QColor PianoRoll::barColor() const
|
||||
void PianoRoll::setBarColor( const QColor & c )
|
||||
{ m_barColor = c; }
|
||||
|
||||
float PianoRoll::noteBorderRadiusX() const
|
||||
{ return m_noteBorderRadiusX; }
|
||||
|
||||
void PianoRoll::setNoteBorderRadiusX( float b )
|
||||
{ m_noteBorderRadiusX = b; }
|
||||
|
||||
float PianoRoll::noteBorderRadiusY() const
|
||||
{ return m_noteBorderRadiusY; }
|
||||
|
||||
void PianoRoll::setNoteBorderRadiusY( float b )
|
||||
{ m_noteBorderRadiusY = b; }
|
||||
|
||||
QColor PianoRoll::selectedNoteColor() const
|
||||
{ return m_selectedNoteColor; }
|
||||
|
||||
@@ -791,9 +779,25 @@ QColor PianoRoll::markedSemitoneColor() const
|
||||
void PianoRoll::setMarkedSemitoneColor( const QColor & c )
|
||||
{ m_markedSemitoneColor = c; }
|
||||
|
||||
void PianoRoll::drawNoteRect(QPainter & p, int x, int y,
|
||||
int PianoRoll::noteOpacity() const
|
||||
{ return m_noteOpacity; }
|
||||
|
||||
void PianoRoll::setNoteOpacity( const int i )
|
||||
{ m_noteOpacity = i; }
|
||||
|
||||
bool PianoRoll::noteBorders() const
|
||||
{ return m_noteBorders; }
|
||||
|
||||
void PianoRoll::setNoteBorders( const bool b )
|
||||
{ m_noteBorders = b; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void PianoRoll::drawNoteRect( QPainter & p, int x, int y,
|
||||
int width, const Note * n, const QColor & noteCol,
|
||||
float radiusX, float radiusY, const QColor & selCol )
|
||||
const QColor & selCol, const int noteOpc, const bool borders )
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
@@ -804,8 +808,8 @@ void PianoRoll::drawNoteRect(QPainter & p, int x, int y,
|
||||
width = 2;
|
||||
}
|
||||
|
||||
int volVal = qMin( 255, 25 + (int) ( ( (float)( n->getVolume() - MinVolume ) ) /
|
||||
( (float)( MaxVolume - MinVolume ) ) * 230.0f) );
|
||||
int volVal = qMin( 255, 100 + (int) ( ( (float)( n->getVolume() - MinVolume ) ) /
|
||||
( (float)( MaxVolume - MinVolume ) ) * 155.0f) );
|
||||
float rightPercent = qMin<float>( 1.0f,
|
||||
( (float)( n->getPanning() - PanningLeft ) ) /
|
||||
( (float)( PanningRight - PanningLeft ) ) * 2.0f );
|
||||
@@ -815,37 +819,47 @@ void PianoRoll::drawNoteRect(QPainter & p, int x, int y,
|
||||
( (float)( PanningRight - PanningLeft ) ) * 2.0f );
|
||||
|
||||
QColor col = QColor( noteCol );
|
||||
QPen pen;
|
||||
|
||||
if( n->selected() )
|
||||
{
|
||||
col = QColor( selCol );
|
||||
}
|
||||
|
||||
const int borderWidth = borders ? 1 : 0;
|
||||
|
||||
const int noteHeight = KEY_LINE_HEIGHT - 1 - borderWidth;
|
||||
int noteWidth = width + 1 - borderWidth;
|
||||
|
||||
// adjust note to make it a bit faded if it has a lower volume
|
||||
// in stereo using gradients
|
||||
QColor lcol = QColor::fromHsv( col.hue(), col.saturation(),
|
||||
volVal * leftPercent );
|
||||
volVal * leftPercent, noteOpc );
|
||||
QColor rcol = QColor::fromHsv( col.hue(), col.saturation(),
|
||||
volVal * rightPercent );
|
||||
volVal * rightPercent, noteOpc );
|
||||
|
||||
QLinearGradient gradient( x, y, x+width, y+KEY_LINE_HEIGHT );
|
||||
gradient.setColorAt( 0, lcol );
|
||||
gradient.setColorAt( 1, rcol );
|
||||
QLinearGradient gradient( x, y, x, y + noteHeight );
|
||||
gradient.setColorAt( 0, rcol );
|
||||
gradient.setColorAt( 1, lcol );
|
||||
p.setBrush( gradient );
|
||||
|
||||
p.setPen( col );
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.drawRoundedRect( QRectF ( x + 0.5, y - 0.5, width, KEY_LINE_HEIGHT ), radiusX, radiusY );
|
||||
if ( borders )
|
||||
{
|
||||
p.setPen( col );
|
||||
}
|
||||
else
|
||||
{
|
||||
p.setPen( Qt::NoPen );
|
||||
}
|
||||
|
||||
// that little tab thing on the end hinting at the user
|
||||
// to resize the note
|
||||
p.setPen( noteCol.lighter( 200 ) );
|
||||
p.setBrush( noteCol.lighter( 200 ) );
|
||||
p.drawRect( x, y, noteWidth, noteHeight );
|
||||
|
||||
// draw the note endmark, to hint the user to resize
|
||||
p.setBrush( col );
|
||||
if( width > 2 )
|
||||
{
|
||||
float leftIndent = 2.5;
|
||||
float vertIndent = 3.5;
|
||||
p.drawRect( QRectF (x + width - leftIndent, y + vertIndent, 1, KEY_LINE_HEIGHT - (2*vertIndent + 1) ) );
|
||||
const int endmarkWidth = 3 - borderWidth;
|
||||
p.drawRect( x + noteWidth - endmarkWidth, y, endmarkWidth, noteHeight );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2975,7 +2989,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
|
||||
// note
|
||||
drawNoteRect( p, x + WHITE_KEY_WIDTH,
|
||||
y_base - key * KEY_LINE_HEIGHT,
|
||||
note_width, note, noteColor(), noteBorderRadiusX(), noteBorderRadiusY(), selectedNoteColor() );
|
||||
note_width, note, noteColor(), selectedNoteColor(),
|
||||
noteOpacity(), noteBorders() );
|
||||
}
|
||||
|
||||
// draw note editing stuff
|
||||
@@ -3013,12 +3028,12 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
|
||||
( (float)( (PanningRight - PanningLeft ) ) ) *
|
||||
( (float)( noteEditBottom() - noteEditTop() ) );
|
||||
|
||||
p.drawLine( QLineF( noteEditLeft() + x + 0.5, noteEditTop() + 0.5 +
|
||||
p.drawLine( QLine( noteEditLeft() + x, noteEditTop() +
|
||||
( (float)( noteEditBottom() - noteEditTop() ) ) / 2.0f,
|
||||
noteEditLeft() + x + 0.5, editHandleTop + 0.5 ) );
|
||||
noteEditLeft() + x , editHandleTop ) );
|
||||
}
|
||||
editHandles << QPointF ( x + noteEditLeft() + 0.5,
|
||||
editHandleTop + 1.5 );
|
||||
editHandles << QPoint ( x + noteEditLeft(),
|
||||
editHandleTop );
|
||||
|
||||
if( note->hasDetuningInfo() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user