Files
viseq/src/draggable.h
T

36 lines
690 B
C++
Raw Normal View History

#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() {
if(clicked() && held()) {
picked_up = true;
2024-11-14 23:21:04 +01:00
drag_offset = position - state->screen_mouse;
}
return picked_up;
}
virtual void drag() {
2024-11-14 00:55:09 +01:00
position = state->mod_mouse + drag_offset;
}
virtual void putDown(){
picked_up = false;
}
};
}