|
|
@@ -12,6 +12,27 @@
|
|
|
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
|
|
|
static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
|
|
|
|
|
|
+struct Node
|
|
|
+{
|
|
|
+ int ID;
|
|
|
+ char Name[32];
|
|
|
+ ImVec2 Pos, Size;
|
|
|
+ float Value;
|
|
|
+ int InputsCount, OutputsCount;
|
|
|
+
|
|
|
+ Node(int id, const char* name, const ImVec2& pos, float value, int inputs_count, int outputs_count) { ID = id; strncpy(Name, name, 31); Name[31] = 0; Pos = pos; Value = value; InputsCount = inputs_count; OutputsCount = outputs_count; }
|
|
|
+
|
|
|
+ ImVec2 GetInputSlotPos(int slot_no) const { return ImVec2(Pos.x, Pos.y + Size.y * ((float)slot_no+1) / ((float)InputsCount+1)); }
|
|
|
+ ImVec2 GetOutputSlotPos(int slot_no) const { return ImVec2(Pos.x + Size.x, Pos.y + Size.y * ((float)slot_no+1) / ((float)OutputsCount+1)); }
|
|
|
+};
|
|
|
+
|
|
|
+struct NodeLink
|
|
|
+{
|
|
|
+ int InputIdx, InputSlot, OutputIdx, OutputSlot;
|
|
|
+
|
|
|
+ NodeLink(int input_idx, int input_slot, int output_idx, int output_slot) { InputIdx = input_idx; InputSlot = input_slot; OutputIdx = output_idx; OutputSlot = output_slot; }
|
|
|
+};
|
|
|
+
|
|
|
// Really dumb data structure provided for the example.
|
|
|
// Note that we storing links are INDICES (not ID) to make example code shorter, obviously a bad idea for any general purpose code.
|
|
|
void ShowExampleAppCustomNodeGraph(bool* opened)
|
|
|
@@ -23,26 +44,6 @@ void ShowExampleAppCustomNodeGraph(bool* opened)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- struct Node
|
|
|
- {
|
|
|
- int ID;
|
|
|
- char Name[32];
|
|
|
- ImVec2 Pos, Size;
|
|
|
- float Value;
|
|
|
- int InputsCount, OutputsCount;
|
|
|
-
|
|
|
- Node(int id, const char* name, const ImVec2& pos, float value, int inputs_count, int outputs_count) { ID = id; strncpy(Name, name, 31); Name[31] = 0; Pos = pos; Value = value; InputsCount = inputs_count; OutputsCount = outputs_count; }
|
|
|
-
|
|
|
- ImVec2 GetInputSlotPos(int slot_no) const { return ImVec2(Pos.x, Pos.y + Size.y * ((float)slot_no+1) / ((float)InputsCount+1)); }
|
|
|
- ImVec2 GetOutputSlotPos(int slot_no) const { return ImVec2(Pos.x + Size.x, Pos.y + Size.y * ((float)slot_no+1) / ((float)OutputsCount+1)); }
|
|
|
- };
|
|
|
- struct NodeLink
|
|
|
- {
|
|
|
- int InputIdx, InputSlot, OutputIdx, OutputSlot;
|
|
|
-
|
|
|
- NodeLink(int input_idx, int input_slot, int output_idx, int output_slot) { InputIdx = input_idx; InputSlot = input_slot; OutputIdx = output_idx; OutputSlot = output_slot; }
|
|
|
- };
|
|
|
-
|
|
|
static ImVector<Node> nodes;
|
|
|
static ImVector<NodeLink> links;
|
|
|
static bool inited = false;
|