Skip to content

Commit

Permalink
Gradient can be toggled and color can be changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuukumar committed Jun 23, 2020
1 parent f909a21 commit c5dc75d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
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: rgba(255, 255, 255, 153);
}

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)

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
38 changes: 31 additions & 7 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,36 @@
#include "Track.h"

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




void positionLine::paintEvent( QPaintEvent * pe )
{
QPainter p( this );

// Create the gradient trail behind the line
QLinearGradient gradient(rect().bottomLeft(), rect().bottomRight());
gradient.setColorAt(0, QColor (255, 255, 255, 0) );
gradient.setColorAt(0.875, QColor (255, 255, 255, 60) );
gradient.setColorAt(1, QColor (255, 255, 255, 153) );

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) );
}

// Fill line
p.fillRect( rect(), gradient );
Expand Down Expand Up @@ -1139,3 +1151,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; }

0 comments on commit c5dc75d

Please sign in to comment.