Connectables working now. On to more refactoring!
This commit is contained in:
+10
-3
@@ -18,14 +18,18 @@ namespace VISEQ::GRAPH::NODES {
|
||||
class Node : public BASE::Draggable, public GraphItem{
|
||||
|
||||
public:
|
||||
Node() {addConnector();}
|
||||
Node(float x, float y) : Draggable(Vec2Df(x, y)) {addConnector();}
|
||||
Node(Vec2Df p) : Draggable(p) {addConnector();}
|
||||
Node() {}
|
||||
Node(float x, float y) : Draggable(Vec2Df(x, y)) {}
|
||||
Node(Vec2Df p) : Draggable(p) {}
|
||||
|
||||
void addConnector() {
|
||||
connectors.emplace_back(std::make_shared<Connector>(position, radius + 5.0f));
|
||||
connectors.back()->init();
|
||||
}
|
||||
|
||||
void init() {
|
||||
addConnector();
|
||||
}
|
||||
|
||||
NodeType nodeType;
|
||||
|
||||
@@ -55,10 +59,13 @@ namespace VISEQ::GRAPH::NODES {
|
||||
void update() override{
|
||||
if(pickedUp()) drag();
|
||||
if(released()) putDown();
|
||||
int free_connectors = 0;
|
||||
for(auto c : connectors){
|
||||
if(!c->partner) free_connectors++;
|
||||
c->setPosition(position);
|
||||
c->update();
|
||||
}
|
||||
if(free_connectors == 0) addConnector();
|
||||
}
|
||||
|
||||
void draw(Vec2Df mp, Camera2D cam) override {}
|
||||
|
||||
Reference in New Issue
Block a user