Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
Olympe::NodeGraphClipboard Class Reference

Singleton clipboard for node-graph copy / paste operations. More...

#include <Clipboard.h>

Public Member Functions

void CopySelectedNodes (NodeGraph *graph, int graphID)
 Serialise currently selected nodes to JSON and write to the system clipboard.
 
void PasteNodes (NodeGraph *graph, int graphID, float mousePosX, float mousePosY, bool snapToGrid=false, float snapGridSize=16.0f)
 Read the system clipboard, deserialise nodes and create them in the active graph under the current mouse cursor.
 

Static Public Member Functions

static NodeGraphClipboardGet ()
 Returns the singleton instance.
 

Private Member Functions

 NodeGraphClipboard ()=default
 

Static Private Attributes

static const chark_ClipPrefix = "OLYMPE_NG_CLIP:"
 Prefix that marks Olympe node-graph clipboard payloads.
 

Detailed Description

Singleton clipboard for node-graph copy / paste operations.

Definition at line 41 of file Clipboard.h.

Constructor & Destructor Documentation

◆ NodeGraphClipboard()

Olympe::NodeGraphClipboard::NodeGraphClipboard ( )
privatedefault

Member Function Documentation

◆ CopySelectedNodes()

void Olympe::NodeGraphClipboard::CopySelectedNodes ( NodeGraph graph,
int  graphID 
)

Serialise currently selected nodes to JSON and write to the system clipboard.

Parameters
graphActive NodeGraph (source of node data and selection).
graphIDActive graph ID (used to resolve ImNodes global UIDs).

If no nodes are selected the clipboard is left unchanged.

Definition at line 70 of file Clipboard.cpp.

References Olympe::CLIP_GRAPH_ID_MULTIPLIER, GetComponentTypeID_Static(), k_ClipPrefix, Olympe::NodeTypeToString(), Olympe::GraphNode::posX, and SYSTEM_LOG.

Referenced by Olympe::NodeGraphPanel::HandleKeyboardShortcuts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get()

NodeGraphClipboard & Olympe::NodeGraphClipboard::Get ( )
static

Returns the singleton instance.

Definition at line 60 of file Clipboard.cpp.

Referenced by Olympe::NodeGraphPanel::HandleKeyboardShortcuts().

+ Here is the caller graph for this function:

◆ PasteNodes()

void Olympe::NodeGraphClipboard::PasteNodes ( NodeGraph graph,
int  graphID,
float  mousePosX,
float  mousePosY,
bool  snapToGrid = false,
float  snapGridSize = 16.0f 
)

Read the system clipboard, deserialise nodes and create them in the active graph under the current mouse cursor.

Parameters
graphActive NodeGraph (destination).
graphIDActive graph ID used to set ImNodes node positions via ImNodes::SetNodeGridSpacePos immediately after creation.
mousePosXPaste anchor X in canvas (grid) space.
mousePosYPaste anchor Y in canvas (grid) space.
snapToGridWhen true, each pasted node position is snapped to the nearest grid cell of size snapGridSize.
snapGridSizeGrid cell size used when snapToGrid is true.

If the clipboard does not contain a valid Olympe payload this is a no-op.

Definition at line 143 of file Clipboard.cpp.

References Olympe::CLIP_GRAPH_ID_MULTIPLIER, GetComponentTypeID_Static(), k_ClipPrefix, Olympe::StringToNodeType(), and SYSTEM_LOG.

Referenced by Olympe::NodeGraphPanel::HandleKeyboardShortcuts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ k_ClipPrefix

const char * Olympe::NodeGraphClipboard::k_ClipPrefix = "OLYMPE_NG_CLIP:"
staticprivate

Prefix that marks Olympe node-graph clipboard payloads.

Definition at line 80 of file Clipboard.h.

Referenced by CopySelectedNodes(), and PasteNodes().


The documentation for this class was generated from the following files: