Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a trail (gradient) behind the position bar #5543

Merged
merged 13 commits into from
Jul 2, 2020
Merged
5 changes: 5 additions & 0 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ QMenu::indicator:selected {
background-color: #747474;
}

positionLine {
qproperty-tailGradient: false;
qproperty-lineColor: rgb(255, 255, 255);
}

PianoRoll {
background-color: rgb(0, 0, 0);
qproperty-backgroundShade: rgba( 255, 255, 255, 10 );
Expand Down
5 changes: 5 additions & 0 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ QMenu::indicator:selected {
background-color: #101213;
}

positionLine {
qproperty-tailGradient: true;
qproperty-lineColor: rgb(255, 255, 255);
}

PianoRoll {
background-color: #141616;
qproperty-backgroundShade: rgba(255, 255, 255, 10);
Expand Down
15 changes: 15 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define SONG_EDITOR_H

#include <QVector>
#include <QLinearGradient>

#include "ActionGroup.h"
#include "Editor.h"
Expand All @@ -45,13 +46,27 @@ class Song;
class TextFloat;
class TimeLineWidget;

Q_DECLARE_METATYPE(QLinearGradient)
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved

class positionLine : public QWidget
{
Q_OBJECT
Q_PROPERTY( bool tailGradient READ tailGradient WRITE setTailGradient )
Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor )
public:
positionLine( QWidget * parent );

// qproperty access functions
bool tailGradient() const;
void setTailGradient( const bool & g );
QColor lineColor() const;
void setLineColor( const QColor & c );

private:
void paintEvent( QPaintEvent * pe ) override;

bool m_tailGradient;
QColor m_lineColor;

} ;

Expand Down
47 changes: 40 additions & 7 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,40 @@
#include "Track.h"

positionLine::positionLine( QWidget * parent ) :
QWidget( parent )
QWidget( parent ),
m_tailGradient ( false ),
m_lineColor (0, 0, 0, 0)
{
setFixedWidth( 1 );
setFixedWidth( 8 );
setAttribute( Qt::WA_NoSystemBackground, true );
setAttribute( Qt::WA_TransparentForMouseEvents );
}




void positionLine::paintEvent( QPaintEvent * pe )
{
QPainter p( this );
p.fillRect( rect(), QColor( 255, 255, 255, 153 ) );

// Create the gradient trail behind the line
QLinearGradient gradient(rect().bottomLeft(), rect().bottomRight());

gradient.setColorAt(0,
QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 0) );
gradient.setColorAt(1,
QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 153) );

if (m_tailGradient)
{
gradient.setColorAt(0.875,
QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 60) );
}
else
{
gradient.setColorAt(0.875,
QColor (m_lineColor.red(), m_lineColor.green(), m_lineColor.blue(), 0) );
}
SecondFlight marked this conversation as resolved.
Show resolved Hide resolved

// Fill line
p.fillRect( rect(), gradient );
}

const QVector<double> SongEditor::m_zoomLevels =
Expand Down Expand Up @@ -808,7 +829,7 @@ void SongEditor::updatePosition( const MidiTime & t )
if( x >= trackOpWidth + widgetWidth -1 )
{
m_positionLine->show();
m_positionLine->move( x, m_timeLine->height() );
m_positionLine->move( x-7, m_timeLine->height() );
SecondFlight marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Expand Down Expand Up @@ -1131,3 +1152,15 @@ void SongEditorWindow::keyReleaseEvent( QKeyEvent *ke )
}
}
}

bool positionLine::tailGradient() const
{ return m_tailGradient; }

void positionLine::setTailGradient( const bool & g )
{ m_tailGradient = g; }

QColor positionLine::lineColor() const
{ return m_lineColor; }

void positionLine::setLineColor( const QColor & c )
{ m_lineColor = c; }