Fix widget not update value

This commit is contained in:
Tanasart 2024-03-31 16:10:14 +07:00
parent caabe634c3
commit ea1b80161b
55 changed files with 683 additions and 419 deletions

View file

@ -244,7 +244,6 @@
{"name":"oRigidbody","order":13,"path":"objects/oRigidbody/oRigidbody.yy",},
{"name":"rotator_Rotator","order":3,"path":"objects/rotator_Rotator/rotator_Rotator.yy",},
{"name":"slider_Slider","order":1,"path":"objects/slider_Slider/slider_Slider.yy",},
{"name":"textBox_slider","order":16,"path":"objects/textBox_slider/textBox_slider.yy",},
{"name":"__3d_particle","order":1,"path":"scripts/__3d_particle/__3d_particle.yy",},
{"name":"__3D","order":6,"path":"scripts/__3D/__3D.yy",},
{"name":"__add_node_item","order":13,"path":"scripts/__add_node_item/__add_node_item.yy",},

View file

@ -579,7 +579,6 @@
{"id":{"name":"oRigidbody","path":"objects/oRigidbody/oRigidbody.yy",},},
{"id":{"name":"rotator_Rotator","path":"objects/rotator_Rotator/rotator_Rotator.yy",},},
{"id":{"name":"slider_Slider","path":"objects/slider_Slider/slider_Slider.yy",},},
{"id":{"name":"textBox_slider","path":"objects/textBox_slider/textBox_slider.yy",},},
{"id":{"name":"rm_main","path":"rooms/rm_main/rm_main.yy",},},
{"id":{"name":"__3d_particle","path":"scripts/__3d_particle/__3d_particle.yy",},},
{"id":{"name":"__3D","path":"scripts/__3D/__3D.yy",},},

View file

@ -235,7 +235,6 @@
DIALOGS = ds_list_create();
WIDGET_TAB_BLOCK = false;
instance_create(0, 0, textBox_slider);
instance_create(0, 0, o_dialog_textbox_autocomplete);
instance_create(0, 0, o_dialog_textbox_function_guide);
#endregion

View file

@ -1,23 +0,0 @@
/// @description
depth = -19999;
tb = noone;
def_val = 0;
cur_val = 0;
def_mx = 0;
def_my = 0;
prev_mx = 0;
function activate(defVal) {
def_val = defVal;
cur_val = defVal;
def_mx = mouse_mx;
def_my = mouse_my;
prev_mx = mouse_mx;
CURSOR_LOCK_X = mouse_mx;
CURSOR_LOCK_Y = mouse_my;
}

View file

@ -1,41 +0,0 @@
/// @description
if(tb == noone) exit;
MOUSE_BLOCK = true;
CURSOR_LOCK = true;
if(mouse_check_button_pressed(mb_right)) {
tb._input_text = string_real(def_val);
tb.apply();
tb.sliding = false;
tb.deactivate();
UNDO_HOLDING = false;
tb = noone;
exit;
}
var _s = tb.slide_speed;
var _mdx = window_mouse_get_delta_x();
var _mdy = window_mouse_get_delta_y();
var _dx = abs(_mdx) > abs(_mdy)? _mdx : -_mdy;
if(key_mod_press(CTRL) && !tb.slide_snap) _s *= 10;
if(key_mod_press(ALT)) _s /= 10;
cur_val += _dx * _s;
if(tb.slide_range != noone)
cur_val = clamp(cur_val, tb.curr_range[0], tb.curr_range[1]);
var _val = value_snap(cur_val, _s);
if(key_mod_press(CTRL) && tb.slide_snap) _val = value_snap(cur_val, tb.slide_snap);
if(tb.slide_int) _val = round(_val);
if(abs(_val) < _s * 4) _val = 0;
tb._input_text = string_real(_val);
if(tb.apply()) UNDO_HOLDING = true;
tb = noone;

View file

@ -1,36 +0,0 @@
{
"$GMObject":"",
"%Name":"textBox_slider",
"eventList":[
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"textBox_slider",
"overriddenProperties":[],
"parent":{
"name":"text",
"path":"folders/widgets/text.yy",
},
"parentObjectId":null,
"persistent":false,
"physicsAngularDamping":0.1,
"physicsDensity":0.5,
"physicsFriction":0.2,
"physicsGroup":1,
"physicsKinematic":false,
"physicsLinearDamping":0.1,
"physicsObject":false,
"physicsRestitution":0.1,
"physicsSensor":false,
"physicsShape":1,
"physicsShapePoints":[],
"physicsStartAwake":true,
"properties":[],
"resourceType":"GMObject",
"resourceVersion":"2.0",
"solid":false,
"spriteId":null,
"spriteMaskId":null,
"visible":true,
}

View file

@ -139,7 +139,7 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m);
} #endregion
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) {
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { #region
x = _x;
y = _y;
w = _w;
@ -360,5 +360,11 @@ function areaBox(_onModify, _unit = noone) : widget() constructor {
resetFocus();
return h;
}
} #endregion
static clone = function() { #region
var cln = new areaBox(onModify, unit);
return cln;
} #endregion
}

View file

@ -115,6 +115,20 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
return _h;
} #endregion
static clone = function() { #region
var cln = new buttonClass(onClick);
cln.icon = icon;
cln.icon_blend = icon_blend;
cln.icon_index = icon_index;
cln.text = text;
cln.tooltip = tooltip;
cln.blend = blend;
return cln;
} #endregion
}
function buttonInstant(spr, _x, _y, _w, _h, _m, _act, _hvr, _tip = "", _icon = noone, _icon_index = 0, _icon_blend = COLORS._main_icon, _icon_alpha = 1, _icon_scale = 1) { #region

View file

@ -39,4 +39,12 @@ function buttonAnchor(_onClick) : widget() constructor {
return _h;
}
static clone = function() { #region
var cln = new buttonAnchor();
cln.onClick = onClick;
return cln;
} #endregion
}

View file

@ -1,8 +1,8 @@
function buttonColor(_onApply, dialog = noone) : widget() constructor {
onApply = _onApply;
parentDialog = dialog;
onApply = _onApply;
parentDialog = dialog;
current_value = 0;
triggered = false;
triggered = false;
onColorPick = function() {
var dialog = dialogCall(o_dialog_color_selector, WIN_W / 2, WIN_H / 2);
@ -17,7 +17,7 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
is_picking = false;
current_color = c_black;
b_picker = button(onColorPick);
b_picker = button(onColorPick);
b_picker.icon = THEME.color_picker_dropper;
b_quick_pick = button(function() {
@ -152,6 +152,11 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
resetFocus();
return h;
}
static clone = function() { #region
var cln = new buttonColor(onApply, parentDialog);
return cln;
} #endregion
}
function drawColor(color, _x, _y, _w, _h) {

View file

@ -93,4 +93,9 @@ function buttonGradient(_onApply, dialog = noone) : widget() constructor {
resetFocus();
return h;
} #endregion
static clone = function() { #region
var cln = new buttonGradient(onApply, parentDialog);
return cln;
} #endregion
}

View file

@ -120,4 +120,9 @@ function buttonGroup(_data, _onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new buttonGroup(data, onClick);
return cln;
} #endregion
}

View file

@ -93,6 +93,11 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
return h;
} #endregion
static clone = function() { #region
var cln = new buttonPalette(onApply, parentDialog);
return cln;
} #endregion
}
function drawPalette(_pal, _x, _y, _w, _h, _a = 1) { #region

View file

@ -83,4 +83,10 @@ function checkBox(_onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new checkBox(onClick);
return cln;
} #endregion
}

