[Graph Panel] Refactor selection to use single array.

This commit is contained in:
Tanasart 2023-11-03 09:22:02 +07:00
parent 6e336452c5
commit a344c06035
12 changed files with 284 additions and 369 deletions

View file

@ -1,79 +1,79 @@
function node_halign(nodeList, alignment = fa_center) {
var amo = ds_list_size(nodeList);
var amo = array_length(nodeList);
switch(alignment) {
case fa_left:
var x0 = 999999;
for( var i = 0; i < amo; i++ )
x0 = min(x0, nodeList[| i].x);
x0 = min(x0, nodeList[i].x);
for( var i = 0; i < amo; i++ )
nodeList[| i].x = x0;
nodeList[i].x = x0;
break;
case fa_center:
var xc = 0;
for( var i = 0; i < amo; i++ )
xc += nodeList[| i].x + nodeList[| i].w / 2;
xc += nodeList[i].x + nodeList[i].w / 2;
xc /= amo;
for( var i = 0; i < amo; i++ )
nodeList[| i].x = xc - nodeList[| i].w / 2;
nodeList[i].x = xc - nodeList[i].w / 2;
break;
case fa_right:
var x0 = -999999;
for( var i = 0; i < amo; i++ )
x0 = max(x0, nodeList[| i].x + nodeList[| i].w);
x0 = max(x0, nodeList[i].x + nodeList[i].w);
for( var i = 0; i < amo; i++ )
nodeList[| i].x = x0 - nodeList[| i].w;
nodeList[i].x = x0 - nodeList[i].w;
break;
}
}
function node_valign(nodeList, alignment = fa_middle) {
var amo = ds_list_size(nodeList);
var amo = array_length(nodeList);
switch(alignment) {
case fa_top:
var y0 = 999999;
for( var i = 0; i < amo; i++ )
y0 = min(y0, nodeList[| i].y);
y0 = min(y0, nodeList[i].y);
for( var i = 0; i < amo; i++ )
nodeList[| i].y = y0;
nodeList[i].y = y0;
break;
case fa_middle:
var yc = 0;
for( var i = 0; i < amo; i++ )
yc += nodeList[| i].y + nodeList[| i].h / 2;
yc += nodeList[i].y + nodeList[i].h / 2;
yc /= amo;
for( var i = 0; i < amo; i++ )
nodeList[| i].y = yc - nodeList[| i].h / 2;
nodeList[i].y = yc - nodeList[i].h / 2;
break;
case fa_bottom:
var y0 = -999999;
for( var i = 0; i < amo; i++ )
y0 = max(y0, nodeList[| i].y + nodeList[| i].h);
y0 = max(y0, nodeList[i].y + nodeList[i].h);
for( var i = 0; i < amo; i++ )
nodeList[| i].y = y0 - nodeList[| i].h;
nodeList[i].y = y0 - nodeList[i].h;
break;
}
}
function node_hdistribute(nodeList) {
var amo = ds_list_size(nodeList);
var amo = array_length(nodeList);
var nodes = ds_priority_create();
var x0 = 999999;
var x1 = -999999;
for( var i = 0; i < amo; i++ ) {
var _x = nodeList[| i].x + nodeList[| i].w / 2;
var _x = nodeList[i].x + nodeList[i].w / 2;
x0 = min(x0, _x);
x1 = max(x1, _x);
ds_priority_add(nodes, nodeList[| i], _x);
ds_priority_add(nodes, nodeList[i], _x);
}
var sp = (x1 - x0) / (amo - 1);
@ -93,11 +93,11 @@ function node_vdistribute(nodeList) {
var y0 = 999999;
var y1 = -999999;
for( var i = 0; i < amo; i++ ) {
var _y = nodeList[| i].y + nodeList[| i].h / 2;
var _y = nodeList[i].y + nodeList[i].h / 2;
y0 = min(y0, _y);
y1 = max(y1, _y);
ds_priority_add(nodes, nodeList[| i], _y);
ds_priority_add(nodes, nodeList[i], _y);
}
var sp = (y1 - y0) / (amo - 1);

View file

@ -1153,6 +1153,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
}
} #endregion
static groupCheck = function(_x, _y, _s, _mx, _my) {}
static drawNodeBG = function(_x, _y, _mx, _my, _s, display_parameter = noone) {}
static drawNode = function(_x, _y, _mx, _my, _s, display_parameter = noone) { #region
@ -1179,7 +1181,7 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
}
drawDimension(xx, yy, _s);
onDrawNode(xx, yy, _mx, _my, _s, PANEL_GRAPH.node_hovering == self, PANEL_GRAPH.node_focus == self);
onDrawNode(xx, yy, _mx, _my, _s, PANEL_GRAPH.node_hovering == self, PANEL_GRAPH.getFocusingNode() == self);
drawNodeName(xx, yy, _s);
if(active_draw_index > -1) {
@ -1258,7 +1260,8 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
disable();
if(PANEL_GRAPH.node_hover == self) PANEL_GRAPH.node_hover = noone;
if(PANEL_GRAPH.node_focus == self) PANEL_GRAPH.node_focus = noone;
PANEL_GRAPH.nodes_selecting = [];
if(PANEL_INSPECTOR.inspecting == self) PANEL_INSPECTOR.inspecting = noone;
PANEL_PREVIEW.removeNodePreview(self);

View file

@ -255,7 +255,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
}
draw_set_alpha(1);
if(PANEL_GRAPH.node_hovering == self && PANEL_GRAPH.node_focus == self) {
if(PANEL_GRAPH.node_hovering == self && PANEL_GRAPH.getFocusingNode() == self) {
if(point_in_rectangle(mx, my, xx, yy, xx + ww + 8, yy + hh + 8) && DOUBLE_CLICK) {
ta_editor._current_text = txt;
ta_editor.activate();

View file

@ -177,8 +177,7 @@
function graphFocusNode(node) {
PANEL_INSPECTOR.setInspecting(node);
ds_list_clear(PANEL_GRAPH.nodes_select_list);
PANEL_GRAPH.node_focus = node;
PANEL_GRAPH.nodes_selecting = [ node ];
PANEL_GRAPH.fullView();
}

View file

@ -133,9 +133,6 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
_splice.inputs[| 2].setValue(amo);
_splice.inputs[| 3].setValue([ amo, 1 ]);
_splice.inspector1Update();
ds_list_add(PANEL_GRAPH.nodes_select_list, self);
ds_list_add(PANEL_GRAPH.nodes_select_list, _splice);
}
}
}

