2012-05-26 00:56:55 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-05-26 00:56:55 +02:00
|
|
|
Clementine 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.
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-05-26 00:56:55 +02:00
|
|
|
Clementine 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.
|
2014-02-07 16:34:20 +01:00
|
|
|
|
2012-05-26 00:56:55 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOODBARRENDERER_H
|
|
|
|
#define MOODBARRENDERER_H
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QPixmap>
|
2012-05-27 17:46:16 +02:00
|
|
|
#include <QMetaType>
|
2012-05-26 00:56:55 +02:00
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
class QPalette;
|
2012-05-27 17:46:16 +02:00
|
|
|
typedef QVector<QColor> ColorVector;
|
2012-05-26 00:56:55 +02:00
|
|
|
|
|
|
|
class MoodbarRenderer {
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2012-05-28 00:44:49 +02:00
|
|
|
// These values are persisted. Remember to change appearancesettingspage.ui
|
|
|
|
// when changing them.
|
2012-05-26 00:56:55 +02:00
|
|
|
enum MoodbarStyle {
|
2012-05-28 00:44:49 +02:00
|
|
|
Style_Normal = 0,
|
2012-05-26 00:56:55 +02:00
|
|
|
Style_Angry,
|
|
|
|
Style_Frozen,
|
|
|
|
Style_Happy,
|
2012-05-28 13:50:07 +02:00
|
|
|
Style_SystemPalette,
|
|
|
|
StyleCount
|
2012-05-26 00:56:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const int kNumHues;
|
|
|
|
|
2012-05-28 13:50:07 +02:00
|
|
|
static QString StyleName(MoodbarStyle style);
|
|
|
|
|
2012-05-27 17:46:16 +02:00
|
|
|
static ColorVector Colors(const QByteArray& data, MoodbarStyle style,
|
|
|
|
const QPalette& palette);
|
|
|
|
static void Render(const ColorVector& colors, QPainter* p, const QRect& rect);
|
2012-05-27 19:53:57 +02:00
|
|
|
static QImage RenderToImage(const ColorVector& colors, const QSize& size);
|
2012-05-26 00:56:55 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2012-05-26 00:56:55 +02:00
|
|
|
MoodbarRenderer();
|
|
|
|
|
|
|
|
struct StyleProperties {
|
|
|
|
StyleProperties(int threshold = 0, int range_start = 0, int range_delta = 0,
|
|
|
|
int sat = 0, int val = 0)
|
2014-02-07 16:34:20 +01:00
|
|
|
: threshold_(threshold),
|
|
|
|
range_start_(range_start),
|
|
|
|
range_delta_(range_delta),
|
|
|
|
sat_(sat),
|
|
|
|
val_(val) {}
|
2012-05-26 00:56:55 +02:00
|
|
|
|
|
|
|
int threshold_;
|
|
|
|
int range_start_;
|
|
|
|
int range_delta_;
|
|
|
|
int sat_;
|
|
|
|
int val_;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2012-05-27 17:46:16 +02:00
|
|
|
Q_DECLARE_METATYPE(QVector<QColor>)
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // MOODBARRENDERER_H
|