diff --git a/src/graph-manager.cpp b/src/graph-manager.cpp index 1389e56..a8b6d31 100644 --- a/src/graph-manager.cpp +++ b/src/graph-manager.cpp @@ -368,8 +368,11 @@ namespace VISEQ::GRAPH{ float v1_v2_distance = v1_position.dist(&v2_position); if(v1_v2_distance < 100) c->switches_offset = v1_v2_distance/2.3f; - Vec2Df from_to_handle = c->start.lock()->position - ((c->start.lock()->position - c->end.lock()->position)).norm()*45.0f; - Vec2Df to_from_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm()*45.0f; + float from_radius = c->start.lock()->radius; + float to_radius = c->end.lock()->radius; + + Vec2Df from_to_handle = c->start.lock()->position - ((c->start.lock()->position - c->end.lock()->position)).norm() * (from_radius + 35.0f); + Vec2Df to_from_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm() * (to_radius + 35.0f); //Vec2Df middle_handle_2 = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm()*65.0f; //Vec2Df middle_handle = c->start.lock()->position - ((c->start.lock()->position - c->end.lock()->position)).norm()*65.0f; Vec2Df center_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position))*0.5f; diff --git a/src/midi-node.cpp b/src/midi-node.cpp index 2fe1f39..7643b2e 100644 --- a/src/midi-node.cpp +++ b/src/midi-node.cpp @@ -181,6 +181,9 @@ namespace VISEQ::GRAPH::NODES { switch(mode){ case NOTE:{ + if(state->isModChain(APP::CTRL, APP::SHIFT, APP::ALT)){ + std::cout << "yeah" << std::endl; + } if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) modMidiNoteValue(wheel); if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) modMidiNoteVelocity(wheel); @@ -236,22 +239,22 @@ namespace VISEQ::GRAPH::NODES { switch((Handles)mode){ case NOTE:{ - radius = (float)midiNote.velocity * 0.2f + 5.0f; + radius = (float)midiNote.velocity * 0.2f + 15.0f; break;} case CC:{ - radius = (float)midiCC.value * 0.2f + 5.0f; + radius = (float)midiCC.value * 0.2f + 15.0f; break;} case PC:{ - radius = (float)midiPC.value * 0.2f + 5.0f; + radius = (float)midiPC.value * 0.2f + 15.0f; break;} case PB:{ - radius = (float)midiPitchBend.value * 0.002f + 5.0f; + radius = (float)midiPitchBend.value * 0.002f + 15.0f; break;} case AT:{ - radius = (float)midiAftertouch.value * 0.002f + 5.0f; + radius = (float)midiAftertouch.value * 0.002f + 15.0f; break;} case PP:{ - radius = (float)midiPolyPressure.value * 0.002f + 5.0f; + radius = (float)midiPolyPressure.value * 0.002f + 15.0f; break;} } @@ -274,74 +277,74 @@ namespace VISEQ::GRAPH::NODES { VMATH::Vec2D desc_position = position + VMATH::Vec2D(radius + 7.0f, radius + 7.0f); switch(mode){ case NOTE:{ - if(!KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(MIDI::Notes[getNotes().note], position, 14, VS_COLOR_BLACK); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getNotes().velocity), position, 12, VS_COLOR_BLACK); + if(!KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(MIDI::Notes[getNotes().note], position, 14, VS_COLOR_DARKGREY); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getNotes().velocity), position, 12, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.1f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_BLACK); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_BLACK); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_BLACK); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.3f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_BLACK); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.1f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.3f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("NOTE", desc_position, 8, VS_COLOR_BLACK); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, VS_COLOR_BLACK); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VELOCITY", desc_position, 8, VS_COLOR_BLACK); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("NOTE", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VELOCITY", desc_position, 8, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.1s", desc_position, 8, VS_COLOR_BLACK); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 1.0s", desc_position, 8, VS_COLOR_BLACK); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.01s", desc_position, 8, VS_COLOR_BLACK); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.001s", desc_position, 8, VS_COLOR_BLACK); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.1s", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 1.0s", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.01s", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.001s", desc_position, 8, VS_COLOR_WHITE); } break;} case CC:{ - if(!KEYS_DOWN.shift) DrawCenteredText(std::format("{}", getCC().value), position, 12, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getCC().control), position, 12, BLACK); + if(!KEYS_DOWN.shift) DrawCenteredText(std::format("{}", getCC().value), position, 12, VS_COLOR_DARKGREY); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getCC().control), position, 12, VS_COLOR_WHITE); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("CC", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("CONTROL", desc_position, 8, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("CC", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("CONTROL", desc_position, 8, VS_COLOR_WHITE); } break;} case PC:{ - if(!KEYS_DOWN.shift) DrawCenteredText(std::format("{}", getPC().value), position, 12, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPC().program), position, 12, BLACK); + if(!KEYS_DOWN.shift) DrawCenteredText(std::format("{}", getPC().value), position, 12, VS_COLOR_DARKGREY); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPC().program), position, 12, VS_COLOR_WHITE); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PROGRAM CHANGE", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PROGRAM", desc_position, 8, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PROGRAM CHANGE", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PROGRAM", desc_position, 8, VS_COLOR_WHITE); } break;} case PB:{ - DrawCenteredText(std::format("{}", getPitchBend().value), position, 10, WHITE); + DrawCenteredText(std::format("{}", getPitchBend().value), position, 10, VS_COLOR_DARKGREY); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PITCHBEND", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("64", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("2048", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("256", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("PITCHBEND", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("64", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("2048", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("256", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, VS_COLOR_WHITE); } break;} case AT:{ - DrawCenteredText(std::format("{}", getAftertouch().value), position, 12, WHITE); + DrawCenteredText(std::format("{}", getAftertouch().value), position, 12, VS_COLOR_DARKGREY); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("AFTERTOUCH", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("10", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("100", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("AFTERTOUCH", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("10", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("100", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, VS_COLOR_WHITE); } break;} case PP:{ - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(MIDI::Notes[getPolyPressure().note], position, 12, WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(MIDI::Notes[getPolyPressure().note], position, 12, VS_COLOR_DARKGREY); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, VS_COLOR_DARKGREY); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, VS_COLOR_DARKGREY); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getPolyPressure().value), position, 12, VS_COLOR_DARKGREY); if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("POLYPRESSURE", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("64", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("2048", desc_position, 8, WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("256", desc_position, 8, WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("POLYPRESSURE", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("64", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("2048", desc_position, 8, VS_COLOR_WHITE); + if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("256", desc_position, 8, VS_COLOR_WHITE); + if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("1", desc_position, 8, VS_COLOR_WHITE); } break;} }; diff --git a/src/state.cpp b/src/state.cpp index 4dd3f83..bde4e9a 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -54,6 +54,21 @@ namespace VISEQ::APP{ keys_released.shift = IsKeyReleased(KEY_LEFT_SHIFT) || IsKeyReleased(KEY_RIGHT_SHIFT); keys_released.alt = IsKeyReleased(KEY_LEFT_ALT) || IsKeyReleased(KEY_RIGHT_ALT); + int n_modifier = keys_down.alt + keys_down.ctrl + keys_down.shift; + + if(modifier_chain.size() < n_modifier){ + ModifierKeyNames modKey = keys_pressed.ctrl ? CTRL : keys_pressed.shift ? SHIFT : ALT; + modifier_chain.push_back(modKey); + std::cout << modifier_chain.size() << " " << modKey << std::endl; + } + + if(modifier_chain.size() > n_modifier){ + ModifierKeyNames modKey = !keys_released.ctrl ? CTRL : !keys_released.shift ? SHIFT : ALT; + auto it = std::remove(modifier_chain.begin(), modifier_chain.end(), modKey); + modifier_chain.erase(it); + std::cout << modifier_chain.size() << " " << modKey << std::endl; + } + screen_mouse = {round(mouse_pos.x), round(mouse_pos.y)}; raw_mouse = {GetMousePosition().x, GetMousePosition().y}; mod_mouse = {round(mouse_pos.x), round(mouse_pos.y)}; @@ -73,4 +88,16 @@ namespace VISEQ::APP{ } return State::instance; } + + bool State::isModChain(ModifierKeyNames first){ + return modifier_chain == std::vector{first}; + } + + bool State::isModChain(ModifierKeyNames first, ModifierKeyNames second){ + return modifier_chain == std::vector{first, second}; + } + + bool State::isModChain(ModifierKeyNames first, ModifierKeyNames second, ModifierKeyNames third){ + return modifier_chain == std::vector{first, second, third}; + } } diff --git a/src/state.h b/src/state.h index fc46af1..7a45049 100644 --- a/src/state.h +++ b/src/state.h @@ -49,6 +49,8 @@ namespace VISEQ::APP{ bool alt = false; }; + enum ModifierKeyNames {CTRL, SHIFT, ALT}; + class State{ public: State(){} @@ -80,6 +82,8 @@ namespace VISEQ::APP{ ModifierKeys keys_pressed; ModifierKeys keys_released; + std::vector modifier_chain; + Rectangle selection; Rectangle bounding_box; @@ -97,6 +101,10 @@ namespace VISEQ::APP{ static std::shared_ptr get(); std::deque event_queue; + + bool isModChain(ModifierKeyNames first); + bool isModChain(ModifierKeyNames first, ModifierKeyNames second); + bool isModChain(ModifierKeyNames first, ModifierKeyNames second, ModifierKeyNames third); }; }