#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>
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 )
{
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);
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#include "CanvasPlacement.hxx"
+#include <simgear/props/props.hxx>
namespace simgear
{
{
//----------------------------------------------------------------------------
- Placement::Placement()
+ Placement::Placement(SGPropertyNode* node):
+ _node(node)
{
}
}
+ //----------------------------------------------------------------------------
+ SGConstPropertyNode_ptr Placement::getProps() const
+ {
+ return _node;
+ }
+
+ //----------------------------------------------------------------------------
+ SGPropertyNode_ptr Placement::getProps()
+ {
+ return _node;
+ }
+
+ //----------------------------------------------------------------------------
+ bool Placement::childChanged(SGPropertyNode* child)
+ {
+ return false;
+ }
+
} // namespace canvas
} // namespace simgear
#ifndef CANVAS_PLACEMENT_HXX_
#define CANVAS_PLACEMENT_HXX_
+#include <simgear/props/propsfwd.hxx>
+
namespace simgear
{
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 */;