View file

@ -70,7 +70,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_drag_oy = 0;
selection_block = 0;
nodes_select_list = ds_list_create();
nodes_selecting = [];
nodes_select_drag = false;
nodes_select_mx = 0;
nodes_select_my = 0;
@ -81,7 +81,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_hovering = noone;
node_hover = noone;
node_focus = noone;
junction_hovering = noone;
add_node_draw_junc = false;
@ -213,7 +212,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
addHotkey("Graph", "Add node", "A", MOD_KEY.none, function() { PANEL_GRAPH.callAddDialog(); });
addHotkey("Graph", "Focus content", "F", MOD_KEY.none, function() { PANEL_GRAPH.fullView(); });
addHotkey("Graph", "Preview focusing node", "P", MOD_KEY.none, function() { PANEL_GRAPH.setCurrentPreview(); });
addHotkey("Graph", "Preview window", "P", MOD_KEY.ctrl, function() { create_preview_window(PANEL_GRAPH.node_focus); });
addHotkey("Graph", "Preview window", "P", MOD_KEY.ctrl, function() { create_preview_window(PANEL_GRAPH.getFocusingNode()); });
addHotkey("Graph", "Import image", "I", MOD_KEY.none, function() { nodeBuild("Node_Image", PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y); });
addHotkey("Graph", "Import image array", "I", MOD_KEY.shift, function() { nodeBuild("Node_Image_Sequence", PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y); });
addHotkey("Graph", "Add number", "1", MOD_KEY.none, function() { nodeBuild("Node_Number", PANEL_GRAPH.mouse_grid_x, PANEL_GRAPH.mouse_grid_y); });
@ -223,16 +222,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
addHotkey("Graph", "Transform node", "T", MOD_KEY.ctrl, function() { PANEL_GRAPH.doTransform(); });
addHotkey("Graph", "Select all", "A", MOD_KEY.ctrl, function() {
ds_list_clear(nodes_select_list);
for(var i = 0; i < ds_list_size(nodes_list); i++) {
ds_list_add(nodes_select_list, nodes_list[| i]);
}
});
addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { display_parameter.show_grid = !display_parameter.show_grid; });
addHotkey("Graph", "Toggle preview", "H", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerPreview(); });
addHotkey("Graph", "Toggle render", "R", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerRender(); });
addHotkey("Graph", "Select all", "A", MOD_KEY.ctrl, function() { nodes_selecting = ds_list_to_array(nodes_list); });
addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, function() { display_parameter.show_grid = !display_parameter.show_grid; });
addHotkey("Graph", "Toggle preview", "H", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerPreview(); });
addHotkey("Graph", "Toggle render", "R", MOD_KEY.none, function() { PANEL_GRAPH.setTriggerRender(); });
if(!DEMO)
addHotkey("Graph", "Export", "E", MOD_KEY.ctrl, function() { PANEL_GRAPH.setCurrentExport(); });
@ -269,13 +262,13 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#endregion
#region ++++ node setters ++++
function setCurrentPreview(_node = node_focus) { #region
function setCurrentPreview(_node = getFocusingNode()) { #region
if(!_node) return;
PANEL_PREVIEW.setNodePreview(_node);
} #endregion
function setCurrentExport(_node = node_focus) { #region
function setCurrentExport(_node = getFocusingNode()) { #region
if(DEMO) return;
if(!_node) return;
@ -298,7 +291,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
_export.inputs[| 0].setFrom(_outp);
} #endregion
function setCurrentCanvas(_node = node_focus) { #region
function setCurrentCanvas(_node = getFocusingNode()) { #region
if(!_node) return;
var _outp = -1;
@ -326,28 +319,22 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function setTriggerPreview() { #region
if(node_focus != noone)
node_focus.previewable = !node_focus.previewable;
var show = false;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
if(i == 0) show = !nodes_select_list[| i].previewable;
nodes_select_list[| i].previewable = show;
}
__temp_show = false;
array_foreach(nodes_selecting, function(node, index) {
if(index == 0) __temp_show = !node.previewable;
node.previewable = __temp_show;
});
} #endregion
function setTriggerRender() { #region
if(node_focus != noone)
node_focus.renderActive = !node_focus.renderActive;
var show = false;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
if(i == 0) show = !nodes_select_list[| i].renderActive;
nodes_select_list[| i].renderActive = show;
}
__temp_active = false;
array_foreach(nodes_selecting, function(node, index) {
if(index == 0) __temp_active = !node.renderActive;
node.renderActive = __temp_active;
});
} #endregion
function setCurrentCanvasBlend(_node = node_focus) { #region
function setCurrentCanvasBlend(_node = getFocusingNode()) { #region
if(!_node) return;
var _outp = -1;
@ -421,18 +408,18 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
menu_nodes_align = menuItem(__txtx("panel_graph_align_nodes", "Align nodes"), function(_dat) {
return submenuCall(_dat, [
menuItemGroup(__txtx("horizontal", "Horizontal"), [
[ [THEME.inspector_surface_halign, 0], function() { node_halign(nodes_select_list, fa_left); } ],
[ [THEME.inspector_surface_halign, 1], function() { node_halign(nodes_select_list, fa_center); } ],
[ [THEME.inspector_surface_halign, 2], function() { node_halign(nodes_select_list, fa_right); } ],
[ [THEME.inspector_surface_halign, 0], function() { node_halign(nodes_selecting, fa_left); } ],
[ [THEME.inspector_surface_halign, 1], function() { node_halign(nodes_selecting, fa_center); } ],
[ [THEME.inspector_surface_halign, 2], function() { node_halign(nodes_selecting, fa_right); } ],
]),
menuItemGroup(__txtx("vertical", "Vertical"), [
[ [THEME.inspector_surface_valign, 0], function() { node_valign(nodes_select_list, fa_top); } ],
[ [THEME.inspector_surface_valign, 1], function() { node_valign(nodes_select_list, fa_middle); } ],
[ [THEME.inspector_surface_valign, 2], function() { node_valign(nodes_select_list, fa_bottom); } ],
[ [THEME.inspector_surface_valign, 0], function() { node_valign(nodes_selecting, fa_top); } ],
[ [THEME.inspector_surface_valign, 1], function() { node_valign(nodes_selecting, fa_middle); } ],
[ [THEME.inspector_surface_valign, 2], function() { node_valign(nodes_selecting, fa_bottom); } ],
]),
menuItemGroup(__txtx("distribute", "Distribute"), [
[ [THEME.obj_distribute_h, 0], function() { node_hdistribute(nodes_select_list); } ],
[ [THEME.obj_distribute_v, 0], function() { node_vdistribute(nodes_select_list); } ],
[ [THEME.obj_distribute_h, 0], function() { node_hdistribute(nodes_selecting); } ],
[ [THEME.obj_distribute_v, 0], function() { node_vdistribute(nodes_selecting); } ],
]),
]);
}).setIsShelf();
@ -447,11 +434,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region node color
function setSelectingNodeColor(color) {
if(node_hover == noone) return;
node_hover.attributes.color = color;
__temp_color = color;
for(var i = 0; i < ds_list_size(nodes_select_list); i++)
nodes_select_list[| i].attributes.color = color;
if(node_hover) node_hover.attributes.color = __temp_color;
array_foreach(nodes_selecting, function(node) { node.attributes.color = __temp_color; });
}
var _clrs = COLORS.labels;
@ -489,13 +475,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(__junction_hovering.value_from != noone)
__junction_hovering.value_from.color = color;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
for( var j = 0, m = ds_list_size(_node.inputs); j < m; j++ ) {
var _input = _node.inputs[| j];
if(_input.isLeaf()) continue;
if(!ds_exists(_input.value_from.node, nodes_select_list)) continue;
_input.color = color;
_input.value_from.color = color;
@ -529,6 +514,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#endregion
#endregion
function getFocusingNode() { gml_pragma("forceinline"); return array_empty(nodes_selecting)? noone : nodes_selecting[0]; }
function getCurrentContext() { #region
if(ds_list_empty(node_context)) return noone;
return node_context[| ds_list_size(node_context) - 1];
@ -556,11 +543,15 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function focusNode(_node) { #region
node_focus = _node;
if(_node == noone) return;
if(_node == noone) {
nodes_selecting = [];
return;
}
var cx = node_focus.x + node_focus.w / 2;
var cy = node_focus.y + node_focus.h / 2;
nodes_selecting = [ _node ];
var cx = _node.x + _node.w / 2;
var cy = _node.y + _node.h / 2;
graph_x = w / 2 / graph_s - cx;
graph_y = (h - toolbar_height) / 2 / graph_s - cy;
@ -570,13 +561,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function fullView() { #region
if(node_focus == noone) {
var _node = getFocusingNode();
if(_node == noone) {
toCenterNode();
return;
}
graph_x = -(node_focus.x + node_focus.w / 2) + w / 2 / graph_s;
graph_y = -(node_focus.y + node_focus.h / 2) + h / 2 / graph_s;
graph_x = -(_node.x + _node.w / 2) + w / 2 / graph_s;
graph_y = -(_node.y + _node.h / 2) + h / 2 / graph_s;
graph_x = round(graph_x);
graph_y = round(graph_y);
@ -740,7 +732,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function drawNodes() { #region
if(selection_block-- > 0) return;
//print("==== DRAW NODES ====");
display_parameter.highlight = (!ds_list_empty(nodes_select_list) || node_focus != noone) * PREFERENCES.connection_line_highlight;
display_parameter.highlight = !array_empty(nodes_selecting) * PREFERENCES.connection_line_highlight;
var gr_x = graph_x * graph_s;
var gr_y = graph_y * graph_s;
@ -794,64 +786,58 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
} else if(mouse_press(mb_left, pFOCUS)) {
if(key_mod_press(SHIFT)) {
if(ds_list_empty(nodes_select_list) && node_focus)
ds_list_add(nodes_select_list, node_focus);
if(node_focus != node_hovering)
ds_list_add(nodes_select_list, node_hovering);
if(node_hovering) {
if(array_exists(nodes_selecting, node_hovering))
array_remove(nodes_selecting, node_hovering);
else
array_push(nodes_selecting, node_hovering);
} else
nodes_selecting = [];
} else if(value_focus || node_hovering == noone) {
nodes_selecting = [];
if(DOUBLE_CLICK && !PANEL_INSPECTOR.locked)
PANEL_INSPECTOR.inspecting = noone;
} else {
var _prevFocus = node_focus;
if(node_hovering != noone || value_focus == noone)
node_focus = node_hovering;
if(is_instanceof(node_hovering, Node_Frame)) {
var fx0 = (node_hovering.x + graph_x) * graph_s;
var fy0 = (node_hovering.y + graph_y) * graph_s;
var fx1 = fx0 + node_hovering.w * graph_s;
var fy1 = fy0 + node_hovering.h * graph_s;
if(node_focus) {
if(is_instanceof(node_focus, Node_Frame)) {
var fx0 = (node_focus.x + graph_x) * graph_s;
var fy0 = (node_focus.y + graph_y) * graph_s;
var fx1 = fx0 + node_focus.w * graph_s;
var fy1 = fy0 + node_focus.h * graph_s;
nodes_selecting = [ node_hovering ];
ds_list_clear(nodes_select_list);
if(!key_mod_press(CTRL))
for(var i = 0; i < ds_list_size(nodes_list); i++) { //select content
var _node = nodes_list[| i];
if(is_instanceof(_node, Node_Frame)) continue;
var _x = (_node.x + graph_x) * graph_s;
var _y = (_node.y + graph_y) * graph_s;
var _w = _node.w * graph_s;
var _h = _node.h * graph_s;
if(!key_mod_press(CTRL))
for(var i = 0; i < ds_list_size(nodes_list); i++) { //select content
var _node = nodes_list[| i];
if(is_instanceof(_node, Node_Frame)) continue;
var _x = (_node.x + graph_x) * graph_s;
var _y = (_node.y + graph_y) * graph_s;
var _w = _node.w * graph_s;
var _h = _node.h * graph_s;
if(rectangle_inside_rectangle(fx0, fy0, fx1, fy1, _x, _y, _x + _w, _y + _h))
ds_list_add(nodes_select_list, _node);
}
ds_list_add(nodes_select_list, node_focus);
} else if(DOUBLE_CLICK) {
PANEL_PREVIEW.setNodePreview(node_focus);
if(PREFERENCES.inspector_focus_on_double_click) {
if(PANEL_INSPECTOR.panel && struct_has(PANEL_INSPECTOR.panel, "switchContent"))
PANEL_INSPECTOR.panel.switchContent(PANEL_INSPECTOR);
}
} else {
if(_prevFocus != node_focus)
bringNodeToFront(node_focus);
var hover_selected = false;
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
if(nodes_select_list[| i] == node_focus) {
hover_selected = true;
break;
}
}
if(!hover_selected)
ds_list_clear(nodes_select_list);
if(rectangle_inside_rectangle(fx0, fy0, fx1, fy1, _x, _y, _x + _w, _y + _h))
array_push(nodes_selecting, _node);
}
} else if(DOUBLE_CLICK) {
PANEL_PREVIEW.setNodePreview(node_hovering);
if(PREFERENCES.inspector_focus_on_double_click) {
if(PANEL_INSPECTOR.panel && struct_has(PANEL_INSPECTOR.panel, "switchContent"))
PANEL_INSPECTOR.panel.switchContent(PANEL_INSPECTOR);
}
} else {
if(value_focus == noone)
ds_list_clear(nodes_select_list);
var hover_selected = false;
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
if(nodes_selecting[i] != node_hovering) continue;
if(DOUBLE_CLICK && !PANEL_INSPECTOR.locked)
PANEL_INSPECTOR.inspecting = noone;
hover_selected = true;
break;
}
if(!hover_selected)
nodes_selecting = [];
}
array_foreach(nodes_selecting, function(node) { bringNodeToFront(node); });
}
}
#endregion
@ -873,11 +859,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_push(menu, menu_group_tool);
array_push(menu, -1, menu_node_delete_merge, menu_node_delete_cut, menu_node_duplicate, menu_node_copy);
if(ds_list_empty(nodes_select_list)) array_push(menu, menu_node_copy_prop, menu_node_paste_prop);
if(array_empty(nodes_selecting)) array_push(menu, menu_node_copy_prop, menu_node_paste_prop);
array_push(menu, -1, menu_node_transform, menu_node_canvas);
if(ds_list_size(nodes_select_list) >= 2)
if(array_empty(nodes_selecting) >= 2)
array_push(menu, -1, menu_nodes_align, menu_nodes_blend, menu_nodes_compose, menu_nodes_array, menu_nodes_group, menu_nodes_frame);
menuCall("graph_node_selected_multiple_menu",,, menu );
@ -888,7 +874,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(junction_hovering != noone)
array_push(menu, menu_junc_color, -1);
array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(node_focus != noone || ds_list_size(nodes_select_list)));
array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(array_length(nodes_selecting)));
array_push(menu, menuItem(__txt("Paste"), function() { doPaste(); }, THEME.paste, ["Graph", "Paste"]).setActive(clipboard_get_text() != ""));
callAddDialog();
@ -901,10 +887,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
printIf(log, "Node selection time: " + string(current_time - t)); t = current_time;
#region draw active
if(node_focus) node_focus.drawActive(gr_x, gr_y, graph_s);
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
if(!_node) continue;
_node.drawActive(gr_x, gr_y, graph_s);
}
@ -934,7 +918,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
maxy : h + 64,
active : hoverable,
max_layer : ds_list_size(nodes_list),
highlight : !ds_list_empty(nodes_select_list) || node_focus != noone,
highlight : array_length(nodes_selecting),
};
for(var i = 0; i < ds_list_size(nodes_list); i++) {
@ -1008,77 +992,64 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_dragging = noone;
if(node_dragging && !key_mod_press(ALT)) {
node_focus = node_dragging;
if(key_mod_press(SHIFT)) { ////////////// Group dragging
for(var i = 0; i < ds_list_size(nodes_list); i++) {
var _node = nodes_list[| i];
if(ds_list_size(nodes_select_list) == 0) { // move single node
var nx = node_drag_sx + (mouse_graph_x - node_drag_mx);
var ny = node_drag_sy + (mouse_graph_y - node_drag_my);
if(!key_mod_press(CTRL) && project.graphGrid.snap) {
nx = round(nx / project.graphGrid.size) * project.graphGrid.size;
ny = round(ny / project.graphGrid.size) * project.graphGrid.size;
_node.groupCheck(gr_x, gr_y, graph_s, mx, my);
}
node_dragging.move(nx, ny, graph_s);
if(key_mod_press(SHIFT) && node_dragging.cache_group != noone)
if(node_dragging && node_dragging.cache_group != noone)
node_dragging.cache_group.removeNode(node_dragging);
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sx, "x", "node x position" ]);
recordAction(ACTION_TYPE.var_modify, node_dragging, [ node_drag_sy, "y", "node y position" ]);
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
if(_node.cache_group != noone)
_node.cache_group.removeNode(_node);
}
} else { // move multiple nodes
var nx = node_drag_sx + (mouse_graph_x - node_drag_mx);
var ny = node_drag_sy + (mouse_graph_y - node_drag_my);
}
if(!key_mod_press(CTRL) && project.graphGrid.snap) {
nx = round(nx / project.graphGrid.size) * project.graphGrid.size;
ny = round(ny / project.graphGrid.size) * project.graphGrid.size;
}
var nx = node_drag_sx + (mouse_graph_x - node_drag_mx);
var ny = node_drag_sy + (mouse_graph_y - node_drag_my);
if(node_drag_ox == -1 || node_drag_oy == -1) {
node_drag_ox = nx;
node_drag_oy = ny;
} else if(nx != node_drag_ox || ny != node_drag_oy) {
var dx = nx - node_drag_ox;
var dy = ny - node_drag_oy;
if(!key_mod_press(CTRL) && project.graphGrid.snap) {
nx = round(nx / project.graphGrid.size) * project.graphGrid.size;
ny = round(ny / project.graphGrid.size) * project.graphGrid.size;
}
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
var _nx = _node.x + dx;
var _ny = _node.y + dy;
if(node_drag_ox == -1 || node_drag_oy == -1) {
node_drag_ox = nx;
node_drag_oy = ny;
} else if(nx != node_drag_ox || ny != node_drag_oy) {
var dx = nx - node_drag_ox;
var dy = ny - node_drag_oy;
if(!key_mod_press(CTRL) && project.graphGrid.snap) {
_nx = round(_nx / project.graphGrid.size) * project.graphGrid.size;
_ny = round(_ny / project.graphGrid.size) * project.graphGrid.size;
}
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
var _nx = _node.x + dx;
var _ny = _node.y + dy;
_node.move(_nx, _ny, graph_s);
if(!key_mod_press(CTRL) && project.graphGrid.snap) {
_nx = round(_nx / project.graphGrid.size) * project.graphGrid.size;
_ny = round(_ny / project.graphGrid.size) * project.graphGrid.size;
}
node_drag_ox = nx;
node_drag_oy = ny;
_node.move(_nx, _ny, graph_s);
}
if(key_mod_press(SHIFT)) {
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
if(_node.cache_group != noone)
_node.cache_group.removeNode(_node);
}
}
node_drag_ox = nx;
node_drag_oy = ny;
}
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
var shfx = node_drag_sx - nx;
var shfy = node_drag_sy - ny;
if(mouse_release(mb_left) && (nx != node_drag_sx || ny != node_drag_sy)) {
var shfx = node_drag_sx - nx;
var shfy = node_drag_sy - ny;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _n = nodes_select_list[| i];
if(_n == noone) continue;
recordAction(ACTION_TYPE.var_modify, _n, [ _n.x + shfx, "x", "node x position" ]);
recordAction(ACTION_TYPE.var_modify, _n, [ _n.y + shfy, "y", "node y position" ]);
}
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _n = nodes_selecting[i];
if(_n == noone) continue;
recordAction(ACTION_TYPE.var_modify, _n, [ _n.x + shfx, "x", "node x position" ]);
recordAction(ACTION_TYPE.var_modify, _n, [ _n.y + shfy, "y", "node y position" ]);
}
}
}
@ -1089,13 +1060,14 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#endregion
if(mouse_on_graph && pFOCUS) { #region
if(node_focus && node_focus.draggable && value_focus == noone) {
var _node = getFocusingNode();
if(_node && _node.draggable && value_focus == noone) {
if(mouse_press(mb_left) && !key_mod_press(ALT)) {
node_dragging = node_focus;
node_dragging = _node;
node_drag_mx = mouse_graph_x;
node_drag_my = mouse_graph_y;
node_drag_sx = node_focus.x;
node_drag_sy = node_focus.y;
node_drag_sx = _node.x;
node_drag_sy = _node.y;
node_drag_ox = -1;
node_drag_oy = -1;
@ -1127,10 +1099,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _sel = rectangle_in_rectangle(_x, _y, _x + _w, _y + _h, nodes_select_mx, nodes_select_my, mx, my);
if(!ds_list_exist(nodes_select_list, _node) && _sel)
ds_list_add(nodes_select_list, _node);
if(ds_list_exist(nodes_select_list, _node) && !_sel)
ds_list_remove(nodes_select_list, _node);
if(!array_exists(nodes_selecting, _node) && _sel)
array_push(nodes_selecting, _node);
if(array_exists(nodes_selecting, _node) && !_sel)
array_remove(nodes_selecting, _node);
}
}
@ -1159,7 +1131,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_junction_d = junction_hovering;
nodes_junction_dx = junction_hovering.draw_line_shift_x;
nodes_junction_dy = junction_hovering.draw_line_shift_y;
} else if(!node_focus && !value_focus && !drag_locking) {
} else if(array_empty(nodes_selecting) && !value_focus && !drag_locking) {
nodes_select_drag = true;
nodes_select_mx = mx;
nodes_select_my = my;
@ -1260,8 +1232,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} 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 i = 0, n = array_length(nodes_selecting); i < n; i++ ) {
var _node = nodes_selecting[i];
for( var j = 0, m = ds_list_size(_node.outputs); j < m; j++ ) {
var _junction = _node.outputs[| j];
@ -1324,8 +1296,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(i < ds_list_size(node_context) - 1) {
if(buttonInstant(THEME.button_hide_fill, xx - ui(6), tbh - bh / 2, tw + ui(12), bh, [mx, my], pFOCUS, pHOVER) == 2) {
node_hover = noone;
node_focus = noone;
node_hover = noone;
nodes_selecting = [];
PANEL_PREVIEW.resetNodePreview();
setContextFrame(true, node_context[| i + 1]);
@ -1539,9 +1511,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
nodes_list = _node.nodes;
ds_list_add(node_context, _node);
node_dragging = noone;
ds_list_clear(nodes_select_list);
selection_block = 1;
node_dragging = noone;
nodes_selecting = [];
selection_block = 1;
toCenterNode();
} #endregion
@ -1580,7 +1552,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
drawToolBar();
drawMinimap();
if(pFOCUS && node_focus) node_focus.focusStep();
if(pFOCUS) array_foreach(nodes_selecting, function(node) { node.focusStep(); });
if(UPDATE == RENDER_TYPE.full)
draw_text(w - ui(8), ui(28), __txtx("panel_graph_rendering", "Rendering") + "...");
@ -1605,42 +1577,25 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region ++++ node manipulation ++++
function doTransform() { #region
if(ds_list_empty(nodes_select_list)) {
if(node_focus != noone && !ds_list_empty(node_focus.outputs)) {
var _o = node_focus.outputs[| 0];
if(_o.type == VALUE_TYPE.surface || _o.type == VALUE_TYPE.dynaSurface) {
var tr = nodeBuild("Node_Transform", node_focus.x + node_focus.w + 64, node_focus.y);
tr.inputs[| 0].setFrom(_o);
}
}
} else {
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
var node = nodes_select_list[| i];
if(ds_list_empty(node.outputs)) continue;
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var node = nodes_selecting[i];
if(ds_list_empty(node.outputs)) continue;
var _o = node.outputs[| 0];
if(_o.type == VALUE_TYPE.surface || _o.type == VALUE_TYPE.dynaSurface) {
var tr = nodeBuild("Node_Transform", node.x + node.w + 64, node.y);
tr.inputs[| 0].setFrom(_o);
}
var _o = node.outputs[| 0];
if(_o.type == VALUE_TYPE.surface || _o.type == VALUE_TYPE.dynaSurface) {
var tr = nodeBuild("Node_Transform", node.x + node.w + 64, node.y);
tr.inputs[| 0].setFrom(_o);
}
}
} #endregion
function doDuplicate() { #region
var nodeArray = [];
if(ds_list_empty(nodes_select_list)) {
if(node_focus == noone) return;
nodeArray = [node_focus];
} else {
for(var i = 0; i < ds_list_size(nodes_select_list); i++)
nodeArray[i] = nodes_select_list[| i];
}
if(array_empty(nodes_selecting)) return;
var _map = {};
var _node = [];
for(var i = 0; i < array_length(nodeArray); i++)
SAVE_NODE(_node, nodeArray[i],,,, getCurrentContext());
for(var i = 0; i < array_length(nodes_selecting); i++)
SAVE_NODE(_node, nodes_selecting[i],,,, getCurrentContext());
_map.nodes = _node;
APPENDING = true;
@ -1668,23 +1623,22 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_drag_sx = x0; node_drag_sy = y0;
node_drag_ox = x0; node_drag_oy = y0;
ds_list_destroy(nodes_select_list);
nodes_select_list = _app;
nodes_selecting = array_create_from_list(_app);
} #endregion
function doInstance() { #region
if(node_focus == noone) return;
if(!struct_has(node_focus, "nodes")) return;
var node = getFocusingNode();
if(node == noone) return;
if(node_focus.instanceBase == noone) {
node_focus.isInstancer = true;
if(node.instanceBase == noone) {
node.isInstancer = true;
CLONING = true;
var _type = instanceof(node_focus);
var _type = instanceof(node);
var _node = nodeBuild(_type, x, y);
CLONING = false;
_node.setInstance(node_focus);
_node.setInstance(node);
}
var _nodeNew = _node.clone();
@ -1696,23 +1650,13 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function doCopy() { #region
if(array_empty(nodes_selecting)) return;
clipboard_set_text("");
var nodeArray = [];
if(ds_list_empty(nodes_select_list)) {
if(node_focus == noone) return;
nodeArray = [node_focus];
} else {
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
nodeArray[i] = _node;
}
}
var _map = {};
var _node = [];
for(var i = 0; i < array_length(nodeArray); i++)
SAVE_NODE(_node, nodeArray[i],,,, getCurrentContext());
for(var i = 0; i < array_length(nodes_selecting); i++)
SAVE_NODE(_node, nodes_selecting[i],,,, getCurrentContext());
_map.nodes = _node;
clipboard_set_text(json_stringify_minify(_map));
@ -1754,8 +1698,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_drag_sx = x0; node_drag_sy = y0;
node_drag_ox = x0; node_drag_oy = y0;
ds_list_destroy(nodes_select_list);
nodes_select_list = _app;
nodes_selecting = array_create_from_list(_app);
return;
}
@ -1784,23 +1727,22 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function doBlend() { #region
if(ds_list_empty(nodes_select_list)) return;
if(ds_list_size(nodes_select_list) != 2) return;
if(array_length(nodes_selecting) != 2) return;
var cx = nodes_select_list[| 0].x;
var cx = nodes_selecting[0].x;
var cy = 0;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx = max(cx, _node.x);
cy += _node.y;
}
cx = cx + 160;
cy = round(cy / ds_list_size(nodes_select_list) / 32) * 32;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _blend = new Node_Blend(cx, cy, getCurrentContext());
var index = 0;
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
var _node = nodes_select_list[| i];
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
if(_node.outputs[| 0].type == VALUE_TYPE.surface) {
_blend.inputs[| index].setFrom(_node.outputs[| 0]);
@ -1808,125 +1750,106 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
}
ds_list_clear(nodes_select_list);
nodes_selecting = [];
} #endregion
function doCompose() { #region
if(ds_list_empty(nodes_select_list)) return;
if(array_empty(nodes_selecting)) return;
var cx = nodes_select_list[| 0].x;
var cx = nodes_selecting[0].x;
var cy = 0;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx = max(cx, _node.x);
cy += _node.y;
}
cx = cx + 160;
cy = round(cy / ds_list_size(nodes_select_list) / 32) * 32;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _compose = nodeBuild("Node_Composite", cx, cy);
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
var _node = nodes_select_list[| i];
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
if(_node.outputs[| 0].type == VALUE_TYPE.surface) {
_compose.addInput(_node.outputs[| 0]);
}
}
ds_list_clear(nodes_select_list);
nodes_selecting = [];
} #endregion
function doArray() { #region
if(ds_list_empty(nodes_select_list)) return;
if(array_empty(nodes_selecting)) return;
var cx = nodes_select_list[| 0].x;
var cx = nodes_selecting[0].x;
var cy = 0;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx = max(cx, _node.x);
cy += _node.y;
}
cx = cx + 160;
cy = round(cy / ds_list_size(nodes_select_list) / 32) * 32;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _array = nodeBuild("Node_Array", cx, cy);
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
var _node = nodes_select_list[| i];
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
if(ds_list_size(_node.outputs) == 0) continue;
_array.addInput(_node.outputs[| 0]);
}
ds_list_clear(nodes_select_list);
nodes_selecting = [];
} #endregion
function doGroup() { #region
if(ds_list_empty(nodes_select_list) && node_focus != noone)
ds_list_add(nodes_select_list, node_focus);
node_focus = noone;
if(ds_list_empty(nodes_select_list)) return;
groupNodes(array_create_from_list(nodes_select_list));
if(array_empty(nodes_selecting)) return;
groupNodes(nodes_selecting);
} #endregion
function doUngroup() { #region
if(node_focus == noone) return;
if(!variable_struct_exists(node_focus, "nodes")) return;
if(!node_focus.ungroupable) return;
var _node = getFocusingNode();
if(_node == noone) return;
if(!is_instanceof(_node, Node_Collection) || !_node.ungroupable) return;
upgroupNode(node_focus);
upgroupNode(_node);
} #endregion
function doLoop() { #region
if(ds_list_empty(nodes_select_list) && node_focus != noone)
ds_list_add(nodes_select_list, node_focus);
if(ds_list_empty(nodes_select_list)) return;
if(array_empty(nodes_selecting)) return;
var cx = 0;
var cy = 0;
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
var _node = nodes_select_list[| i];
for(var i = 0; i < array_length(nodes_selecting); i++) {
var _node = nodes_selecting[i];
cx += _node.x;
cy += _node.y;
}
cx = round(cx / ds_list_size(nodes_select_list) / 32) * 32;
cy = round(cy / ds_list_size(nodes_select_list) / 32) * 32;
cx = round(cx / array_length(nodes_selecting) / 32) * 32;
cy = round(cy / array_length(nodes_selecting) / 32) * 32;
var _group = new Node_Iterate(cx, cy, getCurrentContext());
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
_group.add(nodes_select_list[| i]);
}
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
nodes_select_list[| i].checkConnectGroup("loop");
}
for(var i = 0; i < array_length(nodes_selecting); i++)
_group.add(nodes_selecting[i]);
ds_list_clear(nodes_select_list);
for(var i = 0; i < array_length(nodes_selecting); i++)
nodes_selecting[i].checkConnectGroup("loop");
nodes_selecting = [];
} #endregion
function doFrame() { #region
var x0 = 999999, y0 = 999999, x1 = -999999, y1 = -999999;
if(ds_list_empty(nodes_select_list)) {
if(node_focus != noone) {
x0 = node_focus.x;
y0 = node_focus.y;
x1 = node_focus.x + node_focus.w;
y1 = node_focus.y + node_focus.h;
} else
return;
} else {
for( var i = 0; i < ds_list_size(nodes_select_list); i++ ) {
var _node = nodes_select_list[| i];
x0 = min(x0, _node.x);
y0 = min(y0, _node.y);
x1 = max(x1, _node.x + _node.w);
y1 = max(y1, _node.y + _node.h);
}
for( var i = 0; i < array_length(nodes_selecting); i++ ) {
var _node = nodes_selecting[i];
x0 = min(x0, _node.x);
y0 = min(y0, _node.y);
x1 = max(x1, _node.x + _node.w);
y1 = max(y1, _node.y + _node.h);
}
x0 -= 64;
@ -1939,14 +1862,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} #endregion
function doDelete(_merge = false) { #region
if(node_focus != noone && node_focus.manual_deletable)
nodeDelete(node_focus, _merge);
for(var i = 0; i < ds_list_size(nodes_select_list); i++) {
if(nodes_select_list[| i].manual_deletable)
nodeDelete(nodes_select_list[| i], _merge);
}
ds_list_clear(nodes_select_list);
array_foreach(nodes_selecting, function(node) { if(node.manual_deletable) nodeDelete(node, _merge); });
nodes_selecting = [];
} #endregion
node_prop_clipboard = noone;
@ -2038,7 +1955,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
break;
case "Collection":
var path = DRAGGING.data.path;
ds_list_clear(nodes_select_list);
nodes_selecting = [];
var app = APPEND(DRAGGING.data.path, getCurrentContext());

View file

@ -27,7 +27,7 @@ function Panel_Graph_Export_Image(targetPanel) : PanelContent() constructor {
sel = 0;
nodes_select = [ "All nodes", "Selected" ];
widgets = [];
widgets[0] = [ "Nodes", new scrollBox(nodes_select, function(val) { sel = val; nodeList = val? targetPanel.nodes_select_list : targetPanel.nodes_list; refresh(); }, false),
widgets[0] = [ "Nodes", new scrollBox(nodes_select, function(val) { sel = val; nodeList = val? ds_list_create_from_array(targetPanel.nodes_selecting) : targetPanel.nodes_list; refresh(); }, false),
function() { return nodes_select[sel] } ];
widgets[1] = [ "Scale", new textBox(TEXTBOX_INPUT.number, function(val) { settings.scale = val; refresh(); }),
function() { return settings.scale } ];

View file

@ -844,7 +844,7 @@ function Panel_Inspector() : PanelContent() constructor {
contentPane.setFocusHover(pFOCUS, pHOVER);
contentPane.draw(ui(16), top_bar_h, mx - ui(16), my - top_bar_h);
if(!locked && PANEL_GRAPH.node_focus && inspecting != PANEL_GRAPH.node_focus)
setInspecting(PANEL_GRAPH.node_focus);
if(!locked && PANEL_GRAPH.getFocusingNode() && inspecting != PANEL_GRAPH.getFocusingNode())
setInspecting(PANEL_GRAPH.getFocusingNode());
} #endregion
}

View file

@ -12,15 +12,15 @@ function Panel_Node_Align() : PanelContent() constructor {
/////////////////////////////
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_halign, 0, c_white) == 2)
node_halign(PANEL_GRAPH.nodes_select_list, fa_left);
node_halign(PANEL_GRAPH.nodes_selecting, fa_left);
xx += 34
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_halign, 1, c_white) == 2)
node_halign(PANEL_GRAPH.nodes_select_list, fa_center);
node_halign(PANEL_GRAPH.nodes_selecting, fa_center);
xx += 34
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_halign, 2, c_white) == 2)
node_halign(PANEL_GRAPH.nodes_select_list, fa_right);
node_halign(PANEL_GRAPH.nodes_selecting, fa_right);
xx += 34
xx += 2;
@ -31,15 +31,15 @@ function Panel_Node_Align() : PanelContent() constructor {
/////////////////////////////
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_valign, 0, c_white) == 2)
node_valign(PANEL_GRAPH.nodes_select_list, fa_top);
node_valign(PANEL_GRAPH.nodes_selecting, fa_top);
xx += 34
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_valign, 1, c_white) == 2)
node_valign(PANEL_GRAPH.nodes_select_list, fa_middle);
node_valign(PANEL_GRAPH.nodes_selecting, fa_middle);
xx += 34
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.object_valign, 2, c_white) == 2)
node_valign(PANEL_GRAPH.nodes_select_list, fa_bottom);
node_valign(PANEL_GRAPH.nodes_selecting, fa_bottom);
xx += 34
xx += 2;
@ -50,11 +50,11 @@ function Panel_Node_Align() : PanelContent() constructor {
/////////////////////////////
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.obj_distribute_h, 0, c_white) == 2)
node_hdistribute(PANEL_GRAPH.nodes_select_list);
node_hdistribute(PANEL_GRAPH.nodes_selecting);
xx += 34
if(buttonInstant(THEME.button_hide, xx, yy, 32, 32, [mx, my], pFOCUS, pHOVER,, THEME.obj_distribute_v, 0, c_white) == 2)
node_vdistribute(PANEL_GRAPH.nodes_select_list);
node_vdistribute(PANEL_GRAPH.nodes_selecting);
xx += 34
}
}

