Merge pull request #880 from 2youyou2/extensions

remove unused extensions files
This commit is contained in:
James Chen
2017-10-10 14:45:16 +08:00
committed by GitHub
42 changed files with 3 additions and 16146 deletions
@@ -45,64 +45,6 @@
15AE1BC219AADFFB00C27E9E /* ExtensionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168321807AF4E005B8026 /* ExtensionMacros.h */; };
15AE1BC319AADFFB00C27E9E /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; };
15AE1BC419AADFFB00C27E9E /* ExtensionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168321807AF4E005B8026 /* ExtensionMacros.h */; };
15AE1BC919AAE01E00C27E9E /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168351807AF4E005B8026 /* CCControl.cpp */; };
15AE1BCA19AAE01E00C27E9E /* CCControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168361807AF4E005B8026 /* CCControl.h */; };
15AE1BCB19AAE01E00C27E9E /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168371807AF4E005B8026 /* CCControlButton.cpp */; };
15AE1BCC19AAE01E00C27E9E /* CCControlButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168381807AF4E005B8026 /* CCControlButton.h */; };
15AE1BCD19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */; };
15AE1BCE19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */; };
15AE1BCF19AAE01E00C27E9E /* CCControlExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */; };
15AE1BD019AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */; };
15AE1BD119AAE01E00C27E9E /* CCControlHuePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */; };
15AE1BD219AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */; };
15AE1BD319AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */; };
15AE1BD419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */; };
15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */; };
15AE1BD619AAE01E00C27E9E /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168421807AF4E005B8026 /* CCControlSlider.cpp */; };
15AE1BD719AAE01E00C27E9E /* CCControlSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168431807AF4E005B8026 /* CCControlSlider.h */; };
15AE1BD819AAE01E00C27E9E /* CCControlStepper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168441807AF4E005B8026 /* CCControlStepper.cpp */; };
15AE1BD919AAE01E00C27E9E /* CCControlStepper.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168451807AF4E005B8026 /* CCControlStepper.h */; };
15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */; };
15AE1BDB19AAE01E00C27E9E /* CCControlSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168471807AF4E005B8026 /* CCControlSwitch.h */; };
15AE1BDC19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168481807AF4E005B8026 /* CCControlUtils.cpp */; };
15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; };
15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; };
15AE1BDF19AAE01E00C27E9E /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; };
15AE1BE219AAE01E00C27E9E /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; };
15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; };
15AE1BE419AAE01E00C27E9E /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; };
15AE1BE519AAE01E00C27E9E /* CCTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168631807AF4E005B8026 /* CCTableView.h */; };
15AE1BE619AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */; };
15AE1BE719AAE01E00C27E9E /* CCTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168651807AF4E005B8026 /* CCTableViewCell.h */; };
15AE1BE819AAE01E00C27E9E /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168351807AF4E005B8026 /* CCControl.cpp */; };
15AE1BE919AAE01E00C27E9E /* CCControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168361807AF4E005B8026 /* CCControl.h */; };
15AE1BEA19AAE01E00C27E9E /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168371807AF4E005B8026 /* CCControlButton.cpp */; };
15AE1BEB19AAE01E00C27E9E /* CCControlButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168381807AF4E005B8026 /* CCControlButton.h */; };
15AE1BEC19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */; };
15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */; };
15AE1BEE19AAE01E00C27E9E /* CCControlExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683B1807AF4E005B8026 /* CCControlExtensions.h */; };
15AE1BEF19AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */; };
15AE1BF019AAE01E00C27E9E /* CCControlHuePicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */; };
15AE1BF119AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */; };
15AE1BF219AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */; };
15AE1BF319AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */; };
15AE1BF419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */; };
15AE1BF519AAE01E00C27E9E /* CCControlSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168421807AF4E005B8026 /* CCControlSlider.cpp */; };
15AE1BF619AAE01E00C27E9E /* CCControlSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168431807AF4E005B8026 /* CCControlSlider.h */; };
15AE1BF719AAE01E00C27E9E /* CCControlStepper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168441807AF4E005B8026 /* CCControlStepper.cpp */; };
15AE1BF819AAE01E00C27E9E /* CCControlStepper.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168451807AF4E005B8026 /* CCControlStepper.h */; };
15AE1BF919AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168461807AF4E005B8026 /* CCControlSwitch.cpp */; };
15AE1BFA19AAE01E00C27E9E /* CCControlSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168471807AF4E005B8026 /* CCControlSwitch.h */; };
15AE1BFB19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168481807AF4E005B8026 /* CCControlUtils.cpp */; };
15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; };
15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; };
15AE1BFE19AAE01E00C27E9E /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; };
15AE1C0119AAE01E00C27E9E /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; };
15AE1C0219AAE01E00C27E9E /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; };
15AE1C0319AAE01E00C27E9E /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; };
15AE1C0419AAE01E00C27E9E /* CCTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168631807AF4E005B8026 /* CCTableView.h */; };
15AE1C0519AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */; };
15AE1C0619AAE01E00C27E9E /* CCTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168651807AF4E005B8026 /* CCTableViewCell.h */; };
15EFA211198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; };
15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; };
15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; };
@@ -1174,12 +1116,6 @@
A0E749F81BA8FD7F001A8332 /* UIEditBoxImpl-common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0E749F51BA8FD7F001A8332 /* UIEditBoxImpl-common.cpp */; };
A0E749F91BA8FD7F001A8332 /* UIEditBoxImpl-common.h in Headers */ = {isa = PBXBuildFile; fileRef = A0E749F61BA8FD7F001A8332 /* UIEditBoxImpl-common.h */; };
A0E749FA1BA8FD7F001A8332 /* UIEditBoxImpl-common.h in Headers */ = {isa = PBXBuildFile; fileRef = A0E749F61BA8FD7F001A8332 /* UIEditBoxImpl-common.h */; };
A60A9D5F1C200DE10070800A /* CCPhysicsDebugNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A60A9D5B1C200DE10070800A /* CCPhysicsDebugNode.cpp */; };
A60A9D601C200DE10070800A /* CCPhysicsDebugNode.h in Headers */ = {isa = PBXBuildFile; fileRef = A60A9D5C1C200DE10070800A /* CCPhysicsDebugNode.h */; };
A60A9D611C200DE10070800A /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A60A9D5D1C200DE10070800A /* CCPhysicsSprite.cpp */; };
A60A9D621C200DE10070800A /* CCPhysicsSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = A60A9D5E1C200DE10070800A /* CCPhysicsSprite.h */; };
A60A9D631C200DE40070800A /* CCPhysicsDebugNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A60A9D5B1C200DE10070800A /* CCPhysicsDebugNode.cpp */; };
A60A9D641C200DE70070800A /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A60A9D5D1C200DE10070800A /* CCPhysicsSprite.cpp */; };
A60A9D661C200E5A0070800A /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A60A9D651C200E5A0070800A /* libchipmunk.a */; };
A614E2E01C8E72360065A737 /* CCLabelTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = A614E2DE1C8E72360065A737 /* CCLabelTTF.h */; };
A614E2E11C8E761D0065A737 /* CCLabelTTF.h in Headers */ = {isa = PBXBuildFile; fileRef = A614E2DE1C8E72360065A737 /* CCLabelTTF.h */; };
@@ -1846,35 +1782,6 @@
46A15FE11807A56F005B8026 /* Export.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = "<group>"; };
46A167D21807AF4D005B8026 /* cocos-ext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "cocos-ext.h"; sourceTree = "<group>"; };
46A168321807AF4E005B8026 /* ExtensionMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExtensionMacros.h; sourceTree = "<group>"; };
46A168351807AF4E005B8026 /* CCControl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = "<group>"; };
46A168361807AF4E005B8026 /* CCControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = "<group>"; };
46A168371807AF4E005B8026 /* CCControlButton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlButton.cpp; sourceTree = "<group>"; };
46A168381807AF4E005B8026 /* CCControlButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlButton.h; sourceTree = "<group>"; };
46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlColourPicker.cpp; sourceTree = "<group>"; };
46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlColourPicker.h; sourceTree = "<group>"; };
46A1683B1807AF4E005B8026 /* CCControlExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlExtensions.h; sourceTree = "<group>"; };
46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlHuePicker.cpp; sourceTree = "<group>"; };
46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlHuePicker.h; sourceTree = "<group>"; };
46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlPotentiometer.cpp; sourceTree = "<group>"; };
46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlPotentiometer.h; sourceTree = "<group>"; };
46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSaturationBrightnessPicker.cpp; sourceTree = "<group>"; };
46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSaturationBrightnessPicker.h; sourceTree = "<group>"; };
46A168421807AF4E005B8026 /* CCControlSlider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSlider.cpp; sourceTree = "<group>"; };
46A168431807AF4E005B8026 /* CCControlSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSlider.h; sourceTree = "<group>"; };
46A168441807AF4E005B8026 /* CCControlStepper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlStepper.cpp; sourceTree = "<group>"; };
46A168451807AF4E005B8026 /* CCControlStepper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlStepper.h; sourceTree = "<group>"; };
46A168461807AF4E005B8026 /* CCControlSwitch.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitch.cpp; sourceTree = "<group>"; };
46A168471807AF4E005B8026 /* CCControlSwitch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlSwitch.h; sourceTree = "<group>"; };
46A168481807AF4E005B8026 /* CCControlUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlUtils.cpp; sourceTree = "<group>"; };
46A168491807AF4E005B8026 /* CCControlUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = "<group>"; };
46A1684A1807AF4E005B8026 /* CCInvocation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = "<group>"; };
46A1684B1807AF4E005B8026 /* CCInvocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = "<group>"; };
46A1685E1807AF4E005B8026 /* CCScrollView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCScrollView.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
46A1685F1807AF4E005B8026 /* CCScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = "<group>"; };
46A168621807AF4E005B8026 /* CCTableView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = "<group>"; };
46A168631807AF4E005B8026 /* CCTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTableView.h; sourceTree = "<group>"; };
46A168641807AF4E005B8026 /* CCTableViewCell.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableViewCell.cpp; sourceTree = "<group>"; };
46A168651807AF4E005B8026 /* CCTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTableViewCell.h; sourceTree = "<group>"; };
4D2816641E8CBB7200F26B06 /* CCPhysicsContactImpulse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContactImpulse.cpp; sourceTree = "<group>"; };
4D2816651E8CBB7200F26B06 /* CCPhysicsContactImpulse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsContactImpulse.h; sourceTree = "<group>"; };
4D2E69031CC543B40032DD5C /* CCGraphicsNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCGraphicsNode.cpp; path = creator/CCGraphicsNode.cpp; sourceTree = "<group>"; };
@@ -2247,10 +2154,6 @@
A07A4D641783777C0073F6A7 /* libcocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A0E749F51BA8FD7F001A8332 /* UIEditBoxImpl-common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "UIEditBoxImpl-common.cpp"; sourceTree = "<group>"; };
A0E749F61BA8FD7F001A8332 /* UIEditBoxImpl-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIEditBoxImpl-common.h"; sourceTree = "<group>"; };
A60A9D5B1C200DE10070800A /* CCPhysicsDebugNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysicsDebugNode.cpp; path = "physics-nodes/CCPhysicsDebugNode.cpp"; sourceTree = "<group>"; };
A60A9D5C1C200DE10070800A /* CCPhysicsDebugNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysicsDebugNode.h; path = "physics-nodes/CCPhysicsDebugNode.h"; sourceTree = "<group>"; };
A60A9D5D1C200DE10070800A /* CCPhysicsSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysicsSprite.cpp; path = "physics-nodes/CCPhysicsSprite.cpp"; sourceTree = "<group>"; };
A60A9D5E1C200DE10070800A /* CCPhysicsSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysicsSprite.h; path = "physics-nodes/CCPhysicsSprite.h"; sourceTree = "<group>"; };
A60A9D651C200E5A0070800A /* libchipmunk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libchipmunk.a; path = ../external/ios/libs/libchipmunk.a; sourceTree = "<group>"; };
A614E2DE1C8E72360065A737 /* CCLabelTTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLabelTTF.h; sourceTree = "<group>"; };
A63CEFF91CD9CF3500A6971D /* CCUIEditBoxMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCUIEditBoxMac.h; path = Mac/CCUIEditBoxMac.h; sourceTree = "<group>"; };
@@ -3276,67 +3179,13 @@
isa = PBXGroup;
children = (
BA679B271CEC371100F875FA /* assets-manager */,
A60A9D5A1C200DD00070800A /* PhysicsSprite */,
46A167D21807AF4D005B8026 /* cocos-ext.h */,
46A168321807AF4E005B8026 /* ExtensionMacros.h */,
46A168331807AF4E005B8026 /* GUI */,
);
name = extensions;
path = ../extensions;
sourceTree = "<group>";
};
46A168331807AF4E005B8026 /* GUI */ = {
isa = PBXGroup;
children = (
46A168341807AF4E005B8026 /* CCControlExtension */,
46A1685D1807AF4E005B8026 /* CCScrollView */,
);
path = GUI;
sourceTree = "<group>";
};
46A168341807AF4E005B8026 /* CCControlExtension */ = {
isa = PBXGroup;
children = (
46A168351807AF4E005B8026 /* CCControl.cpp */,
46A168361807AF4E005B8026 /* CCControl.h */,
46A168371807AF4E005B8026 /* CCControlButton.cpp */,
46A168381807AF4E005B8026 /* CCControlButton.h */,
46A168391807AF4E005B8026 /* CCControlColourPicker.cpp */,
46A1683A1807AF4E005B8026 /* CCControlColourPicker.h */,
46A1683B1807AF4E005B8026 /* CCControlExtensions.h */,
46A1683C1807AF4E005B8026 /* CCControlHuePicker.cpp */,
46A1683D1807AF4E005B8026 /* CCControlHuePicker.h */,
46A1683E1807AF4E005B8026 /* CCControlPotentiometer.cpp */,
46A1683F1807AF4E005B8026 /* CCControlPotentiometer.h */,
46A168401807AF4E005B8026 /* CCControlSaturationBrightnessPicker.cpp */,
46A168411807AF4E005B8026 /* CCControlSaturationBrightnessPicker.h */,
46A168421807AF4E005B8026 /* CCControlSlider.cpp */,
46A168431807AF4E005B8026 /* CCControlSlider.h */,
46A168441807AF4E005B8026 /* CCControlStepper.cpp */,
46A168451807AF4E005B8026 /* CCControlStepper.h */,
46A168461807AF4E005B8026 /* CCControlSwitch.cpp */,
46A168471807AF4E005B8026 /* CCControlSwitch.h */,
46A168481807AF4E005B8026 /* CCControlUtils.cpp */,
46A168491807AF4E005B8026 /* CCControlUtils.h */,
46A1684A1807AF4E005B8026 /* CCInvocation.cpp */,
46A1684B1807AF4E005B8026 /* CCInvocation.h */,
);
path = CCControlExtension;
sourceTree = "<group>";
};
46A1685D1807AF4E005B8026 /* CCScrollView */ = {
isa = PBXGroup;
children = (
46A1685E1807AF4E005B8026 /* CCScrollView.cpp */,
46A1685F1807AF4E005B8026 /* CCScrollView.h */,
46A168621807AF4E005B8026 /* CCTableView.cpp */,
46A168631807AF4E005B8026 /* CCTableView.h */,
46A168641807AF4E005B8026 /* CCTableViewCell.cpp */,
46A168651807AF4E005B8026 /* CCTableViewCell.h */,
);
path = CCScrollView;
sourceTree = "<group>";
};
46A169A11807B037005B8026 /* 2d */ = {
isa = PBXGroup;
children = (
@@ -3854,17 +3703,6 @@
path = apple;
sourceTree = "<group>";
};
A60A9D5A1C200DD00070800A /* PhysicsSprite */ = {
isa = PBXGroup;
children = (
A60A9D5B1C200DE10070800A /* CCPhysicsDebugNode.cpp */,
A60A9D5C1C200DE10070800A /* CCPhysicsDebugNode.h */,
A60A9D5D1C200DE10070800A /* CCPhysicsSprite.cpp */,
A60A9D5E1C200DE10070800A /* CCPhysicsSprite.h */,
);
name = PhysicsSprite;
sourceTree = "<group>";
};
A63CEFF81CD9CF2700A6971D /* Mac */ = {
isa = PBXGroup;
children = (
@@ -4238,14 +4076,10 @@
4DED487A1DFFA4AF0070C5C4 /* b2RevoluteJoint.h in Headers */,
4DED487E1DFFA4AF0070C5C4 /* b2RopeJoint.h in Headers */,
1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */,
15AE1BD719AAE01E00C27E9E /* CCControlSlider.h in Headers */,
15AE1BE519AAE01E00C27E9E /* CCTableView.h in Headers */,
15AE1BD319AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */,
FA6F1B4B1D80F858007DD223 /* IAnimateble.h in Headers */,
15AE1B6E19AADA9900C27E9E /* UIHelper.h in Headers */,
B230ED7319B417AE00364AA8 /* CCTrianglesCommand.h in Headers */,
1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */,
15AE1BCC19AAE01E00C27E9E /* CCControlButton.h in Headers */,
FA6F1B751D80F858007DD223 /* CCTextureData.h in Headers */,
5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */,
1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */,
@@ -4314,7 +4148,6 @@
15AE1B6C19AADA9900C27E9E /* UIWidget.h in Headers */,
FA6F1B711D80F858007DD223 /* CCSlot.h in Headers */,
1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */,
15AE1BD919AAE01E00C27E9E /* CCControlStepper.h in Headers */,
FA6F1BA31D80F858007DD223 /* TimelineData.h in Headers */,
5034CA47191D591100CE6051 /* ccShader_Label_normal.frag in Headers */,
BAFF7DDA1D5C1CF80051B92F /* VertexAttachment.h in Headers */,
@@ -4335,7 +4168,6 @@
4DED488A1DFFA4AF0070C5C4 /* b2Rope.h in Headers */,
4DED48361DFFA4AF0070C5C4 /* b2ChainAndCircleContact.h in Headers */,
1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */,
15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */,
294D7D9A1D0E93A2002CE7B7 /* CCDevice-apple.h in Headers */,
FA6F1B971D80F858007DD223 /* ArmatureData.h in Headers */,
A6F0D7A21C2796020029CC44 /* CCStencilStateManager.hpp in Headers */,
@@ -4344,7 +4176,6 @@
1A5701E8180BCB8C0088DEC7 /* CCTransition.h in Headers */,
1A5701EC180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */,
FA6F1B871D80F858007DD223 /* ColorTransform.h in Headers */,
A60A9D621C200DE10070800A /* CCPhysicsSprite.h in Headers */,
BAFF7DD21D5C1CF80051B92F /* TransformConstraint.h in Headers */,
1A28FF851F20AFAB007A1D9D /* SRSIMDHelpers.h in Headers */,
1A5701F0180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */,
@@ -4369,7 +4200,6 @@
4D6CF4391E83AAD5003327D4 /* CCCameraNode.h in Headers */,
FAC8F6681E1DF15D002B17E8 /* kvec.h in Headers */,
4DC06BE11E8A68D400CA08B1 /* CCPhysicsRayCastCallback.h in Headers */,
15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */,
50ABBD891925AB4100A911A9 /* CCCustomCommand.h in Headers */,
5034CA43191D591100CE6051 /* ccShader_Label.vert in Headers */,
4DC06BDD1E8A68D400CA08B1 /* CCPhysicsDebugDraw.h in Headers */,
@@ -4408,7 +4238,6 @@
1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */,
5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */,
FA6F1B8D1D80F858007DD223 /* Rectangle.h in Headers */,
15AE1BCE19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */,
1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */,
1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */,
4DED48421DFFA4AF0070C5C4 /* b2Contact.h in Headers */,
@@ -4437,7 +4266,6 @@
50ABBD4E1925AB0000A911A9 /* MathUtil.h in Headers */,
15AE1BC219AADFFB00C27E9E /* ExtensionMacros.h in Headers */,
4DED48241DFFA4AF0070C5C4 /* b2Fixture.h in Headers */,
15AE1BDF19AAE01E00C27E9E /* CCInvocation.h in Headers */,
BAFF7D9C1D5C1CF80051B92F /* PathConstraintData.h in Headers */,
50ABBE431925AB6F00A911A9 /* CCDirector.h in Headers */,
1A28FF911F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.h in Headers */,
@@ -4488,11 +4316,9 @@
FA6F1B611D80F858007DD223 /* Slot.h in Headers */,
50ABBE331925AB6F00A911A9 /* CCConfiguration.h in Headers */,
4D2816681E8CBB7200F26B06 /* CCPhysicsContactImpulse.h in Headers */,
15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */,
50CB247519D9C5A100687767 /* AudioCache.h in Headers */,
50ABC01F1926664800A911A9 /* CCThread.h in Headers */,
BAFF7DC81D5C1CF80051B92F /* SlotData.h in Headers */,
15AE1BCA19AAE01E00C27E9E /* CCControl.h in Headers */,
50ABBDBF1925AB4100A911A9 /* CCTextureCache.h in Headers */,
BAFF7D701D5C1CF80051B92F /* BoundingBoxAttachment.h in Headers */,
5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
@@ -4526,11 +4352,9 @@
50ABBDA51925AB4100A911A9 /* CCQuadCommand.h in Headers */,
BAFF7D5C1D5C1CF80051B92F /* Attachment.h in Headers */,
BA68D7811D62F4A500B7A3F9 /* utils.h in Headers */,
15AE1BCF19AAE01E00C27E9E /* CCControlExtensions.h in Headers */,
1A28FF951F20AFAB007A1D9D /* SocketRocket.h in Headers */,
50643BD919BFAF4400EF68ED /* CCApplication.h in Headers */,
BA68D78B1D62F4A500B7A3F9 /* cdt.h in Headers */,
15AE1BE719AAE01E00C27E9E /* CCTableViewCell.h in Headers */,
BAFF7D641D5C1CF80051B92F /* AttachmentVertices.h in Headers */,
50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */,
15AE1BB319AADFEF00C27E9E /* HttpRequest.h in Headers */,
@@ -4547,7 +4371,6 @@
50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */,
FA6F1BAF1D80F858007DD223 /* TextureData.h in Headers */,
FAC8F66C1E1DF15D002B17E8 /* SkeletonBinary.h in Headers */,
15AE1BDB19AAE01E00C27E9E /* CCControlSwitch.h in Headers */,
B24AA987195A675C007B4522 /* CCFastTMXLayer.h in Headers */,
50ABBEBD1925AB6F00A911A9 /* ccUtils.h in Headers */,
4DED486E1DFFA4AF0070C5C4 /* b2MouseJoint.h in Headers */,
@@ -4584,7 +4407,6 @@
50ABBE2D1925AB6F00A911A9 /* ccCArray.h in Headers */,
50ABBD5E1925AB0000A911A9 /* Vec3.h in Headers */,
ED3057A21BEC77D50083C3ED /* xxhash.h in Headers */,
A60A9D601C200DE10070800A /* CCPhysicsDebugNode.h in Headers */,
BAFF7D581D5C1CF80051B92F /* AtlasAttachmentLoader.h in Headers */,
291901431B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */,
B24AA98B195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */,
@@ -4604,7 +4426,6 @@
50ABC0691926664800A911A9 /* CCStdC-mac.h in Headers */,
BAFF7DC01D5C1CF80051B92F /* Skin.h in Headers */,
1A28FF711F20AFAB007A1D9D /* SRHash.h in Headers */,
15AE1BD119AAE01E00C27E9E /* CCControlHuePicker.h in Headers */,
FA6F1B891D80F858007DD223 /* Matrix.h in Headers */,
50ABBE771925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */,
5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */,
@@ -4653,7 +4474,6 @@
1A28FF8E1F20AFAB007A1D9D /* NSRunLoop+SRWebSocket.h in Headers */,
5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
BAFF7DCF1D5C1CF80051B92F /* spine.h in Headers */,
15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */,
4D2E690E1CC543B40032DD5C /* Triangulate.h in Headers */,
50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */,
2980F0241BA9A5550059E678 /* CCUIMultilineTextField.h in Headers */,
@@ -4728,7 +4548,6 @@
1A570094180BC5A10088DEC7 /* CCActionTween.h in Headers */,
1A57009B180BC5C10088DEC7 /* CCAtlasNode.h in Headers */,
1A5700A1180BC5D20088DEC7 /* CCNode.h in Headers */,
15AE1BF019AAE01E00C27E9E /* CCControlHuePicker.h in Headers */,
503DD8E41926736A00CD74DD /* CCDirectorCaller-ios.h in Headers */,
BAFF7D551D5C1CF80051B92F /* Atlas.h in Headers */,
FA6F1B681D80F858007DD223 /* CCArmatureDisplay.h in Headers */,
@@ -4771,7 +4590,6 @@
1A28FF6A1F20AFAB007A1D9D /* SRConstants.h in Headers */,
50ABBFFE1926664800A911A9 /* CCFileUtils-apple.h in Headers */,
1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */,
15AE1C0219AAE01E00C27E9E /* CCScrollView.h in Headers */,
1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */,
FA6F1B581D80F858007DD223 /* Armature.h in Headers */,
1A5701B4180BCB590088DEC7 /* CCFontFNT.h in Headers */,
@@ -4797,12 +4615,10 @@
4DED48211DFFA4AF0070C5C4 /* b2ContactManager.h in Headers */,
5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */,
50643BE519BFCF1800EF68ED /* CCPlatformMacros.h in Headers */,
15AE1BFA19AAE01E00C27E9E /* CCControlSwitch.h in Headers */,
FA6F1B641D80F858007DD223 /* TransformObject.h in Headers */,
4DED47E91DFFA4AF0070C5C4 /* b2DynamicTree.h in Headers */,
BAFF7D651D5C1CF80051B92F /* AttachmentVertices.h in Headers */,
1A5701E1180BCB8C0088DEC7 /* CCLayer.h in Headers */,
15AE1BEE19AAE01E00C27E9E /* CCControlExtensions.h in Headers */,
1A28FF621F20AFAB007A1D9D /* SRRunLoopThread.h in Headers */,
1A5701E5180BCB8C0088DEC7 /* CCScene.h in Headers */,
1A5701E9180BCB8C0088DEC7 /* CCTransition.h in Headers */,
@@ -4828,7 +4644,6 @@
BAFF7D751D5C1CF80051B92F /* Cocos2dAttachmentLoader.h in Headers */,
1A28FF7A1F20AFAB007A1D9D /* SRLog.h in Headers */,
BAFF7DB11D5C1CF80051B92F /* SkeletonBounds.h in Headers */,
15AE1C0419AAE01E00C27E9E /* CCTableView.h in Headers */,
50ABBEA21925AB6F00A911A9 /* CCScheduler.h in Headers */,
4D2816691E8CBB7200F26B06 /* CCPhysicsContactImpulse.h in Headers */,
4DC06BE21E8A68D400CA08B1 /* CCPhysicsRayCastCallback.h in Headers */,
@@ -4877,8 +4692,6 @@
2980F0221BA9A5550059E678 /* CCUIEditBoxIOS.h in Headers */,
FA6F1B941D80F858007DD223 /* AnimationData.h in Headers */,
4DED47FD1DFFA4AF0070C5C4 /* b2PolygonShape.h in Headers */,
15AE1BF219AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */,
15AE1BEB19AAE01E00C27E9E /* CCControlButton.h in Headers */,
1A570281180BCC900088DEC7 /* CCSprite.h in Headers */,
1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */,
1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */,
@@ -4929,7 +4742,6 @@
4DED487F1DFFA4AF0070C5C4 /* b2RopeJoint.h in Headers */,
1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */,
15AE1BC419AADFFB00C27E9E /* ExtensionMacros.h in Headers */,
15AE1BFE19AAE01E00C27E9E /* CCInvocation.h in Headers */,
1AFFCD781F7A59B200628F2C /* CCThreadPool.h in Headers */,
4DC06BF01E8B604B00CA08B1 /* CCPhysicsManifoldWrapper.h in Headers */,
50ABBD4B1925AB0000A911A9 /* Mat4.h in Headers */,
@@ -4974,7 +4786,6 @@
FA6F1B441D80F858007DD223 /* Animation.h in Headers */,
50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */,
1A28FF561F20AFAB007A1D9D /* SRIOConsumerPool.h in Headers */,
15AE1C0619AAE01E00C27E9E /* CCTableViewCell.h in Headers */,
50ABBEBE1925AB6F00A911A9 /* ccUtils.h in Headers */,
1A28FF7E1F20AFAB007A1D9D /* SRMutex.h in Headers */,
FA6F1B8C1D80F858007DD223 /* Point.h in Headers */,
@@ -4985,7 +4796,6 @@
50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */,
BAFF7DDB1D5C1CF80051B92F /* VertexAttachment.h in Headers */,
1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */,
15AE1BF419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */,
50643BD519BFAECF00EF68ED /* CCGL.h in Headers */,
B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */,
50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */,
@@ -5004,9 +4814,7 @@
50ABBEAE1925AB6F00A911A9 /* ccTypes.h in Headers */,
4DED48371DFFA4AF0070C5C4 /* b2ChainAndCircleContact.h in Headers */,
BA679B3F1CEC373000F875FA /* Manifest.h in Headers */,
15AE1BF819AAE01E00C27E9E /* CCControlStepper.h in Headers */,
50ABBE261925AB6F00A911A9 /* base64.h in Headers */,
15AE1BF619AAE01E00C27E9E /* CCControlSlider.h in Headers */,
50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */,
1A28FF5C1F20AFAB007A1D9D /* NSURLRequest+SRWebSocketPrivate.h in Headers */,
50ABBDC01925AB4100A911A9 /* CCTextureCache.h in Headers */,
@@ -5019,7 +4827,6 @@
15AE184B19AAD30500C27E9E /* Export.h in Headers */,
50ABBED21925AB6F00A911A9 /* TGAlib.h in Headers */,
4DED47F11DFFA4AF0070C5C4 /* b2ChainShape.h in Headers */,
15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */,
4DED48771DFFA4AF0070C5C4 /* b2PulleyJoint.h in Headers */,
4DED483F1DFFA4AF0070C5C4 /* b2CircleContact.h in Headers */,
4DED48531DFFA4AF0070C5C4 /* b2PolygonAndCircleContact.h in Headers */,
@@ -5034,7 +4841,6 @@
50ABC01C1926664800A911A9 /* CCSAXParser.h in Headers */,
503DD8F11926736A00CD74DD /* OpenGL_Internal-ios.h in Headers */,
50ABBDAA1925AB4100A911A9 /* CCRenderCommand.h in Headers */,
15AE1BE919AAE01E00C27E9E /* CCControl.h in Headers */,
BAFF7DCD1D5C1CF80051B92F /* spine-cocos2dx.h in Headers */,
B63990CF1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */,
A614E2E11C8E761D0065A737 /* CCLabelTTF.h in Headers */,
@@ -5123,12 +4929,9 @@
4D2E69071CC543B40032DD5C /* CCGraphicsNode.cpp in Sources */,
4DED48221DFFA4AF0070C5C4 /* b2Fixture.cpp in Sources */,
50ABBE2B1925AB6F00A911A9 /* ccCArray.cpp in Sources */,
15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */,
15AE1BE219AAE01E00C27E9E /* CCScrollView.cpp in Sources */,
50ABBD581925AB0000A911A9 /* Vec2.cpp in Sources */,
50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */,
4D2E690B1CC543B40032DD5C /* Triangulate.cpp in Sources */,
15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */,
4DED47F21DFFA4AF0070C5C4 /* b2CircleShape.cpp in Sources */,
4DED481E1DFFA4AF0070C5C4 /* b2ContactManager.cpp in Sources */,
5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */,
@@ -5146,7 +4949,6 @@
4DED48581DFFA4AF0070C5C4 /* b2DistanceJoint.cpp in Sources */,
50ABBDA71925AB4100A911A9 /* CCRenderCommand.cpp in Sources */,
50ABBD501925AB0000A911A9 /* Quaternion.cpp in Sources */,
15AE1BE619AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */,
4DFA4C171CBCE34100E3B736 /* CCScale9Sprite.cpp in Sources */,
50ABBEBB1925AB6F00A911A9 /* ccUtils.cpp in Sources */,
ED30579A1BEC77B70083C3ED /* ConvertUTF.c in Sources */,
@@ -5161,9 +4963,7 @@
50ABBE8B1925AB6F00A911A9 /* CCNS.cpp in Sources */,
FA6F1B551D80F858007DD223 /* Armature.cpp in Sources */,
1A28FF6B1F20AFAB007A1D9D /* SRConstants.m in Sources */,
15AE1BD819AAE01E00C27E9E /* CCControlStepper.cpp in Sources */,
1A570061180BC5A10088DEC7 /* CCAction.cpp in Sources */,
15AE1BDC19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */,
294D7D9C1D0E93A2002CE7B7 /* CCDevice-apple.mm in Sources */,
BAFF7D7A1D5C1CF80051B92F /* EventData.c in Sources */,
4DED48301DFFA4AF0070C5C4 /* b2WorldCallbacks.cpp in Sources */,
@@ -5227,13 +5027,11 @@
15AE1B6D19AADA9900C27E9E /* UIHelper.cpp in Sources */,
29394CF219B01DBA00D2DE1A /* UIWebView.mm in Sources */,
A0534A671B872FFD006B03E5 /* CCDownloader-apple.mm in Sources */,
15AE1BD419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */,
BAFF7D621D5C1CF80051B92F /* AttachmentVertices.cpp in Sources */,
1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */,
50CB247B19D9C5A100687767 /* AudioEngine-inl.mm in Sources */,
1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */,
1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */,
15AE1BCD19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */,
BAFF7DD01D5C1CF80051B92F /* TransformConstraint.c in Sources */,
1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */,
BAFF7D6A1D5C1CF80051B92F /* BoneData.c in Sources */,
@@ -5275,7 +5073,6 @@
1A5701EE180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */,
1A5701F7180BCBAD0088DEC7 /* CCMenu.cpp in Sources */,
ED3057821BEC76C90083C3ED /* unzip.cpp in Sources */,
15AE1BC919AAE01E00C27E9E /* CCControl.cpp in Sources */,
1A5701FB180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */,
1A570202180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */,
A63CF0091CD9CF3500A6971D /* CCUIPasswordTextField.m in Sources */,
@@ -5292,7 +5089,6 @@
1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */,
A0E749F71BA8FD7F001A8332 /* UIEditBoxImpl-common.cpp in Sources */,
BAFF7D661D5C1CF80051B92F /* Bone.c in Sources */,
15AE1BD019AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */,
B276EF651988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */,
50ABBE411925AB6F00A911A9 /* CCDirector.cpp in Sources */,
4DC06BE31E8A68D400CA08B1 /* CCPhysicsUtils.cpp in Sources */,
@@ -5321,7 +5117,6 @@
50693C5E1B6BF2AE005C5820 /* CCDownloader.cpp in Sources */,
50ABBEAF1925AB6F00A911A9 /* CCUserDefault.cpp in Sources */,
BAFF7D4A1D5C1CF80051B92F /* AnimationState.c in Sources */,
15AE1BCB19AAE01E00C27E9E /* CCControlButton.cpp in Sources */,
50ABBE791925AB6F00A911A9 /* CCEventMouse.cpp in Sources */,
A05DCF9D1B90584E00EE040B /* CCDownloader-curl.cpp in Sources */,
4DED48001DFFA4AF0070C5C4 /* b2BlockAllocator.cpp in Sources */,
@@ -5333,7 +5128,6 @@
1A28FF4F1F20AFAB007A1D9D /* SRDelegateController.m in Sources */,
1A5702EA180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */,
50ABBD971925AB4100A911A9 /* CCGLProgramStateCache.cpp in Sources */,
15AE1BD619AAE01E00C27E9E /* CCControlSlider.cpp in Sources */,
50ABBE691925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */,
4DED485C1DFFA4AF0070C5C4 /* b2FrictionJoint.cpp in Sources */,
FA6F1B951D80F858007DD223 /* ArmatureData.cpp in Sources */,
@@ -5380,7 +5174,6 @@
4DED48401DFFA4AF0070C5C4 /* b2Contact.cpp in Sources */,
50ABBEA71925AB6F00A911A9 /* CCTouch.cpp in Sources */,
BAFF7D9A1D5C1CF80051B92F /* PathConstraintData.c in Sources */,
A60A9D611C200DE10070800A /* CCPhysicsSprite.cpp in Sources */,
FA6F1BA91D80F858007DD223 /* JSONDataParser.cpp in Sources */,
4DED48441DFFA4AF0070C5C4 /* b2ContactSolver.cpp in Sources */,
BA68D7891D62F4A500B7A3F9 /* cdt.cc in Sources */,
@@ -5409,7 +5202,6 @@
4DED48781DFFA4AF0070C5C4 /* b2RevoluteJoint.cpp in Sources */,
15AE1B6719AADA9900C27E9E /* UIScale9Sprite.cpp in Sources */,
1AAF584F180E40B9000584C8 /* LocalStorage.cpp in Sources */,
15AE1BD219AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */,
50ABBEA31925AB6F00A911A9 /* CCScriptSupport.cpp in Sources */,
826294331AAF001C00CB7CF7 /* HttpAsynConnection-apple.m in Sources */,
50ABBE6D1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */,
@@ -5421,7 +5213,6 @@
4DC06BCF1E8A68D400CA08B1 /* CCPhysicsAABBQueryCallback.cpp in Sources */,
50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */,
50ABBDB91925AB4100A911A9 /* CCTextureAtlas.cpp in Sources */,
15AE1BE419AAE01E00C27E9E /* CCTableView.cpp in Sources */,
FA6F1B911D80F858007DD223 /* AnimationData.cpp in Sources */,
BA68D77D1D62F4A500B7A3F9 /* shapes.cc in Sources */,
50ABBECF1925AB6F00A911A9 /* TGAlib.cpp in Sources */,
@@ -5474,7 +5265,6 @@
4DED47DA1DFFA4AF0070C5C4 /* b2CollideEdge.cpp in Sources */,
15AE1B6B19AADA9900C27E9E /* UIWidget.cpp in Sources */,
50ABBE931925AB6F00A911A9 /* CCProfiling.cpp in Sources */,
A60A9D5F1C200DE10070800A /* CCPhysicsDebugNode.cpp in Sources */,
1A28FF9D1F20AFAB007A1D9D /* SRWebSocket.m in Sources */,
1ABA68AE1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */,
1A28FF931F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.m in Sources */,
@@ -5490,13 +5280,11 @@
15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */,
FA6F1B521D80F858007DD223 /* WorldClock.cpp in Sources */,
1A28FF601F20AFAB007A1D9D /* SRProxyConnect.m in Sources */,
15AE1C0519AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */,
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */,
FA6F1B701D80F858007DD223 /* CCSlot.cpp in Sources */,
50ABBDA01925AB4100A911A9 /* CCGroupCommand.cpp in Sources */,
1A28FF901F20AFAB007A1D9D /* NSRunLoop+SRWebSocket.m in Sources */,
50ABC0161926664800A911A9 /* CCImage.cpp in Sources */,
15AE1BFB19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */,
B230ED7219B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */,
4DED47DD1DFFA4AF0070C5C4 /* b2CollidePolygon.cpp in Sources */,
15AE1B9019AADA9A00C27E9E /* UIWidget.cpp in Sources */,
@@ -5516,7 +5304,6 @@
BAFF7D9B1D5C1CF80051B92F /* PathConstraintData.c in Sources */,
FA6F1B961D80F858007DD223 /* ArmatureData.cpp in Sources */,
503DD8EE1926736A00CD74DD /* CCImage-ios.mm in Sources */,
15AE1BEA19AAE01E00C27E9E /* CCControlButton.cpp in Sources */,
50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */,
ED30578B1BEC774D0083C3ED /* ioapi_mem.cpp in Sources */,
FA6F1B421D80F858007DD223 /* Animation.cpp in Sources */,
@@ -5524,7 +5311,6 @@
4DFA4C181CBCE34100E3B736 /* CCScale9Sprite.cpp in Sources */,
1A28FF9A1F20AFAB007A1D9D /* SRSecurityPolicy.m in Sources */,
50ABBE281925AB6F00A911A9 /* CCAutoreleasePool.cpp in Sources */,
A60A9D641C200DE70070800A /* CCPhysicsSprite.cpp in Sources */,
BAFF7D531D5C1CF80051B92F /* Atlas.c in Sources */,
1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */,
1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
@@ -5532,11 +5318,9 @@
4DC06BE81E8A68D400CA08B1 /* CCPhysicsWorldManifoldWrapper.cpp in Sources */,
1A28FF581F20AFAB007A1D9D /* SRIOConsumerPool.m in Sources */,
B276EF661988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */,
15AE1C0119AAE01E00C27E9E /* CCScrollView.cpp in Sources */,
ED30579E1BEC77BD0083C3ED /* ConvertUTFWrapper.cpp in Sources */,
1A28FF801F20AFAB007A1D9D /* SRMutex.m in Sources */,
1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
15AE1BEF19AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */,
BAFF7DA31D5C1CF80051B92F /* Skeleton.c in Sources */,
BAFF7D4F1D5C1CF80051B92F /* AnimationStateData.c in Sources */,
BA679B391CEC373000F875FA /* CCEventListenerAssetsManagerEx.cpp in Sources */,
@@ -5552,7 +5336,6 @@
4DED48411DFFA4AF0070C5C4 /* b2Contact.cpp in Sources */,
FA6F1B841D80F858007DD223 /* BaseFactory.cpp in Sources */,
DABC9FAA19E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */,
15AE1BF119AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */,
4DED48791DFFA4AF0070C5C4 /* b2RevoluteJoint.cpp in Sources */,
4DED47D91DFFA4AF0070C5C4 /* b2CollideCircle.cpp in Sources */,
50ABBE621925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */,
@@ -5562,7 +5345,6 @@
4DED48491DFFA4AF0070C5C4 /* b2EdgeAndCircleContact.cpp in Sources */,
BAFF7D6F1D5C1CF80051B92F /* BoundingBoxAttachment.c in Sources */,
4D2E690C1CC543B40032DD5C /* Triangulate.cpp in Sources */,
15AE1BF719AAE01E00C27E9E /* CCControlStepper.cpp in Sources */,
4DED48651DFFA4AF0070C5C4 /* b2Joint.cpp in Sources */,
50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */,
ED30578A1BEC77460083C3ED /* tinyxml2.cpp in Sources */,
@@ -5571,7 +5353,6 @@
50ABBE461925AB6F00A911A9 /* CCEvent.cpp in Sources */,
50ABBEA01925AB6F00A911A9 /* CCScheduler.cpp in Sources */,
50ABBE4E1925AB6F00A911A9 /* CCEventCustom.cpp in Sources */,
15AE1BF519AAE01E00C27E9E /* CCControlSlider.cpp in Sources */,
4DC06BEE1E8B604B00CA08B1 /* CCPhysicsManifoldWrapper.cpp in Sources */,
50ABBE761925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
50ABBE5A1925AB6F00A911A9 /* CCEventKeyboard.cpp in Sources */,
@@ -5580,7 +5361,6 @@
50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */,
4DED480B1DFFA4AF0070C5C4 /* b2Math.cpp in Sources */,
1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */,
15AE1BEC19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */,
4DC06BD41E8A68D400CA08B1 /* CCPhysicsContactListener.cpp in Sources */,
FA6F1B4E1D80F858007DD223 /* TimelineState.cpp in Sources */,
50ABBEC01925AB6F00A911A9 /* CCValue.cpp in Sources */,
@@ -5591,10 +5371,8 @@
1A28FF9E1F20AFAB007A1D9D /* SRWebSocket.m in Sources */,
50ABBE421925AB6F00A911A9 /* CCDirector.cpp in Sources */,
BAFF7D831D5C1CF80051B92F /* IkConstraint.c in Sources */,
15AE1C0319AAE01E00C27E9E /* CCTableView.cpp in Sources */,
BA679B311CEC373000F875FA /* AssetsManagerEx.cpp in Sources */,
1A57007E180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */,
15AE1BF319AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */,
4DC06BD01E8A68D400CA08B1 /* CCPhysicsAABBQueryCallback.cpp in Sources */,
1A570082180BC5A10088DEC7 /* CCActionManager.cpp in Sources */,
4D6CF4381E83AAD5003327D4 /* CCCameraNode.cpp in Sources */,
@@ -5693,7 +5471,6 @@
1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */,
4DED48751DFFA4AF0070C5C4 /* b2PulleyJoint.cpp in Sources */,
BAFF7DA71D5C1CF80051B92F /* SkeletonAnimation.cpp in Sources */,
15AE1BE819AAE01E00C27E9E /* CCControl.cpp in Sources */,
1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */,
ED30579D1BEC77B90083C3ED /* ConvertUTF.c in Sources */,
BA8122AC1D77C4160010BEE9 /* CCLabelTTF.cpp in Sources */,
@@ -5701,7 +5478,6 @@
15AE1BBD19AADFF000C27E9E /* SocketIO.cpp in Sources */,
BAFF7DAB1D5C1CF80051B92F /* SkeletonBatch.cpp in Sources */,
4DED483D1DFFA4AF0070C5C4 /* b2CircleContact.cpp in Sources */,
15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */,
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */,
BAFF7D4B1D5C1CF80051B92F /* AnimationState.c in Sources */,
29394CF719B01DBA00D2DE1A /* UIWebViewImpl-ios.mm in Sources */,
@@ -5785,7 +5561,6 @@
50ABBDA81925AB4100A911A9 /* CCRenderCommand.cpp in Sources */,
50ABBEA41925AB6F00A911A9 /* CCScriptSupport.cpp in Sources */,
503DD8E71926736A00CD74DD /* CCEAGLView-ios.mm in Sources */,
A60A9D631C200DE40070800A /* CCPhysicsDebugNode.cpp in Sources */,
3E2BDAEC19C0436F0055CDCD /* AudioEngine.cpp in Sources */,
52B47A311A5349A3004E4C60 /* HttpCookie.cpp in Sources */,
50ABBDA41925AB4100A911A9 /* CCQuadCommand.cpp in Sources */,
@@ -5799,7 +5574,6 @@
BA68D7861D62F4A500B7A3F9 /* advancing_front.cc in Sources */,
FA6F1B561D80F858007DD223 /* Armature.cpp in Sources */,
1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */,
15AE1BF919AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */,
A6E018661CB7A7E000EC1419 /* CCDownloader.cpp in Sources */,
BAFF7DD11D5C1CF80051B92F /* TransformConstraint.c in Sources */,
50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */,
-33
View File
@@ -162,22 +162,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32\libs\*.*" "$(OutDir)"
<ClCompile Include="..\..\extensions\assets-manager\CCEventAssetsManagerEx.cpp" />
<ClCompile Include="..\..\extensions\assets-manager\CCEventListenerAssetsManagerEx.cpp" />
<ClCompile Include="..\..\extensions\assets-manager\Manifest.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControl.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlButton.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlColourPicker.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlHuePicker.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlPotentiometer.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSaturationBrightnessPicker.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSlider.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlStepper.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSwitch.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlUtils.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCInvocation.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCScrollView.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCTableView.cpp" />
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCTableViewCell.cpp" />
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp" />
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsSprite.cpp" />
<ClCompile Include="..\..\external\sources\clipper\clipper.cpp" />
<ClCompile Include="..\..\external\sources\ConvertUTF\ConvertUTF.c" />
<ClCompile Include="..\..\external\sources\ConvertUTF\ConvertUTFWrapper.cpp" />
@@ -391,23 +375,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32\libs\*.*" "$(OutDir)"
<ClInclude Include="..\..\extensions\cocos-ext.h" />
<ClInclude Include="..\..\extensions\ExtensionExport.h" />
<ClInclude Include="..\..\extensions\ExtensionMacros.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControl.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlButton.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlColourPicker.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlExtensions.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlHuePicker.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlPotentiometer.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSaturationBrightnessPicker.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSlider.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlStepper.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSwitch.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlUtils.h" />
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCInvocation.h" />
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCScrollView.h" />
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCTableView.h" />
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCTableViewCell.h" />
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.h" />
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsSprite.h" />
<ClInclude Include="..\..\external\sources\clipper\clipper.hpp" />
<ClInclude Include="..\..\external\sources\ConvertUTF\ConvertUTF.h" />
<ClInclude Include="..\..\external\sources\edtaa3func\edtaa3func.h" />
-111
View File
@@ -52,12 +52,6 @@
<Filter Include="extension">
<UniqueIdentifier>{976bf662-699e-482e-b5db-a20d4abab137}</UniqueIdentifier>
</Filter>
<Filter Include="extension\GUI">
<UniqueIdentifier>{b27aba95-51a2-413c-8570-0aff9adf2b6b}</UniqueIdentifier>
</Filter>
<Filter Include="extension\GUI\CCScrollView">
<UniqueIdentifier>{a1f539bc-d5be-4224-a4d2-01c0b6f17d6e}</UniqueIdentifier>
</Filter>
<Filter Include="network">
<UniqueIdentifier>{31338a7d-ebe1-4867-9c17-d3645122a864}</UniqueIdentifier>
</Filter>
@@ -79,9 +73,6 @@
<Filter Include="ui\UIWidgets\EditBox">
<UniqueIdentifier>{89eb6312-dc7f-4fda-b9b2-ab67c31ddd55}</UniqueIdentifier>
</Filter>
<Filter Include="extension\GUI\CCControlExtensions">
<UniqueIdentifier>{118d80ca-ccf2-480c-b87d-25220af23440}</UniqueIdentifier>
</Filter>
<Filter Include="audioengine">
<UniqueIdentifier>{e916e2b4-0a6e-4d25-8b36-66fa03719f48}</UniqueIdentifier>
</Filter>
@@ -100,9 +91,6 @@
<Filter Include="creator">
<UniqueIdentifier>{691a1234-91c6-4c12-992d-3973f4da830f}</UniqueIdentifier>
</Filter>
<Filter Include="extension\PhysicsSprite">
<UniqueIdentifier>{87ddafca-e85f-430b-bfa1-b6e09279138f}</UniqueIdentifier>
</Filter>
<Filter Include="extension\AssetManager">
<UniqueIdentifier>{c1b7ac70-432f-4d5b-bd3b-5ff5fce3436b}</UniqueIdentifier>
</Filter>
@@ -565,15 +553,6 @@
<ClCompile Include="..\base\ccRandom.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCScrollView.cpp">
<Filter>extension\GUI\CCScrollView</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCTableView.cpp">
<Filter>extension\GUI\CCScrollView</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCScrollView\CCTableViewCell.cpp">
<Filter>extension\GUI\CCScrollView</Filter>
</ClCompile>
<ClCompile Include="..\network\HttpClient.cpp">
<Filter>network\Source Files</Filter>
</ClCompile>
@@ -595,39 +574,6 @@
<ClCompile Include="..\ui\UIEditBox\UIEditBox.cpp">
<Filter>ui\UIWidgets\EditBox</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControl.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlButton.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlColourPicker.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlHuePicker.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlPotentiometer.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSaturationBrightnessPicker.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSlider.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlStepper.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlSwitch.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCControlUtils.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\GUI\CCControlExtension\CCInvocation.cpp">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClCompile>
<ClCompile Include="..\platform\win32\CCApplication-win32.cpp">
<Filter>platform\win32</Filter>
</ClCompile>
@@ -695,12 +641,6 @@
<ClCompile Include="..\editor-support\creator\CCScale9Sprite.cpp">
<Filter>creator</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp">
<Filter>extension\PhysicsSprite</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsSprite.cpp">
<Filter>extension\PhysicsSprite</Filter>
</ClCompile>
<ClCompile Include="..\..\extensions\assets-manager\AssetsManagerEx.cpp">
<Filter>extension\AssetManager</Filter>
</ClCompile>
@@ -1272,15 +1212,6 @@
<ClInclude Include="..\base\ccRandom.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCScrollView.h">
<Filter>extension\GUI\CCScrollView</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCTableView.h">
<Filter>extension\GUI\CCScrollView</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCScrollView\CCTableViewCell.h">
<Filter>extension\GUI\CCScrollView</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\cocos-ext.h">
<Filter>extension</Filter>
</ClInclude>
@@ -1326,42 +1257,6 @@
<ClInclude Include="..\ui\UIEditBox\UIEditBoxImpl.h">
<Filter>ui\UIWidgets\EditBox</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControl.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlButton.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlColourPicker.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlExtensions.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlHuePicker.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlPotentiometer.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSaturationBrightnessPicker.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSlider.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlStepper.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlSwitch.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCControlUtils.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\GUI\CCControlExtension\CCInvocation.h">
<Filter>extension\GUI\CCControlExtensions</Filter>
</ClInclude>
<ClInclude Include="..\platform\win32\CCApplication-win32.h">
<Filter>platform\win32</Filter>
</ClInclude>
@@ -1453,12 +1348,6 @@
<ClInclude Include="..\editor-support\creator\CCScale9Sprite.h">
<Filter>creator</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.h">
<Filter>extension\PhysicsSprite</Filter>
</ClInclude>
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsSprite.h">
<Filter>extension\PhysicsSprite</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\creator\CCGraphicsNode.h">
<Filter>creator</Filter>
</ClInclude>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -78,284 +78,3 @@ SE_DECLARE_FUNC(js_cocos2dx_extension_EventListenerAssetsManagerEx_init);
SE_DECLARE_FUNC(js_cocos2dx_extension_EventListenerAssetsManagerEx_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_EventListenerAssetsManagerEx_EventListenerAssetsManagerEx);
extern se::Object* __jsb_cocos2d_extension_Control_proto;
extern se::Class* __jsb_cocos2d_extension_Control_class;
bool js_register_cocos2d_extension_Control(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_setEnabled);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_getState);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_sendActionsForControlEvents);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_setSelected);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_isEnabled);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_needsLayout);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_hasVisibleParents);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_isSelected);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_isTouchInside);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_setHighlighted);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_getTouchLocation);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_isHighlighted);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_Control_Control);
extern se::Object* __jsb_cocos2d_extension_ControlButton_proto;
extern se::Class* __jsb_cocos2d_extension_ControlButton_class;
bool js_register_cocos2d_extension_ControlButton(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_isPushed);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleLabelForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setLabelAnchorPoint);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getLabelAnchorPoint);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_initWithBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleTTFForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setPreferredSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getCurrentTitleColor);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setZoomOnTouchDown);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getHorizontalOrigin);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleBMFontForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getScaleRatio);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleTTFForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleColorForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setTitleColorForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setScaleRatio);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleBMFontForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getPreferredSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getVerticalMargin);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleLabelForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_setMargins);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getCurrentTitle);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getZoomOnTouchDown);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_getTitleForState);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlButton_ControlButton);
extern se::Object* __jsb_cocos2d_extension_ControlHuePicker_proto;
extern se::Class* __jsb_cocos2d_extension_ControlHuePicker_class;
bool js_register_cocos2d_extension_ControlHuePicker(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_setHue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_getStartPos);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_getHue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_getSlider);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_setBackground);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_setHuePercentage);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_getBackground);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_getHuePercentage);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_setSlider);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlHuePicker_ControlHuePicker);
extern se::Object* __jsb_cocos2d_extension_ControlSaturationBrightnessPicker_proto;
extern se::Class* __jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class;
bool js_register_cocos2d_extension_ControlSaturationBrightnessPicker(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSaturationBrightnessPicker_ControlSaturationBrightnessPicker);
extern se::Object* __jsb_cocos2d_extension_ControlColourPicker_proto;
extern se::Class* __jsb_cocos2d_extension_ControlColourPicker_class;
bool js_register_cocos2d_extension_ControlColourPicker(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_getHuePicker);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_getcolourPicker);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_setBackground);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_setcolourPicker);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_setHuePicker);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_getBackground);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlColourPicker_ControlColourPicker);
extern se::Object* __jsb_cocos2d_extension_ControlPotentiometer_proto;
extern se::Class* __jsb_cocos2d_extension_ControlPotentiometer_class;
bool js_register_cocos2d_extension_ControlPotentiometer(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getProgressTimer);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getMaximumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setMaximumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getMinimumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setProgressTimer);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_setMinimumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_getThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlPotentiometer_ControlPotentiometer);
extern se::Object* __jsb_cocos2d_extension_ControlSlider_proto;
extern se::Class* __jsb_cocos2d_extension_ControlSlider_class;
bool js_register_cocos2d_extension_ControlSlider(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_initWithSprites);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getMaximumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setProgressSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setMaximumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getMinimumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getBackgroundSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_locationFromTouch);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setMinimumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_getProgressSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSlider_ControlSlider);
extern se::Object* __jsb_cocos2d_extension_ControlStepper_proto;
extern se::Class* __jsb_cocos2d_extension_ControlStepper_class;
bool js_register_cocos2d_extension_ControlStepper(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_getMinusSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setStepValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setMaximumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_getMinusLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_getPlusLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setWraps);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setMinusLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_startAutorepeat);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_isContinuous);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_stopAutorepeat);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setMinimumValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setPlusLabel);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_getValue);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_getPlusSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setPlusSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_setMinusSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlStepper_ControlStepper);
extern se::Object* __jsb_cocos2d_extension_ControlSwitch_proto;
extern se::Class* __jsb_cocos2d_extension_ControlSwitch_class;
bool js_register_cocos2d_extension_ControlSwitch(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_setOn);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_locationFromTouch);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_isOn);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_initWithMaskSprite);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_hasMoved);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ControlSwitch_ControlSwitch);
extern se::Object* __jsb_cocos2d_extension_ScrollView_proto;
extern se::Class* __jsb_cocos2d_extension_ScrollView_class;
bool js_register_cocos2d_extension_ScrollView(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isClippingToBounds);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setContainer);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setContentOffsetInDuration);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setZoomScaleInDuration);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_updateTweenAction);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setMaxScale);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_hasVisibleParents);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_getDirection);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_getContainer);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setMinScale);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_getZoomScale);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_updateInset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_initWithViewSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_pause);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setDirection);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_stopAnimatedContentOffset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setContentOffset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isDragging);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isTouchEnabled);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isBounceable);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setTouchEnabled);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_getContentOffset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_resume);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setClippingToBounds);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setViewSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_getViewSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_maxContainerOffset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setBounceable);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isTouchMoved);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_isNodeVisible);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_minContainerOffset);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_setZoomScale);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_ScrollView_ScrollView);
extern se::Object* __jsb_cocos2d_extension_TableViewCell_proto;
extern se::Class* __jsb_cocos2d_extension_TableViewCell_class;
bool js_register_cocos2d_extension_TableViewCell(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableViewCell_reset);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableViewCell_getIdx);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableViewCell_setIdx);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableViewCell_create);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableViewCell_TableViewCell);
extern se::Object* __jsb_cocos2d_extension_TableView_proto;
extern se::Class* __jsb_cocos2d_extension_TableView_class;
bool js_register_cocos2d_extension_TableView(se::Object* obj);
bool register_all_cocos2dx_extension(se::Object* obj);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_updateCellAtIndex);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_setVerticalFillOrder);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_scrollViewDidZoom);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView__updateContentSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_getVerticalFillOrder);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_removeCellAtIndex);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_initWithViewSize);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_scrollViewDidScroll);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_reloadData);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_insertCellAtIndex);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_cellAtIndex);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_dequeueCell);
SE_DECLARE_FUNC(js_cocos2dx_extension_TableView_TableView);
-16
View File
@@ -14,22 +14,6 @@ assets-manager/Manifest.cpp \
assets-manager/AssetsManagerEx.cpp \
assets-manager/CCEventAssetsManagerEx.cpp \
assets-manager/CCEventListenerAssetsManagerEx.cpp \
GUI/CCControlExtension/CCControl.cpp \
GUI/CCControlExtension/CCControlButton.cpp \
GUI/CCControlExtension/CCControlColourPicker.cpp \
GUI/CCControlExtension/CCControlHuePicker.cpp \
GUI/CCControlExtension/CCControlPotentiometer.cpp \
GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \
GUI/CCControlExtension/CCControlSlider.cpp \
GUI/CCControlExtension/CCControlStepper.cpp \
GUI/CCControlExtension/CCControlSwitch.cpp \
GUI/CCControlExtension/CCControlUtils.cpp \
GUI/CCControlExtension/CCInvocation.cpp \
GUI/CCScrollView/CCScrollView.cpp \
GUI/CCScrollView/CCTableView.cpp \
GUI/CCScrollView/CCTableViewCell.cpp \
physics-nodes/CCPhysicsDebugNode.cpp \
physics-nodes/CCPhysicsSprite.cpp
LOCAL_STATIC_LIBRARIES := cocos2dx_internal_static
LOCAL_STATIC_LIBRARIES += cocos_chipmunk_static
@@ -1,338 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* converted to c++ / cocos2d-x by Angus C
*/
#include "CCControl.h"
#include "base/CCDirector.h"
#include "2d/CCMenu.h"
#include "base/CCTouch.h"
#include "CCInvocation.h"
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerTouch.h"
NS_CC_EXT_BEGIN
Control::Control()
: _enabled(false)
, _selected(false)
, _highlighted(false)
, _hasVisibleParents(false)
, _isOpacityModifyRGB(false)
, _state(State::NORMAL)
{
}
Control* Control::create()
{
Control* pRet = new (std::nothrow) Control();
if (pRet && pRet->init())
{
pRet->autorelease();
return pRet;
}
else
{
CC_SAFE_DELETE(pRet);
return nullptr;
}
}
bool Control::init()
{
if (Layer::init())
{
// Initialise instance variables
_state=Control::State::NORMAL;
setEnabled(true);
setSelected(false);
setHighlighted(false);
auto dispatcher = Director::getInstance()->getEventDispatcher();
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(true);
touchListener->onTouchBegan = CC_CALLBACK_2(Control::onTouchBegan, this);
touchListener->onTouchMoved = CC_CALLBACK_2(Control::onTouchMoved, this);
touchListener->onTouchEnded = CC_CALLBACK_2(Control::onTouchEnded, this);
touchListener->onTouchCancelled = CC_CALLBACK_2(Control::onTouchCancelled, this);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
return true;
}
else
{
return false;
}
}
Control::~Control()
{
for (auto iter = _dispatchTable.begin(); iter != _dispatchTable.end(); ++iter)
{
delete iter->second;
}
_dispatchTable.clear();
}
void Control::sendActionsForControlEvents(EventType controlEvents)
{
retain();
// For each control events
for (int i = 0; i < kControlEventTotalNumber; i++)
{
// If the given controlEvents bitmask contains the curent event
if (((int)controlEvents & (1 << i)))
{
// Call invocations
const auto& invocationList = this->dispatchListforControlEvent((Control::EventType)(1<<i));
for(const auto &invocation : invocationList) {
invocation->invoke(this);
}
#if CC_ENABLE_SCRIPT_BINDING
//Call ScriptFunc
if (kScriptTypeLua == _scriptType)
{
cocos2d::BasicScriptData data(this,(void*)&controlEvents);
cocos2d::ScriptEvent event(cocos2d::kControlEvent,(void*)&data);
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
#endif
}
}
release();
}
void Control::addTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents)
{
// For each control events
for (int i = 0; i < kControlEventTotalNumber; i++)
{
// If the given controlEvents bitmask contains the curent event
if (((int)controlEvents & (1 << i)))
{
this->addTargetWithActionForControlEvent(target, action, (EventType)(1<<i));
}
}
}
/**
* Adds a target and action for a particular event to an internal dispatch
* table.
* The action message may optionnaly include the sender and the event as
* parameters, in that order.
* When you call this method, target is not retained.
*
* @param target The target object that is, the object to which the action
* message is sent. It cannot be nil. The target is not retained.
* @param action A selector identifying an action message. It cannot be nullptr.
* @param controlEvent A control event for which the action message is sent.
* See "CCControlEvent" for constants.
*/
void Control::addTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent)
{
// Create the invocation object
Invocation *invocation = Invocation::create(target, action, controlEvent);
// Add the invocation into the dispatch list for the given control event
auto& eventInvocationList = this->dispatchListforControlEvent(controlEvent);
eventInvocationList.pushBack(invocation);
}
void Control::removeTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents)
{
// For each control events
for (int i = 0; i < kControlEventTotalNumber; i++)
{
// If the given controlEvents bitmask contains the curent event
if (((int)controlEvents & (1 << i)))
{
this->removeTargetWithActionForControlEvent(target, action, (EventType)(1 << i));
}
}
}
void Control::removeTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent)
{
// Retrieve all invocations for the given control event
//<Invocation*>
auto& eventInvocationList = this->dispatchListforControlEvent(controlEvent);
//remove all invocations if the target and action are null
//TODO: should the invocations be deleted, or just removed from the array? Won't that cause issues if you add a single invocation for multiple events?
if (!target && !action)
{
//remove objects
eventInvocationList.clear();
}
else
{
std::vector<Invocation*> tobeRemovedInvocations;
//normally we would use a predicate, but this won't work here. Have to do it manually
for(const auto &invocation : eventInvocationList) {
bool shouldBeRemoved=true;
if (target)
{
shouldBeRemoved=(target==invocation->getTarget());
}
if (action)
{
shouldBeRemoved=(shouldBeRemoved && (action==invocation->getAction()));
}
// Remove the corresponding invocation object
if (shouldBeRemoved)
{
tobeRemovedInvocations.push_back(invocation);
}
}
for(const auto &invocation : tobeRemovedInvocations) {
eventInvocationList.eraseObject(invocation);
}
}
}
//CRGBA protocol
void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
{
_isOpacityModifyRGB=bOpacityModifyRGB;
for(auto child : _children){
child->setOpacityModifyRGB(bOpacityModifyRGB);
}
}
bool Control::isOpacityModifyRGB() const
{
return _isOpacityModifyRGB;
}
Vec2 Control::getTouchLocation(Touch* touch)
{
Vec2 touchLocation = touch->getLocation(); // Get the touch position
touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class
return touchLocation;
}
bool Control::isTouchInside(Touch* touch)
{
Vec2 touchLocation = touch->getLocation(); // Get the touch position
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
Rect bBox = getBoundingBox();
return bBox.containsPoint(touchLocation);
}
Vector<Invocation*>& Control::dispatchListforControlEvent(EventType controlEvent)
{
Vector<Invocation*>* invocationList = nullptr;
auto iter = _dispatchTable.find((int)controlEvent);
// If the invocation list does not exist for the dispatch table, we create it
if (iter == _dispatchTable.end())
{
invocationList = new (std::nothrow) Vector<Invocation*>();
_dispatchTable[(int)controlEvent] = invocationList;
}
else
{
invocationList = iter->second;
}
return *invocationList;
}
void Control::needsLayout()
{
}
void Control::setEnabled(bool bEnabled)
{
_enabled = bEnabled;
if(_enabled) {
_state = Control::State::NORMAL;
} else {
_state = Control::State::DISABLED;
}
this->needsLayout();
}
bool Control::isEnabled() const
{
return _enabled;
}
void Control::setSelected(bool bSelected)
{
_selected = bSelected;
this->needsLayout();
}
bool Control::isSelected() const
{
return _selected;
}
void Control::setHighlighted(bool bHighlighted)
{
_highlighted = bHighlighted;
this->needsLayout();
}
bool Control::isHighlighted() const
{
return _highlighted;
}
bool Control::hasVisibleParents() const
{
auto parent = this->getParent();
for( auto c = parent; c != nullptr; c = c->getParent() )
{
if( !c->isVisible() )
{
return false;
}
}
return true;
}
Control::EventType operator|(Control::EventType a, Control::EventType b) {
return static_cast<Control::EventType>(static_cast<int>(a) | static_cast<int>(b));
}
NS_CC_EXT_END
@@ -1,278 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_H__
#define __CCCONTROL_H__
#include "CCControlUtils.h"
#include "2d/CCLayer.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
class Invocation;
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
/** Number of kinds of control event. */
#define kControlEventTotalNumber 9
/*
* @class
* Control is inspired by the UIControl API class from the UIKit library of
* CocoaTouch. It provides a base class for control Sprites such as Button
* or Slider that convey user intent to the application.
*
* The goal of Control is to define an interface and base implementation for
* preparing action messages and initially dispatching them to their targets when
* certain events occur.
*
* To use the Control you have to subclass it.
*/
class CC_EX_DLL Control : public Layer
{
public:
/** Kinds of possible events for the control objects. */
enum class CC_EX_DLL EventType
{
TOUCH_DOWN = 1 << 0, // A touch-down event in the control.
DRAG_INSIDE = 1 << 1, // An event where a finger is dragged inside the bounds of the control.
DRAG_OUTSIDE = 1 << 2, // An event where a finger is dragged just outside the bounds of the control.
DRAG_ENTER = 1 << 3, // An event where a finger is dragged into the bounds of the control.
DRAG_EXIT = 1 << 4, // An event where a finger is dragged from within a control to outside its bounds.
TOUCH_UP_INSIDE = 1 << 5, // A touch-up event in the control where the finger is inside the bounds of the control.
TOUCH_UP_OUTSIDE = 1 << 6, // A touch-up event in the control where the finger is outside the bounds of the control.
TOUCH_CANCEL = 1 << 7, // A system event canceling the current touches for the control.
VALUE_CHANGED = 1 << 8 // A touch dragging or otherwise manipulating a control, causing it to emit a series of different values.
};
typedef void (Ref::*Handler)(Ref*, EventType);
/** The possible state for a control. */
enum class State
{
NORMAL = 1 << 0, // The normal, or default state of a control。ェthat is, enabled but neither selected nor highlighted.
HIGH_LIGHTED = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
DISABLED = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
SELECTED = 1 << 3 // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
};
/** Creates a Control object */
static Control* create();
/** Tells whether the control is enabled. */
virtual void setEnabled(bool bEnabled);
virtual bool isEnabled() const;
/** A Boolean value that determines the control selected state. */
virtual void setSelected(bool bSelected);
virtual bool isSelected() const;
/** A Boolean value that determines whether the control is highlighted. */
virtual void setHighlighted(bool bHighlighted);
virtual bool isHighlighted() const;
bool hasVisibleParents() const;
/**
* Updates the control layout using its current internal state.
*/
virtual void needsLayout();
/**
* Sends action messages for the given control events.
*
* @param controlEvents A bitmask whose set flags specify the control events for
* which action messages are sent. See "CCControlEvent" for bitmask constants.
*/
virtual void sendActionsForControlEvents(EventType controlEvents);
/**
* Adds a target and action for a particular event (or events) to an internal
* dispatch table.
* The action message may optionnaly include the sender and the event as
* parameters, in that order.
* When you call this method, target is not retained.
*
* @param target The target object that is, the object to which the action
* message is sent. It cannot be nil. The target is not retained.
* @param action A selector identifying an action message. It cannot be NULL.
* @param controlEvents A bitmask specifying the control events for which the
* action message is sent. See "CCControlEvent" for bitmask constants.
*/
virtual void addTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents);
/**
* Removes a target and action for a particular event (or events) from an
* internal dispatch table.
*
* @param target The target object葉hat is, the object to which the action
* message is sent. Pass nil to remove all targets paired with action and the
* specified control events.
* @param action A selector identifying an action message. Pass NULL to remove
* all action messages paired with target.
* @param controlEvents A bitmask specifying the control events associated with
* target and action. See "CCControlEvent" for bitmask constants.
*/
virtual void removeTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents);
/**
* Returns a point corresponding to the touh location converted into the
* control space coordinates.
* @param touch A Touch object that represents a touch.
*/
virtual Vec2 getTouchLocation(Touch* touch);
virtual bool onTouchBegan(Touch *touch, Event *event) { return false; };
virtual void onTouchMoved(Touch *touch, Event *event) {};
virtual void onTouchEnded(Touch *touch, Event *event) {};
virtual void onTouchCancelled(Touch *touch, Event *event) {};
/**
* Returns a boolean value that indicates whether a touch is inside the bounds
* of the receiver. The given touch must be relative to the world.
*
* @param touch A Touch object that represents a touch.
*
* @return Whether a touch is inside the receiver's rect.
*/
virtual bool isTouchInside(Touch * touch);
// Overrides
virtual bool isOpacityModifyRGB() const override;
virtual void setOpacityModifyRGB(bool bOpacityModifyRGB) override;
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
Control();
/**
* @js NA
* @lua NA
*/
virtual ~Control();
virtual bool init(void) override;
protected:
/**
* Returns an Invocation object able to construct messages using a given
* target-action pair. (The invocation may optionnaly include the sender and
* the event as parameters, in that order)
*
* @param target The target object.
* @param action A selector identifying an action message.
* @param controlEvent A control events for which the action message is sent.
* See "CCControlEvent" for constants.
*
* @return an Invocation object able to construct messages using a given
* target-action pair.
*/
Invocation* invocationWithTargetAndActionForControlEvent(Ref* target, Handler action, EventType controlEvent);
/**
* Returns the Invocation list for the given control event. If the list does
* not exist, it'll create an empty array before returning it.
*
* @param controlEvent A control events for which the action message is sent.
* See "CCControlEvent" for constants.
*
* @return the Invocation list for the given control event.
*/
Vector<Invocation*>& dispatchListforControlEvent(EventType controlEvent);
/**
* Adds a target and action for a particular event to an internal dispatch
* table.
* The action message may optionnaly include the sender and the event as
* parameters, in that order.
* When you call this method, target is not retained.
*
* @param target The target object。ェthat is, the object to which the action
* message is sent. It cannot be nil. The target is not retained.
* @param action A selector identifying an action message. It cannot be NULL.
* @param controlEvent A control event for which the action message is sent.
* See "CCControlEvent" for constants.
*/
void addTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent);
/**
* Removes a target and action for a particular event from an internal dispatch
* table.
*
* @param target The target object。ェthat is, the object to which the action
* message is sent. Pass nil to remove all targets paired with action and the
* specified control events.
* @param action A selector identifying an action message. Pass NULL to remove
* all action messages paired with target.
* @param controlEvent A control event for which the action message is sent.
* See "CCControlEvent" for constants.
*/
void removeTargetWithActionForControlEvent(Ref* target, Handler action, EventType controlEvent);
bool _enabled;
bool _selected;
bool _highlighted;
/** True if all of the controls parents are visible */
bool _hasVisibleParents;
/**
* Table of connection between the ControlEvents and their associated
* target-actions pairs. For each ButtonEvents a list of NSInvocation
* (which contains the target-action pair) is linked.
*/
std::unordered_map<int, Vector<Invocation*>*> _dispatchTable;
//CCRGBAProtocol
bool _isOpacityModifyRGB;
/** The current control state constant. */
CC_SYNTHESIZE_READONLY(State, _state, State);
private:
CC_DISALLOW_COPY_AND_ASSIGN(Control);
};
CC_EX_DLL Control::EventType operator|(Control::EventType a, Control::EventType b);
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,755 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "CCControlButton.h"
#include "2d/CCLabel.h"
#include "2d/CCAction.h"
#include "2d/CCActionInterval.h"
using namespace std;
NS_CC_EXT_BEGIN
enum
{
kZoomActionTag = 0xCCCB0001,
};
ControlButton::ControlButton()
: _isPushed(false)
, _parentInited(false)
, _doesAdjustBackgroundImage(false)
, _currentTitleColor(Color3B::WHITE)
, _titleLabel(nullptr)
, _backgroundSprite(nullptr)
, _zoomOnTouchDown(false)
, _marginV(ControlButtonMarginTB)
, _marginH(ControlButtonMarginLR)
{
}
ControlButton::~ControlButton()
{
CC_SAFE_RELEASE(_titleLabel);
CC_SAFE_RELEASE(_backgroundSprite);
}
//initialisers
bool ControlButton::init()
{
return this->initWithLabelAndBackgroundSprite(Label::createWithSystemFont("", "Helvetica", 12), cocos2d::ui::Scale9Sprite::create(),true);
}
bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize)
{
if (Control::init())
{
CCASSERT(node != nullptr, "node must not be nil.");
if (node == nullptr) {
return false;
}
LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil.");
CCASSERT(label != nullptr, "label must not be nil.");
if (backgroundSprite == nullptr || label == nullptr) {
return false;
}
_parentInited = true;
_isPushed = false;
setPreferredSize(Size::ZERO);
// Adjust the background image by adjustBackGroundSize
setAdjustBackgroundImage(adjustBackGroundSize);
// Zooming button by default
_zoomOnTouchDown = true;
_scaleRatio = 1.1f;
// Set the default anchor point
setIgnoreAnchorPointForPosition(false);
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
// Set the nodes
setTitleLabel(node);
setBackgroundSprite(backgroundSprite);
// Set the default color and opacity
setColor(Color3B::WHITE);
setOpacity(255.0f);
setOpacityModifyRGB(true);
// Initialize the dispatch table
setTitleForState(label->getString(), Control::State::NORMAL);
setTitleColorForState(node->getColor(), Control::State::NORMAL);
setTitleLabelForState(node, Control::State::NORMAL);
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
setLabelAnchorPoint(Vec2::ANCHOR_MIDDLE);
// Layout update
needsLayout();
return true;
}
//couldn't init the Control
else
{
return false;
}
}
ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite)
{
ControlButton *ret = new (std::nothrow) ControlButton();
if (ret && ret->initWithLabelAndBackgroundSprite(label, backgroundSprite, true))
{
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}
ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize)
{
ControlButton *pRet = new (std::nothrow) ControlButton();
pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite, adjustBackGroundSize);
pRet->autorelease();
return pRet;
}
bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize)
{
return initWithLabelAndBackgroundSprite(Label::createWithSystemFont(title, fontName, fontSize), cocos2d::ui::Scale9Sprite::create(),true);
}
ControlButton* ControlButton::create(const std::string& title, const std::string& fontName, float fontSize)
{
ControlButton *pRet = new (std::nothrow) ControlButton();
pRet->initWithTitleAndFontNameAndFontSize(title, fontName, fontSize);
pRet->autorelease();
return pRet;
}
bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite)
{
Label *label = Label::createWithSystemFont("", "Arial", 30);//
return initWithLabelAndBackgroundSprite(label, sprite,false);
}
ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite)
{
ControlButton *pRet = new (std::nothrow) ControlButton();
pRet->initWithBackgroundSprite(sprite);
pRet->autorelease();
return pRet;
}
void ControlButton::setMargins(int marginH, int marginV)
{
_marginV = marginV;
_marginH = marginH;
needsLayout();
}
void ControlButton::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
needsLayout();
}
void ControlButton::setSelected(bool enabled)
{
Control::setSelected(enabled);
needsLayout();
}
void ControlButton::setHighlighted(bool enabled)
{
if (enabled == true)
{
_state = Control::State::HIGH_LIGHTED;
}
else
{
_state = Control::State::NORMAL;
}
Control::setHighlighted(enabled);
Action *action = getActionByTag(kZoomActionTag);
if (action)
{
stopAction(action);
}
needsLayout();
if( _zoomOnTouchDown )
{
float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? _scaleRatio : 1.0f;
Action *zoomAction = ScaleTo::create(0.05f, scaleValue);
zoomAction->setTag(kZoomActionTag);
runAction(zoomAction);
}
}
void ControlButton::setZoomOnTouchDown(bool zoomOnTouchDown)
{
_zoomOnTouchDown = zoomOnTouchDown;
}
bool ControlButton::getZoomOnTouchDown() const
{
return _zoomOnTouchDown;
}
void ControlButton::setPreferredSize(const Size& size)
{
if(size.width == 0 && size.height == 0)
{
_doesAdjustBackgroundImage = true;
}
else
{
_doesAdjustBackgroundImage = false;
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->setPreferredSize(size);
}
}
_preferredSize = size;
needsLayout();
}
const Size& ControlButton::getPreferredSize() const
{
return _preferredSize;
}
void ControlButton::setAdjustBackgroundImage(bool adjustBackgroundImage)
{
_doesAdjustBackgroundImage = adjustBackgroundImage;
needsLayout();
}
bool ControlButton::doesAdjustBackgroundImage()
{
return _doesAdjustBackgroundImage;
}
const Vec2& ControlButton::getLabelAnchorPoint() const
{
return this->_labelAnchorPoint;
}
void ControlButton::setLabelAnchorPoint(const Vec2& labelAnchorPoint)
{
this->_labelAnchorPoint = labelAnchorPoint;
if (_titleLabel != nullptr)
{
this->_titleLabel->setAnchorPoint(labelAnchorPoint);
}
}
std::string ControlButton::getTitleForState(State state)
{
auto iter = _titleDispatchTable.find((int)state);
if (iter != _titleDispatchTable.end())
{
return iter->second;
}
iter = _titleDispatchTable.find((int)Control::State::NORMAL);
return iter != _titleDispatchTable.end() ? iter->second : "";
}
void ControlButton::setTitleForState(const std::string& title, State state)
{
_titleDispatchTable.erase((int)state);
if (!title.empty())
{
_titleDispatchTable[(int)state] = title;
}
// If the current state if equal to the given state we update the layout
if (getState() == state)
{
needsLayout();
}
}
Color3B ControlButton::getTitleColorForState(State state) const
{
Color3B returnColor = Color3B::WHITE;
auto iter = _titleColorDispatchTable.find((int)state);
if (iter != _titleColorDispatchTable.end())
{
returnColor = iter->second;
}
else
{
iter = _titleColorDispatchTable.find((int)Control::State::NORMAL);
if (iter != _titleColorDispatchTable.end())
{
returnColor = iter->second;
}
}
return returnColor;
}
void ControlButton::setTitleColorForState(const Color3B& color, State state)
{
_titleColorDispatchTable.erase((int)state);
_titleColorDispatchTable[(int)state] = color;
// If the current state if equal to the given state we update the layout
if (getState() == state)
{
needsLayout();
}
}
Node* ControlButton::getTitleLabelForState(State state)
{
Node* titleLabel = _titleLabelDispatchTable.at((int)state);
if (titleLabel)
{
return titleLabel;
}
return _titleLabelDispatchTable.at((int)Control::State::NORMAL);
}
void ControlButton::setTitleLabelForState(Node* titleLabel, State state)
{
Node* previousLabel = _titleLabelDispatchTable.at((int)state);
if (previousLabel)
{
removeChild(previousLabel, true);
_titleLabelDispatchTable.erase((int)state);
}
_titleLabelDispatchTable.insert((int)state, titleLabel);
titleLabel->setVisible(false);
titleLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
addChild(titleLabel, 1);
// If the current state if equal to the given state we update the layout
if (getState() == state)
{
needsLayout();
}
}
void ControlButton::setTitleTTFForState(const std::string& fontName, State state)
{
this->setTitleLabelForState(Label::createWithSystemFont(getTitleForState(state), fontName, 12), state);
}
const std::string& ControlButton::getTitleTTFForState(State state)
{
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0)
{
return labelTTF->getSystemFontName();
}
static std::string ret("");
return ret;
}
void ControlButton::setTitleTTFSizeForState(float size, State state)
{
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
if(label)
{
Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0)
{
return labelTTF->setSystemFontSize(size);
}
}
}
float ControlButton::getTitleTTFSizeForState(State state)
{
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
Label* labelTTF = dynamic_cast<Label*>(label);
if(labelTTF != 0)
{
return labelTTF->getSystemFontSize();
}
else
{
return 0;
}
}
void ControlButton::setTitleBMFontForState(const std::string& fntFile, State state)
{
std::string title = this->getTitleForState(state);
this->setTitleLabelForState(Label::createWithBMFont(fntFile, title, nullptr), state);
}
const std::string& ControlButton::getTitleBMFontForState(State state)
{
LabelProtocol* label = dynamic_cast<LabelProtocol*>(this->getTitleLabelForState(state));
auto labelBMFont = dynamic_cast<Label*>(label);
if(labelBMFont != 0)
{
return labelBMFont->getBMFontFilePath();
}
static std::string ret("");
return ret;
}
ui::Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state)
{
auto backgroundSprite = _backgroundSpriteDispatchTable.at((int)state);
if (backgroundSprite)
{
return backgroundSprite;
}
return _backgroundSpriteDispatchTable.at((int)Control::State::NORMAL);
}
void ControlButton::setBackgroundSpriteForState(ui::Scale9Sprite* sprite, State state)
{
Size oldPreferredSize = _preferredSize;
auto previousBackgroundSprite = _backgroundSpriteDispatchTable.at((int)state);
if (previousBackgroundSprite)
{
removeChild(previousBackgroundSprite, true);
_backgroundSpriteDispatchTable.erase((int)state);
}
_backgroundSpriteDispatchTable.insert((int)state, sprite);
sprite->setVisible(false);
sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
addChild(sprite);
if (this->_preferredSize.width != 0 || this->_preferredSize.height != 0)
{
if (oldPreferredSize.equals(_preferredSize))
{
// Force update of preferred size
sprite->setPreferredSize(Size(oldPreferredSize.width+1, oldPreferredSize.height+1));
}
sprite->setPreferredSize(this->_preferredSize);
}
// If the current state if equal to the given state we update the layout
if (getState() == state)
{
needsLayout();
}
}
void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state)
{
ui::Scale9Sprite * sprite = ui::Scale9Sprite::createWithSpriteFrame(spriteFrame);
this->setBackgroundSpriteForState(sprite, state);
}
void ControlButton::needsLayout()
{
if (!_parentInited) {
return;
}
// Hide the background and the label
if (_titleLabel != nullptr) {
_titleLabel->setVisible(false);
}
if (_backgroundSprite) {
_backgroundSprite->setVisible(false);
}
// Update anchor of all labels
this->setLabelAnchorPoint(this->_labelAnchorPoint);
// Update the label to match with the current state
_currentTitle = getTitleForState(_state);
_currentTitleColor = getTitleColorForState(_state);
this->setTitleLabel(getTitleLabelForState(_state));
LabelProtocol* label = dynamic_cast<LabelProtocol*>(_titleLabel);
if (label && !_currentTitle.empty())
{
label->setString(_currentTitle);
}
if (_titleLabel)
{
_titleLabel->setColor(_currentTitleColor);
}
if (_titleLabel != nullptr)
{
_titleLabel->setPosition(getContentSize().width / 2, getContentSize().height / 2);
}
// Update the background sprite
this->setBackgroundSprite(this->getBackgroundSpriteForState(_state));
if (_backgroundSprite != nullptr)
{
_backgroundSprite->setPosition(getContentSize().width / 2, getContentSize().height / 2);
}
// Get the title label size
Size titleLabelSize;
if (_titleLabel != nullptr)
{
titleLabelSize = _titleLabel->getBoundingBox().size;
}
// Adjust the background image if necessary
if (_doesAdjustBackgroundImage)
{
// Add the margins
if (_backgroundSprite != nullptr)
{
_backgroundSprite->setContentSize(Size(titleLabelSize.width + _marginH * 2, titleLabelSize.height + _marginV * 2));
}
}
else
{
//TODO: should this also have margins if one of the preferred sizes is relaxed?
if (_backgroundSprite != nullptr)
{
Size preferredSize = _backgroundSprite->getPreferredSize();
if (preferredSize.width <= 0)
{
preferredSize.width = titleLabelSize.width;
}
if (preferredSize.height <= 0)
{
preferredSize.height = titleLabelSize.height;
}
_backgroundSprite->setContentSize(preferredSize);
}
}
// Set the content size
Rect rectTitle;
if (_titleLabel != nullptr)
{
rectTitle = _titleLabel->getBoundingBox();
}
Rect rectBackground;
if (_backgroundSprite != nullptr)
{
rectBackground = _backgroundSprite->getBoundingBox();
}
Rect maxRect = ControlUtils::RectUnion(rectTitle, rectBackground);
setContentSize(Size(maxRect.size.width, maxRect.size.height));
if (_titleLabel != nullptr)
{
_titleLabel->setPosition(getContentSize().width/2, getContentSize().height/2);
// Make visible the background and the label
_titleLabel->setVisible(true);
}
if (_backgroundSprite != nullptr)
{
_backgroundSprite->setPosition(getContentSize().width/2, getContentSize().height/2);
_backgroundSprite->setVisible(true);
}
}
bool ControlButton::onTouchBegan(Touch *pTouch, Event *pEvent)
{
if (!isTouchInside(pTouch) || !isEnabled() || !isVisible() || !hasVisibleParents() )
{
return false;
}
for (Node *c = this->_parent; c != nullptr; c = c->getParent())
{
if (c->isVisible() == false)
{
return false;
}
}
_isPushed = true;
this->setHighlighted(true);
sendActionsForControlEvents(Control::EventType::TOUCH_DOWN);
return true;
}
void ControlButton::onTouchMoved(Touch *pTouch, Event *pEvent)
{
if (!isEnabled() || !isPushed() || isSelected())
{
if (isHighlighted())
{
setHighlighted(false);
}
return;
}
bool isTouchMoveInside = isTouchInside(pTouch);
if (isTouchMoveInside && !isHighlighted())
{
setHighlighted(true);
sendActionsForControlEvents(Control::EventType::DRAG_ENTER);
}
else if (isTouchMoveInside && isHighlighted())
{
sendActionsForControlEvents(Control::EventType::DRAG_INSIDE);
}
else if (!isTouchMoveInside && isHighlighted())
{
setHighlighted(false);
sendActionsForControlEvents(Control::EventType::DRAG_EXIT);
}
else if (!isTouchMoveInside && !isHighlighted())
{
sendActionsForControlEvents(Control::EventType::DRAG_OUTSIDE);
}
}
void ControlButton::onTouchEnded(Touch *pTouch, Event *pEvent)
{
_isPushed = false;
setHighlighted(false);
if (isTouchInside(pTouch))
{
sendActionsForControlEvents(Control::EventType::TOUCH_UP_INSIDE);
}
else
{
sendActionsForControlEvents(Control::EventType::TOUCH_UP_OUTSIDE);
}
}
void ControlButton::setOpacity(GLubyte opacity)
{
Control::setOpacity(opacity);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->setOpacity(opacity);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->setOpacity(opacity);
}
}
void ControlButton::updateDisplayedOpacity(GLubyte parentOpacity)
{
Control::updateDisplayedOpacity(parentOpacity);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedOpacity(parentOpacity);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedOpacity(parentOpacity);
}
}
void ControlButton::setColor(const Color3B & color)
{
Control::setColor(color);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->setColor(color);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->setColor(color);
}
}
void ControlButton::updateDisplayedColor(const Color3B& parentColor)
{
Control::updateDisplayedColor(parentColor);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedColor(parentColor);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedColor(parentColor);
}
}
void ControlButton::onTouchCancelled(Touch *pTouch, Event *pEvent)
{
_isPushed = false;
setHighlighted(false);
sendActionsForControlEvents(Control::EventType::TOUCH_CANCEL);
}
ControlButton* ControlButton::create()
{
ControlButton *pControlButton = new (std::nothrow) ControlButton();
if (pControlButton && pControlButton->init())
{
pControlButton->autorelease();
return pControlButton;
}
CC_SAFE_DELETE(pControlButton);
return nullptr;
}
NS_CC_EXT_END
@@ -1,259 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_BUTTON_H__
#define __CCCONTROL_BUTTON_H__
#include "CCControl.h"
#include "CCInvocation.h"
#include "base/CCMap.h"
#include "ui/UIScale9Sprite.h"
NS_CC_EXT_BEGIN
/* Define the button margin for Left/Right edge */
#define ControlButtonMarginLR 8 // px
/* Define the button margin for Top/Bottom edge */
#define ControlButtonMarginTB 2 // px
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
/** @class ControlButton Button control for Cocos2D. */
class CC_EX_DLL ControlButton : public Control
{
public:
static ControlButton* create();
static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite);
static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite);
static ControlButton* create(const std::string& title, const std::string& fontName, float fontSize);
static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize);
virtual void needsLayout(void) override;
virtual void setEnabled(bool enabled) override;
virtual void setSelected(bool enabled) override;
virtual void setHighlighted(bool enabled) override;
bool isPushed() const { return _isPushed; }
/**
* Returns the title used for a state.
*
* @param state The state that uses the title. Possible values are described in
* "CCControlState".
*
* @return The title for the specified state.
*/
virtual std::string getTitleForState(State state);
/**
* Sets the title string to use for the specified state.
* If a property is not specified for a state, the default is to use
* the ButtonStateNormal value.
*
* @param title The title string to use for the specified state.
* @param state The state that uses the specified title. The values are described
* in "CCControlState".
*/
virtual void setTitleForState(const std::string& title, State state);
/**
* Returns the title color used for a state.
*
* @param state The state that uses the specified color. The values are described
* in "CCControlState".
*
* @return The color of the title for the specified state.
*/
virtual Color3B getTitleColorForState(State state) const;
/**
* Sets the color of the title to use for the specified state.
*
* @param color The color of the title to use for the specified state.
* @param state The state that uses the specified color. The values are described
* in "CCControlState".
*/
virtual void setTitleColorForState(const Color3B& color, State state);
/**
* Returns the title label used for a state.
*
* @param state The state that uses the title label. Possible values are described
* in "CCControlState".
*/
virtual Node* getTitleLabelForState(State state);
/**
* Sets the title label to use for the specified state.
* If a property is not specified for a state, the default is to use
* the ButtonStateNormal value.
*
* @param label The title label to use for the specified state.
* @param state The state that uses the specified title. The values are described
* in "CCControlState".
*/
virtual void setTitleLabelForState(Node* label, State state);
virtual void setTitleTTFForState(const std::string& fntFile, State state);
virtual const std::string& getTitleTTFForState(State state);
virtual void setTitleTTFSizeForState(float size, State state);
virtual float getTitleTTFSizeForState(State state);
/**
* Sets the font of the label, changes the label to a BMFont if necessary.
* @param fntFile The name of the font to change to
* @param state The state that uses the specified fntFile. The values are described
* in "CCControlState".
*/
virtual void setTitleBMFontForState(const std::string& fntFile, State state);
virtual const std::string& getTitleBMFontForState(State state);
/**
* Returns the background sprite used for a state.
*
* @param state The state that uses the background sprite. Possible values are
* described in "CCControlState".
*/
virtual cocos2d::ui::Scale9Sprite* getBackgroundSpriteForState(State state);
/**
* Sets the background sprite to use for the specified button state.
*
* @param sprite The background sprite to use for the specified state.
* @param state The state that uses the specified image. The values are described
* in "CCControlState".
*/
virtual void setBackgroundSpriteForState(cocos2d::ui::Scale9Sprite* sprite, State state);
/**
* Sets the background spriteFrame to use for the specified button state.
*
* @param spriteFrame The background spriteFrame to use for the specified state.
* @param state The state that uses the specified image. The values are described
* in "CCControlState".
*/
virtual void setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state);
//set the margins at once (so we only have to do one call of needsLayout)
virtual void setMargins(int marginH, int marginV);
/** Adjust the background image. YES by default. If the property is set to NO, the
background will use the preferred size of the background image. */
bool doesAdjustBackgroundImage();
void setAdjustBackgroundImage(bool adjustBackgroundImage);
// Overrides
virtual bool onTouchBegan(Touch *touch, Event *event) override;
virtual void onTouchMoved(Touch *touch, Event *event) override;
virtual void onTouchEnded(Touch *touch, Event *event) override;
virtual void onTouchCancelled(Touch *touch, Event *event) override;
virtual void setOpacity(GLubyte var) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual void setColor(const Color3B&) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
const std::string& getCurrentTitle() const { return _currentTitle; };
std::string getCurrentTitle() { return _currentTitle; };
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
ControlButton();
/**
* @js NA
* @lua NA
*/
virtual ~ControlButton();
virtual bool init() override;
virtual bool initWithLabelAndBackgroundSprite(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize);
virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite);
virtual bool initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize);
protected:
bool _isPushed;
bool _parentInited;
bool _doesAdjustBackgroundImage;
/** The current title that is displayed on the button. */
std::string _currentTitle;
/** The current color used to display the title. */
CC_SYNTHESIZE_READONLY_PASS_BY_REF(Color3B, _currentTitleColor, CurrentTitleColor);
/** The current title label. */
CC_SYNTHESIZE_RETAIN(Node*, _titleLabel, TitleLabel);
/** The current background sprite. */
CC_SYNTHESIZE_RETAIN(cocos2d::ui::Scale9Sprite*, _backgroundSprite, BackgroundSprite);
/** The preferred size of the button, if label is larger it will be expanded. */
CC_PROPERTY_PASS_BY_REF(Size, _preferredSize, PreferredSize);
/** Adjust the button zooming on touchdown. Default value is YES. */
CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown);
/** Scale ratio button on touchdown. Default value 1.1f */
CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio);
CC_PROPERTY_PASS_BY_REF(Vec2, _labelAnchorPoint, LabelAnchorPoint);
std::unordered_map<int, std::string> _titleDispatchTable;
std::unordered_map<int, Color3B> _titleColorDispatchTable;
Map<int, Node*> _titleLabelDispatchTable;
Map<int, cocos2d::ui::Scale9Sprite*> _backgroundSpriteDispatchTable;
/* Define the button margin for Top/Bottom edge */
CC_SYNTHESIZE_READONLY(int, _marginV, VerticalMargin);
/* Define the button margin for Left/Right edge */
CC_SYNTHESIZE_READONLY(int, _marginH, HorizontalOrigin);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ControlButton);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,200 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* converted to c++ / cocos2d-x by Angus C
*/
#include "CCControlColourPicker.h"
#include "2d/CCSpriteFrameCache.h"
#include "2d/CCSpriteBatchNode.h"
NS_CC_EXT_BEGIN
ControlColourPicker::ControlColourPicker()
: _colourPicker(nullptr)
, _huePicker(nullptr)
, _background(nullptr)
{
}
ControlColourPicker::~ControlColourPicker()
{
CC_SAFE_RELEASE(_background);
CC_SAFE_RELEASE(_huePicker);
CC_SAFE_RELEASE(_colourPicker);
}
bool ControlColourPicker::init()
{
if (Control::init())
{
// Cache the sprites
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist");
// Create the sprite batch node
SpriteBatchNode *spriteSheet = SpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png");
addChild(spriteSheet);
// MIPMAP
// ccTexParams params = {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
/* Comment next line to avoid something like mosaic in 'ControlExtensionTest',
especially the display of 'huePickerBackground.png' when in 800*480 window size with 480*320 design resolution and hd(960*640) resources.
*/
// spriteSheet->getTexture()->setAliasTexParameters();
// spriteSheet->getTexture()->setTexParameters(&params);
// spriteSheet->getTexture()->generateMipmap();
// Init default color
_hsv.h = 0;
_hsv.s = 0;
_hsv.v = 0;
// Add image
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vec2::ZERO, Vec2(0.5f, 0.5f));
if(!_background) return false;
CC_SAFE_RETAIN(_background);
Vec2 backgroundPointZero = _background->getPosition() - Vec2(_background->getContentSize().width / 2, _background->getContentSize().height / 2);
// Setup panels
float hueShift = 8;
float colourShift = 28;
_huePicker = new (std::nothrow) ControlHuePicker();
_huePicker->initWithTargetAndPos(spriteSheet, Vec2(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift));
_colourPicker = new (std::nothrow) ControlSaturationBrightnessPicker();
_colourPicker->initWithTargetAndPos(spriteSheet, Vec2(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift));
// Setup events
_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::hueSliderValueChanged), Control::EventType::VALUE_CHANGED);
_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlColourPicker::colourSliderValueChanged), Control::EventType::VALUE_CHANGED);
// Set defaults
updateHueAndControlPicker();
addChild(_huePicker);
addChild(_colourPicker);
// Set content size
setContentSize(_background->getContentSize());
return true;
}
else
return false;
}
ControlColourPicker* ControlColourPicker::create()
{
ControlColourPicker *pRet = new (std::nothrow) ControlColourPicker();
pRet->init();
pRet->autorelease();
return pRet;
}
void ControlColourPicker::setColor(const Color3B& color)
{
// FIXME: fixed me if not correct
Control::setColor(color);
RGBA rgba;
rgba.r = color.r / 255.0f;
rgba.g = color.g / 255.0f;
rgba.b = color.b / 255.0f;
rgba.a = 1.0f;
_hsv=ControlUtils::HSVfromRGB(rgba);
updateHueAndControlPicker();
}
void ControlColourPicker::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
if (_huePicker != nullptr)
{
_huePicker->setEnabled(enabled);
}
if (_colourPicker)
{
_colourPicker->setEnabled(enabled);
}
}
//need two events to prevent an infinite loop! (can't update huePicker when the huePicker triggers the callback due to Control::EventType::VALUE_CHANGED)
void ControlColourPicker::updateControlPicker()
{
_huePicker->setHue(_hsv.h);
_colourPicker->updateWithHSV(_hsv);
}
void ControlColourPicker::updateHueAndControlPicker()
{
_huePicker->setHue(_hsv.h);
_colourPicker->updateWithHSV(_hsv);
_colourPicker->updateDraggerWithHSV(_hsv);
}
void ControlColourPicker::hueSliderValueChanged(Ref * sender, Control::EventType controlEvent)
{
_hsv.h = ((ControlHuePicker*)sender)->getHue();
// Update the value
RGBA rgb = ControlUtils::RGBfromHSV(_hsv);
// FIXME: fixed me if not correct
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
// Send Control callback
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
updateControlPicker();
}
void ControlColourPicker::colourSliderValueChanged(Ref * sender, Control::EventType controlEvent)
{
_hsv.s=((ControlSaturationBrightnessPicker*)sender)->getSaturation();
_hsv.v=((ControlSaturationBrightnessPicker*)sender)->getBrightness();
// Update the value
RGBA rgb = ControlUtils::RGBfromHSV(_hsv);
// FIXME: fixed me if not correct
Control::setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
// Send Control callback
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
//ignore all touches, handled by children
bool ControlColourPicker::onTouchBegan(Touch* touch, Event* pEvent)
{
return false;
}
NS_CC_EXT_END
@@ -1,93 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_COLOUR_PICKER_H__
#define __CCCONTROL_COLOUR_PICKER_H__
#include "CCControl.h"
#include "CCControlUtils.h"
#include "CCControlHuePicker.h"
#include "CCControlSaturationBrightnessPicker.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
class CC_EX_DLL ControlColourPicker: public Control
{
public:
static ControlColourPicker* create();
/**
* @js ctor
* @lua new
*/
ControlColourPicker();
/**
* @js NA
* @lua NA
*/
virtual ~ControlColourPicker();
virtual bool init() override;
virtual void setColor(const Color3B& colorValue) override;
virtual void setEnabled(bool bEnabled) override;
//virtual ~ControlColourPicker();
void hueSliderValueChanged(Ref * sender, Control::EventType controlEvent);
void colourSliderValueChanged(Ref * sender, Control::EventType controlEvent);
protected:
void updateControlPicker();
void updateHueAndControlPicker();
virtual bool onTouchBegan(Touch* touch, Event* pEvent) override;
HSV _hsv;
CC_SYNTHESIZE_RETAIN(ControlSaturationBrightnessPicker*, _colourPicker, colourPicker)
CC_SYNTHESIZE_RETAIN(ControlHuePicker*, _huePicker, HuePicker)
CC_SYNTHESIZE_RETAIN(Sprite*, _background, Background)
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,37 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCCONTROL_EXTENSIONS_H__
#define __CCCONTROL_EXTENSIONS_H__
#include "CCControl.h"
#include "CCControlButton.h"
#include "CCControlColourPicker.h"
#include "CCControlPotentiometer.h"
#include "CCControlSlider.h"
#include "CCControlStepper.h"
#include "CCControlSwitch.h"
#endif
@@ -1,194 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#include "CCControlHuePicker.h"
NS_CC_EXT_BEGIN
ControlHuePicker::ControlHuePicker()
: _hue(0.0f)
, _huePercentage(0.0f)
, _background(nullptr)
, _slider(nullptr)
{
}
ControlHuePicker::~ControlHuePicker()
{
removeAllChildrenWithCleanup(true);
CC_SAFE_RELEASE(_background);
CC_SAFE_RELEASE(_slider);
}
ControlHuePicker* ControlHuePicker::create(Node* target, const Vec2& pos)
{
ControlHuePicker *pRet = new (std::nothrow) ControlHuePicker();
pRet->initWithTargetAndPos(target, pos);
pRet->autorelease();
return pRet;
}
bool ControlHuePicker::initWithTargetAndPos(Node* target, const Vec2& pos)
{
if (Control::init())
{
// Add background and slider sprites
this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Vec2::ZERO));
this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2::ANCHOR_MIDDLE));
_slider->setPosition(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f);
_startPos=pos;
// Sets the default value
_hue=0.0f;
_huePercentage=0.0f;
return true;
}
else
{
return false;
}
}
void ControlHuePicker::setHue(float hueValue)
{
_hue=hueValue;
// Set the position of the slider to the correct hue
// We need to divide it by 360 as its taken as an angle in degrees
float huePercentage = hueValue / 360.0f;
setHuePercentage(huePercentage);
}
void ControlHuePicker::setHuePercentage(float hueValueInPercent)
{
_huePercentage=hueValueInPercent;
_hue=_huePercentage*360.0f;
// Clamp the position of the icon within the circle
Rect backgroundBox=_background->getBoundingBox();
// Get the center point of the background image
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;
float centerY = _startPos.y + backgroundBox.size.height * 0.5f;
// Work out the limit to the distance of the picker when moving around the hue bar
float limit = backgroundBox.size.width * 0.5f - 15.0f;
// Update angle
float angleDeg = _huePercentage * 360.0f - 180.0f;
float angle = CC_DEGREES_TO_RADIANS(angleDeg);
// Set new position of the slider
float x = centerX + limit * cosf(angle);
float y = centerY + limit * sinf(angle);
_slider->setPosition(x, y);
}
void ControlHuePicker::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
if (_slider != nullptr)
{
_slider->setOpacity(enabled ? 255 : 128);
}
}
void ControlHuePicker::updateSliderPosition(const Vec2& location)
{
// Clamp the position of the icon within the circle
Rect backgroundBox=_background->getBoundingBox();
// Get the center point of the background image
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;
float centerY = _startPos.y + backgroundBox.size.height * 0.5f;
// Work out the distance difference between the location and center
float dx = location.x - centerX;
float dy = location.y - centerY;
// Update angle by using the direction of the location
float angle = atan2f(dy, dx);
float angleDeg = CC_RADIANS_TO_DEGREES(angle) + 180.0f;
// use the position / slider width to determin the percentage the dragger is at
setHue(angleDeg);
// send Control callback
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
bool ControlHuePicker::checkSliderPosition(const Vec2& location)
{
// compute the distance between the current location and the center
double distance = sqrt(pow (location.x + 10, 2) + pow(location.y, 2));
// check that the touch location is within the circle
if (80 > distance && distance > 59)
{
updateSliderPosition(location);
return true;
}
return false;
}
bool ControlHuePicker::onTouchBegan(Touch* touch, Event* event)
{
if (!isEnabled() || !isVisible())
{
return false;
}
// Get the touch location
Vec2 touchLocation=getTouchLocation(touch);
// Check the touch position on the slider
return checkSliderPosition(touchLocation);
}
void ControlHuePicker::onTouchMoved(Touch* touch, Event* event)
{
// Get the touch location
Vec2 touchLocation=getTouchLocation(touch);
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
// updateSliderPosition(touchLocation);
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
// Check the touch position on the slider
checkSliderPosition(touchLocation);
}
NS_CC_EXT_END
@@ -1,93 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_HUE_PICKER_H__
#define __CCCONTROL_HUE_PICKER_H__
#include "CCControl.h"
#include "CCInvocation.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
class CC_EX_DLL ControlHuePicker : public Control
{
public:
static ControlHuePicker* create(Node* target, const Vec2& pos);
/**
* @js ctor
*/
ControlHuePicker();
/**
* @js NA
* @lua NA
*/
virtual ~ControlHuePicker();
virtual bool initWithTargetAndPos(Node* target, const Vec2& pos);
virtual void setEnabled(bool enabled) override;
// overrides
virtual bool onTouchBegan(Touch* touch, Event* pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
protected:
void updateSliderPosition(const Vec2& location);
bool checkSliderPosition(const Vec2& location);
//maunally put in the setters
CC_SYNTHESIZE_READONLY(float, _hue, Hue);
virtual void setHue(float val);
CC_SYNTHESIZE_READONLY(float, _huePercentage, HuePercentage);
virtual void setHuePercentage(float val);
//not sure if these need to be there actually. I suppose someone might want to access the sprite?
CC_SYNTHESIZE_RETAIN(Sprite*, _background, Background);
CC_SYNTHESIZE_RETAIN(Sprite*, _slider, Slider);
CC_SYNTHESIZE_READONLY(Vec2, _startPos, StartPos);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,264 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "CCControlPotentiometer.h"
NS_CC_EXT_BEGIN
ControlPotentiometer::ControlPotentiometer()
: _value(0.0f)
, _minimumValue(0.0f)
, _maximumValue(0.0f)
, _thumbSprite(nullptr)
, _progressTimer(nullptr)
{
}
ControlPotentiometer::~ControlPotentiometer()
{
CC_SAFE_RELEASE(_thumbSprite);
CC_SAFE_RELEASE(_progressTimer);
}
ControlPotentiometer* ControlPotentiometer::create(const char* backgroundFile, const char* progressFile, const char* thumbFile)
{
ControlPotentiometer* pRet = new (std::nothrow) ControlPotentiometer();
if (pRet != nullptr)
{
// Prepare track for potentiometer
Sprite *backgroundSprite = Sprite::create(backgroundFile);
// Prepare thumb for potentiometer
Sprite *thumbSprite = Sprite::create(thumbFile);
// Prepare progress for potentiometer
ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create(progressFile));
//progressTimer.type = ProgressTimer::RADIALCW;
if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
}
return pRet;
}
bool ControlPotentiometer::initWithTrackSprite_ProgressTimer_ThumbSprite(Sprite* trackSprite, ProgressTimer* progressTimer, Sprite* thumbSprite)
{
if (Control::init())
{
setProgressTimer(progressTimer);
setThumbSprite(thumbSprite);
thumbSprite->setPosition(progressTimer->getPosition());
addChild(thumbSprite, 2);
addChild(progressTimer, 1);
addChild(trackSprite);
setContentSize(trackSprite->getContentSize());
// Init default values
_minimumValue = 0.0f;
_maximumValue = 1.0f;
setValue(_minimumValue);
return true;
}
return false;
}
void ControlPotentiometer::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
if (_thumbSprite != nullptr)
{
_thumbSprite->setOpacity((enabled) ? 255 : 128);
}
}
void ControlPotentiometer::setValue(float value)
{
// set new value with sentinel
if (value < _minimumValue)
{
value = _minimumValue;
}
if (value > _maximumValue)
{
value = _maximumValue;
}
_value = value;
// Update thumb and progress position for new value
float percent = (value - _minimumValue) / (_maximumValue - _minimumValue);
_progressTimer->setPercentage(percent * 100.0f);
_thumbSprite->setRotation(percent * 360.0f);
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
float ControlPotentiometer::getValue()
{
return _value;
}
void ControlPotentiometer::setMinimumValue(float minimumValue)
{
_minimumValue = minimumValue;
if (_minimumValue >= _maximumValue)
{
_maximumValue = _minimumValue + 1.0f;
}
setValue(_maximumValue);
}
float ControlPotentiometer::getMinimumValue()
{
return _minimumValue;
}
void ControlPotentiometer::setMaximumValue(float maximumValue)
{
_maximumValue = maximumValue;
if (_maximumValue <= _minimumValue)
{
_minimumValue = _maximumValue - 1.0f;
}
setValue(_minimumValue);
}
float ControlPotentiometer::getMaximumValue()
{
return _maximumValue;
}
bool ControlPotentiometer::isTouchInside(Touch * touch)
{
Vec2 touchLocation = this->getTouchLocation(touch);
float distance = this->distanceBetweenPointAndPoint(_progressTimer->getPosition(), touchLocation);
return distance < MIN(getContentSize().width / 2, getContentSize().height / 2);
}
bool ControlPotentiometer::onTouchBegan(Touch *pTouch, Event *pEvent)
{
if (!this->isTouchInside(pTouch) || !this->isEnabled() || !isVisible())
{
return false;
}
_previousLocation = this->getTouchLocation(pTouch);
this->potentiometerBegan(_previousLocation);
return true;
}
void ControlPotentiometer::onTouchMoved(Touch *pTouch, Event *pEvent)
{
Vec2 location = this->getTouchLocation(pTouch);
this->potentiometerMoved(location);
}
void ControlPotentiometer::onTouchEnded(Touch *pTouch, Event *pEvent)
{
this->potentiometerEnded(Vec2::ZERO);
}
float ControlPotentiometer::distanceBetweenPointAndPoint(const Vec2& point1, const Vec2& point2)
{
float dx = point1.x - point2.x;
float dy = point1.y - point2.y;
return sqrt(dx*dx + dy*dy);
}
float ControlPotentiometer::angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(
const Vec2& beginLineA,
const Vec2& endLineA,
const Vec2& beginLineB,
const Vec2& endLineB)
{
float a = endLineA.x - beginLineA.x;
float b = endLineA.y - beginLineA.y;
float c = endLineB.x - beginLineB.x;
float d = endLineB.y - beginLineB.y;
float atanA = atan2(a, b);
float atanB = atan2(c, d);
// convert radiants to degrees
return (atanA - atanB) * 180 / M_PI;
}
void ControlPotentiometer::potentiometerBegan(const Vec2& location)
{
setSelected(true);
getThumbSprite()->setColor(Color3B::GRAY);
}
void ControlPotentiometer::potentiometerMoved(const Vec2& location)
{
float angle = this->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(
_progressTimer->getPosition(),
location,
_progressTimer->getPosition(),
_previousLocation);
// fix value, if the 12 o'clock position is between location and previousLocation
if (angle > 180)
{
angle -= 360;
}
else if (angle < -180)
{
angle += 360;
}
setValue(_value + angle / 360.0f * (_maximumValue - _minimumValue));
_previousLocation = location;
}
void ControlPotentiometer::potentiometerEnded(const Vec2& location)
{
getThumbSprite()->setColor(Color3B::WHITE);
setSelected(false);
}
NS_CC_EXT_END
@@ -1,122 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef __CCCONTROLPOTENTIOMETER_H__
#define __CCCONTROLPOTENTIOMETER_H__
#include "CCControl.h"
#include "2d/CCProgressTimer.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
/** @class ControlPotentiometer Potentiometer control for Cocos2D. */
class CC_EX_DLL ControlPotentiometer : public Control
{
public:
/**
* Creates potentiometer with a track filename and a progress filename.
*/
static ControlPotentiometer* create(const char* backgroundFile, const char* progressFile, const char* thumbFile);
/**
* @js ctor
* @lua new
*/
ControlPotentiometer();
/**
* @js NA
* @lua NA
*/
virtual ~ControlPotentiometer();
/**
* Initializes a potentiometer with a track sprite and a progress bar.
*
* @param trackSprite Sprite, that is used as a background.
* @param progressTimer ProgressTimer, that is used as a progress bar.
*/
bool initWithTrackSprite_ProgressTimer_ThumbSprite(Sprite* trackSprite, ProgressTimer* progressTimer, Sprite* thumbSprite);
void setValue(float value);
float getValue();
void setMinimumValue(float minimumValue);
float getMinimumValue();
void setMaximumValue(float maximumValue);
float getMaximumValue();
// Overrides
virtual bool isTouchInside(Touch * touch) override;
void setEnabled(bool enabled) override;
virtual bool onTouchBegan(Touch *pTouch, Event *pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override;
/** Factorize the event dispath into these methods. */
void potentiometerBegan(const Vec2& location);
void potentiometerMoved(const Vec2& location);
void potentiometerEnded(const Vec2& location);
/** Returns the distance between the point1 and point2. */
float distanceBetweenPointAndPoint(const Vec2& point1, const Vec2& point2);
/** Returns the angle in degree between line1 and line2. */
float angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(
const Vec2& beginLineA,
const Vec2& endLineA,
const Vec2& beginLineB,
const Vec2& endLineB);
protected:
/** Contains the receiver’s current value. */
float _value;
/** Contains the minimum value of the receiver.
* The default value of this property is 0.0. */
float _minimumValue;
/** Contains the maximum value of the receiver.
* The default value of this property is 1.0. */
float _maximumValue;
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite)
CC_SYNTHESIZE_RETAIN(ProgressTimer*, _progressTimer, ProgressTimer)
CC_SYNTHESIZE(Vec2, _previousLocation, PreviousLocation)
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif /* __CCCONTROLPOTENTIOMETER_H__ */
@@ -1,211 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#include "CCControlSaturationBrightnessPicker.h"
NS_CC_EXT_BEGIN
ControlSaturationBrightnessPicker::ControlSaturationBrightnessPicker()
: _saturation(0.0f)
, _brightness(0.0f)
, _background(nullptr)
, _overlay(nullptr)
, _shadow(nullptr)
, _slider(nullptr)
, boxPos(0)
, boxSize(0)
{
}
ControlSaturationBrightnessPicker::~ControlSaturationBrightnessPicker()
{
removeAllChildrenWithCleanup(true);
_background = nullptr;
_overlay = nullptr;
_shadow = nullptr;
_slider = nullptr;
}
bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, const Vec2& pos)
{
if (Control::init())
{
// Add background and slider sprites
_background=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, Vec2::ZERO);
_overlay=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, Vec2::ZERO);
_shadow=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, Vec2::ZERO);
_slider=ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Vec2::ANCHOR_MIDDLE);
_startPos=pos; // starting position of the colour picker
boxPos = 35; // starting position of the virtual box area for picking a colour
boxSize = _background->getContentSize().width / 2;; // the size (width and height) of the virtual box for picking a colour from
return true;
}
else
{
return false;
}
}
ControlSaturationBrightnessPicker* ControlSaturationBrightnessPicker::create(Node* target, const Vec2& pos)
{
ControlSaturationBrightnessPicker *pRet = new (std::nothrow) ControlSaturationBrightnessPicker();
pRet->initWithTargetAndPos(target, pos);
pRet->autorelease();
return pRet;
}
void ControlSaturationBrightnessPicker::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
if (_slider != nullptr)
{
_slider->setOpacity(enabled ? 255 : 128);
}
}
void ControlSaturationBrightnessPicker::updateWithHSV(HSV hsv)
{
HSV hsvTemp;
hsvTemp.s = 1;
hsvTemp.h = hsv.h;
hsvTemp.v = 1;
RGBA rgb = ControlUtils::RGBfromHSV(hsvTemp);
_background->setColor(Color3B((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
}
void ControlSaturationBrightnessPicker::updateDraggerWithHSV(HSV hsv)
{
// Set the position of the slider to the correct saturation and brightness
Vec2 pos(_startPos.x + boxPos + (boxSize*(1 - hsv.s)),
_startPos.y + boxPos + (boxSize*hsv.v));
// update
updateSliderPosition(pos);
}
void ControlSaturationBrightnessPicker::updateSliderPosition(Vec2 sliderPosition)
{
// Clamp the position of the icon within the circle
// Get the center point of the bkgd image
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
// Work out the distance difference between the location and center
float dx = sliderPosition.x - centerX;
float dy = sliderPosition.y - centerY;
float dist = sqrtf(dx * dx + dy * dy);
// Update angle by using the direction of the location
float angle = atan2f(dy, dx);
// Set the limit to the slider movement within the colour picker
float limit = _background->getBoundingBox().size.width*0.5f;
// Check distance doesn't exceed the bounds of the circle
if (dist > limit)
{
sliderPosition.x = centerX + limit * cosf(angle);
sliderPosition.y = centerY + limit * sinf(angle);
}
// Set the position of the dragger
_slider->setPosition(sliderPosition);
// Clamp the position within the virtual box for colour selection
if (sliderPosition.x < _startPos.x + boxPos) sliderPosition.x = _startPos.x + boxPos;
else if (sliderPosition.x > _startPos.x + boxPos + boxSize - 1) sliderPosition.x = _startPos.x + boxPos + boxSize - 1;
if (sliderPosition.y < _startPos.y + boxPos) sliderPosition.y = _startPos.y + boxPos;
else if (sliderPosition.y > _startPos.y + boxPos + boxSize) sliderPosition.y = _startPos.y + boxPos + boxSize;
// Use the position / slider width to determin the percentage the dragger is at
_saturation = 1.0f - fabs((_startPos.x + (float)boxPos - sliderPosition.x)/(float)boxSize);
_brightness = fabs((_startPos.y + (float)boxPos - sliderPosition.y)/(float)boxSize);
}
bool ControlSaturationBrightnessPicker::checkSliderPosition(const Vec2& location)
{
// Clamp the position of the icon within the circle
// get the center point of the bkgd image
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
// work out the distance difference between the location and center
float dx = location.x - centerX;
float dy = location.y - centerY;
float dist = sqrtf(dx*dx+dy*dy);
// check that the touch location is within the bounding rectangle before sending updates
if (dist <= _background->getBoundingBox().size.width*0.5f)
{
updateSliderPosition(location);
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
return true;
}
return false;
}
bool ControlSaturationBrightnessPicker::onTouchBegan(Touch* touch, Event* event)
{
if (!isEnabled() || !isVisible())
{
return false;
}
// Get the touch location
Vec2 touchLocation=getTouchLocation(touch);
// Check the touch position on the slider
return checkSliderPosition(touchLocation);
}
void ControlSaturationBrightnessPicker::onTouchMoved(Touch* touch, Event* event)
{
// Get the touch location
Vec2 touchLocation=getTouchLocation(touch);
//small modification: this allows changing of the colour, even if the touch leaves the bounding area
// updateSliderPosition(touchLocation);
// sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
// Check the touch position on the slider
checkSliderPosition(touchLocation);
}
NS_CC_EXT_END
@@ -1,108 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_SATURATION_PICKER_H__
#define __CCCONTROL_SATURATION_PICKER_H__
#include "CCControl.h"
#include "CCInvocation.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
class CC_EX_DLL ControlSaturationBrightnessPicker : public Control
{
/** Contains the receiver's current saturation value. */
CC_SYNTHESIZE_READONLY(float, _saturation, Saturation);
/** Contains the receiver's current brightness value. */
CC_SYNTHESIZE_READONLY(float, _brightness, Brightness);
//not sure if these need to be there actually. I suppose someone might want to access the sprite?
CC_SYNTHESIZE_READONLY(Sprite*, _background, Background);
CC_SYNTHESIZE_READONLY(Sprite*, _overlay, Overlay);
CC_SYNTHESIZE_READONLY(Sprite*, _shadow, Shadow);
CC_SYNTHESIZE_READONLY(Sprite*, _slider, Slider);
CC_SYNTHESIZE_READONLY(Vec2, _startPos, StartPos);
protected:
int boxPos;
int boxSize;
public:
/**
* @js ctor
*/
ControlSaturationBrightnessPicker();
/**
* @js NA
* @lua NA
*/
virtual ~ControlSaturationBrightnessPicker();
virtual bool initWithTargetAndPos(Node* target, const Vec2& pos);
static ControlSaturationBrightnessPicker* create(Node* target, const Vec2& pos);
virtual void setEnabled(bool enabled) override;
/**
* @js NA
* @lua NA
*/
virtual void updateWithHSV(HSV hsv);
/**
* @js NA
* @lua NA
*/
virtual void updateDraggerWithHSV(HSV hsv);
protected:
void updateSliderPosition(Vec2 location);
bool checkSliderPosition(const Vec2& location);
virtual bool onTouchBegan(Touch* touch, Event* pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,328 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*
*/
#include "CCControlSlider.h"
#include "base/CCTouch.h"
#include "base/CCDirector.h"
NS_CC_EXT_BEGIN
ControlSlider::ControlSlider()
: _value(0.0f)
, _minimumValue(0.0f)
, _maximumValue(0.0f)
, _minimumAllowedValue(0.0f)
, _maximumAllowedValue(0.0f)
, _thumbSprite(nullptr)
, _selectedThumbSprite(nullptr)
, _progressSprite(nullptr)
, _backgroundSprite(nullptr)
{
}
ControlSlider::~ControlSlider()
{
CC_SAFE_RELEASE(_thumbSprite);
CC_SAFE_RELEASE(_selectedThumbSprite);
CC_SAFE_RELEASE(_progressSprite);
CC_SAFE_RELEASE(_backgroundSprite);
}
ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile)
{
// Prepare background for slider
Sprite *backgroundSprite = Sprite::create(bgFile);
// Prepare progress for slider
Sprite *progressSprite = Sprite::create(progressFile);
// Prepare thumb (menuItem) for slider
Sprite *thumbSprite = Sprite::create(thumbFile);
return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite);
}
ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile,
const char* selectedThumbSpriteFile)
{
// Prepare background for slider
Sprite *backgroundSprite = Sprite::create(bgFile);
// Prepare progress for slider
Sprite *progressSprite = Sprite::create(progressFile);
// Prepare thumb (menuItem) for slider
Sprite *thumbSprite = Sprite::create(thumbFile);
// Prepare selected thumb (menuItem) for slider
Sprite *selectedThumbSprite = Sprite::create(selectedThumbSpriteFile);
return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite);
}
ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite)
{
ControlSlider *pRet = new (std::nothrow) ControlSlider();
pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite);
pRet->autorelease();
return pRet;
}
ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite,
Sprite* selectedThumbSprite)
{
ControlSlider *pRet = new (std::nothrow) ControlSlider();
pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite, selectedThumbSprite);
pRet->autorelease();
return pRet;
}
bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite)
{
Sprite* selectedThumbSprite = Sprite::createWithTexture(thumbSprite->getTexture(),
thumbSprite->getTextureRect());
selectedThumbSprite->setColor(Color3B::GRAY);
return this->initWithSprites(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite);
}
bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite,
Sprite* selectedThumbSprite)
{
if (Control::init())
{
CCASSERT(backgroundSprite, "Background sprite must be not nil");
CCASSERT(progressSprite, "Progress sprite must be not nil");
CCASSERT(thumbSprite, "Thumb sprite must be not nil");
CCASSERT(selectedThumbSprite, "Thumb sprite must be not nil");
if (backgroundSprite == nullptr || progressSprite == nullptr ||
thumbSprite == nullptr || selectedThumbSprite == nullptr) {
return false;
}
setIgnoreAnchorPointForPosition(false);
this->setBackgroundSprite(backgroundSprite);
this->setProgressSprite(progressSprite);
this->setThumbSprite(thumbSprite);
this->setSelectedThumbSprite(selectedThumbSprite);
// Defines the content size
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox());
setContentSize(Size(maxRect.size.width, maxRect.size.height));
// Add the slider background
_backgroundSprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_backgroundSprite->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2);
addChild(_backgroundSprite);
// Add the progress bar
_progressSprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
_progressSprite->setPosition(0.0f, this->getContentSize().height / 2);
addChild(_progressSprite);
// Add the slider thumb
_thumbSprite->setPosition(0.0f, this->getContentSize().height / 2);
addChild(_thumbSprite);
_selectedThumbSprite->setPosition(0.0f, this->getContentSize().height / 2);
_selectedThumbSprite->setVisible(false);
addChild(_selectedThumbSprite);
// Init default values
_minimumValue = 0.0f;
_maximumValue = 1.0f;
setValue(_minimumValue);
return true;
}
else
{
return false;
}
}
void ControlSlider::setEnabled(bool enabled)
{
Control::setEnabled(enabled);
if (_thumbSprite != nullptr)
{
_thumbSprite->setOpacity((enabled) ? 255 : 128);
}
}
void ControlSlider::setValue(float value)
{
// set new value with sentinel
if (value < _minimumValue)
{
value = _minimumValue;
}
if (value > _maximumValue)
{
value = _maximumValue;
}
_value = value;
this->needsLayout();
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
void ControlSlider::setMinimumValue(float minimumValue)
{
_minimumValue=minimumValue;
_minimumAllowedValue = minimumValue;
if (_minimumValue >= _maximumValue)
{
_maximumValue = _minimumValue + 1.0f;
}
setValue(_value);
}
void ControlSlider::setMaximumValue(float maximumValue)
{
_maximumValue=maximumValue;
_maximumAllowedValue = maximumValue;
if (_maximumValue <= _minimumValue)
{
_minimumValue = _maximumValue - 1.0f;
}
setValue(_value);
}
bool ControlSlider::isTouchInside(Touch * touch)
{
Vec2 touchLocation = touch->getLocation();
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
Rect rect = this->getBoundingBox();
rect.size.width += _thumbSprite->getContentSize().width;
rect.origin.x -= _thumbSprite->getContentSize().width / 2;
return rect.containsPoint(touchLocation);
}
Vec2 ControlSlider::locationFromTouch(Touch* touch)
{
Vec2 touchLocation = touch->getLocation(); // Get the touch position
touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class
if (touchLocation.x < 0)
{
touchLocation.x = 0;
} else if (touchLocation.x > _backgroundSprite->getContentSize().width)
{
touchLocation.x = _backgroundSprite->getContentSize().width;
}
return touchLocation;
}
bool ControlSlider::onTouchBegan(Touch* touch, Event* pEvent)
{
if (!isTouchInside(touch) || !isEnabled() || !isVisible())
{
return false;
}
Vec2 location = locationFromTouch(touch);
sliderBegan(location);
return true;
}
void ControlSlider::onTouchMoved(Touch *pTouch, Event *pEvent)
{
Vec2 location = locationFromTouch(pTouch);
sliderMoved(location);
}
void ControlSlider::onTouchEnded(Touch *pTouch, Event *pEvent)
{
sliderEnded(Vec2::ZERO);
}
void ControlSlider::needsLayout()
{
if (nullptr == _thumbSprite || nullptr == _selectedThumbSprite || nullptr == _backgroundSprite
|| nullptr == _progressSprite)
{
return;
}
// Update thumb position for new value
float percent = (_value - _minimumValue) / (_maximumValue - _minimumValue);
Vec2 pos = _thumbSprite->getPosition();
pos.x = percent * _backgroundSprite->getContentSize().width;
_thumbSprite->setPosition(pos);
_selectedThumbSprite->setPosition(pos);
// Stretches content proportional to newLevel
Rect textureRect = _progressSprite->getTextureRect();
textureRect = Rect(textureRect.origin.x, textureRect.origin.y, pos.x, textureRect.size.height);
_progressSprite->setTextureRect(textureRect, _progressSprite->isTextureRectRotated(), textureRect.size);
}
void ControlSlider::sliderBegan(const Vec2& location)
{
this->setSelected(true);
_thumbSprite->setVisible(false);
_selectedThumbSprite->setVisible(true);
setValue(valueForLocation(location));
}
void ControlSlider::sliderMoved(const Vec2& location)
{
setValue(valueForLocation(location));
}
void ControlSlider::sliderEnded(const Vec2& location)
{
if (this->isSelected())
{
setValue(valueForLocation(_thumbSprite->getPosition()));
}
_thumbSprite->setVisible(true);
_selectedThumbSprite->setVisible(false);
this->setSelected(false);
}
float ControlSlider::valueForLocation(const Vec2& location)
{
float percent = location.x/ _backgroundSprite->getContentSize().width;
return MAX(MIN(_minimumValue + percent * (_maximumValue - _minimumValue), _maximumAllowedValue), _minimumAllowedValue);
}
NS_CC_EXT_END
@@ -1,162 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2011 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_SLIDER_H__
#define __CCCONTROL_SLIDER_H__
#include "CCControl.h"
#include "CCInvocation.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
class CC_EX_DLL ControlSlider: public Control
{
public:
/**
* Creates slider with a background filename, a progress filename and a
* thumb image filename.
*/
static ControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile);
/**
* Creates a slider with a given background sprite and a progress bar and a
* thumb item.
*
* @see initWithSprites
*/
static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite);
/**
* Creates slider with a background filename, a progress filename, a thumb
* and a selected thumb image filename.
*/
static ControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile,
const char* selectedThumbSpriteFile);
/**
* Creates a slider with a given background sprite and a progress bar, a thumb
* and a selected thumb .
*
* @see initWithSprites
*/
static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite,
Sprite* selectedThumbSprite);
/**
* @js ctor
* @lua new
*/
ControlSlider();
/**
* @js NA
* @lua NA
*/
virtual ~ControlSlider();
/**
* Initializes a slider with a background sprite, a progress bar and a thumb
* item.
*
* @param backgroundSprite Sprite, that is used as a background.
* @param progressSprite Sprite, that is used as a progress bar.
* @param thumbSprite Sprite, that is used as a thumb.
*/
virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite);
/**
* Initializes a slider with a background sprite, a progress bar and a thumb
* item.
*
* @param backgroundSprite Sprite, that is used as a background.
* @param progressSprite Sprite, that is used as a progress bar.
* @param thumbSprite Sprite, that is used as a thumb.
* @param selectedThumbSprite Sprite, that is used as a selected thumb.
*/
virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite,
Sprite* selectedThumbSprite);
virtual void needsLayout() override;
virtual void setMaximumValue(float val);
virtual void setEnabled(bool enabled) override;
virtual bool isTouchInside(Touch * touch) override;
Vec2 locationFromTouch(Touch* touch);
virtual void setValue(float val);
virtual void setMinimumValue(float val);
protected:
void sliderBegan(const Vec2& location);
void sliderMoved(const Vec2& location);
void sliderEnded(const Vec2& location);
virtual bool onTouchBegan(Touch* touch, Event* pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override;
/** Returns the value for the given location. */
float valueForLocation(const Vec2& location);
//maunally put in the setters
/** Contains the receiver's current value. */
CC_SYNTHESIZE_READONLY(float, _value, Value);
/** Contains the minimum value of the receiver.
* The default value of this property is 0.0. */
CC_SYNTHESIZE_READONLY(float, _minimumValue, MinimumValue);
/** Contains the maximum value of the receiver.
* The default value of this property is 1.0. */
CC_SYNTHESIZE_READONLY(float, _maximumValue, MaximumValue);
CC_SYNTHESIZE(float, _minimumAllowedValue, MinimumAllowedValue);
CC_SYNTHESIZE(float, _maximumAllowedValue, MaximumAllowedValue);
// maybe this should be read-only
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite);
CC_SYNTHESIZE_RETAIN(Sprite*, _selectedThumbSprite, SelectedThumbSprite);
CC_SYNTHESIZE_RETAIN(Sprite*, _progressSprite, ProgressSprite);
CC_SYNTHESIZE_RETAIN(Sprite*, _backgroundSprite, BackgroundSprite);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,352 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT falseT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND falseNINFRINGEMENT. IN false EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "CCControlStepper.h"
NS_CC_EXT_BEGIN
#define ControlStepperLabelColorEnabled Color3B(55, 55, 55)
#define ControlStepperLabelColorDisabled Color3B(147, 147, 147)
#define ControlStepperLabelFont "CourierNewPSMT"
#define kAutorepeatDeltaTime 0.15f
#define kAutorepeatIncreaseTimeIncrement 12
ControlStepper::ControlStepper()
: _value(0.0)
, _continuous(false)
, _autorepeat(false)
, _wraps(false)
, _minimumValue(0.0)
, _maximumValue(0.0)
, _stepValue(0.0)
, _touchInsideFlag(false)
, _touchedPart(Part::NONE)
, _autorepeatCount(0)
, _minusSprite(nullptr)
, _plusSprite(nullptr)
, _minusLabel(nullptr)
, _plusLabel(nullptr)
{
}
ControlStepper::~ControlStepper()
{
unscheduleAllCallbacks();
CC_SAFE_RELEASE(_minusSprite);
CC_SAFE_RELEASE(_plusSprite);
CC_SAFE_RELEASE(_minusLabel);
CC_SAFE_RELEASE(_plusLabel);
}
bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprite *plusSprite)
{
if (Control::init())
{
CCASSERT(minusSprite, "Minus sprite must be not nil");
CCASSERT(plusSprite, "Plus sprite must be not nil");
if (minusSprite == nullptr || plusSprite == nullptr) {
return false;
}
// Set the default values
_autorepeat = true;
_continuous = true;
_minimumValue = 0;
_maximumValue = 100;
_value = 0;
_stepValue = 1;
_wraps = false;
this->setIgnoreAnchorPointForPosition( false );
// Add the minus components
this->setMinusSprite(minusSprite);
_minusSprite->setPosition(minusSprite->getContentSize().width / 2, minusSprite->getContentSize().height / 2);
this->addChild(_minusSprite);
this->setMinusLabel( Label::createWithSystemFont("-", ControlStepperLabelFont, 40));
_minusLabel->setColor(ControlStepperLabelColorDisabled);
_minusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_minusLabel->setPosition(_minusSprite->getContentSize().width / 2, _minusSprite->getContentSize().height / 2);
_minusSprite->addChild(_minusLabel);
// Add the plus components
this->setPlusSprite( plusSprite );
_plusSprite->setPosition(minusSprite->getContentSize().width + plusSprite->getContentSize().width / 2,
minusSprite->getContentSize().height / 2);
this->addChild(_plusSprite);
this->setPlusLabel( Label::createWithSystemFont("+", ControlStepperLabelFont, 40 ));
_plusLabel->setColor( ControlStepperLabelColorEnabled );
_plusLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_plusLabel->setPosition(_plusSprite->getContentSize().width / 2, _plusSprite->getContentSize().height / 2);
_plusSprite->addChild(_plusLabel);
// Defines the content size
Rect maxRect = ControlUtils::RectUnion(_minusSprite->getBoundingBox(), _plusSprite->getBoundingBox());
this->setContentSize( Size(_minusSprite->getContentSize().width + _plusSprite->getContentSize().height, maxRect.size.height) );
return true;
}
return false;
}
ControlStepper* ControlStepper::create(Sprite *minusSprite, Sprite *plusSprite)
{
ControlStepper* pRet = new (std::nothrow) ControlStepper();
if (pRet != nullptr && pRet->initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
//// Properties
void ControlStepper::setWraps(bool wraps)
{
_wraps = wraps;
if (_wraps)
{
_minusLabel->setColor( ControlStepperLabelColorEnabled );
_plusLabel->setColor(ControlStepperLabelColorEnabled );
}
this->setValue( _value );
}
void ControlStepper::setMinimumValue(double minimumValue)
{
if (minimumValue >= _maximumValue)
{
CCASSERT(0, "Must be numerically less than maximumValue.");
}
_minimumValue = minimumValue;
this->setValue( _value );
}
void ControlStepper::setMaximumValue(double maximumValue)
{
if (maximumValue <= _minimumValue)
{
CCASSERT(0, "Must be numerically greater than minimumValue.");
}
_maximumValue = maximumValue;
this->setValue(_value);
}
void ControlStepper::setValue(double value)
{
this->setValueWithSendingEvent(value, true);
}
double ControlStepper::getValue() const
{
return _value;
}
void ControlStepper::setStepValue(double stepValue)
{
if (stepValue <= 0)
{
CCASSERT(0,"Must be numerically greater than 0.");
}
_stepValue = stepValue;
}
bool ControlStepper::isContinuous() const
{
return _continuous;
}
//
//// ControlStepper Public Methods
void ControlStepper::setValueWithSendingEvent(double value, bool send)
{
if (value < _minimumValue)
{
value = _wraps ? _maximumValue : _minimumValue;
} else if (value > _maximumValue)
{
value = _wraps ? _minimumValue : _maximumValue;
}
_value = value;
if (!_wraps)
{
_minusLabel->setColor((value == _minimumValue) ? ControlStepperLabelColorDisabled : ControlStepperLabelColorEnabled);
_plusLabel->setColor((value == _maximumValue) ? ControlStepperLabelColorDisabled : ControlStepperLabelColorEnabled);
}
if (send)
{
this->sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
}
void ControlStepper::startAutorepeat()
{
_autorepeatCount = -1;
this->schedule(CC_SCHEDULE_SELECTOR(ControlStepper::update), kAutorepeatDeltaTime, CC_REPEAT_FOREVER, kAutorepeatDeltaTime * 3);
}
/** Stop the autorepeat. */
void ControlStepper::stopAutorepeat()
{
this->unschedule(CC_SCHEDULE_SELECTOR(ControlStepper::update));
}
void ControlStepper::update(float dt)
{
_autorepeatCount++;
if ((_autorepeatCount < kAutorepeatIncreaseTimeIncrement) && (_autorepeatCount % 3) != 0)
return;
if (_touchedPart == Part::MINUS)
{
this->setValueWithSendingEvent(_value - _stepValue, _continuous);
} else if (_touchedPart == Part::PLUS)
{
this->setValueWithSendingEvent(_value + _stepValue, _continuous);
}
}
//// ControlStepper Private Methods
void ControlStepper::updateLayoutUsingTouchLocation(const Vec2& location)
{
if (location.x < _minusSprite->getContentSize().width
&& _value > _minimumValue)
{
_touchedPart = Part::MINUS;
_minusSprite->setColor(Color3B::GRAY);
_plusSprite->setColor(Color3B::WHITE);
} else if (location.x >= _minusSprite->getContentSize().width
&& _value < _maximumValue)
{
_touchedPart = Part::PLUS;
_minusSprite->setColor(Color3B::WHITE);
_plusSprite->setColor(Color3B::GRAY);
} else
{
_touchedPart = Part::NONE;
_minusSprite->setColor(Color3B::WHITE);
_plusSprite->setColor(Color3B::WHITE);
}
}
bool ControlStepper::onTouchBegan(Touch *pTouch, Event *pEvent)
{
if (!isTouchInside(pTouch) || !isEnabled() || !isVisible())
{
return false;
}
Vec2 location = this->getTouchLocation(pTouch);
this->updateLayoutUsingTouchLocation(location);
_touchInsideFlag = true;
if (_autorepeat)
{
this->startAutorepeat();
}
return true;
}
void ControlStepper::onTouchMoved(Touch *pTouch, Event *pEvent)
{
if (this->isTouchInside(pTouch))
{
Vec2 location = this->getTouchLocation(pTouch);
this->updateLayoutUsingTouchLocation(location);
if (!_touchInsideFlag)
{
_touchInsideFlag = true;
if (_autorepeat)
{
this->startAutorepeat();
}
}
}
else
{
_touchInsideFlag = false;
_touchedPart = Part::NONE;
_minusSprite->setColor(Color3B::WHITE);
_plusSprite->setColor(Color3B::WHITE);
if (_autorepeat)
{
this->stopAutorepeat();
}
}
}
void ControlStepper::onTouchEnded(Touch *pTouch, Event *pEvent)
{
_minusSprite->setColor(Color3B::WHITE);
_plusSprite->setColor(Color3B::WHITE);
if (_autorepeat)
{
this->stopAutorepeat();
}
if (this->isTouchInside(pTouch))
{
Vec2 location = this->getTouchLocation(pTouch);
this->setValue(_value + ((location.x < _minusSprite->getContentSize().width) ? (0.0-_stepValue) : _stepValue));
}
}
NS_CC_EXT_END
@@ -1,127 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef __CCCONTROLSTEPPER_H__
#define __CCCONTROLSTEPPER_H__
#include "CCControl.h"
#include "2d/CCLabel.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
class CC_EX_DLL ControlStepper : public Control
{
public:
enum class Part
{
MINUS,
PLUS,
NONE
};
static ControlStepper* create(Sprite *minusSprite, Sprite *plusSprite);
/**
* @js ctor
* @lua new
*/
ControlStepper();
/**
* @js NA
* @lua NA
*/
virtual ~ControlStepper();
bool initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprite *plusSprite);
virtual void setWraps(bool wraps);
virtual void setMinimumValue(double minimumValue);
virtual void setMaximumValue(double maximumValue);
virtual void setValue(double value);
virtual double getValue() const;
virtual void setStepValue(double stepValue);
/** Set the numeric value of the stepper. If send is true, the Control::EventType::VALUE_CHANGED is sent. */
virtual void setValueWithSendingEvent(double value, bool send);
virtual bool isContinuous() const;
// Overrides
virtual bool onTouchBegan(Touch *pTouch, Event *pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override;
void update(float dt) override;
/** Update the layout of the stepper with the given touch location. */
void updateLayoutUsingTouchLocation(const Vec2& location);
/** Start the autorepeat increment/decrement. */
void startAutorepeat();
/** Stop the autorepeat. */
void stopAutorepeat();
protected:
/** The numeric value of the stepper. */
double _value;
/** The continuous vs. noncontinuous state of the stepper. */
bool _continuous;
/** The automatic vs. nonautomatic repeat state of the stepper. */
bool _autorepeat;
/** The wrap vs. no-wrap state of the stepper. */
bool _wraps;
/** The lowest possible numeric value for the stepper. */
double _minimumValue;
/** The highest possible numeric value for the stepper. */
double _maximumValue;
/** The step, or increment, value for the stepper. */
double _stepValue;
bool _touchInsideFlag;
Part _touchedPart;
int _autorepeatCount;
// Weak links to children
CC_SYNTHESIZE_RETAIN(Sprite*, _minusSprite, MinusSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _plusSprite, PlusSprite)
CC_SYNTHESIZE_RETAIN(Label*, _minusLabel, MinusLabel)
CC_SYNTHESIZE_RETAIN(Label*, _plusLabel, PlusLabel)
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif /* __CCCONTROLSTEPPER_H__ */
@@ -1,464 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "CCControlSwitch.h"
#include "2d/CCSprite.h"
#include "2d/CCActionTween.h"
#include "2d/CCLabel.h"
#include "2d/CCClippingNode.h"
#include "renderer/ccShaders.h"
#include "2d/CCRenderTexture.h"
NS_CC_EXT_BEGIN
// ControlSwitchSprite
class ControlSwitchSprite : public Sprite, public ActionTweenDelegate
{
public:
/** creates an autorelease instance of ControlSwitchSprite */
static ControlSwitchSprite* create(
Sprite *maskSprite,
Sprite *onSprite,
Sprite *offSprite,
Sprite *thumbSprite,
Label* onLabel,
Label* offLabel);
/**
* @js NA
* @lua NA
*/
void needsLayout();
/**
* @js NA
* @lua NA
*/
void setSliderXPosition(float sliderXPosition);
/**
* @js NA
* @lua NA
*/
float getSliderXPosition() {return _sliderXPosition;}
/**
* @js NA
* @lua NA
*/
float onSideWidth();
/**
* @js NA
* @lua NA
*/
float offSideWidth();
/**
* @js NA
* @lua NA
*/
virtual void updateTweenAction(float value, const std::string& key) override;
/** Contains the position (in x-axis) of the slider inside the receiver. */
float _sliderXPosition;
CC_SYNTHESIZE(float, _onPosition, OnPosition)
CC_SYNTHESIZE(float, _offPosition, OffPosition)
CC_SYNTHESIZE_RETAIN(Texture2D*, _maskTexture, MaskTexture)
CC_SYNTHESIZE(GLuint, _textureLocation, TextureLocation)
CC_SYNTHESIZE(GLuint, _maskLocation, MaskLocation)
CC_SYNTHESIZE_RETAIN(Sprite*, _onSprite, OnSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _offSprite, OffSprite)
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite)
CC_SYNTHESIZE_RETAIN(Label*, _onLabel, OnLabel)
CC_SYNTHESIZE_RETAIN(Label*, _offLabel, OffLabel)
Sprite* _clipperStencil;
protected:
/**
* @js NA
* @lua NA
*/
ControlSwitchSprite();
/**
* @js NA
* @lua NA
*/
virtual ~ControlSwitchSprite();
/**
* @js NA
* @lua NA
*/
bool initWithMaskSprite(
Sprite *maskSprite,
Sprite *onSprite,
Sprite *offSprite,
Sprite *thumbSprite,
Label* onLabel,
Label* offLabel);
private:
CC_DISALLOW_COPY_AND_ASSIGN(ControlSwitchSprite);
};
ControlSwitchSprite* ControlSwitchSprite::create(Sprite *maskSprite,
Sprite *onSprite,
Sprite *offSprite,
Sprite *thumbSprite,
Label* onLabel,
Label* offLabel)
{
auto ret = new (std::nothrow) ControlSwitchSprite();
ret->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
ret->autorelease();
return ret;
}
ControlSwitchSprite::ControlSwitchSprite()
: _sliderXPosition(0.0f)
, _onPosition(0.0f)
, _offPosition(0.0f)
, _maskTexture(nullptr)
, _textureLocation(0)
, _maskLocation(0)
, _onSprite(nullptr)
, _offSprite(nullptr)
, _thumbSprite(nullptr)
, _onLabel(nullptr)
, _offLabel(nullptr)
, _clipperStencil(nullptr)
{
}
ControlSwitchSprite::~ControlSwitchSprite()
{
CC_SAFE_RELEASE(_onSprite);
CC_SAFE_RELEASE(_offSprite);
CC_SAFE_RELEASE(_thumbSprite);
CC_SAFE_RELEASE(_onLabel);
CC_SAFE_RELEASE(_offLabel);
CC_SAFE_RELEASE(_maskTexture);
CC_SAFE_RELEASE(_clipperStencil);
}
bool ControlSwitchSprite::initWithMaskSprite(
Sprite *maskSprite,
Sprite *onSprite,
Sprite *offSprite,
Sprite *thumbSprite,
Label* onLabel,
Label* offLabel)
{
if (Sprite::initWithTexture(maskSprite->getTexture()))
{
// Sets the default values
_onPosition = 0;
_offPosition = -onSprite->getContentSize().width + thumbSprite->getContentSize().width / 2;
_sliderXPosition = _onPosition;
setOnSprite(onSprite);
setOffSprite(offSprite);
setThumbSprite(thumbSprite);
setOnLabel(onLabel);
setOffLabel(offLabel);
ClippingNode* clipper = ClippingNode::create();
_clipperStencil = Sprite::createWithTexture(maskSprite->getTexture());
_clipperStencil->retain();
clipper->setAlphaThreshold(0.1f);
clipper->setStencil(_clipperStencil);
clipper->addChild(onSprite);
clipper->addChild(offSprite);
clipper->addChild(onLabel);
clipper->addChild(offLabel);
clipper->addChild(thumbSprite);
addChild(clipper);
// Set up the mask with the Mask shader
setMaskTexture(maskSprite->getTexture());
setContentSize(_maskTexture->getContentSize());
needsLayout();
return true;
}
return false;
}
void ControlSwitchSprite::updateTweenAction(float value, const std::string& key)
{
CCLOGINFO("key = %s, value = %f", key.c_str(), value);
setSliderXPosition(value);
}
void ControlSwitchSprite::needsLayout()
{
_onSprite->setPosition(_onSprite->getContentSize().width / 2 + _sliderXPosition,
_onSprite->getContentSize().height / 2);
_offSprite->setPosition(_onSprite->getContentSize().width + _offSprite->getContentSize().width / 2 + _sliderXPosition,
_offSprite->getContentSize().height / 2);
_thumbSprite->setPosition(_onSprite->getContentSize().width + _sliderXPosition,
_maskTexture->getContentSize().height / 2);
_clipperStencil->setPosition(_maskTexture->getContentSize().width/2,
_maskTexture->getContentSize().height / 2);
if (_onLabel)
{
_onLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_onLabel->setPosition(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6,
_onSprite->getContentSize().height / 2);
}
if (_offLabel)
{
_offLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_offLabel->setPosition(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6,
_offSprite->getContentSize().height / 2);
}
setFlippedY(true);
}
void ControlSwitchSprite::setSliderXPosition(float sliderXPosition)
{
if (sliderXPosition <= _offPosition)
{
// Off
sliderXPosition = _offPosition;
} else if (sliderXPosition >= _onPosition)
{
// On
sliderXPosition = _onPosition;
}
_sliderXPosition = sliderXPosition;
needsLayout();
}
float ControlSwitchSprite::onSideWidth()
{
return _onSprite->getContentSize().width;
}
float ControlSwitchSprite::offSideWidth()
{
return _offSprite->getContentSize().height;
}
// ControlSwitch
ControlSwitch::ControlSwitch()
: _switchSprite(nullptr)
, _initialTouchXPosition(0.0f)
, _moved(false)
, _on(false)
{
}
ControlSwitch::~ControlSwitch()
{
CC_SAFE_RELEASE(_switchSprite);
}
bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite)
{
return initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, nullptr, nullptr);
}
ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite)
{
ControlSwitch* pRet = new (std::nothrow) ControlSwitch();
if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, nullptr, nullptr))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
bool ControlSwitch::initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
{
if (Control::init())
{
CCASSERT(maskSprite, "Mask must not be nil.");
CCASSERT(onSprite, "onSprite must not be nil.");
CCASSERT(offSprite, "offSprite must not be nil.");
CCASSERT(thumbSprite, "thumbSprite must not be nil.");
if (maskSprite == nullptr || onSprite == nullptr ||
offSprite == nullptr || thumbSprite == nullptr) {
return false;
}
_on = true;
_switchSprite = ControlSwitchSprite::create(maskSprite,
onSprite,
offSprite,
thumbSprite,
onLabel,
offLabel);
_switchSprite->retain();
_switchSprite->setPosition(_switchSprite->getContentSize().width / 2, _switchSprite->getContentSize().height / 2);
addChild(_switchSprite);
setIgnoreAnchorPointForPosition(false);
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
setContentSize(_switchSprite->getContentSize());
return true;
}
return false;
}
ControlSwitch* ControlSwitch::create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel)
{
ControlSwitch* pRet = new (std::nothrow) ControlSwitch();
if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
void ControlSwitch::setOn(bool isOn)
{
setOn(isOn, false);
}
void ControlSwitch::setOn(bool isOn, bool animated)
{
_on = isOn;
if (animated) {
_switchSprite->runAction
(
ActionTween::create
(
0.2f,
"sliderXPosition",
_switchSprite->getSliderXPosition(),
(_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition()
)
);
}
else {
_switchSprite->setSliderXPosition((_on) ? _switchSprite->getOnPosition() : _switchSprite->getOffPosition());
}
sendActionsForControlEvents(Control::EventType::VALUE_CHANGED);
}
void ControlSwitch::setEnabled(bool enabled)
{
_enabled = enabled;
if (_switchSprite != nullptr)
{
_switchSprite->setOpacity((enabled) ? 255 : 128);
}
}
Vec2 ControlSwitch::locationFromTouch(Touch* pTouch)
{
Vec2 touchLocation = pTouch->getLocation(); // Get the touch position
touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class
return touchLocation;
}
bool ControlSwitch::onTouchBegan(Touch *pTouch, Event *pEvent)
{
if (!isTouchInside(pTouch) || !isEnabled() || !isVisible())
{
return false;
}
_moved = false;
Vec2 location = this->locationFromTouch(pTouch);
_initialTouchXPosition = location.x - _switchSprite->getSliderXPosition();
_switchSprite->getThumbSprite()->setColor(Color3B::GRAY);
_switchSprite->needsLayout();
return true;
}
void ControlSwitch::onTouchMoved(Touch *pTouch, Event *pEvent)
{
Vec2 location = this->locationFromTouch(pTouch);
location = Vec2(location.x - _initialTouchXPosition, 0);
_moved = true;
_switchSprite->setSliderXPosition(location.x);
}
void ControlSwitch::onTouchEnded(Touch *pTouch, Event *pEvent)
{
Vec2 location = this->locationFromTouch(pTouch);
_switchSprite->getThumbSprite()->setColor(Color3B::WHITE);
if (hasMoved())
{
setOn(!(location.x < _switchSprite->getContentSize().width / 2), true);
}
else
{
setOn(!_on, true);
}
}
void ControlSwitch::onTouchCancelled(Touch *pTouch, Event *pEvent)
{
Vec2 location = this->locationFromTouch(pTouch);
_switchSprite->getThumbSprite()->setColor(Color3B::WHITE);
if (hasMoved())
{
setOn(!(location.x < _switchSprite->getContentSize().width / 2), true);
} else
{
setOn(!_on, true);
}
}
NS_CC_EXT_END
@@ -1,111 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Copyright 2012 Yannick Loriot. All rights reserved.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef __CCCONTROLSWITCH_H__
#define __CCCONTROLSWITCH_H__
#include "CCControl.h"
#include "extensions/ExtensionExport.h"
namespace cocos2d { class Sprite; }
namespace cocos2d { class Label; }
NS_CC_EXT_BEGIN
class ControlSwitchSprite;
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
/** @class ControlSwitch Switch control for Cocos2D. */
class CC_EX_DLL ControlSwitch : public Control
{
public:
/** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
/** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
static ControlSwitch* create(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
/**
* @js ctor
* @lua new
*/
ControlSwitch();
/**
* @js NA
* @lua NA
*/
virtual ~ControlSwitch();
/** Initializes a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite);
/** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
bool initWithMaskSprite(Sprite *maskSprite, Sprite * onSprite, Sprite * offSprite, Sprite * thumbSprite, Label* onLabel, Label* offLabel);
/**
* Set the state of the switch to On or Off, optionally animating the transition.
*
* @param isOn YES if the switch should be turned to the On position; NO if it
* should be turned to the Off position. If the switch is already in the
* designated position, nothing happens.
* @param animated YES to animate the "flipping" of the switch; otherwise NO.
*/
void setOn(bool isOn, bool animated);
void setOn(bool isOn);
bool isOn(void) const { return _on; }
bool hasMoved() const { return _moved; }
virtual void setEnabled(bool enabled) override;
Vec2 locationFromTouch(Touch* touch);
// Overrides
virtual bool onTouchBegan(Touch *pTouch, Event *pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override;
virtual void onTouchCancelled(Touch *pTouch, Event *pEvent) override;
protected:
/** Sprite which represents the view. */
ControlSwitchSprite* _switchSprite;
float _initialTouchXPosition;
bool _moved;
/** A Boolean value that determines the off/on state of the switch. */
bool _on;
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif /* __CCCONTROLSWITCH_H__ */
@@ -1,172 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCControlUtils.h"
NS_CC_EXT_BEGIN
Sprite* ControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, const Vec2& pos, const Vec2& anchor)
{
Sprite *sprite =Sprite::createWithSpriteFrameName(spriteName);
if (!sprite)
return nullptr;
sprite->setPosition(pos);
sprite->setAnchorPoint(anchor);
target->addChild(sprite);
return sprite;
}
HSV ControlUtils::HSVfromRGB(RGBA value)
{
HSV out;
double min, max, delta;
min = value.r < value.g ? value.r : value.g;
min = min < value.b ? min : value.b;
max = value.r > value.g ? value.r : value.g;
max = max > value.b ? max : value.b;
out.v = max; // v
delta = max - min;
if( max > 0.0 )
{
out.s = (delta / max); // s
} else
{
// r = g = b = 0 // s = 0, v is undefined
out.s = 0.0;
out.h = -1; // its now undefined (don't know if setting to NAN is a good idea)
return out;
}
if( value.r >= max ) // > is bogus, just keeps compilor happy
{
out.h = ( value.g - value.b ) / delta; // between yellow & magenta
} else
{
if( value.g >= max )
out.h = 2.0 + ( value.b - value.r ) / delta; // between cyan & yellow
else
out.h = 4.0 + ( value.r - value.g ) / delta; // between magenta & cyan
}
out.h *= 60.0; // degrees
if( out.h < 0.0 )
out.h += 360.0;
return out;
}
RGBA ControlUtils::RGBfromHSV(HSV value)
{
double hh, p, q, t, ff;
long i;
RGBA out;
out.a = 1;
if (value.s <= 0.0) // < is bogus, just shuts up warnings
{
if (std::isnan(value.h)) // value.h == NAN
{
out.r = value.v;
out.g = value.v;
out.b = value.v;
return out;
}
// error - should never happen
out.r = 0.0;
out.g = 0.0;
out.b = 0.0;
return out;
}
hh = value.h;
if(hh >= 360.0) hh = 0.0;
hh /= 60.0;
i = (long)hh;
ff = hh - i;
p = value.v * (1.0 - value.s);
q = value.v * (1.0 - (value.s * ff));
t = value.v * (1.0 - (value.s * (1.0 - ff)));
switch(i)
{
case 0:
out.r = value.v;
out.g = t;
out.b = p;
break;
case 1:
out.r = q;
out.g = value.v;
out.b = p;
break;
case 2:
out.r = p;
out.g = value.v;
out.b = t;
break;
case 3:
out.r = p;
out.g = q;
out.b = value.v;
break;
case 4:
out.r = t;
out.g = p;
out.b = value.v;
break;
case 5:
default:
out.r = value.v;
out.g = p;
out.b = q;
break;
}
return out;
}
Rect ControlUtils::RectUnion(const Rect& src1, const Rect& src2)
{
Rect result;
float x1 = MIN(src1.getMinX(), src2.getMinX());
float y1 = MIN(src1.getMinY(), src2.getMinY());
float x2 = MAX(src1.getMaxX(), src2.getMaxX());
float y2 = MAX(src1.getMaxY(), src2.getMaxY());
result.origin=Vec2(x1,y1);
result.size=Size(x2-x1, y2-y1);
return result;
}
NS_CC_EXT_END
@@ -1,109 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* Converted to c++ / cocos2d-x by Angus C
*/
#ifndef __CCCONTROL_UTILS_H__
#define __CCCONTROL_UTILS_H__
#include "2d/CCSprite.h"
#include "../../ExtensionMacros.h"
#include "extensions/ExtensionExport.h"
NS_CC_EXT_BEGIN
typedef struct
{
double r; // percent
double g; // percent
double b; // percent
double a; // percent
} RGBA;
typedef struct
{
double h; // angle in degrees
double s; // percent
double v; // percent
} HSV;
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
//helper class to store Color3B's in mutable arrays
class CC_EX_DLL Color3bObject : public Ref
{
public:
Color3B value;
/**
* @js NA
* @lua NA
*/
Color3bObject(Color3B s_value):value(s_value){}
};
class CC_EX_DLL ControlUtils
{
public:
/**
* @js NA
* @lua NA
*/
static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, const Vec2& pos, const Vec2& anchor);
/**
* @js NA
* @lua NA
*/
static HSV HSVfromRGB(RGBA value);
/**
* @js NA
* @lua NA
*/
static RGBA RGBfromHSV(HSV value);
/**
* @js NA
* @lua NA
*/
static Rect RectUnion(const Rect& src1, const Rect& src2);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,57 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* Converted to c++ / cocos2d-x by Angus C
*/
#include "CCInvocation.h"
NS_CC_EXT_BEGIN
Invocation* Invocation::create(Ref* target, Control::Handler action, Control::EventType controlEvent)
{
Invocation* pRet = new (std::nothrow) Invocation(target, action, controlEvent);
if (pRet != nullptr)
{
pRet->autorelease();
}
return pRet;
}
Invocation::Invocation(Ref* target, Control::Handler action, Control::EventType controlEvent)
{
_target=target;
_action=action;
_controlEvent=controlEvent;
}
void Invocation::invoke(Ref* sender)
{
if (_target && _action)
{
(_target->*_action)(sender, _controlEvent);
}
}
NS_CC_EXT_END
@@ -1,81 +0,0 @@
/*
* Copyright (c) 2012 cocos2d-x.org
* http://www.cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
* Converted to c++ / cocos2d-x by Angus C
*/
/*
*
* Helper class to store targets and selectors (and eventually, params?) in the same MutableArray. Basically a very crude form of a NSInvocation
*/
#ifndef __CCINVOCATION_H__
#define __CCINVOCATION_H__
#include "base/CCRef.h"
#include "../../ExtensionMacros.h"
#include "extensions/ExtensionExport.h"
#include "CCControl.h"
NS_CC_EXT_BEGIN
/**
* @addtogroup GUI
* @{
* @addtogroup control_extension
* @{
*/
#define cccontrol_selector(_SELECTOR) static_cast<cocos2d::extension::Control::Handler>(&_SELECTOR)
class CC_EX_DLL Invocation : public Ref
{
public:
/**
* @js NA
* @lua NA
*/
static Invocation* create(Ref* target, Control::Handler action, Control::EventType controlEvent);
/**
* @js NA
* @lua NA
*/
Invocation(Ref* target, Control::Handler action, Control::EventType controlEvent);
/**
* @js NA
* @lua NA
*/
void invoke(Ref* sender);
protected:
CC_SYNTHESIZE_READONLY(Control::Handler, _action, Action);
CC_SYNTHESIZE_READONLY(Ref*, _target, Target);
CC_SYNTHESIZE_READONLY(Control::EventType, _controlEvent, ControlEvent);
};
// end of GUI group
/// @}
/// @}
NS_CC_EXT_END
#endif
@@ -1,888 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCScrollView.h"
#include "platform/CCDevice.h"
#include "2d/CCActionInstant.h"
#include "2d/CCActionInterval.h"
#include "2d/CCActionTween.h"
#include "base/CCDirector.h"
#include "base/CCEventDispatcher.h"
#include "renderer/CCRenderer.h"
#include <algorithm>
NS_CC_EXT_BEGIN
#define SCROLL_DEACCEL_RATE 0.95f
#define SCROLL_DEACCEL_DIST 1.0f
#define BOUNCE_DURATION 0.15f
#define INSET_RATIO 0.2f
#define MOVE_INCH 7.0f/160.0f
#define BOUNCE_BACK_FACTOR 0.35f
static float convertDistanceFromPointToInch(float pointDis)
{
auto glview = Director::getInstance()->getOpenGLView();
float factor = ( glview->getScaleX() + glview->getScaleY() ) / 2;
return pointDis * factor / Device::getDPI();
}
ScrollView::ScrollView()
: _delegate(nullptr)
, _direction(Direction::BOTH)
, _dragging(false)
, _container(nullptr)
, _touchMoved(false)
, _bounceable(false)
, _clippingToBounds(false)
, _touchLength(0.0f)
, _minScale(0.0f)
, _maxScale(0.0f)
, _scissorRestored(false)
, _touchListener(nullptr)
, _animatedScrollAction(nullptr)
{
}
ScrollView::~ScrollView()
{
}
ScrollView* ScrollView::create(const Size& size, Node* container/* = nullptr*/)
{
ScrollView* pRet = new (std::nothrow) ScrollView();
if (pRet && pRet->initWithViewSize(size, container))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
ScrollView* ScrollView::create()
{
ScrollView* pRet = new (std::nothrow) ScrollView();
if (pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
bool ScrollView::initWithViewSize(const Size& size, Node *container/* = nullptr*/)
{
if (Layer::init())
{
_container = container;
if (!this->_container)
{
_container = Layer::create();
_container->setIgnoreAnchorPointForPosition(false);
_container->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
}
this->setViewSize(size);
setTouchEnabled(true);
_touches.reserve(EventTouch::MAX_TOUCHES);
_delegate = nullptr;
_bounceable = true;
_clippingToBounds = true;
//_container->setContentSize(Size::ZERO);
_direction = Direction::BOTH;
_container->setPosition(0.0f, 0.0f);
_touchLength = 0.0f;
this->addChild(_container);
_minScale = _maxScale = 1.0f;
return true;
}
return false;
}
bool ScrollView::init()
{
return this->initWithViewSize(Size(200, 200), nullptr);
}
bool ScrollView::isNodeVisible(Node* node)
{
const Vec2 offset = this->getContentOffset();
const Size size = this->getViewSize();
const float scale = this->getZoomScale();
Rect viewRect;
viewRect = Rect(-offset.x/scale, -offset.y/scale, size.width/scale, size.height/scale);
return viewRect.intersectsRect(node->getBoundingBox());
}
void ScrollView::pause(Ref* sender)
{
_container->pause();
auto& children = _container->getChildren();
for(const auto &child : children) {
child->pause();
}
}
void ScrollView::resume(Ref* sender)
{
auto& children = _container->getChildren();
for(const auto &child : children) {
child->resume();
}
_container->resume();
}
bool ScrollView::isTouchEnabled() const
{
return _touchListener != nullptr;
}
void ScrollView::setTouchEnabled(bool enabled)
{
_eventDispatcher->removeEventListener(_touchListener);
_touchListener = nullptr;
if (enabled)
{
_touchListener = EventListenerTouchOneByOne::create();
_touchListener->setSwallowTouches(true);
_touchListener->onTouchBegan = CC_CALLBACK_2(ScrollView::onTouchBegan, this);
_touchListener->onTouchMoved = CC_CALLBACK_2(ScrollView::onTouchMoved, this);
_touchListener->onTouchEnded = CC_CALLBACK_2(ScrollView::onTouchEnded, this);
_touchListener->onTouchCancelled = CC_CALLBACK_2(ScrollView::onTouchCancelled, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(_touchListener, this);
}
else
{
_dragging = false;
_touchMoved = false;
_touches.clear();
}
}
void ScrollView::setContentOffset(Vec2 offset, bool animated/* = false*/)
{
if (animated)
{ //animate scrolling
this->setContentOffsetInDuration(offset, BOUNCE_DURATION);
}
else
{ //set the container position directly
if (!_bounceable)
{
const Vec2 minOffset = this->minContainerOffset();
const Vec2 maxOffset = this->maxContainerOffset();
offset.x = MAX(minOffset.x, MIN(maxOffset.x, offset.x));
offset.y = MAX(minOffset.y, MIN(maxOffset.y, offset.y));
}
_container->setPosition(offset);
if (_delegate != nullptr)
{
_delegate->scrollViewDidScroll(this);
}
}
}
void ScrollView::setContentOffsetInDuration(const Vec2& offset, float dt)
{
FiniteTimeAction *scroll, *expire;
if (_animatedScrollAction) {
stopAnimatedContentOffset();
}
scroll = MoveTo::create(dt, offset);
expire = CallFuncN::create(CC_CALLBACK_1(ScrollView::stoppedAnimatedScroll,this));
_animatedScrollAction = _container->runAction(Sequence::create(scroll, expire, nullptr));
this->schedule(CC_SCHEDULE_SELECTOR(ScrollView::performedAnimatedScroll));
}
void ScrollView::stopAnimatedContentOffset()
{
stopAction(_animatedScrollAction);
_animatedScrollAction = nullptr;
stoppedAnimatedScroll(this);
}
Vec2 ScrollView::getContentOffset()
{
return _container->getPosition();
}
void ScrollView::setZoomScale(float s)
{
if (_container->getScale() != s)
{
Vec2 oldCenter, newCenter;
Vec2 center;
if (_touchLength == 0.0f)
{
center.set(_viewSize.width*0.5f, _viewSize.height*0.5f);
center = this->convertToWorldSpace(center);
}
else
{
center = _touchPoint;
}
oldCenter = _container->convertToNodeSpace(center);
_container->setScale(MAX(_minScale, MIN(_maxScale, s)));
newCenter = _container->convertToWorldSpace(oldCenter);
const Vec2 offset = center - newCenter;
if (_delegate != nullptr)
{
_delegate->scrollViewDidZoom(this);
}
this->setContentOffset(_container->getPosition() + offset);
}
}
float ScrollView::getZoomScale()
{
return _container->getScale();
}
void ScrollView::setZoomScale(float s, bool animated)
{
if (animated)
{
this->setZoomScaleInDuration(s, BOUNCE_DURATION);
}
else
{
this->setZoomScale(s);
}
}
void ScrollView::setZoomScaleInDuration(float s, float dt)
{
if (dt > 0)
{
if (_container->getScale() != s)
{
ActionTween *scaleAction;
scaleAction = ActionTween::create(dt, "zoomScale", _container->getScale(), s);
this->runAction(scaleAction);
}
}
else
{
this->setZoomScale(s);
}
}
void ScrollView::updateTweenAction(float value, const std::string& key)
{
this->setZoomScale(value);
}
void ScrollView::setViewSize(const Size& size)
{
_viewSize = size;
Layer::setContentSize(size);
}
Node * ScrollView::getContainer()
{
return this->_container;
}
void ScrollView::setContainer(Node * pContainer)
{
// Make sure that '_container' has a non-nullptr value since there are
// lots of logic that use '_container'.
if (nullptr == pContainer)
return;
this->removeAllChildrenWithCleanup(true);
this->_container = pContainer;
this->_container->setIgnoreAnchorPointForPosition(false);
this->_container->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
this->addChild(this->_container);
this->setViewSize(this->_viewSize);
}
bool ScrollView::hasVisibleParents() const
{
auto parent = this->getParent();
for( auto c = parent; c != nullptr; c = c->getParent() )
{
if( !c->isVisible() )
{
return false;
}
}
return true;
}
void ScrollView::relocateContainer(bool animated)
{
Vec2 oldPoint, min, max;
float newX, newY;
min = this->minContainerOffset();
max = this->maxContainerOffset();
oldPoint = _container->getPosition();
newX = oldPoint.x;
newY = oldPoint.y;
if (_direction == Direction::BOTH || _direction == Direction::HORIZONTAL)
{
newX = MAX(newX, min.x);
newX = MIN(newX, max.x);
}
if (_direction == Direction::BOTH || _direction == Direction::VERTICAL)
{
newY = MIN(newY, max.y);
newY = MAX(newY, min.y);
}
if (newY != oldPoint.y || newX != oldPoint.x)
{
this->setContentOffset(Vec2(newX, newY), animated);
}
}
Vec2 ScrollView::maxContainerOffset()
{
Point anchorPoint = _container->isIgnoreAnchorPointForPosition()?Point::ZERO:_container->getAnchorPoint();
float contW = _container->getContentSize().width * _container->getScaleX();
float contH = _container->getContentSize().height * _container->getScaleY();
return Vec2(anchorPoint.x * contW, anchorPoint.y * contH);
}
Vec2 ScrollView::minContainerOffset()
{
Point anchorPoint = _container->isIgnoreAnchorPointForPosition()?Point::ZERO:_container->getAnchorPoint();
float contW = _container->getContentSize().width * _container->getScaleX();
float contH = _container->getContentSize().height * _container->getScaleY();
return Vec2(_viewSize.width - (1 - anchorPoint.x) * contW, _viewSize.height - (1 - anchorPoint.y) * contH);
}
void ScrollView::deaccelerateScrolling(float dt)
{
if (_dragging)
{
this->unschedule(CC_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
return;
}
float newX, newY;
Vec2 maxInset, minInset;
_container->setPosition(_container->getPosition() + _scrollDistance);
if (_bounceable)
{
maxInset = _maxInset;
minInset = _minInset;
}
else
{
maxInset = this->maxContainerOffset();
minInset = this->minContainerOffset();
}
newX = _container->getPosition().x;
newY = _container->getPosition().y;
_scrollDistance = _scrollDistance * SCROLL_DEACCEL_RATE;
this->setContentOffset(Vec2(newX,newY));
if ((fabsf(_scrollDistance.x) <= SCROLL_DEACCEL_DIST &&
fabsf(_scrollDistance.y) <= SCROLL_DEACCEL_DIST) ||
((_direction == Direction::BOTH || _direction == Direction::VERTICAL) && (newY >= maxInset.y || newY <= minInset.y)) ||
((_direction == Direction::BOTH || _direction == Direction::HORIZONTAL) && (newX >= maxInset.x || newX <= minInset.x)))
{
this->unschedule(CC_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
this->relocateContainer(true);
}
}
void ScrollView::stoppedAnimatedScroll(Node * node)
{
this->unschedule(CC_SCHEDULE_SELECTOR(ScrollView::performedAnimatedScroll));
// After the animation stopped, "scrollViewDidScroll" should be invoked, this could fix the bug of lack of tableview cells.
if (_delegate != nullptr)
{
_delegate->scrollViewDidScroll(this);
}
}
void ScrollView::performedAnimatedScroll(float dt)
{
if (_dragging)
{
this->unschedule(CC_SCHEDULE_SELECTOR(ScrollView::performedAnimatedScroll));
return;
}
if (_delegate != nullptr)
{
_delegate->scrollViewDidScroll(this);
}
}
const Size& ScrollView::getContentSize() const
{
return _container->getContentSize();
}
void ScrollView::setContentSize(const Size & size)
{
if (this->getContainer() != nullptr)
{
this->getContainer()->setContentSize(size);
this->updateInset();
}
}
void ScrollView::updateInset()
{
if (this->getContainer() != nullptr)
{
_maxInset = this->maxContainerOffset();
_maxInset.set(_maxInset.x + _viewSize.width * INSET_RATIO,
_maxInset.y + _viewSize.height * INSET_RATIO);
_minInset = this->minContainerOffset();
_minInset.set(_minInset.x - _viewSize.width * INSET_RATIO,
_minInset.y - _viewSize.height * INSET_RATIO);
}
}
/**
* make sure all children go to the container
*/
void ScrollView::addChild(Node * child, int zOrder, int tag)
{
if (_container != child) {
_container->addChild(child, zOrder, tag);
} else {
Layer::addChild(child, zOrder, tag);
}
}
void ScrollView::removeChild(Node* node, bool cleanup)
{
if(_container != node)
{
_container->removeChild(node, cleanup);
}
else
{
Layer::removeChild(node, cleanup);
}
}
void ScrollView::removeAllChildrenWithCleanup(bool cleanup)
{
_container->removeAllChildrenWithCleanup(cleanup);
Layer::removeAllChildrenWithCleanup(cleanup);
}
void ScrollView::removeAllChildren()
{
removeAllChildrenWithCleanup(true);
}
void ScrollView::addChild(Node * child, int zOrder, const std::string &name)
{
if (_container != child)
{
_container->addChild(child, zOrder, name);
}
else
{
Layer::addChild(child, zOrder, name);
}
}
void ScrollView::beforeDraw()
{
//ScrollView don't support drawing in 3D space
_beforeDrawCommand.init(_globalZOrder);
_beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand);
}
/**
* clip this view so that outside of the visible bounds can be hidden.
*/
void ScrollView::onBeforeDraw()
{
if (_clippingToBounds)
{
_scissorRestored = false;
Rect frame = getViewRect();
auto glview = Director::getInstance()->getOpenGLView();
if (glview->isScissorEnabled()) {
_scissorRestored = true;
_parentScissorRect = glview->getScissorRect();
//set the intersection of _parentScissorRect and frame as the new scissor rect
if (frame.intersectsRect(_parentScissorRect)) {
float x = MAX(frame.origin.x, _parentScissorRect.origin.x);
float y = MAX(frame.origin.y, _parentScissorRect.origin.y);
float xx = MIN(frame.origin.x+frame.size.width, _parentScissorRect.origin.x+_parentScissorRect.size.width);
float yy = MIN(frame.origin.y+frame.size.height, _parentScissorRect.origin.y+_parentScissorRect.size.height);
glview->setScissorInPoints(x, y, xx-x, yy-y);
}
}
else {
glEnable(GL_SCISSOR_TEST);
glview->setScissorInPoints(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
}
}
}
void ScrollView::afterDraw()
{
_afterDrawCommand.init(_globalZOrder);
_afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand);
}
/**
* retract what's done in beforeDraw so that there's no side effect to
* other nodes.
*/
void ScrollView::onAfterDraw()
{
if (_clippingToBounds)
{
if (_scissorRestored) {//restore the parent's scissor rect
auto glview = Director::getInstance()->getOpenGLView();
glview->setScissorInPoints(_parentScissorRect.origin.x, _parentScissorRect.origin.y, _parentScissorRect.size.width, _parentScissorRect.size.height);
}
else {
glDisable(GL_SCISSOR_TEST);
}
}
}
void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible
if (!isVisible())
{
return;
}
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when setting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
this->beforeDraw();
if (!_children.empty())
{
int i=0;
// draw children zOrder < 0
for( ; i < _children.size(); i++ )
{
Node *child = _children.at(i);
if ( child->getLocalZOrder() < 0 )
{
child->visit(renderer, _modelViewTransform, flags);
}
else
{
break;
}
}
// this draw
this->draw(renderer, _modelViewTransform, flags);
// draw children zOrder >= 0
for( ; i < _children.size(); i++ )
{
Node *child = _children.at(i);
child->visit(renderer, _modelViewTransform, flags);
}
}
else
{
this->draw(renderer, _modelViewTransform, flags);
}
this->afterDraw();
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
bool ScrollView::onTouchBegan(Touch* touch, Event* event)
{
if (!this->isVisible() || !this->hasVisibleParents())
{
return false;
}
Rect frame = getViewRect();
//dispatcher does not know about clipping. reject touches outside visible bounds.
if (_touches.size() > 2 ||
_touchMoved ||
!frame.containsPoint(touch->getLocation()))
{
return false;
}
if (std::find(_touches.begin(), _touches.end(), touch) == _touches.end())
{
_touches.push_back(touch);
}
if (_touches.size() == 1)
{ // scrolling
_touchPoint = this->convertTouchToNodeSpace(touch);
_touchMoved = false;
_dragging = true; //dragging started
_scrollDistance.setZero();
_touchLength = 0.0f;
}
else if (_touches.size() == 2)
{
_touchPoint = (this->convertTouchToNodeSpace(_touches[0]).getMidpoint(
this->convertTouchToNodeSpace(_touches[1])));
_touchLength = _container->convertTouchToNodeSpace(_touches[0]).getDistance(
_container->convertTouchToNodeSpace(_touches[1]));
_dragging = false;
}
return true;
}
void ScrollView::onTouchMoved(Touch* touch, Event* event)
{
if (!this->isVisible())
{
return;
}
if (std::find(_touches.begin(), _touches.end(), touch) != _touches.end())
{
if (_touches.size() == 1 && _dragging)
{ // scrolling
Vec2 moveDistance, newPoint;
Rect frame;
float newX, newY;
frame = getViewRect();
newPoint = this->convertTouchToNodeSpace(_touches[0]);
moveDistance = newPoint - _touchPoint;
float dis = 0.0f;
if (_direction == Direction::VERTICAL)
{
dis = moveDistance.y;
float pos = _container->getPosition().y;
if (!(minContainerOffset().y <= pos && pos <= maxContainerOffset().y)) {
moveDistance.y *= BOUNCE_BACK_FACTOR;
}
}
else if (_direction == Direction::HORIZONTAL)
{
dis = moveDistance.x;
float pos = _container->getPosition().x;
if (!(minContainerOffset().x <= pos && pos <= maxContainerOffset().x)) {
moveDistance.x *= BOUNCE_BACK_FACTOR;
}
}
else
{
dis = sqrtf(moveDistance.x*moveDistance.x + moveDistance.y*moveDistance.y);
float pos = _container->getPosition().y;
if (!(minContainerOffset().y <= pos && pos <= maxContainerOffset().y)) {
moveDistance.y *= BOUNCE_BACK_FACTOR;
}
pos = _container->getPosition().x;
if (!(minContainerOffset().x <= pos && pos <= maxContainerOffset().x)) {
moveDistance.x *= BOUNCE_BACK_FACTOR;
}
}
if (!_touchMoved && fabs(convertDistanceFromPointToInch(dis)) < MOVE_INCH )
{
//CCLOG("Invalid movement, distance = [%f, %f], disInch = %f", moveDistance.x, moveDistance.y);
return;
}
if (!_touchMoved)
{
moveDistance.setZero();
}
_touchPoint = newPoint;
_touchMoved = true;
if (_dragging)
{
switch (_direction)
{
case Direction::VERTICAL:
moveDistance.set(0.0f, moveDistance.y);
break;
case Direction::HORIZONTAL:
moveDistance.set(moveDistance.x, 0.0f);
break;
default:
break;
}
newX = _container->getPosition().x + moveDistance.x;
newY = _container->getPosition().y + moveDistance.y;
_scrollDistance = moveDistance;
this->setContentOffset(Vec2(newX, newY));
}
}
else if (_touches.size() == 2 && !_dragging)
{
const float len = _container->convertTouchToNodeSpace(_touches[0]).getDistance(
_container->convertTouchToNodeSpace(_touches[1]));
this->setZoomScale(this->getZoomScale()*len/_touchLength);
}
}
}
void ScrollView::onTouchEnded(Touch* touch, Event* event)
{
if (!this->isVisible())
{
return;
}
auto touchIter = std::find(_touches.begin(), _touches.end(), touch);
if (touchIter != _touches.end())
{
if (_touches.size() == 1 && _touchMoved)
{
this->schedule(CC_SCHEDULE_SELECTOR(ScrollView::deaccelerateScrolling));
}
_touches.erase(touchIter);
}
if (_touches.empty())
{
_dragging = false;
_touchMoved = false;
}
}
void ScrollView::onTouchCancelled(Touch* touch, Event* event)
{
if (!this->isVisible())
{
return;
}
auto touchIter = std::find(_touches.begin(), _touches.end(), touch);
_touches.erase(touchIter);
if (_touches.empty())
{
_dragging = false;
_touchMoved = false;
}
}
Rect ScrollView::getViewRect()
{
Vec2 screenPos = this->convertToWorldSpace(Vec2::ZERO);
float scaleX = this->getScaleX();
float scaleY = this->getScaleY();
for (Node *p = _parent; p != nullptr; p = p->getParent()) {
scaleX *= p->getScaleX();
scaleY *= p->getScaleY();
}
// Support negative scaling. Not doing so causes intersectsRect calls
// (eg: to check if the touch was within the bounds) to return false.
// Note, Node::getScale will assert if X and Y scales are different.
if(scaleX<0.f) {
screenPos.x += _viewSize.width*scaleX;
scaleX = -scaleX;
}
if(scaleY<0.f) {
screenPos.y += _viewSize.height*scaleY;
scaleY = -scaleY;
}
return Rect(screenPos.x, screenPos.y, _viewSize.width*scaleX, _viewSize.height*scaleY);
}
NS_CC_EXT_END
@@ -1,399 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCSCROLLVIEW_H__
#define __CCSCROLLVIEW_H__
#include "2d/CCLayer.h"
#include "base/CCEventListenerTouch.h"
#include "2d/CCActionTween.h"
#include "extensions/ExtensionMacros.h"
#include "extensions/ExtensionExport.h"
/**
* @addtogroup ui
* @{
*/
NS_CC_EXT_BEGIN
class ScrollView;
class CC_EX_DLL ScrollViewDelegate
{
public:
/**
* @js NA
* @lua NA
*/
virtual ~ScrollViewDelegate() {}
/**
* @js NA
* @lua NA
*/
virtual void scrollViewDidScroll(ScrollView* view) {};
/**
* @js NA
* @lua NA
*/
virtual void scrollViewDidZoom(ScrollView* view) {};
};
/**
* ScrollView support for cocos2d-x.
* It provides scroll view functionalities to cocos2d projects natively.
*/
class CC_EX_DLL ScrollView : public Layer, public ActionTweenDelegate
{
public:
enum class Direction
{
NONE = -1,
HORIZONTAL = 0,
VERTICAL,
BOTH
};
/**
* Returns an autoreleased scroll view object.
*
* @param size view size
* @param container parent object
* @return autoreleased scroll view object
*/
static ScrollView* create(const Size& size, Node* container = NULL);
/**
* Returns an autoreleased scroll view object.
*
* @return autoreleased scroll view object
*/
static ScrollView* create();
/**
* @js ctor
* @lua new
*/
ScrollView();
/**
* @js NA
* @lua NA
*/
virtual ~ScrollView();
bool init() override;
/**
* Returns a scroll view object
*
* @param size view size
* @param container parent object
* @return scroll view object
*/
bool initWithViewSize(const Size& size, Node* container = NULL);
/**
* Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
*
* @param offset The new offset.
* @param animated If true, the view will scroll to the new offset.
*/
void setContentOffset(Vec2 offset, bool animated = false);
Vec2 getContentOffset();
/**
* Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
* You can override the animation duration with this method.
*
* @param offset The new offset.
* @param dt The animation duration.
*/
void setContentOffsetInDuration(const Vec2& offset, float dt);
/**
* Halts the movement animation of the inner content started with setContentOffset() or setContentOffsetInDuration()
*/
void stopAnimatedContentOffset();
void setZoomScale(float s);
/**
* Sets a new scale and does that for a predefined duration.
*
* @param s The new scale vale
* @param animated If true, scaling is animated
*/
void setZoomScale(float s, bool animated);
float getZoomScale();
/**
* Sets a new scale for container in a given duration.
*
* @param s The new scale value
* @param dt The animation duration
*/
void setZoomScaleInDuration(float s, float dt);
/**
* Set min scale
*
* @param minScale min scale
*/
void setMinScale(float minScale) {
_minScale = minScale;
}
/**
* Set max scale
*
* @param maxScale max scale
*/
void setMaxScale(float maxScale) {
_maxScale = maxScale;
}
/**
* Returns the current container's minimum offset. You may want this while you animate scrolling by yourself
*/
Vec2 minContainerOffset();
/**
* Returns the current container's maximum offset. You may want this while you animate scrolling by yourself
*/
Vec2 maxContainerOffset();
/**
* Determines if a given node's bounding box is in visible bounds
*
* @returns true if it is in visible bounds
*/
bool isNodeVisible(Node * node);
/**
* Provided to make scroll view compatible with SWLayer's pause method
*/
using Layer::pause; // fix warning
void pause(Ref* sender);
/**
* Provided to make scroll view compatible with SWLayer's resume method
*/
using Layer::resume; // fix warning
void resume(Ref* sender);
void setTouchEnabled(bool enabled);
bool isTouchEnabled() const;
bool isDragging() const {return _dragging;}
bool isTouchMoved() const { return _touchMoved; }
bool isBounceable() const { return _bounceable; }
void setBounceable(bool bBounceable) { _bounceable = bBounceable; }
/**
* size to clip. Node boundingBox uses contentSize directly.
* It's semantically different what it actually means to common scroll views.
* Hence, this scroll view will use a separate size property.
*/
Size getViewSize() const { return _viewSize; }
void setViewSize(const Size& size);
Node * getContainer();
void setContainer(Node * pContainer);
/**
* direction allowed to scroll. ScrollViewDirectionBoth by default.
*/
Direction getDirection() const { return _direction; }
virtual void setDirection(Direction eDirection) { _direction = eDirection; }
/**
* @js NA
* @lua NA
*/
ScrollViewDelegate* getDelegate() { return _delegate; }
/**
* @code
* when this function bound to js or lua,the input param are changed
* in js: var setDelegate(var jsObject)
* in lua: local setDelegate()
* @endcode
*/
void setDelegate(ScrollViewDelegate* pDelegate) { _delegate = pDelegate; }
void updateInset();
/**
* Determines whether it clips its children or not.
*/
bool isClippingToBounds() { return _clippingToBounds; }
void setClippingToBounds(bool bClippingToBounds) { _clippingToBounds = bClippingToBounds; }
virtual bool onTouchBegan(Touch *touch, Event *event);
virtual void onTouchMoved(Touch *touch, Event *event);
virtual void onTouchEnded(Touch *touch, Event *event);
virtual void onTouchCancelled(Touch *touch, Event *event);
// Overrides
virtual void setContentSize(const Size & size) override;
virtual const Size& getContentSize() const override;
/**
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void addChild(Node * child, int zOrder, const std::string &name) override;
virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void removeChild(Node* child, bool cleanup = true) override;
/**
* CCActionTweenDelegate
*/
void updateTweenAction(float value, const std::string& key) override;
bool hasVisibleParents() const;
protected:
/**
* Relocates the container at the proper offset, in bounds of max/min offsets.
*
* @param animated If true, relocation is animated
*/
void relocateContainer(bool animated);
/**
* implements auto-scrolling behavior. change SCROLL_DEACCEL_RATE as needed to choose
* deacceleration speed. it must be less than 1.0f.
*
* @param dt delta
*/
void deaccelerateScrolling(float dt);
/**
* This method makes sure auto scrolling causes delegate to invoke its method
*/
void performedAnimatedScroll(float dt);
/**
* Expire animated scroll delegate calls
*/
void stoppedAnimatedScroll(Node* node);
/**
* clip this view so that outside of the visible bounds can be hidden.
*/
void beforeDraw();
void onBeforeDraw();
/**
* retract what's done in beforeDraw so that there's no side effect to
* other nodes.
*/
void afterDraw();
void onAfterDraw();
/**
* Zoom handling
*/
void handleZoom();
Rect getViewRect();
/**
* scroll view delegate
*/
ScrollViewDelegate* _delegate;
Direction _direction;
/**
* If YES, the view is being dragged.
*/
bool _dragging;
/**
* Content offset. Note that left-bottom point is the origin
*/
Vec2 _contentOffset;
/**
* Container holds scroll view contents, Sets the scrollable container object of the scroll view
*/
Node* _container;
/**
* Determines whether user touch is moved after begin phase.
*/
bool _touchMoved;
/**
* max inset point to limit scrolling by touch
*/
Vec2 _maxInset;
/**
* min inset point to limit scrolling by touch
*/
Vec2 _minInset;
/**
* Determines whether the scroll view is allowed to bounce or not.
*/
bool _bounceable;
bool _clippingToBounds;
/**
* scroll speed
*/
Vec2 _scrollDistance;
/**
* Touch point
*/
Vec2 _touchPoint;
/**
* length between two fingers
*/
float _touchLength;
/**
* Touch objects to detect multitouch
*/
std::vector<Touch*> _touches;
/**
* size to clip. Node boundingBox uses contentSize directly.
* It's semantically different what it actually means to common scroll views.
* Hence, this scroll view will use a separate size property.
*/
Size _viewSize;
/**
* max and min scale
*/
float _minScale, _maxScale;
/**
* scissor rect for parent, just for restoring GL_SCISSOR_BOX
*/
Rect _parentScissorRect;
bool _scissorRestored;
/** Touch listener */
EventListenerTouchOneByOne* _touchListener;
CustomCommand _beforeDrawCommand;
CustomCommand _afterDrawCommand;
/**
* Action created with setContentOffsetInDuration(), saved so it can be halted
*/
Action* _animatedScrollAction;
};
NS_CC_EXT_END
// end of ui group
/// @}
#endif /* __CCSCROLLVIEW_H__ */
@@ -1,673 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCTableView.h"
#include "CCTableViewCell.h"
NS_CC_EXT_BEGIN
TableView* TableView::create()
{
return TableView::create(nullptr, Size::ZERO);
}
TableView* TableView::create(TableViewDataSource* dataSource, Size size)
{
return TableView::create(dataSource, size, nullptr);
}
TableView* TableView::create(TableViewDataSource* dataSource, Size size, Node *container)
{
TableView *table = new (std::nothrow) TableView();
table->initWithViewSize(size, container);
table->autorelease();
table->setDataSource(dataSource);
table->_updateCellPositions();
table->_updateContentSize();
return table;
}
bool TableView::initWithViewSize(const Size& size, Node* container/* = nullptr*/)
{
if (ScrollView::initWithViewSize(size,container))
{
CC_SAFE_DELETE(_indices);
_indices = new (std::nothrow) std::set<ssize_t>();
_vordering = VerticalFillOrder::BOTTOM_UP;
this->setDirection(Direction::VERTICAL);
ScrollView::setDelegate(this);
return true;
}
return false;
}
TableView::TableView()
: _touchedCell(nullptr)
, _indices(nullptr)
, _dataSource(nullptr)
, _tableViewDelegate(nullptr)
, _oldDirection(Direction::NONE)
, _isUsedCellsDirty(false)
{
}
TableView::~TableView()
{
CC_SAFE_DELETE(_indices);
}
void TableView::setVerticalFillOrder(VerticalFillOrder fillOrder)
{
if (_vordering != fillOrder)
{
_vordering = fillOrder;
if (!_cellsUsed.empty())
{
this->reloadData();
}
}
}
TableView::VerticalFillOrder TableView::getVerticalFillOrder()
{
return _vordering;
}
void TableView::reloadData()
{
_oldDirection = Direction::NONE;
for(const auto &cell : _cellsUsed) {
if(_tableViewDelegate != nullptr) {
_tableViewDelegate->tableCellWillRecycle(this, cell);
}
_cellsFreed.pushBack(cell);
cell->reset();
if (cell->getParent() == this->getContainer())
{
this->getContainer()->removeChild(cell, true);
}
}
_indices->clear();
_cellsUsed.clear();
this->_updateCellPositions();
this->_updateContentSize();
if (_dataSource->numberOfCellsInTableView(this) > 0)
{
this->scrollViewDidScroll(this);
}
}
TableViewCell *TableView::cellAtIndex(ssize_t idx)
{
if (_indices->find(idx) != _indices->end())
{
for (const auto& cell : _cellsUsed)
{
if (cell->getIdx() == idx)
{
return cell;
}
}
}
return nullptr;
}
void TableView::updateCellAtIndex(ssize_t idx)
{
if (idx == CC_INVALID_INDEX)
{
return;
}
long countOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == countOfItems || idx > countOfItems-1)
{
return;
}
TableViewCell* cell = cellAtIndex(idx);
if (cell)
{
_moveCellOutOfSight(cell);
}
cell = _dataSource->tableCellAtIndex(this, idx);
if (cell)
{
_setIndexForCell(idx, cell);
_addCellIfNecessary(cell);
}
}
void TableView::insertCellAtIndex(ssize_t idx)
{
if (idx == CC_INVALID_INDEX)
{
return;
}
long countOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == countOfItems || idx > countOfItems-1)
{
return;
}
long newIdx = 0;
auto cell = cellAtIndex(idx);
if (cell)
{
newIdx = _cellsUsed.getIndex(cell);
// Move all cells behind the inserted position
for (long i = newIdx; i < _cellsUsed.size(); i++)
{
cell = _cellsUsed.at(i);
this->_setIndexForCell(cell->getIdx()+1, cell);
}
}
//insert a new cell
cell = _dataSource->tableCellAtIndex(this, idx);
this->_setIndexForCell(idx, cell);
this->_addCellIfNecessary(cell);
this->_updateCellPositions();
this->_updateContentSize();
}
void TableView::removeCellAtIndex(ssize_t idx)
{
if (idx == CC_INVALID_INDEX)
{
return;
}
long uCountOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == uCountOfItems || idx > uCountOfItems-1)
{
return;
}
ssize_t newIdx = 0;
TableViewCell* cell = this->cellAtIndex(idx);
if (!cell)
{
return;
}
newIdx = _cellsUsed.getIndex(cell);
//remove first
this->_moveCellOutOfSight(cell);
_indices->erase(idx);
this->_updateCellPositions();
for (ssize_t i = _cellsUsed.size()-1; i > newIdx; i--)
{
cell = _cellsUsed.at(i);
this->_setIndexForCell(cell->getIdx()-1, cell);
}
}
TableViewCell *TableView::dequeueCell()
{
TableViewCell *cell;
if (_cellsFreed.empty()) {
cell = nullptr;
} else {
cell = _cellsFreed.at(0);
cell->retain();
_cellsFreed.erase(0);
cell->autorelease();
}
return cell;
}
void TableView::_addCellIfNecessary(TableViewCell * cell)
{
if (cell->getParent() != this->getContainer())
{
this->getContainer()->addChild(cell);
}
_cellsUsed.pushBack(cell);
_indices->insert(cell->getIdx());
_isUsedCellsDirty = true;
}
void TableView::_updateContentSize()
{
Size size = Size::ZERO;
ssize_t cellsCount = _dataSource->numberOfCellsInTableView(this);
if (cellsCount > 0)
{
float maxPosition = _vCellsPositions[cellsCount];
switch (this->getDirection())
{
case Direction::HORIZONTAL:
size = Size(maxPosition, _viewSize.height);
break;
default:
size = Size(_viewSize.width, maxPosition);
break;
}
}
this->setContentSize(size);
if (_oldDirection != _direction)
{
if (_direction == Direction::HORIZONTAL)
{
this->setContentOffset(Vec2::ZERO);
}
else
{
this->setContentOffset(Vec2(0,this->minContainerOffset().y));
}
_oldDirection = _direction;
}
}
Vec2 TableView::_offsetFromIndex(ssize_t index)
{
Vec2 offset = this->__offsetFromIndex(index);
const Size cellSize = _dataSource->tableCellSizeForIndex(this, index);
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y = this->getContainer()->getContentSize().height - offset.y - cellSize.height;
}
return offset;
}
Vec2 TableView::__offsetFromIndex(ssize_t index)
{
Vec2 offset;
Size cellSize;
switch (this->getDirection())
{
case Direction::HORIZONTAL:
offset.set(_vCellsPositions[index], 0.0f);
break;
default:
offset.set(0.0f, _vCellsPositions[index]);
break;
}
return offset;
}
long TableView::_indexFromOffset(Vec2 offset)
{
long index = 0;
const long maxIdx = _dataSource->numberOfCellsInTableView(this) - 1;
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y = this->getContainer()->getContentSize().height - offset.y;
}
index = this->__indexFromOffset(offset);
if (index != -1)
{
index = MAX(0, index);
if (index > maxIdx)
{
index = CC_INVALID_INDEX;
}
}
return index;
}
long TableView::__indexFromOffset(Vec2 offset)
{
long low = 0;
long high = _dataSource->numberOfCellsInTableView(this) - 1;
float search;
switch (this->getDirection())
{
case Direction::HORIZONTAL:
search = offset.x;
break;
default:
search = offset.y;
break;
}
while (high >= low)
{
long index = low + (high - low) / 2;
float cellStart = _vCellsPositions[index];
float cellEnd = _vCellsPositions[index + 1];
if (search >= cellStart && search <= cellEnd)
{
return index;
}
else if (search < cellStart)
{
high = index - 1;
}
else
{
low = index + 1;
}
}
if (low <= 0) {
return 0;
}
return -1;
}
void TableView::_moveCellOutOfSight(TableViewCell *cell)
{
if(_tableViewDelegate != nullptr) {
_tableViewDelegate->tableCellWillRecycle(this, cell);
}
_cellsFreed.pushBack(cell);
_cellsUsed.eraseObject(cell);
_isUsedCellsDirty = true;
_indices->erase(cell->getIdx());
cell->reset();
if (cell->getParent() == this->getContainer())
{
this->getContainer()->removeChild(cell, true);;
}
}
void TableView::_setIndexForCell(ssize_t index, TableViewCell *cell)
{
cell->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
cell->setPosition(this->_offsetFromIndex(index));
cell->setIdx(index);
}
void TableView::_updateCellPositions()
{
long cellsCount = _dataSource->numberOfCellsInTableView(this);
_vCellsPositions.resize(cellsCount + 1, 0.0);
if (cellsCount > 0)
{
float currentPos = 0;
Size cellSize;
for (int i=0; i < cellsCount; i++)
{
_vCellsPositions[i] = currentPos;
cellSize = _dataSource->tableCellSizeForIndex(this, i);
switch (this->getDirection())
{
case Direction::HORIZONTAL:
currentPos += cellSize.width;
break;
default:
currentPos += cellSize.height;
break;
}
}
_vCellsPositions[cellsCount] = currentPos;//1 extra value allows us to get right/bottom of the last cell
}
}
void TableView::scrollViewDidScroll(ScrollView* view)
{
long countOfItems = _dataSource->numberOfCellsInTableView(this);
if (0 == countOfItems)
{
return;
}
if (_isUsedCellsDirty)
{
_isUsedCellsDirty = false;
std::sort(_cellsUsed.begin(), _cellsUsed.end(), [](TableViewCell *a, TableViewCell *b) -> bool{
return a->getIdx() < b->getIdx();
});
}
if(_tableViewDelegate != nullptr) {
_tableViewDelegate->scrollViewDidScroll(this);
}
ssize_t startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
Vec2 offset = this->getContentOffset() * -1;
maxIdx = MAX(countOfItems-1, 0);
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y = offset.y + _viewSize.height/this->getContainer()->getScaleY();
}
startIdx = this->_indexFromOffset(offset);
if (startIdx == CC_INVALID_INDEX)
{
startIdx = countOfItems - 1;
}
if (_vordering == VerticalFillOrder::TOP_DOWN)
{
offset.y -= _viewSize.height/this->getContainer()->getScaleY();
}
else
{
offset.y += _viewSize.height/this->getContainer()->getScaleY();
}
offset.x += _viewSize.width/this->getContainer()->getScaleX();
endIdx = this->_indexFromOffset(offset);
if (endIdx == CC_INVALID_INDEX)
{
endIdx = countOfItems - 1;
}
#if 0 // For Testing.
Ref* pObj;
int i = 0;
CCARRAY_FOREACH(_cellsUsed, pObj)
{
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
log("cells Used index %d, value = %d", i, pCell->getIdx());
i++;
}
log("---------------------------------------");
i = 0;
CCARRAY_FOREACH(_cellsFreed, pObj)
{
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
log("cells freed index %d, value = %d", i, pCell->getIdx());
i++;
}
log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
#endif
if (!_cellsUsed.empty())
{
auto cell = _cellsUsed.at(0);
idx = cell->getIdx();
while(idx < startIdx)
{
this->_moveCellOutOfSight(cell);
if (!_cellsUsed.empty())
{
cell = _cellsUsed.at(0);
idx = cell->getIdx();
}
else
{
break;
}
}
}
if (!_cellsUsed.empty())
{
auto cell = _cellsUsed.back();
idx = cell->getIdx();
while(idx <= maxIdx && idx > endIdx)
{
this->_moveCellOutOfSight(cell);
if (!_cellsUsed.empty())
{
cell = _cellsUsed.back();
idx = cell->getIdx();
}
else
{
break;
}
}
}
for (long i = startIdx; i <= endIdx; i++)
{
if (_indices->find(i) != _indices->end())
{
continue;
}
this->updateCellAtIndex(i);
}
}
void TableView::onTouchEnded(Touch *pTouch, Event *pEvent)
{
if (!this->isVisible()) {
return;
}
if (_touchedCell){
Rect bb = this->getBoundingBox();
bb.origin = _parent->convertToWorldSpace(bb.origin);
if (bb.containsPoint(pTouch->getLocation()) && _tableViewDelegate != nullptr)
{
_tableViewDelegate->tableCellUnhighlight(this, _touchedCell);
_tableViewDelegate->tableCellTouched(this, _touchedCell);
}
_touchedCell = nullptr;
}
ScrollView::onTouchEnded(pTouch, pEvent);
}
bool TableView::onTouchBegan(Touch *pTouch, Event *pEvent)
{
for (Node *c = this; c != nullptr; c = c->getParent())
{
if (!c->isVisible())
{
return false;
}
}
bool touchResult = ScrollView::onTouchBegan(pTouch, pEvent);
if(_touches.size() == 1)
{
long index;
Vec2 point;
point = this->getContainer()->convertTouchToNodeSpace(pTouch);
index = this->_indexFromOffset(point);
if (index == CC_INVALID_INDEX)
{
_touchedCell = nullptr;
}
else
{
_touchedCell = this->cellAtIndex(index);
}
if (_touchedCell && _tableViewDelegate != nullptr)
{
_tableViewDelegate->tableCellHighlight(this, _touchedCell);
}
}
else if (_touchedCell)
{
if(_tableViewDelegate != nullptr)
{
_tableViewDelegate->tableCellUnhighlight(this, _touchedCell);
}
_touchedCell = nullptr;
}
return touchResult;
}
void TableView::onTouchMoved(Touch *pTouch, Event *pEvent)
{
ScrollView::onTouchMoved(pTouch, pEvent);
if (_touchedCell && isTouchMoved())
{
if(_tableViewDelegate != nullptr)
{
_tableViewDelegate->tableCellUnhighlight(this, _touchedCell);
}
_touchedCell = nullptr;
}
}
void TableView::onTouchCancelled(Touch *pTouch, Event *pEvent)
{
ScrollView::onTouchCancelled(pTouch, pEvent);
if (_touchedCell)
{
if(_tableViewDelegate != nullptr)
{
_tableViewDelegate->tableCellUnhighlight(this, _touchedCell);
}
_touchedCell = nullptr;
}
}
NS_CC_EXT_END
@@ -1,341 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTABLEVIEW_H__
#define __CCTABLEVIEW_H__
#include "CCScrollView.h"
#include "CCTableViewCell.h"
#include "extensions/ExtensionExport.h"
#include <set>
#include <vector>
/**
* @addtogroup ui
* @{
*/
NS_CC_EXT_BEGIN
class TableView;
/**
* Sole purpose of this delegate is to single touch event in this version.
*/
class CC_EX_DLL TableViewDelegate : public ScrollViewDelegate
{
public:
/**
* Delegate to respond touch event
*
* @param table table contains the given cell
* @param cell cell that is touched
* @js NA
* @lua NA
*/
virtual void tableCellTouched(TableView* table, TableViewCell* cell) = 0;
/**
* Delegate to respond a table cell press event.
*
* @param table table contains the given cell
* @param cell cell that is pressed
* @js NA
* @lua NA
*/
virtual void tableCellHighlight(TableView* table, TableViewCell* cell){};
/**
* Delegate to respond a table cell release event
*
* @param table table contains the given cell
* @param cell cell that is pressed
* @js NA
* @lua NA
*/
virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell){};
/**
* Delegate called when the cell is about to be recycled. Immediately
* after this call the cell will be removed from the scene graph and
* recycled.
*
* @param table table contains the given cell
* @param cell cell that is pressed
* @js NA
* @lua NA
*/
virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell){};
};
/**
* Data source that governs table backend data.
*/
class CC_EX_DLL TableViewDataSource
{
public:
/**
* @js NA
* @lua NA
*/
virtual ~TableViewDataSource() {}
/**
* cell size for a given index
*
* @param idx the index of a cell to get a size
* @return size of a cell at given index
*/
virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) {
return cellSizeForTable(table);
};
/**
* cell height for a given table.
*
* @param table table to hold the instances of Class
* @return cell size
*/
virtual Size cellSizeForTable(TableView *table) {
return Size::ZERO;
};
/**
* a cell instance at a given index
*
* @param idx index to search for a cell
* @return cell found at idx
*/
virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) = 0;
/**
* Returns number of cells in a given table view.
*
* @return number of cells
*/
virtual ssize_t numberOfCellsInTableView(TableView *table) = 0;
};
/**
* UITableView support for cocos2d-x.
*
* This is a very basic, minimal implementation to bring UITableView-like component into cocos2d world.
*/
class CC_EX_DLL TableView : public ScrollView, public ScrollViewDelegate
{
public:
enum class VerticalFillOrder
{
TOP_DOWN,
BOTTOM_UP
};
/** Empty contructor of TableView */
static TableView* create();
/**
* An intialized table view object
*
* @param dataSource data source
* @param size view size
* @return table view
* @code
* when this function bound to js or lua,the input params are changed
* in js:var create(var jsObject,var size)
* in lua:local create(var size)
* in lua:
* @endcode
*/
static TableView* create(TableViewDataSource* dataSource, Size size);
/**
* An initialized table view object
*
* @param dataSource data source;
* @param size view size
* @param container parent object for cells
* @return table view
* @code
* when this function bound to js or lua,the input params are changed
* in js:var create(var jsObject,var size,var container)
* in lua:local create(var size, var container)
* in lua:
* @endcode
*/
static TableView* create(TableViewDataSource* dataSource, Size size, Node *container);
/**
* @js ctor
* @lua new
*/
TableView();
/**
* @js NA
* @lua NA
*/
virtual ~TableView();
bool initWithViewSize(const Size& size, Node* container = NULL);
/**
* data source
* @js NA
* @lua NA
*/
TableViewDataSource* getDataSource() { return _dataSource; }
/**
* when this function bound to js or lua,the input params are changed
* in js:var setDataSource(var jsSource)
* in lua:local setDataSource()
* @endcode
*/
void setDataSource(TableViewDataSource* source) { _dataSource = source; }
/**
* delegate
* @js NA
* @lua NA
*/
TableViewDelegate* getDelegate() { return _tableViewDelegate; }
/**
* @code
* when this function bound to js or lua,the input params are changed
* in js:var setDelegate(var jsDelegate)
* in lua:local setDelegate()
* @endcode
*/
void setDelegate(TableViewDelegate* pDelegate) { _tableViewDelegate = pDelegate; }
/**
* determines how cell is ordered and filled in the view.
*/
void setVerticalFillOrder(VerticalFillOrder order);
VerticalFillOrder getVerticalFillOrder();
/**
* Updates the content of the cell at a given index.
*
* @param idx index to find a cell
*/
void updateCellAtIndex(ssize_t idx);
/**
* Inserts a new cell at a given index
*
* @param idx location to insert
*/
void insertCellAtIndex(ssize_t idx);
/**
* Removes a cell at a given index
*
* @param idx index to find a cell
*/
void removeCellAtIndex(ssize_t idx);
/**
* reloads data from data source. the view will be refreshed.
*/
void reloadData();
/**
* Dequeues a free cell if available. nil if not.
*
* @return free cell
*/
TableViewCell *dequeueCell();
/**
* Returns an existing cell at a given index. Returns nil if a cell is nonexistent at the moment of query.
*
* @param idx index
* @return a cell at a given index
*/
TableViewCell *cellAtIndex(ssize_t idx);
// Overrides
virtual void scrollViewDidScroll(ScrollView* view) override;
virtual void scrollViewDidZoom(ScrollView* view) override {}
virtual bool onTouchBegan(Touch *pTouch, Event *pEvent) override;
virtual void onTouchMoved(Touch *pTouch, Event *pEvent) override;
virtual void onTouchEnded(Touch *pTouch, Event *pEvent) override;
virtual void onTouchCancelled(Touch *pTouch, Event *pEvent) override;
protected:
long __indexFromOffset(Vec2 offset);
long _indexFromOffset(Vec2 offset);
Vec2 __offsetFromIndex(ssize_t index);
Vec2 _offsetFromIndex(ssize_t index);
void _moveCellOutOfSight(TableViewCell *cell);
void _setIndexForCell(ssize_t index, TableViewCell *cell);
void _addCellIfNecessary(TableViewCell * cell);
void _updateCellPositions();
TableViewCell *_touchedCell;
/**
* vertical direction of cell filling
*/
VerticalFillOrder _vordering;
/**
* index set to query the indexes of the cells used.
*/
std::set<ssize_t>* _indices;
/**
* vector with all cell positions
*/
std::vector<float> _vCellsPositions;
//NSMutableIndexSet *indices_;
/**
* cells that are currently in the table
*/
Vector<TableViewCell*> _cellsUsed;
/**
* free list of cells
*/
Vector<TableViewCell*> _cellsFreed;
/**
* weak link to the data source object
*/
TableViewDataSource* _dataSource;
/**
* weak link to the delegate object
*/
TableViewDelegate* _tableViewDelegate;
Direction _oldDirection;
bool _isUsedCellsDirty;
public:
void _updateContentSize();
};
NS_CC_EXT_END
// end of ui group
/// @}
#endif /* __CCTABLEVIEW_H__ */
@@ -1,46 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCTableViewCell.h"
NS_CC_EXT_BEGIN
void TableViewCell::reset()
{
_idx = CC_INVALID_INDEX;
}
ssize_t TableViewCell::getIdx() const
{
return _idx;
}
void TableViewCell::setIdx(ssize_t idx)
{
_idx = idx;
}
NS_CC_EXT_END
@@ -1,68 +0,0 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2010 Sangwoo Im
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTABLEVIEWCELL_H__
#define __CCTABLEVIEWCELL_H__
#include "extensions/ExtensionMacros.h"
#include "2d/CCNode.h"
#include "extensions/ExtensionExport.h"
/**
* @addtogroup ui
* @{
*/
NS_CC_EXT_BEGIN
/**
* Abstract class for SWTableView cell node
*/
class CC_EX_DLL TableViewCell: public Node
{
public:
CREATE_FUNC(TableViewCell);
TableViewCell() {}
/**
* The index used internally by SWTableView and its subclasses
*/
ssize_t getIdx() const;
void setIdx(ssize_t uIdx);
/**
* Cleans up any resources linked to this cell and resets <code>idx</code> property.
*/
void reset();
private:
ssize_t _idx;
};
NS_CC_EXT_END
// end of ui group
/// @}
#endif /* __CCTABLEVIEWCELL_H__ */
-6
View File
@@ -8,11 +8,5 @@
#include "assets-manager/CCEventListenerAssetsManagerEx.h"
#include "assets-manager/Manifest.h"
#include "GUI/CCControlExtension/CCControlExtensions.h"
#include "GUI/CCScrollView/CCScrollView.h"
#include "GUI/CCScrollView/CCTableView.h"
#include "physics-nodes/CCPhysicsSprite.h"
#include "physics-nodes/CCPhysicsDebugNode.h"
#endif /* __COCOS2D_EXT_H__ */
@@ -1,244 +0,0 @@
/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software
* Copyright (c) 2012 cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "CCPhysicsDebugNode.h"
#if CC_ENABLE_CHIPMUNK_INTEGRATION
#include "chipmunk/chipmunk_private.h"
#endif
#include "base/ccTypes.h"
#include "math/CCGeometry.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <string.h>
NS_CC_EXT_BEGIN
#if CC_ENABLE_CHIPMUNK_INTEGRATION
/*
IMPORTANT - READ ME!
This file sets pokes around in the private API a lot to provide efficient
debug rendering given nothing more than reference to a Chipmunk space.
It is not recommended to write rendering code like this in your own games
as the private API may change with little or no warning.
*/
static Color4F ColorForBody(cpBody *body)
{
if (CP_BODY_TYPE_STATIC == cpBodyGetType(body) || cpBodyIsSleeping(body))
{
return Color4F(0.5f, 0.5f, 0.5f ,0.5f);
}
else if (body->sleeping.idleTime > cpBodyGetSpace(body)->sleepTimeThreshold)
{
return Color4F(0.33f, 0.33f, 0.33f, 0.5f);
}
else
{
return Color4F(1.0f, 0.0f, 0.0f, 0.5f);
}
}
static Vec2 cpVert2Point(const cpVect &vert)
{
return Vec2(vert.x, vert.y);
}
static Vec2* cpVertArray2ccpArrayN(const cpVect* cpVertArray, unsigned int count)
{
if (count == 0) return nullptr;
Vec2* pPoints = new (std::nothrow) Vec2[count];
for (unsigned int i = 0; i < count; ++i)
{
pPoints[i].x = cpVertArray[i].x;
pPoints[i].y = cpVertArray[i].y;
}
return pPoints;
}
static void DrawShape(cpShape *shape, DrawNode *renderer)
{
cpBody *body = cpShapeGetBody(shape);
Color4F color = ColorForBody(body);
switch (shape->CP_PRIVATE(klass)->type)
{
case CP_CIRCLE_SHAPE:
{
cpCircleShape *circle = (cpCircleShape *)shape;
cpVect center = circle->tc;
cpFloat radius = circle->r;
renderer->drawDot(cpVert2Point(center), cpfmax(radius, 1.0), color);
renderer->drawSegment(cpVert2Point(center), cpVert2Point(cpvadd(center, cpvmult(cpBodyGetRotation(body), radius))), 1.0, color);
}
break;
case CP_SEGMENT_SHAPE:
{
cpSegmentShape *seg = (cpSegmentShape *)shape;
renderer->drawSegment(cpVert2Point(seg->ta), cpVert2Point(seg->tb), cpfmax(seg->r, 2.0), color);
}
break;
case CP_POLY_SHAPE:
{
cpPolyShape* poly = (cpPolyShape*)shape;
Color4F line = color;
line.a = cpflerp(color.a, 1.0, 0.5);
int num = poly->count;
Vec2* pPoints = new (std::nothrow) Vec2[num];
for(int i=0;i<num;++i)
pPoints[i] = cpVert2Point(poly->planes[i].v0);
renderer->drawPolygon(pPoints, num, color, 1.0, line);
CC_SAFE_DELETE_ARRAY(pPoints);
}
break;
default:
cpAssertHard(false, "Bad assertion in DrawShape()");
}
}
static Color4F CONSTRAINT_COLOR(0, 1, 0, 0.5);
static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer)
{
cpBody *body_a = cpConstraintGetBodyA(constraint);
cpBody *body_b = cpConstraintGetBodyB(constraint);
if(cpConstraintIsPinJoint(constraint))
{
cpVect a = cpvadd(cpBodyGetPosition(body_a), cpvrotate(cpPinJointGetAnchorA(constraint), cpBodyGetRotation(body_a)));
cpVect b = cpvadd(cpBodyGetPosition(body_b), cpvrotate(cpPinJointGetAnchorB(constraint), cpBodyGetRotation(body_b)));
renderer->drawDot(cpVert2Point(a), 3.0, CONSTRAINT_COLOR);
renderer->drawDot(cpVert2Point(b), 3.0, CONSTRAINT_COLOR);
renderer->drawSegment(cpVert2Point(a), cpVert2Point(b), 1.0, CONSTRAINT_COLOR);
}
else if(cpConstraintIsSlideJoint(constraint))
{
cpVect a = cpvadd(cpBodyGetPosition(body_a), cpvrotate(cpSlideJointGetAnchorA(constraint), cpBodyGetRotation(body_a)));
cpVect b = cpvadd(cpBodyGetPosition(body_b), cpvrotate(cpSlideJointGetAnchorB(constraint), cpBodyGetRotation(body_b)));
renderer->drawDot(cpVert2Point(a), 3.0, CONSTRAINT_COLOR);
renderer->drawDot(cpVert2Point(b), 3.0, CONSTRAINT_COLOR);
renderer->drawSegment(cpVert2Point(a), cpVert2Point(b), 1.0, CONSTRAINT_COLOR);
}
else if(cpConstraintIsPivotJoint(constraint))
{
cpVect a = cpvadd(cpBodyGetPosition(body_a), cpvrotate(cpPivotJointGetAnchorA(constraint), cpBodyGetRotation(body_a)));
cpVect b = cpvadd(cpBodyGetPosition(body_b), cpvrotate(cpPivotJointGetAnchorB(constraint), cpBodyGetRotation(body_b)));
renderer->drawDot(cpVert2Point(a), 3.0, CONSTRAINT_COLOR);
renderer->drawDot(cpVert2Point(b), 3.0, CONSTRAINT_COLOR);
}
else if(cpConstraintIsGrooveJoint(constraint))
{
cpVect a = cpvadd(cpBodyGetPosition(body_a), cpvrotate(cpGrooveJointGetGrooveA(constraint), cpBodyGetRotation(body_a)));
cpVect b = cpvadd(cpBodyGetPosition(body_a), cpvrotate(cpGrooveJointGetGrooveB(constraint), cpBodyGetRotation(body_a)));
cpVect c = cpvadd(cpBodyGetPosition(body_b), cpvrotate(cpGrooveJointGetAnchorB(constraint), cpBodyGetRotation(body_b)));
renderer->drawDot(cpVert2Point(c), 3.0, CONSTRAINT_COLOR);
renderer->drawSegment(cpVert2Point(a), cpVert2Point(b), 1.0, CONSTRAINT_COLOR);
}
else if(cpConstraintIsDampedSpring(constraint))
{
// TODO: uninplemented
}
else
{
// printf("Cannot draw constraint\n");
}
}
#endif // #if CC_ENABLE_CHIPMUNK_INTEGRATION
// implementation of PhysicsDebugNode
void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (! _spacePtr)
{
return;
}
#if CC_ENABLE_CHIPMUNK_INTEGRATION
// clear the shapes information before draw current shapes.
DrawNode::clear();
cpSpaceEachShape(_spacePtr, (cpSpaceShapeIteratorFunc)DrawShape, this);
cpSpaceEachConstraint(_spacePtr, (cpSpaceConstraintIteratorFunc)DrawConstraint, this);
DrawNode::draw(renderer, transform, flags);
#endif
}
PhysicsDebugNode::PhysicsDebugNode()
: _spacePtr(nullptr)
{}
PhysicsDebugNode* PhysicsDebugNode::create(cpSpace *space)
{
PhysicsDebugNode *node = new (std::nothrow) PhysicsDebugNode();
if (node)
{
node->init();
#if CC_ENABLE_CHIPMUNK_INTEGRATION
node->_spacePtr = space;
#else
CCASSERT(false, "CC_ENABLE_CHIPMUNK_INTEGRATION was not enabled!");
#endif
node->autorelease();
}
else
{
CC_SAFE_DELETE(node);
}
return node;
}
PhysicsDebugNode::~PhysicsDebugNode()
{
}
cpSpace* PhysicsDebugNode::getSpace() const
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
return _spacePtr;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
return nullptr;
#endif
}
void PhysicsDebugNode::setSpace(cpSpace *space)
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
_spacePtr = space;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
#endif
}
NS_CC_EXT_END
@@ -1,74 +0,0 @@
/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software
* Copyright (c) 2012 cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __PHYSICSNODES_DEBUGNODE_H__
#define __PHYSICSNODES_DEBUGNODE_H__
#include "extensions/ExtensionMacros.h"
#include "2d/CCDrawNode.h"
#include "extensions/ExtensionExport.h"
struct cpSpace;
NS_CC_EXT_BEGIN
/**
* A BaseData that draws the components of a physics engine.
* Supported physics engines:
* - Chipmunk
* - Objective-Chipmunk
* @since v2.1
* @lua NA
*/
class CC_EX_DLL PhysicsDebugNode : public DrawNode
{
public:
/** Create a debug node for a regular Chipmunk space. */
static PhysicsDebugNode* create(cpSpace *space);
/**
* @js ctor
*/
PhysicsDebugNode();
/**
* @js NA
*/
virtual ~PhysicsDebugNode();
cpSpace* getSpace() const;
void setSpace(cpSpace *space);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
cpSpace *_spacePtr;
};
NS_CC_EXT_END
#endif // __PHYSICSNODES_DEBUGNODE_H__
@@ -1,441 +0,0 @@
/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software
* Copyright (c) 2012 cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "CCPhysicsSprite.h"
#include "base/CCDirector.h"
#include "base/CCEventDispatcher.h"
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
#if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION)
#error "Either Chipmunk or Box2d should be enabled, but not both at the same time"
#endif
#if CC_ENABLE_CHIPMUNK_INTEGRATION
#include "chipmunk/chipmunk.h"
#elif CC_ENABLE_BOX2D_INTEGRATION
#include "Box2D/Box2D.h"
#endif
NS_CC_EXT_BEGIN
PhysicsSprite::PhysicsSprite()
: _ignoreBodyRotation(false)
, _CPBody(nullptr)
, _pB2Body(nullptr)
, _PTMRatio(0.0f)
, _syncTransform(nullptr)
{}
PhysicsSprite* PhysicsSprite::create()
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::createWithTexture(Texture2D *pTexture)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithTexture(pTexture))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::createWithTexture(Texture2D *pTexture, const Rect& rect)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithTexture(pTexture, rect))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::createWithSpriteFrame(SpriteFrame *pSpriteFrame)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithSpriteFrame(pSpriteFrame))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::createWithSpriteFrameName(const char *pszSpriteFrameName)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithSpriteFrameName(pszSpriteFrameName))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::create(const char *pszFileName)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithFile(pszFileName))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
PhysicsSprite* PhysicsSprite::create(const char *pszFileName, const Rect& rect)
{
PhysicsSprite* pRet = new (std::nothrow) PhysicsSprite();
if (pRet && pRet->initWithFile(pszFileName, rect))
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
// this method will only get called if the sprite is batched.
// return YES if the physic's values (angles, position ) changed.
// If you return NO, then getNodeToParentTransform won't be called.
bool PhysicsSprite::isDirty() const
{
return true;
}
bool PhysicsSprite::isIgnoreBodyRotation() const
{
return _ignoreBodyRotation;
}
void PhysicsSprite::setIgnoreBodyRotation(bool bIgnoreBodyRotation)
{
_ignoreBodyRotation = bIgnoreBodyRotation;
}
// Override the setters and getters to always reflect the body's properties.
const Vec2& PhysicsSprite::getPosition() const
{
return getPosFromPhysics();
}
void PhysicsSprite::getPosition(float* x, float* y) const
{
if (x == nullptr || y == nullptr) {
return;
}
const Vec2& pos = getPosFromPhysics();
*x = pos.x;
*y = pos.y;
}
float PhysicsSprite::getPositionX() const
{
return getPosFromPhysics().x;
}
float PhysicsSprite::getPositionY() const
{
return getPosFromPhysics().y;
}
//
// Chipmunk only
//
cpBody* PhysicsSprite::getCPBody() const
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
return _CPBody;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
return nullptr;
#endif
}
void PhysicsSprite::setCPBody(cpBody *pBody)
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
_CPBody = pBody;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
#endif
}
b2Body* PhysicsSprite::getB2Body() const
{
#if CC_ENABLE_BOX2D_INTEGRATION
return _pB2Body;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
return nullptr;
#endif
}
void PhysicsSprite::setB2Body(b2Body *pBody)
{
#if CC_ENABLE_BOX2D_INTEGRATION
_pB2Body = pBody;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
#endif
}
float PhysicsSprite::getPTMRatio() const
{
#if CC_ENABLE_BOX2D_INTEGRATION
return _PTMRatio;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
return 0;
#endif
}
void PhysicsSprite::setPTMRatio(float fRatio)
{
#if CC_ENABLE_BOX2D_INTEGRATION
_PTMRatio = fRatio;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
#endif
}
//
// Common to Box2d and Chipmunk
//
const Vec2& PhysicsSprite::getPosFromPhysics() const
{
static Vec2 s_physicPosion;
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect cpPos = cpBodyGetPosition(_CPBody);
s_physicPosion = Vec2(cpPos.x, cpPos.y);
#elif CC_ENABLE_BOX2D_INTEGRATION
b2Vec2 pos = _pB2Body->GetPosition();
float x = pos.x * _PTMRatio;
float y = pos.y * _PTMRatio;
s_physicPosion.set(x,y);
#endif
return s_physicPosion;
}
void PhysicsSprite::setPosition(float x, float y)
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect cpPos = cpv(x, y);
cpBodySetPosition(_CPBody, cpPos);
#elif CC_ENABLE_BOX2D_INTEGRATION
float angle = _pB2Body->GetAngle();
_pB2Body->SetTransform(b2Vec2(x / _PTMRatio, y / _PTMRatio), angle);
#endif
}
void PhysicsSprite::setPosition(const Vec2 &pos)
{
setPosition(pos.x, pos.y);
}
void PhysicsSprite::setPositionX(float x)
{
setPosition(x, getPositionY());
}
void PhysicsSprite::setPositionY(float y)
{
setPosition(getPositionX(), y);
}
float PhysicsSprite::getRotation() const
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
return (_ignoreBodyRotation ? Sprite::getRotation() : -CC_RADIANS_TO_DEGREES(cpBodyGetAngle(_CPBody)));
#elif CC_ENABLE_BOX2D_INTEGRATION
return (_ignoreBodyRotation ? Sprite::getRotation() :
CC_RADIANS_TO_DEGREES(_pB2Body->GetAngle()));
#else
return 0.0f;
#endif
}
void PhysicsSprite::setRotation(float fRotation)
{
if (_ignoreBodyRotation)
{
Sprite::setRotation(fRotation);
}
#if CC_ENABLE_CHIPMUNK_INTEGRATION
else
{
cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation));
}
#elif CC_ENABLE_BOX2D_INTEGRATION
else
{
b2Vec2 p = _pB2Body->GetPosition();
float radians = CC_DEGREES_TO_RADIANS(fRotation);
_pB2Body->SetTransform(p, radians);
}
#endif
}
void PhysicsSprite::syncPhysicsTransform() const
{
// Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions.
// For more info see: http://www.cocos2d-iphone.org/forum/topic/68990
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect rot = (_ignoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(_rotationX)) : cpBodyGetRotation(_CPBody));
float x = cpBodyGetPosition(_CPBody).x + rot.x * -_anchorPointInPoints.x * _scaleX - rot.y * -_anchorPointInPoints.y * _scaleY;
float y = cpBodyGetPosition(_CPBody).y + rot.y * -_anchorPointInPoints.x * _scaleX + rot.x * -_anchorPointInPoints.y * _scaleY;
if (_ignoreAnchorPointForPosition)
{
x += _anchorPointInPoints.x;
y += _anchorPointInPoints.y;
}
float mat[] = { (float)rot.x * _scaleX, (float)rot.y * _scaleX, 0, 0,
(float)-rot.y * _scaleY, (float)rot.x * _scaleY, 0, 0,
0, 0, 1, 0,
x, y, 0, 1};
_transform.set(mat);
#elif CC_ENABLE_BOX2D_INTEGRATION
b2Vec2 pos = _pB2Body->GetPosition();
float x = pos.x * _PTMRatio;
float y = pos.y * _PTMRatio;
if (_ignoreAnchorPointForPosition)
{
x += _anchorPointInPoints.x;
y += _anchorPointInPoints.y;
}
// Make matrix
float radians = _pB2Body->GetAngle();
float c = cosf(radians);
float s = sinf(radians);
if (!_anchorPointInPoints.isZero())
{
x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY));
y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY));
}
// Rot, Translate Matrix
float mat[] = { (float)c * _scaleX, (float)s * _scaleX, 0, 0,
(float)-s * _scaleY, (float)c * _scaleY, 0, 0,
0, 0, 1, 0,
x, y, 0, 1};
_transform.set(mat);
#endif
}
void PhysicsSprite::onEnter()
{
Node::onEnter();
_syncTransform = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_AFTER_UPDATE, std::bind(&PhysicsSprite::afterUpdate, this, std::placeholders::_1));
_syncTransform->retain();
}
void PhysicsSprite::onExit()
{
if (_syncTransform != nullptr)
{
Director::getInstance()->getEventDispatcher()->removeEventListener(_syncTransform);
_syncTransform->release();
}
Node::onExit();
}
void PhysicsSprite::afterUpdate(EventCustom *event)
{
syncPhysicsTransform();
_transformDirty = false;
_transformUpdated = true;
setDirtyRecursively(true);
}
NS_CC_EXT_END
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION
@@ -1,152 +0,0 @@
/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software
* Copyright (c) 2012 cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__
#define __PHYSICSNODES_CCPHYSICSSPRITE_H__
#include "2d/CCSprite.h"
#include "extensions/ExtensionMacros.h"
#include "extensions/ExtensionExport.h"
#include "base/CCEventListenerCustom.h"
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
struct cpBody;
class b2Body;
NS_CC_EXT_BEGIN
/** A Sprite subclass that is bound to a physics body.
It works with:
- Chipmunk: Preprocessor macro CC_ENABLE_CHIPMUNK_INTEGRATION should be defined
- Objective-Chipmunk: Preprocessor macro CC_ENABLE_CHIPMUNK_INTEGRATION should be defined
- Box2d: Preprocessor macro CC_ENABLE_BOX2D_INTEGRATION should be defined
Features and Limitations:
- Scale and Skew properties are ignored.
- Position and rotation are going to updated from the physics body
- If you update the rotation or position manually, the physics body will be updated
- You can't enble both Chipmunk support and Box2d support at the same time. Only one can be enabled at compile time
* @lua NA
*/
class CC_EX_DLL PhysicsSprite : public Sprite
{
public:
static PhysicsSprite* create();
/** Creates an sprite with a texture.
The rect used will be the size of the texture.
The offset will be (0,0).
*/
static PhysicsSprite* createWithTexture(Texture2D *pTexture);
/** Creates an sprite with a texture and a rect.
The offset will be (0,0).
*/
static PhysicsSprite* createWithTexture(Texture2D *pTexture, const Rect& rect);
/** Creates an sprite with an sprite frame. */
static PhysicsSprite* createWithSpriteFrame(SpriteFrame *pSpriteFrame);
/** Creates an sprite with an sprite frame name.
An SpriteFrame will be fetched from the SpriteFrameCache by name.
If the SpriteFrame doesn't exist it will raise an exception.
@since v0.9
*/
static PhysicsSprite* createWithSpriteFrameName(const char *pszSpriteFrameName);
/** Creates an sprite with an image filename.
The rect used will be the size of the image.
The offset will be (0,0).
*/
static PhysicsSprite* create(const char *pszFileName);
/** Creates an sprite with an image filename and a rect.
The offset will be (0,0).
*/
static PhysicsSprite* create(const char *pszFileName, const Rect& rect);
PhysicsSprite();
virtual bool isDirty() const override;
/** Keep the sprite's rotation separate from the body. */
bool isIgnoreBodyRotation() const;
void setIgnoreBodyRotation(bool bIgnoreBodyRotation);
//
// Chipmunk specific
//
/** Body accessor when using regular Chipmunk */
cpBody* getCPBody() const;
void setCPBody(cpBody *pBody);
//
// Box2d specific
//
/** Body accessor when using box2d */
b2Body* getB2Body() const;
void setB2Body(b2Body *pBody);
float getPTMRatio() const;
void setPTMRatio(float fPTMRatio);
virtual void syncPhysicsTransform() const;
// overrides
virtual const Vec2& getPosition() const override;
virtual void getPosition(float* x, float* y) const override;
virtual float getPositionX() const override;
virtual float getPositionY() const override;
virtual void setPosition(const Vec2 &position) override;
virtual void setPosition(float x, float y) override;
virtual void setPositionX(float x) override;
virtual void setPositionY(float y) override;
virtual float getRotation() const override;
virtual void setRotation(float fRotation) override;
virtual void onEnter() override;
virtual void onExit() override;
protected:
const Vec2& getPosFromPhysics() const;
void afterUpdate(EventCustom *event);
protected:
bool _ignoreBodyRotation;
// chipmunk specific
cpBody *_CPBody;
// box2d specific
b2Body *_pB2Body;
float _PTMRatio;
// Event for update synchronise physic transform
cocos2d::EventListenerCustom* _syncTransform;
};
NS_CC_EXT_END
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION
#endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__
+2 -9
View File
@@ -29,7 +29,7 @@ replace_headers = cocos-ext.h::extensions/cocos-ext.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = AssetsManagerEx Manifest EventListenerAssetsManagerEx EventAssetsManagerEx Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$
classes = AssetsManagerEx Manifest EventListenerAssetsManagerEx EventAssetsManagerEx
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@@ -42,13 +42,6 @@ skip = ScrollView::[(g|s)etDelegate$],
.*Delegate::[*],
.*Loader.*::[*],
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener],
TableView::[create (g|s)etDataSource$ (g|s)etDelegate],
Control::[removeHandleOfControlEvent addHandleOfControlEvent],
ControlUtils::[*],
ControlSwitchSprite::[*],
ActionManagerEx::[initWithDictionary],
ActionNode::[initWithDictionary],
ActionObject::[initWithDictionary],
Manifest::[getAssets],
AssetsManagerEx::[getFailedAssets updateAssets]
@@ -71,4 +64,4 @@ base_classes_to_skip = Ref
# Set is special and we will use a hand-written constructor
abstract_classes =
classes_need_extend = ScrollView TableView TableViewCell ControlButton ControlStepper ControlSwitch ControlSlider ControlColourPicker ControlPotentiometer
classes_need_extend =