00001 #ifndef GUI_TEXTURE_HPP
00002 #define GUI_TEXTURE_HPP
00003
00004 #include <utils.hpp>
00005 #include "gui_layeredregion.hpp"
00006 #include "gui_gradient.hpp"
00007 #include "gui_sprite.hpp"
00008
00009 namespace gui
00010 {
00012
00015 class texture : public layered_region
00016 {
00017 public :
00018
00019 enum blend_mode
00020 {
00021 BLEND_NONE,
00022 BLEND_BLEND,
00023 BLEND_KEY,
00024 BLEND_ADD,
00025 BLEND_MOD
00026 };
00027
00029 explicit texture(manager* pManager);
00030
00032 virtual ~texture();
00033
00035
00038 virtual std::string serialize(const std::string& sTab) const;
00039
00041 virtual void render();
00042
00044
00046 virtual void copy_from(uiobject* pObj);
00047
00049
00051 blend_mode get_blend_mode() const;
00052
00054
00056 const color& get_color() const;
00057
00059
00061 const gradient& get_gradient() const;
00062
00064
00071 const std::array<float,8>& get_tex_coord() const;
00072
00074
00077 bool get_tex_coord_modifies_rect() const;
00078
00080
00082 const std::string& get_texture() const;
00083
00085
00090 color get_vertex_color() const;
00091
00093
00097 bool is_desaturated() const;
00098
00100
00102 void set_blend_mode(blend_mode mBlendMode);
00103
00105
00107 void set_blend_mode(const std::string& sBlendMode);
00108
00110
00112 void set_desaturated(bool bIsDesaturated);
00113
00115
00118 void set_gradient(const gradient& mGradient);
00119
00121
00129 void set_tex_coord(const std::array<float,4>& lCoordinates);
00130
00132
00140 void set_tex_coord(const std::array<float,8>& lCoordinates);
00141
00143
00145 void set_tex_coord_modifies_rect(bool bTexCoordModifiesRect);
00146
00148
00153 void set_texture(const std::string& sFile);
00154
00156
00162 void set_texture(utils::refptr<render_target> pRenderTarget);
00163
00165
00169 void set_color(const color& mColor);
00170
00172
00179 void set_sprite(utils::refptr<sprite> pSprite);
00180
00182
00187 void set_vertex_color(const color& mColor);
00188
00190 virtual void create_glue();
00191
00193
00195 virtual void parse_block(xml::block* pBlock);
00196
00198 static void register_glue(utils::wptr<lua::state> pLua);
00199
00200 private :
00201
00202 virtual void parse_attributes_(xml::block* pBlock);
00203 void parse_tex_coords_block_(xml::block* pBlock);
00204 void parse_color_block_(xml::block* pBlock);
00205 void parse_gradient_block_(xml::block* pBlock);
00206
00207 utils::refptr<sprite> pSprite_;
00208 std::string sTextureFile_;
00209
00210 blend_mode mBlendMode_;
00211 bool bIsDesaturated_;
00212 gradient mGradient_;
00213 color mColor_;
00214
00215 std::array<float,8> lTexCoord_;
00216 bool bTexCoordModifiesRect_;
00217 };
00218
00222 class lua_texture : public lua_layered_region
00223 {
00224 public :
00225
00226 explicit lua_texture(lua_State* pLua);
00227
00228
00229 int _set_vertex_color(lua_State*);
00230 int _get_blend_mode(lua_State*);
00231 int _get_tex_coord(lua_State*);
00232 int _get_tex_coord_modifies_rect(lua_State*);
00233 int _get_texture(lua_State*);
00234 int _get_vertex_color(lua_State*);
00235 int _is_desaturated(lua_State*);
00236 int _set_blend_mode(lua_State*);
00237 int _set_desaturated(lua_State*);
00238 int _set_gradient(lua_State*);
00239 int _set_gradientAlpha(lua_State*);
00240 int _set_tex_coord(lua_State*);
00241 int _set_tex_coord_modifies_rect(lua_State*);
00242 int _set_texture(lua_State*);
00243
00244 static const char className[];
00245 static const char* classList[];
00246 static Lunar<lua_texture>::RegType methods[];
00247
00248 protected :
00249
00250 texture* pTextureParent_;
00251 };
00252
00255 }
00256
00257 #endif