Allow canvas::Placements to have own properties
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "Canvas.hxx"
|
||||
#include <simgear/canvas/MouseEvent.hxx>
|
||||
#include <simgear/canvas/CanvasPlacement.hxx>
|
||||
#include <simgear/scene/util/parse_color.hxx>
|
||||
#include <simgear/scene/util/RenderConstants.hxx>
|
||||
|
||||
@@ -382,6 +383,21 @@ namespace canvas
|
||||
if( node->getParent()->getParent() == _node
|
||||
&& node->getParent()->getNameString() == "placement" )
|
||||
{
|
||||
bool placement_dirty = false;
|
||||
BOOST_FOREACH(Placements& placements, _placements)
|
||||
{
|
||||
BOOST_FOREACH(PlacementPtr& placement, placements)
|
||||
{
|
||||
// check if change can be directly handled by placement
|
||||
if( placement->getProps() == node->getParent()
|
||||
&& !placement->childChanged(node) )
|
||||
placement_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !placement_dirty )
|
||||
return;
|
||||
|
||||
// prevent double updates...
|
||||
for( size_t i = 0; i < _dirty_placements.size(); ++i )
|
||||
{
|
||||
|
||||
@@ -159,12 +159,12 @@ namespace canvas
|
||||
bool _render_always; //<! Used to disable automatic lazy rendering (culling)
|
||||
|
||||
std::vector<SGPropertyNode*> _dirty_placements;
|
||||
std::vector<canvas::Placements> _placements;
|
||||
std::vector<Placements> _placements;
|
||||
std::set<CanvasWeakPtr> _dependent_canvases; //<! Canvases which use this
|
||||
// canvas and should be
|
||||
// notified about changes
|
||||
|
||||
typedef std::map<std::string, canvas::PlacementFactory> PlacementFactoryMap;
|
||||
typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
|
||||
static PlacementFactoryMap _placement_factories;
|
||||
|
||||
virtual void setSelf(const PropertyBasedElementPtr& self);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
#include "CanvasPlacement.hxx"
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
@@ -24,7 +25,8 @@ namespace canvas
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Placement::Placement()
|
||||
Placement::Placement(SGPropertyNode* node):
|
||||
_node(node)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -35,5 +37,23 @@ namespace canvas
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SGConstPropertyNode_ptr Placement::getProps() const
|
||||
{
|
||||
return _node;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SGPropertyNode_ptr Placement::getProps()
|
||||
{
|
||||
return _node;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool Placement::childChanged(SGPropertyNode* child)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace canvas
|
||||
} // namespace simgear
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#ifndef CANVAS_PLACEMENT_HXX_
|
||||
#define CANVAS_PLACEMENT_HXX_
|
||||
|
||||
#include <simgear/props/propsfwd.hxx>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
namespace canvas
|
||||
@@ -27,9 +29,17 @@ namespace canvas
|
||||
class Placement
|
||||
{
|
||||
public:
|
||||
Placement();
|
||||
Placement(SGPropertyNode* node);
|
||||
virtual ~Placement() = 0;
|
||||
|
||||
SGConstPropertyNode_ptr getProps() const;
|
||||
SGPropertyNode_ptr getProps();
|
||||
|
||||
virtual bool childChanged(SGPropertyNode* child);
|
||||
|
||||
protected:
|
||||
SGPropertyNode_ptr _node;
|
||||
|
||||
private:
|
||||
Placement(const Placement&) /* = delete */;
|
||||
Placement& operator=(const Placement&) /* = delete */;
|
||||
|
||||
Reference in New Issue
Block a user