-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
139 additions
and
26 deletions.
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
64 changes: 64 additions & 0 deletions
64
controls/com/vicr123/Contemporary/CoreStyles/layercalculator.cpp
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "layercalculator.h" | ||
|
||
#include <QColor> | ||
|
||
struct LayerCalculatorPrivate { | ||
uint layer = 1; | ||
QColor layerBase = Qt::transparent; | ||
QColor layerColor; | ||
}; | ||
|
||
LayerCalculator::LayerCalculator(uint layer, QColor layerColor, QColor layerBase, QObject* parent) : | ||
QObject{parent}, d{new LayerCalculatorPrivate} { | ||
d->layer = layer; | ||
d->layerColor = layerColor; | ||
d->layerBase = layerBase; | ||
} | ||
|
||
LayerCalculator::~LayerCalculator() { | ||
delete d; | ||
} | ||
|
||
uint LayerCalculator::layer() const { | ||
return d->layer; | ||
} | ||
|
||
QColor LayerCalculator::layerBase() const { | ||
return d->layerBase; | ||
} | ||
|
||
QColor LayerCalculator::value() const { | ||
if (d->layer <= 0) return d->layerBase; | ||
|
||
auto layerColor = this->layerColor(); | ||
auto base = this->layerBase(); | ||
for (auto i = 0; i < d->layer; i++) { | ||
base.setRedF(layerColor.alphaF() * layerColor.redF() + (1 - layerColor.alphaF()) * base.redF()); | ||
base.setGreenF(layerColor.alphaF() * layerColor.greenF() + (1 - layerColor.alphaF()) * base.greenF()); | ||
base.setBlueF(layerColor.alphaF() * layerColor.blueF() + (1 - layerColor.alphaF()) * base.blueF()); | ||
} | ||
return base; | ||
} | ||
|
||
void LayerCalculator::setLayer(uint layer) { | ||
d->layer = layer; | ||
emit layerChanged(); | ||
emit valueChanged(); | ||
} | ||
|
||
void LayerCalculator::setLayerBase(const QColor& color) { | ||
d->layerBase = color; | ||
emit layerBaseChanged(); | ||
emit valueChanged(); | ||
} | ||
|
||
QColor LayerCalculator::layerColor() const { | ||
return d->layerColor; | ||
} | ||
|
||
void LayerCalculator::setLayerColor(const QColor& color) { | ||
d->layerColor = color; | ||
emit layerColorChanged(); | ||
emit valueChanged(); | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
controls/com/vicr123/Contemporary/CoreStyles/layercalculator.h
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef LAYERCALCULATOR_H | ||
#define LAYERCALCULATOR_H | ||
|
||
#include <QObject> | ||
#include <QColor> | ||
|
||
struct LayerCalculatorPrivate; | ||
class LayerCalculator : public QObject { | ||
Q_OBJECT | ||
Q_PROPERTY(uint layer READ layer WRITE setLayer NOTIFY layerChanged) | ||
Q_PROPERTY(QColor layerBase READ layerBase WRITE setLayerBase NOTIFY layerBaseChanged) | ||
Q_PROPERTY(QColor layerColor READ layerColor WRITE setLayerColor NOTIFY layerColorChanged) | ||
Q_PROPERTY(QColor value READ value NOTIFY valueChanged) | ||
|
||
public: | ||
explicit LayerCalculator(uint layer, QColor layerColor, QColor layerBase = Qt::transparent, QObject* parent = nullptr); | ||
~LayerCalculator(); | ||
|
||
uint layer() const; | ||
void setLayer(uint layer); | ||
|
||
QColor layerBase() const; | ||
void setLayerBase(const QColor& color); | ||
|
||
QColor layerColor() const; | ||
void setLayerColor(const QColor& color); | ||
|
||
QColor value() const; | ||
|
||
signals: | ||
void layerChanged(); | ||
void layerBaseChanged(); | ||
void layerColorChanged(); | ||
void valueChanged(); | ||
|
||
private: | ||
LayerCalculatorPrivate* d; | ||
}; | ||
|
||
#endif // LAYERCALCULATOR_H |
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
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
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