- [Animation Panel] Graph view for separated axis can now be toggled separately.

This commit is contained in:
Tanasart 2024-07-07 11:07:42 +07:00
parent 9f5a76f89a
commit c54e918ff4
6 changed files with 258 additions and 190 deletions

View file

@ -5,7 +5,7 @@ function draw_arc(_x, _y, _r, _as, _at, _th = 1, _pr = 32) {
var sgn = sign(ad);
var ar = abs(ad) / 360 * _pr;
for( var i = 0; i < ar; i++ ) {
for( var i = 0; i <= ar; i++ ) {
var a = _as + ast * i * sgn;
nx = _x + lengthdir_x(_r, a);

View file

@ -80,6 +80,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[| 9] = nodeValue("Corner radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 0.5, 0.001] });
inputs[| 9].overlay_draw_text = false;
inputs[| 10] = nodeValue("Shape color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
@ -150,7 +151,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
attribute_surface_depth();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
PROCESSOR_OVERLAY_CHECK
var _hov = false;
@ -174,28 +175,76 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
}
var _type = current_data[15];
var _pos = [ 0, 0 ];
var _sca = [ 1, 1 ];
var _px, _py;
var hv;
var _hov = false;
var _int = hover;
if(_type == 0) {
var hv = inputs[| 3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
_pos = [ current_data[3][0], current_data[3][1] ];
_sca = [ current_data[3][2], current_data[3][3] ];
} else if(_type == 1) {
var _pos = current_data[16];
_pos = current_data[16];
_sca = current_data[17];
}
if(_type != 2) {
if(inputs[| 9].show_in_inspector) {
var _px = _x + _pos[0] * _s;
var _py = _y + _pos[1] * _s;
var hv = inputs[| 16].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
var hv = inputs[| 17].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny); _hov |= hv;
var _x0 = _px - _sca[0] * _s;
var _y0 = _py - _sca[1] * _s;
var _x1 = _px + _sca[0] * _s;
var _y1 = _py + _sca[1] * _s;
var aa = -45;
var ar = 90;
if(_sca[0] < 0 && _sca[1] < 0) { aa = 135; ar = -90; }
else if(_sca[0] < 0 && _sca[1] > 0) { aa = -135; ar = 0; }
else if(_sca[0] > 0 && _sca[1] < 0) { aa = 45; ar = 180; }
var _max_s = max(abs(_sca[0]), abs(_sca[1]));
var _corr = current_data[9] * _s * _max_s;
var _cor = _corr / (sqrt(2) - 1);
var cx = _x0 + lengthdir_x(_cor, aa);
var cy = _y0 + lengthdir_y(_cor, aa);
draw_set_color(COLORS._main_accent);
draw_arc(cx, cy, _cor - _corr, ar, ar + 90, 2);
hv = inputs[| 9].drawOverlay(_int, active, _x0, _y0, _s, _mx, _my, _snx, _sny, aa, _max_s); _hov |= hv; _int &= !_hov;
}
}
if(_type == 0) {
hv = inputs[| 3].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
} else if(_type == 1) {
_px = _x + _pos[0] * _s;
_py = _y + _pos[1] * _s;
hv = inputs[| 16].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
hv = inputs[| 17].drawOverlay(_int, active, _px, _py, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
}
return _hov;
} #endregion
}
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
var _dim = _data[0];
var _bg = _data[1];
var _shape = _data[2];
var _aa = _data[6];
var _corner = _data[9];
var _corner = _data[9]; _corner = clamp(_corner, 0, .9);
var _color = _data[10];
var _df = _data[12];
var _path = _data[14];
@ -248,7 +297,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
use_path = _path != noone && struct_has(_path, "getPointRatio");
if(use_path) { #region
if(use_path) {
inputs[| 3].setVisible(false);
inputs[| 4].setVisible(false);
inputs[| 5].setVisible(false);
@ -293,7 +342,7 @@ function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
surface_reset_target();
return _outSurf;
} #endregion
}
surface_set_shader(_outSurf, sh_shape);
if(_bg) draw_clear_alpha(0, 1);

View file

@ -161,10 +161,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_blend_color = 1;
__overlay_hover = [];
overlay_draw_text = true;
#endregion
#region ---- timeline ----
show_graph = false;
show_graphs = array_create(array_safe_length(_value));
graph_h = ui(96);
#endregion
@ -1759,33 +1761,34 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
switch(display_type) {
case VALUE_DISPLAY._default :
case VALUE_DISPLAY.slider :
var _angle = argument_count > arc + 0? argument[arc + 0] : 0;
var _scale = argument_count > arc + 1? argument[arc + 1] : 1;
var _spr = argument_count > arc + 2? argument[arc + 2] : 0;
return preview_overlay_scalar(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _angle, _scale, _spr);
return preview_overlay_scalar(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _angle, _scale, _spr);
case VALUE_DISPLAY.rotation :
var _rad = argument_count > arc + 0? argument[ arc + 0] : 64;
return preview_overlay_rotation(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _rad);
return preview_overlay_rotation(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _rad);
case VALUE_DISPLAY.vector :
var _typ = argument_count > arc + 0? argument[arc + 0] : 0;
var _sca = argument_count > arc + 1? argument[arc + 1] : 1;
return preview_overlay_vector(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _typ);
return preview_overlay_vector(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _typ);
case VALUE_DISPLAY.gradient_range :
var _dim = argument[arc];
if(mappedJunc.attributes.mapped)
return preview_overlay_gradient_range(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _dim);
return preview_overlay_gradient_range(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _dim);
break;
case VALUE_DISPLAY.area :
var _flag = argument_count > arc + 0? argument[arc + 0] : 0b0011;
return preview_overlay_area(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, struct_try_get(display_data, "onSurfaceSize"));
return preview_overlay_area(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag, struct_try_get(display_data, "onSurfaceSize"));
case VALUE_DISPLAY.puppet_control :
return preview_overlay_puppet(value_from == noone, active, _x, _y, _s, _mx, _my, _snx, _sny);
return preview_overlay_puppet(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
}
return -1;

View file

@ -1224,6 +1224,8 @@ function Panel_Animation() : PanelContent() constructor {
var _max = -999999;
for( var i = 0, n = array_length(prop.animators); i < n; i++ ) {
if(!prop.show_graphs[i]) continue;
var animator = prop.animators[i];
for(var k = 0; k < ds_list_size(animator.values); k++) {
var key_val = animator.values[| k].value;
@ -1239,8 +1241,11 @@ function Panel_Animation() : PanelContent() constructor {
}
}
for( var i = 0, n = array_length(prop.animators); i < n; i++ )
for( var i = 0, n = array_length(prop.animators); i < n; i++ ) {
if(!prop.show_graphs[i]) continue;
__drawDopesheetGraphLine(prop.animators[i], 0, _mmx, _mmy, _min, _max);
}
} else
__drawDopesheetGraphLine(prop.animator, 0, _mmx, _mmy);
surface_reset_target();
@ -1492,7 +1497,9 @@ function Panel_Animation() : PanelContent() constructor {
draw_rectangle(_tool_x0, ty - ui(8), _tool_x1, ty + ui(8), false);
BLEND_NORMAL
if(prop.show_graph) {
var _graph_show = prop.sep_axis? prop.show_graphs[animator.index] : prop.show_graph;
if(_graph_show) {
var _y1 = ty + ui(10) + prop.graph_h + ui(8);
var c1 = colorMultiply(_item.item.color_cur, COLORS.panel_animation_dope_key_bg_hover);
draw_set_color(c1);
@ -1554,10 +1561,12 @@ function Panel_Animation() : PanelContent() constructor {
draw_sprite_ui_uniform(THEME.timeline_graph, 1, tx, ty, 1, COLORS._main_icon_on_inner, _tool_a);
TOOLTIP = __txtx("panel_animation_show_graph", "Show graph");
if(mouse_press(mb_left, pFOCUS))
prop.show_graph = !prop.show_graph;
if(mouse_press(mb_left, pFOCUS)) {
if(prop.sep_axis) prop.show_graphs[animator.index] = !_graph_show;
else prop.show_graph = !_graph_show;
}
} else
draw_sprite_ui_uniform(THEME.timeline_graph, 1, tx, ty, 1, prop.show_graph? COLORS._main_accent : COLORS._main_icon, prop.show_graph? 1 : _tool_a);
draw_sprite_ui_uniform(THEME.timeline_graph, 1, tx, ty, 1, _graph_show? COLORS._main_accent : COLORS._main_icon, _graph_show? 1 : _tool_a);
}
tx = tool_width - ui(20 + 16 * 4.5);
@ -1847,7 +1856,9 @@ function Panel_Animation() : PanelContent() constructor {
_cont.h += ui(18);
}
if(_prop.show_graph && _prop.type != VALUE_TYPE.color) {
var _graph_show = _prop.sep_axis? array_any(_prop.show_graphs, function(v) /*=>*/ {return v == true}) : _prop.show_graph;
if(_graph_show && _prop.type != VALUE_TYPE.color) {
if(_cont.item.color_cur > -1) {
draw_set_color(c1);
draw_rectangle(0, key_y - ui(10), bar_show_w, key_y + _prop.graph_h - ui(2), false);
@ -1905,8 +1916,10 @@ function Panel_Animation() : PanelContent() constructor {
var _dy = prop.y;
var _prop = prop.prop;
if(isGraphable(_prop) && _prop.show_graph)
_drawDopesheetGraph(_prop, _dy, msx, msy);
if(isGraphable(_prop)) {
var _graph_show = _prop.sep_axis? array_any(_prop.show_graphs, function(v) /*=>*/ {return v == true}) : _prop.show_graph;
if(_graph_show) _drawDopesheetGraph(_prop, _dy, msx, msy);
}
for( var k = 0; k < array_length(prop.animators); k++ ) {
var key = _drawDopesheetAnimatorKeysBG(prop.animators[k], msx, msy);

View file

@ -43,8 +43,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
}
}
if(!interact) return -1;
if(interact) {
var _hov = [ 0, 0, 0, 0 ], _hovPos = 0;
if(drag_type == 1) _r = value_snap(drag_sx - (_mx - drag_mx) / _s, _snx);
@ -113,6 +112,7 @@ function preview_overlay_area_padding(interact, active, _x, _y, _s, _mx, _my, _s
drag_mx = _mx;
}
}
}
for( var i = 0; i < 4; i++ )
__overlay_hover[i] = lerp_float(__overlay_hover[i], _hov[i], 4);
@ -164,8 +164,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my,
}
}
if(!interact) return -1;
if(interact) {
var _hov = [ 0, 0, 0 ];
var _r = 10;
@ -262,6 +261,7 @@ function preview_overlay_area_two_point(interact, active, _x, _y, _s, _mx, _my,
drag_my = _my;
}
}
}
for( var i = 0; i < 3; i++ )
__overlay_hover[i] = lerp_float(__overlay_hover[i], _hov[i], 4);
@ -305,8 +305,6 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx,
}
}
if(!interact) return -1;
var _hov = [ 0, 0 ];
var _r = 10;
@ -321,6 +319,8 @@ function preview_overlay_area_span(interact, active, _x, _y, _s, _mx, _my, _snx,
if((drag_type == 0 || drag_type == 1) && drawPos) draw_anchor_cross(__overlay_hover[0], _ax, _ay, _r + 4);
if((drag_type == 0 || drag_type == 2) && drawSize) draw_anchor(__overlay_hover[1], _ax + _aw, _ay + _ah, _r);
if(!interact) return -1;
if(drag_type == 1) {
var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
var _yy = value_snap(drag_sy + (_my - drag_my) / _s, _sny);

View file

@ -13,7 +13,8 @@ function preview_overlay_scalar(interact, active, _x, _y, _s, _mx, _my, _snx, _s
if(drag_type) {
index = 1;
var dist = point_distance(_mx, _my, _x, _y) / _s / _scale;
var dist = point_distance(_mx, _my, _x, _y) / (_s * _scale);
if(key_mod_press(CTRL))
dist = round(dist);
@ -43,8 +44,10 @@ function preview_overlay_scalar(interact, active, _x, _y, _s, _mx, _my, _snx, _s
__overlay_hover[0] = lerp_float(__overlay_hover[0], index, 4);
draw_anchor(__overlay_hover[0], _ax, _ay, _r, _type);
if(overlay_draw_text) {
draw_set_text(_f_p2b, fa_center, fa_bottom, COLORS._main_accent);
draw_text_add(round(_ax), round(_ay - 4), name);
}
return hover;
}