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

Refactor PianoRoll #5253

Merged
merged 13 commits into from
Aug 9, 2020
Merged
13 changes: 12 additions & 1 deletion data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ QMenu::indicator:selected {
background-color: #747474;
}

positionLine {
PositionLine {
qproperty-tailGradient: false;
qproperty-lineColor: rgb(255, 255, 255);
}
Expand All @@ -138,6 +138,17 @@ PianoRoll {
qproperty-ghostNoteBorders: true;
qproperty-barColor: #4afd85;
qproperty-markedSemitoneColor: rgba( 0, 255, 200, 60 );
/* Piano keys */
qproperty-whiteKeyWidth: 64;
qproperty-whiteKeyActiveTextColor: #000;
qproperty-whiteKeyActiveTextShadow: rgb( 240, 240, 240 );
qproperty-whiteKeyActiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #43e97b, stop:1 #3bcd6c);
qproperty-whiteKeyInactiveTextColor: rgb( 128, 128, 128);
qproperty-whiteKeyInactiveTextShadow: rgb( 240, 240, 240 );
qproperty-whiteKeyInactiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #eeeeee, stop:1 #ffffff);
qproperty-blackKeyWidth: 48;
qproperty-blackKeyActiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #43e97b, stop:1 #3bcd6c);
qproperty-blackKeyInactiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #333, stop:1 #000);
/* Grid colors */
qproperty-lineColor: rgba( 128, 128, 128, 80 );
qproperty-beatLineColor: rgba( 128, 128, 128, 160 );
Expand Down
13 changes: 12 additions & 1 deletion data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ QMenu::indicator:selected {
background-color: #101213;
}

positionLine {
PositionLine {
qproperty-tailGradient: true;
qproperty-lineColor: rgb(255, 255, 255);
}
Expand All @@ -170,6 +170,17 @@ PianoRoll {
qproperty-ghostNoteBorders: false;
qproperty-barColor: #078f3a;
qproperty-markedSemitoneColor: rgba(255, 255, 255, 30);
/* Piano keys */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to note these updates are purely for testing and by no means are to be considered final.

qproperty-whiteKeyWidth: 64;
qproperty-whiteKeyActiveTextColor: #000;
qproperty-whiteKeyActiveTextShadow: #fff;
qproperty-whiteKeyActiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #43e97b, stop:1 #3bcd6c);
qproperty-whiteKeyInactiveTextColor: #000;
qproperty-whiteKeyInactiveTextShadow: #fff;
qproperty-whiteKeyInactiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #eeeeee, stop:1 #ffffff);
qproperty-blackKeyWidth: 48;
qproperty-blackKeyActiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #43e97b, stop:1 #3bcd6c);
qproperty-blackKeyInactiveBackground: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #333, stop:1 #000);
/* Grid colors */
qproperty-lineColor: #292929;
qproperty-beatLineColor: #2d6b45;
Expand Down
121 changes: 53 additions & 68 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "ToolTip.h"
#include "StepRecorder.h"
#include "StepRecorderWidget.h"
#include "PositionLine.h"
Veratil marked this conversation as resolved.
Show resolved Hide resolved

class QPainter;
class QPixmap;
Expand All @@ -55,25 +56,38 @@ class TimeLineWidget;
class PianoRoll : public QWidget
{
Q_OBJECT
Q_PROPERTY( QColor barLineColor READ barLineColor WRITE setBarLineColor )
Q_PROPERTY( QColor beatLineColor READ beatLineColor WRITE setBeatLineColor )
Q_PROPERTY( QColor lineColor READ lineColor WRITE setLineColor )
Q_PROPERTY( QColor noteModeColor READ noteModeColor WRITE setNoteModeColor )
Q_PROPERTY( QColor noteColor READ noteColor WRITE setNoteColor )
Q_PROPERTY( QColor ghostNoteColor READ ghostNoteColor WRITE setGhostNoteColor )
Q_PROPERTY( QColor noteTextColor READ noteTextColor WRITE setNoteTextColor )
Q_PROPERTY( QColor ghostNoteTextColor READ ghostNoteTextColor WRITE setGhostNoteTextColor )
Q_PROPERTY( QColor barColor READ barColor WRITE setBarColor )
Q_PROPERTY( QColor selectedNoteColor READ selectedNoteColor WRITE setSelectedNoteColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
Q_PROPERTY( QColor textColorLight READ textColorLight WRITE setTextColorLight )
Q_PROPERTY( QColor textShadow READ textShadow WRITE setTextShadow )
Q_PROPERTY( QColor markedSemitoneColor READ markedSemitoneColor WRITE setMarkedSemitoneColor )
Q_PROPERTY( int noteOpacity READ noteOpacity WRITE setNoteOpacity )
Q_PROPERTY( bool noteBorders READ noteBorders WRITE setNoteBorders )
Q_PROPERTY( int ghostNoteOpacity READ ghostNoteOpacity WRITE setGhostNoteOpacity )
Q_PROPERTY( bool ghostNoteBorders READ ghostNoteBorders WRITE setGhostNoteBorders )
Q_PROPERTY( QColor backgroundShade READ backgroundShade WRITE setBackgroundShade )
Q_PROPERTY(QColor barLineColor MEMBER m_barLineColor)
Q_PROPERTY(QColor beatLineColor MEMBER m_beatLineColor)
Q_PROPERTY(QColor lineColor MEMBER m_lineColor)
Q_PROPERTY(QColor noteModeColor MEMBER m_noteModeColor)
Q_PROPERTY(QColor noteColor MEMBER m_noteColor)
Q_PROPERTY(QColor ghostNoteColor MEMBER m_ghostNoteColor)
Q_PROPERTY(QColor noteTextColor MEMBER m_noteTextColor)
Q_PROPERTY(QColor ghostNoteTextColor MEMBER m_ghostNoteTextColor)
Q_PROPERTY(QColor barColor MEMBER m_barColor)
Q_PROPERTY(QColor selectedNoteColor MEMBER m_selectedNoteColor)
Q_PROPERTY(QColor textColor MEMBER m_textColor)
Q_PROPERTY(QColor textColorLight MEMBER m_textColorLight)
Q_PROPERTY(QColor textShadow MEMBER m_textShadow)
Q_PROPERTY(QColor markedSemitoneColor MEMBER m_markedSemitoneColor)
Q_PROPERTY(int noteOpacity MEMBER m_noteOpacity)
Q_PROPERTY(bool noteBorders MEMBER m_noteBorders)
Q_PROPERTY(int ghostNoteOpacity MEMBER m_ghostNoteOpacity)
Q_PROPERTY(bool ghostNoteBorders MEMBER m_ghostNoteBorders)
Q_PROPERTY(QColor backgroundShade MEMBER m_backgroundShade)

/* white key properties */
Q_PROPERTY(int whiteKeyWidth MEMBER m_whiteKeyWidth)
Q_PROPERTY(QColor whiteKeyInactiveTextColor MEMBER m_whiteKeyInactiveTextColor)
Q_PROPERTY(QColor whiteKeyInactiveTextShadow MEMBER m_whiteKeyInactiveTextShadow)
Q_PROPERTY(QBrush whiteKeyInactiveBackground MEMBER m_whiteKeyInactiveBackground)
Q_PROPERTY(QColor whiteKeyActiveTextColor MEMBER m_whiteKeyActiveTextColor)
Q_PROPERTY(QColor whiteKeyActiveTextShadow MEMBER m_whiteKeyActiveTextShadow)
Q_PROPERTY(QBrush whiteKeyActiveBackground MEMBER m_whiteKeyActiveBackground)
/* black key properties */
Q_PROPERTY(int blackKeyWidth MEMBER m_blackKeyWidth)
Q_PROPERTY(QBrush blackKeyInactiveBackground MEMBER m_blackKeyInactiveBackground)
Q_PROPERTY(QBrush blackKeyActiveBackground MEMBER m_blackKeyActiveBackground)
public:
enum EditModes
{
Expand Down Expand Up @@ -125,47 +139,6 @@ class PianoRoll : public QWidget

int quantization() const;

// qproperty access functions
QColor barLineColor() const;
void setBarLineColor( const QColor & c );
QColor beatLineColor() const;
void setBeatLineColor( const QColor & c );
QColor lineColor() const;
void setLineColor( const QColor & c );
QColor noteModeColor() const;
void setNoteModeColor( const QColor & c );
QColor noteColor() const;
void setNoteColor( const QColor & c );
QColor noteTextColor() const;
void setNoteTextColor( const QColor & c );
QColor barColor() const;
void setBarColor( const QColor & c );
QColor selectedNoteColor() const;
void setSelectedNoteColor( const QColor & c );
QColor textColor() const;
void setTextColor( const QColor & c );
QColor textColorLight() const;
void setTextColorLight( const QColor & c );
QColor textShadow() const;
void setTextShadow( const QColor & c );
QColor markedSemitoneColor() const;
void setMarkedSemitoneColor( const QColor & c );
int noteOpacity() const;
void setNoteOpacity( const int i );
bool noteBorders() const;
void setNoteBorders( const bool b );
QColor ghostNoteColor() const;
void setGhostNoteColor( const QColor & c );
QColor ghostNoteTextColor() const;
void setGhostNoteTextColor( const QColor & c );
int ghostNoteOpacity() const;
void setGhostNoteOpacity( const int i );
bool ghostNoteBorders() const;
void setGhostNoteBorders( const bool b );
QColor backgroundShade() const;
void setBackgroundShade( const QColor & c );


protected:
void keyPressEvent( QKeyEvent * ke ) override;
void keyReleaseEvent( QKeyEvent * ke ) override;
Expand All @@ -188,7 +161,6 @@ class PianoRoll : public QWidget
void selectAll();
NoteVector getSelectedNotes() const;
void selectNotesOnKey();
int xCoordOfTick( int tick );

// for entering values with dblclick in the vol/pan bars
void enterValue( NoteVector* nv );
Expand Down Expand Up @@ -279,6 +251,8 @@ protected slots:
PR_BLACK_KEY
};

PositionLine * m_positionLine;

QVector<QString> m_nemStr; // gui names of each edit mode
QMenu * m_noteEditMenu; // when you right click below the key area

Expand Down Expand Up @@ -306,6 +280,9 @@ protected slots:
void playChordNotes(int key, int velocity=-1);
void pauseChordNotes(int key);

void updateScrollbars();
void updatePositionLineHeight();

QList<int> getAllOctavesForKey( int keyToMirror ) const;

int noteEditTop() const;
Expand All @@ -320,12 +297,6 @@ protected slots:
static const int cm_scrollAmtHoriz = 10;
static const int cm_scrollAmtVert = 1;

static QPixmap * s_whiteKeyBigPm;
static QPixmap * s_whiteKeyBigPressedPm;
static QPixmap * s_whiteKeySmallPm;
static QPixmap * s_whiteKeySmallPressedPm;
static QPixmap * s_blackKeyPm;
static QPixmap * s_blackKeyPressedPm;
static QPixmap * s_toolDraw;
static QPixmap * s_toolErase;
static QPixmap * s_toolSelect;
Expand Down Expand Up @@ -389,10 +360,11 @@ protected slots:
int m_moveStartX;
int m_moveStartY;

int m_oldNotesEditHeight;
int m_notesEditHeight;
int m_userSetNotesEditHeight;
int m_ppb; // pixels per bar
int m_totalKeysToScroll;
int m_pianoKeysVisible;

int m_keyLineHeight;
int m_octaveHeight;
Expand Down Expand Up @@ -458,6 +430,18 @@ protected slots:
bool m_noteBorders;
bool m_ghostNoteBorders;
QColor m_backgroundShade;
/* white key properties */
int m_whiteKeyWidth;
QColor m_whiteKeyActiveTextColor;
QColor m_whiteKeyActiveTextShadow;
QBrush m_whiteKeyActiveBackground;
QColor m_whiteKeyInactiveTextColor;
QColor m_whiteKeyInactiveTextShadow;
QBrush m_whiteKeyInactiveBackground;
/* black key properties */
int m_blackKeyWidth;
QBrush m_blackKeyActiveBackground;
QBrush m_blackKeyInactiveBackground;

signals:
void positionChanged( const MidiTime & );
Expand Down Expand Up @@ -501,6 +485,7 @@ class PianoRollWindow : public Editor, SerializingObject
}

QSize sizeHint() const override;
bool hasFocus() const;

signals:
void currentPatternChanged();
Expand Down
49 changes: 49 additions & 0 deletions include/PositionLine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* PositionLine.h - declaration of class PositionLine, a simple widget that
* draws a line, mainly works with TimeLineWidget
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef POSITION_LINE_H
#define POSITION_LINE_H

#include <QWidget>

class PositionLine : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool tailGradient MEMBER m_hasTailGradient)
Q_PROPERTY(QColor lineColor MEMBER m_lineColor)
public:
PositionLine(QWidget* parent);

public slots:
void zoomChange(double zoom);

private:
void paintEvent(QPaintEvent* pe) override;

bool m_hasTailGradient;
QColor m_lineColor;
};

#endif
28 changes: 2 additions & 26 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ActionGroup.h"
#include "Editor.h"
#include "TrackContainerView.h"
#include "PositionLine.h"
Veratil marked this conversation as resolved.
Show resolved Hide resolved

class QLabel;
class QScrollBar;
Expand All @@ -46,31 +47,6 @@ class Song;
class TextFloat;
class TimeLineWidget;

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

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

public slots:
void zoomChange (double zoom);

private:
void paintEvent( QPaintEvent* pe ) override;

bool m_hasTailGradient;
QColor m_lineColor;

};


class SongEditor : public TrackContainerView
{
Expand Down Expand Up @@ -156,7 +132,7 @@ private slots:
TextFloat * m_mvsStatus;
TextFloat * m_mpsStatus;

positionLine * m_positionLine;
PositionLine * m_positionLine;

ComboBoxModel* m_zoomingModel;
ComboBoxModel* m_snappingModel;
Expand Down
2 changes: 2 additions & 0 deletions include/StepRecorderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class StepRecorderWidget : public QWidget
//API used by PianoRoll
void setPixelsPerBar(int ppb);
void setCurrentPosition(MidiTime currentPosition);
void setMargins(const QMargins &qm);
void setBottomMargin(const int marginBottom);
QMargins margins();

//API used by StepRecorder
void setStepsLength(MidiTime stepsLength);
Expand Down
2 changes: 2 additions & 0 deletions include/TimeLineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ class TimeLineWidget : public QWidget, public JournallingObject
update();
}

void setXOffset(const int x);

void addToolButtons(QToolBar* _tool_bar );


Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ SET(LMMS_SRCS
gui/widgets/NStateButton.cpp
gui/widgets/Oscilloscope.cpp
gui/widgets/PixmapButton.cpp
gui/widgets/PositionLine.cpp
gui/widgets/ProjectNotes.cpp
gui/widgets/RenameDialog.cpp
gui/widgets/Rubberband.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/gui/TimeLineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ TimeLineWidget::~TimeLineWidget()



void TimeLineWidget::setXOffset(const int x)
{
m_xOffset = x;
if (s_posMarkerPixmap != nullptr) { m_xOffset -= s_posMarkerPixmap->width() / 2; }
}




void TimeLineWidget::addToolButtons( QToolBar * _tool_bar )
{
Expand Down
Loading