Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2770_fix_warnings

This commit is contained in:
boyu0 2013-11-12 18:22:26 +08:00
commit 15c8c04f3a
48 changed files with 2005 additions and 1534 deletions

View File

@ -642,6 +642,7 @@ Developers:
ledyba ledyba
Fixed a bug that EventListeners can't be removed sometimes. Fixed a bug that EventListeners can't be removed sometimes.
Fixed a bug that the data size has to be specified when parsing XML using TinyXML. Fixed a bug that the data size has to be specified when parsing XML using TinyXML.
Closed X display after getting DPI on Linux.
Luis Parravicini (luisparravicini) Luis Parravicini (luisparravicini)
Fixed typos in create_project.py. Fixed typos in create_project.py.
@ -649,6 +650,9 @@ Developers:
xhcnb xhcnb
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
bopohaa
Fixed a bug that Webp test crashes.
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang
Author of windows port, CCTextField, Author of windows port, CCTextField,

View File

@ -20,6 +20,7 @@ cocos2d-x-3.0alpha1 @??? 2013
[NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] Sprite: Override setScale(float scaleX, float scaleY)
[NEW] External: added | operator for Control::EventType [NEW] External: added | operator for Control::EventType
[NEW] Android & iOS screen size change support [NEW] Android & iOS screen size change support
[FIX] Webp Test Crashes.
[Android] [Android]
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
[FIX] Fixed application will crash when pause and resume. [FIX] Fixed application will crash when pause and resume.
@ -34,6 +35,7 @@ cocos2d-x-3.0alpha1 @??? 2013
[FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox. [FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox.
[Linux] [Linux]
[NEW] Used CMake to build linux projects. [NEW] Used CMake to build linux projects.
[FIX] Closed X display after getting DPI on Linux.
[Desktop] [Desktop]
[FIX] Trigger onKeyReleased only after the key has been released. [FIX] Trigger onKeyReleased only after the key has been released.
[Javascript binding] [Javascript binding]

View File

@ -103,8 +103,8 @@ $ cmake ..
$ make $ make
``` ```
You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target,
`install-deps-linux.sh` only has to be run onece. you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run onece.
* For Windows * For Windows

View File

@ -15,11 +15,12 @@ ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES
def usage(): def usage():
print "%prog [-n ndk-build-parameter] target\n\ print """%s [-n ndk-build-parameter] target.
valid target are [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon\
|crystalcraze|moonwarriors|testjavascript|watermelonwithme], of course you can use 'cpp'\ Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon
to build all cpp samples, 'lua' to build all lua samples, 'jsb' to build all javascript samples,\ |crystalcraze|moonwarriors|testjavascript|watermelonwithme]
and 'all' for all samples"
You can use [all|cpp|lua|jsb], to build all, or all the C++, or all the Lua, or all the JavaScript samples respectevely.""" % sys.argv[0]
def check_environment_variables(): def check_environment_variables():
''' Checking the environment NDK_ROOT, which will be used for building ''' Checking the environment NDK_ROOT, which will be used for building
@ -132,13 +133,26 @@ def copy_resources(target, app_android_root):
resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android") resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android")
if target == "crystalcraze": if target == "crystalcraze":
resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android") resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android")
if target == "moonwarriors":
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res")
if target == "testjavascript": if target == "testjavascript":
resources_dir = os.path.join(app_android_root, "../../Shared/tests/") resources_dir = os.path.join(app_android_root, "../../Shared/tests/")
if target == "watermelonwithme": if target == "watermelonwithme":
resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe") resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe")
if target != "moonwarriors":
copy_files(resources_dir, assets_dir) copy_files(resources_dir, assets_dir)
else:
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res")
dst_dir = os.path.join(assets_dir, "res")
os.mkdir(dst_dir)
copy_files(resources_dir, dst_dir)
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/src")
dst_dir = os.path.join(assets_dir, "src")
os.mkdir(dst_dir)
copy_files(resources_dir, dst_dir)
resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors")
for item in os.listdir(resources_dir):
path = os.path.join(resources_dir, item)
if item.endswith('.js') and os.path.isfile(path):
shutil.copy(path, assets_dir)
# AssetsManager test should also copy javascript files # AssetsManager test should also copy javascript files
if target == "assetsmanager": if target == "assetsmanager":

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "CCTMXXMLParser.h" #include "CCTMXXMLParser.h"
#include "CCTMXLayer.h" #include "CCTMXLayer.h"
#include "CCSprite.h" #include "CCSprite.h"
#include <algorithm>
NS_CC_BEGIN NS_CC_BEGIN

View File

@ -1737,12 +1737,12 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
_width = config.input.width; _width = config.input.width;
_height = config.input.height; _height = config.input.height;
int bufferSize = _width * _height * 4; _dataLen = _width * _height * 4;
_data = new unsigned char[bufferSize]; _data = new unsigned char[_dataLen];
config.output.u.RGBA.rgba = static_cast<uint8_t*>(_data); config.output.u.RGBA.rgba = static_cast<uint8_t*>(_data);
config.output.u.RGBA.stride = _width * 4; config.output.u.RGBA.stride = _width * 4;
config.output.u.RGBA.size = bufferSize; config.output.u.RGBA.size = _dataLen;
config.output.is_external_memory = 1; config.output.is_external_memory = 1;
if (WebPDecode(static_cast<const uint8_t*>(data), dataLen, &config) != VP8_STATUS_OK) if (WebPDecode(static_cast<const uint8_t*>(data), dataLen, &config) != VP8_STATUS_OK)

View File

@ -37,8 +37,10 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
- (id) init - (id) init
{ {
if( (self = [super init]) ) {
_acceleration = new cocos2d::Acceleration(); _acceleration = new cocos2d::Acceleration();
_motionManager = [[CMMotionManager alloc] init]; _motionManager = [[CMMotionManager alloc] init];
}
return self; return self;
} }

View File

@ -24,6 +24,7 @@ int Device::getDPI()
((double) DisplayWidthMM(dpy,scr))); ((double) DisplayWidthMM(dpy,scr)));
dpi = (int) (xres + 0.5); dpi = (int) (xres + 0.5);
//printf("dpi = %d\n", dpi); //printf("dpi = %d\n", dpi);
XCloseDisplay (dpy);
} }
return dpi; return dpi;
} }

View File

@ -121,7 +121,7 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const
return false; return false;
} }
unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, unsigned long* size) unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, long* size)
{ {
unsigned char * pBuffer = NULL; unsigned char * pBuffer = NULL;
CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters.");

View File

@ -58,7 +58,7 @@ protected:
* @return Upon success, a pointer to the data is returned, otherwise NULL. * @return Upon success, a pointer to the data is returned, otherwise NULL.
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
*/ */
virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size) override; virtual unsigned char* getFileData(const char* filename, const char* mode, long * size) override;
/** /**
* Gets full path for filename, resolution directory and search path. * Gets full path for filename, resolution directory and search path.

View File

@ -56,6 +56,7 @@ ArmatureAnimation::ArmatureAnimation()
, _toIndex(0) , _toIndex(0)
, _tweenList(nullptr) , _tweenList(nullptr)
, _ignoreFrameEvent(false) , _ignoreFrameEvent(false)
, _userObject(nullptr)
, _movementEventCallFunc(nullptr) , _movementEventCallFunc(nullptr)
, _frameEventCallFunc(nullptr) , _frameEventCallFunc(nullptr)
@ -70,8 +71,7 @@ ArmatureAnimation::~ArmatureAnimation(void)
CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_tweenList);
CC_SAFE_RELEASE_NULL(_animationData); CC_SAFE_RELEASE_NULL(_animationData);
CC_SAFE_RELEASE_NULL(_movementEventTarget); CC_SAFE_RELEASE_NULL(_userObject);
CC_SAFE_RELEASE_NULL(_frameEventTarget);
} }
bool ArmatureAnimation::init(Armature *armature) bool ArmatureAnimation::init(Armature *armature)
@ -208,7 +208,7 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
loop = (loop < 0) ? _movementData->loop : loop; loop = (loop < 0) ? _movementData->loop : loop;
ProcessBase::play((void *)animationName, durationTo, durationTween, loop, tweenEasing); ProcessBase::play(durationTo, durationTween, loop, tweenEasing);
if (_rawDuration == 0) if (_rawDuration == 0)
@ -423,26 +423,23 @@ std::string ArmatureAnimation::getCurrentMovementID() const
void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc) void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc)
{ {
if (target != _movementEventTarget)
{
CC_SAFE_RETAIN(target);
CC_SAFE_RELEASE_NULL(_movementEventTarget);
_movementEventTarget = target; _movementEventTarget = target;
}
_movementEventCallFunc = callFunc; _movementEventCallFunc = callFunc;
} }
void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc) void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc)
{ {
if (target != _frameEventTarget)
{
CC_SAFE_RETAIN(target);
CC_SAFE_RELEASE_NULL(_frameEventTarget);
_frameEventTarget = target; _frameEventTarget = target;
}
_frameEventCallFunc = callFunc; _frameEventCallFunc = callFunc;
} }
void ArmatureAnimation::setUserObject(Object *pUserObject)
{
CC_SAFE_RETAIN(pUserObject);
CC_SAFE_RELEASE(_userObject);
_userObject = pUserObject;
}
void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)
{ {
if (_frameEventTarget && _frameEventCallFunc) if (_frameEventTarget && _frameEventCallFunc)

View File

@ -100,6 +100,7 @@ public:
//! The animation update speed //! The animation update speed
virtual void setAnimationInternal(float animationInternal); virtual void setAnimationInternal(float animationInternal);
using ProcessBase::play;
/** /**
* Play animation by animation name. * Play animation by animation name.
* *
@ -202,6 +203,35 @@ public:
} }
} }
virtual AnimationData *getAnimationData() const { return _animationData; } virtual AnimationData *getAnimationData() const { return _animationData; }
/**
* Returns a user assigned Object
*
* Similar to userData, but instead of holding a void* it holds an object
*
* @return A user assigned Object
* @js NA
* @lua NA
*/
virtual Object* getUserObject() { return _userObject; }
/**
* @js NA
* @lua NA
*/
virtual const Object* getUserObject() const { return _userObject; }
/**
* Returns a user assigned Object
*
* Similar to UserData, but instead of holding a void* it holds an object.
* The UserObject will be retained once in this method,
* and the previous UserObject (if existed) will be relese.
* The UserObject will be released in Node's destructure.
*
* @param userObject A user assigned Object
*/
virtual void setUserObject(Object *userObject);
protected: protected:
/** /**
@ -242,6 +272,8 @@ protected:
bool _ignoreFrameEvent; bool _ignoreFrameEvent;
std::queue<FrameEvent*> _frameEventQueue; std::queue<FrameEvent*> _frameEventQueue;
cocos2d::Object *_userObject;
protected: protected:
/** /**
* MovementEvent CallFunc. * MovementEvent CallFunc.

View File

@ -112,6 +112,7 @@ public:
*/ */
Bone *getParentBone(); Bone *getParentBone();
using Node::removeFromParent;
/** /**
* Remove itself from its parent. * Remove itself from its parent.
* @param recursion whether or not to remove childBone's display * @param recursion whether or not to remove childBone's display

View File

@ -594,10 +594,10 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
if (parentName) if (parentName)
{ {
parentXML = armatureXML->FirstChildElement(BONE); parentXML = armatureXML->FirstChildElement(BONE);
std::string name = parentName; std::string parentNameStr = parentName;
while (parentXML) while (parentXML)
{ {
if (name.compare(parentXML->Attribute(A_NAME)) == 0) if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0)
{ {
break; break;
} }
@ -822,7 +822,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
} }
int length = 0; int length = 0;
int i = 0; int index = 0;
int parentTotalDuration = 0; int parentTotalDuration = 0;
int currentDuration = 0; int currentDuration = 0;
@ -863,13 +863,12 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
/* /*
* in this loop we get the corresponding parent frame xml * in this loop we get the corresponding parent frame xml
*/ */
while(i < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) while(index < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true))
{ {
parentFrameXML = parentXmlList[i]; parentFrameXML = parentXmlList[index];
parentTotalDuration += currentDuration; parentTotalDuration += currentDuration;
parentFrameXML->QueryIntAttribute(A_DURATION, &currentDuration); parentFrameXML->QueryIntAttribute(A_DURATION, &currentDuration);
i++; index++;
} }
} }

View File

@ -163,10 +163,8 @@ public:
*/ */
virtual ~SpriteDisplayData(); virtual ~SpriteDisplayData();
inline void setParam(const char *name) void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; }
{
this->displayName = name;
}
void copy(SpriteDisplayData *displayData); void copy(SpriteDisplayData *displayData);
public: public:
/** /**
@ -197,10 +195,7 @@ public:
*/ */
virtual ~ArmatureDisplayData(); virtual ~ArmatureDisplayData();
inline void setParam(const char *name) void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; }
{
this->displayName = name;
}
void copy(ArmatureDisplayData *displayData); void copy(ArmatureDisplayData *displayData);
public: public:
/** /**
@ -230,10 +225,7 @@ public:
*/ */
virtual ~ParticleDisplayData() {}; virtual ~ParticleDisplayData() {};
void setParam(const char *aPlist) void setParam(const char *pszPlistName) { this->plist = pszPlistName; }
{
this->plist = aPlist;
}
void copy(ParticleDisplayData *displayData); void copy(ParticleDisplayData *displayData);
public: public:
@ -478,10 +470,10 @@ public:
struct ContourVertex2 : public cocos2d::Object struct ContourVertex2 : public cocos2d::Object
{ {
ContourVertex2(float ax, float ay) ContourVertex2(float xx, float yy)
{ {
this->x = ax; this->x = xx;
this->y = ay; this->y = yy;
} }
float x; float x;

View File

@ -141,11 +141,29 @@ void DisplayManager::addDisplay(Node *display, int index)
((SpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData; ((SpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData;
} }
else else
{
bool find = false;
for (int i = _decoDisplayList->count()-2; i>=0; i--)
{
DecorativeDisplay *dd = static_cast<DecorativeDisplay*>(_decoDisplayList->getObjectAtIndex(i));
SpriteDisplayData *sdd = static_cast<SpriteDisplayData*>(dd->getDisplayData());
if (sdd)
{
find = true;
skin->setSkinData(sdd->skinData);
static_cast<SpriteDisplayData*>(displayData)->skinData = sdd->skinData;
break;
}
}
if (!find)
{ {
BaseData baseData; BaseData baseData;
skin->setSkinData(baseData); skin->setSkinData(baseData);
} }
} }
}
else if (dynamic_cast<ParticleSystemQuad *>(display)) else if (dynamic_cast<ParticleSystemQuad *>(display))
{ {
displayData = ParticleDisplayData::create(); displayData = ParticleDisplayData::create();

View File

@ -77,7 +77,7 @@ void ProcessBase::stop()
_currentPercent = 0; _currentPercent = 0;
} }
void ProcessBase::play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing) void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEasing)
{ {
_isComplete = false; _isComplete = false;
_isPause = false; _isPause = false;

View File

@ -63,7 +63,6 @@ public:
/** /**
* Play animation by animation name. * Play animation by animation name.
* *
* @param animation It will not used in the ProcessBase Class
* @param durationTo The frames between two animation changing-over. * @param durationTo The frames between two animation changing-over.
* It's meaning is changing to this animation need how many frames * It's meaning is changing to this animation need how many frames
* *
@ -88,7 +87,7 @@ public:
* 2 : fade in and out * 2 : fade in and out
* *
*/ */
virtual void play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing); virtual void play(int durationTo, int durationTween, int loop, int tweenEasing);
/** /**
* Pause the Process * Pause the Process

File diff suppressed because it is too large Load Diff

View File

@ -31,49 +31,90 @@
namespace cocostudio { namespace cocostudio {
#define kCCSVersion 1.0 #define kCCSVersion 1.0
class CCSGUIReader : cocos2d::Object class GUIReader : public cocos2d::Object
{ {
public: public:
CCSGUIReader(); GUIReader();
~CCSGUIReader(); ~GUIReader();
static CCSGUIReader* shareReader(); static GUIReader* shareReader();
static void purgeCCSGUIReader(); static void purgeGUIReader();
gui::UIWidget* widgetFromJsonFile(const char* fileName); gui::UIWidget* widgetFromJsonFile(const char* fileName);
gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* data);
int getVersionInteger(const char* str); int getVersionInteger(const char* str);
void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForContainerWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForTextAreaFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForTextButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForImageButtonFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options);
void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options);
void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void setPropsForDragPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
void storeFileDesignSize(const char* fileName, const cocos2d::Size &size); void storeFileDesignSize(const char* fileName, const cocos2d::Size &size);
const cocos2d::Size getFileDesignSize(const char* fileName) const; const cocos2d::Size getFileDesignSize(const char* fileName) const;
protected: protected:
std::string m_strFilePath; std::string m_strFilePath;
bool m_bOlderVersion;
cocos2d::Dictionary* _fileDesignSizes; cocos2d::Dictionary* _fileDesignSizes;
}; };
class WidgetPropertiesReader : public cocos2d::Object
{
public:
virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName)=0;
virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic) = 0;
protected:
std::string m_strFilePath;
};
class WidgetPropertiesReader0250 : public WidgetPropertiesReader
{
public:
WidgetPropertiesReader0250(){};
virtual ~WidgetPropertiesReader0250(){};
virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName);
virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic);
virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
};
class WidgetPropertiesReader0300 : public WidgetPropertiesReader
{
public:
WidgetPropertiesReader0300(){};
virtual ~WidgetPropertiesReader0300(){};
virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName);
virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic);
virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options);
virtual void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options);
};
} }

View File

@ -98,7 +98,7 @@ bool Tween::init(Bone *bone)
void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing) void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing)
{ {
ProcessBase::play(nullptr, durationTo, durationTween, loop, tweenEasing); ProcessBase::play(durationTo, durationTween, loop, tweenEasing);
if (loop) if (loop)
{ {

View File

@ -59,6 +59,7 @@ public:
*/ */
virtual bool init(Bone *bone); virtual bool init(Bone *bone);
using ProcessBase::play;
/** /**
* Start the Process * Start the Process
* *

View File

@ -34,8 +34,8 @@ _frontCrossRenderer(NULL),
_backGroundBoxDisabledRenderer(NULL), _backGroundBoxDisabledRenderer(NULL),
_frontCrossDisabledRenderer(NULL), _frontCrossDisabledRenderer(NULL),
_isSelected(true), _isSelected(true),
_selectedStateEventListener(NULL), _checkBoxEventListener(NULL),
_selectedStateEventSelector(NULL), _checkBoxEventSelector(NULL),
_backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundTexType(UI_TEX_TYPE_LOCAL),
_backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL),
_frontCrossTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL),
@ -51,8 +51,8 @@ _frontCrossDisabledFileName("")
UICheckBox::~UICheckBox() UICheckBox::~UICheckBox()
{ {
_selectedStateEventListener = NULL; _checkBoxEventListener = NULL;
_selectedStateEventSelector = NULL; _checkBoxEventSelector = NULL;
} }
UICheckBox* UICheckBox::create() UICheckBox* UICheckBox::create()
@ -285,24 +285,24 @@ bool UICheckBox::getSelectedState()
void UICheckBox::selectedEvent() void UICheckBox::selectedEvent()
{ {
if (_selectedStateEventListener && _selectedStateEventSelector) if (_checkBoxEventListener && _checkBoxEventSelector)
{ {
(_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED);
} }
} }
void UICheckBox::unSelectedEvent() void UICheckBox::unSelectedEvent()
{ {
if (_selectedStateEventListener && _selectedStateEventSelector) if (_checkBoxEventListener && _checkBoxEventSelector)
{ {
(_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED);
} }
} }
void UICheckBox::addEventListener(cocos2d::Object *target, SEL_SelectedStateEvent selector) void UICheckBox::addEventListenerCheckBox(cocos2d::Object *target, SEL_SelectedStateEvent selector)
{ {
_selectedStateEventListener = target; _checkBoxEventListener = target;
_selectedStateEventSelector = selector; _checkBoxEventSelector = selector;
} }
void UICheckBox::setFlipX(bool flipX) void UICheckBox::setFlipX(bool flipX)

View File

@ -138,7 +138,7 @@ public:
virtual void setAnchorPoint(const cocos2d::Point &pt); virtual void setAnchorPoint(const cocos2d::Point &pt);
//add a call back function would called when checkbox is selected or unselected. //add a call back function would called when checkbox is selected or unselected.
void addEventListener(cocos2d::Object* target,SEL_SelectedStateEvent selector); void addEventListenerCheckBox(cocos2d::Object* target,SEL_SelectedStateEvent selector);
//override "setFlipX" method of widget. //override "setFlipX" method of widget.
virtual void setFlipX(bool flipX); virtual void setFlipX(bool flipX);
@ -190,8 +190,8 @@ protected:
cocos2d::Sprite* _frontCrossDisabledRenderer; cocos2d::Sprite* _frontCrossDisabledRenderer;
bool _isSelected; bool _isSelected;
cocos2d::Object* _selectedStateEventListener; cocos2d::Object* _checkBoxEventListener;
SEL_SelectedStateEvent _selectedStateEventSelector; SEL_SelectedStateEvent _checkBoxEventSelector;
TextureResType _backGroundTexType; TextureResType _backGroundTexType;
TextureResType _backGroundSelectedTexType; TextureResType _backGroundSelectedTexType;

View File

@ -129,7 +129,17 @@ void UILayout::setClippingEnabled(bool able)
void UILayout::onSizeChanged() void UILayout::onSizeChanged()
{ {
DYNAMIC_CAST_CLIPPINGLAYER->setClippingSize(_size); DYNAMIC_CAST_CLIPPINGLAYER->setClippingSize(_size);
if (strcmp(getDescription(), "Layout") == 0)
{
cocos2d::ccArray* arrayChildren = _children->data;
int length = arrayChildren->num;
for (int i=0; i<length; ++i)
{
UIWidget* child = (UIWidget*)arrayChildren->arr[i];
child->updateSizeAndPosition();
}
doLayout(); doLayout();
}
if (_backGroundImage) if (_backGroundImage)
{ {
_backGroundImage->setPosition(cocos2d::Point(_size.width/2.0f, _size.height/2.0f)); _backGroundImage->setPosition(cocos2d::Point(_size.width/2.0f, _size.height/2.0f));
@ -953,7 +963,7 @@ bool UIRectClippingNode::init()
rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height);
rect[3] = cocos2d::Point(0, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height);
cocos2d::Color4F green = {0, 1, 0, 1}; cocos2d::Color4F green(0, 1, 0, 1);
_innerStencil->drawPolygon(rect, 4, green, 0, green); _innerStencil->drawPolygon(rect, 4, green, 0, green);
if (cocos2d::ClippingNode::init(_innerStencil)) if (cocos2d::ClippingNode::init(_innerStencil))
{ {
@ -971,7 +981,7 @@ void UIRectClippingNode::setClippingSize(const cocos2d::Size &size)
rect[1] = cocos2d::Point(_clippingSize.width, 0); rect[1] = cocos2d::Point(_clippingSize.width, 0);
rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height);
rect[3] = cocos2d::Point(0, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height);
cocos2d::Color4F green = {0, 1, 0, 1}; cocos2d::Color4F green(0, 1, 0, 1);
_innerStencil->clear(); _innerStencil->clear();
_innerStencil->drawPolygon(rect, 4, green, 0, green); _innerStencil->drawPolygon(rect, 4, green, 0, green);
} }

View File

@ -32,7 +32,10 @@ UIListView::UIListView():
_model(NULL), _model(NULL),
_items(NULL), _items(NULL),
_gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL),
_itemsMargin(0.0f) _itemsMargin(0.0f),
_listViewEventListener(NULL),
_listViewEventSelector(NULL),
_curSelectedIndex(0)
{ {
} }
@ -41,6 +44,8 @@ UIListView::~UIListView()
{ {
_items->removeAllObjects(); _items->removeAllObjects();
CC_SAFE_RELEASE(_items); CC_SAFE_RELEASE(_items);
_listViewEventListener = NULL;
_listViewEventSelector = NULL;
} }
UIListView* UIListView::create() UIListView* UIListView::create()
@ -376,7 +381,44 @@ void UIListView::refreshView()
remedyLayoutParameter(item); remedyLayoutParameter(item);
} }
updateInnerContainerSize(); updateInnerContainerSize();
doLayout(); }
void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector)
{
_listViewEventListener = target;
_listViewEventSelector = selector;
}
void UIListView::selectedItemEvent()
{
if (_listViewEventListener && _listViewEventSelector)
{
(_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECEDTITEM);
}
}
void UIListView::interceptTouchEvent(int handleState, gui::UIWidget *sender, const cocos2d::Point &touchPoint)
{
UIScrollView::interceptTouchEvent(handleState, sender, touchPoint);
if (handleState != 1)
{
UIWidget* parent = sender;
while (parent)
{
if (parent && parent->getParent() == _innerContainer)
{
_curSelectedIndex = getIndex(parent);
break;
}
parent = parent->getParent();
}
selectedItemEvent();
}
}
int UIListView::getCurSelectedIndex() const
{
return _curSelectedIndex;
} }
void UIListView::onSizeChanged() void UIListView::onSizeChanged()

View File

@ -41,6 +41,14 @@ typedef enum
LISTVIEW_GRAVITY_CENTER_VERTICAL, LISTVIEW_GRAVITY_CENTER_VERTICAL,
}ListViewGravity; }ListViewGravity;
typedef enum
{
LISTVIEW_ONSELECEDTITEM
}ListViewEventType;
typedef void (cocos2d::Object::*SEL_ListViewEvent)(cocos2d::Object*,ListViewEventType);
#define listvieweventselector(_SELECTOR) (SEL_ListViewEvent)(&_SELECTOR)
class UIListView : public UIScrollView class UIListView : public UIScrollView
{ {
@ -145,6 +153,10 @@ public:
*/ */
void refreshView(); void refreshView();
int getCurSelectedIndex() const;
void addEventListenerListView(cocos2d::Object* target, SEL_ListViewEvent selector);
/** /**
* Changes scroll direction of scrollview. * Changes scroll direction of scrollview.
* *
@ -164,12 +176,17 @@ protected:
virtual UIWidget* createCloneInstance(); virtual UIWidget* createCloneInstance();
virtual void copySpecialProperties(UIWidget* model); virtual void copySpecialProperties(UIWidget* model);
virtual void copyClonedWidgetChildren(UIWidget* model); virtual void copyClonedWidgetChildren(UIWidget* model);
void selectedItemEvent();
virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint);
protected: protected:
UIWidget* _model; UIWidget* _model;
cocos2d::Array* _items; cocos2d::Array* _items;
ListViewGravity _gravity; ListViewGravity _gravity;
float _itemsMargin; float _itemsMargin;
cocos2d::Object* _listViewEventListener;
SEL_ListViewEvent _listViewEventSelector;
int _curSelectedIndex;
}; };
} }

View File

@ -42,8 +42,8 @@ _autoScrollDistance(0.0f),
_autoScrollSpeed(0.0f), _autoScrollSpeed(0.0f),
_autoScrollDir(0), _autoScrollDir(0),
_childFocusCancelOffset(5.0f), _childFocusCancelOffset(5.0f),
_eventListener(NULL), _pageViewEventListener(NULL),
_eventSelector(NULL) _pageViewEventSelector(NULL)
{ {
} }
@ -51,8 +51,8 @@ UIPageView::~UIPageView()
{ {
_pages->removeAllObjects(); _pages->removeAllObjects();
CC_SAFE_RELEASE(_pages); CC_SAFE_RELEASE(_pages);
_eventListener = NULL; _pageViewEventListener = NULL;
_eventSelector = NULL; _pageViewEventSelector = NULL;
} }
UIPageView* UIPageView::create() UIPageView* UIPageView::create()
@ -565,16 +565,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const co
void UIPageView::pageTurningEvent() void UIPageView::pageTurningEvent()
{ {
if (_eventListener && _eventSelector) if (_pageViewEventListener && _pageViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING); (_pageViewEventListener->*_pageViewEventSelector)(this, PAGEVIEW_EVENT_TURNING);
} }
} }
void UIPageView::addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector) void UIPageView::addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector)
{ {
_eventListener = target; _pageViewEventListener = target;
_eventSelector = selector; _pageViewEventSelector = selector;
} }
int UIPageView::getCurPageIndex() const int UIPageView::getCurPageIndex() const

View File

@ -118,7 +118,7 @@ public:
cocos2d::Array* getPages(); cocos2d::Array* getPages();
// event // event
void addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector); void addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector);
//override "removeChild" method of widget. //override "removeChild" method of widget.
@ -186,8 +186,8 @@ protected:
float _autoScrollSpeed; float _autoScrollSpeed;
int _autoScrollDir; int _autoScrollDir;
float _childFocusCancelOffset; float _childFocusCancelOffset;
cocos2d::Object* _eventListener; cocos2d::Object* _pageViewEventListener;
SEL_PageViewEvent _eventSelector; SEL_PageViewEvent _pageViewEventSelector;
}; };

View File

@ -69,15 +69,15 @@ _bouncing(false),
_bounceDir(cocos2d::Point::ZERO), _bounceDir(cocos2d::Point::ZERO),
_bounceOriginalSpeed(0.0f), _bounceOriginalSpeed(0.0f),
_inertiaScrollEnabled(true), _inertiaScrollEnabled(true),
_eventListener(NULL), _scrollViewEventListener(NULL),
_eventSelector(NULL) _scrollViewEventSelector(NULL)
{ {
} }
UIScrollView::~UIScrollView() UIScrollView::~UIScrollView()
{ {
_eventListener = NULL; _scrollViewEventListener = NULL;
_eventSelector = NULL; _scrollViewEventSelector = NULL;
} }
UIScrollView* UIScrollView::create() UIScrollView* UIScrollView::create()
@ -1458,80 +1458,80 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const cocos2d
void UIScrollView::scrollToTopEvent() void UIScrollView::scrollToTopEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP);
} }
} }
void UIScrollView::scrollToBottomEvent() void UIScrollView::scrollToBottomEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM);
} }
} }
void UIScrollView::scrollToLeftEvent() void UIScrollView::scrollToLeftEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT);
} }
} }
void UIScrollView::scrollToRightEvent() void UIScrollView::scrollToRightEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT);
} }
} }
void UIScrollView::scrollingEvent() void UIScrollView::scrollingEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLLING);
} }
} }
void UIScrollView::bounceTopEvent() void UIScrollView::bounceTopEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP);
} }
} }
void UIScrollView::bounceBottomEvent() void UIScrollView::bounceBottomEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM);
} }
} }
void UIScrollView::bounceLeftEvent() void UIScrollView::bounceLeftEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT);
} }
} }
void UIScrollView::bounceRightEvent() void UIScrollView::bounceRightEvent()
{ {
if (_eventListener && _eventSelector) if (_scrollViewEventListener && _scrollViewEventSelector)
{ {
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT);
} }
} }
void UIScrollView::addEventListener(cocos2d::Object *target, SEL_ScrollViewEvent selector) void UIScrollView::addEventListenerScrollView(cocos2d::Object *target, SEL_ScrollViewEvent selector)
{ {
_eventListener = target; _scrollViewEventListener = target;
_eventSelector = selector; _scrollViewEventSelector = selector;
} }
void UIScrollView::setDirection(SCROLLVIEW_DIR dir) void UIScrollView::setDirection(SCROLLVIEW_DIR dir)

View File

@ -231,7 +231,7 @@ public:
/** /**
* Add call back function called scrollview event triggered * Add call back function called scrollview event triggered
*/ */
void addEventListener(cocos2d::Object* target, SEL_ScrollViewEvent selector); void addEventListenerScrollView(cocos2d::Object* target, SEL_ScrollViewEvent selector);
//override "addChild" method of widget. //override "addChild" method of widget.
virtual bool addChild(UIWidget* widget); virtual bool addChild(UIWidget* widget);
@ -382,8 +382,8 @@ protected:
cocos2d::Object* _eventListener; cocos2d::Object* _scrollViewEventListener;
SEL_ScrollViewEvent _eventSelector; SEL_ScrollViewEvent _scrollViewEventSelector;
}; };
} }

View File

@ -46,8 +46,8 @@ _slidBallPressedTextureFile(""),
_slidBallDisabledTextureFile(""), _slidBallDisabledTextureFile(""),
_capInsetsBarRenderer(cocos2d::Rect::ZERO), _capInsetsBarRenderer(cocos2d::Rect::ZERO),
_capInsetsProgressBarRenderer(cocos2d::Rect::ZERO), _capInsetsProgressBarRenderer(cocos2d::Rect::ZERO),
_slidPercentListener(NULL), _sliderEventListener(NULL),
_slidPercentSelector(NULL), _sliderEventSelector(NULL),
_barTexType(UI_TEX_TYPE_LOCAL), _barTexType(UI_TEX_TYPE_LOCAL),
_progressBarTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL),
_ballNTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL),
@ -58,8 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL)
UISlider::~UISlider() UISlider::~UISlider()
{ {
_slidPercentListener = NULL; _sliderEventListener = NULL;
_slidPercentSelector = NULL; _sliderEventSelector = NULL;
} }
UISlider* UISlider::create() UISlider* UISlider::create()
@ -411,17 +411,17 @@ float UISlider::getPercentWithBallPos(float px)
return (((px-(-_barLength/2.0f))/_barLength)*100.0f); return (((px-(-_barLength/2.0f))/_barLength)*100.0f);
} }
void UISlider::addEventListener(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) void UISlider::addEventListenerSlider(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector)
{ {
_slidPercentListener = target; _sliderEventListener = target;
_slidPercentSelector = selector; _sliderEventSelector = selector;
} }
void UISlider::percentChangedEvent() void UISlider::percentChangedEvent()
{ {
if (_slidPercentListener && _slidPercentSelector) if (_sliderEventListener && _sliderEventSelector)
{ {
(_slidPercentListener->*_slidPercentSelector)(this,SLIDER_PERCENTCHANGED); (_sliderEventListener->*_sliderEventSelector)(this,SLIDER_PERCENTCHANGED);
} }
} }

View File

@ -162,7 +162,7 @@ public:
/** /**
* Add call back function called when slider's percent has changed to slider. * Add call back function called when slider's percent has changed to slider.
*/ */
void addEventListener(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); void addEventListenerSlider(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector);
//override "onTouchBegan" method of widget. //override "onTouchBegan" method of widget.
virtual bool onTouchBegan(const cocos2d::Point &touchPoint); virtual bool onTouchBegan(const cocos2d::Point &touchPoint);
@ -226,8 +226,8 @@ protected:
cocos2d::Rect _capInsetsBarRenderer; cocos2d::Rect _capInsetsBarRenderer;
cocos2d::Rect _capInsetsProgressBarRenderer; cocos2d::Rect _capInsetsProgressBarRenderer;
cocos2d::Object* _slidPercentListener; cocos2d::Object* _sliderEventListener;
SEL_SlidPercentChangedEvent _slidPercentSelector; SEL_SlidPercentChangedEvent _sliderEventSelector;
TextureResType _barTexType; TextureResType _barTexType;
TextureResType _progressBarTexType; TextureResType _progressBarTexType;
TextureResType _ballNTexType; TextureResType _ballNTexType;

View File

@ -275,16 +275,16 @@ _textFieldRenderer(NULL),
_touchWidth(0.0f), _touchWidth(0.0f),
_touchHeight(0.0f), _touchHeight(0.0f),
_useTouchArea(false), _useTouchArea(false),
_eventListener(NULL), _textFieldEventListener(NULL),
_eventSelector(NULL), _textFieldEventSelector(NULL),
_passwordStyleText("") _passwordStyleText("")
{ {
} }
UITextField::~UITextField() UITextField::~UITextField()
{ {
_eventListener = NULL; _textFieldEventListener = NULL;
_eventSelector = NULL; _textFieldEventSelector = NULL;
} }
UITextField* UITextField::create() UITextField* UITextField::create()
@ -472,40 +472,40 @@ void UITextField::setDeleteBackward(bool deleteBackward)
void UITextField::attachWithIMEEvent() void UITextField::attachWithIMEEvent()
{ {
if (_eventListener && _eventSelector) if (_textFieldEventListener && _textFieldEventSelector)
{ {
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME);
} }
} }
void UITextField::detachWithIMEEvent() void UITextField::detachWithIMEEvent()
{ {
if (_eventListener && _eventSelector) if (_textFieldEventListener && _textFieldEventSelector)
{ {
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME);
} }
} }
void UITextField::insertTextEvent() void UITextField::insertTextEvent()
{ {
if (_eventListener && _eventSelector) if (_textFieldEventListener && _textFieldEventSelector)
{ {
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT);
} }
} }
void UITextField::deleteBackwardEvent() void UITextField::deleteBackwardEvent()
{ {
if (_eventListener && _eventSelector) if (_textFieldEventListener && _textFieldEventSelector)
{ {
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD);
} }
} }
void UITextField::addEventListener(cocos2d::Object *target, SEL_TextFieldEvent selecor) void UITextField::addEventListenerTextField(cocos2d::Object *target, SEL_TextFieldEvent selecor)
{ {
_eventListener = target; _textFieldEventListener = target;
_eventSelector = selecor; _textFieldEventSelector = selecor;
} }
void UITextField::setAnchorPoint(const cocos2d::Point &pt) void UITextField::setAnchorPoint(const cocos2d::Point &pt)

View File

@ -132,7 +132,7 @@ public:
void setInsertText(bool insertText); void setInsertText(bool insertText);
bool getDeleteBackward(); bool getDeleteBackward();
void setDeleteBackward(bool deleteBackward); void setDeleteBackward(bool deleteBackward);
void addEventListener(cocos2d::Object* target, SEL_TextFieldEvent selecor); void addEventListenerTextField(cocos2d::Object* target, SEL_TextFieldEvent selecor);
virtual void setAnchorPoint(const cocos2d::Point &pt); virtual void setAnchorPoint(const cocos2d::Point &pt);
virtual void setColor(const cocos2d::Color3B &color); virtual void setColor(const cocos2d::Color3B &color);
@ -163,8 +163,8 @@ protected:
float _touchHeight; float _touchHeight;
bool _useTouchArea; bool _useTouchArea;
cocos2d::Object* _eventListener; cocos2d::Object* _textFieldEventListener;
SEL_TextFieldEvent _eventSelector; SEL_TextFieldEvent _textFieldEventSelector;
std::string _passwordStyleText; std::string _passwordStyleText;
}; };

View File

@ -881,6 +881,8 @@ public:
virtual void onEnter(); virtual void onEnter();
virtual void onExit(); virtual void onExit();
void updateSizeAndPosition();
virtual Object* getUserObject() { return _userObject; } virtual Object* getUserObject() { return _userObject; }
/** /**
* @js NA * @js NA
@ -926,7 +928,6 @@ protected:
void cancelUpEvent(); void cancelUpEvent();
void longClickEvent(); void longClickEvent();
void updateAnchorPoint(); void updateAnchorPoint();
void updateSizeAndPosition();
void copyProperties(UIWidget* model); void copyProperties(UIWidget* model);
virtual UIWidget* createCloneInstance(); virtual UIWidget* createCloneInstance();
virtual void copySpecialProperties(UIWidget* model); virtual void copySpecialProperties(UIWidget* model);

View File

@ -12,11 +12,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\CocosGUI.h" /> <ClInclude Include="..\CocosGUI.h" />
<ClInclude Include="..\Layout.h" />
<ClInclude Include="..\LayoutParameter.h" />
<ClInclude Include="..\UIButton.h" /> <ClInclude Include="..\UIButton.h" />
<ClInclude Include="..\UICheckBox.h" /> <ClInclude Include="..\UICheckBox.h" />
<ClInclude Include="..\UIDragPanel.h" />
<ClInclude Include="..\UIHelper.h" /> <ClInclude Include="..\UIHelper.h" />
<ClInclude Include="..\UIImageView.h" /> <ClInclude Include="..\UIImageView.h" />
<ClInclude Include="..\UIInputManager.h" /> <ClInclude Include="..\UIInputManager.h" />
@ -24,7 +21,9 @@
<ClInclude Include="..\UILabelAtlas.h" /> <ClInclude Include="..\UILabelAtlas.h" />
<ClInclude Include="..\UILabelBMFont.h" /> <ClInclude Include="..\UILabelBMFont.h" />
<ClInclude Include="..\UILayer.h" /> <ClInclude Include="..\UILayer.h" />
<ClInclude Include="..\UILayout.h" />
<ClInclude Include="..\UILayoutDefine.h" /> <ClInclude Include="..\UILayoutDefine.h" />
<ClInclude Include="..\UILayoutParameter.h" />
<ClInclude Include="..\UIListView.h" /> <ClInclude Include="..\UIListView.h" />
<ClInclude Include="..\UILoadingBar.h" /> <ClInclude Include="..\UILoadingBar.h" />
<ClInclude Include="..\UIPageView.h" /> <ClInclude Include="..\UIPageView.h" />
@ -37,11 +36,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\CocosGUI.cpp" /> <ClCompile Include="..\CocosGUI.cpp" />
<ClCompile Include="..\Layout.cpp" />
<ClCompile Include="..\LayoutParameter.cpp" />
<ClCompile Include="..\UIButton.cpp" /> <ClCompile Include="..\UIButton.cpp" />
<ClCompile Include="..\UICheckBox.cpp" /> <ClCompile Include="..\UICheckBox.cpp" />
<ClCompile Include="..\UIDragPanel.cpp" />
<ClCompile Include="..\UIHelper.cpp" /> <ClCompile Include="..\UIHelper.cpp" />
<ClCompile Include="..\UIImageView.cpp" /> <ClCompile Include="..\UIImageView.cpp" />
<ClCompile Include="..\UIInputManager.cpp" /> <ClCompile Include="..\UIInputManager.cpp" />
@ -49,7 +45,9 @@
<ClCompile Include="..\UILabelAtlas.cpp" /> <ClCompile Include="..\UILabelAtlas.cpp" />
<ClCompile Include="..\UILabelBMFont.cpp" /> <ClCompile Include="..\UILabelBMFont.cpp" />
<ClCompile Include="..\UILayer.cpp" /> <ClCompile Include="..\UILayer.cpp" />
<ClCompile Include="..\UILayout.cpp" />
<ClCompile Include="..\UILayoutDefine.cpp" /> <ClCompile Include="..\UILayoutDefine.cpp" />
<ClCompile Include="..\UILayoutParameter.cpp" />
<ClCompile Include="..\UIListView.cpp" /> <ClCompile Include="..\UIListView.cpp" />
<ClCompile Include="..\UILoadingBar.cpp" /> <ClCompile Include="..\UILoadingBar.cpp" />
<ClCompile Include="..\UIPageView.cpp" /> <ClCompile Include="..\UIPageView.cpp" />

View File

@ -24,9 +24,6 @@
<ClInclude Include="..\UIScrollView.h"> <ClInclude Include="..\UIScrollView.h">
<Filter>UIWidgets\ScrollWidget</Filter> <Filter>UIWidgets\ScrollWidget</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\UIDragPanel.h">
<Filter>UIWidgets\ScrollWidget</Filter>
</ClInclude>
<ClInclude Include="..\UIListView.h"> <ClInclude Include="..\UIListView.h">
<Filter>UIWidgets\ScrollWidget</Filter> <Filter>UIWidgets\ScrollWidget</Filter>
</ClInclude> </ClInclude>
@ -72,12 +69,6 @@
<ClInclude Include="..\UILayer.h"> <ClInclude Include="..\UILayer.h">
<Filter>System</Filter> <Filter>System</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Layout.h">
<Filter>Layouts</Filter>
</ClInclude>
<ClInclude Include="..\LayoutParameter.h">
<Filter>Layouts</Filter>
</ClInclude>
<ClInclude Include="..\UILayoutDefine.h"> <ClInclude Include="..\UILayoutDefine.h">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClInclude> </ClInclude>
@ -87,14 +78,17 @@
<ClInclude Include="..\UIWidget.h"> <ClInclude Include="..\UIWidget.h">
<Filter>BaseClasses</Filter> <Filter>BaseClasses</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\UILayout.h">
<Filter>Layouts</Filter>
</ClInclude>
<ClInclude Include="..\UILayoutParameter.h">
<Filter>Layouts</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\UIScrollView.cpp"> <ClCompile Include="..\UIScrollView.cpp">
<Filter>UIWidgets\ScrollWidget</Filter> <Filter>UIWidgets\ScrollWidget</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\UIDragPanel.cpp">
<Filter>UIWidgets\ScrollWidget</Filter>
</ClCompile>
<ClCompile Include="..\UIListView.cpp"> <ClCompile Include="..\UIListView.cpp">
<Filter>UIWidgets\ScrollWidget</Filter> <Filter>UIWidgets\ScrollWidget</Filter>
</ClCompile> </ClCompile>
@ -140,12 +134,6 @@
<ClCompile Include="..\UILayer.cpp"> <ClCompile Include="..\UILayer.cpp">
<Filter>System</Filter> <Filter>System</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\Layout.cpp">
<Filter>Layouts</Filter>
</ClCompile>
<ClCompile Include="..\LayoutParameter.cpp">
<Filter>Layouts</Filter>
</ClCompile>
<ClCompile Include="..\UILayoutDefine.cpp"> <ClCompile Include="..\UILayoutDefine.cpp">
<Filter>Layouts</Filter> <Filter>Layouts</Filter>
</ClCompile> </ClCompile>
@ -155,5 +143,11 @@
<ClCompile Include="..\UIWidget.cpp"> <ClCompile Include="..\UIWidget.cpp">
<Filter>BaseClasses</Filter> <Filter>BaseClasses</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\UILayout.cpp">
<Filter>Layouts</Filter>
</ClCompile>
<ClCompile Include="..\UILayoutParameter.cpp">
<Filter>Layouts</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -539,7 +539,7 @@ bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMate
cpVect* vecs = new cpVect[count]; cpVect* vecs = new cpVect[count];
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset));
CC_SAFE_DELETE(vecs); CC_SAFE_DELETE_ARRAY(vecs);
CC_BREAK_IF(shape == nullptr); CC_BREAK_IF(shape == nullptr);
@ -563,7 +563,7 @@ float PhysicsShapePolygon::calculateArea(const Point* points, int count)
cpVect* vecs = new cpVect[count]; cpVect* vecs = new cpVect[count];
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs));
CC_SAFE_DELETE(vecs); CC_SAFE_DELETE_ARRAY(vecs);
return area; return area;
} }
@ -574,7 +574,7 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int
PhysicsHelper::points2cpvs(points, vecs, count); PhysicsHelper::points2cpvs(points, vecs, count);
float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY
: PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset)));
CC_SAFE_DELETE(vecs); CC_SAFE_DELETE_ARRAY(vecs);
return moment; return moment;
} }

@ -1 +1 @@
Subproject commit 5788b2500339473ecc19acf1c2e43656a2537a6d Subproject commit 3fa10c3f8f9fe083ef05cb401924d31740da9719

View File

@ -32,7 +32,7 @@ extern "C" {
} }
#endif #endif
std::map<int, std::string> g_luaType; std::map<long, std::string> g_luaType;
#if COCOS2D_DEBUG >=1 #if COCOS2D_DEBUG >=1
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err)

View File

@ -10,7 +10,7 @@ extern "C" {
using namespace cocos2d; using namespace cocos2d;
extern std::map<int, std::string> g_luaType; extern std::map<long, std::string> g_luaType;
#if COCOS2D_DEBUG >=1 #if COCOS2D_DEBUG >=1
void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err);

View File

@ -54,7 +54,7 @@ bool UICheckBoxTest::init()
"cocosgui/check_box_active_disable.png"); "cocosgui/check_box_active_disable.png");
checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
// checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent)); // checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent));
m_pUiLayer->addWidget(checkBox); m_pUiLayer->addWidget(checkBox);

View File

@ -79,7 +79,7 @@ bool UIPageViewTest::init()
pageView->addPage(layout); pageView->addPage(layout);
} }
pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); pageView->addEventListenerPageView(this, pagevieweventselector(UIPageViewTest::pageViewEvent));
m_pUiLayer->addWidget(pageView); m_pUiLayer->addWidget(pageView);

View File

@ -26,7 +26,7 @@ bool UIScene::init()
m_pUiLayer = UILayer::create(); m_pUiLayer = UILayer::create();
addChild(m_pUiLayer); addChild(m_pUiLayer);
m_pWidget = dynamic_cast<UILayout*>(cocostudio::CCSGUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); m_pWidget = dynamic_cast<UILayout*>(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json"));
m_pUiLayer->addWidget(m_pWidget); m_pUiLayer->addWidget(m_pWidget);
m_pSceneTitle = dynamic_cast<UILabel*>(m_pUiLayer->getWidgetByName("UItest")); m_pSceneTitle = dynamic_cast<UILabel*>(m_pUiLayer->getWidgetByName("UItest"));

View File

@ -52,7 +52,7 @@ bool UISliderTest::init()
slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", ""); slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosgui/sliderProgress.png"); slider->loadProgressBarTexture("cocosgui/sliderProgress.png");
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent));
m_pUiLayer->addWidget(slider); m_pUiLayer->addWidget(slider);
return true; return true;
@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init()
slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setCapInsets(Rect(0, 0, 0, 0));
slider->setSize(Size(250, 10)); slider->setSize(Size(250, 10));
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent));
m_pUiLayer->addWidget(slider); m_pUiLayer->addWidget(slider);
return true; return true;

View File

@ -51,7 +51,7 @@ bool UITextFieldTest::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input words here"); textField->setPlaceHolder("input words here");
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest::textFieldEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;
@ -139,7 +139,7 @@ bool UITextFieldTest_MaxLength::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input words here"); textField->setPlaceHolder("input words here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;
@ -233,7 +233,7 @@ bool UITextFieldTest_Password::init()
textField->setFontSize(30); textField->setFontSize(30);
textField->setPlaceHolder("input password here"); textField->setPlaceHolder("input password here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent));
m_pUiLayer->addWidget(textField); m_pUiLayer->addWidget(textField);
return true; return true;

@ -1 +1 @@
Subproject commit 9797d4403207848f431d5b6456632cc966d84b0d Subproject commit 2f3c19e01d5043485d0887ad69a3f02e312ad690