connecting does weird things!

This commit is contained in:
Sebastian
2024-11-12 01:42:05 +01:00
parent 31a1a264d4
commit 96082e1190
5 changed files with 62 additions and 24 deletions
+31 -2
View File
@@ -1,17 +1,46 @@
#pragma once
#include "draggable.h"
#include <memory>
namespace VISEQ::BASE {
class Connectable : public Draggable{
public:
Connectable() {}
Connectable() {VISEQ::BASE::Connectable::connectables.emplace_back(this);}
Connectable(Vec2Df position) : Draggable(position) {VISEQ::BASE::Connectable::connectables.emplace_back(this);}
virtual ~Connectable() {}
inline static std::vector<std::shared_ptr<Connectable>> connectables;
std::shared_ptr<Connectable> partner;
virtual bool hovering() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
return CheckCollisionPointCircle(mp, position, 5);
}
virtual void drag() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
}
virtual void connect() {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
if(picked_up){
DrawLineV(position, mp, (Color){229, 181, 103, 255});
}
if(released()){
std::cout << connectables.size() << std::endl;
// static auto hover_partner = VISEQ::BASE::Connectable::connectables | std::ranges::views::filter([](std::shared_ptr<Connectable> c){ return c->hovering();}) | std::ranges::to<std::vector<std::shared_ptr<Connectable>>>();
// if(hover_partner.empty()){
/*SPTR_Node new_node = app.gm.copyNode(std::dynamic_pointer_cast<MidiNode>(connecting_nodes.front()), target_position);*/
/*new_node->connecting = false;*/
/*app.gm.addConnection(connecting_nodes.front(), new_node);*/
// } else {
// partner = hover_partner.front();
// }
}
}
};
}