2016-03-20 21:53:44 +08:00
|
|
|
#include "editor-support/cocosbuilder/CCScrollViewLoader.h"
|
2012-06-18 19:00:26 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
using namespace cocos2d;
|
|
|
|
using namespace cocos2d::extension;
|
2012-06-18 19:00:26 +08:00
|
|
|
|
2012-06-19 04:59:45 +08:00
|
|
|
#define PROPERTY_CONTAINER "container"
|
|
|
|
#define PROPERTY_DIRECTION "direction"
|
|
|
|
#define PROPERTY_CLIPSTOBOUNDS "clipsToBounds"
|
|
|
|
#define PROPERTY_BOUNCES "bounces"
|
|
|
|
#define PROPERTY_SCALE "scale"
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocosbuilder {
|
2012-07-19 17:22:36 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void ScrollViewLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((ScrollView *)pNode)->setViewSize(pSize);
|
2012-09-09 22:34:32 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader);
|
2012-09-09 22:34:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void ScrollViewLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_CLIPSTOBOUNDS) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((ScrollView *)pNode)->setClippingToBounds(pCheck);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_BOUNCES) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((ScrollView *)pNode)->setBounceable(pCheck);
|
2012-06-19 04:59:45 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader);
|
2012-06-19 04:59:45 +08:00
|
|
|
}
|
2012-06-18 19:00:26 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void ScrollViewLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_CONTAINER) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((ScrollView *)pNode)->setContainer(pCCBFileNode);
|
|
|
|
((ScrollView *)pNode)->updateInset();
|
2012-06-19 04:59:45 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, ccbReader);
|
2012-06-19 04:59:45 +08:00
|
|
|
}
|
2012-06-18 19:00:26 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void ScrollViewLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((ScrollView *)pNode)->setScale(pFloat);
|
2012-06-19 04:59:45 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, ccbReader);
|
2012-06-19 04:59:45 +08:00
|
|
|
}
|
2012-06-18 19:00:26 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void ScrollViewLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_DIRECTION) == 0) {
|
2013-07-26 22:55:41 +08:00
|
|
|
((ScrollView *)pNode)->setDirection(ScrollView::Direction(pIntegerLabeled));
|
2012-06-19 04:59:45 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, ccbReader);
|
2012-06-19 04:59:45 +08:00
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:45:24 +08:00
|
|
|
}
|