2024-11-07 00:56:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "datatypes.h"
|
|
|
|
|
#include "node.h"
|
2024-11-08 01:43:06 +01:00
|
|
|
#include "raymath.h"
|
2024-12-07 15:28:33 +01:00
|
|
|
#include <memory>
|
2024-11-07 00:56:33 +01:00
|
|
|
|
|
|
|
|
namespace VISEQ::GRAPH::NODES {
|
|
|
|
|
|
|
|
|
|
class ConfigNode : public Node{
|
|
|
|
|
|
|
|
|
|
public:
|
2024-12-07 03:44:03 +01:00
|
|
|
ConfigNode() : Node() {std::cout << "ConfigNode Constructor std" << std::endl;}
|
|
|
|
|
ConfigNode(Vec2Df position) : Node(position) {}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ConfigNode> getPtr(){
|
|
|
|
|
return std::static_pointer_cast<ConfigNode>(shared_from_this());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 00:56:33 +01:00
|
|
|
NodeType nodeType = NodeType::CONFIGNODE;
|
|
|
|
|
|
|
|
|
|
MIDI::MidiNote midiNote;
|
2024-11-08 01:43:06 +01:00
|
|
|
MIDI::MidiCC midiCC;
|
|
|
|
|
MIDI::MidiPitchBend midiPitchBend;
|
|
|
|
|
MIDI::MidiPolyPressure midiPolyPressure;
|
|
|
|
|
MIDI::MidiPC midiPC;
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiAftertouch midiAftertouch;
|
2024-11-07 00:56:33 +01:00
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
int mode = 0;
|
2024-12-07 03:44:03 +01:00
|
|
|
float radius = 20.0f;
|
2024-11-07 00:56:33 +01:00
|
|
|
|
|
|
|
|
virtual NodeType getNodeType() const override {return nodeType;}
|
2024-12-07 03:44:03 +01:00
|
|
|
|
|
|
|
|
int GGate(){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2024-12-07 22:09:06 +01:00
|
|
|
|
|
|
|
|
MIDI::MidiNote getNotes(){
|
|
|
|
|
return midiNote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MIDI::MidiCC getCC(){
|
|
|
|
|
return midiCC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MIDI::MidiPC getPC(){
|
|
|
|
|
return midiPC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MIDI::MidiPitchBend getPitchBend(){
|
|
|
|
|
return midiPitchBend;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MIDI::MidiPolyPressure getPolyPressure(){
|
|
|
|
|
return midiPolyPressure;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MIDI::MidiAftertouch getAftertouch(){
|
|
|
|
|
return midiAftertouch;
|
|
|
|
|
}
|
2024-12-07 03:44:03 +01:00
|
|
|
|
|
|
|
|
void update() override {
|
|
|
|
|
Node::update();
|
|
|
|
|
mode = state->node_mode;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 22:09:06 +01:00
|
|
|
/*std::vector<std::weak_ptr<MidiNode>> getConnectedMidiNodes(){*/
|
|
|
|
|
/* auto midi_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::MIDINODE || c->end.lock()->getNodeType() == NodeType::MIDINODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();*/
|
|
|
|
|
/* std::vector<std::weak_ptr<MidiNode>> midi_nodes;*/
|
|
|
|
|
/* for(auto e : midi_conns){*/
|
|
|
|
|
/* if(e->start.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->start.lock()));*/
|
|
|
|
|
/* if(e->end.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->end.lock()));*/
|
|
|
|
|
/* }*/
|
|
|
|
|
/* return midi_nodes;*/
|
|
|
|
|
/*}*/
|
2024-12-07 15:28:33 +01:00
|
|
|
|
2024-12-07 03:44:03 +01:00
|
|
|
void interact(){
|
|
|
|
|
float wheel = GetMouseWheelMove();
|
2024-12-07 22:09:06 +01:00
|
|
|
/*auto midi_nodes = getConnectedMidiNodes();*/
|
2024-12-07 03:44:03 +01:00
|
|
|
|
|
|
|
|
if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){
|
|
|
|
|
switch(state->node_mode){
|
|
|
|
|
case 0:{
|
|
|
|
|
midiNote.note += wheel;
|
2024-12-07 22:09:06 +01:00
|
|
|
/* for(auto mn : midi_nodes){*/
|
|
|
|
|
/*mn.lock()->modMidiNote(wheel);*/
|
|
|
|
|
/* }*/
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
|
|
|
|
case 1:{
|
|
|
|
|
midiCC.value += wheel;
|
2024-12-07 22:09:06 +01:00
|
|
|
/* for(auto mn : midi_nodes){*/
|
|
|
|
|
/*mn.lock()->modMidiCC(wheel);*/
|
|
|
|
|
/* }*/
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
|
|
|
|
case 2:{
|
|
|
|
|
midiPitchBend.value += wheel;
|
2024-12-07 22:09:06 +01:00
|
|
|
/* for(auto mn : midi_nodes){*/
|
|
|
|
|
/*mn.lock()->modMidiPitchBend(wheel);*/
|
|
|
|
|
/* }*/
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
|
|
|
|
};
|
2024-12-07 15:28:33 +01:00
|
|
|
if(midiNote.note < -127 ) midiNote.note = -127;
|
|
|
|
|
if(midiNote.note > 127 ) midiNote.note = 127;
|
2024-12-07 03:44:03 +01:00
|
|
|
|
2024-12-07 15:28:33 +01:00
|
|
|
if(midiCC.value < -127 ) midiCC.value = -127;
|
|
|
|
|
if(midiCC.value > 127 ) midiCC.value = 127;
|
2024-12-07 03:44:03 +01:00
|
|
|
|
2024-12-07 15:28:33 +01:00
|
|
|
if(midiPitchBend.value < -16383 ) midiPitchBend.value = -16383;
|
2024-12-07 03:44:03 +01:00
|
|
|
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
2024-11-07 00:56:33 +01:00
|
|
|
|
2024-12-07 03:44:03 +01:00
|
|
|
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
|
|
|
|
} else if(KEYS_DOWN.alt) {
|
|
|
|
|
switch(state->node_mode){
|
|
|
|
|
case 0:{
|
|
|
|
|
midiNote.channel += wheel;
|
|
|
|
|
if(midiNote.channel < 0 ) midiNote.channel = 0;
|
|
|
|
|
if(midiNote.channel > 15) midiNote.channel = 15;
|
|
|
|
|
break;}
|
|
|
|
|
case 1:{
|
|
|
|
|
midiCC.channel += wheel;
|
|
|
|
|
if(midiCC.channel < 0 ) midiCC.channel = 0;
|
|
|
|
|
if(midiCC.channel > 15 ) midiCC.channel = 15;
|
|
|
|
|
break;}
|
|
|
|
|
case 2:{
|
|
|
|
|
midiPitchBend.channel += wheel;
|
|
|
|
|
if(midiPitchBend.channel < 0 ) midiPitchBend.channel = 0;
|
|
|
|
|
if(midiPitchBend.channel > 15 ) midiPitchBend.channel = 15;
|
|
|
|
|
break;}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
void draw(Vec2Df mouse, Camera2D cam) override {
|
2024-12-07 03:44:03 +01:00
|
|
|
Node::draw();
|
|
|
|
|
if(hovering() || selected) interact();
|
|
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
DrawRing(position, radius, radius+4, 0, 360, 24, (Color){60, 60, 60, 255});
|
|
|
|
|
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
|
|
|
|
|
|
|
|
|
Color gate_color = VS_COLOR_GREEN;
|
|
|
|
|
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:{
|
2024-12-07 03:44:03 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){180, 210, 115 + 70, (unsigned char)Clamp(255, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
case 1:{
|
2024-12-07 03:44:03 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){229, 181, 103 + 70, (unsigned char)Clamp(255, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
case 2:{
|
2024-12-07 03:44:03 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){232, 125, 62 + 70, (unsigned char)Clamp(255, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
}
|
2024-12-07 03:44:03 +01:00
|
|
|
if(!picked_up && !selected && !in_selection_rect && !hovering()) DrawCircle(position.x, position.y, radius, gate_color);
|
|
|
|
|
if(picked_up || in_selection_rect || hovering()) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
|
|
|
|
if(selected) DrawCircle(position.x, position.y, radius, (Color){255, 153, 187, 255});
|
2024-11-08 01:43:06 +01:00
|
|
|
|
|
|
|
|
if(distributionMode == Distribution::RANDOM) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_PINK);
|
|
|
|
|
if(distributionMode == Distribution::ROUNDROBIN) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_YELLOW);
|
2024-12-07 03:44:03 +01:00
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
2024-12-07 03:44:03 +01:00
|
|
|
|
|
|
|
|
if(KEYS_DOWN.alt){
|
2024-11-08 01:43:06 +01:00
|
|
|
float value = 0;
|
|
|
|
|
int offset_gate = 0;
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:
|
2024-12-07 03:44:03 +01:00
|
|
|
value = (float)midiNote.channel;
|
|
|
|
|
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
2024-11-08 01:43:06 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2024-12-07 03:44:03 +01:00
|
|
|
value = (float)midiCC.channel;
|
2024-11-08 01:43:06 +01:00
|
|
|
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2024-12-07 03:44:03 +01:00
|
|
|
value = (float)midiPitchBend.channel;
|
2024-11-08 01:43:06 +01:00
|
|
|
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:{
|
2024-12-07 15:28:33 +01:00
|
|
|
int offset = MeasureText(std::format("{:+}", midiNote.note).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{:+}", midiNote.note).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
case 1:{
|
2024-12-07 15:28:33 +01:00
|
|
|
int offset = MeasureText(std::format("{:+}", midiCC.value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{:+}", midiCC.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
case 2:{
|
2024-12-07 15:28:33 +01:00
|
|
|
int offset = MeasureText(std::format("{:+}", midiPitchBend.value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{:+}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-12-07 03:44:03 +01:00
|
|
|
break;}
|
2024-11-08 01:43:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200});
|
|
|
|
|
DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
|
|
|
|
|
}
|
2024-11-07 00:56:33 +01:00
|
|
|
};
|
|
|
|
|
}
|