- [Graph] Hold ctrl while dragging output junction to disconnect multiple connections at once.

This commit is contained in:
MakhamDev 2023-10-16 18:54:31 +07:00
parent d8c5fd2d3d
commit b1b422d79b
2 changed files with 71 additions and 68 deletions

View File

@ -2147,28 +2147,20 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
switch(PREF_MAP[? "curve_connection_line"]) { switch(PREF_MAP[? "curve_connection_line"]) {
case 0 : case 0 :
if(ty == LINE_STYLE.solid) if(ty == LINE_STYLE.solid) draw_line_width_color(jx, jy, frx, fry, th, c1, c0);
draw_line_width_color(jx, jy, frx, fry, th, c1, c0); else draw_line_dashed_color(jx, jy, frx, fry, th, c1, c0, 12 * ss);
else
draw_line_dashed_color(jx, jy, frx, fry, th, c1, c0, 12 * ss);
break; break;
case 1 : case 1 :
if(downDirection) if(downDirection) draw_line_curve_corner(jx, jy, frx, fry, ss, th, c0, c1);
draw_line_curve_corner(jx, jy, frx, fry, ss, th, c0, c1); else draw_line_curve_color(jx, jy, frx, fry, cx, cy, ss, th, c0, c1, ty);
else
draw_line_curve_color(jx, jy, frx, fry, cx, cy, ss, th, c0, c1, ty);
break; break;
case 2 : case 2 :
if(downDirection) if(downDirection) draw_line_elbow_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
draw_line_elbow_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); else draw_line_elbow_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
else
draw_line_elbow_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
break; break;
case 3 : case 3 :
if(downDirection) if(downDirection) draw_line_elbow_diag_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
draw_line_elbow_diag_corner(frx, fry, jx, jy, ss, th, c0, c1, corner, fromIndex, toIndex, ty); else draw_line_elbow_diag_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
else
draw_line_elbow_diag_color(frx, fry, jx, jy, cx, cy, ss, th, c0, c1, corner, fromIndex, toIndex, ty);
break; break;
} }
@ -2181,52 +2173,43 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
drawCorner |= target.type == VALUE_TYPE.action; drawCorner |= target.type == VALUE_TYPE.action;
var corner = PREF_MAP[? "connection_line_corner"] * ss; var corner = PREF_MAP[? "connection_line_corner"] * ss;
var th = PREF_MAP[? "connection_line_width"] * ss; var th = max(1, PREF_MAP[? "connection_line_width"] * ss);
var col = color_display; var col = color_display;
draw_set_color(col); draw_set_color(col);
var _action = type == VALUE_TYPE.action;
var _output = connect_type == JUNCTION_CONNECT.output;
switch(PREF_MAP[? "curve_connection_line"]) { switch(PREF_MAP[? "curve_connection_line"]) {
case 0 : case 0 :
draw_line_width(x, y, _mx, _my, th); draw_line_width(x, y, _mx, _my, th);
break; break;
case 1 : case 1 :
if(drawCorner) { if(drawCorner) {
if(type == VALUE_TYPE.action) if(_action) draw_line_curve_corner(_mx, _my, x, y, ss, th, col, col);
draw_line_curve_corner(_mx, _my, x, y, ss, th, col, col); else draw_line_curve_corner(x, y, _mx, _my, ss, th, col, col);
else
draw_line_curve_corner(x, y, _mx, _my, ss, th, col, col);
} else { } else {
if(connect_type == JUNCTION_CONNECT.output) if(_output) draw_line_curve_color(_mx, _my, x, y,,, ss, th, col, col);
draw_line_curve_color(_mx, _my, x, y,,, ss, th, col, col); else draw_line_curve_color(x, y, _mx, _my,,, ss, th, col, col);
else
draw_line_curve_color(x, y, _mx, _my,,, ss, th, col, col);
} }
break; break;
case 2 : case 2 :
if(drawCorner) { if(drawCorner) {
if(type == VALUE_TYPE.action) if(_action) draw_line_elbow_corner(_mx, _my, x, y, ss, th, col, col, corner);
draw_line_elbow_corner(_mx, _my, x, y, ss, th, col, col, corner); else draw_line_elbow_corner(x, y, _mx, _my, ss, th, col, col, corner);
else
draw_line_elbow_corner(x, y, _mx, _my, ss, th, col, col, corner);
} else { } else {
if(connect_type == JUNCTION_CONNECT.output) if(_output) draw_line_elbow_color(x, y, _mx, _my,,, ss, th, col, col, corner);
draw_line_elbow_color(x, y, _mx, _my,,, ss, th, col, col, corner); else draw_line_elbow_color(_mx, _my, x, y,,, ss, th, col, col, corner);
else
draw_line_elbow_color(_mx, _my, x, y,,, ss, th, col, col, corner);
} }
break; break;
case 3 : case 3 :
if(drawCorner) { if(drawCorner) {
if(type == VALUE_TYPE.action) if(_action) draw_line_elbow_diag_corner(_mx, _my, x, y, ss, th, col, col, corner);
draw_line_elbow_diag_corner(_mx, _my, x, y, ss, th, col, col, corner); else draw_line_elbow_diag_corner(x, y, _mx, _my, ss, th, col, col, corner);
else
draw_line_elbow_diag_corner(x, y, _mx, _my, ss, th, col, col, corner);
} else { } else {
if(connect_type == JUNCTION_CONNECT.output) if(_output) draw_line_elbow_diag_color(x, y, _mx, _my,,, ss, th, col, col, corner);
draw_line_elbow_diag_color(x, y, _mx, _my,,, ss, th, col, col, corner); else draw_line_elbow_diag_color(_mx, _my, x, y,,, ss, th, col, col, corner);
else
draw_line_elbow_diag_color(_mx, _my, x, y,,, ss, th, col, col, corner);
} }
break; break;
} }

