-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add gradient class and start widget
- Loading branch information
Showing
8 changed files
with
385 additions
and
239 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "gradient.h" | ||
|
||
void Gradient::sort() | ||
{ | ||
std::sort(points.begin(), points.end(), | ||
[](const GradientPoint& a, const GradientPoint& b) { | ||
return a.position < b.position; | ||
}); | ||
} | ||
|
||
Gradient Gradient::defaultGradient() | ||
{ | ||
Gradient gradient; | ||
gradient.addPoint(GradientPoint(0.0, QColor(0, 0, 0))); | ||
gradient.addPoint(GradientPoint(1.0, QColor(255, 255, 255))); | ||
return gradient; | ||
} |
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,29 @@ | ||
#pragma once | ||
|
||
#include <QColor> | ||
#include <QVector> | ||
|
||
class GradientPoint { | ||
public: | ||
float position; | ||
QColor color; | ||
|
||
GradientPoint(float position, const QColor& color) | ||
: position(position), color(color) | ||
{ | ||
} | ||
}; | ||
|
||
class Gradient { | ||
public: | ||
QVector<GradientPoint> points; | ||
|
||
Gradient() {} | ||
Gradient(const QVector<GradientPoint>& points) : points(points) {} | ||
Gradient(const Gradient& other) : points(other.points) {} | ||
|
||
void addPoint(GradientPoint point) { points.append(point); } | ||
void sort(); | ||
|
||
static Gradient defaultGradient(); | ||
}; |
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,29 @@ | ||
#include "gradientpicker.h" | ||
#include "gradient.h" | ||
|
||
GradientSlider::GradientSlider() { this->initUI(); } | ||
|
||
void GradientSlider::setGradient(const Gradient& gradient) | ||
{ | ||
this->gradient = gradient; | ||
this->update(); | ||
} | ||
|
||
void GradientSlider::initUI() { this->setFixedSize(400, 100); } | ||
|
||
GradientPickerDialog::GradientPickerDialog() { this->initUI(); } | ||
|
||
void GradientPickerDialog::setGradient(const Gradient& gradient) | ||
{ | ||
// this->gradient = gradient; | ||
this->gradientSlider->setGradient(gradient); | ||
|
||
// update ui | ||
// this->update(); | ||
} | ||
|
||
void GradientPickerDialog::initUI() | ||
{ | ||
// create ui | ||
// this->setFixedSize(400, 100); | ||
} |
Oops, something went wrong.