mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7491 from Dhilan007/v3-320final
fixed text line wrap issue in UITextField.
This commit is contained in:
commit
c482e2e14f
|
@ -186,7 +186,7 @@ bool LabelTextFormatter::alignText(Label *theLabel)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
int lineNumber = 0;
|
int lineNumber = 0;
|
||||||
int strLen = static_cast<int>(theLabel->_currentUTF16String.length());
|
int strLen = theLabel->_limitShowCount;
|
||||||
std::vector<char16_t> lastLine;
|
std::vector<char16_t> lastLine;
|
||||||
auto strWhole = theLabel->_currentUTF16String;
|
auto strWhole = theLabel->_currentUTF16String;
|
||||||
|
|
||||||
|
|
|
@ -799,24 +799,9 @@ void TextField::adaptRenderers()
|
||||||
|
|
||||||
void TextField::textfieldRendererScaleChangedWithSize()
|
void TextField::textfieldRendererScaleChangedWithSize()
|
||||||
{
|
{
|
||||||
if (_ignoreSize)
|
if (!_ignoreSize)
|
||||||
{
|
|
||||||
_textFieldRenderer->setDimensions(0,0);
|
|
||||||
_textFieldRenderer->setScale(1.0f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
|
_textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
|
||||||
Size textureSize = getContentSize();
|
|
||||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
|
||||||
{
|
|
||||||
_textFieldRenderer->setScale(1.0f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float scaleX = _contentSize.width / textureSize.width;
|
|
||||||
float scaleY = _contentSize.height / textureSize.height;
|
|
||||||
_textFieldRenderer->setScaleX(scaleX);
|
|
||||||
_textFieldRenderer->setScaleY(scaleY);
|
|
||||||
}
|
}
|
||||||
_textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
_textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||||
}
|
}
|
||||||
|
@ -871,7 +856,7 @@ void TextField::copySpecialProperties(Widget *widget)
|
||||||
|
|
||||||
void TextField::setTextAreaSize(const Size &size)
|
void TextField::setTextAreaSize(const Size &size)
|
||||||
{
|
{
|
||||||
_textFieldRenderer->setDimensions(size.width,size.height);
|
this->setContentSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::setTextHorizontalAlignment(TextHAlignment alignment)
|
void TextField::setTextHorizontalAlignment(TextHAlignment alignment)
|
||||||
|
|
|
@ -275,7 +275,8 @@ bool UITextFieldTest_LineWrap::init()
|
||||||
// Create the textfield
|
// Create the textfield
|
||||||
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
||||||
textField->ignoreContentAdaptWithSize(false);
|
textField->ignoreContentAdaptWithSize(false);
|
||||||
textField->setContentSize(Size(240, 160));
|
((Label*)(textField->getVirtualRenderer()))->setLineBreakWithoutSpace(true);
|
||||||
|
textField->setContentSize(Size(240, 70));
|
||||||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||||
textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
textField->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
|
|
Loading…
Reference in New Issue