-///@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>
//
class CanvasMgr;
class MouseEvent;
+ /**
+ * Canvas to draw onto (to an off-screen render target).
+ */
class Canvas:
public PropertyBasedElement,
public nasal::Object
{
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
*/
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
*
SGRect<int> getViewport() const;
bool handleMouseEvent(const MouseEventPtr& event);
+ bool handleKeyboardEvent(const KeyboardEventPtr& event);
+
bool propagateEvent( EventPtr const& event,
EventPropagationPath const& path );
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;