diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index ea892828c3..58b0303ca4 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -191,7 +191,7 @@ void Button::setScale9Enabled(bool able) setBright(_bright); } -bool Button::isScale9Enabled() +bool Button::isScale9Enabled()const { return _scale9Enabled; } @@ -374,7 +374,7 @@ void Button::setCapInsetsNormalRenderer(const Rect &capInsets) static_cast(_buttonNormalRenderer)->setCapInsets(capInsets); } -const Rect& Button::getCapInsetsNormalRenderer() +const Rect& Button::getCapInsetsNormalRenderer()const { return _capInsetsNormal; } @@ -389,7 +389,7 @@ void Button::setCapInsetsPressedRenderer(const Rect &capInsets) static_cast(_buttonClickedRenderer)->setCapInsets(capInsets); } -const Rect& Button::getCapInsetsPressedRenderer() +const Rect& Button::getCapInsetsPressedRenderer()const { return _capInsetsPressed; } @@ -404,7 +404,7 @@ void Button::setCapInsetsDisabledRenderer(const Rect &capInsets) static_cast(_buttonDisableRenderer)->setCapInsets(capInsets); } -const Rect& Button::getCapInsetsDisabledRenderer() +const Rect& Button::getCapInsetsDisabledRenderer()const { return _capInsetsDisabled; } diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index 3f37b4554a..18a1d5dd17 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -126,7 +126,7 @@ public: */ void setCapInsetsNormalRenderer(const Rect &capInsets); - const Rect& getCapInsetsNormalRenderer(); + const Rect& getCapInsetsNormalRenderer()const; /** * Sets capinsets for button, if button is using scale9 renderer. @@ -135,7 +135,7 @@ public: */ void setCapInsetsPressedRenderer(const Rect &capInsets); - const Rect& getCapInsetsPressedRenderer(); + const Rect& getCapInsetsPressedRenderer()const; /** * Sets capinsets for button, if button is using scale9 renderer. @@ -144,7 +144,7 @@ public: */ void setCapInsetsDisabledRenderer(const Rect &capInsets); - const Rect& getCapInsetsDisabledRenderer(); + const Rect& getCapInsetsDisabledRenderer()const; /** * Sets if button is using scale9 renderer. @@ -153,7 +153,7 @@ public: */ virtual void setScale9Enabled(bool able); - bool isScale9Enabled(); + bool isScale9Enabled()const; /** * Changes if button can be clicked zoom effect. diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index 75fd2edc1c..4a5d81e873 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -343,7 +343,7 @@ void CheckBox::setSelectedState(bool selected) _frontCrossRenderer->setVisible(_isSelected); } -bool CheckBox::getSelectedState() +bool CheckBox::getSelectedState()const { return _isSelected; } diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index 2e35ed7798..940c3acbbb 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -170,7 +170,7 @@ public: * * @return selected true that checkbox is selected, false otherwise. */ - bool getSelectedState(); + bool getSelectedState()const; //add a call back function would called when checkbox is selected or unselected. CC_DEPRECATED_ATTRIBUTE void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector); diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index d67fe503e3..f37997e1bf 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -230,7 +230,7 @@ void ImageView::setScale9Enabled(bool able) setCapInsets(_capInsets); } -bool ImageView::isScale9Enabled() +bool ImageView::isScale9Enabled()const { return _scale9Enabled; } @@ -254,7 +254,7 @@ void ImageView::setCapInsets(const Rect &capInsets) STATIC_CAST_SCALE9SPRITE->setCapInsets(capInsets); } -const Rect& ImageView::getCapInsets() +const Rect& ImageView::getCapInsets()const { return _capInsets; } diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 26ce344704..867d1c1394 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -88,7 +88,7 @@ public: */ void setScale9Enabled(bool able); - bool isScale9Enabled(); + bool isScale9Enabled()const; /** * Sets capinsets for imageview, if imageview is using scale9 renderer. @@ -97,7 +97,7 @@ public: */ void setCapInsets(const Rect &capInsets); - const Rect& getCapInsets(); + const Rect& getCapInsets()const; //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index ded60801cd..61fbf55179 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -178,7 +178,7 @@ void Layout::removeAllChildrenWithCleanup(bool cleanup) _doLayoutDirty = true; } -bool Layout::isClippingEnabled() +bool Layout::isClippingEnabled()const { return _clippingEnabled; } @@ -445,7 +445,7 @@ void Layout::setClippingType(ClippingType type) setClippingEnabled(clippingEnabled); } -Layout::ClippingType Layout::getClippingType() +Layout::ClippingType Layout::getClippingType()const { return _clippingType; } @@ -465,7 +465,7 @@ void Layout::setStencilClippingSize(const Size &size) } } -const Rect& Layout::getClippingRect() +const Rect& Layout::getClippingRect() { if (_clippingRectDirty) { @@ -582,7 +582,7 @@ void Layout::setBackGroundImageScale9Enabled(bool able) setBackGroundImageCapInsets(_backGroundImageCapInsets); } -bool Layout::isBackGroundImageScale9Enabled() +bool Layout::isBackGroundImageScale9Enabled()const { return _backGroundScale9Enabled; } @@ -643,7 +643,7 @@ void Layout::setBackGroundImageCapInsets(const Rect &capInsets) } } -const Rect& Layout::getBackGroundImageCapInsets() +const Rect& Layout::getBackGroundImageCapInsets()const { return _backGroundImageCapInsets; } @@ -773,7 +773,7 @@ void Layout::setBackGroundColorType(BackGroundColorType type) } } -Layout::BackGroundColorType Layout::getBackGroundColorType() +Layout::BackGroundColorType Layout::getBackGroundColorType()const { return _colorType; } @@ -787,7 +787,7 @@ void Layout::setBackGroundColor(const Color3B &color) } } -const Color3B& Layout::getBackGroundColor() +const Color3B& Layout::getBackGroundColor()const { return _cColor; } @@ -806,12 +806,12 @@ void Layout::setBackGroundColor(const Color3B &startColor, const Color3B &endCol } } -const Color3B& Layout::getBackGroundStartColor() +const Color3B& Layout::getBackGroundStartColor()const { return _gStartColor; } -const Color3B& Layout::getBackGroundEndColor() +const Color3B& Layout::getBackGroundEndColor()const { return _gEndColor; } @@ -834,7 +834,7 @@ void Layout::setBackGroundColorOpacity(GLubyte opacity) } } -GLubyte Layout::getBackGroundColorOpacity() +GLubyte Layout::getBackGroundColorOpacity()const { return _cOpacity; } @@ -848,7 +848,7 @@ void Layout::setBackGroundColorVector(const Vec2 &vector) } } -const Vec2& Layout::getBackGroundColorVector() +const Vec2& Layout::getBackGroundColorVector()const { return _alongVector; } @@ -865,12 +865,12 @@ void Layout::setBackGroundImageOpacity(GLubyte opacity) updateBackGroundImageOpacity(); } -const Color3B& Layout::getBackGroundImageColor() +const Color3B& Layout::getBackGroundImageColor()const { return _backGroundImageColor; } -GLubyte Layout::getBackGroundImageOpacity() +GLubyte Layout::getBackGroundImageOpacity()const { return _backGroundImageOpacity; } @@ -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(); } @@ -1020,7 +1020,7 @@ void Layout::setLoopFocus(bool loop) _loopFocus = loop; } -bool Layout::isLoopFocus() +bool Layout::isLoopFocus()const { return _loopFocus; } @@ -1031,7 +1031,7 @@ void Layout::setPassFocusToChild(bool pass) _passFocusToChild = pass; } -bool Layout::isPassFocusToChild() +bool Layout::isPassFocusToChild()const { return _passFocusToChild; } @@ -1073,7 +1073,7 @@ Size Layout::getLayoutAccumulatedSize()const return layoutSize; } -Vec2 Layout::getWorldCenterPoint(Widget* widget) +Vec2 Layout::getWorldCenterPoint(Widget* widget)const { Layout *layout = dynamic_cast(widget); //FIXEDME: we don't need to calculate the content size of layout anymore @@ -1433,7 +1433,7 @@ Widget* Layout::passFocusToChild(FocusDirection dir, cocos2d::ui::Widget *curren } -bool Layout::checkFocusEnabledChild() +bool Layout::checkFocusEnabledChild()const { bool ret = false; for(Node* node : _children) @@ -1448,7 +1448,7 @@ bool Layout::checkFocusEnabledChild() return ret; } -Widget* Layout::getChildWidgetByIndex(ssize_t index) +Widget* Layout::getChildWidgetByIndex(ssize_t index)const { ssize_t size = _children.size(); int count = 0; @@ -1671,7 +1671,7 @@ Widget* Layout::getNextFocusedWidget(FocusDirection direction, Widget *current) } } -bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) +bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction)const { Layout* parent = dynamic_cast(widget->getParent()); if (parent == nullptr) @@ -1757,7 +1757,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return false; } -bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection direction) +bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection direction)const { Layout* parent = dynamic_cast(widget->getParent()); if (parent == nullptr) diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 94f1bf6c10..e869f4f108 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; }; @@ -110,7 +110,7 @@ public: */ void setBackGroundImageCapInsets(const Rect& capInsets); - const Rect& getBackGroundImageCapInsets(); + const Rect& getBackGroundImageCapInsets()const; /** * Sets Color Type for layout. @@ -119,7 +119,7 @@ public: */ void setBackGroundColorType(BackGroundColorType type); - BackGroundColorType getBackGroundColorType(); + BackGroundColorType getBackGroundColorType()const; /** * Sets background iamge use scale9 renderer. @@ -128,7 +128,7 @@ public: */ void setBackGroundImageScale9Enabled(bool enabled); - bool isBackGroundImageScale9Enabled(); + bool isBackGroundImageScale9Enabled()const; /** * Sets background color for layout, if color type is LAYOUT_COLOR_SOLID @@ -137,7 +137,7 @@ public: */ void setBackGroundColor(const Color3B &color); - const Color3B& getBackGroundColor(); + const Color3B& getBackGroundColor()const; /** * Sets background color for layout, if color type is LAYOUT_COLOR_GRADIENT @@ -148,9 +148,9 @@ public: */ void setBackGroundColor(const Color3B &startColor, const Color3B &endColor); - const Color3B& getBackGroundStartColor(); + const Color3B& getBackGroundStartColor()const; - const Color3B& getBackGroundEndColor(); + const Color3B& getBackGroundEndColor()const; /** * Sets background opacity layout. @@ -159,7 +159,7 @@ public: */ void setBackGroundColorOpacity(GLubyte opacity); - GLubyte getBackGroundColorOpacity(); + GLubyte getBackGroundColorOpacity()const; /** * Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT @@ -168,15 +168,15 @@ public: */ void setBackGroundColorVector(const Vec2 &vector); - const Vec2& getBackGroundColorVector(); + const Vec2& getBackGroundColorVector()const; void setBackGroundImageColor(const Color3B& color); void setBackGroundImageOpacity(GLubyte opacity); - const Color3B& getBackGroundImageColor(); + const Color3B& getBackGroundImageColor()const; - GLubyte getBackGroundImageOpacity(); + GLubyte getBackGroundImageOpacity()const; /** * Remove the background image of layout. @@ -201,14 +201,14 @@ public: void setClippingType(ClippingType type); - ClippingType getClippingType(); + ClippingType getClippingType()const; /** * Gets if layout is clipping enabled. * * @return if layout is clipping enabled. */ - virtual bool isClippingEnabled(); + virtual bool isClippingEnabled()const; /** * Returns the "class name" of widget. @@ -276,7 +276,7 @@ public: /** *@return If focus loop is enabled, then it will return true, otherwise it returns false. The default value is false. */ - bool isLoopFocus(); + bool isLoopFocus()const; /** *@param pass To specify whether the layout pass its focus to its child @@ -286,7 +286,7 @@ public: /** * @return To query whether the layout will pass the focus to its children or not. The default value is true */ - bool isPassFocusToChild(); + bool isPassFocusToChild()const; /** * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction. @@ -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(); @@ -402,7 +402,7 @@ protected: /** * get the center point of a widget in world space */ - Vec2 getWorldCenterPoint(Widget* node); + Vec2 getWorldCenterPoint(Widget* node)const; /** * this method is called internally by nextFocusedWidget. When the dir is Right/Down, then this method will be called @@ -424,17 +424,17 @@ protected: * find the nth elment in the _children array. Only the Widget descendant object will be returned *@param index The index of a element in the _children array */ - Widget* getChildWidgetByIndex(ssize_t index); + Widget* getChildWidgetByIndex(ssize_t index)const; /** * whether it is the last element according to all their parents */ - bool isLastWidgetInContainer(Widget* widget, FocusDirection direction); + bool isLastWidgetInContainer(Widget* widget, FocusDirection direction)const; /**Lookup any parent widget with a layout type as the direction, * if the layout is loop focused, then return true, otherwise * It returns false */ - bool isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection direction); + bool isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection direction)const; /** * pass the focus to the layout's next focus enabled child @@ -444,7 +444,7 @@ protected: /** * If there are no focus enabled child in the layout, it will return false, otherwise it returns true */ - bool checkFocusEnabledChild(); + bool checkFocusEnabledChild()const; protected: bool _clippingEnabled; 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/UIListView.cpp b/cocos/ui/UIListView.cpp index 4923c6af89..b0391bbcb1 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -353,7 +353,7 @@ void ListView::removeAllItems() removeAllChildren(); } -Widget* ListView::getItem(ssize_t index) +Widget* ListView::getItem(ssize_t index)const { if (index < 0 || index >= _items.size()) { @@ -396,7 +396,7 @@ void ListView::setItemsMargin(float margin) _refreshViewDirty = true; } -float ListView::getItemsMargin() +float ListView::getItemsMargin()const { return _itemsMargin; } diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 563f6bfaeb..d053bca7cc 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -130,7 +130,7 @@ public: * * @return the item widget. */ - Widget* getItem(ssize_t index); + Widget* getItem(ssize_t index)const; /** * Returns the item container. @@ -159,7 +159,7 @@ public: */ void setItemsMargin(float margin); - float getItemsMargin(); + float getItemsMargin()const; virtual void sortAllChildren() override; virtual void addChild(Node * child) override; diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index fd4395487b..221b266ebf 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -217,7 +217,7 @@ void LoadingBar::setScale9Enabled(bool enabled) setPercent(_percent); } -bool LoadingBar::isScale9Enabled() +bool LoadingBar::isScale9Enabled()const { return _scale9Enabled; } @@ -232,7 +232,7 @@ void LoadingBar::setCapInsets(const Rect &capInsets) static_cast(_barRenderer)->setCapInsets(capInsets); } -const Rect& LoadingBar::getCapInsets() +const Rect& LoadingBar::getCapInsets()const { return _capInsets; } diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index b20c9d0c59..838d2a7af3 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -114,7 +114,7 @@ public: */ void setScale9Enabled(bool enabled); - bool isScale9Enabled(); + bool isScale9Enabled()const; /** * Sets capinsets for loadingbar, if loadingbar is using scale9 renderer. @@ -123,7 +123,7 @@ public: */ void setCapInsets(const Rect &capInsets); - const Rect& getCapInsets(); + const Rect& getCapInsets()const; //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index e3e4517092..0d2f42011f 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -181,7 +181,7 @@ void PageView::removePageAtIndex(ssize_t index) void PageView::removeAllPages() { - for(auto& node : _pages) + for(const auto& node : _pages) { removeProtectedChild(node); } @@ -200,12 +200,12 @@ void PageView::updateBoundaryPages() _rightBoundaryChild = _pages.at(this->getPageCount()-1); } -ssize_t PageView::getPageCount() +ssize_t PageView::getPageCount()const { return _pages.size(); } -float PageView::getPositionXByIndex(ssize_t idx) +float PageView::getPositionXByIndex(ssize_t idx)const { return (getSize().width * (idx-_curPageIdx)); } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index af3ba46f25..bc5d11cb03 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -178,8 +178,8 @@ CC_CONSTRUCTOR_ACCESS: protected: Layout* createPage(); - float getPositionXByIndex(ssize_t idx); - ssize_t getPageCount(); + float getPositionXByIndex(ssize_t idx)const; + ssize_t getPageCount()const; void updateBoundaryPages(); virtual bool scrollPages(float touchOffset); diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 23b8ebb34c..97ac197faf 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); } @@ -1709,7 +1709,7 @@ void ScrollView::setDirection(Direction dir) _direction = dir; } -ScrollView::Direction ScrollView::getDirection() +ScrollView::Direction ScrollView::getDirection()const { return _direction; } @@ -1734,7 +1734,7 @@ bool ScrollView::isInertiaScrollEnabled() const return _inertiaScrollEnabled; } -Layout* ScrollView::getInnerContainer() +Layout* ScrollView::getInnerContainer()const { return _innerContainer; } diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index c2daeb3de1..ff159a27da 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -118,7 +118,7 @@ public: * * @return SCROLLVIEW_DIR */ - Direction getDirection(); + Direction getDirection()const; /** * Gets inner container of scrollview. @@ -127,7 +127,7 @@ public: * * @return inner container. */ - Layout* getInnerContainer(); + Layout* getInnerContainer()const; /** * Scroll inner container to bottom boundary of scrollview. @@ -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/UISlider.cpp b/cocos/ui/UISlider.cpp index 4b6e89f4e3..561c39e891 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -231,7 +231,7 @@ void Slider::setScale9Enabled(bool able) setCapInsetProgressBarRebderer(_capInsetsProgressBarRenderer); } -bool Slider::isScale9Enabled() +bool Slider::isScale9Enabled()const { return _scale9Enabled; } @@ -261,7 +261,7 @@ void Slider::setCapInsetsBarRenderer(const Rect &capInsets) static_cast(_barRenderer)->setCapInsets(capInsets); } -const Rect& Slider::getCapInsetsBarRenderer() +const Rect& Slider::getCapInsetsBarRenderer()const { return _capInsetsBarRenderer; } @@ -276,7 +276,7 @@ void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets) static_cast(_progressBarRenderer)->setCapInsets(capInsets); } -const Rect& Slider::getCapInsetsProgressBarRebderer() +const Rect& Slider::getCapInsetsProgressBarRebderer()const { return _capInsetsProgressBarRenderer; } @@ -422,7 +422,7 @@ void Slider::onTouchCancelled(Touch *touch, Event *unusedEvent) Widget::onTouchCancelled(touch, unusedEvent); } -float Slider::getPercentWithBallPos(float px) +float Slider::getPercentWithBallPos(float px)const { return ((px/_barLength)*100.0f); } @@ -449,7 +449,7 @@ void Slider::percentChangedEvent() } } -int Slider::getPercent() +int Slider::getPercent()const { return _percent; } diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index fc2e9af290..76bb7463c4 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -85,7 +85,7 @@ public: */ void setScale9Enabled(bool able); - bool isScale9Enabled(); + bool isScale9Enabled()const; /** * Sets capinsets for slider, if slider is using scale9 renderer. @@ -101,7 +101,7 @@ public: */ void setCapInsetsBarRenderer(const Rect &capInsets); - const Rect& getCapInsetsBarRenderer(); + const Rect& getCapInsetsBarRenderer()const; /** * Sets capinsets for slider, if slider is using scale9 renderer. @@ -110,7 +110,7 @@ public: */ void setCapInsetProgressBarRebderer(const Rect &capInsets); - const Rect& getCapInsetsProgressBarRebderer(); + const Rect& getCapInsetsProgressBarRebderer()const; /** * Load textures for slider ball. @@ -176,7 +176,7 @@ public: * * @return percent percent value from 1 to 100. */ - int getPercent(); + int getPercent()const; /** * Add call back function called when slider's percent has changed to slider. @@ -210,7 +210,7 @@ CC_CONSTRUCTOR_ACCESS: protected: virtual void initRenderer() override; - float getPercentWithBallPos(float location); + float getPercentWithBallPos(float location)const; void percentChangedEvent(); virtual void onPressStateChangedToNormal() override; virtual void onPressStateChangedToPressed() override; diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index 88b0aafa36..5d4efd57df 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -136,7 +136,7 @@ void Text::setFontSize(int size) _labelRendererAdaptDirty = true; } -int Text::getFontSize() +int Text::getFontSize()const { return _fontSize; } @@ -160,7 +160,7 @@ void Text::setFontName(const std::string& name) _labelRendererAdaptDirty = true; } -const std::string& Text::getFontName() +const std::string& Text::getFontName()const { return _fontName; } @@ -177,7 +177,7 @@ void Text::setTextAreaSize(const Size &size) _labelRendererAdaptDirty = true; } -const Size& Text::getTextAreaSize() +const Size& Text::getTextAreaSize()const { return _labelRenderer->getDimensions(); } @@ -189,7 +189,7 @@ void Text::setTextHorizontalAlignment(TextHAlignment alignment) _labelRendererAdaptDirty = true; } -TextHAlignment Text::getTextHorizontalAlignment() +TextHAlignment Text::getTextHorizontalAlignment()const { return _labelRenderer->getHorizontalAlignment(); } @@ -201,7 +201,7 @@ void Text::setTextVerticalAlignment(TextVAlignment alignment) _labelRendererAdaptDirty = true; } -TextVAlignment Text::getTextVerticalAlignment() +TextVAlignment Text::getTextVerticalAlignment()const { return _labelRenderer->getVerticalAlignment(); } @@ -211,7 +211,7 @@ void Text::setTouchScaleChangeEnabled(bool enable) _touchScaleChangeEnabled = enable; } -bool Text::isTouchScaleChangeEnabled() +bool Text::isTouchScaleChangeEnabled()const { return _touchScaleChangeEnabled; } diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index d0bc342a08..b3cc3bd6b0 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -104,7 +104,7 @@ public: */ void setFontSize(int size); - int getFontSize(); + int getFontSize()const; /** * Sets the font name of label. @@ -117,7 +117,7 @@ public: */ void setFontName(const std::string& name); - const std::string& getFontName(); + const std::string& getFontName()const; Type getType() const; @@ -133,7 +133,7 @@ public: * * @return touch scale enabled of label. */ - bool isTouchScaleChangeEnabled(); + bool isTouchScaleChangeEnabled()const; //override "getVirtualRendererSize" method of widget. virtual const Size& getVirtualRendererSize() const override; @@ -148,15 +148,15 @@ public: void setTextAreaSize(const Size &size); - const Size& getTextAreaSize(); + const Size& getTextAreaSize()const; void setTextHorizontalAlignment(TextHAlignment alignment); - TextHAlignment getTextHorizontalAlignment(); + TextHAlignment getTextHorizontalAlignment()const; void setTextVerticalAlignment(TextVAlignment alignment); - TextVAlignment getTextVerticalAlignment(); + TextVAlignment getTextVerticalAlignment()const; CC_CONSTRUCTOR_ACCESS: virtual bool init() override; diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 688ab9a80f..49bc100eb3 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -246,7 +246,7 @@ void UICCTextField::setMaxLengthEnabled(bool enable) _maxLengthEnabled = enable; } -bool UICCTextField::isMaxLengthEnabled() +bool UICCTextField::isMaxLengthEnabled()const { return _maxLengthEnabled; } @@ -256,12 +256,12 @@ void UICCTextField::setMaxLength(int length) _maxLength = length; } -int UICCTextField::getMaxLength() +int UICCTextField::getMaxLength()const { return _maxLength; } -int UICCTextField::getCharCount() +int UICCTextField::getCharCount()const { return TextFieldTTF::getCharCount(); } @@ -271,7 +271,7 @@ void UICCTextField::setPasswordEnabled(bool enable) _passwordEnabled = enable; } -bool UICCTextField::isPasswordEnabled() +bool UICCTextField::isPasswordEnabled()const { return _passwordEnabled; } @@ -317,7 +317,7 @@ void UICCTextField::setAttachWithIME(bool attach) _attachWithIME = attach; } -bool UICCTextField::getAttachWithIME() +bool UICCTextField::getAttachWithIME()const { return _attachWithIME; } @@ -327,7 +327,7 @@ void UICCTextField::setDetachWithIME(bool detach) _detachWithIME = detach; } -bool UICCTextField::getDetachWithIME() +bool UICCTextField::getDetachWithIME()const { return _detachWithIME; } @@ -337,7 +337,7 @@ void UICCTextField::setInsertText(bool insert) _insertText = insert; } -bool UICCTextField::getInsertText() +bool UICCTextField::getInsertText()const { return _insertText; } @@ -347,7 +347,7 @@ void UICCTextField::setDeleteBackward(bool deleteBackward) _deleteBackward = deleteBackward; } -bool UICCTextField::getDeleteBackward() +bool UICCTextField::getDeleteBackward()const { return _deleteBackward; } @@ -455,7 +455,7 @@ bool TextField::hitTest(const Vec2 &pt) return false; } -Size TextField::getTouchSize() +Size TextField::getTouchSize()const { return Size(_touchWidth, _touchHeight); } @@ -526,7 +526,7 @@ void TextField::setPlaceHolder(const std::string& value) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -const std::string& TextField::getPlaceHolder() +const std::string& TextField::getPlaceHolder()const { return _textFieldRenderer->getPlaceHolder(); } @@ -538,7 +538,7 @@ void TextField::setFontSize(int size) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -int TextField::getFontSize() +int TextField::getFontSize()const { return _textFieldRenderer->getSystemFontSize(); } @@ -550,7 +550,7 @@ void TextField::setFontName(const std::string& name) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -const std::string& TextField::getFontName() +const std::string& TextField::getFontName()const { return _textFieldRenderer->getSystemFontName(); } @@ -560,7 +560,7 @@ void TextField::didNotSelectSelf() _textFieldRenderer->detachWithIME(); } -const std::string& TextField::getStringValue() +const std::string& TextField::getStringValue()const { return _textFieldRenderer->getString(); } @@ -580,7 +580,7 @@ void TextField::setMaxLengthEnabled(bool enable) _textFieldRenderer->setMaxLengthEnabled(enable); } -bool TextField::isMaxLengthEnabled() +bool TextField::isMaxLengthEnabled()const { return _textFieldRenderer->isMaxLengthEnabled(); } @@ -592,7 +592,7 @@ void TextField::setMaxLength(int length) setText(getStringValue()); } -int TextField::getMaxLength() +int TextField::getMaxLength()const { return _textFieldRenderer->getMaxLength(); } @@ -602,7 +602,7 @@ void TextField::setPasswordEnabled(bool enable) _textFieldRenderer->setPasswordEnabled(enable); } -bool TextField::isPasswordEnabled() +bool TextField::isPasswordEnabled()const { return _textFieldRenderer->isPasswordEnabled(); } @@ -616,7 +616,7 @@ void TextField::setPasswordStyleText(const char *styleText) setText(getStringValue()); } -const char* TextField::getPasswordStyleText() +const char* TextField::getPasswordStyleText()const { return _passwordStyleText.c_str(); } @@ -651,7 +651,7 @@ void TextField::update(float dt) } } -bool TextField::getAttachWithIME() +bool TextField::getAttachWithIME()const { return _textFieldRenderer->getAttachWithIME(); } @@ -661,7 +661,7 @@ void TextField::setAttachWithIME(bool attach) _textFieldRenderer->setAttachWithIME(attach); } -bool TextField::getDetachWithIME() +bool TextField::getDetachWithIME()const { return _textFieldRenderer->getDetachWithIME(); } @@ -671,7 +671,7 @@ void TextField::setDetachWithIME(bool detach) _textFieldRenderer->setDetachWithIME(detach); } -bool TextField::getInsertText() +bool TextField::getInsertText()const { return _textFieldRenderer->getInsertText(); } @@ -681,7 +681,7 @@ void TextField::setInsertText(bool insertText) _textFieldRenderer->setInsertText(insertText); } -bool TextField::getDeleteBackward() +bool TextField::getDeleteBackward()const { return _textFieldRenderer->getDeleteBackward(); } diff --git a/cocos/ui/UITextField.h b/cocos/ui/UITextField.h index 95cc9ca650..8c2ef01c9e 100644 --- a/cocos/ui/UITextField.h +++ b/cocos/ui/UITextField.h @@ -59,22 +59,26 @@ public: void closeIME(); void setMaxLengthEnabled(bool enable); - bool isMaxLengthEnabled(); + bool isMaxLengthEnabled()const; void setMaxLength(int length); - int getMaxLength(); - int getCharCount(); + int getMaxLength()const; + int getCharCount()const; + void setPasswordEnabled(bool enable); - bool isPasswordEnabled(); + bool isPasswordEnabled()const; void setPasswordStyleText(const std::string& styleText); void setPasswordText(const std::string& text); + void setAttachWithIME(bool attach); - bool getAttachWithIME(); + bool getAttachWithIME()const; void setDetachWithIME(bool detach); - bool getDetachWithIME(); + bool getDetachWithIME()const; + void setInsertText(bool insert); - bool getInsertText(); + bool getInsertText()const; + void setDeleteBackward(bool deleteBackward); - bool getDeleteBackward(); + bool getDeleteBackward()const; protected: bool _maxLengthEnabled; int _maxLength; @@ -123,36 +127,48 @@ public: const std::string& fontName, int fontSize); void setTouchSize(const Size &size); - Size getTouchSize(); + Size getTouchSize()const; void setTouchAreaEnabled(bool enable); virtual bool hitTest(const Vec2 &pt); - void setText(const std::string& text); + void setPlaceHolder(const std::string& value); - const std::string& getPlaceHolder(); + const std::string& getPlaceHolder()const; + void setFontSize(int size); - int getFontSize(); + int getFontSize()const; void setFontName(const std::string& name); - const std::string& getFontName(); + const std::string& getFontName()const; + virtual void didNotSelectSelf(); - const std::string& getStringValue(); + + void setText(const std::string& text); + const std::string& getStringValue()const; + virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; + void setMaxLengthEnabled(bool enable); - bool isMaxLengthEnabled(); + bool isMaxLengthEnabled()const; void setMaxLength(int length); - int getMaxLength(); + int getMaxLength()const; + void setPasswordEnabled(bool enable); - bool isPasswordEnabled(); + bool isPasswordEnabled()const; void setPasswordStyleText(const char* styleText); - const char* getPasswordStyleText(); + const char* getPasswordStyleText()const; + virtual void update(float dt) override; - bool getAttachWithIME(); + + bool getAttachWithIME()const; void setAttachWithIME(bool attach); - bool getDetachWithIME(); + bool getDetachWithIME()const; void setDetachWithIME(bool detach); - bool getInsertText(); + + bool getInsertText()const; void setInsertText(bool insertText); - bool getDeleteBackward(); + + bool getDeleteBackward()const; void setDeleteBackward(bool deleteBackward); + CC_DEPRECATED_ATTRIBUTE void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor); void addEventListener(const ccTextFieldCallback& callback); @@ -184,6 +200,7 @@ protected: virtual void updateTextureOpacity() override; virtual void updateTextureRGBA() override; void textfieldRendererScaleChangedWithSize(); + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void adaptRenderers() override; diff --git a/cocos/ui/UIVideoPlayer.h b/cocos/ui/UIVideoPlayer.h index c6dd4b3b79..fa3627b61c 100644 --- a/cocos/ui/UIVideoPlayer.h +++ b/cocos/ui/UIVideoPlayer.h @@ -66,10 +66,10 @@ namespace experimental{ virtual void setVisible(bool visible) override; virtual void setKeepAspectRatioEnabled(bool enable); - virtual bool isKeepAspectRatioEnabled() { return _keepAspectRatioEnabled;} + virtual bool isKeepAspectRatioEnabled()const { return _keepAspectRatioEnabled;} virtual void setFullScreenEnabled(bool enabled); - virtual bool isFullScreenEnabled(); + virtual bool isFullScreenEnabled()const; virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback); diff --git a/cocos/ui/UIVideoPlayerAndroid.cpp b/cocos/ui/UIVideoPlayerAndroid.cpp index ae0b7d50d7..2c8073c68c 100644 --- a/cocos/ui/UIVideoPlayerAndroid.cpp +++ b/cocos/ui/UIVideoPlayerAndroid.cpp @@ -242,7 +242,7 @@ void VideoPlayer::setFullScreenEnabled(bool enabled) } } -bool VideoPlayer::isFullScreenEnabled() +bool VideoPlayer::isFullScreenEnabled()const { return _fullScreenEnabled; } diff --git a/cocos/ui/UIVideoPlayerIOS.mm b/cocos/ui/UIVideoPlayerIOS.mm index 52ee49cb99..a38db66291 100644 --- a/cocos/ui/UIVideoPlayerIOS.mm +++ b/cocos/ui/UIVideoPlayerIOS.mm @@ -343,7 +343,7 @@ void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transform #endif } -bool VideoPlayer::isFullScreenEnabled() +bool VideoPlayer::isFullScreenEnabled()const { return [((UIVideoViewWrapperIos*)_videoView) isFullScreenEnabled]; } 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;