Super simple events added. Seems to be a good way for handling interaction. Modified a few base classes.
This commit is contained in:
+15
-3
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "connectable.h"
|
||||
#include "datatypes.h"
|
||||
#include "graph-item.h"
|
||||
#include "moveable.h"
|
||||
#include "raymath.h"
|
||||
#include "state.h"
|
||||
#include "vmath.h"
|
||||
@@ -9,13 +11,17 @@
|
||||
namespace VISEQ::GRAPH {
|
||||
class Connector : public BASE::Connectable, public GraphItem{
|
||||
public:
|
||||
using GraphItem::state;
|
||||
using BASE::Movable::state;
|
||||
|
||||
Connector() {}
|
||||
Connector(std::shared_ptr<GraphItem> parent, Vec2Df center_position, float orbit) : orbit(orbit) {
|
||||
setPosition(center_position);
|
||||
setParent(parent);
|
||||
}
|
||||
|
||||
GraphItemType getType() override{
|
||||
return GraphItemType::CONNECTOR;
|
||||
}
|
||||
|
||||
std::shared_ptr<GraphItem> parent;
|
||||
|
||||
@@ -24,9 +30,13 @@ namespace VISEQ::GRAPH {
|
||||
float radius = 5.0f;
|
||||
float orbit = 14.0f;
|
||||
Vec2Df center_position;
|
||||
|
||||
std::shared_ptr<Connectable> getPtr(){
|
||||
return std::static_pointer_cast<Connector>(shared_from_this());
|
||||
}
|
||||
|
||||
virtual bool hovering() override {
|
||||
return STATE != IState::DRAW_SELECTION && CheckCollisionPointCircle(SCREEN_MOUSE, position, radius);
|
||||
return CheckCollisionPointCircle(SCREEN_MOUSE, position, radius);
|
||||
}
|
||||
|
||||
void setParent(std::shared_ptr<GraphItem> _parent){
|
||||
@@ -40,7 +50,9 @@ namespace VISEQ::GRAPH {
|
||||
}
|
||||
|
||||
void update() override {
|
||||
BASE::Connectable::update();
|
||||
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});
|
||||
}
|
||||
|
||||
void draw() override {
|
||||
|
||||
Reference in New Issue
Block a user