Files
viseq/src/draggable.h
T

69 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include "moveable.h"
#include "raylib.h"
#include "selectable.h"
#include "state.h"
#include "vmath.h"
namespace VISEQ::BASE {
class Draggable : public Movable, public Selectable{
public:
Draggable() {}
Draggable(float x, float y) : Movable(Vec2Df(x, y), 960.0f) {}
Draggable(Vec2Df p) : Movable(p, 960.0f) {}
virtual ~Draggable() {}
std::shared_ptr<APP::State> state = APP::State::get();
Vec2Df drag_offset;
bool picked_up = false;
2024-11-20 11:13:13 +01:00
virtual bool entered() override {
return !is_hovering && hovering();
}
virtual bool exited() override {
return is_hovering && !hovering();
}
virtual bool pickedUp() {
return held() && picked_up;
}
virtual void pickUp() override {
picked_up = true;
drag_offset = position - SCREEN_MOUSE;
}
virtual void pickUp(Vec2Df selection_origin) override {
picked_up = true;
drag_offset = position - selection_origin;
}
virtual void drag() override {
// state->selection_origin = position;
/*if(KEYS_PRESSED.ctrl){*/
/* selection_offset = position - state->selection_origin;*/
/*}*/
/*if(KEYS_DOWN.ctrl){*/
/* position = MOD_MOUSE + selection_offset;*/
/*} else {*/
position = MOD_MOUSE + drag_offset;
/*}*/
}
virtual void putDown() override {
picked_up = false;
}
virtual bool select() override {
/*in_selection_rect = */
/*if(MOUSE_LEFT.released) selected = (KEYS_DOWN.shift && selected) || in_selection_rect;*/
return CheckCollisionPointRec(position, state->selection);
}
};
}