 |
CUGL 1.3
Cornell University Game Library
|
41 #ifndef __CU_LABEL_H__
42 #define __CU_LABEL_H__
45 #include <cugl/2d/CUNode.h>
46 #include <cugl/2d/CUFont.h>
230 #pragma mark Constructors
255 virtual void dispose()
override;
265 CUAssertLog(
false,
"This node does not support the empty initializer");
279 bool init(
const Size& size,
const std::shared_ptr<Font>& font);
298 bool initWithText(
const char* text,
const std::shared_ptr<Font>& font) {
319 bool initWithText(
const std::string& text,
const std::shared_ptr<Font>& font);
349 #pragma mark Static Constructors
360 static std::shared_ptr<Label>
alloc(
const Size& size,
const std::shared_ptr<Font>& font) {
361 std::shared_ptr<Label> result = std::make_shared<Label>();
362 return (result->init(size,font) ? result :
nullptr);
382 static std::shared_ptr<Label>
alloc(
const std::string& text,
const std::shared_ptr<Font>& font) {
383 std::shared_ptr<Label> result = std::make_shared<Label>();
384 return (result->initWithText(text,font) ? result :
nullptr);
407 static std::shared_ptr<Label>
alloc(
const char* text,
const std::shared_ptr<Font>& font) {
408 std::shared_ptr<Label> result = std::make_shared<Label>();
409 return (result->initWithText(text,font) ? result :
nullptr);
438 const std::shared_ptr<JsonValue>& data) {
439 std::shared_ptr<Label> result = std::make_shared<Label>();
440 if (!result->initWithData(loader,data)) { result =
nullptr; }
441 return std::dynamic_pointer_cast<Node>(result);
445 #pragma mark Text Attributes
478 virtual void setText(
const std::string& text,
bool resize=
false);
728 #pragma mark Other Attributes
787 void setFont(
const std::shared_ptr<Font>& font,
bool resize=
false);
790 #pragma mark Rendering
893 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
897 #pragma mark Internal Helpers
913 void generateRenderData();
918 void clearRenderData();
Rect _textbounds
Definition: CULabel.h:196
std::vector< Vertex2 > _vertices
Definition: CULabel.h:222
std::shared_ptr< Font > _font
Definition: CULabel.h:191
const Rect getTrueBounds() const
Definition: CULabel.h:677
void setBackground(Color4 color)
std::string _text
Definition: CULabel.h:194
static std::shared_ptr< Label > alloc(const Size &size, const std::shared_ptr< Font > &font)
Definition: CULabel.h:360
std::shared_ptr< Font > getFont() const
Definition: CULabel.h:776
void setBlendEquation(GLenum equation)
Definition: CULabel.h:854
const Vec2 & getPadding() const
Definition: CULabel.h:496
VAlign
Definition: CULabel.h:138
GLenum getDestinationBlendFactor() const
Definition: CULabel.h:837
bool _rendered
Definition: CULabel.h:220
GLenum getSourceBlendFactor() const
Definition: CULabel.h:823
void setPadding(const Vec2 &padding)
Definition: CULabel.h:544
virtual void dispose() override
std::shared_ptr< Texture > _texture
Definition: CULabel.h:226
float getPaddingY() const
Definition: CULabel.h:526
VAlign getVerticalAlignment() const
Definition: CULabel.h:629
Color4 getForeground() const
Definition: CULabel.h:737
Definition: CUColor4.h:1084
void setVerticalAlignment(VAlign valign)
void setPaddingY(float pady)
Definition: CULabel.h:597
static std::shared_ptr< Label > alloc(const char *text, const std::shared_ptr< Font > &font)
Definition: CULabel.h:407
GLenum _srcFactor
Definition: CULabel.h:215
float x
Definition: CUVec2.h:66
Color4 _foreground
Definition: CULabel.h:208
Color4 _background
Definition: CULabel.h:210
Rect _truebounds
Definition: CULabel.h:198
const Rect & getTextBounds() const
Definition: CULabel.h:658
Vec2 origin
Definition: CURect.h:49
GLenum _blendEquation
Definition: CULabel.h:213
static std::shared_ptr< Label > alloc(const std::string &text, const std::shared_ptr< Font > &font)
Definition: CULabel.h:382
Definition: CUSceneLoader.h:77
virtual void setContentSize(float width, float height) override
Definition: CULabel.h:723
float y
Definition: CUVec2.h:68
virtual void setText(const std::string &text, bool resize=false)
HAlign getHorizontalAlignment() const
Definition: CULabel.h:609
Vec2 _padding
Definition: CULabel.h:201
GLenum getBlendEquation() const
Definition: CULabel.h:868
float getBaseLine() const
VAlign _valign
Definition: CULabel.h:205
static std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data)
Definition: CULabel.h:437
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
bool initWithText(const char *text, const std::shared_ptr< Font > &font)
Definition: CULabel.h:298
HAlign _halign
Definition: CULabel.h:203
GLenum _dstFactor
Definition: CULabel.h:217
virtual bool init() override
Definition: CULabel.h:264
virtual void setContentSize(const Size &size) override
HAlign
Definition: CULabel.h:86
void setHorizontalAlignment(HAlign halign)
void setPaddingX(float padx)
Definition: CULabel.h:580
const std::string & getText() const
Definition: CULabel.h:457
Size size
Definition: CURect.h:51
Color4 getBackground() const
Definition: CULabel.h:758
void setBlendFunc(GLenum srcFactor, GLenum dstFactor)
Definition: CULabel.h:809
~Label()
Definition: CULabel.h:244
void setForeground(Color4 color)
Definition: CULabel.h:747
void setFont(const std::shared_ptr< Font > &font, bool resize=false)
std::vector< unsigned short > _indices
Definition: CULabel.h:224
float getPaddingX() const
Definition: CULabel.h:511
virtual bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data) override