mirror of https://github.com/axmolengine/axmol.git
add const to ui framework methods
This commit is contained in:
parent
a01315e2f5
commit
e32a637bf5
|
@ -932,12 +932,12 @@ void Layout::requestDoLayout()
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Size Layout::getLayoutContentSize()
|
const Size Layout::getLayoutContentSize()const
|
||||||
{
|
{
|
||||||
return this->getSize();
|
return this->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vector<Node*>& Layout::getLayoutElements()
|
const Vector<Node*>& Layout::getLayoutElements()const
|
||||||
{
|
{
|
||||||
return this->getChildren();
|
return this->getChildren();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
virtual ~LayoutProtocol(){}
|
virtual ~LayoutProtocol(){}
|
||||||
|
|
||||||
virtual LayoutExecutant* createLayoutExecutant() = 0;
|
virtual LayoutExecutant* createLayoutExecutant() = 0;
|
||||||
virtual const Size getLayoutContentSize() = 0;
|
virtual const Size getLayoutContentSize()const = 0;
|
||||||
virtual const Vector<Node*>& getLayoutElements() = 0;
|
virtual const Vector<Node*>& getLayoutElements()const = 0;
|
||||||
virtual void doLayout() = 0;
|
virtual void doLayout() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -329,8 +329,8 @@ protected:
|
||||||
|
|
||||||
virtual void doLayout()override;
|
virtual void doLayout()override;
|
||||||
virtual LayoutExecutant* createLayoutExecutant()override;
|
virtual LayoutExecutant* createLayoutExecutant()override;
|
||||||
virtual const Size getLayoutContentSize()override;
|
virtual const Size getLayoutContentSize()const override;
|
||||||
virtual const Vector<Node*>& getLayoutElements() override;
|
virtual const Vector<Node*>& getLayoutElements()const override;
|
||||||
|
|
||||||
//clipping
|
//clipping
|
||||||
void onBeforeVisitStencil();
|
void onBeforeVisitStencil();
|
||||||
|
|
|
@ -136,7 +136,7 @@ public:
|
||||||
LayoutParameterProtocol(){}
|
LayoutParameterProtocol(){}
|
||||||
virtual ~LayoutParameterProtocol(){}
|
virtual ~LayoutParameterProtocol(){}
|
||||||
|
|
||||||
virtual LayoutParameter* getLayoutParameter() = 0;
|
virtual LayoutParameter* getLayoutParameter() const= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ Node* ScrollView::getChildByTag(int tag) const
|
||||||
return _innerContainer->getChildByTag(tag);
|
return _innerContainer->getChildByTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* ScrollView::getChildByName(const std::string& name)
|
Widget* ScrollView::getChildByName(const std::string& name)const
|
||||||
{
|
{
|
||||||
return _innerContainer->getChildByName(name);
|
return _innerContainer->getChildByName(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ public:
|
||||||
virtual const Vector<Node*>& getChildren() const override;
|
virtual const Vector<Node*>& getChildren() const override;
|
||||||
virtual ssize_t getChildrenCount() const override;
|
virtual ssize_t getChildrenCount() const override;
|
||||||
virtual Node * getChildByTag(int tag) const override;
|
virtual Node * getChildByTag(int tag) const override;
|
||||||
virtual Widget* getChildByName(const std::string& name) override;
|
virtual Widget* getChildByName(const std::string& name)const override;
|
||||||
|
|
||||||
//handle touch event
|
//handle touch event
|
||||||
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
|
||||||
|
|
|
@ -244,7 +244,7 @@ void Widget::setEnabled(bool enabled)
|
||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* Widget::getChildByName(const std::string& name)
|
Widget* Widget::getChildByName(const std::string& name)const
|
||||||
{
|
{
|
||||||
for (auto& child : _children)
|
for (auto& child : _children)
|
||||||
{
|
{
|
||||||
|
@ -468,7 +468,7 @@ const Vec2& Widget::getSizePercent() const
|
||||||
return _sizePercent;
|
return _sizePercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 Widget::getWorldPosition()
|
Vec2 Widget::getWorldPosition()const
|
||||||
{
|
{
|
||||||
return convertToWorldSpace(Vec2(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height));
|
return convertToWorldSpace(Vec2(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height));
|
||||||
}
|
}
|
||||||
|
@ -899,8 +899,7 @@ void Widget::setPositionPercent(const Vec2 &percent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vec2& Widget::getPositionPercent()
|
const Vec2& Widget::getPositionPercent()const{
|
||||||
{
|
|
||||||
return _positionPercent;
|
return _positionPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,17 +943,17 @@ float Widget::getTopBoundary() const
|
||||||
return getBottomBoundary() + _size.height;
|
return getBottomBoundary() + _size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vec2& Widget::getTouchStartPos()
|
const Vec2& Widget::getTouchStartPos()const
|
||||||
{
|
{
|
||||||
return _touchStartPos;
|
return _touchStartPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vec2& Widget::getTouchMovePos()
|
const Vec2& Widget::getTouchMovePos()const
|
||||||
{
|
{
|
||||||
return _touchMovePos;
|
return _touchMovePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vec2& Widget::getTouchEndPos()
|
const Vec2& Widget::getTouchEndPos()const
|
||||||
{
|
{
|
||||||
return _touchEndPos;
|
return _touchEndPos;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +979,7 @@ void Widget::setLayoutParameter(LayoutParameter *parameter)
|
||||||
_layoutParameterType = parameter->getLayoutType();
|
_layoutParameterType = parameter->getLayoutType();
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutParameter* Widget::getLayoutParameter()
|
LayoutParameter* Widget::getLayoutParameter()const
|
||||||
{
|
{
|
||||||
return dynamic_cast<LayoutParameter*>(_layoutParameterDictionary.at((int)_layoutParameterType));
|
return dynamic_cast<LayoutParameter*>(_layoutParameterDictionary.at((int)_layoutParameterType));
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1117,7 @@ void Widget::setActionTag(int tag)
|
||||||
_actionTag = tag;
|
_actionTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Widget::getActionTag()
|
int Widget::getActionTag()const
|
||||||
{
|
{
|
||||||
return _actionTag;
|
return _actionTag;
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1136,7 @@ void Widget::setFocused(bool focus)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::isFocused()
|
bool Widget::isFocused()const
|
||||||
{
|
{
|
||||||
return _focused;
|
return _focused;
|
||||||
}
|
}
|
||||||
|
@ -1147,7 +1146,7 @@ void Widget::setFocusEnabled(bool enable)
|
||||||
_focusEnabled = enable;
|
_focusEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::isFocusEnabled()
|
bool Widget::isFocusEnabled()const
|
||||||
{
|
{
|
||||||
return _focusEnabled;
|
return _focusEnabled;
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1239,7 @@ void Widget::onFocusChange(Widget* widgetLostFocus, Widget* widgetGetFocus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* Widget::getCurrentFocusedWidget()
|
Widget* Widget::getCurrentFocusedWidget()const
|
||||||
{
|
{
|
||||||
return _focusedWidget;
|
return _focusedWidget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return a Widget object whose name equals to the input parameter
|
* @return a Widget object whose name equals to the input parameter
|
||||||
*/
|
*/
|
||||||
virtual Widget* getChildByName(const std::string& name);
|
virtual Widget* getChildByName(const std::string& name) const;
|
||||||
|
|
||||||
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The percent (x,y) of the widget in OpenGL coordinates
|
* @return The percent (x,y) of the widget in OpenGL coordinates
|
||||||
*/
|
*/
|
||||||
const Vec2& getPositionPercent();
|
const Vec2& getPositionPercent()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the position type of the widget
|
* Changes the position type of the widget
|
||||||
|
@ -311,7 +311,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return true if the widget is flipped horizaontally, false otherwise.
|
* @return true if the widget is flipped horizaontally, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool isFlippedX(){return _flippedX;};
|
virtual bool isFlippedX()const{return _flippedX;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the widget should be flipped vertically or not.
|
* Sets whether the widget should be flipped vertically or not.
|
||||||
|
@ -330,7 +330,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return true if the widget is flipped vertically, flase otherwise.
|
* @return true if the widget is flipped vertically, flase otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool isFlippedY(){return _flippedY;};
|
virtual bool isFlippedY()const{return _flippedY;};
|
||||||
|
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void setColor(const Color3B& color) override;
|
||||||
|
|
||||||
|
@ -363,21 +363,21 @@ public:
|
||||||
*
|
*
|
||||||
* @return the touch began point.
|
* @return the touch began point.
|
||||||
*/
|
*/
|
||||||
const Vec2& getTouchStartPos();
|
const Vec2& getTouchStartPos()const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets the touch move point of widget when widget is selected.
|
* Gets the touch move point of widget when widget is selected.
|
||||||
*
|
*
|
||||||
* @return the touch move point.
|
* @return the touch move point.
|
||||||
*/
|
*/
|
||||||
const Vec2& getTouchMovePos();
|
const Vec2& getTouchMovePos()const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets the touch end point of widget when widget is selected.
|
* Gets the touch end point of widget when widget is selected.
|
||||||
*
|
*
|
||||||
* @return the touch end point.
|
* @return the touch end point.
|
||||||
*/
|
*/
|
||||||
const Vec2& getTouchEndPos();
|
const Vec2& getTouchEndPos()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the name that is used to identify the widget easily.
|
* Changes the name that is used to identify the widget easily.
|
||||||
|
@ -487,7 +487,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return LayoutParameter
|
* @return LayoutParameter
|
||||||
*/
|
*/
|
||||||
LayoutParameter* getLayoutParameter() override;
|
LayoutParameter* getLayoutParameter()const override;
|
||||||
CC_DEPRECATED_ATTRIBUTE LayoutParameter* getLayoutParameter(LayoutParameter::Type type);
|
CC_DEPRECATED_ATTRIBUTE LayoutParameter* getLayoutParameter(LayoutParameter::Type type);
|
||||||
|
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return world position of widget.
|
* @return world position of widget.
|
||||||
*/
|
*/
|
||||||
Vec2 getWorldPosition();
|
Vec2 getWorldPosition()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Virtual Renderer of widget.
|
* Gets the Virtual Renderer of widget.
|
||||||
|
@ -547,12 +547,12 @@ public:
|
||||||
|
|
||||||
/*temp action*/
|
/*temp action*/
|
||||||
void setActionTag(int tag);
|
void setActionTag(int tag);
|
||||||
int getActionTag();
|
int getActionTag()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@return whether the widget is focused or not
|
*@return whether the widget is focused or not
|
||||||
*/
|
*/
|
||||||
bool isFocused();
|
bool isFocused()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@param focus pass true to let the widget get focus or pass false to let the widget lose focus
|
*@param focus pass true to let the widget get focus or pass false to let the widget lose focus
|
||||||
|
@ -563,7 +563,7 @@ public:
|
||||||
/**
|
/**
|
||||||
*@return true represent the widget could accept focus, false represent the widget couldn't accept focus
|
*@return true represent the widget could accept focus, false represent the widget couldn't accept focus
|
||||||
*/
|
*/
|
||||||
bool isFocusEnabled();
|
bool isFocusEnabled()const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@param enable pass true/false to enable/disable the focus ability of a widget
|
*@param enable pass true/false to enable/disable the focus ability of a widget
|
||||||
|
@ -595,7 +595,7 @@ public:
|
||||||
return getCurrentFocusedWidget();
|
return getCurrentFocusedWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* getCurrentFocusedWidget();
|
Widget* getCurrentFocusedWidget()const;
|
||||||
static void enableDpadNavigation(bool enable);
|
static void enableDpadNavigation(bool enable);
|
||||||
|
|
||||||
std::function<void(Widget*,Widget*)> onFocusChanged;
|
std::function<void(Widget*,Widget*)> onFocusChanged;
|
||||||
|
|
Loading…
Reference in New Issue