animation panel improvements

This commit is contained in:
Tanasart 2025-02-20 16:03:46 +07:00
parent 9bd16da859
commit a15d9678ae
8 changed files with 447 additions and 514 deletions

Binary file not shown.

View file

@ -21,7 +21,7 @@ function __PaletteColor(_color = c_black) constructor {
index_selecting = [ 0, 0 ];
index_dragging = noone;
interactable = true;
drop_target = noone;
drop_target = noone; setDrop = function(d) /*=>*/ { drop_target = d; return self; }
mouse_interact = false;

View file

@ -60,7 +60,7 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group)
lst -= 1;
if(CURRENT_FRAME < str) return;
if(CURRENT_FRAME > lst) return;
if(CURRENT_FRAME >= lst) return;
cacheCurrentFrame(getInputData(0));

View file

@ -184,10 +184,10 @@
ds_map_clear(APPEND_MAP);
}
function graphFocusNode(node) {
function graphFocusNode(node, _moveView = true) {
PANEL_INSPECTOR.setInspecting(node);
PANEL_GRAPH.nodes_selecting = [ node ];
PANEL_GRAPH.fullView();
if(_moveView) PANEL_GRAPH.fullView();
}
function refreshNodeMap() {

View file

@ -61,9 +61,7 @@ function Node_MK_Delay_Machine(_x, _y, _group = noone) : Node(_x, _y, _group) co
var cc, aa;
var _psiz = array_length(_pal) - 1;
surface_set_target(_outSurf);
DRAW_CLEAR
surface_set_shader(_outSurf, sh_sample);
switch(_blnd) {
case 0 : BLEND_NORMAL break;
case 1 : BLEND_ALPHA break;
@ -89,8 +87,7 @@ function Node_MK_Delay_Machine(_x, _y, _group = noone) : Node(_x, _y, _group) co
draw_surface_ext(_s, 0, 0, 1, 1, 0, cc, aa);
}
BLEND_NORMAL
surface_reset_target();
surface_reset_shader();
outputs[0].setValue(_outSurf);
}

View file

@ -546,7 +546,7 @@ function typeIncompatible(from, to) {
function isGraphable(prop) {
INLINE
if(prop.type == VALUE_TYPE.integer || prop.type == VALUE_TYPE.float) {
if(prop.type == VALUE_TYPE.integer || prop.type == VALUE_TYPE.float || prop.type == VALUE_TYPE.boolean) {
if(prop.display_type == VALUE_DISPLAY.puppet_control)
return false;
return true;

View file

@ -39,10 +39,10 @@
registerFunction("", "Play/Pause", vk_space, MOD_KEY.none, panel_animation_play_pause ).setMenu("play_pause", )
registerFunction("", "Resume/Pause", vk_space, MOD_KEY.shift, panel_animation_resume ).setMenu("resume_pause", )
registerFunction("", "First frame", vk_home, MOD_KEY.none, panel_animation_first_frame ).setMenu("first_frame", )
registerFunction("", "Last frame", vk_end, MOD_KEY.none, panel_animation_last_frame ).setMenu("last_frame", )
registerFunction("", "Next frame", vk_right, MOD_KEY.none, panel_animation_next_frame ).setMenu("next_frame", )
registerFunction("", "Previous frame", vk_left, MOD_KEY.none, panel_animation_prev_frame ).setMenu("previous_frame", )
registerFunction("", "First Frame", vk_home, MOD_KEY.none, panel_animation_first_frame ).setMenu("first_frame", )
registerFunction("", "Last Frame", vk_end, MOD_KEY.none, panel_animation_last_frame ).setMenu("last_frame", )
registerFunction("", "Next Frame", vk_right, MOD_KEY.none, panel_animation_next_frame ).setMenu("next_frame", )
registerFunction("", "Previous Frame", vk_left, MOD_KEY.none, panel_animation_prev_frame ).setMenu("previous_frame", )
registerFunction("Animation", "Delete keys", vk_delete, MOD_KEY.none, panel_animation_delete_key ).setMenu("animation_delete_keys", )
registerFunction("Animation", "Duplicate", "D", MOD_KEY.ctrl, panel_animation_duplicate ).setMenu("animation_duplicate", THEME.duplicate)
@ -76,75 +76,23 @@
}
function __fnGroupInit_Animation() {
var s = THEME.timeline_ease;
var t = "panel_animation_ease";
MENU_ITEMS.animation_group_ease_in = menuItemGroup(__txtx("panel_animation_ease_in", "Ease in"), [
[ [THEME.timeline_ease, 0], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.linear;
k.ease_in = [0, 1];
}
}, __txtx("panel_animation_ease_linear", "Linear") ],
[ [THEME.timeline_ease, 1], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.bezier;
k.ease_in = [1, 1];
}
}, __txtx("panel_animation_ease_smooth", "Smooth") ],
[ [THEME.timeline_ease, 2], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.bezier;
k.ease_in = [1, 2];
}
}, __txtx("panel_animation_ease_overshoot", "Overshoot") ],
[ [THEME.timeline_ease, 3], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.bezier;
k.ease_in = [0, 0];
}
}, __txtx("panel_animation_ease_sharp", "Sharp") ],
[ [THEME.timeline_ease, 4], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_in_type = CURVE_TYPE.cut;
k.ease_in = [0, 0];
}
}, __txtx("panel_animation_ease_hold", "Hold") ],
MENU_ITEMS.animation_group_ease_in = menuItemGroup(__txtx($"{t}_in", "Ease in"), [
[ [s,0], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_in_type = CURVE_TYPE.linear; k.ease_in = [0, 1]; }) }, __txtx($"{t}_linear", "Linear") ],
[ [s,1], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_in_type = CURVE_TYPE.bezier; k.ease_in = [1, 1]; }) }, __txtx($"{t}_smooth", "Smooth") ],
[ [s,2], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_in_type = CURVE_TYPE.bezier; k.ease_in = [1, 2]; }) }, __txtx($"{t}_overshoot", "Overshoot") ],
[ [s,3], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_in_type = CURVE_TYPE.bezier; k.ease_in = [0, 0]; }) }, __txtx($"{t}_sharp", "Sharp") ],
[ [s,4], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_in_type = CURVE_TYPE.cut; k.ease_in = [0, 0]; }) }, __txtx($"{t}_hold", "Hold") ],
], [ "Animation", "Ease In" ]);
registerFunction("Animation", "Ease In", "", MOD_KEY.none, function() /*=>*/ { menuCall("", [ MENU_ITEMS.animation_group_ease_in ]); });
MENU_ITEMS.animation_group_ease_out = menuItemGroup(__txtx("panel_animation_ease_out", "Ease out"), [
[ [THEME.timeline_ease, 0], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_out_type = CURVE_TYPE.linear;
k.ease_out = [0, 0];
}
}, __txtx("panel_animation_ease_linear", "Linear") ],
[ [THEME.timeline_ease, 1], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_out_type = CURVE_TYPE.bezier;
k.ease_out = [1, 0];
}
}, __txtx("panel_animation_ease_smooth", "Smooth") ],
[ [THEME.timeline_ease, 2], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_out_type = CURVE_TYPE.bezier;
k.ease_out = [1, -1];
}
}, __txtx("panel_animation_ease_overshoot", "Overshoot") ],
[ [THEME.timeline_ease, 3], function() /*=>*/ {
for( var i = 0, n = array_length(PANEL_ANIMATION.keyframe_selecting); i < n; i++ ) {
var k = PANEL_ANIMATION.keyframe_selecting[i];
k.ease_out_type = CURVE_TYPE.bezier;
k.ease_out = [0, 1];
}
}, __txtx("panel_animation_ease_sharp", "Sharp") ],
MENU_ITEMS.animation_group_ease_out = menuItemGroup(__txtx($"{t}_out", "Ease out"), [
[ [s,0], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_out_type = CURVE_TYPE.linear; k.ease_out = [0, 0]; }) }, __txtx($"{t}_linear", "Linear") ],
[ [s,1], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_out_type = CURVE_TYPE.bezier; k.ease_out = [1, 0]; }) }, __txtx($"{t}_smooth", "Smooth") ],
[ [s,2], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_out_type = CURVE_TYPE.bezier; k.ease_out = [1,-1]; }) }, __txtx($"{t}_overshoot", "Overshoot") ],
[ [s,3], function() /*=>*/ { array_foreach(PANEL_ANIMATION.keyframe_selecting, function(k) /*=>*/ { k.ease_out_type = CURVE_TYPE.bezier; k.ease_out = [0, 1]; }) }, __txtx($"{t}_sharp", "Sharp") ],
], [ "Animation", "Ease Outs" ]);
registerFunction("Animation", "Ease Out", "", MOD_KEY.none, function() /*=>*/ { menuCall("", [ MENU_ITEMS.animation_group_ease_out ]); });
@ -158,12 +106,8 @@
var _clrs = COLORS.labels;
var _item = array_create(array_length(_clrs));
for( var i = 0, n = array_length(_clrs); i < n; i++ ) {
_item[i] = [
[ THEME.timeline_color, i > 0, _clrs[i] ],
function(_data) { PANEL_ANIMATION.setSelectingItemColor(_data.color); }, "", { color: i == 0? -1 : _clrs[i] }
];
}
for( var i = 0, n = array_length(_clrs); i < n; i++ )
_item[i] = [ [ THEME.timeline_color, i > 0, _clrs[i] ], function(_data) /*=>*/ { PANEL_ANIMATION.setSelectingItemColor(_data.color); }, "", { color: i == 0? -1 : _clrs[i] } ];
array_push(_item, [
[ THEME.timeline_color, 2 ],
@ -327,6 +271,7 @@ function Panel_Animation() : PanelContent() constructor {
onion_dragging = noone;
prev_cache = array_create(TOTAL_FRAMES);
copy_clipboard = ds_list_create();
__keyframe_editing = noone;
__collapse = false;
function collapseToggle() {
@ -337,50 +282,50 @@ function Panel_Animation() : PanelContent() constructor {
}
#region ++++ control_buttons ++++
tooltip_toggle_nodes = new tooltipHotkey(__txtx("panel_animation_show_node", "Toggle node label"), "Animation", "Toggle nodes");
tooltip_toggle_nodes = new tooltipHotkey(__txtx("panel_animation_show_node", "Toggle node label"), "Animation", "Toggle Nodes");
tooltip_resume = new tooltipHotkey(__txt("Resume"), "", "Resume/Pause");
tooltip_pause = new tooltipHotkey(__txt("Pause"), "", "Resume/Pause");
tooltip_fr_first = new tooltipHotkey(__txtx("panel_animation_go_to_first_frame", "Go to first frame"), "", "First frame");
tooltip_fr_last = new tooltipHotkey(__txtx("panel_animation_go_to_last_frame", "Go to last frame"), "", "Last frame");
tooltip_fr_prev = new tooltipHotkey(__txtx("panel_animation_previous_frame", "Previous frame"), "", "Previous frame");
tooltip_fr_next = new tooltipHotkey(__txtx("panel_animation_next_frame", "Next frame"), "", "Next frame");
tooltip_fr_first = new tooltipHotkey(__txtx("panel_animation_go_to_first_frame", "Go to first frame"), "", "First Frame");
tooltip_fr_last = new tooltipHotkey(__txtx("panel_animation_go_to_last_frame", "Go to last frame"), "", "Last Frame");
tooltip_fr_prev = new tooltipHotkey(__txtx("panel_animation_previous_frame", "Previous frame"), "", "Previous Frame");
tooltip_fr_next = new tooltipHotkey(__txtx("panel_animation_next_frame", "Next frame"), "", "Next Frame");
control_buttons = [
[
function() { return __txt("Stop"); },
function() { return 4; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { PROJECT.animator.stop(); }
function() /*=>*/ {return __txt("Stop")},
function() /*=>*/ {return 4},
function() /*=>*/ {return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon},
function() /*=>*/ { PROJECT.animator.stop(); }
],
[
function() { return PROJECT.animator.is_playing? tooltip_pause : tooltip_resume; },
function() { return !PROJECT.animator.is_playing; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
function() /*=>*/ {return PROJECT.animator.is_playing? tooltip_pause : tooltip_resume},
function() /*=>*/ {return !PROJECT.animator.is_playing},
function() /*=>*/ {return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon},
function() /*=>*/ { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
],
[
function() { return tooltip_fr_first; },
function() { return 3; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.firstFrame(); }
function() /*=>*/ {return tooltip_fr_first},
function() /*=>*/ {return 3},
function() /*=>*/ {return COLORS._main_icon},
function() /*=>*/ { PROJECT.animator.firstFrame(); }
],
[
function() { return tooltip_fr_last; },
function() { return 2; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.lastFrame(); }
function() /*=>*/ {return tooltip_fr_last},
function() /*=>*/ {return 2},
function() /*=>*/ {return COLORS._main_icon},
function() /*=>*/ { PROJECT.animator.lastFrame(); }
],
[
function() { return tooltip_fr_prev; },
function() { return 5; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
function() /*=>*/ {return tooltip_fr_prev},
function() /*=>*/ {return 5},
function() /*=>*/ {return COLORS._main_icon},
function() /*=>*/ { PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
],
[
function() { return tooltip_fr_next; },
function() { return 6; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
function() /*=>*/ {return tooltip_fr_next},
function() /*=>*/ {return 6},
function() /*=>*/ {return COLORS._main_icon},
function() /*=>*/ { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
],
];
#endregion
@ -389,13 +334,7 @@ function Panel_Animation() : PanelContent() constructor {
#region actions
function edit_keyframe_value() { if(array_empty(keyframe_selecting)) return; editKeyFrame(keyframe_selecting[0]); }
function edit_keyframe_lock_y() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.ease_y_lock = !k.ease_y_lock;
}
}
function edit_keyframe_lock_y() { array_foreach(keyframe_selecting, function(k) /*=>*/ { k.ease_y_lock = !k.ease_y_lock; }); }
function edit_keyframe_stagger() { stagger_mode = 1; }
function edit_keyframe_driver() { dialogPanelCall(new Panel_Keyframe_Driver(keyframe_selecting[0]), mouse_mx + ui(8), mouse_my + ui(8)); }
@ -416,7 +355,6 @@ function Panel_Animation() : PanelContent() constructor {
#endregion
keyframe_menu = [
MENU_ITEMS.animation_edit_keyframe_value,
MENU_ITEMS.animation_lock_keyframe_y,
@ -438,9 +376,6 @@ function Panel_Animation() : PanelContent() constructor {
MENU_ITEMS.animation_paste,
];
context_selecting_item = noone;
context_selecting_prop = noone;
name_menu_empty = [
MENU_ITEMS.animation_new_folder,
-1,
@ -448,6 +383,9 @@ function Panel_Animation() : PanelContent() constructor {
MENU_ITEMS.animation_dopesheet_collapse,
];
context_selecting_item = noone;
context_selecting_prop = noone;
function setSelectingItemColor(color) { if(context_selecting_item == noone) return; context_selecting_item.item.setColor(color); }
var clr = MENU_ITEMS.animation_group_label_color;
@ -520,27 +458,28 @@ function Panel_Animation() : PanelContent() constructor {
switch(_prop.type) {
case VALUE_TYPE.color :
switch(_prop.display_type) {
case VALUE_DISPLAY.palette :
var dialog = dialogCall(o_dialog_palette, WIN_W / 2, WIN_H / 2);
dialog.setDefault(keyframe.value);
dialog.onApply = function(val) { __keyframe_editing.value = val; };
dialog.drop_target = _wid;
dialogCall(o_dialog_palette)
.setDefault(keyframe.value)
.setApply(function(val) /*=>*/ { __keyframe_editing.value = val; })
.setDrop(_wid);
break;
default :
var dialog = dialogCall(o_dialog_color_selector)
dialogCall(o_dialog_color_selector)
.setDefault(keyframe.value)
.setApply(function(val) /*=>*/ { __keyframe_editing.value = val; });
dialog.drop_target = _wid;
.setApply(function(val) /*=>*/ { __keyframe_editing.value = val; })
.setDrop(_wid);
break;
}
break;
case VALUE_TYPE.gradient :
var dialog = dialogCall(o_dialog_gradient, WIN_W / 2, WIN_H / 2);
dialog.setDefault(keyframe.value.clone());
dialog.onApply = function(val) { __keyframe_editing.value = val; };
dialog.drop_target = _wid;
dialogCall(o_dialog_gradient)
.setDefault(keyframe.value.clone())
.setApply(function(val) /*=>*/ { __keyframe_editing.value = val; })
.setDrop(_wid);
break;
default :
@ -549,42 +488,26 @@ function Panel_Animation() : PanelContent() constructor {
}
function deleteKeys() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.anim.removeKey(k);
}
array_foreach(keyframe_selecting, function(k) /*=>*/ { k.anim.removeKey(k); });
keyframe_selecting = [];
}
function alignKeys(halign = fa_left) {
if(array_empty(keyframe_selecting)) return;
var tt = 0;
__tt = 0;
switch(halign) {
case fa_left :
tt = 9999;
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ )
tt = min(tt, keyframe_selecting[i].time);
break;
case fa_left : __tt = array_reduce(keyframe_selecting, function(v, k) /*=>*/ {return min(v, k.time)}, infinity); break;
case fa_right : __tt = array_reduce(keyframe_selecting, function(v, k) /*=>*/ {return max(v, k.time)}, -infinity); break;
case fa_center :
tt = 0;
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ )
tt += keyframe_selecting[i].time;
tt = round(tt / array_length(keyframe_selecting));
break;
case fa_right :
tt = -9999;
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ )
tt = max(tt, keyframe_selecting[i].time);
__tt = array_reduce(keyframe_selecting, function(v, k) /*=>*/ {return v + k.time}, 0);
__tt = round(__tt / array_length(keyframe_selecting));
break;
}
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i];
k.anim.setKeyTime(k, tt,, true);
}
array_foreach(keyframe_selecting, function(k) /*=>*/ { k.anim.setKeyTime(k, __tt,, true) });
}
function arrangeKeys() {}
@ -610,13 +533,14 @@ function Panel_Animation() : PanelContent() constructor {
surface_set_target(timeline_mask);
draw_clear(c_black);
gpu_set_blendmode(bm_subtract);
BLEND_SUBTRACT
draw_sprite_stretched(THEME.ui_panel_bg, 0, 0, 0, timeline_w, timeline_h);
gpu_set_blendmode(bm_normal);
BLEND_NORMAL
surface_reset_target();
if(dope_sheet_h > 8) {
gpu_set_blendmode(bm_subtract);
if(dope_sheet_h < ui(8)) return;
BLEND_SUBTRACT
surface_set_target(dope_sheet_mask);
draw_clear(c_black);
@ -628,30 +552,29 @@ function Panel_Animation() : PanelContent() constructor {
draw_sprite_stretched(THEME.ui_panel_bg, 0, 0, 0, tool_width, dope_sheet_h);
surface_reset_target();
gpu_set_blendmode(bm_normal);
}
BLEND_NORMAL
}
resetTimelineMask();
function getTimelineContentFolder(folder, _context = [], _depth = 0, _show = true) {
var ind = 0;
var _ind = 0;
for( var i = 0, n = array_length(folder.contents); i < n; i++ ) {
var _cont = folder.contents[i];
if(!_cont.active) continue;
var _content = {
item: _cont,
parent: _cont.parent,
index: ind,
contexts: _context,
y: 0,
h: 0,
item: _cont,
parent: _cont.parent,
index: _ind,
contexts: _context,
depth: _depth,
show: _show,
};
if(is_instanceof(_cont, timelineItemGroup)) {
if(is(_cont, timelineItemGroup)) {
_content.type = "folder";
array_push(timeline_contents, _content);
@ -661,8 +584,9 @@ function Panel_Animation() : PanelContent() constructor {
_context_folder[m] = _content;
if(item_dragging == noone || item_dragging.item != _cont)
getTimelineContentFolder(_cont, _context_folder, _depth + 1, _show && _cont.show);
} else if(is_instanceof(_cont, timelineItemNode)) {
getTimelineContentFolder(_cont, _context_folder, _depth + 1, _show && _cont.show || !show_nodes);
} else if(is(_cont, timelineItemNode)) {
var _node = _cont.node;
if(!is_struct(_node)) continue;
@ -688,7 +612,7 @@ function Panel_Animation() : PanelContent() constructor {
array_push(timeline_contents, _content);
}
if(item_dragging == noone || item_dragging.item != _cont) ind++;
if(item_dragging == noone || item_dragging.item != _cont) _ind++;
}
}
@ -705,34 +629,31 @@ function Panel_Animation() : PanelContent() constructor {
var bar_total_w = TOTAL_FRAMES * timeline_scale;
var inspecting = PANEL_INSPECTOR.getInspecting();
var msx = mx - bar_x;
var msy = my - bar_y;
resetTimelineMask();
timeline_surface = surface_verify(timeline_surface, timeline_w, timeline_h);
surface_set_target(timeline_surface);
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var msx = mx - bar_x;
var msy = my - bar_y;
draw_sprite_stretched(THEME.ui_panel_bg, 1, 0, 0, bar_w, bar_h);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 2, 0, 0, bar_w, bar_h, COLORS.panel_animation_timeline_blend, 1);
#region BG & Lines
if(inspecting && inspecting.use_cache) { //cache
for(var i = 0; i < TOTAL_FRAMES; i++) {
if(i >= array_length(inspecting.cache_result))
break;
draw_set_alpha(0.05);
for(var i = 0, n = min(TOTAL_FRAMES, array_length(inspecting.cache_result)); i < n; i++) {
var x0 = (i + 0) * timeline_scale + timeline_shift;
var x1 = (i + 1) * timeline_scale + timeline_shift;
draw_set_color(inspecting.getAnimationCacheExist(i)? c_lime : c_red);
draw_set_alpha(0.05);
draw_rectangle(x0, 0, x1, bar_h, false);
draw_rectangle(x0, 0, x1 - 1, bar_h, false);
}
draw_set_alpha(1);
}
}
#region lines
var _stW = timeline_separate * timeline_scale;
var _st = ceil(-timeline_shift / _stW);
var _fr = _st + ceil(bar_w / _stW);
@ -795,7 +716,7 @@ function Panel_Animation() : PanelContent() constructor {
if(inspecting) inspecting.drawAnimationTimeline(timeline_shift, bar_w, bar_h, timeline_scale);
#endregion
#region summary \\\ Set X for all keyframes
#region Summary \\\ Set X for all keyframes
var index = 0;
var key_y = ui(12) + (bar_h - ui(12)) / 2;
@ -820,7 +741,7 @@ function Panel_Animation() : PanelContent() constructor {
}
#endregion
#region pan zoom
#region Pan Zoom
timeline_shift = lerp_float(timeline_shift, timeline_shift_to, 4);
if(timeline_scubbing) {
@ -838,7 +759,6 @@ function Panel_Animation() : PanelContent() constructor {
if(timeline_dragging) {
timeline_shift_to = timeline_drag_sx + mx - timeline_drag_mx;
// timeline_shift_to = min(0, timeline_shift_to);
timeline_shift = timeline_shift_to;
dope_sheet_y_to = clamp(timeline_drag_sy + my - timeline_drag_my, -dope_sheet_y_max, 0);
@ -847,10 +767,10 @@ function Panel_Animation() : PanelContent() constructor {
}
#endregion
gpu_set_blendmode(bm_subtract);
BLEND_SUBTRACT
draw_surface_safe(timeline_mask);
gpu_set_blendmode(bm_normal);
surface_reset_target();
BLEND_NORMAL
surface_reset_target(); //timeline_surface
draw_surface_safe(timeline_surface, bar_x, bar_y);
@ -876,10 +796,7 @@ function Panel_Animation() : PanelContent() constructor {
var mfa = (mx - bar_x - timeline_shift) / ui(sca);
timeline_shift_to = timeline_shift_to - (mfa - mfb) * timeline_scale;
// timeline_shift_to = min(0, timeline_shift_to);
timeline_shift = timeline_shift_to;
// print($"Timeline zoooooom {timeline_shift}");
}
if(mouse_press(mb_middle, pFOCUS)) {
@ -925,7 +842,7 @@ function Panel_Animation() : PanelContent() constructor {
#endregion
}
function __drawDopesheetGraphLine(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) {
function drawDopesheet_Graph_Line(animator, key_y, msx, msy, _gy_val_min = 999999, _gy_val_max = -999999) {
var bar_total_w = TOTAL_FRAMES * timeline_scale;
var bar_show_w = timeline_shift + bar_total_w;
var hovering = noone;
@ -1249,7 +1166,7 @@ function Panel_Animation() : PanelContent() constructor {
#endregion // draw key
}
function _drawDopesheetGraph(prop, key_y, msx, msy) {
function drawDopesheet_Graph(prop, key_y, msx, msy) {
var bar_total_w = TOTAL_FRAMES * timeline_scale;
var bar_show_w = timeline_shift + bar_total_w;
@ -1361,17 +1278,17 @@ function Panel_Animation() : PanelContent() constructor {
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);
drawDopesheet_Graph_Line(prop.animators[i], 0, _mmx, _mmy, _min, _max);
}
} else
__drawDopesheetGraphLine(prop.animator, 0, _mmx, _mmy);
drawDopesheet_Graph_Line(prop.animator, 0, _mmx, _mmy);
surface_reset_target();
draw_surface(keyframe_graph_surface, 0, _gy0);
}
function _drawDopesheetAnimatorKeysBG(animator, msx, msy) {
function drawDopesheet_AnimatorKeys_BG(animator, msx, msy) {
var prop_dope_y = animator.y;
var key_hover = noone;
var key_list = animator.values;
@ -1430,9 +1347,7 @@ function Panel_Animation() : PanelContent() constructor {
return key_hover;
}
__keyframe_editing = noone;
function _drawDopesheetAnimatorKeys(_cont, animator, msx, msy) {
function drawDopesheet_AnimatorKeys(_cont, animator, msx, msy) {
var _node = _cont.node;
var prop_y = animator.y;
var node_y = _cont.y;
@ -1445,14 +1360,14 @@ function Panel_Animation() : PanelContent() constructor {
for( var j = 0, n = array_length(_cont.contexts); j < n; j++ ) {
var _cxt = _cont.contexts[j];
if(!_cxt.show) continue;
if(!_cxt.show && show_nodes) continue;
draw_sprite_ui_uniform(THEME.timeline_key_empty, 0, t, _cxt.y + ui(10), 1, COLORS._main_icon);
}
if(!_cont.show) continue;
if(!_cont.show && show_nodes) continue;
draw_sprite_ui_uniform(THEME.timeline_key_empty, 0, t, node_y + ui(10), 1, COLORS._main_icon);
if(!_cont.item.show) continue;
if(!_cont.item.show && show_nodes) continue;
var cc = COLORS.panel_animation_keyframe_unselected;
if(on_end_dragging_anim == animator.prop && msx < t && anim_set) {
animator.prop.loop_range = k == 0? -1 : array_length(animator.values) - k;
@ -1513,7 +1428,7 @@ function Panel_Animation() : PanelContent() constructor {
return key_hover;
}
function __drawDopesheetLabelAnimator(_item, _node, animator, msx, msy) {
function drawDopesheet_Label_Animator(_item, _node, animator, msx, msy) {
var prop = animator.prop;
var aa = _node.group == PANEL_GRAPH.getCurrentContext()? 1 : 0.9;
var tx = tool_width;
@ -1533,6 +1448,7 @@ function Panel_Animation() : PanelContent() constructor {
var _title_x = ui(32);
if(!show_nodes) {
draw_set_text(f_p3, fa_left, fa_center);
var _txt = animator.prop.node.getDisplayName();
draw_set_alpha(aa * 0.5);
@ -1661,7 +1577,7 @@ function Panel_Animation() : PanelContent() constructor {
draw_set_alpha(1);
}
function __drawDopesheetLabelItem(_item, _x, _y, msx = -1, msy = -1, alpha = 1) {
function drawDopesheet_Label_Item(_item, _x, _y, msx = -1, msy = -1, alpha = 1) {
var _itx = _x;
var _ity = _y;
var _itw = tool_width;
@ -1686,9 +1602,9 @@ function Panel_Animation() : PanelContent() constructor {
}
}
function _drawDopesheetLabel() {
function drawDopesheet_Label() {
surface_set_target(dope_sheet_name_surface);
draw_clear_alpha(COLORS.panel_bg_clear_inner, 0);
draw_clear_alpha(COLORS.panel_bg_clear_inner, 1);
var msx = mx - ui(8);
var msy = my - ui(8);
@ -1713,7 +1629,7 @@ function Panel_Animation() : PanelContent() constructor {
if(item_dragging != noone)
for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) {
var _cont = timeline_contents[i];
if(!_cont.show) continue;
if(!_cont.show && show_nodes) continue;
var _y = _cont.y;
var _h = _cont.h;
@ -1732,6 +1648,7 @@ function Panel_Animation() : PanelContent() constructor {
if(msy > _y && msy <= _y + _h / 2) {
hovering_folder = _cont.parent;
hovering_order = _cont.index;
} else if(msy > _y + _h / 2 && msy <= _y + _h) {
hovering_folder = _cont.parent;
hovering_order = _cont.index + 1;
@ -1752,7 +1669,7 @@ function Panel_Animation() : PanelContent() constructor {
for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) {
var _cont = timeline_contents[i];
if(!_cont.show) continue;
if(!_cont.show && show_nodes) continue;
var _y = _cont.y;
var _h = _cont.h;
@ -1767,11 +1684,11 @@ function Panel_Animation() : PanelContent() constructor {
continue;
}
if(show_nodes) __drawDopesheetLabelItem(_cont, 0, _cont.y, msx, msy);
if(show_nodes) drawDopesheet_Label_Item(_cont, 0, _cont.y, msx, msy);
if(_cont.type == "node" && _cont.item.show)
if(_cont.type == "node" && (_cont.item.show || !show_nodes))
for( var j = 0, m = array_length(_cont.animators); j < m; j++ )
__drawDopesheetLabelAnimator(_cont, _cont.node, _cont.animators[j], msx, msy);
drawDopesheet_Label_Animator(_cont, _cont.node, _cont.animators[j], msx, msy);
}
if(_itx != -1) {
@ -1804,9 +1721,9 @@ function Panel_Animation() : PanelContent() constructor {
}
#endregion
gpu_set_blendmode(bm_subtract);
BLEND_SUBTRACT
draw_surface_safe(dope_sheet_name_mask);
gpu_set_blendmode(bm_normal);
BLEND_NORMAL
surface_reset_target();
}
@ -1883,10 +1800,10 @@ function Panel_Animation() : PanelContent() constructor {
_cont.h = 0;
_cont.item.drawDopesheet(timeline_shift, _cont.y, timeline_scale, msx, msy);
if(!_cont.show) continue;
if(!_cont.show && show_nodes) continue;
if(item_dragging != noone && item_dragging.item == _cont.item) continue;
var _expand = _cont.type == "node" && _cont.item.show;
var _expand = _cont.type == "node" && (_cont.item.show || !show_nodes);
var _ks = key_y;
if(_cont.item.color_dsp > -1) {
@ -1989,10 +1906,23 @@ function Panel_Animation() : PanelContent() constructor {
for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) {
var _cont = timeline_contents[i];
if(!_cont.show) continue;
if( _cont.type != "node") continue;
if(!_cont.item.show) continue;
var _node = _cont.node;
if(_node.use_cache) { //cache
draw_set_alpha(0.05);
for(var j = 0, m = min(TOTAL_FRAMES, array_length(_node.cache_result)); j < m; j++) {
var x0 = (j + 0) * timeline_scale + timeline_shift;
var x1 = (j + 1) * timeline_scale + timeline_shift;
draw_set_color(_node.getAnimationCacheExist(i)? c_lime : c_red);
draw_rectangle(x0, _cont.y + ui(10) - ui(4), x1 - 1, _cont.y + ui(10) + ui(4), false);
}
draw_set_alpha(1);
}
if(show_nodes && (!_cont.show || !_cont.item.show)) continue;
for( var j = 0, m = array_length(_cont.props); j < m; j++ ) {
var prop = _cont.props[j];
@ -2001,11 +1931,11 @@ function Panel_Animation() : PanelContent() constructor {
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);
if(_graph_show) drawDopesheet_Graph(_prop, _dy, msx, msy);
}
for( var k = 0; k < array_length(prop.animators); k++ ) {
var key = _drawDopesheetAnimatorKeysBG(prop.animators[k], msx, msy);
var key = drawDopesheet_AnimatorKeys_BG(prop.animators[k], msx, msy);
_dy = prop.animators[k].y;
if(key != noone) key_hover = key;
}
@ -2117,7 +2047,7 @@ function Panel_Animation() : PanelContent() constructor {
for( var j = 0, m = array_length(_cont.animators); j < m; j++ ) {
var _anim = _cont.animators[j];
var _key = _drawDopesheetAnimatorKeys(_cont, _anim, msx, msy);
var _key = drawDopesheet_AnimatorKeys(_cont, _anim, msx, msy);
if(_key != noone) key_hover = _key;
}
}
@ -2289,7 +2219,7 @@ function Panel_Animation() : PanelContent() constructor {
var _phover = pHOVER && msy > hh;
for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) {
var _cont = timeline_contents[i];
if(!_cont.show) continue;
if(!_cont.show && show_nodes) continue;
var _hov = _cont.item.drawDopesheetOver(timeline_shift, _cont.y, timeline_scale, msx, msy, _phover, pFOCUS);
if(is_undefined(_hov)) continue;
@ -2476,12 +2406,12 @@ function Panel_Animation() : PanelContent() constructor {
}
#endregion
gpu_set_blendmode(bm_subtract);
BLEND_SUBTRACT
draw_surface_safe(dope_sheet_mask);
gpu_set_blendmode(bm_normal);
BLEND_NORMAL
surface_reset_target();
_drawDopesheetLabel();
drawDopesheet_Label();
if(keyframe_boxable && mouse_press(mb_right, pFOCUS)) { // context menu
if(point_in_rectangle(mx, my, bar_x, ui(8), bar_x + dope_sheet_w, ui(8) + dope_sheet_h)) {
@ -2517,7 +2447,7 @@ function Panel_Animation() : PanelContent() constructor {
draw_sprite_stretched(THEME.ui_panel_bg_cover, 1, bar_x, ui(8), bar_w, dope_sheet_h);
if(item_dragging != noone) __drawDopesheetLabelItem(item_dragging, mx - item_dragging_dx, my - item_dragging_dy,,, 0.5);
if(item_dragging != noone) drawDopesheet_Label_Item(item_dragging, mx - item_dragging_dx, my - item_dragging_dy,,, 0.5);
}
function drawAnimationControl() {

View file

@ -78,6 +78,8 @@ function timelineItemNode(node) : timelineItem() constructor {
if(hover && point_in_rectangle(_msx, _msy, _x + ui(20), _y, _x + _w, _y + lh - 1)) {
draw_sprite_stretched_add(THEME.box_r2, 1, _x, _y, _w, lh, col, 0.3);
if(mouse_press(mb_left, focus)) graphFocusNode(node, false);
if(focus && DOUBLE_CLICK) show = !show;
res = 1;
}
@ -91,7 +93,11 @@ function timelineItemNode(node) : timelineItem() constructor {
var aa = 0.75;
if(hover && point_in_rectangle(_msx, _msy, lx, _y, lx + ui(20), _y + lh)) {
aa = 1;
if(mouse_press(mb_left, focus)) show = !show;
if(DOUBLE_CLICK) {
if(show) panel_animation_dopesheet_expand();
else panel_animation_dopesheet_collapse();
} else if(mouse_press(mb_left, focus)) show = !show;
}
if(node.isActiveDynamic())