View file

@ -45,4 +45,10 @@ function checkBoxActive(_onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new checkBoxActive(onClick);
return cln;
} #endregion
}

View file

@ -70,4 +70,10 @@ function checkBoxGroup(sprs, _onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new checkBoxGroup(sprs, onClick);
return cln;
} #endregion
}

View file

@ -150,4 +150,10 @@ function controlPointBox(_onModify) : widget() constructor {
resetFocus();
return yy - _y;
}
static clone = function() { #region
var cln = new controlPointBox(onModify);
return cln;
} #endregion
}

View file

@ -1,5 +1,6 @@
function cornerBox(_onModify, _unit = noone) : widget() constructor {
onModify = _onModify;
unit = _unit;
linked = false;
b_link = button(function() { linked = !linked; });
@ -118,4 +119,10 @@ function cornerBox(_onModify, _unit = noone) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new cornerBox(onModify, unit);
return cln;
} #endregion
}

View file

@ -66,6 +66,7 @@ function curveBox(_onModify) : widget() constructor {
if(node_dragging != -1) { #region editing
show_coord = true;
_data = array_clone(_data);
if(node_drag_typ == 0) {
var node_point = (node_dragging - 2) / 6;
@ -381,4 +382,10 @@ function curveBox(_onModify) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new curveBox(onModify);
return cln;
} #endregion
}

View file

@ -1,12 +1,18 @@
global.LINE_HEIGHTS = {};
function line_get_height(font = noone, offset = 0) {
INLINE
var _f = font != noone? font : draw_get_font();
if(struct_has(global.LINE_HEIGHTS, _f)) return global.LINE_HEIGHTS[$ _f] + offset * UI_SCALE;
var ff = draw_get_font();
if(font != noone)
draw_set_font(font);
var hh = string_height("l") + offset * UI_SCALE;
if(font != noone) draw_set_font(font);
var hh = string_height("l");
global.LINE_HEIGHTS[$ _f] = hh;
draw_set_font(ff);
return hh;
return hh + offset * UI_SCALE;
}
function line_get_width(txt, font = noone, offset = 0) {

View file

@ -88,4 +88,10 @@ function fontScrollBox(_onModify) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new fontScrollBox(onModify);
return cln;
} #endregion
}

View file

@ -1,4 +1,5 @@
function matrixGrid(_type, _size, _onModify, _unit = noone) : widget() constructor {
type = _type;
size = _size;
inputs = size * size;
onModify = _onModify;
@ -148,4 +149,10 @@ function matrixGrid(_type, _size, _onModify, _unit = noone) : widget() construct
return h;
}
static clone = function() { #region
var cln = new matrixGrid(type, size, onModify, unit);
return cln;
} #endregion
}

View file

@ -71,7 +71,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
if(_hover && point_in_circle(_m[0], _m[1], butx, lb_y, ui(10))) {
if(visi_hold != noone && jun.visible != visi_hold) {
jun.visible = visi_hold;
jun.node.setHeight();
jun.node.refreshNodeDisplay();
}
draw_sprite_ui_uniform(THEME.junc_visible, index, butx, lb_y, 1,, 1);
@ -80,7 +80,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
if(mouse_press(mb_left, _focus)) {
jun.visible = !jun.visible;
visi_hold = jun.visible;
jun.node.setHeight();
jun.node.refreshNodeDisplay();
}
}
#endregion

View file

@ -61,7 +61,7 @@ function Node_VFX_Renderer_Output(_x, _y, _group = noone) : Node_Group_Output(_x
outParent.from = self;
ds_list_add(group.outputs, outParent);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
} if(!LOADING && !APPENDING) createOutput(); #endregion

View file

