mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5806 from Dhilan007/develop_reImplementationWithLabel
issue #3821: Uses new label instead of LabelTTF in engine.
This commit is contained in:
commit
8d28884c9f
|
@ -55,7 +55,7 @@ TextFieldTTF::TextFieldTTF()
|
|||
: _delegate(0)
|
||||
, _charCount(0)
|
||||
, _inputText("")
|
||||
, _placeHolder("") // prevent LabelTTF initWithString assertion
|
||||
, _placeHolder("") // prevent Label initWithString assertion
|
||||
, _secureTextEntry(false)
|
||||
{
|
||||
_colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127;
|
||||
|
@ -88,7 +88,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeho
|
|||
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
|
||||
{
|
||||
TextFieldTTF *ret = new TextFieldTTF();
|
||||
if(ret && ret->initWithString("", fontName, fontSize))
|
||||
if(ret && ret->initWithPlaceHolder("", fontName, fontSize))
|
||||
{
|
||||
ret->autorelease();
|
||||
if (placeholder.size()>0)
|
||||
|
@ -108,12 +108,22 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeho
|
|||
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
|
||||
{
|
||||
_placeHolder = placeholder;
|
||||
return LabelTTF::initWithString(_placeHolder, fontName, fontSize, dimensions, alignment);
|
||||
setDimensions(dimensions.width,dimensions.height);
|
||||
setFontName(fontName);
|
||||
setFontSize(fontSize);
|
||||
setAlignment(alignment,TextVAlignment::CENTER);
|
||||
Label::setString(_placeHolder);
|
||||
|
||||
return true;
|
||||
}
|
||||
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
|
||||
{
|
||||
_placeHolder = std::string(placeholder);
|
||||
return LabelTTF::initWithString(_placeHolder, fontName, fontSize);
|
||||
setFontName(fontName);
|
||||
setFontSize(fontSize);
|
||||
Label::setString(_placeHolder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -228,7 +238,7 @@ void TextFieldTTF::deleteBackward()
|
|||
{
|
||||
_inputText = "";
|
||||
_charCount = 0;
|
||||
LabelTTF::setString(_placeHolder);
|
||||
Label::setString(_placeHolder);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -242,23 +252,19 @@ const std::string& TextFieldTTF::getContentText()
|
|||
return _inputText;
|
||||
}
|
||||
|
||||
void TextFieldTTF::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
void TextFieldTTF::setColor(const Color3B& color)
|
||||
{
|
||||
if (_delegate && _delegate->onDraw(this))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_inputText.length())
|
||||
{
|
||||
LabelTTF::draw(renderer, transform, transformUpdated);
|
||||
return;
|
||||
}
|
||||
_colorText = color;
|
||||
Label::setColor(color);
|
||||
}
|
||||
|
||||
// draw placeholder
|
||||
Color3B color = getColor();
|
||||
setColor(_colorSpaceHolder);
|
||||
LabelTTF::draw(renderer, transform, transformUpdated);
|
||||
setColor(color);
|
||||
void TextFieldTTF::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Label::visit(renderer,parentTransform,parentTransformUpdated);
|
||||
}
|
||||
|
||||
const Color3B& TextFieldTTF::getColorSpaceHolder()
|
||||
|
@ -305,11 +311,13 @@ void TextFieldTTF::setString(const std::string &text)
|
|||
// if there is no input text, display placeholder instead
|
||||
if (! _inputText.length())
|
||||
{
|
||||
LabelTTF::setString(_placeHolder);
|
||||
Label::setColor(_colorSpaceHolder);
|
||||
Label::setString(_placeHolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelTTF::setString(displayText);
|
||||
Label::setColor(_colorText);
|
||||
Label::setString(displayText);
|
||||
}
|
||||
_charCount = _calcCharCount(_inputText.c_str());
|
||||
}
|
||||
|
@ -325,7 +333,7 @@ void TextFieldTTF::setPlaceHolder(const std::string& text)
|
|||
_placeHolder = text;
|
||||
if (! _inputText.length())
|
||||
{
|
||||
LabelTTF::setString(_placeHolder);
|
||||
Label::setString(_placeHolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
#ifndef __CC_TEXT_FIELD_H__
|
||||
#define __CC_TEXT_FIELD_H__
|
||||
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCIMEDelegate.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
/**
|
||||
@brief If the sender doesn't want to draw, return true.
|
||||
*/
|
||||
virtual bool onDraw(TextFieldTTF * sender)
|
||||
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_UNUSED_PARAM(sender);
|
||||
return false;
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
/**
|
||||
@brief A simple text input field with TTF font.
|
||||
*/
|
||||
class CC_DLL TextFieldTTF : public LabelTTF, public IMEDelegate
|
||||
class CC_DLL TextFieldTTF : public Label, public IMEDelegate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
/** creates a TextFieldTTF from a fontname, alignment, dimension and font size */
|
||||
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
|
||||
/** creates a LabelTTF from a fontname and font size */
|
||||
/** creates a TextFieldTTF from a fontname and font size */
|
||||
static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize);
|
||||
/** initializes the TextFieldTTF with a font name, alignment, dimension and font size */
|
||||
bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize);
|
||||
|
@ -148,33 +148,23 @@ public:
|
|||
virtual const Color3B& getColorSpaceHolder();
|
||||
virtual void setColorSpaceHolder(const Color3B& color);
|
||||
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
|
||||
// input text property
|
||||
public:
|
||||
virtual void setString(const std::string& text) override;
|
||||
virtual const std::string& getString() const override;
|
||||
protected:
|
||||
TextFieldDelegate * _delegate;
|
||||
int _charCount;
|
||||
|
||||
std::string _inputText;
|
||||
|
||||
// place holder text property
|
||||
// place holder text displayed when there is no text in the text field.
|
||||
public:
|
||||
virtual void setPlaceHolder(const std::string& text);
|
||||
virtual const std::string& getPlaceHolder(void) const;
|
||||
protected:
|
||||
std::string _placeHolder;
|
||||
Color3B _colorSpaceHolder;
|
||||
public:
|
||||
|
||||
virtual void setSecureTextEntry(bool value);
|
||||
virtual bool isSecureTextEntry();
|
||||
protected:
|
||||
bool _secureTextEntry;
|
||||
protected:
|
||||
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// IMEDelegate interface
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -184,6 +174,18 @@ protected:
|
|||
virtual void insertText(const char * text, size_t len) override;
|
||||
virtual void deleteBackward() override;
|
||||
virtual const std::string& getContentText() override;
|
||||
|
||||
TextFieldDelegate * _delegate;
|
||||
int _charCount;
|
||||
|
||||
std::string _inputText;
|
||||
|
||||
std::string _placeHolder;
|
||||
Color3B _colorSpaceHolder;
|
||||
Color3B _colorText;
|
||||
|
||||
bool _secureTextEntry;
|
||||
|
||||
private:
|
||||
class LengthStack;
|
||||
LengthStack * _lens;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace cocosbuilder {
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||
((LabelTTF *)pNode)->setColor(pColor3B);
|
||||
((Label *)pNode)->setColor(pColor3B);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
|
||||
((LabelTTF *)pNode)->setOpacity(pByte);
|
||||
((Label *)pNode)->setOpacity(pByte);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const ch
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||
((LabelTTF *)pNode)->setBlendFunc(pBlendFunc);
|
||||
((Label *)pNode)->setBlendFunc(pBlendFunc);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, con
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) {
|
||||
((LabelTTF *)pNode)->setFontName(pFontTTF);
|
||||
((Label *)pNode)->setFontName(pFontTTF);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ void LabelTTFLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_STRING) == 0) {
|
||||
((LabelTTF *)pNode)->setString(pText);
|
||||
((Label *)pNode)->setString(pText);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, ccbReader);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void LabelTTFLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const ch
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) {
|
||||
((LabelTTF *)pNode)->setFontSize(pFloatScale);
|
||||
((Label *)pNode)->setFontSize(pFloatScale);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader);
|
||||
}
|
||||
|
@ -64,19 +64,19 @@ void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, co
|
|||
|
||||
void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
|
||||
((LabelTTF *)pNode)->setHorizontalAlignment(TextHAlignment(pIntegerLabeled));
|
||||
((Label *)pNode)->setHorizontalAlignment(TextHAlignment(pIntegerLabeled));
|
||||
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
|
||||
((LabelTTF *)pNode)->setVerticalAlignment(TextVAlignment(pIntegerLabeled));
|
||||
((Label *)pNode)->setVerticalAlignment(TextVAlignment(pIntegerLabeled));
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) {
|
||||
void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size size, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) {
|
||||
((LabelTTF *)pNode)->setDimensions(pSize);
|
||||
((Label *)pNode)->setDimensions(size.width,size.height);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader);
|
||||
NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, size, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define _CCB_CCLABELTTFLOADER_H_
|
||||
|
||||
#include "CCRef.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLabel.h"
|
||||
|
||||
#include "CCNodeLoader.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTTFLoader, loader);
|
||||
|
||||
protected:
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::LabelTTF);
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Label);
|
||||
|
||||
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader);
|
||||
|
|
|
@ -99,7 +99,8 @@ void Button::initRenderer()
|
|||
_buttonNormalRenderer = Sprite::create();
|
||||
_buttonClickedRenderer = Sprite::create();
|
||||
_buttonDisableRenderer = Sprite::create();
|
||||
_titleRenderer = LabelTTF::create();
|
||||
_titleRenderer = Label::create();
|
||||
_titleRenderer->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
|
||||
Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
|
||||
Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
|
||||
|
@ -433,10 +434,10 @@ void Button::onPressStateChangedToDisabled()
|
|||
|
||||
void Button::updateFlippedX()
|
||||
{
|
||||
_titleRenderer->setFlippedX(_flippedX);
|
||||
float flip = _flippedX ? -1.0f : 1.0f;
|
||||
_titleRenderer->setScaleX(flip);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
float flip = _flippedX ? -1.0f : 1.0f;
|
||||
_buttonNormalRenderer->setScaleX(flip);
|
||||
_buttonClickedRenderer->setScaleX(flip);
|
||||
_buttonDisableRenderer->setScaleX(flip);
|
||||
|
@ -451,10 +452,10 @@ void Button::updateFlippedX()
|
|||
|
||||
void Button::updateFlippedY()
|
||||
{
|
||||
_titleRenderer->setFlippedY(_flippedY);
|
||||
float flip = _flippedY ? -1.0f : 1.0f;
|
||||
_titleRenderer->setScaleY(flip);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
float flip = _flippedY ? -1.0f : 1.0f;
|
||||
_buttonNormalRenderer->setScaleY(flip);
|
||||
_buttonClickedRenderer->setScaleY(flip);
|
||||
_buttonDisableRenderer->setScaleY(flip);
|
||||
|
|
|
@ -195,7 +195,7 @@ protected:
|
|||
Node* _buttonNormalRenderer;
|
||||
Node* _buttonClickedRenderer;
|
||||
Node* _buttonDisableRenderer;
|
||||
LabelTTF* _titleRenderer;
|
||||
Label* _titleRenderer;
|
||||
std::string _normalFileName;
|
||||
std::string _clickedFileName;
|
||||
std::string _disabledFileName;
|
||||
|
|
|
@ -193,7 +193,7 @@ void RichText::formatText()
|
|||
case RICH_TEXT:
|
||||
{
|
||||
RichElementText* elmtText = static_cast<RichElementText*>(element);
|
||||
elementRenderer = LabelTTF::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize);
|
||||
elementRenderer = Label::create(elmtText->_text.c_str(), elmtText->_fontName.c_str(), elmtText->_fontSize);
|
||||
break;
|
||||
}
|
||||
case RICH_IMAGE:
|
||||
|
@ -255,7 +255,7 @@ void RichText::formatText()
|
|||
|
||||
void RichText::handleTextRenderer(const char *text, const char *fontName, float fontSize, const Color3B &color, GLubyte opacity)
|
||||
{
|
||||
LabelTTF* textRenderer = LabelTTF::create(text, fontName, fontSize);
|
||||
Label* textRenderer = Label::create(text, fontName, fontSize);
|
||||
float textRendererWidth = textRenderer->getContentSize().width;
|
||||
_leftSpaceWidth -= textRendererWidth;
|
||||
if (_leftSpaceWidth < 0.0f)
|
||||
|
@ -268,7 +268,7 @@ void RichText::handleTextRenderer(const char *text, const char *fontName, float
|
|||
std::string cutWords = curText.substr(leftLength, curText.length()-1);
|
||||
if (leftLength > 0)
|
||||
{
|
||||
LabelTTF* leftRenderer = LabelTTF::create(leftWords.substr(0, leftLength).c_str(), fontName, fontSize);
|
||||
Label* leftRenderer = Label::create(leftWords.substr(0, leftLength).c_str(), fontName, fontSize);
|
||||
leftRenderer->setColor(color);
|
||||
leftRenderer->setOpacity(opacity);
|
||||
pushToContainer(leftRenderer);
|
||||
|
|
|
@ -71,7 +71,7 @@ bool Text::init()
|
|||
|
||||
void Text::initRenderer()
|
||||
{
|
||||
_labelRenderer = LabelTTF::create();
|
||||
_labelRenderer = Label::create();
|
||||
Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1);
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ const std::string& Text::getFontName()
|
|||
|
||||
void Text::setTextAreaSize(const Size &size)
|
||||
{
|
||||
_labelRenderer->setDimensions(size);
|
||||
_labelRenderer->setDimensions(size.width,size.height);
|
||||
labelScaleChangedWithSize();
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,8 @@ void Text::onPressStateChangedToNormal()
|
|||
{
|
||||
return;
|
||||
}
|
||||
_labelRenderer->setScale(_normalScaleValueX, _normalScaleValueY);
|
||||
_labelRenderer->setScaleX(_normalScaleValueX);
|
||||
_labelRenderer->setScaleY(_normalScaleValueY);
|
||||
}
|
||||
|
||||
void Text::onPressStateChangedToPressed()
|
||||
|
@ -173,7 +174,8 @@ void Text::onPressStateChangedToPressed()
|
|||
{
|
||||
return;
|
||||
}
|
||||
_labelRenderer->setScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset);
|
||||
_labelRenderer->setScaleX(_normalScaleValueX + _onSelectedScaleOffset);
|
||||
_labelRenderer->setScaleY(_normalScaleValueY + _onSelectedScaleOffset);
|
||||
}
|
||||
|
||||
void Text::onPressStateChangedToDisabled()
|
||||
|
@ -183,13 +185,26 @@ void Text::onPressStateChangedToDisabled()
|
|||
|
||||
void Text::updateFlippedX()
|
||||
{
|
||||
_labelRenderer->setFlippedX(_flippedX);
|
||||
|
||||
if (_flippedX)
|
||||
{
|
||||
_labelRenderer->setScaleX(-1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_labelRenderer->setScaleX(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Text::updateFlippedY()
|
||||
{
|
||||
_labelRenderer->setFlippedY(_flippedY);
|
||||
if (_flippedY)
|
||||
{
|
||||
_labelRenderer->setScaleY(-1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_labelRenderer->setScaleY(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Text::setAnchorPoint(const Point &pt)
|
||||
|
@ -218,14 +233,14 @@ void Text::labelScaleChangedWithSize()
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_labelRenderer->setDimensions(Size::ZERO);
|
||||
_labelRenderer->setDimensions(0,0);
|
||||
_labelRenderer->setScale(1.0f);
|
||||
_size = _labelRenderer->getContentSize();
|
||||
_normalScaleValueX = _normalScaleValueY = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_labelRenderer->setDimensions(_size);
|
||||
_labelRenderer->setDimensions(_size.width,_size.height);
|
||||
Size textureSize = _labelRenderer->getContentSize();
|
||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
|||
std::string _fontName;
|
||||
int _fontSize;
|
||||
float _onSelectedScaleOffset;
|
||||
LabelTTF* _labelRenderer;
|
||||
Label* _labelRenderer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ UICCTextField * UICCTextField::create(const char *placeholder, const char *fontN
|
|||
{
|
||||
UICCTextField *pRet = new UICCTextField();
|
||||
|
||||
if(pRet && pRet->initWithString("", fontName, fontSize))
|
||||
if(pRet && pRet->initWithPlaceHolder("", fontName, fontSize))
|
||||
{
|
||||
pRet->autorelease();
|
||||
if (placeholder)
|
||||
|
@ -296,7 +296,7 @@ void UICCTextField::setPasswordText(const char *text)
|
|||
{
|
||||
tempStr.append(_passwordStyleText);
|
||||
}
|
||||
LabelTTF::setString(tempStr.c_str());
|
||||
Label::setString(tempStr.c_str());
|
||||
}
|
||||
|
||||
void UICCTextField::setAttachWithIME(bool attach)
|
||||
|
@ -672,13 +672,13 @@ void TextField::textfieldRendererScaleChangedWithSize()
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_textFieldRenderer->setDimensions(Size::ZERO);
|
||||
_textFieldRenderer->setDimensions(0,0);
|
||||
_textFieldRenderer->setScale(1.0f);
|
||||
_size = getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
_textFieldRenderer->setDimensions(_size);
|
||||
_textFieldRenderer->setDimensions(_size.width,_size.height);
|
||||
Size textureSize = getContentSize();
|
||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
||||
{
|
||||
|
@ -754,7 +754,7 @@ void TextField::copySpecialProperties(Widget *widget)
|
|||
|
||||
void TextField::setTextAreaSize(const Size &size)
|
||||
{
|
||||
_textFieldRenderer->setDimensions(size);
|
||||
_textFieldRenderer->setDimensions(size.width,size.height);
|
||||
}
|
||||
|
||||
void TextField::setTextHorizontalAlignment(TextHAlignment alignment)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "CCControlButton.h"
|
||||
#include "CCScale9Sprite.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCLabelBMFont.h"
|
||||
#include "CCAction.h"
|
||||
#include "CCActionInterval.h"
|
||||
|
@ -65,7 +65,7 @@ ControlButton::~ControlButton()
|
|||
|
||||
bool ControlButton::init()
|
||||
{
|
||||
return this->initWithLabelAndBackgroundSprite(LabelTTF::create("", "Helvetica", 12), Scale9Sprite::create());
|
||||
return this->initWithLabelAndBackgroundSprite(Label::create("", "Helvetica", 12), Scale9Sprite::create());
|
||||
}
|
||||
|
||||
bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* backgroundSprite)
|
||||
|
@ -132,7 +132,7 @@ ControlButton* ControlButton::create(Node* label, Scale9Sprite* backgroundSprite
|
|||
|
||||
bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize)
|
||||
{
|
||||
LabelTTF *label = LabelTTF::create(title, fontName, fontSize);
|
||||
Label *label = Label::create(title, fontName, fontSize);
|
||||
return initWithLabelAndBackgroundSprite(label, Scale9Sprite::create());
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ ControlButton* ControlButton::create(const std::string& title, const std::string
|
|||
|
||||
bool ControlButton::initWithBackgroundSprite(Scale9Sprite* sprite)
|
||||
{
|
||||
LabelTTF *label = LabelTTF::create("", "Arial", 30);//
|
||||
Label *label = Label::create("", "Arial", 30);//
|
||||
return initWithLabelAndBackgroundSprite(label, sprite);
|
||||
}
|
||||
|
||||
|
@ -363,13 +363,13 @@ void ControlButton::setTitleLabelForState(Node* titleLabel, State state)
|
|||
void ControlButton::setTitleTTFForState(const std::string& fntFile, State state)
|
||||
{
|
||||
std::string title = this->getTitleForState(state);
|
||||
this->setTitleLabelForState(LabelTTF::create(title, fntFile, 12), state);
|
||||
this->setTitleLabelForState(Label::create(title, fntFile, 12), state);
|
||||
}
|
||||
|
||||
const std::string& ControlButton::getTitleTTFForState(State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
||||
Label* labelTTF = dynamic_cast<Label*>(label);
|
||||
if(labelTTF != 0)
|
||||
{
|
||||
return labelTTF->getFontName();
|
||||
|
@ -384,7 +384,7 @@ void ControlButton::setTitleTTFSizeForState(float size, State state)
|
|||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
if(label)
|
||||
{
|
||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
||||
Label* labelTTF = dynamic_cast<Label*>(label);
|
||||
if(labelTTF != 0)
|
||||
{
|
||||
return labelTTF->setFontSize(size);
|
||||
|
@ -395,7 +395,7 @@ void ControlButton::setTitleTTFSizeForState(float size, State state)
|
|||
float ControlButton::getTitleTTFSizeForState(State state)
|
||||
{
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
|
||||
LabelTTF* labelTTF = dynamic_cast<LabelTTF*>(label);
|
||||
Label* labelTTF = dynamic_cast<Label*>(label);
|
||||
if(labelTTF != 0)
|
||||
{
|
||||
return labelTTF->getFontSize();
|
||||
|
|
|
@ -89,8 +89,9 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
|
|||
_minusSprite->setPosition( Point(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2) );
|
||||
this->addChild(_minusSprite);
|
||||
|
||||
this->setMinusLabel( LabelTTF::create("-", ControlStepperLabelFont, 40));
|
||||
this->setMinusLabel( Label::create("-", ControlStepperLabelFont, 40));
|
||||
_minusLabel->setColor(ControlStepperLabelColorDisabled);
|
||||
_minusLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
_minusLabel->setPosition(Point(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2) );
|
||||
_minusSprite->addChild(_minusLabel);
|
||||
|
||||
|
@ -100,8 +101,9 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
|
|||
minusSprite->getContentSize().height / 2) );
|
||||
this->addChild(_plusSprite);
|
||||
|
||||
this->setPlusLabel( LabelTTF::create("+", ControlStepperLabelFont, 40 ));
|
||||
this->setPlusLabel( Label::create("+", ControlStepperLabelFont, 40 ));
|
||||
_plusLabel->setColor( ControlStepperLabelColorEnabled );
|
||||
_plusLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
_plusLabel->setPosition( Point(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2) );
|
||||
_plusSprite->addChild(_plusLabel);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define __CCCONTROLSTEPPER_H__
|
||||
|
||||
#include "CCControl.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLabel.h"
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
@ -111,8 +111,8 @@ protected:
|
|||
// Weak links to children
|
||||
CC_SYNTHESIZE_RETAIN(Sprite*, _minusSprite, MinusSprite)
|
||||
CC_SYNTHESIZE_RETAIN(Sprite*, _plusSprite, PlusSprite)
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _minusLabel, MinusLabel)
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _plusLabel, PlusLabel)
|
||||
CC_SYNTHESIZE_RETAIN(Label*, _minusLabel, MinusLabel)
|
||||
CC_SYNTHESIZE_RETAIN(Label*, _plusLabel, PlusLabel)
|
||||
};
|
||||
|
||||
// end of GUI group
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "CCControlSwitch.h"
|
||||
#include "CCSprite.h"
|
||||
#include "CCActionTween.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCClippingNode.h"
|
||||
#include "ccShaders.h"
|
||||
#include "CCRenderTexture.h"
|
||||
|
@ -45,8 +45,8 @@ public:
|
|||
Sprite *onSprite,
|
||||
Sprite *offSprite,
|
||||
Sprite *thumbSprite,
|
||||
LabelTTF* onLabel,
|
||||
LabelTTF* offLabel);
|
||||
Label* onLabel,
|
||||
Label* offLabel);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
@ -91,8 +91,8 @@ public:
|
|||
CC_SYNTHESIZE_RETAIN(Sprite*, _onSprite, OnSprite)
|
||||
CC_SYNTHESIZE_RETAIN(Sprite*, _offSprite, OffSprite)
|
||||
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite)
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _onLabel, OnLabel)
|
||||
CC_SYNTHESIZE_RETAIN(LabelTTF*, _offLabel, OffLabel)
|
||||
CC_SYNTHESIZE_RETAIN(Label*, _onLabel, OnLabel)
|
||||
CC_SYNTHESIZE_RETAIN(Label*, _offLabel, OffLabel)
|
||||
|
||||
Sprite* _clipperStencil;
|
||||
|
||||
|
@ -116,8 +116,8 @@ protected:
|
|||
Sprite *onSprite,
|
||||
Sprite *offSprite,
|
||||
Sprite *thumbSprite,
|
||||
LabelTTF* onLabel,
|
||||
LabelTTF* offLabel);
|
||||
Label* onLabel,
|
||||
Label* offLabel);
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(ControlSwitchSprite);
|
||||
};
|
||||
|
@ -126,8 +126,8 @@ ControlSwitchSprite* ControlSwitchSprite::create(Sprite *maskSprite,
|
|||
Sprite *onSprite,
|
||||
Sprite *offSprite,
|
||||
Sprite *thumbSprite,
|
||||
LabelTTF* onLabel,
|
||||
LabelTTF* offLabel)
|
||||
Label* onLabel,
|
||||
Label* offLabel)
|
||||
{
|
||||
auto ret = new ControlSwitchSprite();
|
||||
ret->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
|
||||
|
@ -168,8 +168,8 @@ bool ControlSwitchSprite::initWithMaskSprite(
|
|||
Sprite *onSprite,
|
||||
Sprite *offSprite,
|
||||
Sprite *thumbSprite,
|
||||
LabelTTF* onLabel,
|
||||
LabelTTF* offLabel)
|
||||
Label* onLabel,
|
||||
Label* offLabel)
|
||||
{
|
||||
if (Sprite::initWithTexture(maskSprite->getTexture()))
|
||||
{
|
||||
|
@ -254,11 +254,13 @@ void ControlSwitchSprite::needsLayout()
|
|||
|
||||
if (_onLabel)
|
||||
{
|
||||
_onLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
_onLabel->setPosition(Point(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6,
|
||||
_onSprite->getContentSize().height / 2));
|
||||
}
|
||||
if (_offLabel)
|
||||
{
|
||||
_offLabel->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
_offLabel->setPosition(Point(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6,
|
||||
_offSprite->getContentSize().height / 2));
|
||||
}
|
||||
|
@ -330,7 +332,7 @@ ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Spri
|
|||
return pRet;
|
||||
}
|
||||
|
||||
bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel)
|
||||
bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
|
||||
{
|
||||
if (Control::init())
|
||||
{
|
||||
|
@ -359,7 +361,7 @@ bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sp
|
|||
return false;
|
||||
}
|
||||
|
||||
ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel)
|
||||
ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
|
||||
{
|
||||
ControlSwitch* pRet = new ControlSwitch();
|
||||
if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel))
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
namespace cocos2d { class Sprite; }
|
||||
namespace cocos2d { class LabelTTF; }
|
||||
namespace cocos2d { class Label; }
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
@ -50,7 +50,7 @@ class ControlSwitch : public Control
|
|||
{
|
||||
public:
|
||||
/** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
|
||||
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel);
|
||||
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
|
||||
/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
|
||||
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
/** Initializes a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
|
||||
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
|
||||
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
|
||||
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel);
|
||||
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
|
||||
|
||||
/**
|
||||
* Set the state of the switch to On or Off, optionally animating the transition.
|
||||
|
|
|
@ -87,7 +87,7 @@ Control::Handler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Ref * pTa
|
|||
|
||||
bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) {
|
||||
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", Sprite *, this->mBurstSprite);
|
||||
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", LabelTTF *, this->mTestTitleLabelTTF);
|
||||
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", Label *, this->mTestTitleLabelTTF);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class HelloCocosBuilderLayer
|
|||
|
||||
private:
|
||||
cocos2d::Sprite * mBurstSprite;
|
||||
cocos2d::LabelTTF * mTestTitleLabelTTF;
|
||||
cocos2d::Label * mTestTitleLabelTTF;
|
||||
|
||||
int mCustomPropertyInt;
|
||||
float mCustomPropertyFloat;
|
||||
|
|
|
@ -31,7 +31,7 @@ SEL_CallFuncN TimelineCallbackTestLayer::onResolveCCBCCCallFuncSelector(Ref * pT
|
|||
}
|
||||
|
||||
bool TimelineCallbackTestLayer::onAssignCCBMemberVariable(Ref * pTarget, const char * pMemberVariableName, Node * pNode) {
|
||||
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "helloLabel", LabelTTF *, this->_helloLabel);
|
||||
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "helloLabel", Label *, this->_helloLabel);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class TimelineCallbackTestLayer
|
|||
void onCallback1(Node* sender);
|
||||
void onCallback2(Node* sender);
|
||||
private:
|
||||
cocos2d::LabelTTF* _helloLabel;
|
||||
cocos2d::Label* _helloLabel;
|
||||
};
|
||||
|
||||
#endif /* _TIMELINE_TESTLAYER_H_ */
|
||||
|
|
|
@ -64,8 +64,8 @@ bool ControlSwitchTest::init()
|
|||
Sprite::create("extensions/switch-on.png"),
|
||||
Sprite::create("extensions/switch-off.png"),
|
||||
Sprite::create("extensions/switch-thumb.png"),
|
||||
LabelTTF::create("On", "Arial-BoldMT", 16),
|
||||
LabelTTF::create("Off", "Arial-BoldMT", 16)
|
||||
Label::create("On", "Arial-BoldMT", 16),
|
||||
Label::create("Off", "Arial-BoldMT", 16)
|
||||
);
|
||||
switchControl->setPosition(Point(layer_width + 10 + switchControl->getContentSize().width / 2, 0));
|
||||
layer->addChild(switchControl);
|
||||
|
|
Loading…
Reference in New Issue