From d0d753e9fe7e3bf8dce70ee2b92fc5fb72b70bfb Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:56:23 +0200 Subject: [PATCH] Connection fade modes --- .../__panel_linear_setting.gml | 2 +- scripts/buttonGroup/buttonGroup.gml | 16 ++++++++++++---- scripts/node_value/node_value.gml | 19 ++++++++----------- .../panel_graph_connection_settings.gml | 10 ++++++---- scripts/preferences/preferences.gml | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/scripts/__panel_linear_setting/__panel_linear_setting.gml b/scripts/__panel_linear_setting/__panel_linear_setting.gml index 78816da94..ddffe6951 100644 --- a/scripts/__panel_linear_setting/__panel_linear_setting.gml +++ b/scripts/__panel_linear_setting/__panel_linear_setting.gml @@ -13,7 +13,7 @@ function Panel_Linear_Setting() : PanelContent() constructor { static drawSettings = function(panel) { var yy = ui(24); var th = ui(36); - var ww = ui(200); + var ww = w - ui(180); var wh = TEXTBOX_HEIGHT; var _hov = false; diff --git a/scripts/buttonGroup/buttonGroup.gml b/scripts/buttonGroup/buttonGroup.gml index a11d006ae..514e79879 100644 --- a/scripts/buttonGroup/buttonGroup.gml +++ b/scripts/buttonGroup/buttonGroup.gml @@ -13,6 +13,11 @@ function buttonGroup(_data, _onClick) : widget() constructor { sb_small = new scrollBox(data, _onClick); + static setFont = function(font) { + self.font = font; + return self; + } + static trigger = function() { if(current_selecting + 1 >= array_length(data)) onClick(0); @@ -61,15 +66,16 @@ function buttonGroup(_data, _onClick) : widget() constructor { display_button = total_width < _w; if(display_button) { + var bx = _x; + for(var i = 0; i < amo; i++) { buttons[i].setFocusHover(active, hover); - - var bx = _x + ww * i; + var spr = i == 0 ? buttonSpr[0] : (i == amo - 1? buttonSpr[2] : buttonSpr[1]); if(_selecting == i) { - draw_sprite_stretched(spr, 2, bx, _y, ww - !!i, _h); - draw_sprite_stretched_ext(spr, 3, bx, _y, ww - !!i, _h, COLORS._main_accent, 1); + draw_sprite_stretched(spr, 2, bx, _y, ww, _h); + draw_sprite_stretched_ext(spr, 3, bx, _y, ww, _h, COLORS._main_accent, 1); } else { buttons[i].draw(bx, _y, ww, _h, _m, spr); if(buttons[i].clicked) onClick(i); @@ -81,6 +87,8 @@ function buttonGroup(_data, _onClick) : widget() constructor { } else if(sprite_exists(data[i])) { draw_sprite_ui_uniform(data[i], i, bx + ww / 2, _y + _h / 2); } + + bx += ww; } if(point_in_rectangle(_m[0], _m[1], _x, _y, _x + w, _y + _h)) { diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 9d2b72364..e9cf858c7 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1737,7 +1737,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru var miny = struct_try_get(params, "miny", undefined); var maxx = struct_try_get(params, "maxx", undefined); var maxy = struct_try_get(params, "maxy", undefined); - var high = struct_try_get(params, "highlight", true); + var high = struct_try_get(params, "highlight", 0); var bg = struct_try_get(params, "bg", c_black); @@ -1818,18 +1818,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru ty = LINE_STYLE.dashed; var c0, c1; + var _high = high * PREF_MAP[? "connection_line_highlight"]; + var _selc = node.active_draw_index == 0 || value_from.node.active_draw_index == 0; - if(PREF_MAP[? "connection_line_highlight"]) { - var _colr = 1; + if(!thicken && (_high == 1 && key_mod_press(ALT) || _high == 2)) { var _fade = PREF_MAP[? "connection_line_highlight_fade"]; + var _colr = _selc? 1 : _fade; - if(high) _colr = node.active_draw_index == -1? _fade : 1; - if(thicken) _colr = 1; - - draw_line_blend = _colr == 1? 1 : lerp_float(draw_line_blend, _colr, 3); - - c0 = merge_color(bg, value_color(value_from.type), draw_line_blend); - c1 = merge_color(bg, value_color(type), draw_line_blend); + c0 = merge_color(bg, value_color(value_from.type), _colr); + c1 = merge_color(bg, value_color(type), _colr); } else { c0 = value_color(value_from.type); c1 = value_color(type); @@ -1845,7 +1842,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cy *= aa; corner *= aa; th = max(1, round(th)); - + draw_set_color(c0); var fromIndex = value_from.drawLineIndex; diff --git a/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml b/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml index dd6cd9c55..07936e5a9 100644 --- a/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml +++ b/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml @@ -1,7 +1,7 @@ function Panel_Graph_Connection_Setting() : Panel_Linear_Setting() constructor { title = __txtx("graph_connection_settings", "Connection Settings"); - w = ui(380); + w = ui(400); #region data properties = [ @@ -33,14 +33,16 @@ function Panel_Graph_Connection_Setting() : Panel_Linear_Setting() constructor { function() { return PREF_MAP[? "connection_line_aa"]; } ], [ - new checkBox(function() { - PREF_MAP[? "connection_line_highlight"] = !PREF_MAP[? "connection_line_highlight"]; + new buttonGroup([ "None", "ALT", "Always" ], function(val) { + PREF_MAP[? "connection_line_highlight"] = val; }), __txtx("pref_connection_highlight", "Highlight connection"), function() { return PREF_MAP[? "connection_line_highlight"]; } ], [ - new slider(0, 1, 0.05, function(val) { PREF_MAP[? "connection_line_highlight_fade"] = val; }), + new slider(0, 1, 0.05, function(val) { + PREF_MAP[? "connection_line_highlight_fade"] = val; + }), __txtx("pref_connection_highlight_fade", "Fade connection"), function() { return PREF_MAP[? "connection_line_highlight_fade"] }, ], diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 432578b99..b9664983f 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -28,7 +28,7 @@ PREF_MAP[? "connection_line_corner"] = 8; PREF_MAP[? "connection_line_aa"] = 2; PREF_MAP[? "connection_line_transition"] = true; - PREF_MAP[? "connection_line_highlight"] = false; + PREF_MAP[? "connection_line_highlight"] = 0; PREF_MAP[? "connection_line_highlight_fade"] = 0.75; PREF_MAP[? "curve_connection_line"] = 1;