@ -456,7 +456,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
array_push_unique(attributes.output_display_list, i);
output_display_list = attributes.output_display_list;
setHeight();
refreshNodeDisplay();
} #endregion
static getTool = function() { #region

View file

@ -308,190 +308,190 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
static getInputAmount = function() { INLINE return input_fix_len + (ds_list_size(inputs) - input_fix_len) / data_length; }
static getInputIndex = function(index) { #region
INLINE
//static getInputIndex = function(index) { #region
// INLINE
if(index < input_fix_len) return index;
return input_fix_len + (index - input_fix_len) * data_length;
} #endregion
// if(index < input_fix_len) return index;
// return input_fix_len + (index - input_fix_len) * data_length;
//} #endregion
static setHeight = function() { #region
var _hi = ui(32);
var _ho = ui(32);
//static setHeight = function() { #region
// var _hi = ui(32);
// var _ho = ui(32);
for( var i = 0; i < getInputAmount(); i++ )
if(inputs[| getInputIndex(i)].isVisible())
_hi += 24;
// for( var i = 0; i < getInputAmount(); i++ )
// if(inputs[| getInputIndex(i)].isVisible())
// _hi += 24;
for( var i = 0; i < ds_list_size(outputs); i++ )
if(outputs[| i].isVisible())
_ho += 24;
// for( var i = 0; i < ds_list_size(outputs); i++ )
// if(outputs[| i].isVisible())
// _ho += 24;
h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho);
} #endregion
// h = max(min_h, (preview_surface && previewable)? 128 : 0, _hi, _ho);
//} #endregion
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
if(!active) return;
var hover = noone;
var amo = array_length(input_display_list);
//static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
// if(!active) return;
// var hover = noone;
// var amo = array_length(input_display_list);
var hov = PANEL_GRAPH.value_focus;
var ind = -1;
if(hov != noone && struct_has(hov, "surface_index"))
ind = hov.surface_index;
// var hov = PANEL_GRAPH.value_focus;
// var ind = -1;
// if(hov != noone && struct_has(hov, "surface_index"))
// ind = hov.surface_index;
for( var i = 0; i < getInputAmount(); i++ ) {
var idx = getInputIndex(i);
if(!inputs[| idx].isVisible()) continue;
// for( var i = 0; i < getInputAmount(); i++ ) {
// var idx = getInputIndex(i);
// if(!inputs[| idx].isVisible()) continue;
if(inputs[| idx].drawJunction(_s, _mx, _my, 1.5))
hover = inputs[| idx];
// if(inputs[| idx].drawJunction(_s, _mx, _my, 1.5))
// hover = inputs[| idx];
if(idx >= input_fix_len && inputs[| idx].hover_effect > 0) {
var _px0 = 999999;
var _py0 = 999999;
var _px1 = -999999;
var _py1 = -999999;
var _drw = false;
var _hov = inputs[| idx].hover_effect;
// if(idx >= input_fix_len && inputs[| idx].hover_effect > 0) {
// var _px0 = 999999;
// var _py0 = 999999;
// var _px1 = -999999;
// var _py1 = -999999;
// var _drw = false;
// var _hov = inputs[| idx].hover_effect;
for( var j = 1; j < data_length; j++ ) {
if(!inputs[| idx + j].isVisible()) continue;
_px0 = min( _px0, inputs[| idx + j].x );
_py0 = min( _py0, inputs[| idx + j].y );
_px1 = max( _px1, inputs[| idx + j].x );
_py1 = max( _py1, inputs[| idx + j].y );
_drw = true;
}
// for( var j = 1; j < data_length; j++ ) {
// if(!inputs[| idx + j].isVisible()) continue;
// _px0 = min( _px0, inputs[| idx + j].x );
// _py0 = min( _py0, inputs[| idx + j].y );
// _px1 = max( _px1, inputs[| idx + j].x );
// _py1 = max( _py1, inputs[| idx + j].y );
// _drw = true;
// }
if(!_drw) continue;
// if(!_drw) continue;
//if(_hov > 0.5) {
// var pilx = _px0 - 16 * _s;
// var pily = _py0 - 16 * _s;
// var pilw = _px1 - _px0 + 32 * _s;
// var pilh = _py1 - _py0 + 32 * _s;
// //if(_hov > 0.5) {
// // var pilx = _px0 - 16 * _s;
// // var pily = _py0 - 16 * _s;
// // var pilw = _px1 - _px0 + 32 * _s;
// // var pilh = _py1 - _py0 + 32 * _s;
// draw_sprite_stretched_ext(THEME.node_bg_pill, 0, pilx, pily, pilw, pilh, COLORS._main_icon_dark, (_hov - 0.5) * 2);
//}
// // draw_sprite_stretched_ext(THEME.node_bg_pill, 0, pilx, pily, pilw, pilh, COLORS._main_icon_dark, (_hov - 0.5) * 2);
// //}
for( var j = 1; j < data_length; j++ ) {
if(inputs[| idx + j].drawJunction(_s, _mx, _my, 1.5))
hover = inputs[| idx + j];
}
}
}
// for( var j = 1; j < data_length; j++ ) {
// if(inputs[| idx + j].drawJunction(_s, _mx, _my, 1.5))
// hover = inputs[| idx + j];
// }
// }
// }
for(var i = 0; i < ds_list_size(outputs); i++)
if(outputs[| i].drawJunction(_s, _mx, _my))
hover = outputs[| i];
// for(var i = 0; i < ds_list_size(outputs); i++)
// if(outputs[| i].drawJunction(_s, _mx, _my))
// hover = outputs[| i];
return hover;
} #endregion
// return hover;
//} #endregion
static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region
if(!active) return;
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
var jun;
//static drawJunctionNames = function(_x, _y, _mx, _my, _s) { #region
// if(!active) return;
// var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
// var jun;
var xx = x * _s + _x;
var yy = y * _s + _y;
// var xx = x * _s + _x;
// var yy = y * _s + _y;
show_input_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx - 8 * _s, yy + 20 * _s, xx + 8 * _s, yy + h * _s);
show_output_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx + (w - 8) * _s, yy + 20 * _s, xx + (w + 8) * _s, yy + h * _s);
// show_input_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx - 8 * _s, yy + 20 * _s, xx + 8 * _s, yy + h * _s);
// show_output_name = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx + (w - 8) * _s, yy + 20 * _s, xx + (w + 8) * _s, yy + h * _s);
var hov = PANEL_GRAPH.value_focus;
var ind = -1;
if(hov != noone && struct_has(hov, "surface_index"))
ind = hov.surface_index;
// var hov = PANEL_GRAPH.value_focus;
// var ind = -1;
// if(hov != noone && struct_has(hov, "surface_index"))
// ind = hov.surface_index;
if(ind != -1) {
for( var j = 1; j < data_length; j++ ) {
if(ind + j >= ds_list_size(inputs)) break;
inputs[| ind + j].drawNameBG(_s);
}
// if(ind != -1) {
// for( var j = 1; j < data_length; j++ ) {
// if(ind + j >= ds_list_size(inputs)) break;
// inputs[| ind + j].drawNameBG(_s);
// }
for( var j = 1; j < data_length; j++ ) {
if(ind + j >= ds_list_size(inputs)) break;
inputs[| ind + j].drawName(_s, _mx, _my);
}
// for( var j = 1; j < data_length; j++ ) {
// if(ind + j >= ds_list_size(inputs)) break;
// inputs[| ind + j].drawName(_s, _mx, _my);
// }
} else if(show_input_name) {
for( var i = 0; i < getInputAmount(); i++ ) {
var idx = getInputIndex(i);
// } else if(show_input_name) {
// for( var i = 0; i < getInputAmount(); i++ ) {
// var idx = getInputIndex(i);
if(idx == ind) continue;
inputs[| idx].drawNameBG(_s);
}
// if(idx == ind) continue;
// inputs[| idx].drawNameBG(_s);
// }
for( var i = 0; i < getInputAmount(); i++ ) {
var idx = getInputIndex(i);
// for( var i = 0; i < getInputAmount(); i++ ) {
// var idx = getInputIndex(i);
if(idx == ind) continue;
inputs[| idx].drawName(_s, _mx, _my);
}
}
// if(idx == ind) continue;
// inputs[| idx].drawName(_s, _mx, _my);
// }
// }
if(show_output_name) {
for(var i = 0; i < ds_list_size(outputs); i++)
outputs[| i].drawNameBG(_s);
// if(show_output_name) {
// for(var i = 0; i < ds_list_size(outputs); i++)
// outputs[| i].drawNameBG(_s);
for(var i = 0; i < ds_list_size(outputs); i++)
outputs[| i].drawName(_s, _mx, _my);
}
} #endregion
// for(var i = 0; i < ds_list_size(outputs); i++)
// outputs[| i].drawName(_s, _mx, _my);
// }
//} #endregion
static preDraw = function(_x, _y, _s) { #region
var xx = x * _s + _x;
var yy = y * _s + _y;
var jun;
//static preDraw = function(_x, _y, _s) { #region
// var xx = x * _s + _x;
// var yy = y * _s + _y;
// var jun;
var inamo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
var _in = yy + ui(32) * _s;
// var inamo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
// var _in = yy + ui(32) * _s;
var hov = PANEL_GRAPH.value_focus;
var ind = -1;
if(hov != noone && struct_has(hov, "surface_index"))
ind = hov.surface_index;
// var hov = PANEL_GRAPH.value_focus;
// var ind = -1;
// if(hov != noone && struct_has(hov, "surface_index"))
// ind = hov.surface_index;
for( var i = 0; i < getInputAmount(); i++ ) {
var idx = getInputIndex(i);
jun = ds_list_get(inputs, idx, noone);
if(jun == noone || is_undefined(jun)) continue;
jun.x = xx;
jun.y = _in;
// for( var i = 0; i < getInputAmount(); i++ ) {
// var idx = getInputIndex(i);
// jun = ds_list_get(inputs, idx, noone);
// if(jun == noone || is_undefined(jun)) continue;
// jun.x = xx;
// jun.y = _in;
if(i >= input_fix_len) {
jun.hover_effect = lerp_float(jun.hover_effect, ind == idx, 3);
var sp = jun.hover_effect * 24;
var sx = xx - sp * _s;
var sy = _in;
// if(i >= input_fix_len) {
// jun.hover_effect = lerp_float(jun.hover_effect, ind == idx, 3);
// var sp = jun.hover_effect * 24;
// var sx = xx - sp * _s;
// var sy = _in;
for( var j = 1; j < data_length; j++ ) {
var _jun = ds_list_get(inputs, idx + j, noone);
_jun.x = sx;
_jun.y = sy;
// for( var j = 1; j < data_length; j++ ) {
// var _jun = ds_list_get(inputs, idx + j, noone);
// _jun.x = sx;
// _jun.y = sy;
sy += sp * _s * _jun.isVisible();
}
}
// sy += sp * _s * _jun.isVisible();
// }
// }
_in += 24 * _s * jun.isVisible();
}
// _in += 24 * _s * jun.isVisible();
// }
var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list);
// var outamo = output_display_list == -1? ds_list_size(outputs) : array_length(output_display_list);
xx = xx + w * _s;
_in = yy + ui(32) * _s;
for(var i = 0; i < outamo; i++) {
var idx = getOutputJunctionIndex(i);
jun = outputs[| idx];
// xx = xx + w * _s;
// _in = yy + ui(32) * _s;
// for(var i = 0; i < outamo; i++) {
// var idx = getOutputJunctionIndex(i);
// jun = outputs[| idx];
jun.x = xx;
jun.y = _in;
_in += 24 * _s * jun.isVisible();
}
} #endregion
// jun.x = xx;
// jun.y = _in;
// _in += 24 * _s * jun.isVisible();
// }
//} #endregion
static onValueFromUpdate = function(index) { #region
if(LOADING || APPENDING) return;

View file

@ -14,6 +14,7 @@ enum DYNA_INPUT_COND {
}
function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
#region ---- main & active ----
active = true;
renderActive = true;
@ -173,7 +174,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
attributeEditors = [
"Display",
["Params Width", function() { return attributes.node_param_width; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.node_param_width = val; setHeight(); }) ],
["Params Width", function() { return attributes.node_param_width; }, new textBox(TEXTBOX_INPUT.number, function(val) { attributes.node_param_width = val; refreshNodeDisplay(); }) ],
"Node update",
["Auto update", function() { return attributes.update_graph; }, new checkBox(function() { attributes.update_graph = !attributes.update_graph; }) ],
@ -394,8 +395,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
h = max(min_h, _prev_surf * 128, _hi, _ho, attributes.node_height);
fix_h = h;
getJunctionList();
} run_in(1, function() { setHeight(); }); #endregion
} #endregion
static setDisplayName = function(_name) { #region
renamed = true;
@ -684,7 +684,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(!is_instanceof(self, Node_Collection))
render_time = get_timer() - render_timer;
setHeight();
refreshNodeDisplay();
LOG_BLOCK_END();
} #endregion
@ -717,7 +717,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static triggerRender = function() { #region
LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"Trigger render for {INAME}");
//printCallStack();
LOG_IF(global.FLAG.render == 1, $"Trigger render for {self}");
setRenderStatus(false);
RENDER_PARTIAL
@ -899,8 +900,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static setRenderStatus = function(result) { #region
INLINE
if(rendered == result) return;
LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {INAME} : {result}");
LOG_LINE_IF(global.FLAG.render == 1, $"Set render status for {self} : {result}");
rendered = result;
} #endregion
@ -926,8 +928,16 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_graph_culled = !rectangle_in_rectangle(minx, miny, maxx, maxy, x0, y0, x1, y1);
} #endregion
static refreshNodeDisplay = function() { #region
INLINE
updateIO();
setHeight();
getJunctionList();
} run_in(1, function() { refreshNodeDisplay(); }); #endregion
static getJunctionList = function() { #region
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
var amo = input_display_list == -1? ds_list_size(inputs) : array_length(input_display_list);
inputDisplayList = [];
for(var i = 0; i < amo; i++) {
@ -940,15 +950,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
array_push(inputDisplayList, jun);
}
} run_in(1, function() { getJunctionList() }); #endregion
}#endregion
static preDraw = function(_x, _y, _s) { #region
var xx = x * _s + _x;
var yy = y * _s + _y;
var jun;
//getJunctionList();
var inspCount = hasInspector1Update() + hasInspector2Update();
var ind = 1;
if(hasInspector1Update()) {
@ -970,7 +978,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
updatedOutTrigger.y = yy + 10;
if(in_cache_len != array_length(inputDisplayList) || out_cache_len != ds_list_size(outputs)) {
updateIO();
refreshNodeDisplay();
in_cache_len = array_length(inputDisplayList);
out_cache_len = ds_list_size(outputs);
@ -978,13 +986,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var _iny = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * show_parameter) * _s;
for(var i = 0; i < inputs_amount; i++) {
var idx = inputs_index[i];
jun = inputs[| idx];
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
jun = inputs[| i];
jun.x = xx;
jun.y = _iny;
}
for(var i = 0; i < in_cache_len; i++) {
jun = inputDisplayList[i];
jun.x = xx;
jun.y = _iny;
_iny += junction_draw_hei_y * _s * jun.isVisible();
_iny += junction_draw_hei_y * _s;
}
xx = xx + w * _s;
@ -1026,6 +1039,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_sprite_stretched_ext(bg_spr, 0, xx, yy, w * _s, h * _s, cc, aa);
} #endregion
__draw_bbox = BBOX();
static drawGetBbox = function(xx, yy, _s) { #region
var pad_label = draw_name && display_parameter.avoid_label;
@ -1049,7 +1063,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var y0 = _yc - _h / 2;
var y1 = _yc + _h / 2;
return BBOX().fromPoints(x0, y0, x1, y1);
return __draw_bbox.fromPoints(x0, y0, x1, y1);
} #endregion
static drawNodeName = function(xx, yy, _s) { #region
@ -1119,9 +1133,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_set_text(f_sdf, fa_left, fa_center, jun.color_display);
draw_text_add(lx, jun.y, jun.getName(), _s * 0.25);
if(jun.value_from) continue;
if(wd == noone) {
if(jun.value_from || wd == noone) {
jy += wh;
continue;
}
@ -1161,7 +1173,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
if(!active) return;
var hover = noone;
gpu_set_texfilter(true);
for(var i = 0, n = array_length(inputDisplayList); i < n; i++) {
var jun = inputDisplayList[i];
@ -1193,7 +1204,48 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
}
onDrawJunctions(_x, _y, _mx, _my, _s);
gpu_set_texfilter(false);
return hover;
} #endregion
static drawJunctions_fast = function(_x, _y, _mx, _my, _s) { #region
if(!active) return;
var hover = noone;
_s = _s * 6;
draw_set_circle_precision(4);
for(var i = 0, n = array_length(inputDisplayList); i < n; i++) {
var jun = inputDisplayList[i];
if(jun.drawJunction_fast(_s, _mx, _my))
hover = jun;
}
for(var i = 0; i < ds_list_size(outputs); i++) {
var jun = outputs[| i];
if(jun.drawJunction_fast(_s, _mx, _my))
hover = jun;
}
if(hasInspector1Update()) {
if(inspectInput1.drawJunction_fast(_s, _mx, _my))
hover = inspectInput1;
}
if(hasInspector2Update()) {
if(inspectInput2.drawJunction_fast(_s, _mx, _my))
hover = inspectInput2;
}
if(attributes.show_update_trigger) {
if(updatedInTrigger.drawJunction_fast(_s, _mx, _my)) hover = updatedInTrigger;
if(updatedOutTrigger.drawJunction_fast(_s, _mx, _my)) hover = updatedOutTrigger;
}
onDrawJunctions(_x, _y, _mx, _my, _s / 6);
return hover;
} #endregion
@ -1330,17 +1382,18 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
switch(_node.type) {
case VALUE_TYPE.surface :
case VALUE_TYPE.dynaSurface :
var val = _node.getValue();
var val = _node.showValue();
return val;
}
return noone;
} #endregion
__preview_surf = noone;
__preview_sw = noone;
__preview_sh = noone;
static drawPreview = function(xx, yy, _s) { #region
if(draw_graph_culled) return;
if(!active) return;
var surf = getGraphPreviewSurface();
if(surf == noone) return;
@ -1359,14 +1412,25 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
surf = surf[preview_index];
}
preview_surface = is_surface(surf)? surf : noone;
preview_surface = surf;
if(preview_surface == noone) return;
//if(__preview_surf != preview_surface) {
__preview_sw = surface_get_width(preview_surface);
__preview_sh = surface_get_height(preview_surface);
// __preview_surf = preview_surface;
//}
var bbox = drawGetBbox(xx, yy, _s);
var aa = 0.5 + 0.5 * renderActive;
if(!isHighlightingInGraph()) aa *= 0.25;
draw_surface_bbox(preview_surface, bbox, c_white, aa * graph_preview_alpha);
var _sw = __preview_sw;
var _sh = __preview_sh;
var _ss = min(bbox.w / _sw, bbox.h / _sh);
draw_surface_ext(preview_surface, bbox.xc - _sw * _ss / 2, bbox.yc - _sh * _ss / 2, _ss, _ss, 0, c_white, 1);
//draw_surface_bbox(preview_surface, bbox, c_white, aa * graph_preview_alpha);
} #endregion
static getNodeDimension = function(showFormat = true) { #region
@ -1490,7 +1554,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
draw_droppable = false;
}
return drawJunctions(xx, yy, _mx, _my, _s);
return _s > 0.5? drawJunctions(xx, yy, _mx, _my, _s) : drawJunctions_fast(xx, yy, _mx, _my, _s);
} #endregion
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) {}

