]> git.localhorst.tv Git - l2e.git/blob - src/graphics/Frame.h
defa6b18ab303c175e66226e41969c1ff56a235d
[l2e.git] / src / graphics / Frame.h
1 /*
2  * Frame.h
3  *
4  *  Created on: Aug 7, 2012
5  *      Author: holy
6  */
7
8 #ifndef GRAPHICS_FRAME_H_
9 #define GRAPHICS_FRAME_H_
10
11 #include "../geometry/Vector.h"
12
13 #include <SDL.h>
14
15 namespace graphics {
16
17 class Frame {
18
19 public:
20         static const int TYPE_ID = 405;
21
22 public:
23         explicit Frame(SDL_Surface *s = 0, int borderWidth = 1, int borderHeight = 1, int repeatWidth = 1, int repeatHeight = 1, int xOffset = 0, int yOffset = 0)
24         : surface(s), borderSize(borderWidth, borderHeight), repeatSize(repeatWidth, repeatHeight), offset(xOffset, yOffset) { }
25
26 public:
27         int MinWidth() const { return 2 * BorderWidth(); }
28         int MinHeight() const { return 2 * BorderHeight(); }
29         int BorderWidth() const { return BorderSize().X(); }
30         int BorderHeight() const { return BorderSize().Y(); }
31         const geometry::Vector<int> BorderSize() const { return borderSize; }
32         int RepeatWidth() const { return RepeatSize().X(); }
33         int RepeatHeight() const { return RepeatSize().Y(); }
34         const geometry::Vector<int> RepeatSize() const { return repeatSize; }
35         void Draw(SDL_Surface *dest, const geometry::Vector<int> &position, int width, int height) const;
36
37 public:
38         void SetSurface(SDL_Surface *s) { surface = s; }
39         void SetBorderSize(const geometry::Vector<int> &s) { borderSize = s; }
40         void SetRepeatSize(const geometry::Vector<int> &s) { repeatSize = s; }
41         void SetOffset(const geometry::Vector<int> &o) { offset = o; }
42
43         static void CreateTypeDescription();
44         static void Construct(void *);
45
46 private:
47         SDL_Surface *surface;
48         geometry::Vector<int> borderSize;
49         geometry::Vector<int> repeatSize;
50         geometry::Vector<int> offset;
51
52 };
53
54 }
55
56 #endif /* GRAPHICS_FRAME_H_ */