Files
viseq/src/connectable.h
T

47 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
2024-11-11 02:11:54 +01:00
#include "draggable.h"
2024-11-12 01:42:05 +01:00
#include <memory>
namespace VISEQ::BASE {
2024-11-11 02:11:54 +01:00
class Connectable : public Draggable{
public:
2024-11-12 01:42:05 +01:00
Connectable() {VISEQ::BASE::Connectable::connectables.emplace_back(this);}
Connectable(Vec2Df position) : Draggable(position) {VISEQ::BASE::Connectable::connectables.emplace_back(this);}
virtual ~Connectable() {}
2024-11-11 02:11:54 +01:00
2024-11-12 01:42:05 +01:00
inline static std::vector<std::shared_ptr<Connectable>> connectables;
2024-11-11 02:11:54 +01:00
std::shared_ptr<Connectable> partner;
2024-11-12 01:42:05 +01:00
virtual bool hovering() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
return CheckCollisionPointCircle(mp, position, 5);
}
2024-11-11 02:11:54 +01:00
virtual void drag() override {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
}
2024-11-12 01:42:05 +01:00
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();
// }
}
}
};
}