View file

@ -22,7 +22,7 @@ function Node_DynaSurf_In(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inParent.from = self;
ds_list_add(group.inputs, inParent);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
return inParent;

View file

@ -291,7 +291,7 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
ds_list_add(group.inputs, inParent);
outputs[| 0].setFrom(inParent, false, false);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
onValueUpdate(0);

View file

@ -79,7 +79,7 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
outParent.from = self;
ds_list_add(group.outputs, outParent);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
outParent.setFrom(inputs[| 0]);

View file

@ -49,7 +49,7 @@ function Node_Rigid_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
outParent.from = self;
ds_list_add(group.outputs, outParent);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
} if(!LOADING && !APPENDING) createOutput(); #endregion

View file

@ -47,7 +47,7 @@ function Node_Smoke_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
outParent.from = self;
ds_list_add(group.outputs, outParent);
group.setHeight();
group.refreshNodeDisplay();
group.sortIO();
} if(!LOADING && !APPENDING) createOutput(); #endregion

View file

@ -678,7 +678,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(_type == VALUE_TYPE.curve) display_type = VALUE_DISPLAY.curve;
else if(_type == VALUE_TYPE.d3vertex) display_type = VALUE_DISPLAY.d3vertex;
display_data = { update: method(node, node.triggerRender) };
display_data = {};
display_attribute = noone;
popup_dialog = noone;
@ -885,8 +885,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
switch(display_type) {
case VALUE_DISPLAY._default : #region
editWidget = new textBox(_txt, function(val) { return setValueInspector(val); } );
editWidget.slidable = true;
if(type == VALUE_TYPE.integer) editWidget.setSlidable();
editWidget.setSlidable();
if(struct_has(display_data, "slide_speed")) editWidget.setSlidable(display_data.slide_speed);
if(struct_has(display_data, "unit")) editWidget.unit = display_data.unit;
@ -1280,7 +1279,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
editWidgetRaw = editWidget;
graphWidget = variable_clone(editWidget);
if(editWidget) graphWidget = editWidget.clone();
for( var i = 0, n = ds_list_size(animator.values); i < n; i++ ) {
animator.values[| i].ease_in_type = key_inter;
@ -1338,7 +1337,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(inp.visible != vis) {
inp.visible = vis;
node.setHeight();
node.refreshNodeDisplay();
}
} #endregion
@ -1594,12 +1593,14 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
cache_hit &= cache_value[3] == applyUnit;
cache_hit &= connect_type == JUNCTION_CONNECT.input;
cache_hit &= unit.reference == noone || unit.mode == VALUE_UNIT.constant;
//cache_hit &= !expUse;
if(cache_hit) {
print($"Get cache {name} = {cache_value[2]}");
global.cache_hit++;
return cache_value[2];
}
}
var val = _getValue(_time, applyUnit, arrIndex, log);
@ -1828,22 +1829,22 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return is_anim;
} #endregion
show_val = [];
static showValue = function() { #region
var useCache = true;
if(display_type == VALUE_DISPLAY.area)
useCache = false;
INLINE
var val = getValue(CURRENT_FRAME, false, 0, useCache, true);
var val = animator.values[| 0].value;
if(isArray(val)) {
if(array_length(val) == 0) return 0;
var v = val[safe_mod(node.preview_index, array_length(val))];
if(array_length(v) >= 100) return $"[{array_length(v)}]";
if(value_from != noone || is_anim || expUse)
val = getValue(CURRENT_FRAME, false, 0, true, true);
else if(sep_axis) {
show_val = array_verify(show_val, array_length(animators));
for( var i = 0, n = array_length(animators); i < n; i++ )
show_val[i] = animators[i].values[| 0].value;
val = show_val;
}
if(editWidget != noone && instanceof(editWidget) == "textBox" && string_length(string(val)) > 1024)
val = $"[Long string ({string_length(string(val))} char)]";
return val;
} #endregion
@ -1939,9 +1940,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var r = _node.inputs[| ind].setValueDirect(val, index);
if(_node == node) res = r;
}
} else
} else {
res = setValueDirect(val, index);
//print($"Node {node} : {node.name} {node.internalName}");
//print($"Inspecting {PANEL_INSPECTOR.inspecting} : {PANEL_INSPECTOR.inspecting.name} {PANEL_INSPECTOR.inspecting.internalName}");
//print($"{node == PANEL_INSPECTOR.inspecting}");
//print("");
}
return res;
} #endregion
@ -1966,6 +1973,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
}
updated = animator.setValue(_val, _inp && record, time);
}
if(type == VALUE_TYPE.gradient) updated = true;
@ -1999,7 +2007,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(is_instanceof(node, Node))
node.setInputData(self.index, animator.getValue(time));
if(tags != VALUE_TAG.none) return true;
if(tags == VALUE_TAG.updateInTrigger || tags == VALUE_TAG.updateOutTrigger) return true;
if(_update) {
if(!IS_PLAYING) node.triggerRender();
@ -2258,10 +2266,24 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return -1;
} #endregion
static drawJunction = function(_s, _mx, _my, sca = 1) { #region
var ss = max(0.25, _s / 2);
var hov = PANEL_GRAPH.pHOVER && (PANEL_GRAPH.node_hovering == noone || PANEL_GRAPH.node_hovering == node);
var is_hover = hov && point_in_circle(_mx, _my, x, y, 10 * _s * sca);
static drawJunction_fast = function(_s, _mx, _my) { #region
INLINE
var hov = PANEL_GRAPH.pHOVER && (PANEL_GRAPH.node_hovering == noone || PANEL_GRAPH.node_hovering == node);
var is_hover = hov && abs(_mx - x) + abs(_my - y) < _s;
draw_set_color(draw_fg);
draw_circle(x, y, _s, false);
return is_hover;
} #endregion
static drawJunction = function(_s, _mx, _my) { #region
_s /= 2;
var hov = PANEL_GRAPH.pHOVER && (PANEL_GRAPH.node_hovering == noone || PANEL_GRAPH.node_hovering == node);
var _d = 12 * _s;
var is_hover = hov && point_in_rectangle(_mx, _my, x - _d, y - _d, x + _d, y + _d);
var _bgS = THEME.node_junctions_bg;
var _fgS = is_hover? THEME.node_junctions_outline_hover : THEME.node_junctions_outline;
@ -2272,7 +2294,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(draw_blend != -1)
_cbg = merge_color(draw_blend_color, _cbg, draw_blend);
draw_sprite_ext(THEME.node_junction_inspector, is_hover, x, y, ss, ss, 0, _cbg, 1);
__draw_sprite_ext(THEME.node_junction_inspector, is_hover, x, y, _s, _s, 0, _cbg, 1);
} else {
var _cbg = draw_bg;
var _cfg = draw_fg;
@ -2282,8 +2304,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
_cfg = merge_color(draw_blend_color, _cfg, draw_blend);
}
draw_sprite_ext(_bgS, draw_junction_index, x, y, ss, ss, 0, _cbg, 1);
draw_sprite_ext(_fgS, draw_junction_index, x, y, ss, ss, 0, _cfg, 1);
__draw_sprite_ext(_bgS, draw_junction_index, x, y, _s, _s, 0, _cbg, 1);
__draw_sprite_ext(_fgS, draw_junction_index, x, y, _s, _s, 0, _cfg, 1);
}
return is_hover;

