- [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];
var _px = _x + _pos[0] * _s;
var _py = _y + _pos[1] * _s;
_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 _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;
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;
}
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

@ -160,11 +160,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_blend = 1;
draw_blend_color = 1;
__overlay_hover = [];
__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,74 +43,74 @@ 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;
var _hov = [ 0, 0, 0, 0 ], _hovPos = 0;
if(drag_type == 1) _r = value_snap(drag_sx - (_mx - drag_mx) / _s, _snx);
else if(drag_type == 2) _t = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
else if(drag_type == 3) _l = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
else if(drag_type == 4) _b = value_snap(drag_sy - (_my - drag_my) / _s, _sny);
if(drag_type == 1) _r = value_snap(drag_sx - (_mx - drag_mx) / _s, _snx);
else if(drag_type == 2) _t = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
else if(drag_type == 3) _l = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
else if(drag_type == 4) _b = value_snap(drag_sy - (_my - drag_my) / _s, _sny);
if(drag_type) {
var _sval = array_clone(showValue());
if(unit.mode == VALUE_UNIT.reference) {
var _ref = unit.reference();
_sval[0] *= _ref[0];
_sval[1] *= _ref[1];
_sval[2] *= _ref[0];
_sval[3] *= _ref[1];
}
if(drag_type) {
var _sval = array_clone(showValue());
if(unit.mode == VALUE_UNIT.reference) {
var _ref = unit.reference();
_sval[0] *= _ref[0];
_sval[1] *= _ref[1];
_sval[2] *= _ref[0];
_sval[3] *= _ref[1];
if(drag_type == 1) _sval[0] = _r;
else if(drag_type == 2) _sval[1] = _t;
else if(drag_type == 3) _sval[2] = _l;
else if(drag_type == 4) _sval[3] = _b;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
if(drag_type == 1) _sval[0] = _r;
else if(drag_type == 2) _sval[1] = _t;
else if(drag_type == 3) _sval[2] = _l;
else if(drag_type == 4) _sval[3] = _b;
if(drawSize && point_in_circle(_mx, _my, xc, y0, 16)) {
_hov[0] = 1;
hover = 1;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_press(mb_left, active)) {
drag_type = 2;
drag_sy = _t;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, xc, y1, 16)) {
_hov[1] = 1;
hover = 3;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
if(mouse_press(mb_left, active)) {
drag_type = 4;
drag_sy = _b;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, x0, yc, 16)) {
_hov[2] = 1;
hover = 0;
if(drawSize && point_in_circle(_mx, _my, xc, y0, 16)) {
_hov[0] = 1;
hover = 1;
if(mouse_press(mb_left, active)) {
drag_type = 3;
drag_sx = _l;
drag_mx = _mx;
}
} else if(drawSize && point_in_circle(_mx, _my, x1, yc, 16)) {
_hov[3] = 1;
hover = 2;
if(mouse_press(mb_left, active)) {
drag_type = 2;
drag_sy = _t;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, xc, y1, 16)) {
_hov[1] = 1;
hover = 3;
if(mouse_press(mb_left, active)) {
drag_type = 4;
drag_sy = _b;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, x0, yc, 16)) {
_hov[2] = 1;
hover = 0;
if(mouse_press(mb_left, active)) {
drag_type = 3;
drag_sx = _l;
drag_mx = _mx;
}
} else if(drawSize && point_in_circle(_mx, _my, x1, yc, 16)) {
_hov[3] = 1;
hover = 2;
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_sx = _r;
drag_mx = _mx;
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_sx = _r;
drag_mx = _mx;
}
}
}
@ -164,102 +164,102 @@ 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;
var _hov = [ 0, 0, 0 ];
var _r = 10;
if(drag_type) {
var _sval = array_clone(showValue());
if(unit.mode == VALUE_UNIT.reference) {
var _ref = unit.reference();
_sval[0] *= _ref[0];
_sval[1] *= _ref[1];
_sval[2] *= _ref[0];
_sval[3] *= _ref[1];
if(drag_type) {
var _sval = array_clone(showValue());
if(unit.mode == VALUE_UNIT.reference) {
var _ref = unit.reference();
_sval[0] *= _ref[0];
_sval[1] *= _ref[1];
_sval[2] *= _ref[0];
_sval[3] *= _ref[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);
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);
_sval[0] = _xx;
_sval[1] = _yy;
_sval[0] = _xx;
_sval[1] = _yy;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
} else if(drag_type == 2) {
var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
var _yy = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
_sval[2] = _xx;
_sval[3] = _yy;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
} else if(drag_type == 3) {
var __x0 = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
var __y0 = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
var __x1 = value_snap(_x1 + (__x0 - _x0), _snx);
var __y1 = value_snap(_y1 + (__y0 - _y0), _sny);
_val[0] = __x0;
_val[1] = __y0;
_val[2] = __x1;
_val[3] = __y1;
if(setValueInspector(_val))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
} else if(drag_type == 2) {
var _xx = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
var _yy = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
_sval[2] = _xx;
_sval[3] = _yy;
if(drawSize && point_in_circle(_mx, _my, x0, y0, 8)) {
_hov[1] = 1;
hover = 1;
if(setValueInspector(_sval))
UNDO_HOLDING = true;
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_sx = _x0;
drag_sy = _y0;
drag_mx = _mx;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, x1, y1, 8)) {
_hov[2] = 1;
hover = 2;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
} else if(drag_type == 3) {
var __x0 = value_snap(drag_sx + (_mx - drag_mx) / _s, _snx);
var __y0 = value_snap(drag_sy + (_my - drag_my) / _s, _sny);
var __x1 = value_snap(_x1 + (__x0 - _x0), _snx);
var __y1 = value_snap(_y1 + (__y0 - _y0), _sny);
if(mouse_press(mb_left, active)) {
drag_type = 2;
drag_sx = _x1;
drag_sy = _y1;
drag_mx = _mx;
drag_my = _my;
}
} else if(drawPos && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) {
_hov[0] = 1;
hover = 3;
_val[0] = __x0;
_val[1] = __y0;
_val[2] = __x1;
_val[3] = __y1;
if(setValueInspector(_val))
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
if(drawSize && point_in_circle(_mx, _my, x0, y0, 8)) {
_hov[1] = 1;
hover = 1;
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_sx = _x0;
drag_sy = _y0;
drag_mx = _mx;
drag_my = _my;
}
} else if(drawSize && point_in_circle(_mx, _my, x1, y1, 8)) {
_hov[2] = 1;
hover = 2;
if(mouse_press(mb_left, active)) {
drag_type = 2;
drag_sx = _x1;
drag_sy = _y1;
drag_mx = _mx;
drag_my = _my;
}
} else if(drawPos && point_in_rectangle(_mx, _my, x0, y0, x1, y1)) {
_hov[0] = 1;
hover = 3;
if(mouse_press(mb_left, active)) {
drag_type = 3;
drag_sx = _x0;
drag_sy = _y0;
drag_mx = _mx;
drag_my = _my;
if(mouse_press(mb_left, active)) {
drag_type = 3;
drag_sx = _x0;
drag_sy = _y0;
drag_mx = _mx;
drag_my = _my;
}
}
}
@ -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);
draw_set_text(_f_p2b, fa_center, fa_bottom, COLORS._main_accent);
draw_text_add(round(_ax), round(_ay - 4), name);
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;
}