2019-02-04 21:34:12 +01:00
|
|
|
/*
|
|
|
|
Strawberry Music Player
|
|
|
|
This file was part of Amarok.
|
|
|
|
Copyright 2003-2005, Max Howell <max.howell@methylblue.com>
|
|
|
|
Copyright 2005, Mark Kretschmann <markey@web.de>
|
|
|
|
Copyright 2009-2010, David Sansome <davidsansome@gmail.com>
|
|
|
|
Copyright 2010, 2014, John Maguire <john.maguire@gmail.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/>.
|
|
|
|
|
|
|
|
*/
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#ifndef BLOCKANALYZER_H
|
|
|
|
#define BLOCKANALYZER_H
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
2019-02-04 21:34:12 +01:00
|
|
|
#include <QVector>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QtEvents>
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "analyzerbase.h"
|
|
|
|
|
|
|
|
class QResizeEvent;
|
|
|
|
|
|
|
|
class BlockAnalyzer : public Analyzer::Base {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Q_INVOKABLE BlockAnalyzer(QWidget*);
|
|
|
|
~BlockAnalyzer();
|
|
|
|
|
2019-02-04 21:34:12 +01:00
|
|
|
static const uint kHeight;
|
|
|
|
static const uint kWidth;
|
|
|
|
static const uint kMinRows;
|
|
|
|
static const uint kMinColumns;
|
|
|
|
static const uint kMaxColumns;
|
|
|
|
static const uint kFadeSize;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
static const char *kName;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void transform(Analyzer::Scope&);
|
|
|
|
virtual void analyze(QPainter &p, const Analyzer::Scope&, bool new_frame);
|
|
|
|
virtual void resizeEvent(QResizeEvent*);
|
|
|
|
virtual void paletteChange(const QPalette&);
|
|
|
|
virtual void framerateChanged();
|
|
|
|
|
|
|
|
void drawBackground();
|
|
|
|
void determineStep();
|
|
|
|
|
|
|
|
private:
|
2018-09-30 15:32:21 +02:00
|
|
|
QPixmap *bar() { return &barpixmap_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-02-04 21:34:12 +01:00
|
|
|
uint columns_, rows_; // number of rows and columns of blocks
|
|
|
|
uint y_; // y-offset from top of widget
|
2018-09-30 15:32:21 +02:00
|
|
|
QPixmap barpixmap_;
|
|
|
|
QPixmap topbarpixmap_;
|
|
|
|
QPixmap background_;
|
2018-02-27 18:06:05 +01:00
|
|
|
QPixmap canvas_;
|
2019-02-04 21:34:12 +01:00
|
|
|
Analyzer::Scope scope_; // so we don't create a vector every frame
|
|
|
|
QVector<float> store_; // current bar heights
|
|
|
|
QVector<float> yscale_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-02-04 21:34:12 +01:00
|
|
|
QVector<QPixmap> fade_bars_;
|
|
|
|
QVector<uint> fade_pos_;
|
|
|
|
QVector<int> fade_intensity_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-09-30 15:32:21 +02:00
|
|
|
float step_; // rows to fall per frame
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2019-02-04 21:34:12 +01:00
|
|
|
#endif // BLOCKANALYZER_H
|