|
|
@ -11,15 +11,41 @@ |
|
|
|
|
|
|
|
class GuiNode { |
|
|
|
public: |
|
|
|
GuiNode(std::string name, Rect bbox) |
|
|
|
: name(name), bbox(bbox) |
|
|
|
GuiNode(std::string name, Rect bbox, uint n_slots_in, uint n_slots_out) |
|
|
|
: name(name), bbox(bbox), n_slots_in(n_slots_in), n_slots_out(n_slots_out) |
|
|
|
{} |
|
|
|
|
|
|
|
protected: |
|
|
|
friend class NodeEditor; |
|
|
|
enum SlotDirection { |
|
|
|
IN, |
|
|
|
OUT, |
|
|
|
}; |
|
|
|
|
|
|
|
ImVec2 slot_location(SlotDirection direction, uint i) const { |
|
|
|
uint n_slots; |
|
|
|
switch (direction) { |
|
|
|
case IN: |
|
|
|
n_slots = n_slots_in; break; |
|
|
|
case OUT: |
|
|
|
n_slots = n_slots_out; break; |
|
|
|
} |
|
|
|
|
|
|
|
std::string name; |
|
|
|
auto x_stride = bbox.size.y/(n_slots+1); |
|
|
|
|
|
|
|
ImVec2 base; |
|
|
|
switch(direction) { |
|
|
|
case IN: |
|
|
|
base = bbox.pos; break; |
|
|
|
case OUT: |
|
|
|
base = bbox.pos + ImVec2(bbox.size.x, 0); break; |
|
|
|
} |
|
|
|
|
|
|
|
return base + ImVec2(0, (i + 1) * x_stride); |
|
|
|
} |
|
|
|
|
|
|
|
uint n_slots_in; |
|
|
|
uint n_slots_out; |
|
|
|
|
|
|
|
std::string name; |
|
|
|
Rect bbox; |
|
|
|
}; |
|
|
|
|
|
|
|