working on node ui
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "datatypes.h"
|
||||
#include "node.h"
|
||||
#include "raymath.h"
|
||||
|
||||
namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
@@ -11,9 +12,92 @@ namespace VISEQ::GRAPH::NODES {
|
||||
NodeType nodeType = NodeType::CONFIGNODE;
|
||||
|
||||
MIDI::MidiNote midiNote;
|
||||
MIDI::MidiCC midiCC;
|
||||
MIDI::MidiPitchBend midiPitchBend;
|
||||
MIDI::MidiPolyPressure midiPolyPressure;
|
||||
MIDI::MidiPC midiPC;
|
||||
|
||||
int mode = 0;
|
||||
|
||||
virtual NodeType getNodeType() const override {return nodeType;}
|
||||
|
||||
void draw(Vec2Df mouse, Camera2D cam) override {
|
||||
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) * midiNote.velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
||||
|
||||
float fade = 0;
|
||||
|
||||
float midi_gate_map = round((255.f / midiNote.gate) * fade);
|
||||
|
||||
Color gate_color = VS_COLOR_GREEN;
|
||||
|
||||
switch(mode){
|
||||
case 0:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){180, 210, 115, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
case 1:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){229, 181, 103, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
case 2:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){232, 125, 62, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
}
|
||||
if(!dragging && !selected && !in_rect && !hovering) DrawCircle(position.x, position.y, radius, gate_color);
|
||||
if(selected || dragging || in_rect || hovering) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
||||
|
||||
if(distributionMode == Distribution::RANDOM) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_PINK);
|
||||
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(IsKeyDown(KEY_LEFT_ALT)){
|
||||
float value = 0;
|
||||
int offset_gate = 0;
|
||||
switch(mode){
|
||||
case 0:
|
||||
value = (float)midiNote.gate/1000.0f;
|
||||
offset_gate = MeasureText(std::format("{:.2f}", value).c_str(), 12);
|
||||
DrawText(std::format("{:.2f}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
case 1:
|
||||
value = (float)midiCC.value;
|
||||
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
||||
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
case 2:
|
||||
value = (float)midiPitchBend.value;
|
||||
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
||||
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(mode){
|
||||
case 0:{
|
||||
int offset = MeasureText(MIDI::Notes[(int)midiNote.note].c_str(), 12);
|
||||
DrawText(MIDI::Notes[midiNote.note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
case 1:{
|
||||
int offset = MeasureText(std::format("{}", midiCC.value).c_str(), 12);
|
||||
DrawText(std::format("{}", midiCC.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
case 2:{
|
||||
int offset = MeasureText(std::format("{}", midiPitchBend.value).c_str(), 12);
|
||||
DrawText(std::format("{}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
}
|
||||
}
|
||||
|
||||
Vec2Df connector = position - ((position - mouse)).norm() * (radius + 30);
|
||||
float opacity = 150.0f - Clamp(position.dist(mouse), 0.0f, 150.0f);
|
||||
|
||||
if(hover_connect){
|
||||
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, 255});
|
||||
} else {
|
||||
DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});
|
||||
}
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace VISEQ::GRAPH::EDGES {
|
||||
float switches_offset = 25.0f;
|
||||
|
||||
virtual bool GActive() {return active;}
|
||||
|
||||
virtual EdgeType getEdgeType() const {return edgeType;}
|
||||
|
||||
std::shared_ptr<NODES::Node> getNextNode(std::shared_ptr<NODES::Node> origin){
|
||||
return start == origin ? end : start;
|
||||
|
||||
+20
-2
@@ -154,15 +154,19 @@ int main(){
|
||||
|
||||
app.sm.startSignalThread();
|
||||
|
||||
enum InteractionState {HOVER_CANVAS, HOVER_NODE, HOVER_CONNECTOR, DRAG_NODE, CONNECT_NODE, DRAW_SELECTION, SCALE_SELECTION, DELETE_SELECTED_NODES, COPY_SELECTED_NODES, PASTE_SELECTED_NODES};
|
||||
enum InteractionState {HOVER_CANVAS, HOVER_NODE, HOVER_CONNECTOR, ADD_NODES_MENU, DRAG_NODE, CONNECT_NODE, DRAW_SELECTION, SCALE_SELECTION, DELETE_SELECTED_NODES, COPY_SELECTED_NODES, PASTE_SELECTED_NODES};
|
||||
InteractionState istate = HOVER_CANVAS;
|
||||
|
||||
Vec2Df node_menu_position;
|
||||
|
||||
Vec2Df select_start;
|
||||
Rectangle selection;
|
||||
|
||||
Vec2Df scale_start;
|
||||
Vec2Df scale_rectangle;
|
||||
|
||||
float drag_distance = 0;
|
||||
|
||||
VEC_SPTR_Node copied_nodes;
|
||||
|
||||
|
||||
@@ -200,7 +204,7 @@ int main(){
|
||||
if(hovering_connectors.empty()) n->hover_connect = false;
|
||||
}
|
||||
|
||||
if(!mouse_down && !mouse_right_down && dragging_nodes.empty() && connecting_nodes.empty() && hovering_nodes.empty() && hovering_connectors.empty()) istate = InteractionState::HOVER_CANVAS;
|
||||
if(istate != InteractionState::ADD_NODES_MENU && !mouse_down && !mouse_right_down && dragging_nodes.empty() && connecting_nodes.empty() && hovering_nodes.empty() && hovering_connectors.empty()) istate = InteractionState::HOVER_CANVAS;
|
||||
if((mouse_clicked || mouse_down || mouse_released) && !mouse_right_down && dragging_nodes.empty() && connecting_nodes.empty() && hovering_nodes.empty() && hovering_connectors.empty() && istate != InteractionState::SCALE_SELECTION) istate = InteractionState::DRAW_SELECTION;
|
||||
|
||||
if(!hovering_nodes.empty() && !mouse_down && !mouse_right_down) istate = InteractionState::HOVER_NODE;
|
||||
@@ -271,11 +275,25 @@ int main(){
|
||||
for(auto &n : app.gm.nodes){
|
||||
n->hover_connect = false;
|
||||
}
|
||||
if(mouse_right_clicked){
|
||||
drag_distance = 0;
|
||||
}
|
||||
if(mouse_right_down) {
|
||||
camera.target = Vector2Add(camera.target, delta);
|
||||
drag_distance += delta.length();
|
||||
}
|
||||
if(mouse_right_released && drag_distance < 5) {
|
||||
node_menu_position = mouse_pos;
|
||||
istate = InteractionState::ADD_NODES_MENU;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InteractionState::ADD_NODES_MENU:
|
||||
{
|
||||
DrawCircleV(node_menu_position, 30, VS_COLOR_LIGHTGREY);
|
||||
DrawCircleLines(node_menu_position.x, node_menu_position.y, 32, VS_COLOR_DARKGREY);
|
||||
|
||||
}
|
||||
case InteractionState::DRAW_SELECTION:
|
||||
{
|
||||
if(mouse_clicked){
|
||||
|
||||
Reference in New Issue
Block a user