2024-11-10 01:56:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "moveable.h"
|
2024-11-17 02:40:31 +01:00
|
|
|
#include "raylib.h"
|
|
|
|
|
#include "selectable.h"
|
|
|
|
|
#include "state.h"
|
2024-11-10 01:56:33 +01:00
|
|
|
#include "vmath.h"
|
|
|
|
|
|
|
|
|
|
namespace VISEQ::BASE {
|
2024-11-17 02:40:31 +01:00
|
|
|
class Draggable : public Movable, public Selectable{
|
2024-11-10 01:56:33 +01:00
|
|
|
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() {
|
2024-11-17 02:40:31 +01:00
|
|
|
if(clicked() && held() && state->istate == APP::InteractionState::HOVER_NODE) {
|
2024-11-10 01:56:33 +01:00
|
|
|
picked_up = true;
|
2024-11-14 23:21:04 +01:00
|
|
|
drag_offset = position - state->screen_mouse;
|
2024-11-10 01:56:33 +01:00
|
|
|
}
|
|
|
|
|
return picked_up;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void drag() {
|
2024-11-15 01:49:10 +01:00
|
|
|
if(state->keys_down.ctrl){
|
|
|
|
|
position = state->mod_mouse;
|
|
|
|
|
} else {
|
|
|
|
|
position = state->mod_mouse + drag_offset;
|
|
|
|
|
}
|
2024-11-10 01:56:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void putDown(){
|
|
|
|
|
picked_up = false;
|
|
|
|
|
}
|
2024-11-17 02:40:31 +01:00
|
|
|
|
|
|
|
|
virtual void select() override {
|
|
|
|
|
selected = (state->keys_down.shift && selected) || CheckCollisionPointRec(position, state->selection);
|
|
|
|
|
/**/
|
|
|
|
|
/*//std::cout << "select" << std::endl;*/
|
|
|
|
|
/*if(CheckCollisionPointRec(position, state->selection)) {*/
|
|
|
|
|
/* in_selection_rect = true;*/
|
|
|
|
|
/*} else {*/
|
|
|
|
|
/* in_selection_rect = false;*/
|
|
|
|
|
/*}*/
|
|
|
|
|
/*if(released() && in_selection_rect) selected = true;*/
|
|
|
|
|
/*if(released() && !in_selection_rect) selected = false;*/
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-10 01:56:33 +01:00
|
|
|
};
|
|
|
|
|
}
|