Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c433111e2 | |||
| c15188d456 | |||
| a76954b6f7 | |||
| b02eb7e1d4 |
@@ -12,5 +12,12 @@ namespace VISEQ::APP {
|
|||||||
clipboard.front().push_back(n);
|
clipboard.front().push_back(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Clipboard> Clipboard::get() {
|
||||||
|
if(!Clipboard::instance){
|
||||||
|
Clipboard::instance.reset(new Clipboard());
|
||||||
|
}
|
||||||
|
return Clipboard::instance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ namespace VISEQ::APP {
|
|||||||
GRAPH::NODES::VEC_SPTR_Node pasteNodes();
|
GRAPH::NODES::VEC_SPTR_Node pasteNodes();
|
||||||
|
|
||||||
void copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes);
|
void copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes);
|
||||||
|
|
||||||
|
inline static std::shared_ptr<Clipboard> instance;
|
||||||
|
static std::shared_ptr<Clipboard> get();
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "moveable.h"
|
#include "moveable.h"
|
||||||
#include "raylib.h"
|
|
||||||
#include "selectable.h"
|
#include "selectable.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|||||||
+19
-11
@@ -115,24 +115,25 @@ namespace VISEQ::GRAPH{
|
|||||||
VEC_SPTR_Node GraphManager::getCopiesOfSelectedNodes(){
|
VEC_SPTR_Node GraphManager::getCopiesOfSelectedNodes(){
|
||||||
VEC_SPTR_Node copied_nodes;
|
VEC_SPTR_Node copied_nodes;
|
||||||
for(auto n : selected_nodes){
|
for(auto n : selected_nodes){
|
||||||
copied_nodes.insert(copied_nodes.end(), std::make_shared<Node>(*n));
|
//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));*/
|
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();
|
copied_nodes.back()->deselect();
|
||||||
}
|
}
|
||||||
return copied_nodes;
|
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;
|
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::dynamic_pointer_cast<MidiNode>(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::dynamic_pointer_cast<ConfigNode>(n));
|
||||||
/*if(n->getNodeType() == NodeType::CONFIGNODE) nodes.insert(nodes.end(), std::make_shared<ConfigNode>(*n));*/
|
|
||||||
nodes.back()->setPosition(position);
|
nodes.back()->setPosition(position);
|
||||||
return nodes.back();
|
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;
|
std::cout << "copy midinode" << std::endl;
|
||||||
nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));
|
nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));
|
||||||
nodes.back()->clearConnectors();
|
nodes.back()->clearConnectors();
|
||||||
@@ -291,25 +292,31 @@ namespace VISEQ::GRAPH{
|
|||||||
|
|
||||||
void GraphManager::pasteNodesAndEdges(VEC_SPTR_Node nodes, Vec2Df position){
|
void GraphManager::pasteNodesAndEdges(VEC_SPTR_Node nodes, Vec2Df position){
|
||||||
|
|
||||||
|
deselect();
|
||||||
|
std::cout << "nodes size " << nodes.size() << std::endl;
|
||||||
VEC_SPTR_Edge copy_connections;
|
VEC_SPTR_Edge copy_connections;
|
||||||
for(auto c : edges){
|
for(auto c : edges){
|
||||||
if(std::ranges::contains(nodes, c->start.lock()) && std::ranges::contains(nodes, c->end.lock())) {
|
if(std::ranges::contains(nodes, c->start.lock()) && std::ranges::contains(nodes, c->end.lock())) {
|
||||||
copy_connections.push_back(std::make_shared<Edge>(*c));
|
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){
|
for(auto old_node : nodes){
|
||||||
SPTR_Node new_node;
|
SPTR_Node new_node;
|
||||||
|
|
||||||
if(old_node->getNodeType() == NodeType::MIDINODE) {
|
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 {
|
} else {
|
||||||
|
std::cout << "not node type midi" << std::endl;
|
||||||
new_node = copyNode(old_node, position + old_node->drag_offset);
|
new_node = copyNode(old_node, position + old_node->drag_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
old_node->selected = false;
|
||||||
new_node->copied = false;
|
new_node->copied = false;
|
||||||
new_node->selected = true;
|
new_node->selected = true;
|
||||||
|
|
||||||
|
|
||||||
//TODO copy connectors
|
//TODO copy connectors
|
||||||
|
|
||||||
@@ -325,6 +332,7 @@ namespace VISEQ::GRAPH{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::ranges::copy(copy_connections.begin(), copy_connections.end(), std::back_inserter(edges));
|
std::ranges::copy(copy_connections.begin(), copy_connections.end(), std::back_inserter(edges));
|
||||||
|
addToSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphManager::update(){
|
void GraphManager::update(){
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "raylib.h"
|
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|
||||||
namespace VISEQ::BASE {
|
namespace VISEQ::BASE {
|
||||||
|
|
||||||
class Interactable{
|
class Interactable{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "interactable.h"
|
#include "interactable.h"
|
||||||
#include <deque>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace VISEQ::APP{
|
namespace VISEQ::APP{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "interaction-manager.h"
|
#include "interaction-manager.h"
|
||||||
|
|
||||||
#include "clipboard.h"
|
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
@@ -14,11 +13,11 @@ namespace VISEQ::INTERACTION{
|
|||||||
void InteractionManager::update(){
|
void InteractionManager::update(){
|
||||||
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_C)){
|
if(KEYS_DOWN.ctrl && IsKeyPressed(KEY_C)){
|
||||||
VEC_SPTR_Node selected_nodes = gm->getCopiesOfSelectedNodes();
|
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)){
|
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);
|
if(!paste_nodes.empty()) gm->pasteNodesAndEdges(paste_nodes, MOD_MOUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,14 @@ namespace VISEQ::INTERACTION{
|
|||||||
std::shared_ptr<APP::CANVAS::Canvas> canvas;
|
std::shared_ptr<APP::CANVAS::Canvas> canvas;
|
||||||
std::shared_ptr<GraphManager> gm;
|
std::shared_ptr<GraphManager> gm;
|
||||||
std::shared_ptr<SIGNAL::SignalManager> sm;
|
std::shared_ptr<SIGNAL::SignalManager> sm;
|
||||||
VISEQ::APP::Clipboard cb;
|
|
||||||
|
|
||||||
std::shared_ptr<APP::State> state = APP::State::get();
|
std::shared_ptr<APP::State> state = APP::State::get();
|
||||||
|
|
||||||
Vec2Df scale_start;
|
Vec2Df scale_start;
|
||||||
std::shared_ptr<ScaleHandle> scale_handle = std::make_shared<ScaleHandle>();
|
std::shared_ptr<ScaleHandle> scale_handle = std::make_shared<ScaleHandle>();
|
||||||
|
|
||||||
|
std::shared_ptr<APP::Clipboard> cb = APP::Clipboard::get();
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void draw();
|
void draw();
|
||||||
void removeNodes(VEC_SPTR_Node nodes);
|
void removeNodes(VEC_SPTR_Node nodes);
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
float orbit_4 = orbit_3 + 20.0f;
|
float orbit_4 = orbit_3 + 20.0f;
|
||||||
float orbit_5 = orbit_4 + 30.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.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.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));
|
midiHandles[NOTE].emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", orbit_3, 30, 10, 30000, 40, 300));
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "libremidi/libremidi.hpp"
|
#include "libremidi/libremidi.hpp"
|
||||||
#include "libremidi/observer_configuration.hpp"
|
|
||||||
|
|
||||||
#include <libremidi/configurations.hpp>
|
#include <libremidi/configurations.hpp>
|
||||||
#include <libremidi/defaults.hpp>
|
#include <libremidi/defaults.hpp>
|
||||||
|
|||||||
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "state.h"
|
//#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace VISEQ::BASE {
|
namespace VISEQ::BASE {
|
||||||
class Movable{
|
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, Vec2Df d, float s) : speed(s), position(p), direction(d) {}
|
||||||
Movable(Vec2Df p, float s) : speed(s), position(p) {}
|
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;
|
float speed = 960.0f;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -4,6 +4,7 @@
|
|||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#define STATE state->istate
|
#define STATE state->istate
|
||||||
@@ -86,7 +87,7 @@ namespace VISEQ::APP{
|
|||||||
Vec2Df selection_origin;
|
Vec2Df selection_origin;
|
||||||
|
|
||||||
Color mode_color = settings.mode_colors[0];
|
Color mode_color = settings.mode_colors[0];
|
||||||
|
|
||||||
void pushEvent(InteractionEvent e);
|
void pushEvent(InteractionEvent e);
|
||||||
InteractionEvent pullEvent();
|
InteractionEvent pullEvent();
|
||||||
void update(Camera2D camera);
|
void update(Camera2D camera);
|
||||||
|
|||||||
Reference in New Issue
Block a user