[Group IO Edit] Fix resizing dialog not resizing the content.

This commit is contained in:
Tanasart 2025-03-02 17:02:18 +07:00
parent 3aed925ed7
commit 9a278163c7
16 changed files with 136 additions and 24 deletions

View file

@ -268,6 +268,7 @@
{"name":"rotator","order":1,"path":"folders/widgets/rotator.yy",},
{"name":"sliders","order":2,"path":"folders/widgets/sliders.yy",},
{"name":"text","order":3,"path":"folders/widgets/text.yy",},
{"name":"shaders","order":2,"path":"folders/nodes/data/PB/main/shaders.yy",},
],
"ResourceOrderSettings":[
{"name":"ac_disappear","order":2,"path":"animcurves/ac_disappear/ac_disappear.yy",},
@ -1054,7 +1055,7 @@
{"name":"node_path_weight_adjust","order":32,"path":"scripts/node_path_weight_adjust/node_path_weight_adjust.yy",},
{"name":"node_pb_box_bbox","order":1,"path":"scripts/node_pb_box_bbox/node_pb_box_bbox.yy",},
{"name":"node_pb_box_mirror","order":2,"path":"scripts/node_pb_box_mirror/node_pb_box_mirror.yy",},
{"name":"node_pb_dimension","order":3,"path":"scripts/node_pb_dimension/node_pb_dimension.yy",},
{"name":"node_pb_dimension","order":4,"path":"scripts/node_pb_dimension/node_pb_dimension.yy",},
{"name":"node_pb_draw_diamond","order":7,"path":"scripts/node_pb_draw_diamond/node_pb_draw_diamond.yy",},
{"name":"node_pb_draw_ellipse","order":4,"path":"scripts/node_pb_draw_ellipse/node_pb_draw_ellipse.yy",},
{"name":"node_pb_draw_line","order":6,"path":"scripts/node_pb_draw_line/node_pb_draw_line.yy",},
@ -1063,7 +1064,7 @@
{"name":"node_pb_draw_surface","order":9,"path":"scripts/node_pb_draw_surface/node_pb_draw_surface.yy",},
{"name":"node_pb_draw_trapezoid","order":5,"path":"scripts/node_pb_draw_trapezoid/node_pb_draw_trapezoid.yy",},
{"name":"node_pb_draw","order":1,"path":"scripts/node_pb_draw/node_pb_draw.yy",},
{"name":"node_pb_output","order":2,"path":"scripts/node_pb_output/node_pb_output.yy",},
{"name":"node_pb_output","order":3,"path":"scripts/node_pb_output/node_pb_output.yy",},
{"name":"node_PCX_array_set","order":1,"path":"scripts/node_PCX_array_set/node_PCX_array_set.yy",},
{"name":"node_PCX_equation","order":7,"path":"scripts/node_PCX_equation/node_PCX_equation.yy",},
{"name":"node_PCX_fn_random","order":1,"path":"scripts/node_PCX_fn_random/node_PCX_fn_random.yy",},
@ -1687,6 +1688,7 @@
{"name":"sh_kuwahara_ani_pass3","order":3,"path":"shaders/sh_kuwahara_ani_pass3/sh_kuwahara_ani_pass3.yy",},
{"name":"sh_kuwahara_ani_pass4","order":4,"path":"shaders/sh_kuwahara_ani_pass4/sh_kuwahara_ani_pass4.yy",},
{"name":"sh_kuwahara_gen","order":5,"path":"shaders/sh_kuwahara_gen/sh_kuwahara_gen.yy",},
{"name":"sh_pb_main_draw","order":0,"path":"shaders/sh_pb_main_draw/sh_pb_main_draw.yy",},
{"name":"sh_level_selector","order":23,"path":"shaders/sh_level_selector/sh_level_selector.yy",},
{"name":"sh_level","order":21,"path":"shaders/sh_level/sh_level.yy",},
{"name":"sh_liquefy_bloat","order":3,"path":"shaders/sh_liquefy_bloat/sh_liquefy_bloat.yy",},

View file

@ -348,6 +348,7 @@
{"$GMFolder":"","%Name":"rotator","folderPath":"folders/widgets/rotator.yy","name":"rotator","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"sliders","folderPath":"folders/widgets/sliders.yy","name":"sliders","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"text","folderPath":"folders/widgets/text.yy","name":"text","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"shaders","folderPath":"folders/nodes/data/PB/main/shaders.yy","name":"shaders","resourceType":"GMFolder","resourceVersion":"2.0",},
],
"IncludedFiles":[
{"$GMIncludedFile":"","%Name":"Addons.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Addons.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
@ -1756,6 +1757,7 @@
{"id":{"name":"dynaSurf_3d","path":"scripts/dynaSurf_3d/dynaSurf_3d.yy",},},
{"id":{"name":"dynaSurf_iso","path":"scripts/dynaSurf_iso/dynaSurf_iso.yy",},},
{"id":{"name":"dynaSurf","path":"scripts/dynaSurf/dynaSurf.yy",},},
{"id":{"name":"sh_pb_main_draw","path":"shaders/sh_pb_main_draw/sh_pb_main_draw.yy",},},
{"id":{"name":"event_recorder","path":"scripts/event_recorder/event_recorder.yy",},},
{"id":{"name":"export_portable","path":"scripts/export_portable/export_portable.yy",},},
{"id":{"name":"fft_functions","path":"scripts/fft_functions/fft_functions.yy",},},

View file

@ -13,13 +13,14 @@ event_inherited();
drag_shift = 0;
sep_editing = -1;
tb_edit = new textBox(TEXTBOX_INPUT.text, function(str) {
tb_edit = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ {
if(sep_editing == -1) return;
display_list[sep_editing][0] = str;
sep_editing = -1;
node.sortIO();
} );
tb_edit.align = fa_left;
tb_edit.font = f_p2;
@ -28,16 +29,16 @@ event_inherited();
type = 1;
junction_list = noone;
function setNode(node, type) {
self.node = node;
self.type = type;
self.display_list = type == CONNECT_TYPE.input? node.attributes.input_display_list : node.attributes.output_display_list;
self.junction_list = type == CONNECT_TYPE.input? node.inputs : node.outputs;
function setNode(_node, _type) {
node = _node;
type = _type;
display_list = type == CONNECT_TYPE.input? node.attributes.input_display_list : node.attributes.output_display_list;
junction_list = type == CONNECT_TYPE.input? node.inputs : node.outputs;
}
#endregion
#region content
sc_group = new scrollPane(dialog_w - ui(padding + padding), dialog_h - ui(title_height + padding), function(_y, _m) {
sc_group = new scrollPane(dialog_w - ui(padding * 2), dialog_h - ui(title_height + padding), function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear_inner, 1);
if(node == noone) return 0;

View file

@ -17,6 +17,7 @@ if !ready exit;
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
sc_group.setFocusHover(sFOCUS, sHOVER);
sc_group.verify(dialog_w - ui(padding * 2), dialog_h - ui(title_height + padding));
sc_group.draw(px, py);
var bx = dialog_x + dialog_w - ui(32 + 16);

View file

@ -22,7 +22,7 @@ event_inherited();
#endregion
#region content
sc_group = new scrollPane(dialog_w - ui(padding + padding), dialog_h - ui(title_height + padding), function(_y, _m) {
sc_group = new scrollPane(dialog_w - ui(padding * 2), dialog_h - ui(title_height + padding), function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear_inner, 1);
if(node == noone) return 0;

View file

@ -17,5 +17,6 @@ if !ready exit;
draw_sprite_stretched(THEME.ui_panel_bg, 1, px - ui(8), py - ui(8), pw + ui(16), ph + ui(16));
sc_group.setFocusHover(sFOCUS, sHOVER);
sc_group.verify(dialog_w - ui(padding * 2), dialog_h - ui(title_height + padding));
sc_group.draw(px, py);
#endregion

View file

@ -31,14 +31,14 @@ function __pbBox() constructor {
anchor_w_min = 0; anchor_w_max = 0;
anchor_h_min = 0; anchor_h_max = 0;
function set_w(v) { anchor_w = anchor_w_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
function set_h(v) { anchor_h = anchor_h_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
static set_w = function(v) /*=>*/ { anchor_w = anchor_w_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
static set_h = function(v) /*=>*/ { anchor_h = anchor_h_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
function set_l(v) { v -= base_bbox[0]; anchor_l = anchor_l_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
function set_t(v) { v -= base_bbox[1]; anchor_t = anchor_t_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
static set_l = function(v) /*=>*/ { v -= base_bbox[0]; anchor_l = anchor_l_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
static set_t = function(v) /*=>*/ { v -= base_bbox[1]; anchor_t = anchor_t_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
function set_r(v) { anchor_r = anchor_r_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
function set_b(v) { anchor_b = anchor_b_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
static set_r = function(v) /*=>*/ { anchor_r = anchor_r_fract? v / (base_bbox[2] - base_bbox[0]) : v; }
static set_b = function(v) /*=>*/ { anchor_b = anchor_b_fract? v / (base_bbox[3] - base_bbox[1]) : v; }
////- Draw

View file

@ -5,7 +5,21 @@ function Node_PB_Dimension(_x, _y, _group = noone) : Node(_x, _y, _group) constr
newOutput(0, nodeValue_Output("Dimension", self, VALUE_TYPE.float, [ 1, 1 ] ))
.setDisplay(VALUE_DISPLAY.vector);
newOutput(1, nodeValue_Output("Width", self, VALUE_TYPE.float, 1 ))
.setVisible(false)
newOutput(2, nodeValue_Output("Height", self, VALUE_TYPE.float, 1 ))
.setVisible(false)
static update = function() {
outputs[0].setValue(group.dimension);
outputs[1].setValue(group.dimension[0]);
outputs[2].setValue(group.dimension[1]);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_pb_dimension, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}

View file

@ -1,3 +1,9 @@
#region
FN_NODE_CONTEXT_INVOKE {
addHotkey("Node_PB_Output", "Layer > Set", KEY_GROUP.numeric, MOD_KEY.none, function(val) /*=>*/ { PANEL_GRAPH_FOCUS_STR _n.inputs[1].setValue(toNumber(chr(keyboard_key))); });
});
#endregion
function Node_PB_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "PB Output";
data = noone;

View file

@ -9,6 +9,10 @@ function Node_Pixel_Builder(_x, _y, _group = noone) : Node_Collection(_x, _y, _g
newInput(0, nodeValue_Dimension(self));
newInput(1, nodeValue_b("Outline", self, false));
newInput(2, nodeValue_i("Thickness", self, 1));
newInput(3, nodeValue_c("Color", self, cola(c_white))).setInternalName("Outline Color");
newOutput(0, nodeValue_Output("Surface Out", self, VALUE_TYPE.surface, noone));
layer_colors = [
@ -75,13 +79,17 @@ function Node_Pixel_Builder(_x, _y, _group = noone) : Node_Collection(_x, _y, _g
return _hh;
});
group_input_display_list = [ 0, layer_renderer, new Inspector_Spacer(ui(4), true, true, ui(4)) ];
group_input_display_list = [ 0,
["Layers", false], layer_renderer,
["Border", false, 1], 2, 3, new Inspector_Spacer(ui(4), true, false, ui(4))
];
group_output_display_list = [ 0 ];
custom_input_index = array_length(inputs);
custom_output_index = array_length(outputs);
dimension = [ 1, 1 ];
dimension = [ 1, 1 ];
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(!draw_input_overlay) return;
@ -109,6 +117,9 @@ function Node_Pixel_Builder(_x, _y, _group = noone) : Node_Collection(_x, _y, _g
var _outSurf = outputs[0].getValue();
_outSurf = surface_verify(_outSurf, dimension[0], dimension[1]);
for( var i = 0, n = array_length(temp_surface); i < n; i++ )
temp_surface[i] = surface_verify(temp_surface[i], dimension[0], dimension[1]);
var pr = ds_priority_create();
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var _n = nodes[i];
@ -121,7 +132,7 @@ function Node_Pixel_Builder(_x, _y, _group = noone) : Node_Collection(_x, _y, _g
layers = array_create(ds_priority_size(pr));
var i = 0;
surface_set_shader(_outSurf, noone);
surface_set_shader(temp_surface[0], noone);
while(!ds_priority_empty(pr)) {
var _n = ds_priority_delete_min(pr);
var _surf = _n.data;
@ -138,9 +149,23 @@ function Node_Pixel_Builder(_x, _y, _group = noone) : Node_Collection(_x, _y, _g
BLEND_NORMAL
}
surface_reset_shader();
ds_priority_destroy(pr);
var _stk = inputs[1].getValue();
var _stk_thk = inputs[2].getValue();
var _stk_col = inputs[3].getValue();
surface_set_shader(_outSurf, sh_pb_main_draw);
shader_set_2("dimension", dimension);
shader_set_i("stroke", _stk );
shader_set_f("stroke_thickness", _stk_thk );
shader_set_c("stroke_color", _stk_col );
shader_set_f("corner_radius", 0 );
draw_surface_safe(temp_surface[0]);
surface_reset_shader();
outputs[0].setValue(_outSurf);
}

View file

@ -335,8 +335,6 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
unit.mode = def_unit;
setValue(unit.apply(variable_clone(def_val)));
attributes.mapped = false;
is_modified = false;
}
static setUnitRef = function(ref, mode = VALUE_UNIT.constant) {

View file

@ -2,5 +2,5 @@ function nodeValue_Pbbox(_name, _node, _value, _tooltip = "") { return new __Nod
function __NodeValue_Pbbox(_name, _node, _value, _tooltip = "") : __NodeValue_Object_Generic(_name, _node, VALUE_TYPE.pbBox, _value, _tooltip) constructor {
setVisible(true, true)
is_modified = true;
}

View file

@ -89,7 +89,6 @@ void main() {
float ksize = 0.;
float borDist = 99999.;
float borCond = isShape? 0. : 1.;
float scanRad = max(corner_radius, stroke_thickness);
for(float i = -scanRad; i <= scanRad; i++)

View file

@ -0,0 +1,36 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform int stroke;
uniform float stroke_thickness;
uniform vec4 stroke_color;
uniform float corner_radius;
void main() {
vec2 tx = 1. / dimension;
vec4 cc = texture2D(gm_BaseTexture, v_vTexcoord);
gl_FragColor = cc;
if(cc.a == 1.) return;
float borDist = 99999.;
for(float i = -16.; i <= 16.; i++)
for(float j = -16.; j <= 16.; j++) {
if(abs(i) > stroke_thickness || abs(j) > stroke_thickness) continue;
vec4 samp = texture2D(gm_BaseTexture, v_vTexcoord + vec2(i, j) * tx);
if(abs(i) <= stroke_thickness && abs(j) <= stroke_thickness) {
if(samp.a == 1.) borDist = min(borDist, length(vec2(i, j)));
}
}
if(stroke == 1) {
if(borDist <= float(stroke_thickness))
gl_FragColor = stroke_color;
}
}

View file

@ -0,0 +1,14 @@
attribute vec3 in_Position; // (x, y, z)
attribute vec4 in_Colour; // (r, g, b, a)
attribute vec2 in_TextureCoord; // (u, v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 object_space_pos = vec4(in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,13 @@
{
"$GMShader":"",
"%Name":"sh_pb_main_draw",
"name":"sh_pb_main_draw",
"parent":{
"name":"shaders",
"path":"folders/nodes/data/PB/main/shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"tags":[],
"type":1,
}