From: Thomas Geymayer Date: Wed, 6 Feb 2013 00:19:24 +0000 (+0100) Subject: Expose reloading Canvas placements X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5dea221ad56c6137392631524d539b7fff465716;p=simgear.git Expose reloading Canvas placements --- diff --git a/simgear/canvas/Canvas.cxx b/simgear/canvas/Canvas.cxx index 5ab19006..4117c7af 100644 --- a/simgear/canvas/Canvas.cxx +++ b/simgear/canvas/Canvas.cxx @@ -168,11 +168,7 @@ namespace canvas { // Resizing causes a new texture to be created so we need to reapply all // existing placements - for(size_t i = 0; i < _placements.size(); ++i) - { - if( !_placements[i].empty() ) - _dirty_placements.push_back( _placements[i].front()->getProps() ); - } + reloadPlacements(); } osg::Camera* camera = _texture.getCamera(); @@ -491,6 +487,24 @@ namespace canvas return _cull_callback; } + //---------------------------------------------------------------------------- + void Canvas::reloadPlacements(const std::string& type) + { + for(size_t i = 0; i < _placements.size(); ++i) + { + if( _placements[i].empty() ) + continue; + + SGPropertyNode* child = _placements[i].front()->getProps(); + if( type.empty() + // reload if type matches or no type specified + || child->getStringValue("type", type.c_str()) == type ) + { + _dirty_placements.push_back(child); + } + } + } + //---------------------------------------------------------------------------- void Canvas::addPlacementFactory( const std::string& type, PlacementFactory factory ) diff --git a/simgear/canvas/Canvas.hxx b/simgear/canvas/Canvas.hxx index 4d8239c3..efb5bdc2 100644 --- a/simgear/canvas/Canvas.hxx +++ b/simgear/canvas/Canvas.hxx @@ -130,6 +130,7 @@ namespace canvas CullCallbackPtr getCullCallback() const; + void reloadPlacements( const std::string& type = std::string() ); static void addPlacementFactory( const std::string& type, PlacementFactory factory );