DecoratorTiled.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCOREDECORATORTILED_H
00029 #define ROCKETCOREDECORATORTILED_H
00030
00031 #include <Rocket/Core/Decorator.h>
00032 #include <Rocket/Core/Vertex.h>
00033
00034 namespace Rocket {
00035 namespace Core {
00036
00037 struct Texture;
00038
00045 class DecoratorTiled : public Decorator
00046 {
00047 public:
00048 DecoratorTiled();
00049 virtual ~DecoratorTiled();
00050
00055 enum TileRepeatMode
00056 {
00057 STRETCH = 0,
00058 CLAMP_STRETCH = 1,
00059 CLAMP_TRUNCATE = 2,
00060 REPEAT_STRETCH = 3,
00061 REPEAT_TRUNCATE = 4,
00062 };
00063
00067 enum TileOrientation
00068 {
00069 ROTATE_0_CW = 0,
00070 ROTATE_90_CW = 1,
00071 ROTATE_180_CW = 2,
00072 ROTATE_270_CW = 3,
00073 FLIP_HORIZONTAL = 4,
00074 FLIP_VERTICAL = 5
00075 };
00076
00083 struct Tile
00084 {
00086 Tile();
00087
00089 void CalculateDimensions(Element* element, const Texture& texture);
00091 Vector2f GetDimensions(Element* element);
00092
00100 void GenerateGeometry(std::vector< Vertex >& vertices, std::vector< int >& indices, Element* element, const Vector2f& surface_origin, const Vector2f& surface_dimensions, const Vector2f& tile_dimensions) const;
00101
00102 struct TileData
00103 {
00104 Vector2f dimensions;
00105 Vector2f texcoords[2];
00106 };
00107
00108 typedef std::map< RenderInterface*, TileData > TileDataMap;
00109
00110 int texture_index;
00111 Vector2f texcoords[2];
00112 bool texcoords_absolute[2][2];
00113
00114 mutable TileDataMap data;
00115
00116 TileRepeatMode repeat_mode;
00117 TileOrientation orientation;
00118 };
00119
00120 protected:
00125 void ScaleTileDimensions(Vector2f& tile_dimensions, float axis_value, int axis);
00126 };
00127
00128 }
00129 }
00130
00131 #endif