class EE::Scene::SceneNode¶
Overview¶
#include <scenenode.hpp> class SceneNode: public EE::Scene::Node { public: // construction SceneNode(EE::Window::Window* window = NULL); ~SceneNode(); // methods static SceneNode* New(EE::Window::Window* window = NULL); void enableFrameBuffer(); void disableFrameBuffer(); bool ownsFrameBuffer() const; virtual void draw(); virtual void update(const Time& elapsed); void enableDrawInvalidation(); void disableDrawInvalidation(); EE::Window::Window* getWindow(); FrameBuffer* getFrameBuffer() const; void setEventDispatcher(EventDispatcher* eventDispatcher); EventDispatcher* getEventDispatcher() const; void setDrawDebugData(bool debug); bool getDrawDebugData() const; void setDrawBoxes(bool draw); bool getDrawBoxes() const; void setHighlightOver(bool Highlight); bool getHighlightOver() const; void setHighlightFocus(bool Highlight); bool getHighlightFocus() const; void setHighlightInvalidation(bool Highlight); bool getHighlightInvalidation() const; void setHighlightOverColor(const Color& Color); const Color& getHighlightOverColor() const; void setHighlightFocusColor(const Color& Color); const Color& getHighlightFocusColor() const; void setHighlightInvalidationColor(const Color& Color); const Color& getHighlightInvalidationColor() const; const Time& getElapsed() const; bool usesInvalidation() const; void setUseGlobalCursors(bool use); bool getUseGlobalCursors(); void setCursor(Cursor::Type cursor); virtual bool isDrawInvalidator() const; ActionManager* getActionManager() const; void subscribeScheduledUpdate(Node* node); void unsubscribeScheduledUpdate(Node* node); bool isSubscribedForScheduledUpdate(Node* node); void addMouseOverNode(Node* node); void removeMouseOverNode(Node* node); bool getUpdateAllChildren() const; void setUpdateAllChildren(bool updateAllChildren); const Float& getDPI() const; bool getVerbose() const; void setVerbose(bool verbose); };
Inherited Members¶
public: // typedefs typedef std::function<void(const Event*)> EventCallback; // methods virtual void setPosition(const Vector2f& position); virtual void setRotation(float angle); virtual void setScale(float factorX, float factorY); virtual void setScale(const Vector2f& factors); virtual void setScaleOrigin(float x, float y); virtual void setScaleOrigin(const Vector2f& origin); virtual void setRotationOrigin(float x, float y); virtual void setRotationOrigin(const Vector2f& origin); virtual const Vector2f& getRotationOrigin() const; virtual const Vector2f& getPosition() const; virtual const float& getRotation() const; virtual const Vector2f& getScale() const; virtual const Vector2f& getScaleOrigin() const; void move(float offsetX, float offsetY); void move(const Vector2f& offset); void rotate(float angle); void scale(float factorX, float factorY); void scale(const Vector2f& factor); const Transform& getTransform() const; const Transform& getInverseTransform() const; static Node* New(); virtual void worldToNodeTranslation(Vector2f& position) const; virtual void nodeToWorldTranslation(Vector2f& position) const; virtual void worldToNode(Vector2i& pos) const; virtual void nodeToWorld(Vector2i& pos) const; virtual void worldToNode(Vector2f& pos) const; virtual void nodeToWorld(Vector2f& pos) const; virtual Uint32 getType() const; virtual bool isType(const Uint32& type) const; void messagePost(const NodeMessage* Msg); virtual void setPosition(const Vector2f& Pos); virtual Node* setPosition(const Float& x, const Float& y); virtual Node* setSize(const Sizef& size); Node* setSize(const Float& Width, const Float& Height); virtual const Sizef& getSize() const; const Sizef& getPixelsSize() const; Node* setVisible(const bool& visible, bool emitEventNotification = true); Node* setChildrenVisibility(bool visible, bool emitEventNotification = true); bool isVisible() const; bool hasVisibility() const; Node* setEnabled(const bool& enabled); bool isEnabled() const; bool isDisabled() const; Node* getParent() const; Node* setParent(Node* parent); virtual void close(); virtual void draw(); virtual void update(const Time& time); virtual void scheduledUpdate(const Time& time); Node* getNextNode() const; Node* getPrevNode() const; Node* getNextNodeLoop() const; Node* setData(const UintPtr& data); const UintPtr& getData() const; Node* setBlendMode(const BlendMode& blend); const BlendMode& getBlendMode() const; Node* toFront(); Node* toBack(); void toPosition(const Uint32& position); const Uint32& getNodeFlags() const; void setNodeFlags(const Uint32& flags); bool isSceneNode() const; bool isUISceneNode() const; bool isUINode() const; bool isWidget() const; bool isWindow() const; bool isLayout() const; bool isClipped() const; bool isRotated() const; bool isScaled() const; bool isFrameBuffer() const; bool isMouseOver() const; bool isMouseOverMeOrChildren() const; bool isMeOrParentTreeVisible() const; bool isMeOrParentTreeRotated() const; bool isMeOrParentTreeScaled() const; bool isMeOrParentTreeScaledOrRotated() const; bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer() const; Uint32 addEventListener(const Uint32& eventType, const EventCallback& callback); Uint32 on(const Uint32& eventType, const EventCallback& callback); Uint32 onClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); Uint32 onDoubleClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); void removeEventsOfType(const Uint32& eventType); void removeEventListener(const Uint32& callbackId); void removeEventListener(const std::vector<Uint32>& callbacksIds); void clearEventListener(); Node* getFirstChild() const; Node* getLastChild() const; const Polygon2f& getWorldPolygon(); const Rectf& getWorldBounds(); bool isParentOf(const Node* node) const; void sendEvent(const Event* Event); void sendMouseEvent(const Uint32& Event, const Vector2i& position, const Uint32& flags); void sendCommonEvent(const Uint32& Event); void sendTextEvent(const Uint32& event, const std::string& text); void closeAllChildren(); const std::string& getId() const; virtual Node* setId(const std::string& id); const String::HashType& getIdHash() const; Node* find(const std::string& id) const; Node* hasChild(const std::string& id) const; template <typename T> T* find(const std::string& id) const; template <typename T> T* bind(const std::string& id, T*& node); template <typename T> T* asType(); template <typename T> const T* asConstType() const; Node* findByType(const Uint32& type) const; template <typename T> T* findByType(const Uint32& type) const; template <typename T> T* bindByType(const Uint32& type, T*& node); std::vector<Node*> findAllByType(const Uint32& type) const; template <typename T> std::vector<T*> findAllByType(const Uint32& type) const; bool inNodeTree(Node* node) const; bool isReverseDraw() const; void setReverseDraw(bool reverseDraw); void invalidateDraw(); virtual void setRotation(float angle); void setRotation(const Float& angle, const OriginPoint& center); const OriginPoint& getRotationOriginPoint() const; void setRotationOriginPoint(const OriginPoint& center); void setRotationOriginPointPixels(const OriginPoint& center); void setRotationOriginPointX(const std::string& xEq); void setRotationOriginPointY(const std::string& yEq); Vector2f getRotationCenter() const; void setScale(const Float& scale); virtual void setScale(const Vector2f& scale); void setScale(const Vector2f& scale, const OriginPoint& center); void setScale(const Float& scale, const OriginPoint& center); const OriginPoint& getScaleOriginPoint() const; void setScaleOriginPoint(const OriginPoint& center); void setScaleOriginPointPixels(const OriginPoint& center); void setScaleOriginPointX(const std::string& xEq); void setScaleOriginPointY(const std::string& yEq); Vector2f getScaleCenter() const; virtual void setScale(float factorX, float factorY); virtual void setScaleOrigin(float x, float y); virtual void setRotationOrigin(float x, float y); const Float& getAlpha() const; virtual void setAlpha(const Float& alpha); virtual void setChildrenAlpha(const Float& alpha); ActionManager* getActionManager() const; Node* runAction(Action* action); bool removeAction(Action* action); bool removeActions(const std::vector<Action*>& actions); bool removeActionsByTag(const Action::UniqueID& tag); std::vector<Action*> getActions(); std::vector<Action*> getActionsByTag(const Action::UniqueID& tag); void clearActions(); Transform getLocalTransform() const; Transform getGlobalTransform() const; Transform getNodeToWorldTransform() const; Transform getWorldToNodeTransform() const; Vector2f convertToNodeSpace(const Vector2f& worldPoint) const; Vector2f convertToWorldSpace(const Vector2f& nodePoint) const; Rectf getLocalBounds() const; bool hasFocus() const; bool hasFocusWithin() const; virtual Node* setFocus(NodeFocusReason reason = NodeFocusReason::Unknown); Node* getFirstWidget() const; Node* getParentWidget() const; void enableReportSizeChangeToChildren(); void disableReportSizeChangeToChildren(); bool reportSizeChangeToChildren() const; Node* centerHorizontal(); Node* centerVertical(); Node* center(); Node* clipEnable(); Node* clipDisable(); void writeNodeFlag(const Uint32& Flag, const Uint32& Val); SceneNode* getSceneNode() const; EventDispatcher* getEventDispatcher() const; virtual bool isDrawInvalidator() const; bool invalidated() const; virtual void invalidate(Node* invalidator); Uint32 getChildCount() const; Uint32 getChildOfTypeCount(const Uint32& type) const; Node* getChildAt(Uint32 index) const; Uint32 getNodeIndex() const; Uint32 getNodeOfTypeIndex() const; void runOnMainThread(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); bool ensureMainThread(Actions::Runnable::RunnableFunc runnable, const Action::UniqueID& uniqueIdentifier = 0); void setTimeout(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); void setInterval(Actions::Runnable::RunnableFunc runnable, const Time& interval, const Action::UniqueID& uniqueIdentifier = 0); void debounce(Actions::Runnable::RunnableFunc runnable, const Time& delay, const Action::UniqueID& uniqueIdentifier); bool isChild(Node* child) const; bool inParentTreeOf(Node* child) const; bool inParentTreeOfType(Uint32 type) const; Node* getParentOfType(Uint32 type) const; void setLoadingState(bool loading); bool isLoadingState() const; virtual void onIdChange(); bool isClosing() const; bool isClosingChildren() const; virtual Node* overFind(const Vector2f& Point); void detach(); void forEachNode(std::function<void(Node*)> func); void forEachChild(std::function<void(Node*)> func); virtual void nodeDraw(); Uint32 forceKeyDown(const KeyEvent& event); Uint32 foceKeyUp(const KeyEvent& event); Uint32 forceTextInput(const TextInputEvent& Event); const Vector2f& getScreenPos() const; Rectf getScreenRect() const; bool hasEventsOfType(const Uint32& eventType) const;
Detailed Documentation¶
Construction¶
SceneNode(EE::Window::Window* window = NULL)
Constructs a SceneNode with an optional window.
Creates a SceneNode that can be used as a root node for rendering and scene management. Optionally specifies which window to use.
Parameters:
window |
Pointer to the window to associate with this scene node. If NULL, uses the current window from Engine. |
~SceneNode()
Destroys the SceneNode and cleans up resources.
Deletes associated action manager, event dispatcher, and frame buffer. Also handles removal from window resize callback and closes children.
Methods¶
static SceneNode* New(EE::Window::Window* window = NULL)
Creates a new SceneNode instance.
This is the factory method for creating SceneNode instances.
Parameters:
window |
Pointer to the window to associate with this scene node. If NULL, uses the current window from Engine. |
Returns:
Pointer to the newly created SceneNode instance.
void enableFrameBuffer()
Enables the use of a frame buffer for off-screen rendering.
Creates a frame buffer if one doesn’t exist. When enabled, rendering will occur to the frame buffer first before being drawn to the screen.
void disableFrameBuffer()
Disables frame buffer usage and deletes the frame buffer.
Turns off off-screen rendering and releases the frame buffer resource.
bool ownsFrameBuffer() const
Checks if the node owns its frame buffer.
Ownership means the scene node created and manages the frame buffer.
Returns:
True if the frame buffer is owned by this node, false otherwise.
virtual void draw()
Draws the scene node and its children.
This is the main rendering method. Handles frame buffer binding, matrix transformations, clipping, and drawing children. Also draws debug visualizations if enabled.
virtual void update(const Time& elapsed)
Updates the scene node and its children.
Called each frame to update the node’s state, actions, event dispatcher, and scheduled updates. Manages the update of children based on mUpdateAllChildren flag.
Parameters:
elapsed |
The time elapsed since the last update. |
void enableDrawInvalidation()
Enables draw invalidation.
When enabled, the node will use dirty rectangle rendering and only redraw regions that have been invalidated. This can improve performance.
void disableDrawInvalidation()
Disables draw invalidation.
When disabled, the entire node will be redrawn every frame.
EE::Window::Window* getWindow()
Gets the window associated with this scene node.
Returns:
Pointer to the Window object.
FrameBuffer* getFrameBuffer() const
Gets the frame buffer used for off-screen rendering.
Returns:
Pointer to the FrameBuffer, or NULL if none is set.
void setEventDispatcher(EventDispatcher* eventDispatcher)
Sets the event dispatcher for this scene node.
The event dispatcher handles input and other events. This allows custom event handling for this scene.
Parameters:
eventDispatcher |
Pointer to the EventDispatcher to set. |
EventDispatcher* getEventDispatcher() const
Gets the event dispatcher.
Returns:
Pointer to the EventDispatcher, or NULL if none set.
void setDrawDebugData(bool debug)
Enables or disables debug data drawing.
When enabled, additional debug information may be rendered (like bounding boxes, invalidation regions, etc.).
Parameters:
debug |
True to enable debug drawing, false to disable. |
bool getDrawDebugData() const
Checks if debug data drawing is enabled.
Returns:
True if debug drawing is enabled, false otherwise.
void setDrawBoxes(bool draw)
Enables or disables drawing of bounding boxes.
When enabled, bounding boxes around nodes may be rendered for debugging purposes.
Parameters:
draw |
True to draw boxes, false to hide them. |
bool getDrawBoxes() const
Checks if bounding boxes are being drawn.
Returns:
True if boxes are drawn, false otherwise.
void setHighlightOver(bool Highlight)
Enables or disables highlighting for mouse-over state.
When enabled and a node is moused over, a highlight effect may be shown.
Parameters:
Highlight |
True to enable highlight on mouse over, false to disable. |
bool getHighlightOver() const
Checks if mouse-over highlighting is enabled.
Returns:
True if highlighting is enabled, false otherwise.
void setHighlightFocus(bool Highlight)
Enables or disables highlighting for focus state.
When enabled and a node has focus, a highlight effect may be shown.
Parameters:
Highlight |
True to enable highlight on focus, false to disable. |
bool getHighlightFocus() const
Checks if focus highlighting is enabled.
Returns:
True if focus highlighting is enabled, false otherwise.
void setHighlightInvalidation(bool Highlight)
Enables or disables highlighting for invalidation regions.
When enabled, areas of the screen that are invalidated (need redrawing) may be highlighted for debugging.
Parameters:
Highlight |
True to enable invalidation highlighting, false to disable. |
bool getHighlightInvalidation() const
Checks if invalidation highlighting is enabled.
Returns:
True if invalidation highlighting is enabled, false otherwise.
void setHighlightOverColor(const Color& Color)
Sets the color used for mouse-over highlighting.
Parameters:
Color |
The highlight color to use. |
const Color& getHighlightOverColor() const
Gets the mouse-over highlight color.
Returns:
The highlight color as a const Color reference.
void setHighlightFocusColor(const Color& Color)
Sets the color used for focus highlighting.
Parameters:
Color |
The highlight color to use. |
const Color& getHighlightFocusColor() const
Gets the focus highlight color.
Returns:
The highlight color as a const Color reference.
void setHighlightInvalidationColor(const Color& Color)
Sets the color used for invalidation highlighting.
Parameters:
Color |
The highlight color to use. |
const Color& getHighlightInvalidationColor() const
Gets the invalidation highlight color.
Returns:
The highlight color as a const Color reference.
const Time& getElapsed() const
Gets the elapsed time since the last frame.
This is the time that was passed to the most recent update() call.
Returns:
The elapsed time as a const Time reference.
bool usesInvalidation() const
Checks if draw invalidation is being used.
When using invalidation, only dirty regions are redrawn.
Returns:
True if invalidation is enabled, false otherwise.
void setUseGlobalCursors(bool use)
Sets whether to use global cursor management.
When enabled, cursor changes are managed globally through the window’s cursor manager. When disabled, cursor changes may be managed locally.
Parameters:
use |
True to use global cursors, false for local cursor handling. |
bool getUseGlobalCursors()
Gets whether global cursor management is enabled.
Returns:
Reference to the boolean indicating global cursor usage.
void setCursor(Cursor::Type cursor)
Sets the cursor type.
Changes the cursor appearance if global cursors are enabled.
Parameters:
cursor |
The cursor type to set (from Cursor::Type). |
virtual bool isDrawInvalidator() const
Checks if this node is a draw invalidator.
SceneNode always returns true, indicating it supports dirty rectangle rendering and will invalidate itself when needed.
Returns:
Always true for SceneNode.
ActionManager* getActionManager() const
Gets the action manager associated with this scene node.
The action manager handles timed actions and animations.
Returns:
Pointer to the ActionManager.
void subscribeScheduledUpdate(Node* node)
Subscribes a node for scheduled updates.
The specified node will receive scheduledUpdate() calls each frame.
Parameters:
node |
Pointer to the node to subscribe. |
void unsubscribeScheduledUpdate(Node* node)
Unsubscribes a node from scheduled updates.
The node will no longer receive scheduledUpdate() calls.
Parameters:
node |
Pointer to the node to unsubscribe. |
bool isSubscribedForScheduledUpdate(Node* node)
Checks if a node is subscribed for scheduled updates.
Parameters:
node |
Pointer to the node to check. |
Returns:
True if the node is subscribed, false otherwise.
void addMouseOverNode(Node* node)
Adds a node to the mouse-over tracking list.
This is used internally to track which nodes are currently under the mouse cursor.
Parameters:
node |
Pointer to the node to track. |
void removeMouseOverNode(Node* node)
Removes a node from the mouse-over tracking list.
Parameters:
node |
Pointer to the node to stop tracking. |
bool getUpdateAllChildren() const
Gets whether all children are updated each frame.
When enabled, all children receive update() calls. When disabled, only specific nodes (like those with scheduled updates) are updated.
Returns:
Reference to the boolean indicating update-all-children mode.
void setUpdateAllChildren(bool updateAllChildren)
Sets whether to update all children each frame.
Controls whether all children receive update() calls or only subscribed nodes.
Parameters:
updateAllChildren |
True to update all children, false to update selectively. |
const Float& getDPI() const
Gets the DPI (dots per inch) of the display.
Returns:
The DPI as a Float.
bool getVerbose() const
Checks if verbose logging is enabled.
When enabled, additional debug messages may be logged.
Returns:
True if verbose logging is enabled, false otherwise.
void setVerbose(bool verbose)
Enables or disables verbose logging.
Controls whether detailed debug information is printed to the log.
Parameters:
verbose |
True to enable verbose logging, false to disable. |