00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #ifndef _ANIMATION_H
00027 #define _ANIMATION_H
00028
00029 #include <memory>
00030 #include <vector>
00031
00032 #include "bitmap.h"
00033
00047 class Animation {
00048 public:
00049 Animation(): _nextframe(NULL), _lastframe(NULL), _same_size(1),
00050 _firstw(0), _firsth(0) {}
00051 virtual ~Animation() { delete _lastframe; }
00052
00065 virtual const Bitmap *next(int skip = 0);
00066
00071 virtual const Bitmap *peek(int skip = 0);
00072
00074 virtual int w();
00076 virtual int h();
00077
00082 virtual int same_size(int set = -1);
00083
00084 protected:
00085 virtual Bitmap *getframe(int skip = 0) = 0;
00086 virtual int autofree() { return 1; }
00087
00088 const Bitmap *_nextframe;
00089 const Bitmap *_lastframe;
00090
00091 int _same_size, _firstw, _firsth;
00092 };
00093
00099 class LoopingFrames: public Animation {
00100 public:
00101 virtual ~LoopingFrames();
00102
00106 void insert_frame(const Bitmap &bitmap);
00107
00108 protected:
00109 virtual Bitmap *getframe(int skip = 0);
00110 virtual int autofree() { return 0; }
00111
00112 std::vector<Bitmap *> _frames;
00113 unsigned int _pos;
00114 };
00115
00120 class RollCount: public Animation {
00121 public:
00122 RollCount(): _ready(0) {}
00123
00124
00145 void param(int fps, int from, int digits, int groupspacing = 5,
00146 RGBA *background = NULL, int marginx = 0, int marginy = 0,
00147 int shift = 0, int digitsize = 0) {
00148 _fps = fps; _from = abs(from); _digits = digits;
00149 _groupspacing = groupspacing; _marginx = marginx; _marginy = marginy;
00150 _shift = shift; _digitsize = digitsize;
00151 if (background)
00152 _background.reset((RGBA *)background->clone());
00153
00154 _frameno = _from*_fps;
00155 _ready = 1;
00156 }
00157
00158 protected:
00159 virtual Bitmap *getframe(int skip = 0);
00160 void prepare();
00161
00162 int _fps, _from, _digits, _groupspacing, _marginx, _marginy, _shift;
00163 int _digitsize;
00164
00165 RGBA _figures[10], _empty;
00166 std::auto_ptr<RGBA> _background;
00167 int _ready, _frameno, _maxw, _maxh;
00168 };
00169
00170 #endif