Good working protoype with config nodes and a experimental channel setting ui.
This commit is contained in:
+43
-7
@@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "button.h"
|
||||
#include "config-node.h"
|
||||
#include "datatypes.h"
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "state.h"
|
||||
#include <map>
|
||||
|
||||
#define RADIUS 14.0f
|
||||
#include <random>
|
||||
|
||||
namespace VISEQ::APP::UI{
|
||||
class AppUI;
|
||||
@@ -25,6 +27,8 @@ namespace VISEQ::GRAPH::NODES {
|
||||
MIDI::MidiAftertouch midiAftertouch;
|
||||
MIDI::MidiPolyPressure midiPolyPressure;
|
||||
MIDI::MidiPC midiPC;
|
||||
|
||||
std::vector<APP::UI::ButtonRound> channelButtons;
|
||||
|
||||
public:
|
||||
|
||||
@@ -34,8 +38,8 @@ namespace VISEQ::GRAPH::NODES {
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
MidiNode() {std::cout << "MidiNode Constructor std" << std::endl;}
|
||||
MidiNode(Vec2Df position) : Node(position) {}
|
||||
MidiNode() {init();}
|
||||
MidiNode(Vec2Df position) : Node(position) {init();}
|
||||
|
||||
NodeType nodeType = NodeType::MIDINODE;
|
||||
|
||||
@@ -57,6 +61,14 @@ namespace VISEQ::GRAPH::NODES {
|
||||
float fade = 0;
|
||||
float time = 0;
|
||||
float last = 0;
|
||||
|
||||
void init(){
|
||||
channelButtons.clear();
|
||||
for(int i = 0; i < 16; ++i){
|
||||
channelButtons.emplace_back(position, 4.0f, VS_COLOR_YELLOW);
|
||||
channelButtons.back().hover_color = VS_COLOR_PINK;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<MidiNode> getPtr(){
|
||||
return std::static_pointer_cast<MidiNode>(shared_from_this());
|
||||
@@ -203,6 +215,12 @@ namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
void draw(Vec2Df mouse, Camera2D cam) override {
|
||||
Node::draw();
|
||||
if(hovering()) {
|
||||
radius += radius < 25 ? 2 : 0;
|
||||
} else {
|
||||
radius -= radius > 15 ? 2 : 0;
|
||||
}
|
||||
|
||||
if(hovering() || selected) interact();
|
||||
|
||||
last = time;
|
||||
@@ -214,8 +232,8 @@ namespace VISEQ::GRAPH::NODES {
|
||||
fade -= (time - last)*1000.0f;
|
||||
}
|
||||
|
||||
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) * getNotes().velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
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) * getNotes().velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
||||
|
||||
float midi_gate_map = round((255.f / getNotes().gate) * fade);
|
||||
@@ -241,6 +259,24 @@ namespace VISEQ::GRAPH::NODES {
|
||||
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(hovering()){
|
||||
for(int i = 0; i < 16; ++i){
|
||||
channelButtons.at(i).position = position.orbitAtAngle(21.0, DEG2RAD * (360.0f/16.0f)*i);
|
||||
Color col = VS_COLOR_YELLOW;
|
||||
if(mode == 0 && midiNote.channel == i) col = VS_COLOR_PINK;
|
||||
if(mode == 1 && midiCC.channel == i) col = VS_COLOR_PINK;
|
||||
if(mode == 2 && midiPitchBend.channel == i) col = VS_COLOR_PINK;
|
||||
channelButtons.at(i).color = col;
|
||||
channelButtons.at(i).draw();
|
||||
if(channelButtons.at(i).hovering()) DrawCenteredText(std::format("{}", i+1), position + (Vec2Df){0,10.0f}, 8, VS_COLOR_WHITE);
|
||||
if(channelButtons.at(i).clicked()) {
|
||||
if(mode == 0) midiNote.channel = i;
|
||||
if(mode == 1) midiCC.channel = i;
|
||||
if(mode == 2) midiPitchBend.channel = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(KEYS_DOWN.alt){
|
||||
float value = 0;
|
||||
@@ -280,7 +316,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
}
|
||||
|
||||
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);
|
||||
//DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
|
||||
}
|
||||
|
||||
friend void to_json(json& j, const MidiNode& N){
|
||||
|
||||
Reference in New Issue
Block a user