X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fcanvas%2Felements%2FCanvasElement.hxx;h=0f4b31edf6a4d1a48c12b66f1e301c1a8d1d569a;hb=46442ef50c5a2b7c8e41e5c025f86c1cd35e6e15;hp=d28baaecbd188df18f394c3de458c8baf3802595;hpb=34719da0005f8c3d13cce2538820a45f0a5b7d3e;p=simgear.git diff --git a/simgear/canvas/elements/CanvasElement.hxx b/simgear/canvas/elements/CanvasElement.hxx index d28baaec..0f4b31ed 100644 --- a/simgear/canvas/elements/CanvasElement.hxx +++ b/simgear/canvas/elements/CanvasElement.hxx @@ -20,8 +20,11 @@ #define CANVAS_ELEMENT_HXX_ #include +#include #include #include // for uint32_t +#include + #include #include @@ -38,7 +41,6 @@ namespace simgear namespace canvas { - class MouseEvent; class Element: public SGPropertyChangeListener { @@ -67,11 +69,19 @@ namespace canvas */ virtual void update(double dt); - /** - * Handle mouse event (transforms coordinates to local coordinate frame - * and forwards event to #handleLocalMouseEvent) - */ - virtual bool handleMouseEvent(const canvas::MouseEvent& event); + naRef addEventListener(const nasal::CallContext& ctx); + + SGConstPropertyNode_ptr getProps() const; + SGPropertyNode_ptr getProps(); + + virtual bool accept(EventVisitor& visitor); + virtual bool ascend(EventVisitor& visitor); + virtual bool traverse(EventVisitor& visitor); + + void callListeners(const canvas::EventPtr& event); + + virtual bool hitBound(const osg::Vec2f& pos) const; + osg::ref_ptr getMatrixTransform(); @@ -103,6 +113,7 @@ namespace canvas }; CanvasWeakPtr _canvas; + Element *_parent; uint32_t _attributes_dirty; bool _transform_dirty; @@ -114,9 +125,15 @@ namespace canvas StyleSetters _style_setters; std::vector _bounding_box; + typedef std::vector Listener; + typedef std::map ListenerMap; + + ListenerMap _listener; + Element( const CanvasWeakPtr& canvas, const SGPropertyNode_ptr& node, - const Style& parent_style ); + const Style& parent_style, + Element* parent ); template Element::StyleSetter @@ -153,8 +170,6 @@ namespace canvas return boost::bind(setter, instance, boost::bind(&getValue, _1)); } - virtual bool handleLocalMouseEvent(const canvas::MouseEvent& event); - virtual void childAdded(SGPropertyNode * child) {} virtual void childRemoved(SGPropertyNode * child){} virtual void childChanged(SGPropertyNode * child){}