working on node ui

This commit is contained in:
Sebastian
2024-11-08 01:43:06 +01:00
parent 529106e815
commit cdc0fb7075
4 changed files with 106 additions and 3 deletions
+20 -2
View File
@@ -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){