split edge: check, copy paste: check with a little bug

This commit is contained in:
Sebastian
2024-11-02 02:06:26 +01:00
parent 41cad27806
commit 70d0a186a4
5 changed files with 123 additions and 85 deletions
+55 -46
View File
@@ -7,6 +7,7 @@
*/
#include "midi-node.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <vector>
@@ -291,6 +292,8 @@ int main(){
case InteractionState::COPY_SELECTED_NODES:
{
std::ranges::copy(selected_nodes.begin(), selected_nodes.end(), std::back_inserter(copied_nodes));
std::ranges::for_each(selected_nodes.begin(), selected_nodes.end(), [](SPTR_Node n){n->selected = false;});
selected_nodes.clear();
break;
}
case InteractionState::PASTE_SELECTED_NODES:
@@ -299,59 +302,65 @@ int main(){
n->drag_offset = (n->position - copied_nodes.front()->position);
}
app.copyNodesAndConnections(copied_nodes, mouse_pos);
copied_nodes.clear();
//copied_nodes.clear();
break;
}
};
float wheel = GetMouseWheelMove();
if(wheel != 0){
if(!hovering_nodes.empty() && hovering_nodes.front()->getNodeType() == NodeType::MIDINODE) {
std::shared_ptr<MidiNode> midiNode = std::dynamic_pointer_cast<MidiNode>(hovering_nodes.front());
if(IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
switch(app.settings.mode){
case 0:{
midiNode->midi_note += wheel;
break;}
case 1:{
midiNode->midi_cc += wheel;
break;}
case 2:{
midiNode->midi_pitch_bend += wheel;
break;}
};
if(midiNode->midi_note < 0 ) midiNode->midi_note = app.sm.midi.midiNotes.size()-1;
if(midiNode->midi_note >= app.sm.midi.midiNotes.size() ) midiNode->midi_note = 0;
if(midiNode->midi_cc < 0 ) midiNode->midi_cc = 127;
if(midiNode->midi_cc > 127 ) midiNode->midi_cc = 0;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
if(!hovering_nodes.empty() && hovering_nodes.front()->getNodeType() == NodeType::MIDINODE) {
VEC_SPTR_Node modify_nodes;
std::copy_if(selected_nodes.begin(), selected_nodes.end(), std::back_inserter(modify_nodes), [](SPTR_Node n){ return n->getNodeType() == NodeType::MIDINODE;});
std::copy_if(hovering_nodes.begin(), hovering_nodes.end(), std::back_inserter(modify_nodes), [modify_nodes](SPTR_Node n){ return n->getNodeType() == NodeType::MIDINODE && !std::ranges::contains(modify_nodes, n);});
} else if(!hovering_nodes.empty() && IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_ALT)) {
midiNode->midi_velocity += wheel;
if(midiNode->midi_velocity < 0 ) midiNode->midi_velocity = 127;
if(midiNode->midi_velocity > 127 ) midiNode->midi_velocity = 0;
} else if(!hovering_nodes.empty() && IsKeyDown(KEY_LEFT_ALT)) {
switch(app.settings.mode){
case 0:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_gate += incr;
if(midiNode->midi_gate < 0 ) midiNode->midi_gate = 0;
break;}
case 1:{
midiNode->midi_cc_value += wheel;
if(midiNode->midi_cc_value < 0 ) midiNode->midi_cc_value = 0;
if(midiNode->midi_cc_value > 127 ) midiNode->midi_cc_value = 127;
break;}
case 2:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_pitch_bend += incr;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
break;}
};
for(auto n : modify_nodes){
std::shared_ptr<MidiNode> midiNode = std::dynamic_pointer_cast<MidiNode>(n);
if(IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
switch(app.settings.mode){
case 0:{
midiNode->midi_note += wheel;
break;}
case 1:{
midiNode->midi_cc += wheel;
break;}
case 2:{
midiNode->midi_pitch_bend += wheel;
break;}
};
if(midiNode->midi_note < 0 ) midiNode->midi_note = app.sm.midi.midiNotes.size()-1;
if(midiNode->midi_note >= app.sm.midi.midiNotes.size() ) midiNode->midi_note = 0;
if(midiNode->midi_cc < 0 ) midiNode->midi_cc = 127;
if(midiNode->midi_cc > 127 ) midiNode->midi_cc = 0;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
} else if(IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_ALT)) {
midiNode->midi_velocity += wheel;
if(midiNode->midi_velocity < 0 ) midiNode->midi_velocity = 127;
if(midiNode->midi_velocity > 127 ) midiNode->midi_velocity = 0;
} else if(IsKeyDown(KEY_LEFT_ALT)) {
switch(app.settings.mode){
case 0:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_gate += incr;
if(midiNode->midi_gate < 0 ) midiNode->midi_gate = 0;
break;}
case 1:{
midiNode->midi_cc_value += wheel;
if(midiNode->midi_cc_value < 0 ) midiNode->midi_cc_value = 0;
if(midiNode->midi_cc_value > 127 ) midiNode->midi_cc_value = 127;
break;}
case 2:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_pitch_bend += incr;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
break;}
};
}
}
}
if(hovering_nodes.empty()){