4 Commits

Author SHA1 Message Date
Sebastian 5c433111e2 standard values for midi nodes added 2026-06-25 08:53:11 +02:00
Sebastian c15188d456 copy paste repaired 2026-06-24 23:37:47 +02:00
Sebastian a76954b6f7 clipboard singleton 2026-06-24 18:11:34 +02:00
Sebastian b02eb7e1d4 cleanup and copy/paste bug identified 2026-06-24 11:04:28 +02:00
12 changed files with 43 additions and 23 deletions
+7
View File
@@ -12,5 +12,12 @@ namespace VISEQ::APP {
clipboard.front().push_back(n);
}
}
std::shared_ptr<Clipboard> Clipboard::get() {
if(!Clipboard::instance){
Clipboard::instance.reset(new Clipboard());
}
return Clipboard::instance;
}
}
+3
View File
@@ -13,6 +13,9 @@ namespace VISEQ::APP {
GRAPH::NODES::VEC_SPTR_Node pasteNodes();
void copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes);
inline static std::shared_ptr<Clipboard> instance;
static std::shared_ptr<Clipboard> get();
};
}
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "moveable.h"
#include "raylib.h"
#include "selectable.h"
#include "state.h"
#include "vmath.h"
+19 -11
View File
@@ -115,24 +115,25 @@ namespace VISEQ::GRAPH{
VEC_SPTR_Node GraphManager::getCopiesOfSelectedNodes(){
VEC_SPTR_Node copied_nodes;
for(auto n : selected_nodes){
copied_nodes.insert(copied_nodes.end(), std::make_shared<Node>(*n));
/*if(n->getNodeType() == NodeType::MIDINODE) copied_nodes.insert(copied_nodes.end(), std::make_shared<MidiNode>(*n));*/
/*if(n->getNodeType() == NodeType::CONFIGNODE) copied_nodes.insert(copied_nodes.end(), std::make_shared<ConfigNode>(*n));*/
//copied_nodes.insert(copied_nodes.end(), std::make_shared<Node>(*n));
if(n->getNodeType() == NodeType::MIDINODE) copied_nodes.insert(copied_nodes.end(), std::dynamic_pointer_cast<MidiNode>(n));
if(n->getNodeType() == NodeType::CONFIGNODE) copied_nodes.insert(copied_nodes.end(), std::dynamic_pointer_cast<ConfigNode>(n));
copied_nodes.back()->deselect();
}
return copied_nodes;
}
SPTR_Node GraphManager::copyNode(SPTR_Node n, Vec2Df position){
SPTR_Node GraphManager::copyNode(const SPTR_Node n, Vec2Df position){
std::cout << "copy basenode" << std::endl;
nodes.insert(nodes.end(), std::make_shared<Node>(*n));
/*if(n->getNodeType() == NodeType::MIDINODE) nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));*/
/*if(n->getNodeType() == NodeType::CONFIGNODE) nodes.insert(nodes.end(), std::make_shared<ConfigNode>(*n));*/
if(n->getNodeType() == NodeType::MIDINODE) nodes.insert(nodes.end(), std::dynamic_pointer_cast<MidiNode>(n));
if(n->getNodeType() == NodeType::CONFIGNODE) nodes.insert(nodes.end(), std::dynamic_pointer_cast<ConfigNode>(n));
nodes.back()->setPosition(position);
return nodes.back();
}
SPTR_Node GraphManager::copyNode(std::shared_ptr<MidiNode> n, Vec2Df position){
SPTR_Node GraphManager::copyNode(const std::shared_ptr<MidiNode> n, Vec2Df position){
std::cout << "copy midinode" << std::endl;
nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));
nodes.back()->clearConnectors();
@@ -291,25 +292,31 @@ namespace VISEQ::GRAPH{
void GraphManager::pasteNodesAndEdges(VEC_SPTR_Node nodes, Vec2Df position){
deselect();
std::cout << "nodes size " << nodes.size() << std::endl;
VEC_SPTR_Edge copy_connections;
for(auto c : edges){
if(std::ranges::contains(nodes, c->start.lock()) && std::ranges::contains(nodes, c->end.lock())) {
copy_connections.push_back(std::make_shared<Edge>(*c));
}
}
std::cout << copy_connections.size() << std::endl;
std::cout << "copy_connections size " << copy_connections.size() << std::endl;
Vec2Df insert_pos = nodes.begin()->get()->position;
for(auto old_node : nodes){
SPTR_Node new_node;
if(old_node->getNodeType() == NodeType::MIDINODE) {
new_node = copyNode(std::dynamic_pointer_cast<MidiNode>(old_node), position + old_node->drag_offset);
std::cout << "node type midi" << std::endl;
new_node = copyNode(std::dynamic_pointer_cast<MidiNode>(old_node), (old_node->position - insert_pos) + position);
} else {
std::cout << "not node type midi" << std::endl;
new_node = copyNode(old_node, position + old_node->drag_offset);
}
old_node->selected = false;
new_node->copied = false;
new_node->selected = true;
//TODO copy connectors
@@ -325,6 +332,7 @@ namespace VISEQ::GRAPH{
}
}
std::ranges::copy(copy_connections.begin(), copy_connections.end(), std::back_inserter(edges));
addToSelection();
}
void GraphManager::update(){
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "datatypes.h"
#include "raylib.h"
#include "vmath.h"
namespace VISEQ::BASE {
class Interactable{
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "interactable.h"
#include <deque>
#include <memory>
namespace VISEQ::APP{
+2 -3
View File
@@ -1,6 +1,5 @@
#include "interaction-manager.h"
#include "clipboard.h"
#include "connector.h"
#include "datatypes.h"
#include "node.h"
@@ -14,11 +13,11 @@ namespace VISEQ::INTERACTION{
void InteractionManager::update(){
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_C)){
VEC_SPTR_Node selected_nodes = gm->getCopiesOfSelectedNodes();
if(!selected_nodes.empty()) cb.copyNodes(selected_nodes);
if(!selected_nodes.empty()) cb->copyNodes(selected_nodes);
}
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_V)){
VEC_SPTR_Node paste_nodes = cb.pasteNodes();
VEC_SPTR_Node paste_nodes = cb->pasteNodes();
if(!paste_nodes.empty()) gm->pasteNodesAndEdges(paste_nodes, MOD_MOUSE);
}
+2 -1
View File
@@ -56,13 +56,14 @@ namespace VISEQ::INTERACTION{
std::shared_ptr<APP::CANVAS::Canvas> canvas;
std::shared_ptr<GraphManager> gm;
std::shared_ptr<SIGNAL::SignalManager> sm;
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>();
std::shared_ptr<APP::Clipboard> cb = APP::Clipboard::get();
void update();
void draw();
void removeNodes(VEC_SPTR_Node nodes);
+5
View File
@@ -20,6 +20,11 @@ namespace VISEQ::GRAPH::NODES {
float orbit_4 = orbit_3 + 20.0f;
float orbit_5 = orbit_4 + 30.0f;
midiNote.note = 64;
midiNote.channel = 1;
midiNote.gate = 250;
midiNote.velocity = 64;
midiHandles[NOTE].emplace_back(std::make_shared<NodeHandle<int>>(midiNote.note, position, VS_COLOR_GREEN, "NOTE", orbit_5, 12));
midiHandles[NOTE].emplace_back(std::make_shared<NodeHandle<int>>(midiNote.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 16, 1, 16, 40, 150));
midiHandles[NOTE].emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", orbit_3, 30, 10, 30000, 40, 300));
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "libremidi/libremidi.hpp"
#include "libremidi/observer_configuration.hpp"
#include <libremidi/configurations.hpp>
#include <libremidi/defaults.hpp>
+2 -3
View File
@@ -1,8 +1,7 @@
#pragma once
#include "state.h"
//#include "state.h"
#include "vmath.h"
#include <memory>
namespace VISEQ::BASE {
class Movable{
@@ -14,7 +13,7 @@ namespace VISEQ::BASE {
Movable(Vec2Df p, Vec2Df d, float s) : speed(s), position(p), direction(d) {}
Movable(Vec2Df p, float s) : speed(s), position(p) {}
std::shared_ptr<APP::State> state = APP::State::get();
// std::shared_ptr<APP::State> state = APP::State::get();
float speed = 960.0f;
+2 -1
View File
@@ -4,6 +4,7 @@
#include "nlohmann/json.hpp"
#include "raylib.h"
#include "vmath.h"
#include <deque>
#include <memory>
#define STATE state->istate
@@ -86,7 +87,7 @@ namespace VISEQ::APP{
Vec2Df selection_origin;
Color mode_color = settings.mode_colors[0];
void pushEvent(InteractionEvent e);
InteractionEvent pullEvent();
void update(Camera2D camera);