43 lines
823 B
C++
43 lines
823 B
C++
#pragma once
|
|
|
|
#include "draggable.h"
|
|
#include "vmath.h"
|
|
#include <memory>
|
|
|
|
namespace VISEQ::BASE {
|
|
class Connectable : public Draggable {
|
|
public:
|
|
Connectable() {}
|
|
Connectable(Vec2Df position) : Draggable(position) {}
|
|
|
|
std::weak_ptr<Connectable> partner;
|
|
|
|
bool new_partner = false;
|
|
bool connecting = false;
|
|
bool connected = false;
|
|
|
|
Vec2Df connecting_position;
|
|
|
|
virtual void drag(Vec2Df new_position) override {
|
|
connecting = true;
|
|
connecting_position = new_position;
|
|
}
|
|
|
|
void putDown() override {
|
|
connect();
|
|
Draggable::putDown();
|
|
}
|
|
|
|
virtual void connect() {
|
|
if(picked_up){
|
|
connecting = false;
|
|
connected = true;
|
|
}
|
|
}
|
|
|
|
virtual void draw(){
|
|
if(connecting) DrawLineV(position, connecting_position, (Color){229, 181, 103, 255});
|
|
}
|
|
};
|
|
}
|