qt/AnimationBuilder/Animation.h
2013-06-22 18:37:18 +00:00

112 lines
2.0 KiB
C++

#ifndef ANIMATION_H
#define ANIMATION_H
#include <QObject>
#include <QtWidgets/QGraphicsScene>
#include <QPicture>
#include <QPainter>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
#include "boost/shared_ptr.hpp"
struct TFrame
{
boost::shared_ptr<QPixmap> Pixmap;
size_t TimeToPlay;
std::string FrameName;
int ShiftX;
int ShiftY;
TFrame(boost::shared_ptr<QPixmap> pixmap, size_t timeToPlay, const std::string& frameName)
: Pixmap(pixmap)
, TimeToPlay(timeToPlay)
, FrameName(frameName)
, ShiftX(0)
, ShiftY(0)
{
}
TFrame(const TFrame& frame)
{
Pixmap = frame.Pixmap;
TimeToPlay = frame.TimeToPlay;
FrameName = frame.FrameName;
ShiftX = frame.ShiftX;
ShiftY = frame.ShiftY;
}
TFrame& operator=(const TFrame& frame)
{
if (&frame == this)
{
return *this;
}
Pixmap = frame.Pixmap;
TimeToPlay = frame.TimeToPlay;
FrameName = frame.FrameName;
ShiftX = frame.ShiftX;
ShiftY = frame.ShiftY;
return *this;
}
};
struct TFrameData
{
float TexCoordFromX;
float TexCoordFromY;
float TexCoordToX;
float TexCoordToY;
size_t TimeToPlay;
};
class MainWindow;
class TAnimation : public QObject
{
Q_OBJECT
protected:
std::vector<TFrame> FrameList;
MainWindow* Window;
public:
explicit TAnimation(QObject *parent = 0);
void SetMainWindow(MainWindow* window);
void AddFrame(const TFrame& frame);
TFrame& GetFrame(int i);
size_t GetFrameCount();
int GetMaxWidth();
int GetMaxHeight();
void FillSheet(boost::shared_ptr<QPixmap> sheetPixmap, std::vector<TFrameData>& frameDataArr);
void Clear();
public slots:
void LoadFrame();
};
#endif // ANIMATION_H