X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fcanvas%2FCanvas.hxx;h=c350257c0b26833df58f077ea50a5213b6d45baf;hb=01a43b49a5cb55e8218beb842e5743c04666dd8d;hp=4d8239c3bb79939f1069280ea661d17ef666d689;hpb=ac27fae7129788a099e3820061e69e8139bfabc2;p=simgear.git diff --git a/simgear/canvas/Canvas.hxx b/simgear/canvas/Canvas.hxx index 4d8239c3..c350257c 100644 --- a/simgear/canvas/Canvas.hxx +++ b/simgear/canvas/Canvas.hxx @@ -23,12 +23,13 @@ #include "ODGauge.hxx" #include +#include #include #include #include #include -#include +#include #include namespace simgear @@ -71,29 +72,54 @@ namespace canvas Canvas(SGPropertyNode* node); virtual ~Canvas(); - - void setSystemAdapter(const SystemAdapterPtr& system_adapter); - SystemAdapterPtr getSystemAdapter() const; + virtual void onDestroy(); void setCanvasMgr(CanvasMgr* canvas_mgr); CanvasMgr* getCanvasMgr() const; + bool isInit() const; + /** - * Add a canvas which should be mared as dirty upon any change to this + * Add a canvas which should be marked as dirty upon any change to this * canvas. * * This mechanism is used to eg. redraw a canvas if it's displaying * another canvas (recursive canvases) */ - void addDependentCanvas(const CanvasWeakPtr& canvas); + void addParentCanvas(const CanvasWeakPtr& canvas); + + /** + * Add a canvas which should be marked visible if this canvas is visible. + */ + void addChildCanvas(const CanvasWeakPtr& canvas); /** * Stop notifying the given canvas upon changes */ - void removeDependentCanvas(const CanvasWeakPtr& canvas); + void removeParentCanvas(const CanvasWeakPtr& canvas); + void removeChildCanvas(const CanvasWeakPtr& canvas); + /** + * Create a new group + */ GroupPtr createGroup(const std::string& name = ""); + /** + * Get an existing group with the given name + */ + GroupPtr getGroup(const std::string& name); + + /** + * Get an existing group with the given name or otherwise create a new + * group + */ + GroupPtr getOrCreateGroup(const std::string& name); + + /** + * Get the root group of the canvas + */ + GroupPtr getRootGroup(); + /** * Enable rendering for the next frame * @@ -104,7 +130,7 @@ namespace canvas void update(double delta_time_sec); - naRef addEventListener(const nasal::CallContext& ctx); + bool addEventListener(const std::string& type, const EventListener& cb); void setSizeX(int sx); void setSizeY(int sy); @@ -117,6 +143,7 @@ namespace canvas int getViewWidth() const; int getViewHeight() const; + SGRect getViewport() const; bool handleMouseEvent(const MouseEventPtr& event); @@ -130,15 +157,26 @@ namespace canvas CullCallbackPtr getCullCallback() const; + void reloadPlacements( const std::string& type = std::string() ); static void addPlacementFactory( const std::string& type, PlacementFactory factory ); + static void removePlacementFactory(const std::string& type); + + /** + * Set global SystemAdapter for all Canvas/ODGauge instances. + * + * The SystemAdapter is responsible for application specific operations + * like loading images/fonts and adding/removing cameras to the scene + * graph. + */ + static void setSystemAdapter(const SystemAdapterPtr& system_adapter); + static SystemAdapterPtr getSystemAdapter(); protected: - SystemAdapterPtr _system_adapter; CanvasMgr *_canvas_mgr; - std::auto_ptr _event_manager; + boost::scoped_ptr _event_manager; int _size_x, _size_y, @@ -160,9 +198,9 @@ namespace canvas std::vector _dirty_placements; std::vector _placements; - std::set _dependent_canvases; // _parent_canvases, // PlacementFactoryMap; static PlacementFactoryMap _placement_factories; @@ -172,6 +210,8 @@ namespace canvas private: + static SystemAdapterPtr _system_adapter; + Canvas(const Canvas&); // = delete; Canvas& operator=(const Canvas&); // = delete; };