2024-11-10 01:56:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-11-11 02:11:54 +01:00
|
|
|
#include "connectable.h"
|
2024-11-12 01:42:05 +01:00
|
|
|
#include "graph-item.h"
|
2024-11-11 02:11:54 +01:00
|
|
|
#include "raymath.h"
|
2024-11-10 01:56:33 +01:00
|
|
|
#include "vmath.h"
|
|
|
|
|
|
|
|
|
|
namespace VISEQ::GRAPH {
|
2024-11-12 01:42:05 +01:00
|
|
|
class Connector : public BASE::Connectable, public GraphItem{
|
2024-11-10 01:56:33 +01:00
|
|
|
public:
|
|
|
|
|
Connector() {}
|
2024-11-12 01:42:05 +01:00
|
|
|
Connector(Vec2Df position, float orbit) : BASE::Connectable(position), orbit(orbit) {}
|
2024-11-10 01:56:33 +01:00
|
|
|
|
|
|
|
|
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{
|
2024-11-12 01:42:05 +01:00
|
|
|
connect();
|
2024-11-10 01:56:33 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-12 01:42:05 +01:00
|
|
|
void draw() override {
|
2024-11-11 02:11:54 +01:00
|
|
|
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
2024-11-10 01:56:33 +01:00
|
|
|
|
2024-11-11 02:11:54 +01:00
|
|
|
Vec2Df connector = position - ((position - mp)).norm() * (radius + orbit);
|
|
|
|
|
float opacity = 150.0f - Clamp(position.dist(mp), 0.0f, 150.0f);
|
2024-11-10 01:56:33 +01:00
|
|
|
|
|
|
|
|
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});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|