-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Refactored PR: Theming of disabled knobs #5549
Merged
zonkmachine
merged 8 commits into
LMMS:master
from
thmueller64:feature-theming-of-disabled-knobs
Oct 30, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
291d651
Add example for theming of disabled knobs
thmueller64 5c2c4f1
Add properties for theming of disabled knobs. Minor refactoring: Use …
thmueller64 ba1b2a6
Theming of disabled knobs. Minor refactoring.
thmueller64 36742fb
Update include/Knob.h
thmueller64 57c32c2
Add properties for disabled knobs.
thmueller64 5c5c494
Update src/gui/widgets/Knob.cpp
thmueller64 232ecf3
Changes suggested by review.
thmueller64 ba39988
Remove getters and setters for arc and line colors. Include QPixmap.
thmueller64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ | |
#ifndef KNOB_H | ||
#define KNOB_H | ||
|
||
#include <memory> | ||
#include <QPixmap> | ||
#include <QWidget> | ||
#include <QtCore/QPoint> | ||
|
||
|
@@ -41,6 +43,7 @@ enum knobTypes | |
} ; | ||
|
||
|
||
void convertPixmapToGrayScale(QPixmap &pixMap); | ||
|
||
class LMMS_EXPORT Knob : public QWidget, public FloatModelView | ||
{ | ||
|
@@ -58,8 +61,12 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView | |
// Unfortunately, the gradient syntax doesn't create our gradient | ||
// correctly so we need to do this: | ||
Q_PROPERTY(QColor outerColor READ outerColor WRITE setOuterColor) | ||
Q_PROPERTY(QColor lineColor READ lineColor WRITE setlineColor) | ||
Q_PROPERTY(QColor arcColor READ arcColor WRITE setarcColor) | ||
|
||
Q_PROPERTY(QColor lineActiveColor MEMBER m_lineActiveColor) | ||
Q_PROPERTY(QColor lineInactiveColor MEMBER m_lineInactiveColor) | ||
Q_PROPERTY(QColor arcActiveColor MEMBER m_arcActiveColor) | ||
Q_PROPERTY(QColor arcInactiveColor MEMBER m_arcInactiveColor) | ||
|
||
mapPropertyFromModel(bool,isVolumeKnob,setVolumeKnob,m_volumeKnob); | ||
mapPropertyFromModel(float,volumeRatio,setVolumeRatio,m_volumeRatio); | ||
|
||
|
@@ -74,7 +81,6 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView | |
Knob( knobTypes _knob_num, QWidget * _parent = NULL, const QString & _name = QString() ); | ||
Knob( QWidget * _parent = NULL, const QString & _name = QString() ); //!< default ctor | ||
Knob( const Knob& other ) = delete; | ||
virtual ~Knob(); | ||
|
||
// TODO: remove | ||
inline void setHintText( const QString & _txt_before, | ||
|
@@ -108,10 +114,6 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView | |
|
||
QColor outerColor() const; | ||
void setOuterColor( const QColor & c ); | ||
QColor lineColor() const; | ||
void setlineColor( const QColor & c ); | ||
QColor arcColor() const; | ||
void setarcColor( const QColor & c ); | ||
|
||
QColor textColor() const; | ||
void setTextColor( const QColor & c ); | ||
|
@@ -134,6 +136,7 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView | |
void mouseDoubleClickEvent( QMouseEvent * _me ) override; | ||
void paintEvent( QPaintEvent * _me ) override; | ||
void wheelEvent( QWheelEvent * _me ) override; | ||
void changeEvent(QEvent * ev) override; | ||
|
||
virtual float getValue( const QPoint & _p ); | ||
|
||
|
@@ -169,7 +172,7 @@ private slots: | |
|
||
QString m_label; | ||
|
||
QPixmap * m_knobPixmap; | ||
std::unique_ptr<QPixmap> m_knobPixmap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be a good idea to explicitly |
||
BoolModel m_volumeKnob; | ||
FloatModel m_volumeRatio; | ||
|
||
|
@@ -187,8 +190,11 @@ private slots: | |
float m_outerRadius; | ||
float m_lineWidth; | ||
QColor m_outerColor; | ||
QColor m_lineColor; //!< unused yet | ||
QColor m_arcColor; //!< unused yet | ||
|
||
QColor m_lineActiveColor; | ||
QColor m_lineInactiveColor; | ||
QColor m_arcActiveColor; | ||
QColor m_arcInactiveColor; | ||
|
||
QColor m_textColor; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that might be cool to do and allow even cooler themes is to allow gradients instead of single colors. Changing these to
QBrush
would allow you to define gradients or colors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Veratil for the suggestion. I replaced QColor by QBrush, below is an example. You get the idea from the picture, but a
QLinearGradient
does not result in the intended behavior here, see e.g. the red color at low volumes (I think this is due to the gradient being applied independent of the length of the active line). Furthermore, you can observe thatm_lineColor
is used both for the "middle line" and the active part of the "arc line".Maybe we could address this feature separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wouldn't use a linear gradient in that instance, you'd use a conical gradient in the CSS. Example from Qt documentation:
At the same time though, if you wanted single color you can define the brush to be the normal
rgba(...)
.