- [Graph Panel] Using ctrl to move connection will now swap connection in the same node.

This commit is contained in:
Tanasart 2024-08-02 20:11:05 +07:00
parent f285ada4d0
commit 8dfd2d3c88
2 changed files with 12 additions and 5 deletions

File diff suppressed because one or more lines are too long

View file

@ -285,6 +285,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
_value_focus = noone; _value_focus = noone;
value_dragging = noone; value_dragging = noone;
value_draggings = []; value_draggings = [];
value_drag_from = noone;
frame_hovering = noone; frame_hovering = noone;
_frame_hovering = noone; _frame_hovering = noone;
@ -794,8 +795,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function dragGraph() { function dragGraph() {
if(graph_autopan) { if(graph_autopan) {
graph_x = lerp_float(graph_x, graph_pan_x_to, 16, 1); graph_x = lerp_float(graph_x, graph_pan_x_to, 32, 1);
graph_y = lerp_float(graph_y, graph_pan_y_to, 16, 1); graph_y = lerp_float(graph_y, graph_pan_y_to, 32, 1);
if(graph_x == graph_pan_x_to && graph_y == graph_pan_y_to) if(graph_x == graph_pan_x_to && graph_y == graph_pan_y_to)
graph_autopan = false; graph_autopan = false;
@ -1737,6 +1738,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
target.node.addInput(value_draggings[i]); target.node.addInput(value_draggings[i]);
} else { } else {
if(value_drag_from && target.value_from && value_drag_from.node == target.node)
value_drag_from.setFrom(target.value_from);
_connect = [ target.setFrom(value_dragging), target, value_dragging ]; _connect = [ target.setFrom(value_dragging), target, value_dragging ];
} }
} }
@ -1894,7 +1898,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
} }
function drawJunctionConnect() { #region function drawJunctionConnect() {
var _focus = pFOCUS && !view_hovering; var _focus = pFOCUS && !view_hovering;
if(value_dragging) if(value_dragging)
@ -1903,6 +1907,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(value_dragging == noone && value_focus && mouse_press(mb_left, _focus) && !key_mod_press(ALT)) { if(value_dragging == noone && value_focus && mouse_press(mb_left, _focus) && !key_mod_press(ALT)) {
value_dragging = value_focus; value_dragging = value_focus;
value_draggings = []; value_draggings = [];
value_drag_from = noone;
if(value_dragging.connect_type == JUNCTION_CONNECT.output) { if(value_dragging.connect_type == JUNCTION_CONNECT.output) {
if(key_mod_press(CTRL)) { if(key_mod_press(CTRL)) {
@ -1946,6 +1951,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(value_dragging.connect_type == JUNCTION_CONNECT.input) { if(value_dragging.connect_type == JUNCTION_CONNECT.input) {
if(key_mod_press(CTRL) && value_dragging.value_from) { if(key_mod_press(CTRL) && value_dragging.value_from) {
value_drag_from = value_dragging;
var fr = value_dragging.value_from; var fr = value_dragging.value_from;
value_dragging.removeFrom(); value_dragging.removeFrom();
value_dragging = fr; value_dragging = fr;
@ -1964,7 +1971,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
_node.drawJunctionNames(gr_x, gr_y, mx, my, graph_s); _node.drawJunctionNames(gr_x, gr_y, mx, my, graph_s);
} }
} #endregion }
function callAddDialog(ctx = getCurrentContext()) { #region function callAddDialog(ctx = getCurrentContext()) { #region
var _dia = dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx }); var _dia = dialogCall(o_dialog_add_node, mouse_mx + 8, mouse_my + 8, { context: ctx });