refactor UICheckBox setColor & setOpacity

This commit is contained in:
andyque 2014-06-06 16:01:55 +08:00
parent 46ad4edab3
commit 0805c215b3
2 changed files with 16 additions and 35 deletions

View File

@ -184,7 +184,9 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp
} }
updateFlippedX(); updateFlippedX();
updateFlippedY(); updateFlippedY();
updateRGBAToRenderer(_backGroundBoxRenderer); _backGroundBoxRenderer->setColor(this->getColor());
_backGroundBoxRenderer->setOpacity(this->getOpacity());
updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize()); updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize());
_backGroundBoxRendererAdaptDirty = true; _backGroundBoxRendererAdaptDirty = true;
} }
@ -210,7 +212,8 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect
} }
updateFlippedX(); updateFlippedX();
updateFlippedY(); updateFlippedY();
updateRGBAToRenderer(_backGroundSelectedBoxRenderer); _backGroundSelectedBoxRenderer->setColor(this->getColor());
_backGroundSelectedBoxRenderer->setOpacity(this->getOpacity());
_backGroundSelectedBoxRendererAdaptDirty = true; _backGroundSelectedBoxRendererAdaptDirty = true;
} }
@ -235,7 +238,8 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex
} }
updateFlippedX(); updateFlippedX();
updateFlippedY(); updateFlippedY();
updateRGBAToRenderer(_frontCrossRenderer); _frontCrossRenderer->setColor(this->getColor());
_frontCrossRenderer->setOpacity(this->getOpacity());
_frontCrossRendererAdaptDirty = true; _frontCrossRendererAdaptDirty = true;
} }
@ -260,7 +264,9 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl
} }
updateFlippedX(); updateFlippedX();
updateFlippedY(); updateFlippedY();
updateRGBAToRenderer(_backGroundBoxDisabledRenderer); _backGroundBoxDisabledRenderer->setColor(this->getColor());
_backGroundBoxDisabledRenderer->setOpacity(this->getOpacity());
_backGroundBoxDisabledRendererAdaptDirty = true; _backGroundBoxDisabledRendererAdaptDirty = true;
} }
@ -285,7 +291,9 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl
} }
updateFlippedX(); updateFlippedX();
updateFlippedY(); updateFlippedY();
updateRGBAToRenderer(_frontCrossDisabledRenderer); _frontCrossDisabledRenderer->setColor(this->getColor());
_frontCrossDisabledRenderer->setOpacity(this->getOpacity());
_frontCrossDisabledRendererAdaptDirty = true; _frontCrossDisabledRendererAdaptDirty = true;
} }
@ -565,33 +573,6 @@ std::string CheckBox::getDescription() const
{ {
return "CheckBox"; 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() Widget* CheckBox::createCloneInstance()
{ {

View File

@ -211,16 +211,16 @@ protected:
virtual void releaseUpEvent(); virtual void releaseUpEvent();
virtual void onSizeChanged() override; virtual void onSizeChanged() override;
virtual void updateTextureColor() override;
virtual void updateTextureOpacity() override;
virtual void updateTextureRGBA() override;
virtual void updateFlippedX() override; virtual void updateFlippedX() override;
virtual void updateFlippedY() override; virtual void updateFlippedY() override;
void backGroundTextureScaleChangedWithSize(); void backGroundTextureScaleChangedWithSize();
void backGroundSelectedTextureScaleChangedWithSize(); void backGroundSelectedTextureScaleChangedWithSize();
void frontCrossTextureScaleChangedWithSize(); void frontCrossTextureScaleChangedWithSize();
void backGroundDisabledTextureScaleChangedWithSize(); void backGroundDisabledTextureScaleChangedWithSize();
void frontCrossDisabledTextureScaleChangedWithSize(); void frontCrossDisabledTextureScaleChangedWithSize();
virtual Widget* createCloneInstance() override; virtual Widget* createCloneInstance() override;
virtual void copySpecialProperties(Widget* model) override; virtual void copySpecialProperties(Widget* model) override;
virtual void adaptRenderers() override; virtual void adaptRenderers() override;