issue #4660:remove unnecessary API.

This commit is contained in:
Dhilan007 2014-05-08 21:30:12 +08:00 committed by James Chen
parent 645a9761c8
commit 4692c67b78
3 changed files with 22 additions and 37 deletions

View File

@ -301,7 +301,7 @@ void Label::reset()
TTFConfig temp;
_fontConfig = temp;
_fontDirty = false;
_systemFontDirty = false;
_systemFont = "Helvetica";
_systemFontSize = 12;
@ -472,6 +472,13 @@ void Label::setString(const std::string& text)
{
_originalUTF8String = text;
_contentDirty = true;
std::u16string utf16String;
if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String))
{
_originalUTF16String = utf16String;
_currentUTF16String = utf16String;
}
}
void Label::setAlignment(TextHAlignment hAlignment,TextVAlignment vAlignment)
@ -646,25 +653,6 @@ bool Label::computeHorizontalKernings(const std::u16string& stringToRender)
return true;
}
bool Label::setOriginalString(const std::u16string& stringToSet)
{
_originalUTF16String = stringToSet;
return true;
}
bool Label::setCurrentString(const std::u16string& stringToSet)
{
_currentUTF16String = stringToSet;
computeStringNumLines();
// compute the advances
if (_fontAtlas)
{
computeHorizontalKernings(stringToSet);
}
return true;
}
void Label::updateQuads()
{
int index;
@ -939,11 +927,10 @@ void Label::setFontDefinition(const FontDefinition& textDefinition)
void Label::updateContent()
{
std::u16string utf16String;
if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String))
computeStringNumLines();
if (_fontAtlas)
{
setCurrentString(utf16String);
setOriginalString(utf16String);
computeHorizontalKernings(_originalUTF16String);
}
if (_textSprite)
@ -1019,7 +1006,7 @@ void Label::updateFont()
}
_contentDirty = true;
_fontDirty = false;
_systemFontDirty = false;
}
void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
@ -1058,7 +1045,7 @@ void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parent
{
return;
}
if (_fontDirty)
if (_systemFontDirty)
{
updateFont();
}
@ -1119,7 +1106,7 @@ void Label::setSystemFontName(const std::string& systemFont)
if (systemFont != _systemFont)
{
_systemFont = systemFont;
_fontDirty = true;
_systemFontDirty = true;
}
}
@ -1128,16 +1115,15 @@ void Label::setSystemFontSize(float fontSize)
if (_systemFontSize != fontSize)
{
_systemFontSize = fontSize;
_fontDirty = true;
_systemFontDirty = true;
}
}
///// PROTOCOL STUFF
Sprite * Label::getLetter(int letterIndex)
{
if (_fontDirty)
if (_systemFontDirty || _currentLabelType == LabelType::STRING_TEXTURE)
{
updateFont();
return nullptr;
}
@ -1313,7 +1299,7 @@ std::string Label::getDescription() const
const Size& Label::getContentSize() const
{
if (_fontDirty)
if (_systemFontDirty)
{
const_cast<Label*>(this)->updateFont();
}

View File

@ -287,8 +287,7 @@ protected:
virtual void alignText();
bool computeHorizontalKernings(const std::u16string& stringToRender);
bool setCurrentString(const std::u16string& stringToSet);
bool setOriginalString(const std::u16string& stringToSet);
void computeStringNumLines();
void updateQuads();
@ -311,7 +310,7 @@ protected:
bool _isOpacityModifyRGB;
bool _contentDirty;
bool _fontDirty;
bool _systemFontDirty;
std::string _systemFont;
float _systemFontSize;
LabelType _currentLabelType;

View File

@ -34,9 +34,7 @@ NS_CC_BEGIN
bool LabelTextFormatter::multilineText(Label *theLabel)
{
//int strLen = theLabel->getStringLength();
auto limit = theLabel->_limitShowCount;
auto strWhole = theLabel->_currentUTF16String;
std::vector<char16_t> multiline_string;
@ -175,7 +173,9 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
std::u16string strNew(multiline_string.begin(), multiline_string.end());
theLabel->setCurrentString(strNew);
theLabel->_originalUTF16String = strNew;
theLabel->computeStringNumLines();
theLabel->computeHorizontalKernings(theLabel->_originalUTF16String);
return true;
}