]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/Canvas.hxx
Fix #1783: repeated error message on console
[simgear.git] / simgear / canvas / Canvas.hxx
index 2c817f61bcbf98fe17805b505847204df1d41f7f..efcb0a473f38cf53b139baf488e84f2b57a274b2 100644 (file)
@@ -1,4 +1,5 @@
-///@file 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>
 //
@@ -43,6 +44,9 @@ namespace canvas
   class CanvasMgr;
   class MouseEvent;
 
+  /**
+   * Canvas to draw onto (to an off-screen render target).
+   */
   class Canvas:
     public PropertyBasedElement,
     public nasal::Object
@@ -53,8 +57,7 @@ namespace canvas
       {
         STATUS_OK,
         STATUS_DIRTY   = 1,
-        LAYOUT_DIRTY   = STATUS_DIRTY << 1,
-        MISSING_SIZE_X = LAYOUT_DIRTY << 1,
+        MISSING_SIZE_X = STATUS_DIRTY << 1,
         MISSING_SIZE_Y = MISSING_SIZE_X << 1,
         MISSING_SIZE   = MISSING_SIZE_X | MISSING_SIZE_Y,
         CREATE_FAILED  = MISSING_SIZE_Y << 1
@@ -133,6 +136,22 @@ namespace canvas
        */
       void setLayout(const LayoutRef& layout);
 
+      /**
+       * Set the focus to the given element.
+       *
+       * The focus element will receive all keyboard events propagated to this
+       * canvas. If there is no valid focus element the root group will receive
+       * the events instead.
+       */
+      void setFocusElement(const ElementPtr& el);
+
+      /**
+       * Clear the focus element.
+       *
+       * @see setFocusElement()
+       */
+      void clearFocusElement();
+
       /**
        * Enable rendering for the next frame
        *
@@ -160,6 +179,8 @@ namespace canvas
       SGRect<int> getViewport() const;
 
       bool handleMouseEvent(const MouseEventPtr& event);
+      bool handleKeyboardEvent(const KeyboardEventPtr& event);
+
       bool propagateEvent( EventPtr const& event,
                            EventPropagationPath const& path );
 
@@ -211,13 +232,15 @@ namespace canvas
       GroupPtr  _root_group;
       LayoutRef _layout;
 
+      ElementWeakPtr _focus_element;
+
       CullCallbackPtr _cull_callback;
-      bool _render_always; //<! Used to disable automatic lazy rendering (culling)
+      bool _render_always; //!< Used to disable automatic lazy rendering (culling)
 
       std::vector<SGPropertyNode*> _dirty_placements;
       std::vector<Placements> _placements;
-      std::set<CanvasWeakPtr> _parent_canvases, //<! Canvases showing this canvas
-                              _child_canvases;  //<! Canvases displayed within
+      std::set<CanvasWeakPtr> _parent_canvases, //!< Canvases showing this canvas
+                              _child_canvases;  //!< Canvases displayed within
                                                 //   this canvas
 
       typedef std::map<std::string, PlacementFactory> PlacementFactoryMap;