simple signal config added. bpm config and grid.

This commit is contained in:
Sebastian
2024-10-22 03:07:11 +02:00
parent ad745a720e
commit 0914747d14
3 changed files with 43 additions and 13 deletions
+35 -9
View File
@@ -21,6 +21,7 @@
#include <format>
#include <raylib.h>
#include <raymath.h>
#include <string>
#define RAYGUI_IMPLEMENTATION
#include "raygui/raygui.h"
@@ -121,6 +122,8 @@ int main(){
while(!WindowShouldClose()){
app.grid = round(((app.fps / (app.bpm / 60.0f)) * app.speed) / 4.0f); // from quarter notes to 16th notes = div by 4
Vector2 mp = GetScreenToWorld2D(GetMousePosition(), camera);
Vec2D<float> mouse_pos = {(float)mp.x, (float)mp.y};
Vec2D<float> cam_pos = {camera.offset.x, camera.offset.y};
@@ -244,15 +247,23 @@ int main(){
// Main Config Window
GuiWindowBox((Rectangle){0,0,280,(float)app.height}, "config");
{
GuiLabel((Rectangle){20, 55, 240, 20}, "MIDI OUT");
{
const int s_bpm = 55;
GuiLabel((Rectangle){20, (float)s_bpm, 120, 20}, "TIMING");
GuiLabel((Rectangle){200, (float)s_bpm, 40, 20}, std::format("{}",app.bpm).c_str());
float _bpm = (float)app.bpm;
GuiSlider((Rectangle){20, (float)s_bpm + 25, 240, 20}, "", "", &_bpm, 1, 300);
app.bpm = _bpm;
int s_midi = 100;
GuiLabel((Rectangle){20, (float)s_midi, 240, 20}, "MIDI OUT");
int i = 0;
for(auto& mo : midi.midi_out_ports){
GuiCheckBox((Rectangle){20, 80 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
GuiCheckBox((Rectangle){20, (float)s_midi + 25 + i*20.0f, 20, 20}, mo.port.port_name.c_str(), &mo.enabled);
i++;
}
if(GuiButton((Rectangle){20, 100 + i*20.0f, 240, 20}, "ENABLE FOR ALL")) {
if(GuiButton((Rectangle){20, (float)s_midi + 45 + i*20.0f, 240, 20}, "ENABLE FOR ALL")) {
for(auto &midis : midi.midi_out_ports){
if(midis.enabled){
for(auto &n : nodes){
@@ -261,17 +272,32 @@ int main(){
}
}
}
GuiLabel((Rectangle){20, 135 + i*20.0f, 240, 20}, "SIGNALS");
if(GuiButton((Rectangle){20, 160 + i*20.0f, 240, 20}, "ADD RANDOM SIGNAL")){
int s_signal = s_midi + 90 + i*20;
GuiLabel((Rectangle){20, (float)s_signal, 240, 20}, "SIGNALS");
if(GuiButton((Rectangle){20, (float)s_signal + 35, 240, 20}, "ADD RANDOM SIGNAL")){
int ni = rand() % nodes.size();
sm.addSignalAtNode(&nodes[ni]);
}
GuiLabel((Rectangle){20, 185 + i*20.0f, 240, 20}, "NODES");
if(GuiButton((Rectangle){20, 215 + i*20.0f, 240, 20}, "ADD RANDOM NODE")){
int signal_configs = 0;
for(auto &s : sm.signals){
if(GuiButton((Rectangle){20,(float)s_signal+70 + signal_configs*20, 20, 20},"X")) sm.removeSignal(signal_configs);
DrawCircle(55, s_signal+80 + signal_configs*20, 6.0F, s.color);
float s_speed = round(s.speed*10.0f)/10.0f;
float signal_bpm = (app.bpm / app.speed) * s_speed;
GuiSlider((Rectangle){70, (float)s_signal+70 + signal_configs*20, 160, 20}, "", std::format("{:.1f}",signal_bpm).c_str(), &s_speed, 0.1, 24);
s.speed = s_speed;
signal_configs++;
}
int s_nodes = s_signal + 60 + signal_configs*20;
GuiLabel((Rectangle){20, (float)s_nodes + 30, 240, 20}, "NODES");
if(GuiButton((Rectangle){20, (float)s_nodes + 60, 240, 20}, "ADD RANDOM NODE")){
nodes.emplace_back(Node((float)(rand() % app.width*0.5 + app.width*0.25), (float)(rand() % app.height*0.5 + app.height*0.25), 15.0f));
}
}
// Per Node Config Windows