Connection fade modes

This commit is contained in:
Tanasart 2023-08-31 19:56:23 +02:00
parent 970513a8b3
commit d0d753e9fe
5 changed files with 28 additions and 21 deletions

View file

@ -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;

View file

@ -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)) {

View file

@ -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);

View file

@ -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"] },
],

View file

@ -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;