Skip to content

Commit

Permalink
Open up some gui elements to theming (#7314)
Browse files Browse the repository at this point in the history
* Theming for current step note

* Theming for EnvelopeGraph

* Theming for LfoGraph

* curStepNoteColor - don't break old themes

* EnvelopeGraph - don't break old themes

* LfoGraph - don't break old themea

* currentStepNoteColor
  • Loading branch information
zonkmachine authored Nov 30, 2024
1 parent e311832 commit 3562bbe
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 19 deletions.
16 changes: 16 additions & 0 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ lmms--gui--PianoRoll {
qproperty-noteModeColor: rgb( 255, 255, 255 );
qproperty-noteColor: rgb( 119, 199, 216 );
qproperty-stepNoteColor: #9b1313;
qproperty-currentStepNoteColor: rgb(245, 3, 139);
qproperty-noteTextColor: rgb( 255, 255, 255 );
qproperty-noteOpacity: 128;
qproperty-noteBorders: true; /* boolean property, set false to have borderless notes */
Expand Down Expand Up @@ -796,6 +797,21 @@ lmms--gui--SubWindow > QPushButton:hover{
border-radius: 2px;
}

/* Instrument */

/* Envelope graph */
lmms--gui--EnvelopeGraph {
qproperty-noAmountColor: rgb(96, 91, 96);
qproperty-fullAmountColor: rgb(0, 255, 128);
qproperty-markerFillColor: rgb(153, 175, 255);
qproperty-markerOutlineColor: rgb(0, 0, 0);
}

/* LFO graph */
lmms--gui--LfoGraph {
qproperty-noAmountColor: rgb(96, 91, 96);
qproperty-fullAmountColor: rgb(0, 255, 128);
}

/* Plugins */

Expand Down
16 changes: 16 additions & 0 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ lmms--gui--PianoRoll {
qproperty-noteModeColor: #0bd556;
qproperty-noteColor: #0bd556;
qproperty-stepNoteColor: #9b1313;
qproperty-currentStepNoteColor: rgb(245, 3, 139);
qproperty-noteTextColor: #ffffff;
qproperty-noteOpacity: 165;
qproperty-noteBorders: false; /* boolean property, set false to have borderless notes */
Expand Down Expand Up @@ -835,6 +836,21 @@ lmms--gui--SubWindow > QPushButton:hover{
border-radius: 2px;
}

/* Instrument */

/* Envelope graph */
lmms--gui--EnvelopeGraph {
qproperty-noAmountColor: rgb(96, 91, 96);
qproperty-fullAmountColor: rgb(0, 255, 128);
qproperty-markerFillColor: rgb(153, 175, 255);
qproperty-markerOutlineColor: rgb(0, 0, 0);
}

/* LFO graph */
lmms--gui--LfoGraph {
qproperty-noAmountColor: rgb(96, 91, 96);
qproperty-fullAmountColor: rgb(0, 255, 128);
}

/* Plugins */

Expand Down
11 changes: 11 additions & 0 deletions include/EnvelopeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ namespace gui

class EnvelopeGraph : public QWidget, public ModelView
{
Q_OBJECT
Q_PROPERTY(QColor noAmountColor MEMBER m_noAmountColor)
Q_PROPERTY(QColor fullAmountColor MEMBER m_fullAmountColor)
Q_PROPERTY(QColor markerFillColor MEMBER m_markerFillColor)
Q_PROPERTY(QColor markerOutlineColor MEMBER m_markerOutlineColor)

public:
enum class ScalingMode
{
Expand Down Expand Up @@ -68,6 +74,11 @@ class EnvelopeGraph : public QWidget, public ModelView
EnvelopeAndLfoParameters* m_params = nullptr;

ScalingMode m_scaling = ScalingMode::Dynamic;

QColor m_noAmountColor;
QColor m_fullAmountColor;
QColor m_markerFillColor;
QColor m_markerOutlineColor;
};

} // namespace gui
Expand Down
6 changes: 6 additions & 0 deletions include/LfoGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ namespace gui

class LfoGraph : public QWidget, public ModelView
{
Q_OBJECT
Q_PROPERTY(QColor noAmountColor MEMBER m_noAmountColor)
Q_PROPERTY(QColor fullAmountColor MEMBER m_fullAmountColor)

public:
LfoGraph(QWidget* parent);

Expand All @@ -56,6 +60,8 @@ class LfoGraph : public QWidget, public ModelView
QPixmap m_lfoGraph = embed::getIconPixmap("lfo_graph");

float m_randomGraph {0.};
QColor m_noAmountColor;
QColor m_fullAmountColor;
};

} // namespace gui
Expand Down
2 changes: 2 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class PianoRoll : public QWidget
Q_PROPERTY(QColor noteModeColor MEMBER m_noteModeColor)
Q_PROPERTY(QColor noteColor MEMBER m_noteColor)
Q_PROPERTY(QColor stepNoteColor MEMBER m_stepNoteColor)
Q_PROPERTY(QColor currentStepNoteColor MEMBER m_currentStepNoteColor)
Q_PROPERTY(QColor ghostNoteColor MEMBER m_ghostNoteColor)
Q_PROPERTY(QColor noteTextColor MEMBER m_noteTextColor)
Q_PROPERTY(QColor ghostNoteTextColor MEMBER m_ghostNoteTextColor)
Expand Down Expand Up @@ -471,6 +472,7 @@ protected slots:
QColor m_noteModeColor;
QColor m_noteColor;
QColor m_stepNoteColor;
QColor m_currentStepNoteColor;
QColor m_noteTextColor;
QColor m_ghostNoteColor;
QColor m_ghostNoteTextColor;
Expand Down
5 changes: 0 additions & 5 deletions include/StepRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ class StepRecorder : public QObject
return m_isRecording;
}

QColor curStepNoteColor() const
{
return QColor(245,3,139); // radiant pink
}

private slots:
void removeNotesReleasedForTooLong();

Expand Down
5 changes: 4 additions & 1 deletion src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ PianoRoll::PianoRoll() :
m_lineColor( 0, 0, 0 ),
m_noteModeColor( 0, 0, 0 ),
m_noteColor( 0, 0, 0 ),
m_stepNoteColor(0, 0, 0),
m_currentStepNoteColor(245, 3, 139),
m_noteTextColor(0, 0, 0),
m_ghostNoteColor( 0, 0, 0 ),
m_ghostNoteTextColor( 0, 0, 0 ),
m_barColor( 0, 0, 0 ),
Expand Down Expand Up @@ -3596,7 +3599,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// we've done and checked all, let's draw the note
drawNoteRect(
p, x + m_whiteKeyWidth, noteYPos(note->key()), note_width,
note, m_stepRecorder.curStepNoteColor(), m_noteTextColor, m_selectedNoteColor,
note, m_currentStepNoteColor, m_noteTextColor, m_selectedNoteColor,
m_noteOpacity, m_noteBorders, drawNoteNames);
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/gui/instrument/EnvelopeGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ namespace gui

EnvelopeGraph::EnvelopeGraph(QWidget* parent) :
QWidget(parent),
ModelView(nullptr, this)
ModelView(nullptr, this),
m_noAmountColor(96, 91, 96),
m_fullAmountColor(0, 255, 128),
m_markerFillColor(153, 175, 255),
m_markerOutlineColor(0, 0, 0)
{
setMinimumSize(m_envGraph.size());
}
Expand Down Expand Up @@ -206,9 +210,7 @@ void EnvelopeGraph::paintEvent(QPaintEvent*)

// Compute the color of the lines based on the amount of the envelope
const float absAmount = std::abs(amount);
const QColor noAmountColor{96, 91, 96};
const QColor fullAmountColor{0, 255, 128};
const QColor lineColor{ColorHelper::interpolateInRgb(noAmountColor, fullAmountColor, absAmount)};
const QColor lineColor{ColorHelper::interpolateInRgb(m_noAmountColor, m_fullAmountColor, absAmount)};

// Determine the line width so that it scales with the widget
// Use the minimum value of the current width and height to compute it.
Expand All @@ -221,14 +223,11 @@ void EnvelopeGraph::paintEvent(QPaintEvent*)
p.drawPolyline(linePoly);

// Now draw all marker on top of the lines
const QColor markerFillColor{153, 175, 255};
const QColor markerOutlineColor{0, 0, 0};

QPen pen;
pen.setWidthF(lineWidth * 0.75);
pen.setBrush(markerOutlineColor);
pen.setBrush(m_markerOutlineColor);
p.setPen(pen);
p.setBrush(markerFillColor);
p.setBrush(m_markerFillColor);

// Compute the size of the circle we will draw based on the line width
const qreal baseRectSize = lineWidth * 3;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/instrument/LfoGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace gui

LfoGraph::LfoGraph(QWidget* parent) :
QWidget(parent),
ModelView(nullptr, this)
ModelView(nullptr, this),
m_noAmountColor(96, 91, 96),
m_fullAmountColor(0, 255, 128)
{
setMinimumSize(m_lfoGraph.size());
}
Expand Down Expand Up @@ -143,9 +145,7 @@ void LfoGraph::paintEvent(QPaintEvent*)

// Compute the color of the lines based on the amount of the LFO
const float absAmount = std::abs(amount);
const QColor noAmountColor{96, 91, 96};
const QColor fullAmountColor{0, 255, 128};
const QColor lineColor{ColorHelper::interpolateInRgb(noAmountColor, fullAmountColor, absAmount)};
const QColor lineColor{ColorHelper::interpolateInRgb(m_noAmountColor, m_fullAmountColor, absAmount)};

p.setPen(QPen(lineColor, 1.5));

Expand Down

0 comments on commit 3562bbe

Please sign in to comment.