little progress on the connector idea

This commit is contained in:
Sebastian
2024-11-11 02:11:54 +01:00
parent 4f48aa2d5a
commit 31a1a264d4
4 changed files with 19 additions and 17 deletions
+7 -5
View File
@@ -1,15 +1,17 @@
#pragma once
#include "draggable.h"
namespace VISEQ::BASE {
class Connectable{
class Connectable : public Draggable{
public:
Connectable() {}
virtual ~Connectable() {}
std::shared_ptr<Connectable> partner;
virtual void draw(){
virtual void drag() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
}
};
}
+10 -9
View File
@@ -1,17 +1,18 @@
#pragma once
#include "draggable.h"
#include "edge.h"
#include "connectable.h"
#include "interactable.h"
#include "moveable.h"
#include "raymath.h"
#include "vmath.h"
#include <memory>
namespace VISEQ::GRAPH {
class Connector : public BASE::Draggable{
class Connector : public BASE::Connectable{
public:
Connector() {}
Connector(float orbit) : orbit(orbit) {}
Connector(Vec2Df position, float orbit) : Movable(position, 0.0f), orbit(orbit) {}
std::shared_ptr<Connector> partner;
float radius = 5.0f;
float orbit = 14.0f;
@@ -26,14 +27,14 @@ namespace VISEQ::GRAPH {
}
void update() override{
if(pickedUp()) drag();
if(released()) putDown();
}
void draw() {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
Vec2Df connector = position - ((position - mouse)).norm() * (radius + orbit);
float opacity = 150.0f - Clamp(position.dist(mouse), 0.0f, 150.0f);
Vec2Df connector = position - ((position - mp)).norm() * (radius + orbit);
float opacity = 150.0f - Clamp(position.dist(mp), 0.0f, 150.0f);
if(hover_connect){
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, 255});
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "raylib.h"
#include "vmath.h"
namespace VISEQ::BASE {
class Interactable{
+2 -2
View File
@@ -51,11 +51,11 @@ namespace VISEQ::GRAPH::NODES {
if(pickedUp()) drag();
if(released()) putDown();
for(auto c : connectors){
c->update(position);
c->updatePosition(position);
c->update();
}
}
void draw(Vec2Df mouse_pos, Camera2D cam) override {}
};
typedef std::shared_ptr<VISEQ::GRAPH::NODES::Node> SPTR_Node;