mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
10850c0ec7
refactored the rendering process
64 lines
1.5 KiB
C++
64 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <QPixmap>
|
|
#include <QString>
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
namespace chatterino {
|
|
namespace messages {
|
|
|
|
class Image : public QObject, boost::noncopyable
|
|
{
|
|
public:
|
|
Image() = delete;
|
|
|
|
explicit Image(const QString &_url, qreal _scale = 1, const QString &_name = "",
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
|
bool isHat = false);
|
|
|
|
explicit Image(QPixmap *_currentPixmap, qreal _scale = 1, const QString &_name = "",
|
|
const QString &_tooltip = "", const QMargins &_margin = QMargins(),
|
|
bool isHat = false);
|
|
|
|
const QPixmap *getPixmap();
|
|
qreal getScale() const;
|
|
const QString &getUrl() const;
|
|
const QString &getName() const;
|
|
const QString &getTooltip() const;
|
|
const QMargins &getMargin() const;
|
|
bool isAnimated() const;
|
|
bool isHat() const;
|
|
int getWidth() const;
|
|
int getScaledWidth() const;
|
|
int getHeight() const;
|
|
int getScaledHeight() const;
|
|
|
|
private:
|
|
struct FrameData {
|
|
QPixmap *image;
|
|
int duration;
|
|
};
|
|
|
|
QPixmap *currentPixmap;
|
|
std::vector<FrameData> allFrames;
|
|
int currentFrame = 0;
|
|
int currentFrameOffset = 0;
|
|
|
|
QString url;
|
|
QString name;
|
|
QString tooltip;
|
|
bool animated = false;
|
|
QMargins margin;
|
|
bool ishat;
|
|
qreal scale;
|
|
|
|
bool isLoading;
|
|
|
|
void loadImage();
|
|
void gifUpdateTimout();
|
|
};
|
|
|
|
} // namespace messages
|
|
} // namespace chatterino
|