View file

@ -53,8 +53,7 @@ function Panel_Nodes() : PanelContent() constructor {
if(isGroup)
node_collapse[? node.node_id] = !node_collapse[? node.node_id];
PANEL_INSPECTOR.setInspecting(node);
ds_list_clear(PANEL_GRAPH.nodes_select_list);
PANEL_GRAPH.node_focus = node;
PANEL_GRAPH.nodes_selecting = [ node ];
}
}
} else

View file

@ -51,7 +51,7 @@ function Panel_Preview_Window() : PanelContent() constructor {
menu = [
menuItem(__txtx("reset_view", "Reset view"), function() { reset(); }),
-1,
menuItem(__txt("Inspect"), function() { PANEL_GRAPH.node_focus = node_target; }),
menuItem(__txt("Inspect"), function() { PANEL_GRAPH.nodes_selecting = [ node_target ]; }),
menuItem(__txtx("panel_graph_send_to_preview", "Send to preview"), function() { PANEL_PREVIEW.setNodePreview(node_target); }),
-1,
]

View file

@ -4,7 +4,7 @@ function __test_update_current_collections() {
print("---------- COLLECTION UPDATING STARTED ----------");
var sel = PANEL_GRAPH.node_focus, outj = noone;
var sel = PANEL_GRAPH.getFocusingNode(), outj = noone;
if(sel != noone) outj = sel.outputs[| 0];
while(!ds_stack_empty(st)) {
@ -53,7 +53,7 @@ function __test_load_current_collections() {
print("---------- COLLECTION TESTING STARTED ----------");
var sel = PANEL_GRAPH.node_focus;
var sel = PANEL_GRAPH.getFocusingNode();
var outj = sel == noone? noone : sel.outputs[| 0];
while(!ds_stack_empty(st)) {
@ -113,7 +113,7 @@ function __test_load_all_nodes() {
var yy = 0;
var col = 10;
var ind = 0;
var sel = PANEL_GRAPH.node_focus;
var sel = PANEL_GRAPH.getFocusingNode();
var outj = sel == noone? noone : sel.outputs[| 0];
var index = 0;
@ -156,7 +156,7 @@ function __test_metadata_current_collections() {
print("---------- COLLECTION UPDATING STARTED ----------");
var sel = PANEL_GRAPH.node_focus, outj = noone;
var sel = PANEL_GRAPH.getFocusingNode(), outj = noone;
var _meta = METADATA.serialize();
if(sel != noone) outj = sel.outputs[| 0];