2010-06-06 16:06:23 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-06 16:06:23 +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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PROJECTMVISUALISATION_H
|
|
|
|
#define PROJECTMVISUALISATION_H
|
|
|
|
|
|
|
|
#include <QBasicTimer>
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <QGraphicsScene>
|
2010-06-07 03:55:21 +02:00
|
|
|
#include <QSet>
|
2020-09-18 16:15:19 +02:00
|
|
|
#include <memory>
|
2010-06-06 16:06:23 +02:00
|
|
|
|
|
|
|
#include "engines/bufferconsumer.h"
|
|
|
|
|
|
|
|
class projectM;
|
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
class ProjectMPresetModel;
|
|
|
|
|
2021-04-07 22:05:37 +02:00
|
|
|
class VisualisationContainer;
|
|
|
|
|
2010-07-18 15:26:01 +02:00
|
|
|
class QTemporaryFile;
|
|
|
|
|
2010-06-06 20:18:06 +02:00
|
|
|
class ProjectMVisualisation : public QGraphicsScene, public BufferConsumer {
|
2010-06-06 16:06:23 +02:00
|
|
|
Q_OBJECT
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2021-04-07 22:05:37 +02:00
|
|
|
ProjectMVisualisation(VisualisationContainer* container);
|
2010-06-06 16:06:23 +02:00
|
|
|
~ProjectMVisualisation();
|
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
enum Mode {
|
|
|
|
Random = 0,
|
|
|
|
FromList = 1,
|
|
|
|
};
|
2010-06-07 03:55:21 +02:00
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
QString preset_url() const;
|
|
|
|
ProjectMPresetModel* preset_model() const { return preset_model_; }
|
2010-06-07 03:55:21 +02:00
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
Mode mode() const { return mode_; }
|
2013-12-02 11:15:08 +01:00
|
|
|
int duration() const { return duration_; }
|
2010-06-07 03:55:21 +02:00
|
|
|
|
2010-06-06 16:06:23 +02:00
|
|
|
// BufferConsumer
|
2014-02-07 16:34:20 +01:00
|
|
|
void ConsumeBuffer(GstBuffer* buffer, int);
|
2010-06-06 16:06:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2010-06-07 01:05:11 +02:00
|
|
|
void SetTextureSize(int size);
|
2010-06-07 15:36:50 +02:00
|
|
|
void SetDuration(int seconds);
|
2010-06-07 01:05:11 +02:00
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
void SetSelected(const QStringList& paths, bool selected);
|
|
|
|
void ClearSelected();
|
|
|
|
void SetImmediatePreset(const QString& path);
|
|
|
|
void SetMode(Mode mode);
|
|
|
|
|
|
|
|
void Lock(bool lock);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-06-06 20:18:06 +02:00
|
|
|
// QGraphicsScene
|
2014-02-07 16:34:20 +01:00
|
|
|
void drawBackground(QPainter* painter, const QRectF& rect);
|
2010-06-06 20:18:06 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-06-06 20:18:06 +02:00
|
|
|
void SceneRectChanged(const QRectF& rect);
|
2010-06-06 16:06:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-06-07 12:23:11 +02:00
|
|
|
void InitProjectM();
|
2010-06-07 03:55:21 +02:00
|
|
|
void Load();
|
|
|
|
void Save();
|
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
int IndexOfPreset(const QString& path) const;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<projectM> projectm_;
|
2010-06-07 15:29:57 +02:00
|
|
|
ProjectMPresetModel* preset_model_;
|
|
|
|
Mode mode_;
|
2010-06-07 15:36:50 +02:00
|
|
|
int duration_;
|
2010-06-07 15:29:57 +02:00
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<QTemporaryFile> temporary_font_;
|
2010-07-18 15:26:01 +02:00
|
|
|
|
2010-06-07 15:29:57 +02:00
|
|
|
std::vector<int> default_rating_list_;
|
2010-06-07 01:05:11 +02:00
|
|
|
|
|
|
|
int texture_size_;
|
2021-04-07 22:05:37 +02:00
|
|
|
// As of version 5.6, Qt supports automatic scaling for high-DPI displays. We
|
|
|
|
// need to know the pixel ratio so that we can convert coordinates for
|
|
|
|
// projectM.
|
|
|
|
// https://doc.qt.io/qt-5/highdpi.html
|
|
|
|
qreal pixel_ratio_;
|
|
|
|
VisualisationContainer* container_;
|
2010-06-06 16:06:23 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // PROJECTMVISUALISATION_H
|