-
Notifications
You must be signed in to change notification settings - Fork 5
/
VisualNodeSocket.h
119 lines (89 loc) · 2.52 KB
/
VisualNodeSocket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include "VisualNodeCore.h"
namespace VisNodeSys
{
#define NODE_SOCKET_SIZE 5.0f
#define DEFAULT_NODE_SOCKET_COLOR ImColor(150, 150, 150)
#define DEFAULT_CONNECTION_COLOR ImColor(200, 200, 200)
#define DEFAULT_NODE_SOCKET_MOUSE_HOVERED_CONNECTION_COLOR ImColor(220, 220, 220)
class Node;
class VISUAL_NODE_SYSTEM_API NodeSocket
{
friend class NodeSystem;
friend class NodeArea;
friend Node;
std::string ID;
bool bOutput = false;
std::string Type;
std::string Name;
std::vector<NodeSocket*> ConnectedSockets;
static std::unordered_map<std::string, ImColor> SocketTypeToColorAssosiations;
std::function<void* ()> OutputData = []() { return nullptr; };
protected:
Node* Parent = nullptr;
public:
NodeSocket(Node* Parent, std::string Type, std::string Name, bool bOutput = false, std::function<void* ()> OutputDataFunction = []() { return nullptr; });
Node* GetParent() const;
std::vector<NodeSocket*> GetConnectedSockets();
std::string GetID() const;
std::string GetName() const;
std::string GetType() const;
bool isOutput() const { return bOutput; }
bool isInput() const { return !bOutput; }
void SetFunctionToOutputData(std::function<void* ()> NewFunction);
void* GetData() { return OutputData(); }
};
struct ConnectionStyle
{
ImColor ForceColor = DEFAULT_CONNECTION_COLOR;
bool bMarchingAntsEffect = false;
float MarchingAntsSpeed = 1.0f;
bool bMarchingAntsReverseDirection = false;
bool bPulseEffect = false;
float PulseSpeed = 1.0f;
float PulseMin = 0.1f;
float PulseMax = 1.0f;
};
class NodeArea;
class Connection;
class RerouteNode
{
friend class NodeSystem;
friend class NodeArea;
friend class Connection;
friend Node;
std::string ID;
Connection* Parent = nullptr;
ImVec2 Position;
NodeSocket* BeginSocket = nullptr;
RerouteNode* BeginReroute = nullptr;
NodeSocket* EndSocket = nullptr;
RerouteNode* EndReroute = nullptr;
bool bHovered = false;
bool bSelected = false;
RerouteNode() {};
};
struct ConnectionSegment
{
ImVec2 Begin;
ImVec2 End;
NodeSocket* BeginSocket = nullptr;
RerouteNode* BeginReroute = nullptr;
NodeSocket* EndSocket = nullptr;
RerouteNode* EndReroute = nullptr;
};
class Connection
{
friend class NodeSystem;
friend class NodeArea;
friend Node;
NodeSocket* Out = nullptr;
NodeSocket* In = nullptr;
bool bHovered = false;
bool bSelected = false;
ConnectionStyle Style;
std::vector<RerouteNode*> RerouteNodes;
Connection(NodeSocket* Out, NodeSocket* In);
~Connection();
};
}