kick
|
00001 // 00002 // Created by morten on 30/06/14. 00003 // 00004 00005 00006 #pragma once 00007 00008 #include "kick/2d/component2d.h" 00009 #include "kick/scene/game_object.h" 00010 #include "kick/2d/font.h" 00011 #include "kick/math/bounds2.h" 00012 #include "kick/core/event_listener.h" 00013 00014 00015 namespace kick { 00016 class Font; 00017 class Mesh; 00018 00019 class Label : public Component2D { 00020 public: 00021 Label(GameObject *gameObject, std::shared_ptr<Canvas> canvas); 00022 std::shared_ptr<Font> font() const; 00023 void setFont(std::shared_ptr<Font>& font); 00024 virtual void render(EngineUniforms *engineUniforms); 00025 std::string const &text() const; 00026 void setText(std::string const &text); 00027 virtual Bounds2 bounds() const override; 00028 virtual Shader*shader() const override; 00029 Material *material() const; 00030 void setMaterial(Material *material); 00031 00032 virtual int renderOrder(); 00033 00034 virtual void setBounds(Bounds2 bounds); 00035 00036 glm::vec2 anchor() const; 00037 void setAnchor(glm::vec2 anchor); 00038 private: 00039 void updateVertexBuffer(); 00040 00041 EventListener<Font*> mEventListener; 00042 Bounds2 mBounds; 00043 std::shared_ptr<Font> mFont = nullptr; 00044 Mesh *mMesh = nullptr; 00045 std::shared_ptr<MeshData> mMeshData; 00046 std::string mText; 00047 glm::vec2 mAnchor{0,0}; 00048 Material*mMaterial = nullptr; 00049 }; 00050 } 00051 00052