dragging works. introducing connectors maybe
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "draggable.h"
|
||||
#include "edge.h"
|
||||
#include "vmath.h"
|
||||
#include <memory>
|
||||
|
||||
namespace VISEQ::GRAPH {
|
||||
class Connector : public BASE::Draggable{
|
||||
public:
|
||||
Connector() {}
|
||||
Connector(float orbit) : orbit(orbit) {}
|
||||
|
||||
std::shared_ptr<Connector> partner;
|
||||
|
||||
float radius = 5.0f;
|
||||
float orbit = 14.0f;
|
||||
|
||||
virtual bool hovering() override {
|
||||
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
||||
return CheckCollisionPointCircle(mp, position, radius);
|
||||
}
|
||||
|
||||
void updatePosition(Vec2Df pos){
|
||||
position = pos;
|
||||
}
|
||||
|
||||
void update() override{
|
||||
if(pickedUp()) drag();
|
||||
if(released()) putDown();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
|
||||
Vec2Df connector = position - ((position - mouse)).norm() * (radius + orbit);
|
||||
float opacity = 150.0f - Clamp(position.dist(mouse), 0.0f, 150.0f);
|
||||
|
||||
if(hover_connect){
|
||||
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, 255});
|
||||
} else {
|
||||
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user