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-11-07 00:56:33 +01:00
|
|
|
|
|
|
|
|
namespace VISEQ::GRAPH::NODES {
|
|
|
|
|
|
|
|
|
|
class ConfigNode : public Node{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
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-11-07 00:56:33 +01:00
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
int mode = 0;
|
2024-11-07 00:56:33 +01:00
|
|
|
|
|
|
|
|
virtual NodeType getNodeType() const override {return nodeType;}
|
|
|
|
|
|
2024-11-08 01:43:06 +01:00
|
|
|
void draw(Vec2Df mouse, Camera2D cam) override {
|
|
|
|
|
DrawRing(position, radius, radius+4, 0, 360, 24, (Color){60, 60, 60, 255});
|
|
|
|
|
DrawRing(position, radius, radius+4, 0.0f - 90.0f, (360.0f/127.0f) * midiNote.velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
|
|
|
|
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
|
|
|
|
|
|
|
|
|
float fade = 0;
|
|
|
|
|
|
|
|
|
|
float midi_gate_map = round((255.f / midiNote.gate) * fade);
|
|
|
|
|
|
|
|
|
|
Color gate_color = VS_COLOR_GREEN;
|
|
|
|
|
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:{
|
|
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){180, 210, 115, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
|
|
|
|
case 1:{
|
|
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){229, 181, 103, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
|
|
|
|
case 2:{
|
|
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){232, 125, 62, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
|
|
|
|
break;}
|
|
|
|
|
}
|
|
|
|
|
if(!dragging && !selected && !in_rect && !hovering) DrawCircle(position.x, position.y, radius, gate_color);
|
|
|
|
|
if(selected || dragging || in_rect || hovering) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
|
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_LEFT_ALT)){
|
|
|
|
|
float value = 0;
|
|
|
|
|
int offset_gate = 0;
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:
|
|
|
|
|
value = (float)midiNote.gate/1000.0f;
|
|
|
|
|
offset_gate = MeasureText(std::format("{:.2f}", value).c_str(), 12);
|
|
|
|
|
DrawText(std::format("{:.2f}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
value = (float)midiCC.value;
|
|
|
|
|
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:
|
|
|
|
|
value = (float)midiPitchBend.value;
|
|
|
|
|
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:{
|
|
|
|
|
int offset = MeasureText(MIDI::Notes[(int)midiNote.note].c_str(), 12);
|
|
|
|
|
DrawText(MIDI::Notes[midiNote.note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
|
|
|
|
break;}
|
|
|
|
|
case 1:{
|
|
|
|
|
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 );
|
|
|
|
|
break;}
|
|
|
|
|
case 2:{
|
|
|
|
|
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 );
|
|
|
|
|
break;}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vec2Df connector = position - ((position - mouse)).norm() * (radius + 30);
|
|
|
|
|
float opacity = 150.0f - Clamp(position.dist(mouse), 0.0f, 150.0f);
|
|
|
|
|
|
|
|
|
|
if(hover_connect){
|
|
|
|
|
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, 255});
|
|
|
|
|
} else {
|
|
|
|
|
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|