Canvas: Propagate style changes on groups to children
This commit is contained in:
parent
66786651b0
commit
d06d94c767
@ -297,6 +297,18 @@ namespace canvas
|
||||
childChanged(child);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool Element::setStyle(const SGPropertyNode* child)
|
||||
{
|
||||
StyleSetters::const_iterator setter =
|
||||
_style_setters.find(child->getNameString());
|
||||
if( setter == _style_setters.end() )
|
||||
return false;
|
||||
|
||||
setter->second(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Element::setBoundingBox(const osg::BoundingBox& bb)
|
||||
{
|
||||
@ -364,17 +376,5 @@ namespace canvas
|
||||
setStyle(style.second);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool Element::setStyle(const SGPropertyNode* child)
|
||||
{
|
||||
StyleSetters::const_iterator setter =
|
||||
_style_setters.find(child->getNameString());
|
||||
if( setter == _style_setters.end() )
|
||||
return false;
|
||||
|
||||
setter->second(child);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace canvas
|
||||
} // namespace simgear
|
||||
|
@ -91,6 +91,8 @@ namespace canvas
|
||||
SGPropertyNode * child );
|
||||
virtual void valueChanged(SGPropertyNode * child);
|
||||
|
||||
virtual bool setStyle(const SGPropertyNode* child);
|
||||
|
||||
/**
|
||||
* Write the given bounding box to the property tree
|
||||
*/
|
||||
@ -182,7 +184,6 @@ namespace canvas
|
||||
void setDrawable(osg::Drawable* drawable);
|
||||
|
||||
void setupStyle();
|
||||
bool setStyle(const SGPropertyNode* child);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -132,6 +132,23 @@ namespace canvas
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool Group::setStyle(const SGPropertyNode* style)
|
||||
{
|
||||
if( style->getParent() != _node
|
||||
&& _style.find(style->getNameString()) != _style.end() )
|
||||
return false;
|
||||
|
||||
bool handled = false;
|
||||
BOOST_FOREACH( ChildList::value_type child, _children )
|
||||
{
|
||||
if( child.second->setStyle(style) )
|
||||
handled = true;
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
osg::BoundingBox Group::getTransformedBounds(const osg::Matrix& m) const
|
||||
{
|
||||
@ -174,6 +191,7 @@ namespace canvas
|
||||
}
|
||||
|
||||
_style[ child->getNameString() ] = child;
|
||||
setStyle(child);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -58,6 +58,8 @@ namespace canvas
|
||||
|
||||
virtual bool traverse(EventVisitor& visitor);
|
||||
|
||||
virtual bool setStyle(const SGPropertyNode* child);
|
||||
|
||||
virtual osg::BoundingBox getTransformedBounds(const osg::Matrix& m) const;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user