qt/AnimationBuilder/Animation.h

112 lines
2.0 KiB
C
Raw Permalink Normal View History

2013-01-19 20:12:40 +00:00
#ifndef ANIMATION_H
#define ANIMATION_H
#include <QObject>
2013-06-22 18:37:18 +00:00
#include <QtWidgets/QGraphicsScene>
2013-01-19 20:12:40 +00:00
#include <QPicture>
#include <QPainter>
2013-06-22 18:37:18 +00:00
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
2013-01-19 20:12:40 +00:00
#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);
2013-06-18 20:52:07 +00:00
void Clear();
2013-01-19 20:12:40 +00:00
public slots:
void LoadFrame();
};
#endif // ANIMATION_H