Might be a better way to handle hovering, dragging and mouse interaction in general
This commit is contained in:
+2
-1
@@ -19,7 +19,7 @@ namespace VISEQ::APP {
|
|||||||
class AppManager{
|
class AppManager{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AppManager() : sm(&gm, &mutex), mouse(std::make_shared<GraphManager>(gm)), ui(&sm, &gm) {}
|
AppManager() : sm(&gm, &mutex), mouse(&gm), ui(&sm, &gm) {}
|
||||||
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
||||||
@@ -60,6 +60,7 @@ namespace VISEQ::APP {
|
|||||||
mutex.lock();
|
mutex.lock();
|
||||||
updateMidiPorts();
|
updateMidiPorts();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
mouse.update();
|
||||||
|
|
||||||
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_C)){
|
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_C)){
|
||||||
VEC_SPTR_Node selected_nodes = gm.getSelection();
|
VEC_SPTR_Node selected_nodes = gm.getSelection();
|
||||||
|
|||||||
+9
-3
@@ -1,16 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "draggable.h"
|
||||||
#include "graph-manager.h"
|
#include "graph-manager.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
namespace VISEQ::APP {
|
namespace VISEQ::APP {
|
||||||
class Mouse {
|
class Mouse {
|
||||||
public:
|
public:
|
||||||
Mouse(std::shared_ptr<GRAPH::GraphManager> gm) : gm(gm) {}
|
Mouse() {}
|
||||||
|
Mouse(GraphManager *gm) : gm(gm) {}
|
||||||
|
|
||||||
std::shared_ptr<GraphManager> gm;
|
GraphManager *gm;
|
||||||
|
|
||||||
void update(){
|
void update(){
|
||||||
auto hovering_nodes = gm->nodes | RANGE_FILTER([](SPTR_Node n) { return n->hovering();});
|
auto hovering_nodes = gm->nodes | RANGE_FILTER([](SPTR_Node n) { return n->is_hovering;}) | std::ranges::to<std::vector<std::shared_ptr<BASE::Draggable>>>();
|
||||||
|
|
||||||
|
if(!hovering_nodes.empty()){
|
||||||
|
hovering_nodes.front()->selected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user