[Graph Panel] Fix connection adjustment reset on duplicated nodes.

This commit is contained in:
Tanasart 2024-11-15 12:06:21 +07:00
parent 913f537f6a
commit eb6cb20f14
10 changed files with 84 additions and 67 deletions

View file

@ -7,21 +7,31 @@ event_inherited();
title_height = ui(28);
destroy_on_click_out = false;
req_sign_in = "";
req_auth = "";
campaign_id = "2263128";
req_patreon = "";
req_user = "";
access_token = "";
attmp = 0;
do {
port = irandom_range(7000, 20000);
server = network_create_server_raw(network_socket_ws, port, 32);
} until(server >= 0 || attmp++ >= 100);
status = 0;
if(!IS_PATREON) {
if(IS_PATREON) {
txt = "Patreon verified, thank you for supporting Pixel Composer!";
server = 0;
dialog_h += ui(40);
} else {
txt = "Sign-in to Patreon on browser";
var attmp = 0;
do {
port = irandom_range(7000, 20000);
server = network_create_server_raw(network_socket_ws, port, 32);
} until(server >= 0 || attmp++ >= 100);
var _url = @"www.patreon.com/oauth2/authorize?response_type=code
&client_id=oZ1PNvUY61uH0FiA7ZPMBy77Xau3Ok9tfvsT_Y8DQwyKeMNjaVC35r1qsK09QJhY
&redirect_uri=https://pixel-composer.com/verify";
&client_id=oZ1PNvUY61uH0FiA7ZPMBy77Xau3Ok9tfvsT_Y8DQwyKeMNjaVC35r1qsK09QJhY
&redirect_uri=https://pixel-composer.com/verify";
_url += $"&state={port}";
url_open(_url);
}
#endregion

View file

@ -27,19 +27,30 @@ if !ready exit;
draw_sprite(s_patreon_banner, 0, cx, yy);
var _bw = ui(172);
var _bw = ui(100);
var _bh = ui(32);
var _bx = cx - _bw / 2;
var _by = yy + ui(104);
var _by = dialog_y + dialog_h - ui(16 + 32);
// if(buttonInstant(THEME.button_def, _bx, _by, _bw, _bh, mouse_ui, sFOCUS, sHOVER) == 2) {}
var _ty = yy + ui(120);
if(IS_PATREON) {
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_value_positive);
draw_text(cx, _by + _bh / 2, "Patreon verified, thank you for supporting Pixel Composer!\nRestart to see new contents.");
draw_text(cx, _ty, txt);
if(buttonInstant(THEME.button_def, _bx, _by, _bw, _bh, mouse_ui, sFOCUS, sHOVER) == 2) {
var _path = DIRECTORY + "patreon";
file_delete(_path);
IS_PATREON = false;
instance_destroy();
}
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text);
draw_text(cx, _by + _bh / 2, "Unredeem");
} else {
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text);
draw_text(cx, _by + _bh / 2, "Sign-in to Patreon on browser");
draw_set_text(f_p1, fa_center, fa_center, status == 0? COLORS._main_text : COLORS._main_value_negative);
draw_text(cx, _ty, txt);
}
#endregion

View file

@ -1,4 +1,4 @@
function draw_line_curve_color(x0, y0, x1, y1, xc = noone, yc = noone, _s = 1, thick = 1, col1 = c_white, col2 = c_white, type = LINE_STYLE.solid) { #region
function draw_line_curve_color(x0, y0, x1, y1, xc = noone, yc = noone, _s = 1, thick = 1, col1 = c_white, col2 = c_white, type = LINE_STYLE.solid) {
if(xc == noone) xc = (x0 + x1) / 2;
if(yc == noone) yc = (y0 + y1) / 2;
@ -48,9 +48,9 @@ function draw_line_curve_color(x0, y0, x1, y1, xc = noone, yc = noone, _s = 1, t
oy = ny;
oc = nc;
}
} #endregion
}
function draw_line_curve_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_white, col2 = c_white) { #region
function draw_line_curve_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_white, col2 = c_white) {
var sample = ceil((abs(x0 - x1) + abs(y0 - y1)) / 32 * PREFERENCES.connection_line_sample);
sample = clamp(sample, 2, 128);
@ -84,9 +84,9 @@ function draw_line_curve_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_whit
oy = ny;
oc = nc;
}
} #endregion
}
function distance_to_curve(mx, my, x0, y0, x1, y1, xc, yc, _s) { #region
function distance_to_curve(mx, my, x0, y0, x1, y1, xc, yc, _s) {
var sample = ceil((abs(x0 - x1) + abs(y0 - y1)) / 32 * PREFERENCES.connection_line_sample);
sample = clamp(sample, 2, 128);
@ -122,9 +122,9 @@ function distance_to_curve(mx, my, x0, y0, x1, y1, xc, yc, _s) { #region
}
return dist;
} #endregion
}
function distance_to_curve_corner(mx, my, x0, y0, x1, y1, _s) { #region
function distance_to_curve_corner(mx, my, x0, y0, x1, y1, _s) {
var sample = ceil((abs(x0 - x1) + abs(y0 - y1)) / 32 * PREFERENCES.connection_line_sample);
sample = clamp(sample, 2, 128);
@ -158,4 +158,4 @@ function distance_to_curve_corner(mx, my, x0, y0, x1, y1, _s) { #region
}
return dist;
} #endregion
}

