dragging works. introducing connectors maybe

This commit is contained in:
Sebastian
2024-11-10 01:56:33 +01:00
parent 71dc08d21f
commit 4f48aa2d5a
11 changed files with 493 additions and 375 deletions
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "interactable.h"
#include "moveable.h"
#include "vmath.h"
namespace VISEQ::BASE {
class Draggable : public Movable, public Interactable{
public:
Draggable() {}
Draggable(float x, float y) : Movable(Vec2Df(x, y), 960.0f) {}
Draggable(Vec2Df p) : Movable(p, 960.0f) {}
virtual ~Draggable() {}
Vec2Df drag_offset;
bool picked_up = false;
virtual bool pickedUp() {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
if(clicked() && held()) {
picked_up = true;
drag_offset = position - mp;
}
return picked_up;
}
virtual void drag() {
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
position = mp + drag_offset;
}
virtual void putDown(){
picked_up = false;
}
};
}