mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6685 from andyque/refactor5118
closed #5118, remove WidgetType and refactor LayoutType to Type
This commit is contained in:
commit
ccb55448da
|
@ -218,6 +218,30 @@ Widget* GUIReader::widgetFromJsonFile(const char *fileName)
|
|||
}
|
||||
|
||||
|
||||
void WidgetPropertiesReader::setAnchorPointForWidget(cocos2d::ui::Widget *widget, const rapidjson::Value &options)
|
||||
{
|
||||
bool isAnchorPointXExists = DICTOOL->checkObjectExist_json(options, "anchorPointX");
|
||||
float anchorPointXInFile;
|
||||
if (isAnchorPointXExists) {
|
||||
anchorPointXInFile = DICTOOL->getFloatValue_json(options, "anchorPointX");
|
||||
}else{
|
||||
anchorPointXInFile = widget->getAnchorPoint().x;
|
||||
}
|
||||
|
||||
bool isAnchorPointYExists = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float anchorPointYInFile;
|
||||
if (isAnchorPointYExists) {
|
||||
anchorPointYInFile = DICTOOL->getFloatValue_json(options, "anchorPointY");
|
||||
}
|
||||
else{
|
||||
anchorPointYInFile = widget->getAnchorPoint().y;
|
||||
}
|
||||
|
||||
if (isAnchorPointXExists || isAnchorPointYExists) {
|
||||
widget->setAnchorPoint(Vector2(anchorPointXInFile, anchorPointYInFile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, const char* fullPath, const char* fileName)
|
||||
{
|
||||
|
@ -411,11 +435,9 @@ void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget
|
|||
int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255;
|
||||
int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255;
|
||||
widget->setColor(Color3B(colorR, colorG, colorB));
|
||||
bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX");
|
||||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
|
||||
this->setAnchorPointForWidget(widget, options);
|
||||
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
|
@ -1233,16 +1255,16 @@ void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(Widget
|
|||
int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255;
|
||||
int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255;
|
||||
widget->setColor(Color3B(colorR, colorG, colorB));
|
||||
bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX");
|
||||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
|
||||
this->setAnchorPointForWidget(widget, options);
|
||||
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
widget->setFlippedY(flipY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(Widget*widget,const rapidjson::Value& options)
|
||||
{
|
||||
|
@ -1694,7 +1716,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg
|
|||
float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight");
|
||||
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
|
||||
}
|
||||
panel->setLayoutType((Layout::LayoutType)DICTOOL->getIntValue_json(options, "layoutType"));
|
||||
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, "layoutType"));
|
||||
setColorPropsForWidgetFromJsonDictionary(widget,options);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,9 @@ public:
|
|||
virtual void setPropsForAllCustomWidgetFromJsonDictionary(const std::string& classType,
|
||||
cocos2d::ui::Widget* widget,
|
||||
const rapidjson::Value& customOptions) = 0;
|
||||
protected:
|
||||
void setAnchorPointForWidget(cocos2d::ui::Widget* widget, const rapidjson::Value&options);
|
||||
|
||||
protected:
|
||||
std::string m_strFilePath;
|
||||
};
|
||||
|
@ -160,6 +163,8 @@ public:
|
|||
virtual void setPropsForAllCustomWidgetFromJsonDictionary(const std::string& classType,
|
||||
cocos2d::ui::Widget* widget,
|
||||
const rapidjson::Value& customOptions);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace cocostudio
|
|||
float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight");
|
||||
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
|
||||
}
|
||||
panel->setLayoutType((Layout::LayoutType)DICTOOL->getIntValue_json(options, "layoutType"));
|
||||
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, "layoutType"));
|
||||
|
||||
int bgimgcr = DICTOOL->getIntValue_json(options, "colorR");
|
||||
int bgimgcg = DICTOOL->getIntValue_json(options, "colorG");
|
||||
|
|
|
@ -162,11 +162,9 @@ namespace cocostudio
|
|||
int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255;
|
||||
int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255;
|
||||
widget->setColor(Color3B(colorR, colorG, colorB));
|
||||
bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX");
|
||||
float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f);
|
||||
widget->setAnchorPoint(Vector2(apxf, apyf));
|
||||
|
||||
this->setAnchorPointForWidget(widget, options);
|
||||
|
||||
bool flipX = DICTOOL->getBooleanValue_json(options, "flipX");
|
||||
bool flipY = DICTOOL->getBooleanValue_json(options, "flipY");
|
||||
widget->setFlippedX(flipX);
|
||||
|
@ -194,4 +192,31 @@ namespace cocostudio
|
|||
}
|
||||
return imageFileName_tp;
|
||||
}
|
||||
|
||||
void WidgetReader::setAnchorPointForWidget(cocos2d::ui::Widget *widget, const rapidjson::Value &options)
|
||||
{
|
||||
bool isAnchorPointXExists = DICTOOL->checkObjectExist_json(options, "anchorPointX");
|
||||
float anchorPointXInFile;
|
||||
if (isAnchorPointXExists) {
|
||||
anchorPointXInFile = DICTOOL->getFloatValue_json(options, "anchorPointX");
|
||||
}else{
|
||||
anchorPointXInFile = widget->getAnchorPoint().x;
|
||||
}
|
||||
|
||||
bool isAnchorPointYExists = DICTOOL->checkObjectExist_json(options, "anchorPointY");
|
||||
float anchorPointYInFile;
|
||||
if (isAnchorPointYExists) {
|
||||
anchorPointYInFile = DICTOOL->getFloatValue_json(options, "anchorPointY");
|
||||
}
|
||||
else{
|
||||
anchorPointYInFile = widget->getAnchorPoint().y;
|
||||
}
|
||||
|
||||
if (isAnchorPointXExists || isAnchorPointYExists) {
|
||||
widget->setAnchorPoint(Vector2(anchorPointXInFile, anchorPointYInFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ namespace cocostudio
|
|||
std::string getResourcePath(const rapidjson::Value& dict,
|
||||
const std::string& key,
|
||||
cocos2d::ui::Widget::TextureResType texType);
|
||||
void setAnchorPointForWidget(cocos2d::ui::Widget* widget, const rapidjson::Value&options);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#define DECLARE_CLASS_GUI_INFO \
|
||||
public: \
|
||||
static cocostudio::ObjectFactory::TInfo Type; \
|
||||
static cocostudio::ObjectFactory::TInfo __Type; \
|
||||
static cocos2d::Ref* createInstance(void); \
|
||||
|
||||
#define IMPLEMENT_CLASS_GUI_INFO(className) \
|
||||
|
@ -43,7 +43,7 @@
|
|||
{ \
|
||||
return className::create(); \
|
||||
} \
|
||||
cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
cocostudio::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \
|
||||
|
||||
#define CREATE_CLASS_GUI_INFO(className) \
|
||||
cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \
|
||||
|
@ -55,7 +55,7 @@
|
|||
|
||||
#define DECLARE_CLASS_WIDGET_READER_INFO \
|
||||
public: \
|
||||
static cocostudio::ObjectFactory::TInfo Type; \
|
||||
static cocostudio::ObjectFactory::TInfo __Type; \
|
||||
static cocos2d::Ref* createInstance(void); \
|
||||
|
||||
#define IMPLEMENT_CLASS_WIDGET_READER_INFO(className) \
|
||||
|
@ -63,7 +63,7 @@
|
|||
{ \
|
||||
return className::getInstance(); \
|
||||
} \
|
||||
cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
cocostudio::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \
|
||||
|
||||
#define CREATE_CLASS_WIDGET_READER_INFO(className) \
|
||||
cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \
|
||||
|
|
|
@ -37,17 +37,15 @@ CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType:
|
|||
CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget::TextureResType::LOCAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeWidget = Widget::Type::ELEMENT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeContainer = Widget::Type::CONTAINER;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NONE = Widget::BrightStyle::NONE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NORMAL = Widget::BrightStyle::NORMAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_HIGHLIGHT = Widget::BrightStyle::HIGHLIGHT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_STENCIL = Layout::ClippingType::STENCIL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_SCISSOR = Layout::ClippingType::SCISSOR;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_ABSOLUTE = Layout::LayoutType::ABSOLUTE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_VERTICAL = Layout::LayoutType::VERTICAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_HORIZONTAL = Layout::LayoutType::HORIZONTAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_RELATIVE = Layout::LayoutType::VERTICAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::Type LAYOUT_ABSOLUTE = Layout::Type::ABSOLUTE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::Type LAYOUT_LINEAR_VERTICAL = Layout::Type::VERTICAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::Type LAYOUT_LINEAR_HORIZONTAL = Layout::Type::HORIZONTAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::Type LAYOUT_RELATIVE = Layout::Type::VERTICAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_NONE = Layout::BackGroundColorType::NONE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_SOLID = Layout::BackGroundColorType::SOLID;
|
||||
CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_GRADIENT
|
||||
|
@ -137,10 +135,9 @@ CC_DEPRECATED_ATTRIBUTE const ScrollView::Direction SCROLLVIEW_DIR_BOTH = Scrol
|
|||
CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layout::Type LayoutType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layout::BackGroundColorType LayoutBackGroundColorType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayoutParameter::Type LayoutParameterType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LinearLayoutParameter::LinearGravity LinearGravity;
|
||||
|
|
|
@ -64,7 +64,7 @@ bool HBox::init()
|
|||
{
|
||||
if (Layout::init())
|
||||
{
|
||||
setLayoutType(LayoutType::HORIZONTAL);
|
||||
setLayoutType(Layout::Type::HORIZONTAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -582,7 +582,7 @@ _gEndColor(Color3B::WHITE),
|
|||
_alongVector(Vector2(0.0f, -1.0f)),
|
||||
_cOpacity(255),
|
||||
_backGroundImageTextureSize(Size::ZERO),
|
||||
_layoutType(LayoutType::ABSOLUTE),
|
||||
_layoutType(Type::ABSOLUTE),
|
||||
_clippingType(ClippingType::STENCIL),
|
||||
_clippingStencil(nullptr),
|
||||
_scissorRectDirty(false),
|
||||
|
@ -608,8 +608,8 @@ _curLayoutExecutant(nullptr),
|
|||
_passFocusToChild(true),
|
||||
_loopFocus(false)
|
||||
{
|
||||
_widgetType = Widget::Type::CONTAINER;
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
this->setAnchorPoint(Vector2::ZERO);
|
||||
}
|
||||
|
||||
Layout::~Layout()
|
||||
|
@ -1175,10 +1175,10 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
|||
}
|
||||
switch (_layoutType)
|
||||
{
|
||||
case LayoutType::ABSOLUTE:
|
||||
case Type::ABSOLUTE:
|
||||
break;
|
||||
case LayoutType::HORIZONTAL:
|
||||
case LayoutType::VERTICAL:
|
||||
case Type::HORIZONTAL:
|
||||
case Type::VERTICAL:
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
if (!layoutParameter)
|
||||
|
@ -1187,7 +1187,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case LayoutType::RELATIVE:
|
||||
case Type::RELATIVE:
|
||||
{
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::RELATIVE));
|
||||
if (!layoutParameter)
|
||||
|
@ -1424,7 +1424,7 @@ const Size& Layout::getBackGroundImageTextureSize() const
|
|||
return _backGroundImageTextureSize;
|
||||
}
|
||||
|
||||
void Layout::setLayoutType(LayoutType type)
|
||||
void Layout::setLayoutType(Type type)
|
||||
{
|
||||
_layoutType = type;
|
||||
CC_SAFE_RELEASE_NULL(_curLayoutExecutant);
|
||||
|
@ -1446,13 +1446,13 @@ LayoutExecutant* Layout::createCurrentLayoutExecutant()
|
|||
LayoutExecutant* exe = nullptr;
|
||||
switch (_layoutType)
|
||||
{
|
||||
case LayoutType::VERTICAL:
|
||||
case Type::VERTICAL:
|
||||
exe = LinearVerticalLayoutExecutant::create();
|
||||
break;
|
||||
case LayoutType::HORIZONTAL:
|
||||
case Type::HORIZONTAL:
|
||||
exe = LinearHorizontalLayoutExecutant::create();
|
||||
break;
|
||||
case LayoutType::RELATIVE:
|
||||
case Type::RELATIVE:
|
||||
exe = RelativeLayoutExecutant::create();
|
||||
break;
|
||||
default:
|
||||
|
@ -1461,7 +1461,7 @@ LayoutExecutant* Layout::createCurrentLayoutExecutant()
|
|||
return exe;
|
||||
}
|
||||
|
||||
Layout::LayoutType Layout::getLayoutType() const
|
||||
Layout::Type Layout::getLayoutType() const
|
||||
{
|
||||
return _layoutType;
|
||||
}
|
||||
|
@ -1564,12 +1564,12 @@ Size Layout::getLayoutContentSize()const
|
|||
}
|
||||
|
||||
//substract extra size
|
||||
LayoutType type = this->getLayoutType();
|
||||
if (type == LayoutType::HORIZONTAL)
|
||||
Type type = this->getLayoutType();
|
||||
if (type == Type::HORIZONTAL)
|
||||
{
|
||||
layoutSize = layoutSize - Size(0, layoutSize.height/widgetCount * (widgetCount-1));
|
||||
}
|
||||
if (type == LayoutType::VERTICAL)
|
||||
if (type == Type::VERTICAL)
|
||||
{
|
||||
layoutSize = layoutSize - Size(layoutSize.width/widgetCount * (widgetCount-1), 0);
|
||||
}
|
||||
|
@ -2186,7 +2186,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction)
|
|||
|
||||
auto container = parent->getChildren();
|
||||
ssize_t index = container.getIndex(widget);
|
||||
if (parent->getLayoutType() == LayoutType::HORIZONTAL)
|
||||
if (parent->getLayoutType() == Type::HORIZONTAL)
|
||||
{
|
||||
if (direction == FocusDirection::LEFT) {
|
||||
if (index == 0)
|
||||
|
@ -2218,7 +2218,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction)
|
|||
return isLastWidgetInContainer(parent, direction);
|
||||
}
|
||||
}
|
||||
else if(parent->getLayoutType() == LayoutType::VERTICAL)
|
||||
else if(parent->getLayoutType() == Type::VERTICAL)
|
||||
{
|
||||
if (direction == FocusDirection::UP)
|
||||
{
|
||||
|
@ -2272,7 +2272,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di
|
|||
if (parent->isLoopFocus())
|
||||
{
|
||||
auto layoutType = parent->getLayoutType();
|
||||
if (layoutType == LayoutType::HORIZONTAL)
|
||||
if (layoutType == Type::HORIZONTAL)
|
||||
{
|
||||
if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT)
|
||||
{
|
||||
|
@ -2283,7 +2283,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di
|
|||
return isWidgetAncestorSupportLoopFocus(parent, direction);
|
||||
}
|
||||
}
|
||||
if (layoutType == LayoutType::VERTICAL)
|
||||
if (layoutType == Type::VERTICAL)
|
||||
{
|
||||
if (direction == FocusDirection::DOWN || direction == FocusDirection::UP)
|
||||
{
|
||||
|
@ -2334,7 +2334,7 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current)
|
|||
}
|
||||
else if(current->isFocused() || !current->isFocusEnabled())
|
||||
{
|
||||
if (_layoutType == LayoutType::HORIZONTAL)
|
||||
if (_layoutType == Type::HORIZONTAL)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
|
@ -2371,7 +2371,7 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current)
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (_layoutType == LayoutType::VERTICAL)
|
||||
else if (_layoutType == Type::VERTICAL)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
|
|
|
@ -43,13 +43,7 @@ class Layout : public Widget
|
|||
DECLARE_CLASS_GUI_INFO
|
||||
|
||||
public:
|
||||
enum class ClippingType
|
||||
{
|
||||
STENCIL,
|
||||
SCISSOR
|
||||
};
|
||||
|
||||
enum class LayoutType
|
||||
enum class Type
|
||||
{
|
||||
ABSOLUTE,
|
||||
VERTICAL,
|
||||
|
@ -57,12 +51,19 @@ public:
|
|||
RELATIVE
|
||||
};
|
||||
|
||||
enum class ClippingType
|
||||
{
|
||||
STENCIL,
|
||||
SCISSOR
|
||||
};
|
||||
|
||||
enum class BackGroundColorType
|
||||
{
|
||||
NONE,
|
||||
SOLID,
|
||||
GRADIENT
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
|
@ -77,7 +78,7 @@ public:
|
|||
* Allocates and initializes a layout.
|
||||
*/
|
||||
static Layout* create();
|
||||
|
||||
|
||||
//background
|
||||
/**
|
||||
* Sets a background image for layout
|
||||
|
@ -201,23 +202,10 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
/**
|
||||
* Sets LayoutType.
|
||||
*
|
||||
* @see LayoutType
|
||||
*
|
||||
* @param LayoutType
|
||||
*/
|
||||
virtual void setLayoutType(LayoutType type);
|
||||
|
||||
virtual void setLayoutType(Type type);
|
||||
|
||||
/**
|
||||
* Gets LayoutType.
|
||||
*
|
||||
* @see LayoutType
|
||||
*
|
||||
* @return LayoutType
|
||||
*/
|
||||
virtual LayoutType getLayoutType() const;
|
||||
virtual Type getLayoutType() const;
|
||||
|
||||
virtual void addChild(Node * child) override;
|
||||
/**
|
||||
|
@ -460,7 +448,7 @@ protected:
|
|||
Vector2 _alongVector;
|
||||
GLubyte _cOpacity;
|
||||
Size _backGroundImageTextureSize;
|
||||
LayoutType _layoutType;
|
||||
Type _layoutType;
|
||||
ClippingType _clippingType;
|
||||
DrawNode* _clippingStencil;
|
||||
bool _scissorRectDirty;
|
||||
|
|
|
@ -70,7 +70,7 @@ const Margin MarginZero = Margin();
|
|||
class LayoutParameter : public Ref
|
||||
{
|
||||
public:
|
||||
enum class Type : int
|
||||
enum class Type
|
||||
{
|
||||
NONE = 0,
|
||||
LINEAR,
|
||||
|
|
|
@ -69,7 +69,7 @@ bool ListView::init()
|
|||
{
|
||||
if (ScrollView::init())
|
||||
{
|
||||
setLayoutType(LayoutType::VERTICAL);
|
||||
setLayoutType(Type::VERTICAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -362,10 +362,10 @@ void ListView::setDirection(Direction dir)
|
|||
switch (dir)
|
||||
{
|
||||
case Direction::VERTICAL:
|
||||
setLayoutType(LayoutType::VERTICAL);
|
||||
setLayoutType(Type::VERTICAL);
|
||||
break;
|
||||
case Direction::HORIZONTAL:
|
||||
setLayoutType(LayoutType::HORIZONTAL);
|
||||
setLayoutType(Type::HORIZONTAL);
|
||||
break;
|
||||
case Direction::BOTH:
|
||||
return;
|
||||
|
|
|
@ -131,10 +131,7 @@ void PageView::addPage(Layout* page)
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (page->getWidgetType() != Widget::Type::CONTAINER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pages.contains(page))
|
||||
{
|
||||
return;
|
||||
|
@ -162,10 +159,7 @@ void PageView::insertPage(Layout* page, int idx)
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (page->getWidgetType() != Widget::Type::CONTAINER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pages.contains(page))
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
*
|
||||
* @param LayoutType
|
||||
*/
|
||||
virtual void setLayoutType(LayoutType type) override{};
|
||||
virtual void setLayoutType(Type type) override{};
|
||||
|
||||
/**
|
||||
* Gets LayoutType.
|
||||
|
@ -161,7 +161,7 @@ public:
|
|||
*
|
||||
* @return LayoutType
|
||||
*/
|
||||
virtual LayoutType getLayoutType() const override{return LayoutType::ABSOLUTE;};
|
||||
virtual Type getLayoutType() const override{return Type::ABSOLUTE;};
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
|
|
|
@ -64,7 +64,7 @@ bool RelativeBox::init()
|
|||
{
|
||||
if (Layout::init())
|
||||
{
|
||||
setLayoutType(LayoutType::RELATIVE);
|
||||
setLayoutType(Layout::Type::RELATIVE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1695,12 +1695,12 @@ Layout* ScrollView::getInnerContainer()
|
|||
return _innerContainer;
|
||||
}
|
||||
|
||||
void ScrollView::setLayoutType(LayoutType type)
|
||||
void ScrollView::setLayoutType(Type type)
|
||||
{
|
||||
_innerContainer->setLayoutType(type);
|
||||
}
|
||||
|
||||
Layout::LayoutType ScrollView::getLayoutType() const
|
||||
Layout::Type ScrollView::getLayoutType() const
|
||||
{
|
||||
return _innerContainer->getLayoutType();
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ public:
|
|||
*
|
||||
* @param LayoutType
|
||||
*/
|
||||
virtual void setLayoutType(LayoutType type) override;
|
||||
virtual void setLayoutType(Type type) override;
|
||||
|
||||
/**
|
||||
* Gets LayoutType.
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
*
|
||||
* @return LayoutType
|
||||
*/
|
||||
virtual LayoutType getLayoutType() const override;
|
||||
virtual Type getLayoutType() const override;
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
|
|
|
@ -64,7 +64,7 @@ bool VBox::init()
|
|||
{
|
||||
if (Layout::init())
|
||||
{
|
||||
setLayoutType(LayoutType::VERTICAL);
|
||||
setLayoutType(Layout::Type::VERTICAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -46,7 +46,6 @@ _touchEndPos(Vector2::ZERO),
|
|||
_touchEventListener(nullptr),
|
||||
_touchEventSelector(nullptr),
|
||||
_name("default"),
|
||||
_widgetType(Type::ELEMENT),
|
||||
_actionTag(0),
|
||||
_size(Size::ZERO),
|
||||
_customSize(Size::ZERO),
|
||||
|
@ -68,6 +67,7 @@ _focusEnabled(true)
|
|||
{
|
||||
onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this);
|
||||
onNextFocusedWidget = nullptr;
|
||||
this->setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
|
@ -834,10 +834,6 @@ const std::string& Widget::getName() const
|
|||
return _name;
|
||||
}
|
||||
|
||||
Widget::Type Widget::getWidgetType() const
|
||||
{
|
||||
return _widgetType;
|
||||
}
|
||||
|
||||
void Widget::setLayoutParameter(LayoutParameter *parameter)
|
||||
{
|
||||
|
|
|
@ -94,12 +94,6 @@ public:
|
|||
PLIST = 1
|
||||
};
|
||||
|
||||
enum class Type
|
||||
{
|
||||
ELEMENT,
|
||||
CONTAINER
|
||||
};
|
||||
|
||||
enum class BrightStyle
|
||||
{
|
||||
NONE = -1,
|
||||
|
@ -405,15 +399,6 @@ public:
|
|||
*/
|
||||
const std::string& getName() const;
|
||||
|
||||
/**
|
||||
* Returns a type that is widget's type
|
||||
*
|
||||
* @see WidgetType
|
||||
*
|
||||
* @return A WidgetType
|
||||
*/
|
||||
Type getWidgetType() const;
|
||||
|
||||
/**
|
||||
* Changes the size that is widget's size
|
||||
*
|
||||
|
@ -679,8 +664,7 @@ protected:
|
|||
ccWidgetTouchCallback _touchEventCallback;
|
||||
|
||||
std::string _name;
|
||||
Type _widgetType;
|
||||
int _actionTag;
|
||||
int _actionTag;
|
||||
Size _size;
|
||||
Size _customSize;
|
||||
bool _ignoreSize;
|
||||
|
|
Loading…
Reference in New Issue