123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- #ifndef __UILABEL_H__
- #define __UILABEL_H__
- #include "ui/UIWidget.h"
- #include "ui/GUIExport.h"
- #include "base/ccTypes.h"
- NS_CC_BEGIN
- class Label;
- class Sprite;
- namespace ui {
- class CC_GUI_DLL Text : public Widget
- {
- DECLARE_CLASS_GUI_INFO
- public:
-
- enum class Type
- {
- SYSTEM,
- TTF
- };
-
- Text();
-
- virtual ~Text();
-
- static Text* create();
-
- static Text* create(const std::string& textContent,
- const std::string& fontName,
- float fontSize);
-
- CC_DEPRECATED_ATTRIBUTE void setText(const std::string& text)
- {
- this->setString(text);
- }
- void setString(const std::string& text);
-
- CC_DEPRECATED_ATTRIBUTE const std::string& getStringValue()
- {
- return this->getString();
- }
- const std::string& getString()const;
-
- ssize_t getStringLength()const;
-
- void setFontSize(float size);
-
- float getFontSize()const;
-
- void setFontName(const std::string& name);
-
- const std::string& getFontName()const;
-
- Type getType() const;
-
- void setTouchScaleChangeEnabled(bool enabled);
-
- bool isTouchScaleChangeEnabled()const;
-
- virtual Size getVirtualRendererSize() const override;
-
- virtual Node* getVirtualRenderer() override;
-
- virtual Size getAutoRenderSize();
-
- virtual std::string getDescription() const override;
-
- void setTextAreaSize(const Size &size);
-
- const Size& getTextAreaSize()const;
-
- void setTextHorizontalAlignment(TextHAlignment alignment);
-
- TextHAlignment getTextHorizontalAlignment()const;
-
- void setTextVerticalAlignment(TextVAlignment alignment);
-
- TextVAlignment getTextVerticalAlignment()const;
-
- void setTextColor(const Color4B color);
-
- const Color4B& getTextColor() const;
-
- void enableShadow(const Color4B& shadowColor = Color4B::BLACK,
- const Size &offset = Size(2,-2),
- int blurRadius = 0);
-
- void enableOutline(const Color4B& outlineColor,int outlineSize = 1);
-
- void enableGlow(const Color4B& glowColor);
-
- void disableEffect();
-
- void disableEffect(LabelEffect effect);
-
- bool isShadowEnabled() const;
-
- Size getShadowOffset() const;
-
- float getShadowBlurRadius() const;
-
- Color4B getShadowColor() const;
-
- int getOutlineSize() const;
-
- LabelEffect getLabelEffectType() const;
-
- Color4B getEffectColor() const;
-
-
- virtual Sprite * getLetter(int lettetIndex);
- CC_CONSTRUCTOR_ACCESS:
- virtual bool init() override;
- virtual bool init(const std::string& textContent,
- const std::string& fontName,
- float fontSize);
- protected:
- virtual void initRenderer() override;
- virtual void onPressStateChangedToNormal() override;
- virtual void onPressStateChangedToPressed() override;
- virtual void onPressStateChangedToDisabled() override;
- virtual void onSizeChanged() override;
- void labelScaleChangedWithSize();
- virtual Widget* createCloneInstance() override;
- virtual void copySpecialProperties(Widget* model) override;
- virtual void adaptRenderers() override;
- protected:
- bool _touchScaleChangeEnabled;
- float _normalScaleValueX;
- float _normalScaleValueY;
- std::string _fontName;
- float _fontSize;
- float _onSelectedScaleOffset;
- Label* _labelRenderer;
- bool _labelRendererAdaptDirty;
- Type _type;
- };
- }
- NS_CC_END
- #endif
|