]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/Canvas.hxx
canvas::Text: add heightForWidth method.
[simgear.git] / simgear / canvas / Canvas.hxx
index c350257c0b26833df58f077ea50a5213b6d45baf..2c817f61bcbf98fe17805b505847204df1d41f7f 100644 (file)
@@ -1,4 +1,4 @@
-// The canvas for rendering with the 2d API
+///@file The canvas for rendering with the 2d API
 //
 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
 //
 #include "ODGauge.hxx"
 
 #include <simgear/canvas/elements/CanvasGroup.hxx>
+#include <simgear/canvas/layout/Layout.hxx>
 #include <simgear/math/SGRect.hxx>
+#include <simgear/nasal/cppbind/NasalObject.hxx>
 #include <simgear/props/PropertyBasedElement.hxx>
 #include <simgear/props/propertyObject.hxx>
+
 #include <osg/NodeCallback>
 #include <osg/observer_ptr>
 
 
 namespace simgear
 {
+/// Canvas 2D drawing API
 namespace canvas
 {
   class CanvasMgr;
   class MouseEvent;
 
   class Canvas:
-    public PropertyBasedElement
+    public PropertyBasedElement,
+    public nasal::Object
   {
     public:
 
       enum StatusFlags
       {
         STATUS_OK,
-        STATUS_DIRTY     = 1,
-        MISSING_SIZE_X = STATUS_DIRTY << 1,
+        STATUS_DIRTY   = 1,
+        LAYOUT_DIRTY   = STATUS_DIRTY << 1,
+        MISSING_SIZE_X = LAYOUT_DIRTY << 1,
         MISSING_SIZE_Y = MISSING_SIZE_X << 1,
+        MISSING_SIZE   = MISSING_SIZE_X | MISSING_SIZE_Y,
         CREATE_FAILED  = MISSING_SIZE_Y << 1
       };
 
@@ -120,6 +127,12 @@ namespace canvas
        */
       GroupPtr getRootGroup();
 
+      /**
+       * Set the layout of the canvas (the layout will automatically update with
+       * the viewport size of the canvas)
+       */
+      void setLayout(const LayoutRef& layout);
+
       /**
        * Enable rendering for the next frame
        *
@@ -131,6 +144,7 @@ namespace canvas
       void update(double delta_time_sec);
 
       bool addEventListener(const std::string& type, const EventListener& cb);
+      bool dispatchEvent(const EventPtr& event);
 
       void setSizeX(int sx);
       void setSizeY(int sy);
@@ -146,6 +160,8 @@ namespace canvas
       SGRect<int> getViewport() const;
 
       bool handleMouseEvent(const MouseEventPtr& event);
+      bool propagateEvent( EventPtr const& event,
+                           EventPropagationPath const& path );
 
       virtual void childAdded( SGPropertyNode * parent,
                                SGPropertyNode * child );
@@ -191,7 +207,9 @@ namespace canvas
            _visible;
 
       ODGauge _texture;
-      GroupPtr _root_group;
+
+      GroupPtr  _root_group;
+      LayoutRef _layout;
 
       CullCallbackPtr _cull_callback;
       bool _render_always; //<! Used to disable automatic lazy rendering (culling)
@@ -205,7 +223,6 @@ namespace canvas
       typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;
       static PlacementFactoryMap _placement_factories;
 
-      virtual void setSelf(const PropertyBasedElementPtr& self);
       void setStatusFlags(unsigned int flags, bool set = true);
 
     private: