0.2.0
Loading...
Searching...
No Matches
BlueprintNodeBuilder.hpp
1//------------------------------------------------------------------------------
2// LICENSE
3// This software is dual-licensed to the public domain and under the following
4// license: you are granted a perpetual, irrevocable license to copy, modify,
5// publish, and distribute this file as you see fit.
6//
7// CREDITS
8// Written by Michal Cichon
9//------------------------------------------------------------------------------
10#pragma once
11
12//------------------------------------------------------------------------------
13#include <imgui_node_editor.h>
14
15//------------------------------------------------------------------------------
16namespace ax::NodeEditor::Utilities
17{
18//------------------------------------------------------------------------------
19
22{
23 public:
28 explicit BlueprintNodeBuilder(ImTextureID texture = nullptr, int textureWidth = 0, int textureHeight = 0);
29
32 void Begin(ax::NodeEditor::NodeId id);
33
35 void End();
36
39 void Header(const ImVec4& color = ImVec4(1, 1, 1, 1));
40
42 void EndHeader();
43
46 void Input(ax::NodeEditor::PinId id);
48 static void EndInput();
49
51 void Middle();
52
55 void Output(ax::NodeEditor::PinId id);
57 static void EndOutput();
58
59 private:
61 enum class Stage
62 {
63 Invalid,
64 Begin,
65 Header,
66 Content,
67 Input,
68 Output,
69 Middle,
70 End
71 };
72
76 bool SetStage(Stage stage);
77
81 static void Pin(ax::NodeEditor::PinId id, ax::NodeEditor::PinKind kind);
83 static void EndPin();
84
85 ImTextureID HeaderTextureId;
86 int HeaderTextureWidth;
87 int HeaderTextureHeight;
88 NodeId CurrentNodeId = 0;
89 Stage CurrentStage = Stage::Invalid;
90 ImU32 HeaderColor = IM_COL32(255, 255, 255, 0);
91 ImVec2 NodeMin;
92 ImVec2 NodeMax;
93 ImVec2 HeaderMin;
94 ImVec2 HeaderMax;
95 ImVec2 ContentMin;
96 ImVec2 ContentMax;
97 bool HasHeader = false;
98};
99
100//------------------------------------------------------------------------------
101} // namespace ax::NodeEditor::Utilities
Node Builder class.
Definition BlueprintNodeBuilder.hpp:22
void Output(ax::NodeEditor::PinId id)
Begins building an output pin.
void Begin(ax::NodeEditor::NodeId id)
Begins building a node.
void Middle()
Begins building of the middle of the node.
void Input(ax::NodeEditor::PinId id)
Begins building an input pin.
static void EndInput()
Ends building the input pin.
void EndHeader()
Ends building the header.
BlueprintNodeBuilder(ImTextureID texture=nullptr, int textureWidth=0, int textureHeight=0)
Constructor.
static void EndOutput()
Ends building the output pin.
void Header(const ImVec4 &color=ImVec4(1, 1, 1, 1))
Begins building the header.