View file

@ -133,4 +133,10 @@ function paddingBox(_onModify, _unit = noone) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new paddingBox(onModify, unit);
return cln;
} #endregion
}

View file

@ -453,7 +453,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_foreach(nodes_selecting, function(node, index) {
if(index == 0) __temp_show = !node.previewable;
node.previewable = __temp_show;
node.setHeight();
node.refreshNodeDisplay();
});
} #endregion
@ -462,7 +462,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_foreach(nodes_selecting, function(node, index) {
if(index == 0) __temp_show = !node.show_parameter;
node.show_parameter = __temp_show;
node.setHeight();
node.refreshNodeDisplay();
});
} #endregion

View file

@ -739,7 +739,7 @@ function Panel_Inspector() : PanelContent() constructor {
}
#region color picker
if(key_mod_press(ALT) && color_picker_index && textBox_slider.tb == noone) {
if(key_mod_press(ALT) && color_picker_index) {
pickers[picker_index].editWidget.onColorPick();
}

View file

@ -87,4 +87,10 @@ function pathAnchorBox(_onModify) : widget() constructor {
resetFocus();
return h;
}
static clone = function() { #region
var cln = new pathAnchorBox(onModify);
return cln;
} #endregion
}

View file

@ -81,4 +81,10 @@ function pathArrayBox(_target, _data, _onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new pathArrayBox(target, data, onClick);
return cln;
} #endregion
}

