diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index ded60801cd..65906378f3 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -465,7 +465,7 @@ void Layout::setStencilClippingSize(const Size &size) } } -const Rect& Layout::getClippingRect() +const Rect& Layout::getClippingRect() { if (_clippingRectDirty) { @@ -932,12 +932,12 @@ void Layout::requestDoLayout() _doLayoutDirty = true; } -const Size Layout::getLayoutContentSize() +const Size Layout::getLayoutContentSize()const { return this->getSize(); } -const Vector& Layout::getLayoutElements() +const Vector& Layout::getLayoutElements()const { return this->getChildren(); } diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 94f1bf6c10..8f220ffb79 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -40,8 +40,8 @@ public: virtual ~LayoutProtocol(){} virtual LayoutExecutant* createLayoutExecutant() = 0; - virtual const Size getLayoutContentSize() = 0; - virtual const Vector& getLayoutElements() = 0; + virtual const Size getLayoutContentSize()const = 0; + virtual const Vector& getLayoutElements()const = 0; virtual void doLayout() = 0; }; @@ -329,8 +329,8 @@ protected: virtual void doLayout()override; virtual LayoutExecutant* createLayoutExecutant()override; - virtual const Size getLayoutContentSize()override; - virtual const Vector& getLayoutElements() override; + virtual const Size getLayoutContentSize()const override; + virtual const Vector& getLayoutElements()const override; //clipping void onBeforeVisitStencil(); diff --git a/cocos/ui/UILayoutParameter.h b/cocos/ui/UILayoutParameter.h index 2760e0208b..2308799c0b 100644 --- a/cocos/ui/UILayoutParameter.h +++ b/cocos/ui/UILayoutParameter.h @@ -136,7 +136,7 @@ public: LayoutParameterProtocol(){} virtual ~LayoutParameterProtocol(){} - virtual LayoutParameter* getLayoutParameter() = 0; + virtual LayoutParameter* getLayoutParameter() const= 0; }; diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 23b8ebb34c..b560a7d14d 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -307,7 +307,7 @@ Node* ScrollView::getChildByTag(int tag) const return _innerContainer->getChildByTag(tag); } -Widget* ScrollView::getChildByName(const std::string& name) +Widget* ScrollView::getChildByName(const std::string& name)const { return _innerContainer->getChildByName(name); } diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index c2daeb3de1..15d4c46ec9 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -274,7 +274,7 @@ public: virtual const Vector& getChildren() const override; virtual ssize_t getChildrenCount() 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 virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index b1258e77a7..38c3b61770 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -244,7 +244,7 @@ void Widget::setEnabled(bool enabled) _enabled = enabled; } -Widget* Widget::getChildByName(const std::string& name) +Widget* Widget::getChildByName(const std::string& name)const { for (auto& child : _children) { @@ -468,7 +468,7 @@ const Vec2& Widget::getSizePercent() const return _sizePercent; } -Vec2 Widget::getWorldPosition() +Vec2 Widget::getWorldPosition()const { 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; } @@ -944,17 +943,17 @@ float Widget::getTopBoundary() const return getBottomBoundary() + _size.height; } -const Vec2& Widget::getTouchStartPos() +const Vec2& Widget::getTouchStartPos()const { return _touchStartPos; } -const Vec2& Widget::getTouchMovePos() +const Vec2& Widget::getTouchMovePos()const { return _touchMovePos; } -const Vec2& Widget::getTouchEndPos() +const Vec2& Widget::getTouchEndPos()const { return _touchEndPos; } @@ -980,7 +979,7 @@ void Widget::setLayoutParameter(LayoutParameter *parameter) _layoutParameterType = parameter->getLayoutType(); } -LayoutParameter* Widget::getLayoutParameter() +LayoutParameter* Widget::getLayoutParameter()const { return dynamic_cast(_layoutParameterDictionary.at((int)_layoutParameterType)); } @@ -1118,7 +1117,7 @@ void Widget::setActionTag(int tag) _actionTag = tag; } -int Widget::getActionTag() +int Widget::getActionTag()const { return _actionTag; } @@ -1137,7 +1136,7 @@ void Widget::setFocused(bool focus) } -bool Widget::isFocused() +bool Widget::isFocused()const { return _focused; } @@ -1147,7 +1146,7 @@ void Widget::setFocusEnabled(bool enable) _focusEnabled = enable; } -bool Widget::isFocusEnabled() +bool Widget::isFocusEnabled()const { return _focusEnabled; } @@ -1240,7 +1239,7 @@ void Widget::onFocusChange(Widget* widgetLostFocus, Widget* widgetGetFocus) } } -Widget* Widget::getCurrentFocusedWidget() +Widget* Widget::getCurrentFocusedWidget()const { return _focusedWidget; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index b730f12bd5..780b34ea1d 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -235,7 +235,7 @@ public: * * @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; @@ -274,7 +274,7 @@ public: * * @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 @@ -311,7 +311,7 @@ public: * * @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. @@ -330,7 +330,7 @@ public: * * @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; @@ -363,21 +363,21 @@ public: * * @return the touch began point. */ - const Vec2& getTouchStartPos(); + const Vec2& getTouchStartPos()const; /* * Gets the touch move point of widget when widget is selected. * * @return the touch move point. */ - const Vec2& getTouchMovePos(); + const Vec2& getTouchMovePos()const; /* * Gets the touch end point of widget when widget is selected. * * @return the touch end point. */ - const Vec2& getTouchEndPos(); + const Vec2& getTouchEndPos()const; /** * Changes the name that is used to identify the widget easily. @@ -487,7 +487,7 @@ public: * * @return LayoutParameter */ - LayoutParameter* getLayoutParameter() override; + LayoutParameter* getLayoutParameter()const override; CC_DEPRECATED_ATTRIBUTE LayoutParameter* getLayoutParameter(LayoutParameter::Type type); @@ -510,7 +510,7 @@ public: * * @return world position of widget. */ - Vec2 getWorldPosition(); + Vec2 getWorldPosition()const; /** * Gets the Virtual Renderer of widget. @@ -547,12 +547,12 @@ public: /*temp action*/ void setActionTag(int tag); - int getActionTag(); + int getActionTag()const; /** *@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 @@ -563,7 +563,7 @@ public: /** *@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 @@ -595,7 +595,7 @@ public: return getCurrentFocusedWidget(); } - Widget* getCurrentFocusedWidget(); + Widget* getCurrentFocusedWidget()const; static void enableDpadNavigation(bool enable); std::function onFocusChanged;