Browse Source

GuiNode: slot location computation, unprotect fields

master
gradient 8 years ago
parent
commit
6654768aa4
1 changed files with 31 additions and 5 deletions
  1. +31
    -5
      src/gui/node_editor.h

+ 31
- 5
src/gui/node_editor.h View File

@ -11,15 +11,41 @@
class GuiNode { class GuiNode {
public: 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; Rect bbox;
}; };


Loading…
Cancel
Save