-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathVisualNode.h
More file actions
152 lines (111 loc) · 3.83 KB
/
Copy pathVisualNode.h
File metadata and controls
152 lines (111 loc) · 3.83 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#pragma once
#include "VisualNodeSocket.h"
namespace VisNodeSys
{
enum NODE_STYLE
{
DEFAULT = 0,
CIRCLE = 1
};
#define NODE_NAME_MAX_LENGTH 1024
#define NODE_TITLE_HEIGHT 30.0f
#define NODE_DIAMETER 72.0f
#define NODE_HEIGHT_PER_SOCKET 40
enum NODE_SOCKET_EVENT
{
CONNECTED = 0,
DISCONNECTED = 1,
DESTRUCTION = 2,
UPDATE = 3,
EXECUTE = 4
};
class VISUAL_NODE_SYSTEM_API Node
{
protected:
friend class NodeFactory;
friend class NodeSystem;
friend class NodeArea;
friend class LinkNode;
virtual ~Node();
NodeArea* ParentArea = nullptr;
std::string ID;
ImVec2 Position;
ImVec2 Size;
ImVec2 ClientRegionMin;
ImVec2 ClientRegionMax;
std::string Name;
std::string Type;
bool bShouldBeDestroyed = false;
bool bCouldBeDestroyedByUser = true;
bool bCouldBeCopiedByUser = true;
bool bCouldBeMovedByUser = true;
std::vector<NodeSocket*> Input;
std::vector<NodeSocket*> Output;
ImVec2 LeftTop;
ImVec2 RightBottom;
ImColor TitleBackgroundColor = ImColor(120, 150, 25);
ImColor TitleBackgroundColorHovered = ImColor(140, 190, 35);
bool bHovered = false;
void SetIsHovered(bool bNewValue);
NODE_STYLE Style = DEFAULT;
bool bRenderTitleBar = true;
// -1.0f means no override, use default value based on node style.
float MaxInputLabelWidth = -1.0f;
float MaxOutputLabelWidth = -1.0f;
float TitleBarAvailableWidth = -1.0f;
float TitleBarHeight = -1.0f;
virtual void Draw();
virtual bool IsValidAsNewConnection(NodeSocket* OwnSocket, NodeSocket* CandidateSocket);
virtual bool CanConnect(NodeSocket* OwnSocket, NodeSocket* CandidateSocket, char** MsgToUser = nullptr);
virtual void SocketEvent(NodeSocket* OwnSocket, NodeSocket* ConnectedSocket, NODE_SOCKET_EVENT EventType);
virtual bool OpenContextMenu();
void UpdateClientRegion();
static bool IsNodeWithIDInList(std::string ID, std::vector<Node*> List);
void SetToDefaultState();
public:
Node(std::string ID = "");
Node(const Node& Other);
std::string GetID() const;
ImVec2 GetPosition() const;
void SetPosition(ImVec2 NewValue);
ImVec2 GetSize() const;
void SetSize(ImVec2 NewValue);
ImVec2 GetClientRegionSize();
ImVec2 GetClientRegionPosition();
virtual std::string GetName() const;
virtual void SetName(std::string NewValue);
std::string GetType() const;
NODE_STYLE GetStyle() const;
void SetStyle(NODE_STYLE NewValue);
float GetMaxInputLabelWidth() const;
void SetMaxInputLabelWidth(float NewValue);
float GetMaxOutputLabelWidth() const;
void SetMaxOutputLabelWidth(float NewValue);
float GetTitleBarHeight() const;
void SetTitleBarHeight(float NewValue);
float GetTitleBarAvailableWidth() const;
void SetTitleBarAvailableWidth(float NewValue);
bool GetRenderTitleBar() const;
void SetRenderTitleBar(bool bNewValue);
virtual bool AddSocket(NodeSocket* Socket);
virtual bool DeleteSocket(NodeSocket* Socket);
virtual bool DeleteSocket(std::string SocketID);
virtual Json::Value ToJson();
virtual bool FromJson(Json::Value Json);
NodeSocket* GetSocketByID(std::string SocketID) const;
size_t GetSocketIndexByID(std::string SocketID) const;
NodeSocket* GetSocketByIndex(size_t SocketIndex, NodeSocket::SocketFlow FlowDirection) const;
std::string GetSocketIDByIndex(size_t SocketIndex, NodeSocket::SocketFlow FlowDirection) const;
size_t GetInputSocketCount() const;
std::vector<std::pair<size_t, std::vector<std::string>>> GetInputSocketTypes() const;
std::vector<Node*> GetNodesConnectedToInput() const;
size_t GetOutputSocketCount() const;
std::vector<std::pair<size_t, std::vector<std::string>>> GetOutputSocketTypes() const;
std::vector<Node*> GetNodesConnectedToOutput() const;
bool IsHovered() const;
bool CouldBeMoved() const;
void SetCouldBeMoved(bool bNewValue);
bool CouldBeDestroyed() const;
NodeArea* GetParentArea() const;
};
}