}
}
- //----------------------------------------------------------------------------
- void Canvas::setSystemAdapter(const SystemAdapterPtr& system_adapter)
- {
- _system_adapter = system_adapter;
- _texture.setSystemAdapter(system_adapter);
- }
-
- //----------------------------------------------------------------------------
- SystemAdapterPtr Canvas::getSystemAdapter() const
- {
- return _system_adapter;
- }
-
//----------------------------------------------------------------------------
void Canvas::setCanvasMgr(CanvasMgr* canvas_mgr)
{
_placement_factories.erase(it);
}
+
+ //----------------------------------------------------------------------------
+ void Canvas::setSystemAdapter(const SystemAdapterPtr& system_adapter)
+ {
+ _system_adapter = system_adapter;
+ }
+
+ //----------------------------------------------------------------------------
+ SystemAdapterPtr Canvas::getSystemAdapter()
+ {
+ return _system_adapter;
+ }
+
//----------------------------------------------------------------------------
void Canvas::setSelf(const PropertyBasedElementPtr& self)
{
//----------------------------------------------------------------------------
Canvas::PlacementFactoryMap Canvas::_placement_factories;
+ SystemAdapterPtr Canvas::_system_adapter;
} // namespace canvas
} // namespace simgear
virtual ~Canvas();
virtual void onDestroy();
- void setSystemAdapter(const SystemAdapterPtr& system_adapter);
- SystemAdapterPtr getSystemAdapter() const;
-
void setCanvasMgr(CanvasMgr* canvas_mgr);
CanvasMgr* getCanvasMgr() const;
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;
boost::scoped_ptr<EventManager> _event_manager;
private:
+ static SystemAdapterPtr _system_adapter;
+
Canvas(const Canvas&); // = delete;
Canvas& operator=(const Canvas&); // = delete;
};
}
//----------------------------------------------------------------------------
- CanvasMgr::CanvasMgr( SGPropertyNode_ptr node,
- SystemAdapterPtr system_adapter ):
- PropertyBasedMgr(node, "texture", &canvasFactory),
- _system_adapter(system_adapter)
+ CanvasMgr::CanvasMgr(SGPropertyNode_ptr node):
+ PropertyBasedMgr(node, "texture", &canvasFactory)
{
}
void CanvasMgr::elementCreated(PropertyBasedElementPtr element)
{
CanvasPtr canvas = boost::static_pointer_cast<Canvas>(element);
- canvas->setSystemAdapter(_system_adapter);
canvas->setCanvasMgr(this);
}
/**
* @param node Root node of branch used to control canvasses
- * @param system_adapter Adapter for connecting between canvas and
- * application framework
- *
*/
- CanvasMgr( SGPropertyNode_ptr node,
- SystemAdapterPtr system_adapter );
+ CanvasMgr(SGPropertyNode_ptr node);
/**
* Create a new canvas
protected:
- SystemAdapterPtr _system_adapter;
-
virtual void elementCreated(PropertyBasedElementPtr element);
};
#endif
#include "ODGauge.hxx"
+#include "Canvas.hxx"
#include "CanvasSystemAdapter.hxx"
#include <simgear/debug/logstream.hxx>
clear();
}
- //----------------------------------------------------------------------------
- void ODGauge::setSystemAdapter(const SystemAdapterPtr& system_adapter)
- {
- _system_adapter = system_adapter;
- }
-
//----------------------------------------------------------------------------
void ODGauge::setSize(int size_x, int size_y)
{
updateSampling();
updateBlendMode();
- if( _system_adapter )
- _system_adapter->addCamera(camera.get());
+ if( Canvas::getSystemAdapter() )
+ Canvas::getSystemAdapter()->addCamera(camera.get());
_flags |= AVAILABLE;
}
//----------------------------------------------------------------------------
void ODGauge::clear()
{
- if( camera.valid() && _system_adapter )
- _system_adapter->removeCamera(camera.get());
+ if( camera.valid() && Canvas::getSystemAdapter() )
+ Canvas::getSystemAdapter()->removeCamera(camera.get());
camera.release();
texture.release();
ODGauge();
virtual ~ODGauge();
- void setSystemAdapter(const SystemAdapterPtr& system_adapter);
-
/**
* Set the size of the render target.
*
protected:
- SystemAdapterPtr _system_adapter;
-
int _size_x,
_size_y,
_view_width,
}
else
{
- setImage( canvas->getSystemAdapter()->getImage(path) );
+ setImage( Canvas::getSystemAdapter()->getImage(path) );
}
}
}
//----------------------------------------------------------------------------
void Text::setFont(const char* name)
{
- _text->setFont( _canvas.lock()->getSystemAdapter()->getFont(name) );
+ _text->setFont( Canvas::getSystemAdapter()->getFont(name) );
}
//----------------------------------------------------------------------------