2024-11-30 02:54:40 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "clipboard.h"
|
|
|
|
|
#include "datatypes.h"
|
|
|
|
|
#include "draggable.h"
|
|
|
|
|
#include "graph-item.h"
|
|
|
|
|
#include "graph-manager.h"
|
|
|
|
|
#include "interaction-event.h"
|
2024-12-03 01:25:49 +01:00
|
|
|
#include "node.h"
|
2024-11-30 02:54:40 +01:00
|
|
|
#include "raylib.h"
|
|
|
|
|
#include "signal-manager.h"
|
|
|
|
|
#include "state.h"
|
|
|
|
|
#include "canvas.h"
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace VISEQ::INTERACTION{
|
2024-12-05 00:01:42 +01:00
|
|
|
class ScaleHandle : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<ScaleHandle>{
|
2024-11-30 02:54:40 +01:00
|
|
|
public:
|
|
|
|
|
ScaleHandle(){}
|
|
|
|
|
|
|
|
|
|
float radius = 6;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ScaleHandle> getPtr(){
|
2024-12-05 00:01:42 +01:00
|
|
|
return shared_from_this();
|
2024-11-30 02:54:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual GRAPH::GraphItemType getType() override {
|
|
|
|
|
return GraphItemType::HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool hovering() override {
|
|
|
|
|
return CheckCollisionPointCircle(SCREEN_MOUSE, position, radius);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void update() override {
|
|
|
|
|
if(hovering()) state->pushEvent({getPtr(), APP::Interaction::HOVER});
|
|
|
|
|
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
|
|
|
|
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
|
|
|
|
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void draw() override {
|
|
|
|
|
DrawCircleV(position, radius, VS_COLOR_SUN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool select() override {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class InteractionManager{
|
|
|
|
|
public:
|
2024-12-04 01:43:06 +01:00
|
|
|
InteractionManager() {}
|
|
|
|
|
InteractionManager(std::shared_ptr<GRAPH::GraphManager> gm, std::shared_ptr<SIGNAL::SignalManager> sm, std::shared_ptr<APP::CANVAS::Canvas> canvas) : canvas(canvas), gm(gm), sm(sm) {}
|
2024-11-30 02:54:40 +01:00
|
|
|
|
|
|
|
|
std::shared_ptr<APP::CANVAS::Canvas> canvas;
|
2024-12-04 01:43:06 +01:00
|
|
|
std::shared_ptr<GraphManager> gm;
|
|
|
|
|
std::shared_ptr<SIGNAL::SignalManager> sm;
|
2024-11-30 02:54:40 +01:00
|
|
|
VISEQ::APP::Clipboard cb;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<APP::State> state = APP::State::get();
|
|
|
|
|
|
|
|
|
|
Vec2Df scale_start;
|
|
|
|
|
std::shared_ptr<ScaleHandle> scale_handle = std::make_shared<ScaleHandle>();
|
|
|
|
|
|
2026-01-06 02:44:18 +01:00
|
|
|
void update();
|
|
|
|
|
void draw();
|
|
|
|
|
void removeNodes(VEC_SPTR_Node nodes);
|
|
|
|
|
void scaleSelection();
|
|
|
|
|
void snapPolar(std::shared_ptr<Node> dragNode);
|
|
|
|
|
void doInteraction();
|
2024-11-30 02:54:40 +01:00
|
|
|
};
|
|
|
|
|
}
|