On the road to connector -> connector with edges...
This commit is contained in:
@@ -14,6 +14,7 @@ namespace VISEQ::BASE {
|
|||||||
inline static std::vector<std::shared_ptr<Connectable>> connectables;
|
inline static std::vector<std::shared_ptr<Connectable>> connectables;
|
||||||
|
|
||||||
std::shared_ptr<Connectable> partner;
|
std::shared_ptr<Connectable> partner;
|
||||||
|
bool new_partner = false;
|
||||||
|
|
||||||
virtual void init() {
|
virtual void init() {
|
||||||
connectables.emplace_back(this);
|
connectables.emplace_back(this);
|
||||||
@@ -34,6 +35,8 @@ namespace VISEQ::BASE {
|
|||||||
if(c.get() != this && c->hovering()) {
|
if(c.get() != this && c->hovering()) {
|
||||||
partner = c;
|
partner = c;
|
||||||
c->partner.reset(this);
|
c->partner.reset(this);
|
||||||
|
new_partner = true;
|
||||||
|
partner->new_partner = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-12
@@ -4,7 +4,6 @@
|
|||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "graph-item.h"
|
#include "graph-item.h"
|
||||||
#include "interaction-event.h"
|
#include "interaction-event.h"
|
||||||
#include "moveable.h"
|
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
@@ -13,26 +12,24 @@
|
|||||||
namespace VISEQ::GRAPH {
|
namespace VISEQ::GRAPH {
|
||||||
class Connector : public BASE::Connectable, public GraphItem{
|
class Connector : public BASE::Connectable, public GraphItem{
|
||||||
public:
|
public:
|
||||||
using BASE::Movable::state;
|
|
||||||
|
|
||||||
Connector() {}
|
Connector() {}
|
||||||
Connector(std::shared_ptr<GraphItem> parent, Vec2Df center_position, float orbit) : orbit(orbit) {
|
Connector(std::shared_ptr<GraphItem> parent, Vec2Df center_position, float orbit) : orbit(orbit) {
|
||||||
setPosition(center_position);
|
setPosition(center_position);
|
||||||
setParent(parent);
|
setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphItemType getType() override{
|
|
||||||
return GraphItemType::CONNECTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<GraphItem> parent;
|
std::shared_ptr<GraphItem> parent;
|
||||||
|
|
||||||
bool hover_connect = false;
|
bool passable = false;
|
||||||
|
|
||||||
float radius = 5.0f;
|
float radius = 5.0f;
|
||||||
float orbit = 14.0f;
|
float orbit = 14.0f;
|
||||||
Vec2Df center_position;
|
Vec2Df center_position;
|
||||||
|
|
||||||
|
GraphItemType getType() override{
|
||||||
|
return GraphItemType::CONNECTOR;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<Connectable> getPtr(){
|
std::shared_ptr<Connectable> getPtr(){
|
||||||
return std::static_pointer_cast<Connector>(shared_from_this());
|
return std::static_pointer_cast<Connector>(shared_from_this());
|
||||||
}
|
}
|
||||||
@@ -47,8 +44,6 @@ namespace VISEQ::GRAPH {
|
|||||||
|
|
||||||
void setPosition(Vec2Df pos) override {
|
void setPosition(Vec2Df pos) override {
|
||||||
center_position = pos;
|
center_position = pos;
|
||||||
if(!partner) position = center_position - ((center_position - SCREEN_MOUSE)).norm() * (radius + orbit);
|
|
||||||
if(partner) position = center_position - ((center_position - partner->position)).norm() * (radius + orbit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() override {
|
void update() override {
|
||||||
@@ -56,6 +51,13 @@ namespace VISEQ::GRAPH {
|
|||||||
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
||||||
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
||||||
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
||||||
|
|
||||||
|
if(!partner) position = center_position - ((center_position - SCREEN_MOUSE)).norm() * (radius + orbit);
|
||||||
|
if(partner) position = center_position - ((center_position - partner->position)).norm() * (radius + orbit);
|
||||||
|
if(new_partner) {
|
||||||
|
//TODO what happens if a new partner is connected?
|
||||||
|
new_partner = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw() override {
|
void draw() override {
|
||||||
@@ -65,8 +67,8 @@ namespace VISEQ::GRAPH {
|
|||||||
DrawLineV(position, partner->position, VS_COLOR_RED);
|
DrawLineV(position, partner->position, VS_COLOR_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hover_connect){
|
if(hovering()){
|
||||||
DrawCircle(position.x, position.y, 8.0f, (Color){108, 153, 187, 255});
|
DrawCircle(position.x, position.y, 8.0f, (Color){108, 203, 237, 255});
|
||||||
} else {
|
} else {
|
||||||
DrawCircle(position.x, position.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});
|
DrawCircle(position.x, position.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,11 @@ namespace VISEQ::GRAPH {
|
|||||||
counter.clear();
|
counter.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPTR_Node next_node(SPTR_Node current, SPTR_Node last){
|
||||||
|
std::vector<std::shared_ptr<Connector>> active_connectors;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SPTR_Node next(SPTR_Node current, SPTR_Node last){
|
SPTR_Node next(SPTR_Node current, SPTR_Node last){
|
||||||
VEC_SPTR_Edge possible_connections = current->connections | RANGE_FILTER([current](SPTR_Edge c){
|
VEC_SPTR_Edge possible_connections = current->connections | RANGE_FILTER([current](SPTR_Edge c){
|
||||||
return (c->start == current && c->pass_forward) || (c->end == current && c->pass_backward);
|
return (c->start == current && c->pass_forward) || (c->end == current && c->pass_backward);
|
||||||
|
|||||||
Reference in New Issue
Block a user