View file

@ -55,6 +55,13 @@ function quarternionBox(_onModify) : widget() constructor {
return false;
}
static apply = function() {
for( var i = 0; i < size; i++ ) {
tb[i].apply();
current_value[i] = toNumber(tb[i]._input_text);
}
}
static drawParam = function(params) {
setParam(params);
for(var i = 0; i < 4; i++) tb[i].setParam(params);
@ -115,10 +122,9 @@ function quarternionBox(_onModify) : widget() constructor {
return _h;
}
static apply = function() {
for( var i = 0; i < size; i++ ) {
tb[i].apply();
current_value[i] = toNumber(tb[i]._input_text);
}
}
static clone = function() { #region
var cln = new quarternionBox(onModify);
return cln;
} #endregion
}

View file

@ -1,4 +1,5 @@
function rangeBox(_type, _onModify) : widget() constructor {
type = _type;
onModify = _onModify;
linked = false;
@ -34,38 +35,38 @@ function rangeBox(_type, _onModify) : widget() constructor {
tb[i].label = labels[i];
}
static setSlideSpeed = function(speed) {
static setSlideSpeed = function(speed) { #region
tb[0].setSlidable(speed);
tb[1].setSlidable(speed);
}
} #endregion
static setInteract = function(interactable = noone) {
static setInteract = function(interactable = noone) { #region
self.interactable = interactable;
tb[0].interactable = interactable;
if(!linked)
tb[1].interactable = interactable;
}
} #endregion
static register = function(parent = noone) {
static register = function(parent = noone) { #region
tb[0].register(parent);
if(!linked)
tb[1].register(parent);
}
} #endregion
static isHovering = function() {
static isHovering = function() { #region
for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true;
return false;
}
} #endregion
static drawParam = function(params) {
static drawParam = function(params) { #region
setParam(params);
for(var i = 0; i < 2; i++) tb[i].setParam(params);
return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m);
}
} #endregion
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) {
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { #region
x = _x;
y = _y;
w = _w;
@ -122,5 +123,11 @@ function rangeBox(_type, _onModify) : widget() constructor {
resetFocus();
return h;
}
} #endregion
static clone = function() { #region
var cln = new rangeBox(type, onModify);
return cln;
} #endregion
}

View file

@ -124,4 +124,10 @@ function rotator(_onModify, _step = -1) : widget() constructor {
return h;
} #endregion
static clone = function() { #region
var cln = new rotator(onModify, valStep);
return cln;
} #endregion
}

View file

@ -456,4 +456,10 @@ function rotatorRandom(_onModify) : widget() constructor {
return h;
} #endregion
static clone = function() { #region
var cln = new rotatorRandom(onModify);
return cln;
} #endregion
}

