mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into develop_migrate_math_lib_merge
Conflicts: cocos/ui/UIButton.cpp cocos/ui/UIButton.h cocos/ui/UICheckBox.cpp cocos/ui/UICheckBox.h cocos/ui/UIImageView.cpp cocos/ui/UIImageView.h cocos/ui/UILayout.cpp cocos/ui/UILayout.h cocos/ui/UILoadingBar.cpp cocos/ui/UIRichText.h cocos/ui/UISlider.cpp cocos/ui/UIText.cpp cocos/ui/UIText.h cocos/ui/UITextAtlas.cpp cocos/ui/UITextAtlas.h cocos/ui/UITextBMFont.cpp cocos/ui/UITextBMFont.h cocos/ui/UITextField.cpp cocos/ui/UITextField.h cocos/ui/UIWidget.cpp tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp
This commit is contained in:
commit
3b83d52f95
|
@ -111,3 +111,9 @@ CMakeCache.txt
|
|||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
|
||||
# Ignore files generated by console
|
||||
build/build/
|
||||
cocos/scripting/lua-bindings/proj.ios_mac/build/
|
||||
tests/*/runtime/
|
||||
tests/*/publish/
|
||||
|
|
1
AUTHORS
1
AUTHORS
|
@ -818,6 +818,7 @@ Developers:
|
|||
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
|
||||
Fixed a potential memory leak in CCEditBoxImplIOS.mm
|
||||
Fixed incompatible pointer conversion in external/chipmunk/src/cpArray.c
|
||||
Fix memory leak in CCImage
|
||||
|
||||
ololomax
|
||||
Fixed a potential crash in SceneReader::createNodeWithSceneFile
|
||||
|
|
|
@ -1 +1 @@
|
|||
5c54d396206175b71038b1b99d2db31443421952
|
||||
62ee83b9b745b3f49184d3f440092788aa97c795
|
|
@ -175,7 +175,7 @@ Director::~Director(void)
|
|||
CC_SAFE_RELEASE(_notificationNode);
|
||||
CC_SAFE_RELEASE(_scheduler);
|
||||
CC_SAFE_RELEASE(_actionManager);
|
||||
CC_SAFE_RELEASE(_eventDispatcher);
|
||||
|
||||
|
||||
delete _eventAfterUpdate;
|
||||
delete _eventAfterDraw;
|
||||
|
@ -188,6 +188,8 @@ Director::~Director(void)
|
|||
delete _console;
|
||||
#endif
|
||||
|
||||
CC_SAFE_RELEASE(_eventDispatcher);
|
||||
|
||||
// clean auto release pool
|
||||
PoolManager::destroyInstance();
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ EventListenerTouchOneByOne* EventListenerTouchOneByOne::create()
|
|||
|
||||
bool EventListenerTouchOneByOne::checkAvailable()
|
||||
{
|
||||
// EventDispatcher will use the return value of 'onTouchBegan' to determine whether to pass following 'move', 'end'
|
||||
// message to 'EventListenerTouchOneByOne' or not. So 'onTouchBegan' needs to be set.
|
||||
if (onTouchBegan == nullptr)
|
||||
{
|
||||
CCASSERT(false, "Invalid EventListenerTouchOneByOne!");
|
||||
|
|
|
@ -942,7 +942,14 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
|
||||
_dataLen = rowbytes * _height;
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(!_data);
|
||||
if(!_data)
|
||||
{
|
||||
if (row_pointers != nullptr)
|
||||
{
|
||||
free(row_pointers);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned short i = 0; i < _height; ++i)
|
||||
{
|
||||
|
@ -957,7 +964,7 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
if (row_pointers != nullptr)
|
||||
{
|
||||
free(row_pointers);
|
||||
};
|
||||
}
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
@ -2028,6 +2035,9 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB)
|
|||
{
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
free(row_pointers);
|
||||
row_pointers = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
// helper
|
||||
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
static bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
{
|
||||
return a->getGlobalOrder() < b->getGlobalOrder();
|
||||
}
|
||||
|
|
|
@ -220,6 +220,7 @@ static void _log(const char *format, va_list args)
|
|||
OutputDebugStringW(wszBuf);
|
||||
WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE);
|
||||
printf("%s", buf);
|
||||
fflush(stdout);
|
||||
#else
|
||||
// Linux, Mac, iOS, etc
|
||||
fprintf(stdout, "cocos2d: %s", buf);
|
||||
|
|
|
@ -1109,6 +1109,10 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!dynamic_cast<Layout*>(widget))
|
||||
{
|
||||
child->setPosition(Point(child->getPositionX() + widget->getSize().width / 2.0f, child->getPositionY() + widget->getSize().height / 2.0f));
|
||||
}
|
||||
widget->addChild(child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,11 +137,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -153,7 +148,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] getContentSize
|
||||
-- @function [parent=#Button] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -73,11 +73,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -89,7 +84,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] getContentSize
|
||||
-- @function [parent=#CheckBox] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -50,11 +50,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -66,7 +61,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] getContentSize
|
||||
-- @function [parent=#ImageView] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -137,12 +137,6 @@
|
|||
-- @param self
|
||||
-- @return color3B_table#color3B_table ret (return value: color3B_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Layout] hitTest
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Layout] setBackGroundImageScale9Enabled
|
||||
-- @param self
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#LoadingBar] getContentSize
|
||||
-- @function [parent=#LoadingBar] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
-- @param self
|
||||
-- @param #ccui.RichElement richelement
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] formatText
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] ignoreContentAdaptWithSize
|
||||
-- @param self
|
||||
|
@ -34,9 +30,8 @@
|
|||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] getContentSize
|
||||
-- @function [parent=#RichText] formatText
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- overload function: removeElement(ccui.RichElement)
|
||||
|
@ -57,6 +52,11 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] RichText
|
||||
-- @param self
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Slider] getContentSize
|
||||
-- @function [parent=#Slider] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -95,11 +95,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -111,7 +106,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] getContentSize
|
||||
-- @function [parent=#Text] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] adaptRenderers
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] setStringValue
|
||||
-- @param self
|
||||
|
@ -41,11 +45,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -57,7 +56,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] getContentSize
|
||||
-- @function [parent=#TextAtlas] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -50,7 +45,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] getContentSize
|
||||
-- @function [parent=#TextBMFont] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -184,11 +184,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -205,7 +200,7 @@
|
|||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] getContentSize
|
||||
-- @function [parent=#TextField] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -63,11 +63,6 @@
|
|||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getActionTag
|
||||
-- @param self
|
||||
-- @return int#int ret (return value: int)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getLayoutParameter
|
||||
-- @param self
|
||||
|
@ -100,15 +95,20 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isTouchEnabled
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getContentSize
|
||||
-- @function [parent=#Widget] getActionTag
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
-- @return int#int ret (return value: int)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getWorldPosition
|
||||
|
|
|
@ -1 +1 @@
|
|||
a1f2ceee65fe7b4bdae2cd2c32ff84fa332a6b50
|
||||
088e9951d4f001122370379060141d0e98b5a4d8
|
|
@ -365,7 +365,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __cocos2dx_ui_h__
|
||||
|
|
|
@ -1 +1 @@
|
|||
468c9e8472db4be2923ca63484bc72ba2a30ae88
|
||||
c6021dd4f0d5fbfab61453c2a5f045f4f789a18d
|
|
@ -63,7 +63,10 @@ _pressedTextureScaleXInSize(1.0f),
|
|||
_pressedTextureScaleYInSize(1.0f),
|
||||
_normalTextureLoaded(false),
|
||||
_pressedTextureLoaded(false),
|
||||
_disabledTextureLoaded(false)
|
||||
_disabledTextureLoaded(false),
|
||||
_normalTextureAdaptDirty(true),
|
||||
_pressedTextureAdaptDirty(true),
|
||||
_disabledTextureAdaptDirty(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -253,12 +256,12 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
|
|||
}
|
||||
}
|
||||
_normalTextureSize = _buttonNormalRenderer->getContentSize();
|
||||
normalTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonNormalRenderer);
|
||||
updateContentSizeWithTextureSize(_normalTextureSize);
|
||||
_normalTextureLoaded = true;
|
||||
_normalTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::loadTexturePressed(const std::string& selected,TextureResType texType)
|
||||
|
@ -301,12 +304,11 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy
|
|||
}
|
||||
}
|
||||
_pressedTextureSize = _buttonClickedRenderer->getContentSize();
|
||||
pressedTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonDisableRenderer);
|
||||
_pressedTextureLoaded = true;
|
||||
_pressedTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType)
|
||||
|
@ -349,12 +351,11 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT
|
|||
}
|
||||
}
|
||||
_disabledTextureSize = _buttonDisableRenderer->getContentSize();
|
||||
disabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonDisableRenderer);
|
||||
_disabledTextureLoaded = true;
|
||||
_disabledTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::setCapInsets(const Rect &capInsets)
|
||||
|
@ -517,24 +518,40 @@ void Button::updateFlippedY()
|
|||
}
|
||||
}
|
||||
|
||||
void Button::setAnchorPoint(const Vector2 &pt)
|
||||
void Button::updateTitleLocation()
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_buttonNormalRenderer->setAnchorPoint(pt);
|
||||
_buttonClickedRenderer->setAnchorPoint(pt);
|
||||
_buttonDisableRenderer->setAnchorPoint(pt);
|
||||
_titleRenderer->setPosition(Vector2(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
|
||||
_titleRenderer->setPosition(Vector2(_contentSize.width * 0.5f, _contentSize.height * 0.5f));
|
||||
}
|
||||
|
||||
void Button::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
normalTextureScaleChangedWithSize();
|
||||
pressedTextureScaleChangedWithSize();
|
||||
disabledTextureScaleChangedWithSize();
|
||||
updateTitleLocation();
|
||||
_normalTextureAdaptDirty = true;
|
||||
_pressedTextureAdaptDirty = true;
|
||||
_disabledTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& Button::getContentSize() const
|
||||
void Button::adaptRenderers()
|
||||
{
|
||||
if (_normalTextureAdaptDirty)
|
||||
{
|
||||
normalTextureScaleChangedWithSize();
|
||||
_normalTextureAdaptDirty = false;
|
||||
}
|
||||
if (_pressedTextureAdaptDirty)
|
||||
{
|
||||
pressedTextureScaleChangedWithSize();
|
||||
_pressedTextureAdaptDirty = false;
|
||||
}
|
||||
if (_disabledTextureAdaptDirty)
|
||||
{
|
||||
disabledTextureScaleChangedWithSize();
|
||||
_disabledTextureAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& Button::getVirtualRendererSize() const
|
||||
{
|
||||
return _normalTextureSize;
|
||||
}
|
||||
|
@ -567,7 +584,6 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
{
|
||||
_buttonNormalRenderer->setScale(1.0f);
|
||||
_normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f;
|
||||
_size = _normalTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -593,6 +609,7 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
_normalTextureScaleYInSize = scaleY;
|
||||
}
|
||||
}
|
||||
_buttonNormalRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::pressedTextureScaleChangedWithSize()
|
||||
|
@ -628,6 +645,7 @@ void Button::pressedTextureScaleChangedWithSize()
|
|||
_pressedTextureScaleYInSize = scaleY;
|
||||
}
|
||||
}
|
||||
_buttonClickedRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::disabledTextureScaleChangedWithSize()
|
||||
|
@ -659,6 +677,7 @@ void Button::disabledTextureScaleChangedWithSize()
|
|||
_buttonDisableRenderer->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
_buttonDisableRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::setPressedActionEnabled(bool enabled)
|
||||
|
|
|
@ -146,9 +146,6 @@ public:
|
|||
|
||||
const Rect& getCapInsetsDisabledRenderer();
|
||||
|
||||
//override "setAnchorPoint" of widget.
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
/**
|
||||
* Sets if button is using scale9 renderer.
|
||||
*
|
||||
|
@ -168,8 +165,8 @@ public:
|
|||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -212,6 +209,8 @@ protected:
|
|||
void disabledTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
void updateTitleLocation();
|
||||
protected:
|
||||
Node* _buttonNormalRenderer;
|
||||
Node* _buttonClickedRenderer;
|
||||
|
@ -240,6 +239,9 @@ protected:
|
|||
bool _normalTextureLoaded;
|
||||
bool _pressedTextureLoaded;
|
||||
bool _disabledTextureLoaded;
|
||||
bool _normalTextureAdaptDirty;
|
||||
bool _pressedTextureAdaptDirty;
|
||||
bool _disabledTextureAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,12 @@ _backGroundFileName(""),
|
|||
_backGroundSelectedFileName(""),
|
||||
_frontCrossFileName(""),
|
||||
_backGroundDisabledFileName(""),
|
||||
_frontCrossDisabledFileName("")
|
||||
_frontCrossDisabledFileName(""),
|
||||
_backGroundBoxRendererAdaptDirty(true),
|
||||
_backGroundSelectedBoxRendererAdaptDirty(true),
|
||||
_frontCrossRendererAdaptDirty(true),
|
||||
_backGroundBoxDisabledRendererAdaptDirty(true),
|
||||
_frontCrossDisabledRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -178,11 +183,11 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundBoxRenderer);
|
||||
updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize());
|
||||
_backGroundBoxRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
|
||||
|
@ -204,11 +209,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
|
||||
_backGroundSelectedBoxRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType)
|
||||
|
@ -230,11 +234,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex
|
|||
default:
|
||||
break;
|
||||
}
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_frontCrossRenderer);
|
||||
_frontCrossRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType)
|
||||
|
@ -256,11 +259,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundBoxDisabledRenderer);
|
||||
_backGroundBoxDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
|
||||
|
@ -282,11 +284,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl
|
|||
default:
|
||||
break;
|
||||
}
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_frontCrossDisabledRenderer);
|
||||
_frontCrossDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent)
|
||||
|
@ -396,27 +397,46 @@ void CheckBox::updateFlippedY()
|
|||
_frontCrossDisabledRenderer->setFlippedY(_flippedY);
|
||||
}
|
||||
|
||||
void CheckBox::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_backGroundBoxRenderer->setAnchorPoint(pt);
|
||||
_backGroundSelectedBoxRenderer->setAnchorPoint(pt);
|
||||
_backGroundBoxDisabledRenderer->setAnchorPoint(pt);
|
||||
_frontCrossRenderer->setAnchorPoint(pt);
|
||||
_frontCrossDisabledRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void CheckBox::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
_backGroundBoxRendererAdaptDirty = true;
|
||||
_backGroundSelectedBoxRendererAdaptDirty = true;
|
||||
_frontCrossRendererAdaptDirty = true;
|
||||
_backGroundBoxDisabledRendererAdaptDirty = true;
|
||||
_frontCrossDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& CheckBox::getContentSize() const
|
||||
void CheckBox::adaptRenderers()
|
||||
{
|
||||
if (_backGroundBoxRendererAdaptDirty)
|
||||
{
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
_backGroundBoxRendererAdaptDirty = false;
|
||||
}
|
||||
if (_backGroundSelectedBoxRendererAdaptDirty)
|
||||
{
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
_backGroundSelectedBoxRendererAdaptDirty = false;
|
||||
}
|
||||
if (_frontCrossRendererAdaptDirty)
|
||||
{
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
_frontCrossRendererAdaptDirty = false;
|
||||
}
|
||||
if (_backGroundBoxDisabledRendererAdaptDirty)
|
||||
{
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
_backGroundBoxDisabledRendererAdaptDirty = false;
|
||||
}
|
||||
if (_frontCrossDisabledRendererAdaptDirty)
|
||||
{
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
_frontCrossDisabledRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& CheckBox::getVirtualRendererSize() const
|
||||
{
|
||||
return _backGroundBoxRenderer->getContentSize();
|
||||
}
|
||||
|
@ -431,7 +451,6 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
|
|||
if (_ignoreSize)
|
||||
{
|
||||
_backGroundBoxRenderer->setScale(1.0f);
|
||||
_size = _backGroundBoxRenderer->getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -446,6 +465,7 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
|
|||
_backGroundBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
|
||||
|
@ -467,6 +487,7 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
|
|||
_backGroundSelectedBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundSelectedBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundSelectedBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::frontCrossTextureScaleChangedWithSize()
|
||||
|
@ -488,6 +509,7 @@ void CheckBox::frontCrossTextureScaleChangedWithSize()
|
|||
_frontCrossRenderer->setScaleX(scaleX);
|
||||
_frontCrossRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_frontCrossRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
|
||||
|
@ -509,6 +531,7 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
|
|||
_backGroundBoxDisabledRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundBoxDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
|
||||
|
@ -530,6 +553,7 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
|
|||
_frontCrossDisabledRenderer->setScaleX(scaleX);
|
||||
_frontCrossDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_frontCrossDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
std::string CheckBox::getDescription() const
|
||||
|
|
|
@ -164,17 +164,14 @@ public:
|
|||
*/
|
||||
bool getSelectedState();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
//add a call back function would called when checkbox is selected or unselected.
|
||||
void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector);
|
||||
|
||||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent);
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -213,6 +210,7 @@ protected:
|
|||
void frontCrossDisabledTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
Sprite* _backGroundBoxRenderer;
|
||||
Sprite* _backGroundSelectedBoxRenderer;
|
||||
|
@ -235,6 +233,12 @@ protected:
|
|||
std::string _frontCrossFileName;
|
||||
std::string _backGroundDisabledFileName;
|
||||
std::string _frontCrossDisabledFileName;
|
||||
|
||||
bool _backGroundBoxRendererAdaptDirty;
|
||||
bool _backGroundSelectedBoxRendererAdaptDirty;
|
||||
bool _frontCrossRendererAdaptDirty;
|
||||
bool _backGroundBoxDisabledRendererAdaptDirty;
|
||||
bool _frontCrossDisabledRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ _capInsets(Rect::ZERO),
|
|||
_imageRenderer(nullptr),
|
||||
_textureFile(""),
|
||||
_imageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_imageTextureSize(_size)
|
||||
_imageTextureSize(_size),
|
||||
_imageRendererAdaptDirty(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -150,11 +151,11 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
|
|||
break;
|
||||
}
|
||||
_imageTextureSize = _imageRenderer->getContentSize();
|
||||
imageTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_imageRenderer);
|
||||
updateContentSizeWithTextureSize(_imageTextureSize);
|
||||
_imageRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void ImageView::setTextureRect(const Rect &rect)
|
||||
|
@ -258,19 +259,22 @@ const Rect& ImageView::getCapInsets()
|
|||
return _capInsets;
|
||||
}
|
||||
|
||||
void ImageView::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_imageRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void ImageView::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
imageTextureScaleChangedWithSize();
|
||||
_imageRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& ImageView::getContentSize() const
|
||||
void ImageView::adaptRenderers()
|
||||
{
|
||||
if (_imageRendererAdaptDirty)
|
||||
{
|
||||
imageTextureScaleChangedWithSize();
|
||||
_imageRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& ImageView::getVirtualRendererSize() const
|
||||
{
|
||||
return _imageTextureSize;
|
||||
}
|
||||
|
@ -287,7 +291,6 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
if (!_scale9Enabled)
|
||||
{
|
||||
_imageRenderer->setScale(1.0f);
|
||||
_size = _imageTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -310,6 +313,7 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
_imageRenderer->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
_imageRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
std::string ImageView::getDescription() const
|
||||
|
|
|
@ -99,9 +99,6 @@ public:
|
|||
|
||||
const Rect& getCapInsets();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
|
@ -110,7 +107,7 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
virtual const Size& getContentSize() const override;
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
@ -129,6 +126,7 @@ protected:
|
|||
void imageTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
bool _scale9Enabled;
|
||||
bool _prevIgnoreSize;
|
||||
|
@ -137,6 +135,7 @@ protected:
|
|||
std::string _textureFile;
|
||||
TextureResType _imageTexType;
|
||||
Size _imageTextureSize;
|
||||
bool _imageRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -700,23 +700,13 @@ bool Layout::isClippingEnabled()
|
|||
return _clippingEnabled;
|
||||
}
|
||||
|
||||
bool Layout::hitTest(const Vector2 &pt)
|
||||
{
|
||||
Vector2 nsp = convertToNodeSpace(pt);
|
||||
Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height);
|
||||
if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Layout::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (!_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
adaptRenderers();
|
||||
if (_clippingEnabled)
|
||||
{
|
||||
switch (_clippingType)
|
||||
|
@ -1073,7 +1063,6 @@ const Rect& Layout::getClippingRect()
|
|||
void Layout::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
setContentSize(_size);
|
||||
setStencilClippingSize(_size);
|
||||
_doLayoutDirty = true;
|
||||
_clippingRectDirty = true;
|
||||
|
|
|
@ -266,8 +266,6 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
virtual bool hitTest(const Vector2 &pt);
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
//override "init" method of widget.
|
||||
virtual bool init() override;
|
||||
|
|
|
@ -43,7 +43,8 @@ _barRendererTextureSize(Size::ZERO),
|
|||
_scale9Enabled(false),
|
||||
_prevIgnoreSize(true),
|
||||
_capInsets(Rect::ZERO),
|
||||
_textureFile("")
|
||||
_textureFile(""),
|
||||
_barRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -175,7 +176,9 @@ int LoadingBar::getDirection()
|
|||
}
|
||||
break;
|
||||
}
|
||||
barRendererScaleChangedWithSize();
|
||||
// barRendererScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_barRendererTextureSize);
|
||||
_barRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void LoadingBar::setScale9Enabled(bool enabled)
|
||||
|
@ -265,7 +268,16 @@ int LoadingBar::getPercent()
|
|||
void LoadingBar::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
barRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void LoadingBar::adaptRenderers()
|
||||
{
|
||||
if (_barRendererAdaptDirty)
|
||||
{
|
||||
barRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadingBar::ignoreContentAdaptWithSize(bool ignore)
|
||||
|
@ -277,7 +289,7 @@ void LoadingBar::ignoreContentAdaptWithSize(bool ignore)
|
|||
}
|
||||
}
|
||||
|
||||
const Size& LoadingBar::getContentSize() const
|
||||
const Size& LoadingBar::getVirtualRendererSize() const
|
||||
{
|
||||
return _barRendererTextureSize;
|
||||
}
|
||||
|
@ -295,7 +307,6 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
{
|
||||
_totalLength = _barRendererTextureSize.width;
|
||||
_barRenderer->setScale(1.0f);
|
||||
_size = _barRendererTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -323,10 +334,10 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
switch (_barType)
|
||||
{
|
||||
case LoadingBarTypeLeft:
|
||||
_barRenderer->setPosition(Vector2(-_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Vector2(0.0f, _contentSize.height / 2.0f));
|
||||
break;
|
||||
case LoadingBarTypeRight:
|
||||
_barRenderer->setPosition(Vector2(_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Vector2(_totalLength, _contentSize.height / 2.0f));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -128,8 +128,8 @@ public:
|
|||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -148,6 +148,7 @@ protected:
|
|||
void barRendererScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
LoadingBarType _barType;
|
||||
int _percent;
|
||||
|
@ -159,6 +160,7 @@ protected:
|
|||
bool _prevIgnoreSize;
|
||||
Rect _capInsets;
|
||||
std::string _textureFile;
|
||||
bool _barRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -216,7 +216,6 @@ void RichText::formatText()
|
|||
{
|
||||
elementRenderer = Label::createWithSystemFont(elmtText->_text.c_str(), elmtText->_fontName, elmtText->_fontSize);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case RICH_IMAGE:
|
||||
|
@ -428,13 +427,15 @@ void RichText::formarRenderers()
|
|||
|
||||
if (_ignoreSize)
|
||||
{
|
||||
Size s = getContentSize();
|
||||
Size s = getVirtualRendererSize();
|
||||
_size = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
}
|
||||
updateContentSizeWithTextureSize(_size);
|
||||
_elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void RichText::pushToContainer(cocos2d::Node *renderer)
|
||||
|
@ -466,7 +467,7 @@ void RichText::setAnchorPoint(const Vector2 &pt)
|
|||
_elementRenderersContainer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
const Size& RichText::getContentSize() const
|
||||
const Size& RichText::getVirtualRendererSize() const
|
||||
{
|
||||
return _elementRenderersContainer->getContentSize();
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
virtual void visit(cocos2d::Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
void setVerticalSpace(float space);
|
||||
virtual void setAnchorPoint(const Vector2 &pt);
|
||||
virtual const Size& getContentSize() const;
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
void formatText();
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
virtual std::string getDescription() const override;
|
||||
|
|
|
@ -60,7 +60,9 @@ _barTexType(UI_TEX_TYPE_LOCAL),
|
|||
_progressBarTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballNTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballPTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballDTexType(UI_TEX_TYPE_LOCAL)
|
||||
_ballDTexType(UI_TEX_TYPE_LOCAL),
|
||||
_barRendererAdaptDirty(true),
|
||||
_progressBarRendererDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -145,8 +147,9 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType)
|
|||
break;
|
||||
}
|
||||
updateRGBAToRenderer(_barRenderer);
|
||||
barRendererScaleChangedWithSize();
|
||||
progressBarRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = true;
|
||||
_progressBarRendererDirty = true;
|
||||
updateContentSizeWithTextureSize(_barRenderer->getContentSize());
|
||||
}
|
||||
|
||||
void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType texType)
|
||||
|
@ -185,7 +188,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType
|
|||
updateRGBAToRenderer(_progressBarRenderer);
|
||||
_progressBarRenderer->setAnchorPoint(Vector2(0.0f, 0.5f));
|
||||
_progressBarTextureSize = _progressBarRenderer->getContentSize();
|
||||
progressBarRendererScaleChangedWithSize();
|
||||
_progressBarRendererDirty = true;
|
||||
}
|
||||
|
||||
void Slider::setScale9Enabled(bool able)
|
||||
|
@ -364,7 +367,7 @@ void Slider::setPercent(int percent)
|
|||
_percent = percent;
|
||||
float res = percent / 100.0f;
|
||||
float dis = _barLength * res;
|
||||
_slidBallRenderer->setPosition(Vector2(-_barLength/2.0f + dis, 0.0f));
|
||||
_slidBallRenderer->setPosition(Vector2(dis, _contentSize.height / 2.0f));
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(Size(dis,_progressBarTextureSize.height));
|
||||
|
@ -381,7 +384,8 @@ void Slider::setPercent(int percent)
|
|||
bool Slider::hitTest(const cocos2d::Vector2 &pt)
|
||||
{
|
||||
Vector2 nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt);
|
||||
Rect ballRect = this->_slidBallNormalRenderer->getTextureRect();
|
||||
Size ballSize = this->_slidBallNormalRenderer->getContentSize();
|
||||
Rect ballRect = Rect(0,0, ballSize.width, ballSize.height);
|
||||
if (ballRect.containsPoint(nsp)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -404,7 +408,6 @@ void Slider::onTouchMoved(Touch *touch, Event *unusedEvent)
|
|||
{
|
||||
_touchMovePos = touch->getLocation();
|
||||
Vector2 nsp = convertToNodeSpace(_touchMovePos);
|
||||
_slidBallRenderer->setPosition(Vector2(nsp.x,0));
|
||||
setPercent(getPercentWithBallPos(nsp.x));
|
||||
percentChangedEvent();
|
||||
}
|
||||
|
@ -421,7 +424,7 @@ void Slider::onTouchCancelled(Touch *touch, Event *unusedEvent)
|
|||
|
||||
float Slider::getPercentWithBallPos(float px)
|
||||
{
|
||||
return (((px-(-_barLength/2.0f))/_barLength)*100.0f);
|
||||
return ((px/_barLength)*100.0f);
|
||||
}
|
||||
|
||||
void Slider::addEventListenerSlider(Ref *target, SEL_SlidPercentChangedEvent selector)
|
||||
|
@ -446,11 +449,25 @@ int Slider::getPercent()
|
|||
void Slider::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
barRendererScaleChangedWithSize();
|
||||
progressBarRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = true;
|
||||
_progressBarRendererDirty = true;
|
||||
}
|
||||
|
||||
const Size& Slider::getContentSize() const
|
||||
void Slider::adaptRenderers()
|
||||
{
|
||||
if (_barRendererAdaptDirty)
|
||||
{
|
||||
barRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = false;
|
||||
}
|
||||
if (_progressBarRendererDirty)
|
||||
{
|
||||
progressBarRendererScaleChangedWithSize();
|
||||
_progressBarRendererDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& Slider::getVirtualRendererSize() const
|
||||
{
|
||||
return _barRenderer->getContentSize();
|
||||
}
|
||||
|
@ -466,7 +483,6 @@ void Slider::barRendererScaleChangedWithSize()
|
|||
{
|
||||
|
||||
_barRenderer->setScale(1.0f);
|
||||
_size = _barRenderer->getContentSize();
|
||||
_barLength = _size.width;
|
||||
}
|
||||
else
|
||||
|
@ -490,6 +506,7 @@ void Slider::barRendererScaleChangedWithSize()
|
|||
_barRenderer->setScaleY(bscaleY);
|
||||
}
|
||||
}
|
||||
_barRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
setPercent(_percent);
|
||||
}
|
||||
|
||||
|
@ -527,7 +544,7 @@ void Slider::progressBarRendererScaleChangedWithSize()
|
|||
_progressBarRenderer->setScaleY(pscaleY);
|
||||
}
|
||||
}
|
||||
_progressBarRenderer->setPosition(Vector2(-_barLength * 0.5f, 0.0f));
|
||||
_progressBarRenderer->setPosition(0.0f, _contentSize.height / 2.0f);
|
||||
setPercent(_percent);
|
||||
}
|
||||
|
||||
|
|
|
@ -183,8 +183,8 @@ public:
|
|||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
|
||||
virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -217,6 +217,7 @@ protected:
|
|||
void progressBarRendererScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
Node* _barRenderer;
|
||||
Node* _progressBarRenderer;
|
||||
|
@ -248,6 +249,8 @@ protected:
|
|||
TextureResType _ballNTexType;
|
||||
TextureResType _ballPTexType;
|
||||
TextureResType _ballDTexType;
|
||||
bool _barRendererAdaptDirty;
|
||||
bool _progressBarRendererDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ _normalScaleValueY(1.0f),
|
|||
_fontName("Thonburi"),
|
||||
_fontSize(10),
|
||||
_onSelectedScaleOffset(0.5),
|
||||
_labelRenderer(nullptr)
|
||||
_labelRenderer(nullptr),
|
||||
_labelRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,8 @@ void Text::initRenderer()
|
|||
void Text::setText(const std::string& text)
|
||||
{
|
||||
_labelRenderer->setString(text);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const std::string& Text::getStringValue()
|
||||
|
@ -121,7 +123,8 @@ void Text::setFontSize(int size)
|
|||
{
|
||||
_fontSize = size;
|
||||
_labelRenderer->setSystemFontSize(size);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
int Text::getFontSize()
|
||||
|
@ -133,7 +136,8 @@ void Text::setFontName(const std::string& name)
|
|||
{
|
||||
_fontName = name;
|
||||
_labelRenderer->setSystemFontName(name);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const std::string& Text::getFontName()
|
||||
|
@ -144,7 +148,8 @@ const std::string& Text::getFontName()
|
|||
void Text::setTextAreaSize(const Size &size)
|
||||
{
|
||||
_labelRenderer->setDimensions(size.width,size.height);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& Text::getTextAreaSize()
|
||||
|
@ -155,7 +160,8 @@ const Size& Text::getTextAreaSize()
|
|||
void Text::setTextHorizontalAlignment(TextHAlignment alignment)
|
||||
{
|
||||
_labelRenderer->setHorizontalAlignment(alignment);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
TextHAlignment Text::getTextHorizontalAlignment()
|
||||
|
@ -166,7 +172,8 @@ TextHAlignment Text::getTextHorizontalAlignment()
|
|||
void Text::setTextVerticalAlignment(TextVAlignment alignment)
|
||||
{
|
||||
_labelRenderer->setVerticalAlignment(alignment);
|
||||
labelScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
TextVAlignment Text::getTextVerticalAlignment()
|
||||
|
@ -233,19 +240,22 @@ void Text::updateFlippedY()
|
|||
}
|
||||
}
|
||||
|
||||
void Text::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_labelRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void Text::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
labelScaleChangedWithSize();
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& Text::getContentSize() const
|
||||
void Text::adaptRenderers()
|
||||
{
|
||||
if (_labelRendererAdaptDirty)
|
||||
{
|
||||
labelScaleChangedWithSize();
|
||||
_labelRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& Text::getVirtualRendererSize() const
|
||||
{
|
||||
return _labelRenderer->getContentSize();
|
||||
}
|
||||
|
@ -261,7 +271,6 @@ void Text::labelScaleChangedWithSize()
|
|||
{
|
||||
_labelRenderer->setDimensions(0,0);
|
||||
_labelRenderer->setScale(1.0f);
|
||||
_size = _labelRenderer->getContentSize();
|
||||
_normalScaleValueX = _normalScaleValueY = 1.0f;
|
||||
}
|
||||
else
|
||||
|
@ -280,7 +289,7 @@ void Text::labelScaleChangedWithSize()
|
|||
_normalScaleValueX = scaleX;
|
||||
_normalScaleValueY = scaleY;
|
||||
}
|
||||
|
||||
_labelRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
std::string Text::getDescription() const
|
||||
|
|
|
@ -116,11 +116,8 @@ public:
|
|||
*/
|
||||
bool isTouchScaleChangeEnabled();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -162,6 +159,7 @@ protected:
|
|||
void labelScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
bool _touchScaleChangeEnabled;
|
||||
float _normalScaleValueX;
|
||||
|
@ -170,6 +168,7 @@ protected:
|
|||
int _fontSize;
|
||||
float _onSelectedScaleOffset;
|
||||
Label* _labelRenderer;
|
||||
bool _labelRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ _stringValue(""),
|
|||
_charMapFileName(""),
|
||||
_itemWidth(0),
|
||||
_itemHeight(0),
|
||||
_startCharMap("")
|
||||
_startCharMap(""),
|
||||
_labelAtlasRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,7 @@ TextAtlas* TextAtlas::create()
|
|||
void TextAtlas::initRenderer()
|
||||
{
|
||||
_labelAtlasRenderer = LabelAtlas::create();
|
||||
_labelAtlasRenderer->setAnchorPoint(Point::ANCHOR_MIDDLE);
|
||||
addProtectedChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1);
|
||||
}
|
||||
|
||||
|
@ -90,15 +92,18 @@ void TextAtlas::setProperty(const std::string& stringValue, const std::string& c
|
|||
_itemHeight = itemHeight;
|
||||
_startCharMap = startCharMap;
|
||||
_labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0]));
|
||||
updateAnchorPoint();
|
||||
labelAtlasScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelAtlasRenderer->getContentSize());
|
||||
_labelAtlasRendererAdaptDirty = true;
|
||||
CCLOG("cs w %f, h %f", _contentSize.width, _contentSize.height);
|
||||
}
|
||||
|
||||
void TextAtlas::setStringValue(const std::string& value)
|
||||
{
|
||||
_stringValue = value;
|
||||
_labelAtlasRenderer->setString(value);
|
||||
labelAtlasScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelAtlasRenderer->getContentSize());
|
||||
_labelAtlasRendererAdaptDirty = true;
|
||||
CCLOG("cssss w %f, h %f", _contentSize.width, _contentSize.height);
|
||||
}
|
||||
|
||||
const std::string& TextAtlas::getStringValue() const
|
||||
|
@ -106,19 +111,22 @@ const std::string& TextAtlas::getStringValue() const
|
|||
return _labelAtlasRenderer->getString();
|
||||
}
|
||||
|
||||
void TextAtlas::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_labelAtlasRenderer->setAnchorPoint(Vector2(pt.x, pt.y));
|
||||
}
|
||||
|
||||
void TextAtlas::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
labelAtlasScaleChangedWithSize();
|
||||
_labelAtlasRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& TextAtlas::getContentSize() const
|
||||
void TextAtlas::adaptRenderers()
|
||||
{
|
||||
if (_labelAtlasRendererAdaptDirty)
|
||||
{
|
||||
labelAtlasScaleChangedWithSize();
|
||||
_labelAtlasRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& TextAtlas::getVirtualRendererSize() const
|
||||
{
|
||||
return _labelAtlasRenderer->getContentSize();
|
||||
}
|
||||
|
@ -133,7 +141,6 @@ void TextAtlas::labelAtlasScaleChangedWithSize()
|
|||
if (_ignoreSize)
|
||||
{
|
||||
_labelAtlasRenderer->setScale(1.0f);
|
||||
_size = _labelAtlasRenderer->getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -148,6 +155,7 @@ void TextAtlas::labelAtlasScaleChangedWithSize()
|
|||
_labelAtlasRenderer->setScaleX(scaleX);
|
||||
_labelAtlasRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_labelAtlasRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
std::string TextAtlas::getDescription() const
|
||||
|
|
|
@ -78,11 +78,8 @@ public:
|
|||
//get string value for labelatlas.
|
||||
const std::string& getStringValue() const;
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -92,6 +89,7 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
virtual void initRenderer() override;
|
||||
virtual void onSizeChanged() override;
|
||||
|
@ -108,6 +106,7 @@ protected:
|
|||
int _itemWidth;
|
||||
int _itemHeight;
|
||||
std::string _startCharMap;
|
||||
bool _labelAtlasRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ TextBMFont::TextBMFont():
|
|||
_labelBMFontRenderer(nullptr),
|
||||
_fntFileHasInit(false),
|
||||
_fntFileName(""),
|
||||
_stringValue("")
|
||||
_stringValue(""),
|
||||
_labelBMFontRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -85,8 +86,7 @@ void TextBMFont::setFntFile(const std::string& fileName)
|
|||
}
|
||||
_fntFileName = fileName;
|
||||
_labelBMFontRenderer->setBMFontFilePath(fileName);
|
||||
updateAnchorPoint();
|
||||
labelBMFontScaleChangedWithSize();
|
||||
updateRGBAToRenderer(_labelBMFontRenderer);
|
||||
_fntFileHasInit = true;
|
||||
setText(_stringValue);
|
||||
}
|
||||
|
@ -99,7 +99,8 @@ void TextBMFont::setText(const std::string& value)
|
|||
return;
|
||||
}
|
||||
_labelBMFontRenderer->setString(value);
|
||||
labelBMFontScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_labelBMFontRenderer->getContentSize());
|
||||
_labelBMFontRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const std::string TextBMFont::getStringValue()
|
||||
|
@ -107,19 +108,22 @@ const std::string TextBMFont::getStringValue()
|
|||
return _stringValue;
|
||||
}
|
||||
|
||||
void TextBMFont::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_labelBMFontRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void TextBMFont::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
labelBMFontScaleChangedWithSize();
|
||||
_labelBMFontRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
const Size& TextBMFont::getContentSize() const
|
||||
void TextBMFont::adaptRenderers()
|
||||
{
|
||||
if (_labelBMFontRendererAdaptDirty)
|
||||
{
|
||||
labelBMFontScaleChangedWithSize();
|
||||
_labelBMFontRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& TextBMFont::getVirtualRendererSize() const
|
||||
{
|
||||
return _labelBMFontRenderer->getContentSize();
|
||||
}
|
||||
|
@ -134,7 +138,6 @@ void TextBMFont::labelBMFontScaleChangedWithSize()
|
|||
if (_ignoreSize)
|
||||
{
|
||||
_labelBMFontRenderer->setScale(1.0f);
|
||||
_size = _labelBMFontRenderer->getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -149,6 +152,7 @@ void TextBMFont::labelBMFontScaleChangedWithSize()
|
|||
_labelBMFontRenderer->setScaleX(scaleX);
|
||||
_labelBMFontRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_labelBMFontRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
std::string TextBMFont::getDescription() const
|
||||
|
|
|
@ -66,8 +66,8 @@ public:
|
|||
|
||||
/** get string value for labelbmfont*/
|
||||
const std::string getStringValue();
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
virtual const Size& getContentSize() const override;
|
||||
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
|
@ -82,11 +82,13 @@ protected:
|
|||
void labelBMFontScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
cocos2d::Label* _labelBMFontRenderer;
|
||||
bool _fntFileHasInit;
|
||||
std::string _fntFileName;
|
||||
std::string _stringValue;
|
||||
bool _labelBMFontRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -364,7 +364,8 @@ _touchHeight(0.0f),
|
|||
_useTouchArea(false),
|
||||
_textFieldEventListener(nullptr),
|
||||
_textFieldEventSelector(nullptr),
|
||||
_passwordStyleText("")
|
||||
_passwordStyleText(""),
|
||||
_textFieldRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -514,14 +515,15 @@ void TextField::setText(const std::string& text)
|
|||
{
|
||||
_textFieldRenderer->setString(content);
|
||||
}
|
||||
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
|
||||
void TextField::setPlaceHolder(const std::string& value)
|
||||
{
|
||||
_textFieldRenderer->setPlaceHolder(value);
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
|
||||
const std::string& TextField::getPlaceHolder()
|
||||
|
@ -532,7 +534,8 @@ const std::string& TextField::getPlaceHolder()
|
|||
void TextField::setFontSize(int size)
|
||||
{
|
||||
_textFieldRenderer->setSystemFontSize(size);
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
|
||||
int TextField::getFontSize()
|
||||
|
@ -543,7 +546,8 @@ int TextField::getFontSize()
|
|||
void TextField::setFontName(const std::string& name)
|
||||
{
|
||||
_textFieldRenderer->setSystemFontName(name);
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
|
||||
const std::string& TextField::getFontName()
|
||||
|
@ -634,14 +638,16 @@ void TextField::update(float dt)
|
|||
insertTextEvent();
|
||||
setInsertText(false);
|
||||
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
if (getDeleteBackward())
|
||||
{
|
||||
deleteBackwardEvent();
|
||||
setDeleteBackward(false);
|
||||
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,16 +729,19 @@ void TextField::addEventListenerTextField(Ref *target, SEL_TextFieldEvent seleco
|
|||
_textFieldEventSelector = selecor;
|
||||
}
|
||||
|
||||
void TextField::setAnchorPoint(const Vector2 &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_textFieldRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void TextField::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void TextField::adaptRenderers()
|
||||
{
|
||||
if (_textFieldRendererAdaptDirty)
|
||||
{
|
||||
textfieldRendererScaleChangedWithSize();
|
||||
_textFieldRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TextField::textfieldRendererScaleChangedWithSize()
|
||||
|
@ -741,7 +750,6 @@ void TextField::textfieldRendererScaleChangedWithSize()
|
|||
{
|
||||
_textFieldRenderer->setDimensions(0,0);
|
||||
_textFieldRenderer->setScale(1.0f);
|
||||
_size = getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -757,9 +765,10 @@ void TextField::textfieldRendererScaleChangedWithSize()
|
|||
_textFieldRenderer->setScaleX(scaleX);
|
||||
_textFieldRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
const Size& TextField::getContentSize() const
|
||||
const Size& TextField::getVirtualRendererSize() const
|
||||
{
|
||||
return _textFieldRenderer->getContentSize();
|
||||
}
|
||||
|
|
|
@ -146,14 +146,12 @@ public:
|
|||
void setDeleteBackward(bool deleteBackward);
|
||||
void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor);
|
||||
|
||||
virtual void setAnchorPoint(const Vector2 &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
virtual const Size& getContentSize() const override;
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
void attachWithIME();
|
||||
virtual void onEnter() override;
|
||||
|
@ -178,6 +176,7 @@ protected:
|
|||
void textfieldRendererScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
UICCTextField* _textFieldRenderer;
|
||||
|
||||
|
@ -189,6 +188,7 @@ protected:
|
|||
SEL_TextFieldEvent _textFieldEventSelector;
|
||||
|
||||
std::string _passwordStyleText;
|
||||
bool _textFieldRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ void Widget::visit(Renderer *renderer, const Matrix &parentTransform, bool paren
|
|||
{
|
||||
if (_enabled)
|
||||
{
|
||||
adaptRenderers();
|
||||
ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ void Widget::setSize(const Size &size)
|
|||
_customSize = size;
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
_size = getVirtualRendererSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -228,7 +229,7 @@ void Widget::setSizePercent(const Vector2 &percent)
|
|||
}
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
_size = getVirtualRendererSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -261,7 +262,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
_size = getVirtualRendererSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -285,7 +286,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
|
|||
Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y);
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = getContentSize();
|
||||
_size = getVirtualRendererSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -343,7 +344,7 @@ void Widget::ignoreContentAdaptWithSize(bool ignore)
|
|||
_ignoreSize = ignore;
|
||||
if (_ignoreSize)
|
||||
{
|
||||
Size s = getContentSize();
|
||||
Size s = getVirtualRendererSize();
|
||||
_size = s;
|
||||
}
|
||||
else
|
||||
|
@ -375,7 +376,7 @@ const Vector2& Widget::getSizePercent() const
|
|||
|
||||
Vector2 Widget::getWorldPosition()
|
||||
{
|
||||
return convertToWorldSpace(Vector2::ZERO);
|
||||
return convertToWorldSpace(Vector2(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height));
|
||||
}
|
||||
|
||||
Node* Widget::getVirtualRenderer()
|
||||
|
@ -385,6 +386,7 @@ Node* Widget::getVirtualRenderer()
|
|||
|
||||
void Widget::onSizeChanged()
|
||||
{
|
||||
setContentSize(_size);
|
||||
for (auto& child : getChildren())
|
||||
{
|
||||
Widget* widgetChild = dynamic_cast<Widget*>(child);
|
||||
|
@ -395,9 +397,22 @@ void Widget::onSizeChanged()
|
|||
}
|
||||
}
|
||||
|
||||
const Size& Widget::getContentSize() const
|
||||
const Size& Widget::getVirtualRendererSize() const
|
||||
{
|
||||
return _size;
|
||||
return _contentSize;
|
||||
}
|
||||
|
||||
void Widget::updateContentSizeWithTextureSize(const cocos2d::Size &size)
|
||||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_size = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
}
|
||||
onSizeChanged();
|
||||
}
|
||||
|
||||
void Widget::setTouchEnabled(bool enable)
|
||||
|
@ -617,8 +632,9 @@ void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector)
|
|||
bool Widget::hitTest(const Vector2 &pt)
|
||||
{
|
||||
Vector2 nsp = convertToNodeSpace(pt);
|
||||
Rect bb = Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height);
|
||||
if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
|
||||
Rect bb;
|
||||
bb.size = _contentSize;
|
||||
if (bb.containsPoint(nsp))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -712,11 +728,6 @@ void Widget::setPositionPercent(const Vector2 &percent)
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::updateAnchorPoint()
|
||||
{
|
||||
setAnchorPoint(getAnchorPoint());
|
||||
}
|
||||
|
||||
const Vector2& Widget::getPositionPercent()
|
||||
{
|
||||
return _positionPercent;
|
||||
|
|
|
@ -501,12 +501,15 @@ public:
|
|||
*/
|
||||
virtual Node* getVirtualRenderer();
|
||||
|
||||
/**
|
||||
* Gets the content size of widget.
|
||||
*
|
||||
* Content size is widget's texture size.
|
||||
*/
|
||||
virtual const Size& getContentSize() const;
|
||||
// /**
|
||||
// * Gets the content size of widget.
|
||||
// *
|
||||
// * Content size is widget's texture size.
|
||||
// */
|
||||
// virtual const Size& getContentSize() const;
|
||||
virtual const Size& getVirtualRendererSize() const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
|
@ -549,7 +552,6 @@ protected:
|
|||
void moveEvent();
|
||||
void releaseUpEvent();
|
||||
void cancelUpEvent();
|
||||
void updateAnchorPoint();
|
||||
virtual void updateTextureColor(){};
|
||||
virtual void updateTextureOpacity(){};
|
||||
virtual void updateTextureRGBA(){};
|
||||
|
@ -563,6 +565,8 @@ protected:
|
|||
virtual void copySpecialProperties(Widget* model);
|
||||
virtual void copyClonedWidgetChildren(Widget* model);
|
||||
Widget* getWidgetParent();
|
||||
void updateContentSizeWithTextureSize(const Size& size);
|
||||
virtual void adaptRenderers(){};
|
||||
protected:
|
||||
bool _enabled; ///< Highest control of widget
|
||||
bool _bright; ///< is this widget bright
|
||||
|
|
|
@ -264,12 +264,12 @@ static void editBoxCallbackFunc(const char* pText, void* ctx)
|
|||
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"ended",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "ended", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
|||
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
|
||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -187,8 +187,8 @@
|
|||
cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox);
|
||||
cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data);
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
memset(data.eventName, 0, sizeof(data.eventName));
|
||||
strncpy(data.eventName, "return", sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
|
|
|
@ -234,35 +234,6 @@ void EditBoxImplWin::visit(void)
|
|||
{
|
||||
}
|
||||
|
||||
static void editBoxCallbackFunc(const char* pText, void* ctx)
|
||||
{
|
||||
EditBoxImplWin* thiz = (EditBoxImplWin*)ctx;
|
||||
thiz->setText(pText);
|
||||
|
||||
if (thiz->getDelegate() != NULL)
|
||||
{
|
||||
thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText());
|
||||
thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox());
|
||||
thiz->getDelegate()->editBoxReturn(thiz->getEditBox());
|
||||
}
|
||||
|
||||
EditBox* pEditBox = thiz->getEditBox();
|
||||
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
|
||||
{
|
||||
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"ended",64);
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,64*sizeof(char));
|
||||
strncpy(data.eventName,"return",64);
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
void EditBoxImplWin::openKeyboard()
|
||||
{
|
||||
if (_delegate != NULL)
|
||||
|
@ -300,6 +271,26 @@ void EditBoxImplWin::openKeyboard()
|
|||
_delegate->editBoxEditingDidEnd(_editBox);
|
||||
_delegate->editBoxReturn(_editBox);
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
|
||||
{
|
||||
CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox);
|
||||
ScriptEvent event(kCommonEvent,(void*)&data);
|
||||
if (didChange)
|
||||
{
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"ended",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
memset(data.eventName,0,sizeof(data.eventName));
|
||||
strncpy(data.eventName,"return",sizeof(data.eventName));
|
||||
event.data = (void*)&data;
|
||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||
}
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
}
|
||||
|
||||
void EditBoxImplWin::closeKeyboard()
|
||||
|
|
|
@ -1 +1 @@
|
|||
dc1d98e73cda98024add3420a06fa29651c863d0
|
||||
ee8d6b9b640f55a31fff715702df4fed30b34540
|
|
@ -1 +1 @@
|
|||
9b09288998b6198388456c41ccbdd5596622abe5
|
||||
30f4d695532ecab63f94a54d52e0b4d61c910aa4
|
25
setup.py
25
setup.py
|
@ -521,6 +521,27 @@ class SetEnvVar(object):
|
|||
ret = self._force_update_unix_env(var_name, value)
|
||||
return ret
|
||||
|
||||
def _get_ant_path(self):
|
||||
print(" ->Find command ant in system...")
|
||||
ret = None
|
||||
if not self._isWindows():
|
||||
import commands
|
||||
state, result = commands.getstatusoutput("which ant")
|
||||
if state == 0:
|
||||
ret = os.path.dirname(result)
|
||||
|
||||
if ret is not None:
|
||||
print(" ->Path \"%s\" was found\n" % ret)
|
||||
else:
|
||||
print(" ->Command ant not found\n")
|
||||
return ret
|
||||
|
||||
def _find_value_from_sys(self, var_name):
|
||||
if var_name == ANT_ROOT:
|
||||
return self._get_ant_path()
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_variable(self, var_name, value):
|
||||
print("->Check environment variable %s" % var_name)
|
||||
find_value = self._find_environment_variable(var_name)
|
||||
|
@ -538,6 +559,10 @@ class SetEnvVar(object):
|
|||
# do nothing
|
||||
need_action = action_none
|
||||
else:
|
||||
if not value:
|
||||
# find the command path in system
|
||||
value = self._find_value_from_sys(var_name)
|
||||
|
||||
if not value:
|
||||
value = self._get_input_value(var_name)
|
||||
|
||||
|
|
|
@ -32,13 +32,20 @@ import java.net.SocketException;
|
|||
import java.util.Enumeration;
|
||||
|
||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -47,20 +54,36 @@ import android.widget.Toast;
|
|||
|
||||
public class AppActivity extends Cocos2dxActivity{
|
||||
|
||||
static String hostIPAdress="0.0.0.0";
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//2.Set the format of window
|
||||
// getWindow().setFormat(PixelFormat.TRANSLUCENT);
|
||||
if(!isWifiConnected())
|
||||
{
|
||||
Toast.makeText(this, "wifi is closed!", Toast.LENGTH_SHORT).show();
|
||||
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
}
|
||||
}
|
||||
|
||||
// Check the wifi is opened when the android:debuggable is "true".
|
||||
if(0!=((this.getApplicationInfo().flags) & ApplicationInfo.FLAG_DEBUGGABLE))
|
||||
{
|
||||
if(!isWifiConnected())
|
||||
{
|
||||
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||
builder.setTitle("Warning");
|
||||
builder.setMessage("Open Wifi for debuging...");
|
||||
builder.setPositiveButton("OK",new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setCancelable(false);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
hostIPAdress = getHostIpAddress();
|
||||
}
|
||||
private boolean isWifiConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm != null) {
|
||||
|
@ -72,23 +95,15 @@ public class AppActivity extends Cocos2dxActivity{
|
|||
return false;
|
||||
}
|
||||
|
||||
public String getHostIpAddress() {
|
||||
WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
|
||||
int ip = wifiInfo.getIpAddress();
|
||||
return ((ip & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF));
|
||||
}
|
||||
|
||||
public static String getLocalIpAddress() {
|
||||
try {
|
||||
for (Enumeration<NetworkInterface> en = NetworkInterface
|
||||
.getNetworkInterfaces(); en.hasMoreElements();) {
|
||||
NetworkInterface intf = en.nextElement();
|
||||
for (Enumeration<InetAddress> enumIpAddr = intf
|
||||
.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||
if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) {
|
||||
return inetAddress.getHostAddress().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException ex) {
|
||||
Log.e("WifiPreference IpAddress", ex.toString());
|
||||
}
|
||||
return null;
|
||||
return hostIPAdress;
|
||||
}
|
||||
|
||||
public static String getSDCardPath() {
|
||||
|
@ -100,4 +115,3 @@ public class AppActivity extends Cocos2dxActivity{
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ bool UIButtonTest_Scale9::init()
|
|||
// open scale9 render
|
||||
button->setScale9Enabled(true);
|
||||
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||
button->setSize(Size(150, button->getContentSize().height * 1.5f));
|
||||
button->setSize(Size(150, 70));
|
||||
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
|
||||
_uiLayer->addChild(button);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ bool UIImageViewTest::init()
|
|||
// Create the imageview
|
||||
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||
imageView->setPosition(Vector2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f));
|
||||
|
||||
_uiLayer->addChild(imageView);
|
||||
|
||||
|
@ -53,7 +53,7 @@ bool UIImageViewTest_Scale9::init()
|
|||
imageView->setScale9Enabled(true);
|
||||
imageView->setSize(Size(300, 115));
|
||||
imageView->setPosition(Vector2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
||||
widgetSize.height / 2.0f));
|
||||
|
||||
_uiLayer->addChild(imageView);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ bool UILayoutTest::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
|
||||
|
@ -118,7 +118,7 @@ bool UILayoutTest_Color::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool UILayoutTest_Gradient::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
|
||||
|
@ -243,7 +243,7 @@ bool UILayoutTest_BackGroundImage::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
|
||||
|
@ -305,7 +305,7 @@ bool UILayoutTest_BackGroundImage_Scale9::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||
button_scale9->getSize().height / 2.0f));
|
||||
layout->addChild(button_scale9);
|
||||
|
@ -376,7 +376,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
LinearLayoutParameter* lp3 = LinearLayoutParameter::create();
|
||||
|
@ -450,7 +450,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
layout->addChild(button_scale9);
|
||||
|
||||
LinearLayoutParameter* lp3 = LinearLayoutParameter::create();
|
||||
|
|
|
@ -193,7 +193,7 @@ bool UILoadingBarTest_Left_Scale9::init()
|
|||
loadingBar->setTag(0);
|
||||
loadingBar->setScale9Enabled(true);
|
||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
||||
loadingBar->setSize(Size(300, 13));
|
||||
|
||||
loadingBar->setPosition(Vector2(widgetSize.width / 2.0f,
|
||||
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||
|
@ -275,7 +275,7 @@ bool UILoadingBarTest_Right_Scale9::init()
|
|||
loadingBar->setTag(0);
|
||||
loadingBar->setScale9Enabled(true);
|
||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
||||
loadingBar->setSize(Size(300, 13));
|
||||
loadingBar->setDirection(LoadingBarTypeRight);
|
||||
|
||||
loadingBar->setPosition(Vector2(widgetSize.width / 2.0f,
|
||||
|
|
|
@ -65,7 +65,7 @@ bool UIScrollViewTest_Vertical::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
||||
|
@ -143,7 +143,7 @@ bool UIScrollViewTest_Horizontal::init()
|
|||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vector2(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f,
|
||||
titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
|
|
@ -102,7 +102,7 @@ void HttpClientTest::onMenuGetTestClicked(cocos2d::Ref *sender)
|
|||
// test 3
|
||||
{
|
||||
HttpRequest* request = new HttpRequest();
|
||||
request->setUrl("http://httpbin.org/get");
|
||||
request->setUrl("https://httpbin.org/get");
|
||||
request->setRequestType(HttpRequest::Type::GET);
|
||||
request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
|
||||
request->setTag("GET test3");
|
||||
|
|
|
@ -1 +1 @@
|
|||
c43e2d2b4092953dba18fe8223330eb29809bb01
|
||||
1f20f88e2a2985963fc6a2d89ea07be41e8e74d0
|
|
@ -1 +1 @@
|
|||
Subproject commit b594698b5974304694e990cfd63887564d877c53
|
||||
Subproject commit 70fa1ec93b56f535b9714392ddee7ca53c220bb1
|
|
@ -0,0 +1,32 @@
|
|||
import os
|
||||
import json
|
||||
import requests
|
||||
import jenkinsapi
|
||||
from jenkinsapi.jenkins import Jenkins
|
||||
from jenkinsapi.constants import STATUS_SUCCESS
|
||||
|
||||
payload_str = os.environ['payload']
|
||||
payload_str = payload_str.decode('utf-8','ignore')
|
||||
#parse to json obj
|
||||
payload = json.loads(payload_str)
|
||||
#pr = payload['pull_request']
|
||||
url = payload['html_url']
|
||||
print "build pr:" + url
|
||||
#get comments url
|
||||
comments_url = payload['comments_url']
|
||||
|
||||
J = Jenkins(os.environ['JENKINS_URL'])
|
||||
target_url = os.environ['BUILD_URL']
|
||||
build_number = int(os.environ['BUILD_NUMBER'])
|
||||
data = {}
|
||||
access_token = os.environ['GITHUB_COMMENT_ACCESS_TOKEN']
|
||||
Headers = {"Authorization":"token " + access_token}
|
||||
|
||||
result = J[os.environ['JOB_NAME']].get_build(build_number).get_status()
|
||||
|
||||
if(result == STATUS_SUCCESS):
|
||||
data['body'] = "Emptytest run successfully: " + target_url
|
||||
else:
|
||||
data['body'] = "Emptytest failed: " + target_url
|
||||
|
||||
requests.post(comments_url, data=json.dumps(data), headers=Headers)
|
|
@ -24,13 +24,13 @@ def main():
|
|||
#get comment body
|
||||
comment_body = comment['body']
|
||||
print comment_body
|
||||
pattern = re.compile("\[ci(\s+)rebuild\]", re.I)
|
||||
result = pattern.search(comment_body)
|
||||
#will check 'ci' comment
|
||||
searchCI = re.search("\[ci.*\]", comment_body)
|
||||
|
||||
# will check console/console create
|
||||
#will check console/console create
|
||||
searchConsole = re.search('\[console.*\]', comment_body)
|
||||
|
||||
if result is None and searchConsole is None:
|
||||
if searchCI is None and searchConsole is None:
|
||||
print 'skip build for pull request #' + str(pr_num)
|
||||
return(0)
|
||||
|
||||
|
@ -57,6 +57,10 @@ def main():
|
|||
statuses_url = repository['statuses_url']
|
||||
payload_forword['statuses_url'] = statuses_url
|
||||
print 'statuses_url: ' + statuses_url
|
||||
#get comments url
|
||||
comments_url = repository['comments_url']
|
||||
payload_forword['comments_url'] = comments_url
|
||||
print 'comments_url: ' + comments_url
|
||||
|
||||
#get pr target branch
|
||||
branch = repository['base']['ref']
|
||||
|
@ -75,16 +79,23 @@ def main():
|
|||
Headers = {"Authorization":"token " + access_token}
|
||||
|
||||
try:
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
if searchCI:
|
||||
ciOper = searchCI.group()
|
||||
if('rebuild' in ciOper):
|
||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
job_trigger_url = ''
|
||||
if result:
|
||||
job_trigger_url = os.environ['JOB_TRIGGER_URL']
|
||||
if searchCI:
|
||||
ciOper = searchCI.group()
|
||||
if('rebuild' in ciOper):
|
||||
job_trigger_url = os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL']
|
||||
if('emptytest' in ciOper):
|
||||
job_trigger_url = os.environ['JOB_EMPTYTEST_TRIGGER_URL']
|
||||
if searchConsole:
|
||||
consoleOper = searchConsole.group()
|
||||
job_trigger_url = os.environ['JOB_CONSOLE_TEST_URL']
|
||||
job_trigger_url = os.environ['JOB_CONSOLE_TEST_TRIGGER_URL']
|
||||
payload_forword['console'] = consoleOper
|
||||
print 'job_trigger_url is: ', job_trigger_url
|
||||
|
||||
|
|
|
@ -146,6 +146,11 @@ def main():
|
|||
data = codecs.open(modify_file, encoding='UTF-8').read()
|
||||
data = re.sub("director->setDisplayStats\(true\);", "director->setDisplayStats(true); director->getConsole()->listenOnTCP(5678);", data)
|
||||
codecs.open(modify_file, 'wb', encoding='UTF-8').write(data)
|
||||
#modify tests/cpp-empty-test/proj.android/AndroidManifest.xml to support Console
|
||||
modify_file = 'tests/cpp-empty-test/proj.android/AndroidManifest.xml'
|
||||
data = codecs.open(modify_file, encoding='UTF-8').read()
|
||||
data = re.sub('<uses-feature android:glEsVersion="0x00020000" />', '<uses-feature android:glEsVersion="0x00020000" /> <uses-permission android:name="android.permission.INTERNET"/>', data)
|
||||
codecs.open(modify_file, 'wb', encoding='UTF-8').write(data)
|
||||
print "Start build android..."
|
||||
ret = os.system("python build/android-build.py -n -j10 all")
|
||||
# create and save apk
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
#!/bin/sh
|
||||
localfile=$1
|
||||
remotefile=$2
|
||||
|
||||
sftp redmine@10.10.11.15 << EOF
|
||||
sftp $FTP_HOME << EOF
|
||||
put $localfile $remotefile
|
||||
bye
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue