-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathVisualNode.h
More file actions
118 lines (85 loc) · 2.43 KB
/
VisualNode.h
File metadata and controls
118 lines (85 loc) · 2.43 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
#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
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;
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 bCouldBeDestroyed = true;
bool bCouldBeMoved = true;
static bool bInputCountCheck;
static bool bOutputCountCheck;
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 NewValue);
NODE_STYLE Style = DEFAULT;
virtual void Draw();
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();
ImVec2 GetPosition() const;
void SetPosition(ImVec2 NewValue);
ImVec2 GetSize() const;
void SetSize(ImVec2 NewValue);
ImVec2 GetClientRegionSize();
ImVec2 GetClientRegionPosition();
std::string GetName();
void SetName(std::string NewValue);
std::string GetType() const;
void AddSocket(NodeSocket* Socket);
virtual Json::Value ToJson();
virtual bool FromJson(Json::Value Json);
size_t GetInputSocketCount() const;
size_t GetOutputSocketCount() const;
std::vector<Node*> GetNodesConnectedToInput() const;
std::vector<Node*> GetNodesConnectedToOutput() const;
NODE_STYLE GetStyle() const;
void SetStyle(NODE_STYLE NewValue);
bool IsHovered() const;
bool CouldBeMoved() const;
void SetCouldBeMoved(bool NewValue);
bool CouldBeDestroyed() const;
NodeArea* GetParentArea() const;
};
}