Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
SharedGraphRenderer.h
Go to the documentation of this file.
1/**
2 * @file SharedGraphRenderer.h
3 * @brief Shared renderer for BlueprintEditor and RuntimeDebugger.
4 * @author Olympe Engine
5 * @date 2026-03-08
6 *
7 * @details
8 * SharedGraphRenderer encapsulates graph rendering logic that is common to
9 * both the BlueprintEditor (edit mode) and the Visual Runtime Debugger (debug
10 * mode). It is configured via a Config struct that enables/disables features
11 * such as read-only mode and runtime node highlighting.
12 *
13 * Usage:
14 * @code
15 * // In BlueprintEditor:
16 * SharedGraphRenderer::Render(doc, ctx,
17 * SharedGraphRenderer::MakeEditorConfig());
18 *
19 * // In NodeGraphPanel (Runtime Debugger):
20 * SharedGraphRenderer::Render(doc, ctx,
21 * SharedGraphRenderer::MakeDebuggerConfig(), activeNodeID);
22 * @endcode
23 *
24 * @note
25 * SharedGraphRenderer is a rendering abstraction layer. When ImNodes is
26 * available (BlueprintEditor / NodeGraphPanel context), implementations should
27 * call the real ImNodes API. In headless builds (tests, server processes) the
28 * render calls are no-ops.
29 *
30 * C++14 compliant - no C++17/20 features.
31 */
32
33#pragma once
34
35namespace Olympe {
36namespace NodeGraph {
37
38// Forward declarations
39class GraphDocument;
40class EditorContext;
41class LocalBlackboard;
42struct NodeData;
43struct LinkData;
44
45/**
46 * @class SharedGraphRenderer
47 * @brief Renderer shared by BlueprintEditor and RuntimeDebugger.
48 *
49 * @details
50 * All methods are static. No instance state is required because the renderer
51 * is purely functional: it reads from GraphDocument and EditorContext and
52 * issues ImNodes / ImGui draw calls.
53 */
55public:
56
57 // -------------------------------------------------------------------------
58 // Configuration
59 // -------------------------------------------------------------------------
60
61 /**
62 * @struct Config
63 * @brief Rendering configuration knobs.
64 */
65 struct Config {
66 bool readOnly = false; ///< Disable node dragging / connection editing.
67 bool showRuntimeHighlight = false; ///< Highlight the active debug node.
68 bool showBlackboardPanel = true; ///< Show the blackboard side panel.
69 bool showToolbar = true; ///< Show the graph toolbar.
70 };
71
72 /**
73 * @brief Returns the default configuration for the BlueprintEditor (full-edit mode).
74 *
75 * readOnly=false, showRuntimeHighlight=false.
76 */
77 static Config MakeEditorConfig();
78
79 /**
80 * @brief Returns the default configuration for the Runtime Debugger (read-only mode).
81 *
82 * readOnly=true, showRuntimeHighlight=true.
83 */
85
86 // -------------------------------------------------------------------------
87 // Rendering
88 // -------------------------------------------------------------------------
89
90 /**
91 * @brief Renders the graph inside the current ImGui window.
92 *
93 * @param doc GraphDocument to render (non-owning). Must not be null.
94 * @param ctx EditorContext (Editor or Debug mode).
95 * @param cfg Rendering configuration.
96 * @param activeNodeID Node to highlight in debug mode (-1 = none).
97 */
98 static void Render(GraphDocument* doc,
99 const EditorContext& ctx,
100 const Config& cfg,
101 int activeNodeID = -1);
102
103 /**
104 * @brief Renders the blackboard variables panel.
105 *
106 * @param bb LocalBlackboard to display. May be null (panel shows empty state).
107 */
108 static void RenderBlackboardPanel(const LocalBlackboard* bb);
109
110private:
111
112 /**
113 * @brief Renders a single node.
114 * @param node Node data.
115 * @param cfg Rendering config (controls highlight, read-only styling).
116 * @param activeNodeID Highlighted node ID (-1 = none).
117 */
118 static void RenderNode(const NodeData& node, const Config& cfg, int activeNodeID);
119
120 /**
121 * @brief Renders a single link between two nodes.
122 * @param link Link data.
123 */
124 static void RenderLink(const LinkData& link);
125
126 /**
127 * @brief Renders the graph toolbar (save/load/auto-layout buttons).
128 * @param doc GraphDocument (commands are dispatched through it).
129 * @param ctx EditorContext (controls which actions are available).
130 */
131 static void RenderToolbar(GraphDocument* doc, const EditorContext& ctx);
132
133 // Prevent instantiation
135};
136
137} // namespace NodeGraph
138} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Simple map-based blackboard for task graph runtime state.
Contexte d'édition pour un graphe.
Main document class for a node graph.
Renderer shared by BlueprintEditor and RuntimeDebugger.
static Config MakeDebuggerConfig()
Returns the default configuration for the Runtime Debugger (read-only mode).
static void Render(GraphDocument *doc, const EditorContext &ctx, const Config &cfg, int activeNodeID=-1)
Renders the graph inside the current ImGui window.
static Config MakeEditorConfig()
Returns the default configuration for the BlueprintEditor (full-edit mode).
static void RenderBlackboardPanel(const LocalBlackboard *bb)
Renders the blackboard variables panel.
static void RenderLink(const LinkData &link)
Renders a single link between two nodes.
static void RenderToolbar(GraphDocument *doc, const EditorContext &ctx)
Renders the graph toolbar (save/load/auto-layout buttons).
static void RenderNode(const NodeData &node, const Config &cfg, int activeNodeID)
Renders a single node.
< Provides AssetID and INVALID_ASSET_ID
bool readOnly
Disable node dragging / connection editing.
bool showRuntimeHighlight
Highlight the active debug node.
bool showBlackboardPanel
Show the blackboard side panel.