diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index 5fec8fdc3a..5440da5a3a 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -184,7 +184,9 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundBoxRenderer); + _backGroundBoxRenderer->setColor(this->getColor()); + _backGroundBoxRenderer->setOpacity(this->getOpacity()); + updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize()); _backGroundBoxRendererAdaptDirty = true; } @@ -210,7 +212,8 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundSelectedBoxRenderer); + _backGroundSelectedBoxRenderer->setColor(this->getColor()); + _backGroundSelectedBoxRenderer->setOpacity(this->getOpacity()); _backGroundSelectedBoxRendererAdaptDirty = true; } @@ -235,7 +238,8 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_frontCrossRenderer); + _frontCrossRenderer->setColor(this->getColor()); + _frontCrossRenderer->setOpacity(this->getOpacity()); _frontCrossRendererAdaptDirty = true; } @@ -260,7 +264,9 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundBoxDisabledRenderer); + _backGroundBoxDisabledRenderer->setColor(this->getColor()); + _backGroundBoxDisabledRenderer->setOpacity(this->getOpacity()); + _backGroundBoxDisabledRendererAdaptDirty = true; } @@ -285,7 +291,9 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_frontCrossDisabledRenderer); + _frontCrossDisabledRenderer->setColor(this->getColor()); + _frontCrossDisabledRenderer->setOpacity(this->getOpacity()); + _frontCrossDisabledRendererAdaptDirty = true; } @@ -565,33 +573,6 @@ std::string CheckBox::getDescription() const { return "CheckBox"; } - -void CheckBox::updateTextureColor() -{ - updateColorToRenderer(_backGroundBoxRenderer); - updateColorToRenderer(_backGroundSelectedBoxRenderer); - updateColorToRenderer(_frontCrossRenderer); - updateColorToRenderer(_backGroundBoxDisabledRenderer); - updateColorToRenderer(_frontCrossDisabledRenderer); -} - -void CheckBox::updateTextureOpacity() -{ - updateOpacityToRenderer(_backGroundBoxRenderer); - updateOpacityToRenderer(_backGroundSelectedBoxRenderer); - updateOpacityToRenderer(_frontCrossRenderer); - updateOpacityToRenderer(_backGroundBoxDisabledRenderer); - updateOpacityToRenderer(_frontCrossDisabledRenderer); -} - -void CheckBox::updateTextureRGBA() -{ - updateRGBAToRenderer(_backGroundBoxRenderer); - updateRGBAToRenderer(_backGroundSelectedBoxRenderer); - updateRGBAToRenderer(_frontCrossRenderer); - updateRGBAToRenderer(_backGroundBoxDisabledRenderer); - updateRGBAToRenderer(_frontCrossDisabledRenderer); -} Widget* CheckBox::createCloneInstance() { diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index 3192797cf8..05c77d836b 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -211,16 +211,16 @@ protected: virtual void releaseUpEvent(); virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + virtual void updateFlippedX() override; virtual void updateFlippedY() override; + void backGroundTextureScaleChangedWithSize(); void backGroundSelectedTextureScaleChangedWithSize(); void frontCrossTextureScaleChangedWithSize(); void backGroundDisabledTextureScaleChangedWithSize(); void frontCrossDisabledTextureScaleChangedWithSize(); + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void adaptRenderers() override;