Dragging and selecting works. Copy / Paste does not copy connectors yet.
This commit is contained in:
+32
-17
@@ -12,6 +12,7 @@
|
||||
#include "mouse.h"
|
||||
#include "node.h"
|
||||
#include "raylib.h"
|
||||
#include "selectable.h"
|
||||
#include "signal-manager.h"
|
||||
#include "state.h"
|
||||
#include "ui.h"
|
||||
@@ -163,41 +164,55 @@ namespace VISEQ::APP {
|
||||
|
||||
void doInteraction(){
|
||||
bool exit = false;
|
||||
bool once = false;
|
||||
state->mouse_z = canvas->z_index;
|
||||
|
||||
while(event_queue.size() > 0 && !exit){
|
||||
auto e = event_queue.front();
|
||||
std::cout << e.item->getType() << " " << e.action << std::endl;
|
||||
|
||||
if(e.action == Interaction::HOVER){
|
||||
state->mouse_z = e.item->z_index;
|
||||
std::cout << state->mouse_z << std::endl;
|
||||
}
|
||||
|
||||
if(e.item->getType() == GraphItemType::CANVAS) {
|
||||
if(e.action == Interaction::SELECT) {
|
||||
gm.select();
|
||||
std::cout << gm.selected_nodes.size() << std::endl;
|
||||
std::cout << "app canvas select" << std::endl;
|
||||
canvas->clearSelectionRect();
|
||||
}
|
||||
if(e.action == Interaction::DESELECT) gm.deselect();
|
||||
if(e.action == Interaction::DESELECT) {
|
||||
std::cout << "app canvas deselect" << std::endl;
|
||||
gm.deselect();
|
||||
}
|
||||
}
|
||||
|
||||
if(e.item->getType() == GraphItemType::NODE){
|
||||
if(!once && e.item->getType() == GraphItemType::NODE){
|
||||
auto node = std::dynamic_pointer_cast<Node>(e.item);
|
||||
if(e.action == Interaction::PICKUP) {
|
||||
e.item->pickUp();
|
||||
if(std::dynamic_pointer_cast<Node>(e.item)->selected){
|
||||
node->pickUp();
|
||||
if(node->selected){
|
||||
for(auto s : gm.selected_nodes){
|
||||
s->pickUp(std::dynamic_pointer_cast<Node>(e.item)->position);
|
||||
s->pickUp(node->position);
|
||||
}
|
||||
}
|
||||
exit = true;
|
||||
once = true;
|
||||
}
|
||||
if(e.action == Interaction::DRAG) {
|
||||
e.item->drag();
|
||||
if(std::dynamic_pointer_cast<Node>(e.item)->selected){
|
||||
if(KEYS_DOWN.ctrl) node->drag(MOD_MOUSE);
|
||||
else node->drag(MOD_MOUSE + node->drag_offset);
|
||||
|
||||
if(node->selected){
|
||||
for(auto s : gm.selected_nodes){
|
||||
s->drag();
|
||||
s->drag(MOD_MOUSE + s->drag_offset);
|
||||
}
|
||||
}
|
||||
exit = true;
|
||||
once = true;
|
||||
}
|
||||
if(e.action == Interaction::PUTDOWN) {
|
||||
e.item->putDown();
|
||||
if(std::dynamic_pointer_cast<Node>(e.item)->selected){
|
||||
node->putDown();
|
||||
if(node->selected){
|
||||
for(auto s : gm.selected_nodes){
|
||||
s->putDown();
|
||||
}
|
||||
@@ -206,18 +221,18 @@ namespace VISEQ::APP {
|
||||
}
|
||||
if(exit) break;
|
||||
|
||||
if(e.item->getType() == GraphItemType::CONNECTOR || e.item->getType() == GraphItemType::CANVAS) {
|
||||
if(!once && (e.item->getType() == GraphItemType::CONNECTOR || e.item->getType() == GraphItemType::CANVAS)) {
|
||||
switch(e.action){
|
||||
case VISEQ::APP::Interaction::PICKUP:
|
||||
{
|
||||
e.item->pickUp();
|
||||
exit = true;
|
||||
once = true;
|
||||
break;
|
||||
}
|
||||
case VISEQ::APP::Interaction::DRAG:
|
||||
{
|
||||
e.item->drag();
|
||||
exit = true;
|
||||
e.item->drag(MOD_MOUSE);
|
||||
once = true;
|
||||
break;
|
||||
}
|
||||
case VISEQ::APP::Interaction::PUTDOWN:
|
||||
|
||||
Reference in New Issue
Block a user