44 #ifndef __CU_NINEPATCH_H__
45 #define __CU_NINEPATCH_H__
48 #include <cugl/math/CURect.h>
49 #include <cugl/2d/CUNode.h>
50 #include <cugl/renderer/CUTexture.h>
51 #include <cugl/renderer/CUVertex.h>
52 #include <cugl/renderer/CUSpriteBatch.h>
83 std::vector<unsigned short> _indices;
94 #pragma mark Constructors
120 virtual void dispose()
override;
226 #pragma mark Static Constructors
237 static std::shared_ptr<NinePatch>
alloc() {
238 std::shared_ptr<NinePatch> node = std::make_shared<NinePatch>();
239 return (node->init() ? node :
nullptr);
258 static std::shared_ptr<NinePatch>
allocWithFile(
const std::string& filename) {
259 std::shared_ptr<NinePatch> node = std::make_shared<NinePatch>();
260 return (node->initWithFile(filename) ? node :
nullptr);
278 static std::shared_ptr<NinePatch>
allocWithFile(
const std::string& filename,
const Rect& interior) {
279 std::shared_ptr<NinePatch> node = std::make_shared<NinePatch>();
280 return (node->initWithFile(filename,interior) ? node :
nullptr);
294 static std::shared_ptr<NinePatch>
allocWithTexture(
const std::shared_ptr<Texture>& texture) {
295 std::shared_ptr<NinePatch> node = std::make_shared<NinePatch>();
296 return (node->initWithTexture(texture) ? node :
nullptr);
315 static std::shared_ptr<NinePatch>
allocWithTexture(
const std::shared_ptr<Texture>& texture,
316 const Rect& interior) {
317 std::shared_ptr<NinePatch> node = std::make_shared<NinePatch>();
318 return (node->initWithTexture(texture,interior) ? node :
nullptr);
346 const std::shared_ptr<JsonValue> data) {
347 std::shared_ptr<NinePatch> result = std::make_shared<NinePatch>();
348 if (!result->initWithData(loader,data)) { result =
nullptr; }
349 return std::dynamic_pointer_cast<
Node>(result);
354 #pragma mark Attributes
393 void setTexture(
const std::shared_ptr<Texture>& texture);
457 void setBlendFunc(GLenum srcFactor, GLenum dstFactor) { _srcFactor = srcFactor; _dstFactor = dstFactor; }
520 #pragma mark Rendering
544 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
562 virtual std::string
toString(
bool verbose=
false)
const override;
565 #pragma mark Internal Helpers
const std::shared_ptr< Texture > & getTexture() const
Definition: CUNinePatch.h:407
void setInterior(const Rect &interior)
static std::shared_ptr< NinePatch > allocWithTexture(const std::shared_ptr< Texture > &texture)
Definition: CUNinePatch.h:294
const Rect & getInterior() const
Definition: CUNinePatch.h:437
GLenum _dstFactor
Definition: CUNinePatch.h:90
std::vector< Vertex2 > _vertices
Definition: CUNinePatch.h:82
GLenum getBlendEquation() const
Definition: CUNinePatch.h:516
virtual bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data) override
static const std::shared_ptr< Texture > & getBlankTexture()
void setBlendEquation(GLenum equation)
Definition: CUNinePatch.h:502
bool initWithTexture(const std::shared_ptr< Texture > &texture)
void refresh()
Definition: CUNinePatch.h:550
static std::shared_ptr< Texture > allocWithFile(const std::string &filename)
Definition: CUTexture.h:245
unsigned short generatePatch(const Rect &src, const Rect &dst, unsigned short offset)
Rect _interior
Definition: CUNinePatch.h:77
static std::shared_ptr< NinePatch > allocWithFile(const std::string &filename, const Rect &interior)
Definition: CUNinePatch.h:278
virtual void dispose() override
static std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data)
Definition: CUNinePatch.h:345
GLenum _srcFactor
Definition: CUNinePatch.h:88
std::shared_ptr< Texture > _texture
Definition: CUNinePatch.h:74
CU_DISALLOW_COPY_AND_ASSIGN(NinePatch)
virtual void generateRenderData()
virtual std::string toString(bool verbose=false) const override
Definition: CUSceneLoader.h:77
void setBlendFunc(GLenum srcFactor, GLenum dstFactor)
Definition: CUNinePatch.h:457
virtual bool init() override
Definition: CUNinePatch.h:132
GLenum _blendEquation
Definition: CUNinePatch.h:86
static std::shared_ptr< NinePatch > allocWithFile(const std::string &filename)
Definition: CUNinePatch.h:258
void setTexture(const std::string &filename)
Definition: CUNinePatch.h:379
~NinePatch()
Definition: CUNinePatch.h:109
GLenum getDestinationBlendFactor() const
Definition: CUNinePatch.h:485
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
virtual void setContentSize(const Size &size) override
Definition: CUColor4.h:1084
Definition: CUAction.h:51
std::shared_ptr< Texture > & getTexture()
Definition: CUNinePatch.h:400
GLenum getSourceBlendFactor() const
Definition: CUNinePatch.h:471
bool _rendered
Definition: CUNinePatch.h:80
static std::shared_ptr< NinePatch > allocWithTexture(const std::shared_ptr< Texture > &texture, const Rect &interior)
Definition: CUNinePatch.h:315
bool initWithFile(const std::string &filename)
static std::shared_ptr< NinePatch > alloc()
Definition: CUNinePatch.h:237
Definition: CUNinePatch.h:70