mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6052 from pipu/develop_pipu_fixedbugsforeditor_1301
Fixed bugs for Editor
This commit is contained in:
commit
98ed579b34
|
@ -116,6 +116,11 @@ namespace cocostudio
|
|||
}
|
||||
panel->setLayoutType((LayoutType)DICTOOL->getIntValue_json(options, "layoutType"));
|
||||
|
||||
int bgimgcr = DICTOOL->getIntValue_json(options, "colorR");
|
||||
int bgimgcg = DICTOOL->getIntValue_json(options, "colorG");
|
||||
int bgimgcb = DICTOOL->getIntValue_json(options, "colorB");
|
||||
panel->setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb));
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
}
|
||||
|
|
|
@ -392,8 +392,15 @@ void Button::onPressStateChangedToNormal()
|
|||
}
|
||||
else
|
||||
{
|
||||
_buttonNormalRenderer->stopAllActions();
|
||||
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
updateTextureRGBA();
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonNormalRenderer->stopAllActions();
|
||||
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,8 +425,15 @@ void Button::onPressStateChangedToPressed()
|
|||
_buttonNormalRenderer->setVisible(true);
|
||||
_buttonClickedRenderer->setVisible(true);
|
||||
_buttonDisableRenderer->setVisible(false);
|
||||
_buttonNormalRenderer->stopAllActions();
|
||||
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize + 0.1f, _normalTextureScaleYInSize + 0.1f);
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
_buttonNormalRenderer->setColor(Color3B::GRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonNormalRenderer->stopAllActions();
|
||||
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize + 0.1f, _normalTextureScaleYInSize + 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ ListView::~ListView()
|
|||
_listViewEventListener = nullptr;
|
||||
_listViewEventSelector = nullptr;
|
||||
_items.clear();
|
||||
CC_SAFE_RELEASE(_model);
|
||||
}
|
||||
|
||||
ListView* ListView::create()
|
||||
|
|
|
@ -29,6 +29,23 @@ NS_CC_BEGIN
|
|||
|
||||
namespace ui {
|
||||
|
||||
static int _calcCharCount(const char * pszText)
|
||||
{
|
||||
int n = 0;
|
||||
char ch = 0;
|
||||
while ((ch = *pszText))
|
||||
{
|
||||
CC_BREAK_IF(! ch);
|
||||
|
||||
if (0x80 != (0xC0 & ch))
|
||||
{
|
||||
++n;
|
||||
}
|
||||
++pszText;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
bool RichElement::init(int tag, const Color3B &color, GLubyte opacity)
|
||||
{
|
||||
_tag = tag;
|
||||
|
@ -262,7 +279,7 @@ void RichText::handleTextRenderer(const char *text, const char *fontName, float
|
|||
{
|
||||
float overstepPercent = (-_leftSpaceWidth) / textRendererWidth;
|
||||
std::string curText = text;
|
||||
size_t stringLength = curText.length();
|
||||
size_t stringLength = _calcCharCount(text);
|
||||
int leftLength = stringLength * (1.0f - overstepPercent);
|
||||
std::string leftWords = curText.substr(0, leftLength);
|
||||
std::string cutWords = curText.substr(leftLength, curText.length()-1);
|
||||
|
|
|
@ -167,14 +167,15 @@ void UICCTextField::insertText(const char * text, size_t len)
|
|||
}
|
||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
int input_count = _calcCharCount(text);
|
||||
if (input_count > _maxLength)
|
||||
int total = text_count + input_count;
|
||||
if (total > _maxLength)
|
||||
{
|
||||
int ascii = 0;
|
||||
int unicode = 0;
|
||||
int end = 0;
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < input_count * 3; ++i)
|
||||
for (int i = 0; i < total * 3; ++i)
|
||||
{
|
||||
char value = text[i];
|
||||
|
||||
|
@ -291,12 +292,24 @@ void UICCTextField::setPasswordStyleText(const char* styleText)
|
|||
|
||||
void UICCTextField::setPasswordText(const char *text)
|
||||
{
|
||||
std::string tempStr;
|
||||
for (size_t i = 0; i < strlen(text); ++i)
|
||||
std::string tempStr = "";
|
||||
int text_count = _calcCharCount(text);
|
||||
int max = text_count;
|
||||
|
||||
if (_maxLengthEnabled)
|
||||
{
|
||||
if (text_count > _maxLength)
|
||||
{
|
||||
max = _maxLength;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < max; ++i)
|
||||
{
|
||||
tempStr.append(_passwordStyleText);
|
||||
}
|
||||
Label::setString(tempStr.c_str());
|
||||
|
||||
Label::setString(tempStr);
|
||||
}
|
||||
|
||||
void UICCTextField::setAttachWithIME(bool attach)
|
||||
|
@ -433,21 +446,59 @@ Size TextField::getTouchSize()
|
|||
void TextField::setText(const std::string& text)
|
||||
{
|
||||
std::string strText(text);
|
||||
|
||||
if (isMaxLengthEnabled())
|
||||
{
|
||||
strText = strText.substr(0, getMaxLength());
|
||||
int max = _textFieldRenderer->getMaxLength();
|
||||
int text_count = _calcCharCount(text.c_str());
|
||||
int total = text_count + _calcCharCount(getStringValue().c_str());
|
||||
if (total > max)
|
||||
{
|
||||
int ascii = 0;
|
||||
int unicode = 0;
|
||||
int end = 0;
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < total * 3; ++i)
|
||||
{
|
||||
char value = text[i];
|
||||
|
||||
if (value >= 0 && value <= 127) // ascii
|
||||
{
|
||||
ascii++;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
unicode++;
|
||||
if (unicode % 3 == 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == max)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
end = ascii + unicode;
|
||||
strText = strText.substr(0, end);
|
||||
}
|
||||
}
|
||||
|
||||
const char* content = strText.c_str();
|
||||
if (isPasswordEnabled())
|
||||
{
|
||||
_textFieldRenderer->setPasswordText(content);
|
||||
_textFieldRenderer->setString("");
|
||||
_textFieldRenderer->insertText(content, static_cast<int>(strlen(content)));
|
||||
_textFieldRenderer->insertText(content, strlen(content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_textFieldRenderer->setString(content);
|
||||
}
|
||||
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ bool UITextTest_LineWrap::init()
|
|||
|
||||
// Create the line wrap
|
||||
Text* text = Text::create();
|
||||
text->setTextAreaSize(Size(280, 150));
|
||||
text->ignoreContentAdaptWithSize(false);
|
||||
text->setSize(Size(280, 150));
|
||||
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
text->setText("Text can line wrap");
|
||||
text->setFontName("AmericanTypewriter");
|
||||
|
|
Loading…
Reference in New Issue