2019-04-18 15:03:01 +02:00
|
|
|
/* This file was part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Strawberry 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOODBARRENDERER_H
|
|
|
|
#define MOODBARRENDERER_H
|
|
|
|
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QMetaType>
|
|
|
|
#include <QList>
|
2019-04-18 15:03:01 +02:00
|
|
|
#include <QByteArray>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QString>
|
2019-04-18 15:03:01 +02:00
|
|
|
#include <QImage>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QPalette>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QRect>
|
|
|
|
#include <QSize>
|
|
|
|
|
|
|
|
class QPainter;
|
2019-04-18 15:03:01 +02:00
|
|
|
|
2022-10-13 22:39:31 +02:00
|
|
|
using ColorVector = QVector<QColor>;
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
class MoodbarRenderer {
|
|
|
|
public:
|
|
|
|
// These values are persisted. Remember to change moodbarsettingspage.ui when changing them.
|
2023-02-18 14:09:27 +01:00
|
|
|
enum class MoodbarStyle {
|
|
|
|
Normal = 0,
|
|
|
|
Angry,
|
|
|
|
Frozen,
|
|
|
|
Happy,
|
|
|
|
SystemPalette,
|
2019-04-18 15:03:01 +02:00
|
|
|
StyleCount
|
|
|
|
};
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
static QString StyleName(const MoodbarStyle style);
|
2019-04-18 15:03:01 +02:00
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
static ColorVector Colors(const QByteArray &data, const MoodbarStyle style, const QPalette &palette);
|
2021-06-20 19:04:08 +02:00
|
|
|
static void Render(const ColorVector &colors, QPainter *p, const QRect rect);
|
|
|
|
static QImage RenderToImage(const ColorVector &colors, const QSize size);
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
private:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit MoodbarRenderer();
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
struct StyleProperties {
|
2021-01-26 16:48:04 +01:00
|
|
|
explicit StyleProperties(const int threshold = 0, const int range_start = 0, const int range_delta = 0, const int sat = 0, const int val = 0)
|
2019-04-18 15:03:01 +02:00
|
|
|
: threshold_(threshold),
|
|
|
|
range_start_(range_start),
|
|
|
|
range_delta_(range_delta),
|
|
|
|
sat_(sat),
|
|
|
|
val_(val) {}
|
|
|
|
|
|
|
|
int threshold_;
|
|
|
|
int range_start_;
|
|
|
|
int range_delta_;
|
|
|
|
int sat_;
|
|
|
|
int val_;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QVector<QColor>)
|
|
|
|
|
|
|
|
#endif // MOODBARRENDERER_H
|