mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 22:46:19 +01:00
pin
This commit is contained in:
parent
7dbb693687
commit
2fc80b0060
6 changed files with 4794 additions and 31 deletions
|
@ -1,4 +1,4 @@
|
|||
// 2024-04-21 17:06:08
|
||||
// 2024-04-21 20:02:06
|
||||
function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Pin";
|
||||
w = 32;
|
||||
|
@ -57,34 +57,32 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
|
||||
|
||||
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
|
||||
isHovering = false;
|
||||
var hover = noone;
|
||||
|
||||
var _dval = PANEL_GRAPH.value_dragging;
|
||||
var hover = _dval == noone || _dval.connect_type == JUNCTION_CONNECT.input? outputs[| 0] : inputs[| 0];
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
var hov = PANEL_GRAPH.value_dragging;
|
||||
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
|
||||
|
||||
if(hov == noone && point_in_circle(_mx, _my, xx, yy, _s * 24)) {
|
||||
isHovering = true;
|
||||
hover_scale_to = 1;
|
||||
}
|
||||
hover.drawJunction(_s, _mx, _my);
|
||||
|
||||
if(outputs[| 0].drawJunction(_s, _mx, _my))
|
||||
hover = outputs[| 0];
|
||||
if(!isHovering) return noone;
|
||||
|
||||
hover_scale_to = 1;
|
||||
return hover;
|
||||
} #endregion
|
||||
|
||||
static drawNode = function(_x, _y, _mx, _my, _s) { #region
|
||||
if(group != PANEL_GRAPH.getCurrentContext()) return;
|
||||
// if(group != PANEL_GRAPH.getCurrentContext()) return;
|
||||
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
|
||||
hover_alpha = 0.5;
|
||||
if(active_draw_index > -1) {
|
||||
hover_alpha = 1;
|
||||
hover_scale_to = 1;
|
||||
active_draw_index = -1;
|
||||
hover_alpha = 1;
|
||||
hover_scale_to = 1;
|
||||
active_draw_index = -1;
|
||||
}
|
||||
|
||||
if(hover_scale > 0) {
|
||||
|
|
105
#backups/scripts/node_pin/node_pin.gml.backup1
Normal file
105
#backups/scripts/node_pin/node_pin.gml.backup1
Normal file
|
@ -0,0 +1,105 @@
|
|||
// 2024-04-21 19:59:15
|
||||
function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||
name = "Pin";
|
||||
w = 32;
|
||||
h = 32;
|
||||
|
||||
auto_height = false;
|
||||
junction_shift_y = 16;
|
||||
|
||||
isHovering = false;
|
||||
hover_scale = 0;
|
||||
hover_scale_to = 0;
|
||||
hover_alpha = 0;
|
||||
|
||||
bg_spr = THEME.node_pin_bg;
|
||||
bg_sel_spr = THEME.node_pin_bg_active;
|
||||
|
||||
inputs[| 0] = nodeValue("In", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, 0 )
|
||||
.setVisible(true, true);
|
||||
|
||||
outputs[| 0] = nodeValue("Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0);
|
||||
|
||||
static step = function() { #region
|
||||
if(inputs[| 0].isLeaf()) return;
|
||||
|
||||
inputs[| 0].setType(inputs[| 0].value_from.type);
|
||||
outputs[| 0].setType(inputs[| 0].value_from.type);
|
||||
|
||||
inputs[| 0].color_display = inputs[| 0].value_from.color_display;
|
||||
outputs[| 0].color_display = inputs[| 0].color_display;
|
||||
} #endregion
|
||||
|
||||
static update = function() { #region
|
||||
var _val = getInputData(0);
|
||||
outputs[| 0].setValue(_val);
|
||||
} #endregion
|
||||
|
||||
static pointIn = function(_x, _y, _mx, _my, _s) { #region
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
|
||||
return point_in_circle(_mx, _my, xx, yy, _s * 24);
|
||||
} #endregion
|
||||
|
||||
static preDraw = function(_x, _y, _s) { #region
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
|
||||
inputs[| 0].x = xx;
|
||||
inputs[| 0].y = yy;
|
||||
|
||||
outputs[| 0].x = xx;
|
||||
outputs[| 0].y = yy;
|
||||
} #endregion
|
||||
|
||||
static drawBadge = function(_x, _y, _s) {}
|
||||
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
|
||||
|
||||
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
|
||||
|
||||
var _dval = PANEL_GRAPH.value_dragging;
|
||||
var hover = _dval == noone || _dval.connect_type == JUNCTION_CONNECT.input? outputs[| 0] : inputs[| 0];
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
|
||||
|
||||
hover.drawJunction(_s, _mx, _my);
|
||||
|
||||
if(!isHovering) return noone;
|
||||
|
||||
hover_scale_to = 1;
|
||||
return hover;
|
||||
} #endregion
|
||||
|
||||
static drawNode = function(_x, _y, _mx, _my, _s) { #region
|
||||
// if(group != PANEL_GRAPH.getCurrentContext()) return;
|
||||
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
|
||||
hover_alpha = 0.5;
|
||||
if(active_draw_index > -1) {
|
||||
hover_alpha = 1;
|
||||
hover_scale_to = 1;
|
||||
active_draw_index = -1;
|
||||
}
|
||||
|
||||
if(hover_scale > 0) {
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_set_alpha(hover_alpha);
|
||||
draw_circle_border(xx, yy, _s * hover_scale * 20, 2);
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
|
||||
hover_scale = lerp_float(hover_scale, hover_scale_to, 3);
|
||||
hover_scale_to = 0;
|
||||
|
||||
if(renamed && display_name != "" && display_name != "Pin") {
|
||||
draw_set_text(f_p0, fa_center, fa_bottom, COLORS._main_text);
|
||||
draw_text_transformed(xx, yy - 12, display_name, _s, _s, 0);
|
||||
}
|
||||
|
||||
return drawJunctions(_x, _y, _mx, _my, _s);
|
||||
} #endregion
|
||||
}
|
2331
#backups/scripts/panel_graph/panel_graph.gml.backup0
Normal file
2331
#backups/scripts/panel_graph/panel_graph.gml.backup0
Normal file
File diff suppressed because it is too large
Load diff
2332
#backups/scripts/panel_graph/panel_graph.gml.backup1
Normal file
2332
#backups/scripts/panel_graph/panel_graph.gml.backup1
Normal file
File diff suppressed because it is too large
Load diff
|
@ -56,34 +56,32 @@ function Node_Pin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
static drawJunctionNames = function(_x, _y, _mx, _my, _s) {}
|
||||
|
||||
static drawJunctions = function(_x, _y, _mx, _my, _s) { #region
|
||||
isHovering = false;
|
||||
var hover = noone;
|
||||
|
||||
var _dval = PANEL_GRAPH.value_dragging;
|
||||
var hover = _dval == noone || _dval.connect_type == JUNCTION_CONNECT.input? outputs[| 0] : inputs[| 0];
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
var hov = PANEL_GRAPH.value_dragging;
|
||||
isHovering = point_in_circle(_mx, _my, xx, yy, _s * 24);
|
||||
|
||||
if(hov == noone && point_in_circle(_mx, _my, xx, yy, _s * 24)) {
|
||||
isHovering = true;
|
||||
hover_scale_to = 1;
|
||||
}
|
||||
hover.drawJunction(_s, _mx, _my);
|
||||
|
||||
if(outputs[| 0].drawJunction(_s, _mx, _my))
|
||||
hover = outputs[| 0];
|
||||
if(!isHovering) return noone;
|
||||
|
||||
hover_scale_to = 1;
|
||||
return hover;
|
||||
} #endregion
|
||||
|
||||
static drawNode = function(_x, _y, _mx, _my, _s) { #region
|
||||
if(group != PANEL_GRAPH.getCurrentContext()) return;
|
||||
// if(group != PANEL_GRAPH.getCurrentContext()) return;
|
||||
|
||||
var xx = x * _s + _x;
|
||||
var yy = y * _s + _y;
|
||||
|
||||
hover_alpha = 0.5;
|
||||
if(active_draw_index > -1) {
|
||||
hover_alpha = 1;
|
||||
hover_scale_to = 1;
|
||||
active_draw_index = -1;
|
||||
hover_alpha = 1;
|
||||
hover_scale_to = 1;
|
||||
active_draw_index = -1;
|
||||
}
|
||||
|
||||
if(hover_scale > 0) {
|
||||
|
|
|
@ -157,7 +157,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
#endregion
|
||||
|
||||
#region ---- position ----
|
||||
scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.5, 0.65, 0.8, 1, 1.2, 1.35, 1.5, 2.0];
|
||||
scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.50, 0.65, 0.80, 1, 1.2, 1.35, 1.5, 2.0];
|
||||
graph_s = 1;
|
||||
graph_s_to = graph_s;
|
||||
|
||||
|
@ -1182,7 +1182,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
draw_surface(connection_surface_aa, 0, 0);
|
||||
BLEND_NORMAL
|
||||
|
||||
junction_hovering = (node_hovering == noone && !is_struct(node_hovering))? hov : noone;
|
||||
junction_hovering = node_hovering == noone? hov : noone;
|
||||
value_focus = noone;
|
||||
#endregion
|
||||
printIf(log, $"Draw connection: {get_timer() - t}"); t = get_timer();
|
||||
|
@ -1200,8 +1200,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
|
|||
var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter);
|
||||
if(val) {
|
||||
value_focus = val;
|
||||
if(key_mod_press(SHIFT))
|
||||
TOOLTIP = [ val.getValue(), val.type ];
|
||||
if(key_mod_press(SHIFT)) TOOLTIP = [ val.getValue(), val.type ];
|
||||
}
|
||||
} catch(e) {
|
||||
log_warning("NODE DRAW", exception_print(e));
|
||||
|
|
Loading…
Reference in a new issue