View file

@ -126,4 +126,10 @@ function rotatorRange(_onModify) : widget() constructor {
return h;
} #endregion
static clone = function() { #region
var cln = new rotatorRange(onModify);
return cln;
} #endregion
}

View file

@ -130,4 +130,10 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor
return h;
} #endregion
static clone = function() { #region
var cln = new scrollBox(data, onModify, update_hover);
return cln;
} #endregion
}

View file

@ -1,8 +1,8 @@
function sliderRange(_step, _int, _range, _onModify) : widget() constructor {
slide_range = _range;
curr_range = [ _range[0], _range[1] ];
stepSize = _step;
slide_range = _range;
isInt = _int;
curr_range = [ _range[0], _range[1] ];
onModify = _onModify;
@ -80,4 +80,10 @@ function sliderRange(_step, _int, _range, _onModify) : widget() constructor {
return h;
} #endregion
static clone = function() { #region
var cln = new sliderRange(stepSize, isInt, slide_range, onModify);
return cln;
} #endregion
}

View file

@ -10,8 +10,7 @@ function surfaceBox(_onModify, def_path = "") : widget() constructor {
display_data = {};
cb_atlas_crop = new checkBox(function() {
display_data.atlas_crop = !display_data.atlas_crop;
display_data.update();
display_data.atlas_crop = !display_data.atlas_crop;
});
static trigger = function() {
@ -135,4 +134,10 @@ function surfaceBox(_onModify, def_path = "") : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new surfaceBox(onModify, def_path);
return cln;
} #endregion
}

View file

@ -1032,4 +1032,5 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
return hh;
} #endregion
}

View file

@ -2,19 +2,19 @@ function textArrayBox(arraySet, data, onModify = noone) : widget() constructor {
self.getArray = arraySet;
self.arraySet = noone;
self.data = data;
self.data = data;
self.onModify = onModify;
hide = false;
open = false;
static drawParam = function(params) {
static drawParam = function(params) { #region
setParam(params);
return draw(params.x, params.y, params.w, params.h, params.m, params.rx, params.ry);
}
} #endregion
static draw = function(_x, _y, _w, _h, _m, _rx = 0, _ry = 0) {
static draw = function(_x, _y, _w, _h, _m, _rx = 0, _ry = 0) { #region
x = _x;
y = _y;
w = _w;
@ -76,5 +76,11 @@ function textArrayBox(arraySet, data, onModify = noone) : widget() constructor {
resetFocus();
return th;
}
} #endregion
static clone = function() { #region
var cln = new textArrayBox(getArray, data, onModify);
return cln;
} #endregion
}

View file

@ -27,6 +27,9 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
slide_range = noone;
curr_range = [ 0, 1 ];
slider_def_val = 0;
slider_cur_val = 0;
label = "";
starting_char = 1;
@ -160,7 +163,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
}
} #endregion
static apply = function(fn = onModify) { #region
static apply = function(release = false) { #region
var _input_text_current = _input_text;
disp_x_to = 0;
@ -171,10 +174,18 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
_input_text_current = _last_text;
current_value = _input_text_current;
if(is_callable(fn)) {
var _modi = fn(_input_text_current);
if(_modi && IS_PATREON) shake_amount = PREFERENCES.textbox_shake / 4;
return _modi;
if(release) {
if(is_callable(onRelease)) {
var _modi = onRelease(_input_text_current);
if(_modi && IS_PATREON) shake_amount = PREFERENCES.textbox_shake / 4;
return _modi;
}
} else {
if(is_callable(onModify)) {
var _modi = onModify(_input_text_current);
if(_modi && IS_PATREON) shake_amount = PREFERENCES.textbox_shake / 4;
return _modi;
}
}
if(IS_PATREON) shake_amount = PREFERENCES.textbox_shake / 4;
@ -401,6 +412,8 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
if(shake_amount) shake_amount--;
}
var drawText = selecting || _h >= line_get_height(font);
switch(halign) {
case fa_left: _x = _x; break;
case fa_center: _x = _x - _w / 2; break;
@ -435,8 +448,10 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
case fa_right : tx = _x + _w - ui(8); break;
}
var _update = !surface_valid(text_surface, _w - ui(16), _h);
if(_update) text_surface = surface_verify(text_surface, _w - ui(16), _h);
if(drawText) {
var _update = !surface_valid(text_surface, _w - ui(16), _h);
if(_update) text_surface = surface_verify(text_surface, _w - ui(16), _h);
}
if(!hide) {
draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, boxColor, 1);
@ -485,15 +500,56 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
if(sliding == 1 && abs(slide_delta) > 8) {
deactivate();
textBox_slider.activate(toNumber(_input_text));
var _defval = toNumber(_current_text);
slider_def_val = _defval;
slider_cur_val = _defval;
CURSOR_LOCK_X = mouse_mx;
CURSOR_LOCK_Y = mouse_my;
sliding = 2;
}
if(sliding == 2) {
textBox_slider.tb = self;
MOUSE_BLOCK = true;
CURSOR_LOCK = true;
if(mouse_check_button_pressed(mb_right)) {
_input_text = string_real(slider_def_val);
sliding = 0;
apply();
deactivate();
UNDO_HOLDING = false;
} else {
var _s = slide_speed;
var _mdx = window_mouse_get_delta_x();
var _mdy = window_mouse_get_delta_y();
var _dx = abs(_mdx) > abs(_mdy)? _mdx : -_mdy;
if(key_mod_press(CTRL) && !slide_snap) _s *= 10;
if(key_mod_press(ALT)) _s /= 10;
slider_cur_val += _dx * _s;
if(slide_range != noone)
slider_cur_val = clamp(slider_cur_val, curr_range[0], curr_range[1]);
var _val = value_snap(slider_cur_val, _s);
if(key_mod_press(CTRL) && slide_snap) _val = value_snap(slider_cur_val, slide_snap);
if(slide_int) _val = round(_val);
if(abs(_val) < _s * 4) _val = 0;
_input_text = string_real(_val);
if(apply()) UNDO_HOLDING = true;
}
if(mouse_release(mb_left)) {
deactivate();
if(onRelease != noone) apply(onRelease);
if(onRelease != noone) apply(true);
}
}
@ -611,22 +667,6 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
deactivate();
} else {
draw_set_text(font, fa_left, fa_center);
var _display_text = _raw_text;
if(input == TEXTBOX_INPUT.number) {
var dig = floor(_w / string_width("0")) - 3;
_display_text = string_real(_display_text, dig, precision);
}
var tw = string_width(_display_text);
var th = string_height(_display_text);
switch(align) {
case fa_left : break;
case fa_center : tx -= tw / 2; break;
case fa_right : tx -= tw; break;
}
if(hover && hoverRect) {
hovering = true;
@ -655,15 +695,34 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
} else if(!hide)
draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, boxColor, 0.5 + 0.5 * interactable);
if(_update || _display_text != _disp_text) {
surface_set_shader(text_surface, noone, true, BLEND.add);
display_text(tx - tb_surf_x, _h / 2 - th / 2, _display_text, _w - ui(4));
surface_reset_shader();
}
if(drawText) {
draw_set_text(font, fa_left, fa_center);
var _display_text = _raw_text;
BLEND_ALPHA
draw_surface(text_surface, tb_surf_x, tb_surf_y);
BLEND_NORMAL
if(input == TEXTBOX_INPUT.number) {
var dig = floor(_w / string_width("0")) - 3;
_display_text = string_real(_display_text, dig, precision);
}
var tw = string_width(_display_text);
var th = string_height(_display_text);
switch(align) {
case fa_left : break;
case fa_center : tx -= tw / 2; break;
case fa_right : tx -= tw; break;
}
if(_update || _display_text != _disp_text) {
surface_set_shader(text_surface, noone, true, BLEND.add);
display_text(tx - tb_surf_x, _h / 2 - th / 2, _display_text, _w - ui(4));
surface_reset_shader();
}
BLEND_ALPHA
draw_surface(text_surface, tb_surf_x, tb_surf_y);
BLEND_NORMAL
}
}
if(DRAGGING && (DRAGGING.type == "Text" || DRAGGING.type == "Number") && hover && hoverRect) {

View file

@ -15,4 +15,15 @@ function textInput(_input, _onModify) : widget() constructor {
} #endregion
static breakCharacter = function(ch) { return ch == " " || ch == "\n"; }
static clone = function() {
var _onModify = onModify;
onModify = noone;
var cln = variable_clone(self);
cln.onModify = _onModify;
onModify = _onModify;
return cln;
}
}