View File

@ -948,13 +948,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(val) { if(val) {
if(key_mod_press(SHIFT)) if(key_mod_press(SHIFT))
TOOLTIP = [ val.getValue(), val.type ]; TOOLTIP = [ val.getValue(), val.type ];
value_focus = val;
if(key_mod_press(CTRL) && val.value_from != noone) {
value_focus = val.value_from;
if(mouse_press(mb_left))
val.removeFrom();
} else
value_focus = val;
} }
} }
@ -1132,6 +1126,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(value_focus && value_focus != value_dragging && value_focus.connect_type != value_dragging.connect_type) if(value_focus && value_focus != value_dragging && value_focus.connect_type != value_dragging.connect_type)
target = value_focus; target = value_focus;
if(key_mod_press(CTRL) && node_hovering != noone) { if(key_mod_press(CTRL) && node_hovering != noone) {
if(value_dragging.connect_type == JUNCTION_CONNECT.input) { if(value_dragging.connect_type == JUNCTION_CONNECT.input) {
target = node_hovering.getOutput(value_dragging); target = node_hovering.getOutput(value_dragging);
@ -1157,7 +1152,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for( var i = 0, n = array_length(value_draggings); i < n; i++ ) { for( var i = 0, n = array_length(value_draggings); i < n; i++ ) {
var _dmx = _mmx; var _dmx = _mmx;
var _dmy = _mmy + (i - _stIndex) * 24 * graph_s; var _dmy = value_draggings[i].connect_type == JUNCTION_CONNECT.output? _mmy + (i - _stIndex) * 24 * graph_s : _mmy;
value_draggings[i].drawConnectionMouse(_dmx, _dmy, graph_s, target); value_draggings[i].drawConnectionMouse(_dmx, _dmy, graph_s, target);
} }
@ -1169,11 +1164,16 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(mouse_release(mb_left)) { // CONNECT junction if(mouse_release(mb_left)) { // CONNECT junction
if(target != noone) { if(target != noone) {
if(value_dragging.connect_type == JUNCTION_CONNECT.input) if(value_dragging.connect_type == JUNCTION_CONNECT.input) {
value_dragging.setFrom(target); if(array_empty(value_draggings))
else if(!_addInput) value_dragging.setFrom(target);
else {
for( var i = 0, n = array_length(value_draggings); i < n; i++ )
value_draggings[i].setFrom(target);
}
} else if(!_addInput) {
target.setFrom(value_dragging); target.setFrom(value_dragging);
else { //addInput } else { //addInput
if(array_empty(value_draggings)) if(array_empty(value_draggings))
target.node.addInput(value_dragging); target.node.addInput(value_dragging);
else { else {
@ -1204,24 +1204,44 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
value_draggings = []; value_draggings = [];
if(value_dragging.connect_type == JUNCTION_CONNECT.output) { if(value_dragging.connect_type == JUNCTION_CONNECT.output) {
var _jlist = ds_priority_create(); if(key_mod_press(CTRL)) {
var _to = value_dragging.getJunctionTo();
for( var i = 0, n = ds_list_size(nodes_select_list); i < n; i++ ) { if(array_length(_to)) {
var _node = nodes_select_list[| i]; value_dragging = _to[0];
value_draggings = array_create(array_length(_to));
for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) { for( var i = 0, n = array_length(_to); i < n; i++ ) {
var _junction = _node.outputs[| j]; value_draggings[i] = _to[i];
if(!_junction.visible) continue; _to[i].removeFrom();
if(value_bit(_junction.type) & value_bit(value_dragging.type) == 0) continue; }
ds_priority_add(_jlist, _junction, _junction.y);
} }
} else {
var _jlist = ds_priority_create();
for( var i = 0, n = ds_list_size(nodes_select_list); i < n; i++ ) {
var _node = nodes_select_list[| i];
for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) {
var _junction = _node.outputs[| j];
if(!_junction.visible) continue;
if(value_bit(_junction.type) & value_bit(value_dragging.type) == 0) continue;
ds_priority_add(_jlist, _junction, _junction.y);
}
}
while(!ds_priority_empty(_jlist))
array_push(value_draggings, ds_priority_delete_min(_jlist));
ds_priority_destroy(_jlist);
}
} else {
if(key_mod_press(CTRL) && value_dragging.value_from) {
var fr = value_dragging.value_from;
value_dragging.removeFrom();
value_dragging = fr;
} }
while(!ds_priority_empty(_jlist))
array_push(value_draggings, ds_priority_delete_min(_jlist));
ds_priority_destroy(_jlist);
} }
} }