From e4b2df21bccdd5ada491f70b75b78348de6de002 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 27 Jun 2026 01:35:20 +0200 Subject: [PATCH] small steps forward - placement of edge buttons changed and one more texture added --- resources/block.svg | 73 +++++++++++++++ resources/delete.svg | 81 ++++++++++++++++ resources/split.svg | 87 ++++++++++++++++++ resources/textures.svg | 81 ++++++++++++++++ .../textures/{round-delete.png => delete.png} | Bin resources/textures/split.png | Bin 0 -> 2792 bytes src/app-manager.cpp | 2 +- src/button.h | 2 +- src/edge.h | 2 +- src/graph-manager.cpp | 60 ++++++------ src/graph-manager.h | 1 + src/node.cpp | 5 +- 12 files changed, 360 insertions(+), 34 deletions(-) create mode 100644 resources/block.svg create mode 100644 resources/delete.svg create mode 100644 resources/split.svg create mode 100644 resources/textures.svg rename resources/textures/{round-delete.png => delete.png} (100%) create mode 100644 resources/textures/split.png diff --git a/resources/block.svg b/resources/block.svg new file mode 100644 index 0000000..47ef9f8 --- /dev/null +++ b/resources/block.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + diff --git a/resources/delete.svg b/resources/delete.svg new file mode 100644 index 0000000..2f42747 --- /dev/null +++ b/resources/delete.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + diff --git a/resources/split.svg b/resources/split.svg new file mode 100644 index 0000000..ea23a2a --- /dev/null +++ b/resources/split.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + diff --git a/resources/textures.svg b/resources/textures.svg new file mode 100644 index 0000000..2f42747 --- /dev/null +++ b/resources/textures.svg @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + diff --git a/resources/textures/round-delete.png b/resources/textures/delete.png similarity index 100% rename from resources/textures/round-delete.png rename to resources/textures/delete.png diff --git a/resources/textures/split.png b/resources/textures/split.png new file mode 100644 index 0000000000000000000000000000000000000000..a5bb9b58dd67e2bd57ce7b78e3421d4c6b74e2fc GIT binary patch literal 2792 zcmVP)^c!`N*E^}_lGMBi87%pPw zwx)BN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gm->drawNodes(SCREEN_MOUSE, canvas->camera); gm->drawEdges(SCREEN_MOUSE, canvas->camera); + gm->drawNodes(SCREEN_MOUSE, canvas->camera); sm->drawSignals(SCREEN_MOUSE, canvas->camera); im.draw(); diff --git a/src/button.h b/src/button.h index dde5db0..c71e7fb 100644 --- a/src/button.h +++ b/src/button.h @@ -16,7 +16,7 @@ inline bool ViTexButton(Vec2Df mp, Vec2Df position, float rotation, float radius float scale = (radius*2.0f) / (float)tex.width; Vec2Df start_position = position - Vec2Df((tex.width*scale) / 2.0f, (tex.height*scale) / 2.0f); Vec2Df center_pos = start_position.rotateAround(position, rotation); - DrawTexturePro(tex, Rectangle(0.0, 0.0, tex.width, tex.height), Rectangle(center_pos.x, center_pos.y, tex.width*scale, tex.height*scale), Vec2Df(0,tex.height*scale/2.0f), rotation, color); + DrawTexturePro(tex, Rectangle(0.0, 0.0, tex.width, tex.height), Rectangle(center_pos.x, center_pos.y, tex.width*scale, tex.height*scale), Vec2Df(0.0f,tex.height*scale/2.0f), rotation, color); return (Vector2Distance(mp, position) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)); } diff --git a/src/edge.h b/src/edge.h index 24517f2..16dbb6f 100644 --- a/src/edge.h +++ b/src/edge.h @@ -32,7 +32,7 @@ namespace VISEQ::GRAPH::EDGES { float speed = 0; float bpm = 120.0f; - float connector_offset = 8.0f; + float connector_offset = 2.0f; float switches_offset = 25.0f; virtual bool GActive(); diff --git a/src/graph-manager.cpp b/src/graph-manager.cpp index 569cf61..36e262c 100644 --- a/src/graph-manager.cpp +++ b/src/graph-manager.cpp @@ -31,7 +31,8 @@ namespace VISEQ::GRAPH{ } void GraphManager::loadTextures(){ - tex_delete = LoadTexture("resources/textures/round-delete.png"); + tex_delete = LoadTexture("resources/textures/delete.png"); + tex_split = LoadTexture("resources/textures/split.png"); } int GraphManager::getNodesSize(){ @@ -359,29 +360,30 @@ 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() * (c->start.lock()->radius + c->switches_offset); - Vec2Df to_from_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm() * (c->end.lock()->radius + c->switches_offset); - Vec2Df middle_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position))*0.4f; - Vec2Df middle_handle_2 = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position))*0.6f; + Vec2Df from_to_handle = c->start.lock()->position - ((c->start.lock()->position - c->end.lock()->position)).norm()*40.0f; //.norm() * (c->start.lock()->radius + c->switches_offset); + Vec2Df to_from_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm()*40.0f; //.norm() * (c->end.lock()->radius + c->switches_offset); + Vec2Df middle_handle_2 = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position)).norm()*60.0f; + Vec2Df middle_handle = c->start.lock()->position - ((c->start.lock()->position - c->end.lock()->position)).norm()*60.0f; + Vec2Df center_handle = c->end.lock()->position - ((c->end.lock()->position - c->start.lock()->position))*0.5f; Vec2Df flip_handle = middle_handle + (v1_position - v2_position).norm().orth() * (v1_v2_distance < 120.0f ? Clamp((120.0f - v1_v2_distance)*0.2, 0.f, 20.f) : 1.0f); Vec2Df flip_handle_2 = middle_handle_2 + (v1_position - v2_position).norm().orth() * (v1_v2_distance < 120.0f ? Clamp((120.0f - v1_v2_distance)*-0.2, -20.f, 0.f) : 1.0f); // Dynamic opacity by distance to mouse - unsigned char opacity = 150.0f - Clamp(middle_handle.dist(mouse_pos), 0.0f, 150.0f); - unsigned char opacity_from = 250.0f - Clamp(from_to_handle.dist(mouse_pos), 0.0f, 220.0f); - unsigned char opacity_to = 250.0f - Clamp(to_from_handle.dist(mouse_pos), 0.0f, 220.0f); + unsigned char opacity = 200.0f; //150.0f - Clamp(middle_handle.dist(mouse_pos), 0.0f, 150.0f); + unsigned char opacity_from = 200.0f; //250.0f - Clamp(from_to_handle.dist(mouse_pos), 0.0f, 220.0f); + unsigned char opacity_to = 200.0f; //250.0f - Clamp(to_from_handle.dist(mouse_pos), 0.0f, 220.0f); - float opacity_normalized = Clamp((float)opacity / 255.0f, .0f, 1.0f); + float opacity_normalized = 0.80f; //Clamp((float)opacity / 255.0f, .0f, 1.0f); - float midi_gate_v1 = 0.0f; - float midi_gate_v2 = 0.0f; + // float midi_gate_v1 = 0.0f; + // float midi_gate_v2 = 0.0f; - if(c->start.lock()->getNodeType() == NodeType::MIDINODE){ - midi_gate_v1 = Clamp((4.f / 1000.f) * std::dynamic_pointer_cast(c->start.lock())->getNotes().gate, 1.f, 4.f); - } - if(c->end.lock()->getNodeType() == NodeType::MIDINODE){ - midi_gate_v2 = Clamp((4.f / 1000.f) * std::dynamic_pointer_cast(c->end.lock())->getNotes().gate, 1.f, 4.f); - } + // if(c->start.lock()->getNodeType() == NodeType::MIDINODE){ + // midi_gate_v1 = Clamp((4.f / 1000.f) * std::dynamic_pointer_cast(c->start.lock())->getNotes().gate, 1.f, 4.f); + // } + // if(c->end.lock()->getNodeType() == NodeType::MIDINODE){ + // midi_gate_v2 = Clamp((4.f / 1000.f) * std::dynamic_pointer_cast(c->end.lock())->getNotes().gate, 1.f, 4.f); + // } // Line with small connector circles if(c->end.lock()->getNodeType() == NodeType::MIDINODE && c->start.lock()->getNodeType() == NodeType::MIDINODE){ @@ -394,8 +396,8 @@ namespace VISEQ::GRAPH{ Vector2 text_length = MeasureTextEx(GetFontDefault(), std::format("{:.1f}",d).c_str(), 10.0f, 2.0f); Vector2 text_length_frac = MeasureTextEx(GetFontDefault(), frac.c_str(), 10.0f, 2.0f); - Vec2Df middle_handle = c->start.lock()->position + (c->end.lock()->position - c->start.lock()->position) * ((d - text_length.x)*0.5f)/d; - Vec2Df middle_handle_frac = c->start.lock()->position + (c->end.lock()->position - c->start.lock()->position) * ((d - text_length_frac.x)*0.5f)/d; + Vec2Df middle_handle = c->start.lock()->position + (c->end.lock()->position - c->start.lock()->position) * ((d - text_length.x)*0.35f)/d; + Vec2Df middle_handle_frac = c->start.lock()->position + (c->end.lock()->position - c->start.lock()->position) * ((d - text_length_frac.x)*0.35f)/d; Vec2Df text_position = middle_handle + (c->start.lock()->position - c->end.lock()->position).norm().orth() * 12.0f; Vec2Df text_position_frac = middle_handle_frac - (c->start.lock()->position - c->end.lock()->position).norm().orth() * 4.0f; @@ -403,12 +405,12 @@ namespace VISEQ::GRAPH{ DrawTextPro(GetFontDefault(), std::format("{:.1f}",d).c_str(), text_position, (Vector2){0,0}, rotation, 10.0f, 2.0f, VS_COLOR_PINK); if( (int)d % 60 == 0) DrawTextPro(GetFontDefault(), frac.c_str(), text_position_frac, (Vector2){0,0}, rotation, 10.0f, 2.0f, VS_COLOR_PINK); } - if(midi_gate_v1 == 4.0f) col = VS_COLOR_RED; - DrawCircle(v1_position.x, v1_position.y, midi_gate_v1, col); - - col = {229, 181, 103, 255}; - if(midi_gate_v2 == 4.0f) col = VS_COLOR_RED; - DrawCircle(v2_position.x, v2_position.y, midi_gate_v2, col); + // if(midi_gate_v1 == 4.0f) col = VS_COLOR_RED; + // DrawCircle(v1_position.x, v1_position.y, midi_gate_v1, col); + // + // col = {229, 181, 103, 255}; + // if(midi_gate_v2 == 4.0f) col = VS_COLOR_RED; + // DrawCircle(v2_position.x, v2_position.y, midi_gate_v2, col); if(!c->start.lock()->picked_up && !c->end.lock()->picked_up){ // On/Off switches on both sides @@ -426,15 +428,17 @@ namespace VISEQ::GRAPH{ Vec2Df block_point2 = (v1_position - v2_position).norm().orth()*-4.0f + to_from_handle; DrawLineEx(block_point1, block_point2, 2.0f, (Color){232,232,232,opacity_to}); } - - if(ViButton(mouse_pos, flip_handle_2.x, flip_handle_2.y, 8.0f, (Color){232, 125, 62, opacity} )) splitEdge(c); + if(IsWindowReady()){ + if(ViTexButton(mouse_pos, center_handle, HELPER::GetRotation(from_to_handle, to_from_handle) + 90.0f, 8.0f, tex_split, ColorLerp(Fade(VS_COLOR_WHITE, .0f), Fade(VS_COLOR_WHITE, 1.0f), opacity_normalized) )) splitEdge(c); + } } } if(c->start.lock()->getNodeType() == NodeType::CONFIGNODE || c->end.lock()->getNodeType() == NodeType::CONFIGNODE){ DrawLine(v1_position.x, v1_position.y, v2_position.x, v2_position.y, VS_COLOR_BLUE); } if(IsWindowReady()){ - if(ViTexButton(mouse_pos, flip_handle, HELPER::GetRotation(from_to_handle, to_from_handle), 8.0f, tex_delete, ColorLerp(Fade(VS_COLOR_WHITE, .0f), Fade(VS_COLOR_WHITE, 1.0f), opacity_normalized) )) removeEdge(c); + if(ViTexButton(mouse_pos, middle_handle, HELPER::GetRotation(from_to_handle, to_from_handle), 8.0f, tex_delete, ColorLerp(Fade(VS_COLOR_WHITE, .0f), Fade(VS_COLOR_WHITE, 1.0f), opacity_normalized) )) removeEdge(c); + if(ViTexButton(mouse_pos, middle_handle_2, HELPER::GetRotation(from_to_handle, to_from_handle), 8.0f, tex_delete, ColorLerp(Fade(VS_COLOR_WHITE, .0f), Fade(VS_COLOR_WHITE, 1.0f), opacity_normalized) )) removeEdge(c); } } } diff --git a/src/graph-manager.h b/src/graph-manager.h index 42a185c..ef25773 100644 --- a/src/graph-manager.h +++ b/src/graph-manager.h @@ -87,6 +87,7 @@ namespace VISEQ::GRAPH { friend void to_json(json& j, const std::shared_ptr& G); Texture2D tex_delete; + Texture2D tex_split; }; } diff --git a/src/node.cpp b/src/node.cpp index 4dc25bf..bc0a15d 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -76,11 +76,10 @@ namespace VISEQ::GRAPH::NODES { void Node::cycleMode(bool direction){ if(direction){ - mode = (mode + 1) % 7; + mode = (mode + 1) % 6; } else { - mode -= mode > 0 ? 1 : -6; + mode -= mode > 0 ? 1 : -5; } - std::cout << "mode changed to: " << mode << std::endl; } void to_json(json& j, const Node& N){