View file

@ -1,8 +1,6 @@
function draw_line_elbow_color(x0, y0, x1, y1, cx = noone, cy = noone, _s = 1, thick = 1, col1 = c_white, col2 = c_white, params = {}) {
var extend = params.extend;
var corner = min(extend, params.corner);
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var type = params.type;
if(cx == noone) cx = (x0 + x1) / 2;
@ -13,7 +11,7 @@ function draw_line_elbow_color(x0, y0, x1, y1, cx = noone, cy = noone, _s = 1, t
var _y0 = min(y0, y1);
var _y1 = max(y0, y1);
var th = thick / 2;
var inv = x1 - 16 * indexOut * _s <= x0 + 16 * indexIn * _s;
var inv = x1 <= x0;
var rat = inv? (_y1 == _y0? 0.5 : (cy - _y0) / (_y1 - _y0)) :
(_x1 == _x0? 0.5 : (cx - _x0) / (_x1 - _x0));
var cm = merge_color(col1, col2, clamp(rat, 0, 1));
@ -26,8 +24,8 @@ function draw_line_elbow_color(x0, y0, x1, y1, cx = noone, cy = noone, _s = 1, t
var iy1 = sign(y1 - cy);
if(y0 != y1 && inv) {
var xx0 = x0 + 16 * _s * indexIn;
var xx1 = x1 - 16 * _s * indexOut;
var xx0 = x0;
var xx1 = x1;
var corns = min(corner, 16 * _s);
corner = min(corner, abs(cy - y0) / 2, abs(cy - y1) / 2, abs(xx1 - xx0) / 2);
@ -79,8 +77,6 @@ function draw_line_elbow_color(x0, y0, x1, y1, cx = noone, cy = noone, _s = 1, t
function draw_line_elbow_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_white, col2 = c_white, params = {}) {
var extend = params.extend;
var corner = min(extend, params.corner);
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var type = params.type;
var sample = clamp(corner / 4, 1, 8);
@ -99,12 +95,10 @@ function draw_line_elbow_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_whit
function distance_to_elbow(mx, my, x0, y0, x1, y1, cx, cy, _s, params = {}) {
var extend = params.extend;
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var inv = x1 - extend * _s * indexOut <= x0 + extend * _s * indexIn;
var xx0 = x0 + extend * _s * indexIn;
var xx1 = x1 - extend * _s * indexOut;
var inv = x1 <= x0;
var xx0 = x0;
var xx1 = x1;
if(y0 != y1 && inv) {
var dist = distance_to_line(mx, my, xx0, y0, xx0, cy);

View file

@ -1,8 +1,6 @@
function draw_line_elbow_diag_color(x0, y0, x1, y1, cx = noone, cy = noone, _s = 1, thick = 1, c1 = c_white, c2 = c_white, params = {}) {
var extend = params.extend;
var corner = min(extend, params.corner);
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var type = params.type;
var __dash = 6 * _s;
@ -19,8 +17,8 @@ function draw_line_elbow_diag_color(x0, y0, x1, y1, cx = noone, cy = noone, _s =
var iy = sign(y1 - y0);
var xx0 = x0 + extend * _s * indexIn;
var xx1 = x1 - extend * _s * indexOut;
var xx0 = x0;
var xx1 = x1;
var yy0 = y0;
var yy1 = y1;
@ -212,8 +210,6 @@ function draw_line_elbow_diag_color(x0, y0, x1, y1, cx = noone, cy = noone, _s =
function draw_line_elbow_diag_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c_white, col2 = c_white, params = {}) {
var extend = params.extend;
var corner = min(extend, params.corner);
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var type = params.type;
var sample = floor(corner / 8);
@ -240,12 +236,10 @@ function draw_line_elbow_diag_corner(x0, y0, x1, y1, _s = 1, thick = 1, col1 = c
function distance_to_elbow_diag(mx, my, x0, y0, x1, y1, cx, cy, _s, params = {}) {
var extend = params.extend;
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var iy = sign(y1 - y0);
var xx0 = x0 + extend * _s * indexIn;
var xx1 = x1 - extend * _s * indexOut;
var xx0 = x0;
var xx1 = x1;
var yy0 = y0;
var yy1 = y1;

View file

@ -31,10 +31,7 @@ function draw_line_connect(x0, y0, x1, y1, _s = 1, thick = 1, c1 = c_white, c2 =
}
function distance_to_linear_connection(mx, my, x0, y0, x1, y1, _s, params = {}) {
var extend = params.extend;
var indexIn = params.fromIndex;
var indexOut = params.toIndex;
var extend = params.extend;
var xx0 = x0 + extend * _s;
var xx1 = x1 - extend * _s;

View file

@ -184,16 +184,18 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
PANEL_GRAPH.addKeyOverlay("Inline group", [[ "Shift", "Add/remove" ]]);
if(key_mod_down(SHIFT)) {
if(group_hovering) {
if(!array_empty(_list) && key_mod_down(SHIFT)) {
var _remove = _list[0].inline_context == self;
if(_remove) {
for( var i = 0, n = array_length(_list); i < n; i++ )
if(_list[i].manual_ungroupable) removeNode(_list[i]);
} else {
group_adding = true;
for( var i = 0, n = array_length(_list); i < n; i++ )
if(_list[i].manual_ungroupable) addNode(_list[i]);
} else {
for( var i = 0, n = array_length(_list); i < n; i++ )
if(_list[i].manual_ungroupable) removeNode(_list[i]);
}
}
}
}

View file

@ -20,11 +20,13 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
newInput(8, nodeValue_Color("BG Color", self, c_black ));
newInput(9, nodeValue_Enum_Button("Fill", self, 0, [ "Odd", "All" ] ));
newOutput(0, nodeValue_Output("Output", self, VALUE_TYPE.surface, noone ));
input_display_list = [ 0,
[ "Profile", false ], 1, 2,
[ "Render", false ], 3, 5, 4, 6,
[ "Render", false ], 9, 3, 5, 4, 6,
[ "Background", false, 7 ], 8,
];
@ -48,6 +50,7 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
var _aa = _data[6];
var _bg = _data[7];
var _bgC = _data[8];
var _mode = _data[9];
if(_path == noone) return;
@ -72,6 +75,7 @@ function Node_Path_Profile(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
shader_set_i("aa", _aa);
shader_set_color("color", _colr);
shader_set_i("bg", _bg);
shader_set_i("mode", _mode);
shader_set_color("bgColor",_bgC);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);

View file

@ -1715,14 +1715,18 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(setFrom_condition != -1 && !setFrom_condition(_valueFrom))
return -2;
if(value_from != noone)
array_remove(value_from.value_to, self);
if(value_from != noone) array_remove(value_from.value_to, self);
var _o = animator.getValue();
recordAction(ACTION_TYPE.junction_connect, self, value_from);
value_from = _valueFrom;
array_push(_valueFrom.value_to, self);
if(_valueFrom.node.inline_context != noone) {
var _inline = _valueFrom.node.inline_context;
if(node.manual_ungroupable) _inline.addNode(node);
}
node.valueUpdate(index, _o);
if(_update && connect_type == CONNECT_TYPE.input) {
node.valueFromUpdate(index);
@ -1736,7 +1740,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
cache_array[0] = false;
cache_value[0] = false;
if(!LOADING) {
if(!LOADING && !APPENDING && !CLONING) {
draw_line_shift_x = 0;
draw_line_shift_y = 0;
PROJECT.modified = true;
@ -2404,9 +2408,6 @@ function drawJuncConnection(from, to, params) {
var frx = from.x;
var fry = from.y;
var fromIndex = from.drawLineIndex;
var toIndex = to.drawLineIndex;
var _loop = struct_try_get(params, "loop");
@ -2439,8 +2440,6 @@ function drawJuncConnection(from, to, params) {
#region +++++ CHECK HOVER +++++
var _drawParam = {
extend : PREFERENCES.connection_line_extend,
fromIndex : fromIndex,
toIndex : toIndex,
}
var hovDist = max(th * 2, 6);

View file

@ -16,6 +16,7 @@ uniform int side;
uniform int mirror;
uniform int aa;
uniform int bg;
uniform int mode;
void main() {
vec2 px = v_vTexcoord * dimension;
@ -60,7 +61,12 @@ void main() {
ds = min(ds, abs(px.x - _x));
}
if(mod(it, 2.) == 1.) {
bool fill = false;
if(mode == 0) fill = mod(it, 2.) == 1.;
else if(mode == 1) fill = it > 0.;
if(fill) {
gl_FragColor = color;
if(aa == 1) gl_FragColor.a *= min(1., ds);
}