Introduction of mouse.h for z-index mouse events
This commit is contained in:
+3
-1
@@ -4,6 +4,7 @@
|
|||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "graph-manager.h"
|
#include "graph-manager.h"
|
||||||
#include "midi-node.h"
|
#include "midi-node.h"
|
||||||
|
#include "mouse.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "signal-manager.h"
|
#include "signal-manager.h"
|
||||||
@@ -18,13 +19,14 @@ namespace VISEQ::APP {
|
|||||||
class AppManager{
|
class AppManager{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AppManager() : sm(&gm, &mutex), ui(&sm, &gm) {}
|
AppManager() : sm(&gm, &mutex), mouse(std::make_shared<GraphManager>(gm)), ui(&sm, &gm) {}
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
||||||
VISEQ::GRAPH::GraphManager gm;
|
VISEQ::GRAPH::GraphManager gm;
|
||||||
VISEQ::SIGNAL::SignalManager sm;
|
VISEQ::SIGNAL::SignalManager sm;
|
||||||
VISEQ::APP::Clipboard cb;
|
VISEQ::APP::Clipboard cb;
|
||||||
|
VISEQ::APP::Mouse mouse;
|
||||||
|
|
||||||
std::shared_ptr<APP::State> state = APP::State::get();
|
std::shared_ptr<APP::State> state = APP::State::get();
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "draggable.h"
|
#include "draggable.h"
|
||||||
|
#include "state.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace VISEQ::BASE {
|
namespace VISEQ::BASE {
|
||||||
@@ -23,10 +24,12 @@ namespace VISEQ::BASE {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void update() override{
|
void update() override{
|
||||||
|
if(STATE != IState::DRAG_NODE){
|
||||||
Draggable::update();
|
Draggable::update();
|
||||||
if(pickedUp()) drag();
|
if(pickedUp()) drag();
|
||||||
if(released()) putDown();
|
if(released()) putDown();
|
||||||
is_hovering = hovering();
|
// is_hovering = hovering();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void putDown() override {
|
void putDown() override {
|
||||||
|
|||||||
+5
-2
@@ -56,7 +56,7 @@ namespace VISEQ::BASE {
|
|||||||
|
|
||||||
virtual void update() override {
|
virtual void update() override {
|
||||||
if(STATE != IState::HOVER_NODE) select();
|
if(STATE != IState::HOVER_NODE) select();
|
||||||
if(hovering() && z_index > z_hovering) z_hovering = z_index;
|
if((pickedUp() || hovering()) && z_hovering == -1) z_hovering = z_index;
|
||||||
|
|
||||||
if(z_index == z_hovering || selected){
|
if(z_index == z_hovering || selected){
|
||||||
if(pickedUp()){
|
if(pickedUp()){
|
||||||
@@ -67,15 +67,18 @@ namespace VISEQ::BASE {
|
|||||||
if(STATE != IState::DRAG_NODE){
|
if(STATE != IState::DRAG_NODE){
|
||||||
if(entered()){
|
if(entered()){
|
||||||
STATE = IState::HOVER_NODE;
|
STATE = IState::HOVER_NODE;
|
||||||
|
std::cout << "z_index=" << z_index << " z_hovering=" << z_hovering << std::endl;
|
||||||
|
is_hovering = true;
|
||||||
}
|
}
|
||||||
if(exited()){
|
if(exited()){
|
||||||
STATE = IState::HOVER_CANVAS;
|
STATE = IState::HOVER_CANVAS;
|
||||||
|
is_hovering = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(released() && picked_up){
|
if(released() && picked_up){
|
||||||
std::cout << z_hovering << std::endl;
|
|
||||||
putDown();
|
putDown();
|
||||||
STATE = IState::HOVER_CANVAS;
|
STATE = IState::HOVER_CANVAS;
|
||||||
|
if(hovering()) STATE = IState::HOVER_NODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -378,7 +378,7 @@ namespace VISEQ::GRAPH {
|
|||||||
for(auto n : nodes){
|
for(auto n : nodes){
|
||||||
if(KEYS_PRESSED.ctrl && n->hovering()) state->hover_position = n->position;
|
if(KEYS_PRESSED.ctrl && n->hovering()) state->hover_position = n->position;
|
||||||
}
|
}
|
||||||
BASE::Interactable::is_hovering = false;
|
BASE::Interactable::z_hovering = -1;
|
||||||
for(auto n : nodes){
|
for(auto n : nodes){
|
||||||
n->update();
|
n->update();
|
||||||
if(n->picked_up) drawNeighborLines(n, mouse_pos, camera);
|
if(n->picked_up) drawNeighborLines(n, mouse_pos, camera);
|
||||||
|
|||||||
+8
-3
@@ -5,12 +5,17 @@ namespace VISEQ::BASE {
|
|||||||
|
|
||||||
class Interactable{
|
class Interactable{
|
||||||
public:
|
public:
|
||||||
Interactable() {z_index++;}
|
Interactable() {
|
||||||
|
static int _z_index = 0;
|
||||||
|
z_index = _z_index;
|
||||||
|
_z_index++;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~Interactable() {}
|
virtual ~Interactable() {}
|
||||||
|
|
||||||
inline static bool is_hovering = false;
|
bool is_hovering = false;
|
||||||
|
|
||||||
inline static int z_index = 0;
|
int z_index = 0;
|
||||||
inline static int z_hovering = 0;
|
inline static int z_hovering = 0;
|
||||||
|
|
||||||
virtual bool hovering() = 0;
|
virtual bool hovering() = 0;
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "graph-manager.h"
|
||||||
|
#include <memory>
|
||||||
|
namespace VISEQ::APP {
|
||||||
|
class Mouse {
|
||||||
|
public:
|
||||||
|
Mouse(std::shared_ptr<GRAPH::GraphManager> gm) : gm(gm) {}
|
||||||
|
|
||||||
|
std::shared_ptr<GraphManager> gm;
|
||||||
|
|
||||||
|
void update(){
|
||||||
|
auto hovering_nodes = gm->nodes | RANGE_FILTER([](SPTR_Node n) { return n->hovering();});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
+1
-1
@@ -69,7 +69,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
c->update();
|
c->update();
|
||||||
}
|
}
|
||||||
if(free_connectors == 0) addConnector();
|
if(free_connectors == 0) addConnector();
|
||||||
is_hovering = hovering();
|
/*is_hovering = hovering();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw(Vec2Df mp, Camera2D cam) override {}
|
void draw(Vec2Df mp, Camera2D cam) override {}
|
||||||
|
|||||||
Reference in New Issue
Block a user