View file

@ -77,4 +77,10 @@ function toggleGroup(_data, _onClick) : widget() constructor {
return h;
}
static clone = function() { #region
var cln = new toggleGroup(data, onClick);
return cln;
} #endregion
}

View file

@ -25,13 +25,13 @@ function transformBox(_onModify) : widget() constructor {
tb[i].label = labels[i];
}
static setInteract = function(interactable = noone) {
static setInteract = function(interactable = noone) { #region
self.interactable = interactable;
for( var i = 0, n = array_length(tb); i < n; i++ )
tb[i].setInteract(interactable);
rot.setInteract(interactable);
}
} #endregion
static register = function(parent = noone) {
tb[TRANSFORM.pos_x].register(parent);
@ -41,20 +41,20 @@ function transformBox(_onModify) : widget() constructor {
tb[TRANSFORM.sca_y].register(parent);
}
static isHovering = function() {
static isHovering = function() { #region
for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true;
return hovering;
}
} #endregion
static drawParam = function(params) {
static drawParam = function(params) { #region
setParam(params);
rot.setParam(params);
for(var i = 0; i < 5; i++) tb[i].setParam(params);
return draw(params.x, params.y, params.w, params.h, params.data, params.m);
}
} #endregion
static draw = function(_x, _y, _w, _h, _data, _m) {
static draw = function(_x, _y, _w, _h, _data, _m) { #region
x = _x;
y = _y;
w = _w;
@ -109,5 +109,11 @@ function transformBox(_onModify) : widget() constructor {
resetFocus();
return h;
}
} #endregion
static clone = function() { #region
var cln = new transformBox(onModify);
return cln;
} #endregion
}

View file

@ -51,6 +51,13 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
tb[i].slidable = true;
}
static apply = function() { #region
for( var i = 0; i < size; i++ ) {
tb[i].apply();
current_value[i] = toNumber(tb[i]._input_text);
}
} #endregion
static setLinkInactiveColor = function(color) { #region
link_inactive_color = color;
return self;
@ -83,10 +90,10 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
unit.triggerButton.register(parent);
} #endregion
static isHovering = function() {
static isHovering = function() { #region
for( var i = 0, n = array_length(tb); i < n; i++ ) if(tb[i].isHovering()) return true;
return false;
}
} #endregion
static drawParam = function(params) { #region
setParam(params);
@ -95,7 +102,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
return draw(params.x, params.y, params.w, params.h, params.data, params.display_data, params.m);
} #endregion
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) {
static draw = function(_x, _y, _w, _h, _data, _display_data, _m) { #region
x = _x;
y = _y;
w = _w;
@ -168,12 +175,14 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
resetFocus();
return h;
}
} #endregion
static apply = function() {
for( var i = 0; i < size; i++ ) {
tb[i].apply();
current_value[i] = toNumber(tb[i]._input_text);
}
}
static clone = function() { #region
var cln = new vectorBox(size, onModify, unit);
cln.linkable = linkable;
cln.per_line = per_line;
return cln;
} #endregion
}

View file

@ -1,5 +1,6 @@
function vectorRangeBox(_size, _type, _onModify, _unit = noone) : widget() constructor {
size = _size;
type = _type;
onModify = _onModify;
unit = _unit;
linked = false;
@ -135,4 +136,13 @@ function vectorRangeBox(_size, _type, _onModify, _unit = noone) : widget() const
return h;
} #endregion
static clone = function() { #region
var cln = new vectorRangeBox(size, type, onModify, unit);
cln.axis = axis;
cln.extras = extras;
return cln;
} #endregion
}

View file

@ -23,22 +23,22 @@ function widget() constructor {
rx = 0;
ry = 0;
static setLua = function(_lua_thread, _lua_key, _lua_func) {
static setLua = function(_lua_thread, _lua_key, _lua_func) { #region
lua_thread = _lua_thread;
lua_thread_key = _lua_key;
onModify = method(self, _lua_func);
}
} #endregion
static setInteract = function(interactable = noone) {
static setInteract = function(interactable = noone) { #region
self.interactable = interactable;
}
} #endregion
static register = function(parent = noone) {
static register = function(parent = noone) { #region
if(!interactable) return;
array_push(WIDGET_ACTIVE, self);
self.parent = parent;
}
} #endregion
static setParam = function(params) { #region
font = params.font;
@ -48,42 +48,44 @@ function widget() constructor {
static trigger = function() { }
static parentFocus = function() {
static parentFocus = function() { #region
if(parent == noone) return;
if(y < 0)
parent.scroll_y_to += abs(y) + ui(16);
else if(y + ui(16) > parent.surface_h)
parent.scroll_y_to -= abs(parent.surface_h - y) + h + ui(16);
}
} #endregion
static isHovering = function() { return hovering; }
static activate = function() {
static activate = function() { #region
if(!interactable) return;
WIDGET_CURRENT = self;
WIDGET_CURRENT_SCROLL = parent;
parentFocus();
}
} #endregion
static deactivate = function() {
static deactivate = function() { #region
if(WIDGET_CURRENT != self) return;
WIDGET_CURRENT = noone;
WIDGET_CURRENT_SCROLL = noone;
}
} #endregion
static setFocusHover = function(active = false, hover = false) {
static setFocusHover = function(active = false, hover = false) { #region
self.active = interactable && active;
self.hover = interactable && hover;
self.iactive = active;
self.ihover = hover;
}
} #endregion
static resetFocus = function() {
static resetFocus = function() { #region
active = false;
hover = false;
}
} #endregion
static clone = function() { return variable_clone(self); }
static drawParam = function(params) {}
static draw = function() {}