Merge pull request #6655 from zifter/FixCascade

Fixed bug with cascade opacity and color for control button. #4881
This commit is contained in:
minggo 2014-05-19 11:13:29 +08:00
commit c0b0ca0e70
2 changed files with 38 additions and 21 deletions

View File

@ -656,30 +656,32 @@ void ControlButton::onTouchEnded(Touch *pTouch, Event *pEvent)
void ControlButton::setOpacity(GLubyte opacity)
{
// XXX fixed me if not correct
Control::setOpacity(opacity);
// _opacity = opacity;
//
// Ref* child;
// Array* children=getChildren();
// CCARRAY_FOREACH(children, child)
// {
// RGBAProtocol* pNode = dynamic_cast<RGBAProtocol*>(child);
// if (pNode)
// {
// pNode->setOpacity(opacity);
// }
// }
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->setOpacity(opacity);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->setOpacity(opacity);
}
}
GLubyte ControlButton::getOpacity() const
void ControlButton::updateDisplayedOpacity(GLubyte parentOpacity)
{
return _realOpacity;
Control::updateDisplayedOpacity(parentOpacity);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedOpacity(parentOpacity);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedOpacity(parentOpacity);
}
}
void ControlButton::setColor(const Color3B & color)
@ -690,11 +692,26 @@ void ControlButton::setColor(const Color3B & color)
{
iter->second->setColor(color);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->setColor(color);
}
}
const Color3B& ControlButton::getColor() const
void ControlButton::updateDisplayedColor(const Color3B& parentColor)
{
return _realColor;
Control::updateDisplayedColor(parentColor);
for (auto iter = _backgroundSpriteDispatchTable.begin(); iter != _backgroundSpriteDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedColor(parentColor);
}
for (auto iter = _titleLabelDispatchTable.begin(); iter != _titleLabelDispatchTable.end(); ++iter)
{
iter->second->updateDisplayedColor(parentColor);
}
}
void ControlButton::onTouchCancelled(Touch *pTouch, Event *pEvent)

View File

@ -181,11 +181,11 @@ public:
virtual void onTouchMoved(Touch *touch, Event *event) override;
virtual void onTouchEnded(Touch *touch, Event *event) override;
virtual void onTouchCancelled(Touch *touch, Event *event) override;
virtual GLubyte getOpacity(void) const override;
virtual void setOpacity(GLubyte var) override;
virtual const Color3B& getColor(void) const override;
virtual void setColor(const Color3B&) override;
virtual void setOpacity(GLubyte var) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual void setColor(const Color3B&) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
const std::string& getCurrentTitle() const { return _currentTitle; };
std::string getCurrentTitle() { return _currentTitle; };