feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -35,6 +35,7 @@
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/view_panner.h"
#include "scene/resources/text_line.h"
@ -54,7 +55,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
int limit = timeline->get_name_limit();
int right_limit = get_size().width;
//selection may have altered the order of keys
// Selection may have altered the order of keys.
RBMap<real_t, int> key_order;
for (int i = 0; i < animation->track_get_key_count(p_track); i++) {
@ -111,11 +112,11 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
int to_x = (offset_n - timeline->get_value()) * scale + limit;
int point_end = to_x;
if (from_x > right_limit) { //not visible
if (from_x > right_limit) { // Not visible.
continue;
}
if (to_x < limit) { //not visible
if (to_x < limit) { // Not visible.
continue;
}
@ -132,15 +133,15 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
float h;
if (j == point_end) {
h = end.y; //make sure it always connects
h = end.y; // Make sure it always connects.
} else if (j == point_start) {
h = start.y; //make sure it always connects
} else { //custom interpolation, used because it needs to show paths affected by moving the selection or handles
h = start.y; // Make sure it always connects.
} else { // Custom interpolation, used because it needs to show paths affected by moving the selection or handles.
int iterations = 10;
float low = 0;
float high = 1;
//narrow high and low as much as possible
// Narrow high and low as much as possible.
for (int k = 0; k < iterations; k++) {
float middle = (low + high) / 2.0;
@ -153,7 +154,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
}
}
//interpolate the result:
// Interpolate the result.
Vector2 low_pos = start.bezier_interpolate(out_handle, in_handle, end, low);
Vector2 high_pos = start.bezier_interpolate(out_handle, in_handle, end, high);
@ -174,7 +175,7 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) {
}
if (lines.size() >= 2) {
draw_multiline(lines, p_color, Math::round(EDSCALE));
draw_multiline(lines, p_color, Math::round(EDSCALE), true);
}
}
}
@ -208,7 +209,7 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V
from = from.lerp(to, c);
}
draw_line(from, to, p_color, Math::round(EDSCALE));
draw_line(from, to, p_color, Math::round(EDSCALE), true);
}
void AnimationBezierTrackEdit::_notification(int p_what) {
@ -216,13 +217,14 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (EditorSettings::get_singleton()->check_changed_settings_in_group("editors/panning")) {
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
}
} break;
case NOTIFICATION_ENTER_TREE: {
panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EDITOR_GET("editors/panning/simple_panning")));
[[fallthrough]];
}
panner->setup_warped_panning(get_viewport(), EDITOR_GET("editors/panning/warped_mouse_panning"));
} break;
case NOTIFICATION_THEME_CHANGED: {
bezier_icon = get_editor_theme_icon(SNAME("KeyBezierPoint"));
bezier_handle_icon = get_editor_theme_icon(SNAME("KeyBezierHandle"));
@ -236,27 +238,29 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
int limit = timeline->get_name_limit();
const Ref<Font> font = get_theme_font(SceneStringName(font), SNAME("Label"));
const int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label"));
const Color color = get_theme_color(SceneStringName(font_color), SNAME("Label"));
const Color h_line_color = get_theme_color(SNAME("h_line_color"), SNAME("AnimationBezierTrackEdit"));
const Color v_line_color = get_theme_color(SNAME("v_line_color"), SNAME("AnimationBezierTrackEdit"));
const Color focus_color = get_theme_color(SNAME("focus_color"), SNAME("AnimationBezierTrackEdit"));
const Color track_focus_color = get_theme_color(SNAME("track_focus_color"), SNAME("AnimationBezierTrackEdit"));
const int h_separation = get_theme_constant(SNAME("h_separation"), SNAME("AnimationBezierTrackEdit"));
const int v_separation = get_theme_constant(SNAME("h_separation"), SNAME("AnimationBezierTrackEdit"));
if (has_focus()) {
Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
accent.a *= 0.7;
draw_rect(Rect2(Point2(), get_size()), accent, false, Math::round(EDSCALE));
draw_rect(Rect2(Point2(), get_size()), focus_color, false, Math::round(EDSCALE));
}
Ref<Font> font = get_theme_font(SceneStringName(font), SNAME("Label"));
int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label"));
Color color = get_theme_color(SceneStringName(font_color), SNAME("Label"));
int hsep = get_theme_constant(SNAME("h_separation"), SNAME("ItemList"));
int vsep = get_theme_constant(SNAME("v_separation"), SNAME("ItemList"));
Color linecolor = color;
linecolor.a = 0.2;
draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE));
draw_line(Point2(limit, 0), Point2(limit, get_size().height), v_line_color, Math::round(EDSCALE));
int right_limit = get_size().width;
track_v_scroll_max = vsep;
track_v_scroll_max = v_separation;
int vofs = vsep + track_v_scroll;
int vofs = v_separation + track_v_scroll;
int margin = 0;
RBMap<int, Color> subtrack_colors;
@ -272,7 +276,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
String base_path = animation->track_get_path(i);
int end = base_path.find(":");
int end = base_path.find_char(':');
if (end != -1) {
base_path = base_path.substr(0, end + 1);
}
@ -286,7 +290,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
Vector<int> tracks = E.value;
// NAMES AND ICON
// Names and icon.
{
NodePath path = animation->track_get_path(tracks[0]);
@ -304,15 +308,15 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
text = node->get_name();
ofs += hsep;
ofs += h_separation;
TextLine text_buf = TextLine(text, font, font_size);
text_buf.set_width(limit - ofs - icon->get_width() - hsep);
text_buf.set_width(limit - ofs - icon->get_width() - h_separation);
int h = MAX(text_buf.get_size().y, icon->get_height());
draw_texture(icon, Point2(ofs, vofs + int(h - icon->get_height()) / 2.0));
ofs += icon->get_width();
ofs += icon->get_width() + h_separation;
margin = icon->get_width();
@ -320,31 +324,31 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
string_pos = string_pos.floor();
text_buf.draw(get_canvas_item(), string_pos, color);
vofs += h + vsep;
track_v_scroll_max += h + vsep;
vofs += h + v_separation;
track_v_scroll_max += h + v_separation;
}
}
Color dc = get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor));
const Color dc = get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor));
Ref<Texture2D> remove = get_editor_theme_icon(SNAME("Remove"));
float remove_hpos = limit - hsep - remove->get_width();
float remove_hpos = limit - h_separation - remove->get_width();
Ref<Texture2D> lock = get_editor_theme_icon(SNAME("Lock"));
Ref<Texture2D> unlock = get_editor_theme_icon(SNAME("Unlock"));
float lock_hpos = remove_hpos - hsep - lock->get_width();
float lock_hpos = remove_hpos - h_separation - lock->get_width();
Ref<Texture2D> visibility_visible = get_editor_theme_icon(SNAME("GuiVisibilityVisible"));
Ref<Texture2D> visibility_hidden = get_editor_theme_icon(SNAME("GuiVisibilityHidden"));
float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width();
float visibility_hpos = lock_hpos - h_separation - visibility_visible->get_width();
Ref<Texture2D> solo = get_editor_theme_icon(SNAME("AudioBusSolo"));
float solo_hpos = visibility_hpos - hsep - solo->get_width();
float solo_hpos = visibility_hpos - h_separation - solo->get_width();
float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3;
float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + h_separation * 3;
for (int i = 0; i < tracks.size(); ++i) {
// RELATED TRACKS TITLES
// Related track titles.
int current_track = tracks[i];
@ -353,9 +357,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
Color cc = color;
TextLine text_buf = TextLine(path, font, font_size);
text_buf.set_width(limit - margin - buttons_width);
text_buf.set_width(limit - margin - buttons_width - h_separation * 2);
Rect2 rect = Rect2(margin, vofs, solo_hpos - hsep - solo->get_width(), text_buf.get_size().y + vsep);
Rect2 rect = Rect2(margin, vofs, solo_hpos - h_separation - solo->get_width(), text_buf.get_size().y + v_separation);
cc.a *= 0.7;
float h;
@ -381,14 +385,12 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
track_color.set_hsv(h, 0.2, 0.8);
}
track_color.a = 0.5;
draw_rect(Rect2(0, vofs, margin - hsep, text_buf.get_size().y * 0.8), track_color);
draw_rect(Rect2(0, vofs, margin - h_separation, text_buf.get_size().y * 0.8), track_color);
subtrack_colors[current_track] = track_color;
subtracks[current_track] = rect;
} else {
Color ac = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
ac.a = 0.5;
draw_rect(rect, ac);
draw_rect(rect, track_focus_color);
if (locked_tracks.has(selected_track)) {
selected_track_color.set_hsv(h, 0.0, 0.4);
} else {
@ -396,7 +398,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
}
Vector2 string_pos = Point2(margin, vofs);
Vector2 string_pos = Point2(margin + h_separation, vofs);
text_buf.draw(get_canvas_item(), string_pos, cc);
float icon_start_height = vofs + rect.size.y / 2.0;
@ -432,15 +434,16 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
subtrack_icons[current_track] = track_icons;
vofs += text_buf.get_size().y + vsep;
track_v_scroll_max += text_buf.get_size().y + vsep;
vofs += text_buf.get_size().y + v_separation;
track_v_scroll_max += text_buf.get_size().y + v_separation;
}
}
Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
const Color accent = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
{ //guides
float min_left_scale = font->get_height(font_size) + vsep;
// Guides.
{
float min_left_scale = font->get_height(font_size) + v_separation;
float scale = (min_left_scale * 2) * timeline_v_zoom;
float step = Math::pow(10.0, Math::round(Math::log(scale / 5.0) / Math::log(10.0))) * 5.0;
@ -462,7 +465,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
iv -= 1;
}
if (!first && iv != prev_iv) {
Color lc = linecolor;
Color lc = h_line_color;
lc.a *= 0.5;
draw_line(Point2(limit, i), Point2(right_limit, i), lc, Math::round(EDSCALE));
Color c = color;
@ -475,8 +478,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
}
{ //draw OTHER curves
// Draw other curves.
{
float scale = timeline->get_zoom_scale();
Ref<Texture2D> point = get_editor_theme_icon(SNAME("KeyValue"));
for (const KeyValue<int, Color> &E : subtrack_colors) {
@ -498,12 +501,12 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
if (track_count > 0 && !hidden_tracks.has(selected_track)) {
//draw edited curve
// Draw edited curve.
_draw_track(selected_track, selected_track_color);
}
}
//draw editor handles
// Draw editor handles.
{
edit_points.clear();
float scale = timeline->get_zoom_scale();
@ -644,12 +647,12 @@ bool AnimationBezierTrackEdit::_is_track_displayed(int p_track_index) {
// Check if the curves for a track are displayed in the editor (not hidden). Includes the check on the track visibility.
bool AnimationBezierTrackEdit::_is_track_curves_displayed(int p_track_index) {
//Is the track is visible in the editor?
// Is the track is visible in the editor?
if (!_is_track_displayed(p_track_index)) {
return false;
}
//And curves visible?
// And curves visible?
if (hidden_tracks.has(p_track_index)) {
return false;
}
@ -686,7 +689,7 @@ void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
}
void AnimationBezierTrackEdit::_play_position_draw() {
if (!animation.is_valid() || play_position_pos < 0) {
if (animation.is_null() || play_position_pos < 0) {
return;
}
@ -698,7 +701,7 @@ void AnimationBezierTrackEdit::_play_position_draw() {
int px = (-timeline->get_value() + play_position_pos) * scale + limit;
if (px >= limit && px < (get_size().width)) {
Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
const Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE));
}
}
@ -718,7 +721,7 @@ void AnimationBezierTrackEdit::set_root(Node *p_root) {
void AnimationBezierTrackEdit::set_filtered(bool p_filtered) {
is_filtered = p_filtered;
if (animation == nullptr) {
if (animation.is_null()) {
return;
}
String base_path = animation->track_get_path(selected_track);
@ -868,6 +871,11 @@ void AnimationBezierTrackEdit::_change_selected_keys_handle_mode(Animation::Hand
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", track_key_pair.first, track_key_pair.second, animation->bezier_track_get_key_out_handle(track_key_pair.first, track_key_pair.second));
undo_redo->add_do_method(editor, "_bezier_track_set_key_handle_mode", animation.ptr(), track_key_pair.first, track_key_pair.second, p_mode, p_auto ? Animation::HANDLE_SET_MODE_AUTO : Animation::HANDLE_SET_MODE_RESET);
}
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->commit_action();
}
@ -1083,7 +1091,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
if (I.key == REMOVE_ICON) {
if (!read_only) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action("Remove Bezier Track");
undo_redo->create_action("Remove Bezier Track", UndoRedo::MERGE_DISABLE, animation.ptr());
undo_redo->add_do_method(this, "_update_locked_tracks_after", track);
undo_redo->add_do_method(this, "_update_hidden_tracks_after", track);
@ -1218,7 +1226,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
}
//insert new point
// Insert new point.
if (mb->get_position().x >= limit && mb->get_position().x < get_size().width && mb->is_command_or_control_pressed()) {
float h = (get_size().height / 2.0 - mb->get_position().y) * timeline_v_zoom + timeline_v_scroll;
Array new_point = animation->make_default_bezier_key(h);
@ -1234,7 +1242,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
undo_redo->commit_action();
//then attempt to move
// Then attempt to move.
int index = animation->track_find_key(selected_track, time, Animation::FIND_MODE_APPROX);
ERR_FAIL_COND(index == -1);
_clear_selection();
@ -1252,7 +1260,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
return;
}
//box select
// Box select.
if (mb->get_position().x >= limit && mb->get_position().x < get_size().width) {
box_selecting_attempt = true;
box_selecting = false;
@ -1264,7 +1272,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
if (box_selecting_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
if (box_selecting) {
//do actual select
// Do actual select.
if (!box_selecting_add) {
_clear_selection();
}
@ -1292,13 +1300,13 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
}
} else {
_clear_selection(); //clicked and nothing happened, so clear the selection
_clear_selection(); // Clicked and nothing happened, so clear the selection.
//select by clicking on curve
// Select by clicking on curve.
int track_count = animation->get_track_count();
real_t animation_length = animation->get_length();
animation->set_length(real_t(INT_MAX)); //bezier_track_interpolate doesn't find keys if they exist beyond anim length
animation->set_length(real_t(INT_MAX)); // bezier_track_interpolate doesn't find keys if they exist beyond anim length.
real_t time = ((mb->get_position().x - limit) / timeline->get_zoom_scale()) + timeline->get_value();
@ -1334,11 +1342,11 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
List<AnimMoveRestore> to_restore;
List<Animation::HandleMode> to_restore_handle_modes;
// 1-remove the keys
// 1 - Remove the keys.
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->get().first, E->get().second);
}
// 2- remove overlapped keys
// 2 - Remove overlapped keys.
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
real_t newtime = animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x;
@ -1348,7 +1356,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
if (selection.has(IntPair(E->get().first, idx))) {
continue; //already in selection, don't save
continue; // Already in selection, don't save.
}
undo_redo->add_do_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newtime);
@ -1362,7 +1370,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
to_restore_handle_modes.push_back(animation->bezier_track_get_key_handle_mode(E->get().first, idx));
}
// 3-move the keys (re insert them)
// 3 - Move the keys (re-insert them).
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
real_t newpos = animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x;
Array key = animation->track_get_key_value(E->get().first, E->get().second);
@ -1381,13 +1389,13 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
animation->bezier_track_get_key_handle_mode(E->get().first, E->get().second));
}
// 4-(undo) remove inserted keys
// 4 - (undo) Remove inserted keys.
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
real_t newpos = animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x;
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos);
}
// 5-(undo) reinsert keys
// 5 - (undo) Reinsert keys.
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
real_t oldpos = animation->track_get_key_time(E->get().first, E->get().second);
Array key = animation->track_get_key_value(E->get().first, E->get().second);
@ -1403,7 +1411,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
animation->bezier_track_get_key_handle_mode(E->get().first, E->get().second));
}
// 6-(undo) reinsert overlapped keys
// 6 - (undo) Reinsert overlapped keys.
List<AnimMoveRestore>::ConstIterator restore_itr = to_restore.begin();
List<Animation::HandleMode>::ConstIterator handle_itr = to_restore_handle_modes.begin();
for (; restore_itr != to_restore.end() && handle_itr != to_restore_handle_modes.end(); ++restore_itr, ++handle_itr) {
@ -1425,7 +1433,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
// 7-reselect
// 7 - Reselect.
int i = 0;
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
real_t oldpos = animation->track_get_key_time(E->get().first, E->get().second);
@ -1436,6 +1444,11 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
i++;
}
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->commit_action();
} else if (select_single_attempt != IntPair(-1, -1)) {
@ -1489,11 +1502,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
box_selection_to = mm->get_position();
if (get_local_mouse_position().y < 0) {
//avoid cursor from going too above, so it does not lose focus with viewport
warp_mouse(Vector2(get_local_mouse_position().x, 0));
}
queue_redraw();
}
@ -1559,6 +1567,11 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, moving_handle_right, ratio);
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", moving_handle_track, moving_handle_key, animation->bezier_track_get_key_out_handle(moving_handle_track, moving_handle_key), ratio);
}
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->commit_action();
moving_handle = 0;
queue_redraw();
@ -1638,7 +1651,7 @@ void AnimationBezierTrackEdit::_zoom_callback(float p_zoom_factor, Vector2 p_ori
Ref<InputEventWithModifiers> iewm = p_event;
if (iewm.is_valid() && iewm->is_alt_pressed()) {
// Alternate zoom (doesn't affect timeline).
timeline_v_zoom = CLAMP(timeline_v_zoom * p_zoom_factor, 0.000001, 100000);
timeline_v_zoom = CLAMP(timeline_v_zoom / p_zoom_factor, 0.000001, 100000);
} else {
float zoom_factor = p_zoom_factor > 1.0 ? AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN : AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_OUT;
timeline->_zoom_callback(zoom_factor, p_origin, p_event);
@ -1659,7 +1672,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
switch (p_index) {
case MENU_KEY_INSERT: {
if (animation->get_track_count() > 0) {
if (editor->snap->is_pressed() && editor->step->get_value() != 0) {
if (editor->snap_keys->is_pressed() && editor->step->get_value() != 0) {
time = editor->snap_time(time);
}
while (animation->track_find_key(selected_track, time, Animation::FIND_MODE_APPROX) != -1) {
@ -1672,6 +1685,11 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, time, new_point);
undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->commit_action();
queue_redraw();
}
@ -1735,7 +1753,7 @@ void AnimationBezierTrackEdit::duplicate_selected_keys(real_t p_ofs, bool p_ofs_
real_t insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position();
if (p_ofs_valid) {
if (editor->snap->is_pressed() && editor->step->get_value() != 0) {
if (editor->snap_keys->is_pressed() && editor->step->get_value() != 0) {
insert_pos = editor->snap_time(insert_pos);
}
}
@ -1772,6 +1790,11 @@ void AnimationBezierTrackEdit::duplicate_selected_keys(real_t p_ofs, bool p_ofs_
i++;
}
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->add_do_method(this, "queue_redraw");
undo_redo->add_undo_method(this, "queue_redraw");
undo_redo->commit_action();
@ -1821,6 +1844,15 @@ void AnimationBezierTrackEdit::copy_selected_keys(bool p_cut) {
undo_redo->add_undo_method(this, "_select_at_anim", animation, E->key().track, E->value().pos, i == 0);
i++;
}
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->add_do_method(this, "queue_redraw");
undo_redo->add_undo_method(this, "queue_redraw");
undo_redo->commit_action();
}
}
@ -1858,7 +1890,7 @@ void AnimationBezierTrackEdit::paste_keys(real_t p_ofs, bool p_ofs_valid) {
float insert_pos = p_ofs_valid ? p_ofs : timeline->get_play_position();
if (p_ofs_valid) {
if (editor->snap->is_pressed() && editor->step->get_value() != 0) {
if (editor->snap_keys->is_pressed() && editor->step->get_value() != 0) {
insert_pos = editor->snap_time(insert_pos);
}
}
@ -1899,9 +1931,15 @@ void AnimationBezierTrackEdit::paste_keys(real_t p_ofs, bool p_ofs_valid) {
i++;
}
undo_redo->commit_action();
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->add_do_method(this, "queue_redraw");
undo_redo->add_undo_method(this, "queue_redraw");
queue_redraw();
undo_redo->commit_action();
}
}
@ -1916,6 +1954,11 @@ void AnimationBezierTrackEdit::delete_selection() {
}
undo_redo->add_do_method(this, "_clear_selection_for_anim", animation);
undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
AnimationPlayerEditor *ape = AnimationPlayerEditor::get_singleton();
if (ape) {
undo_redo->add_do_method(ape, "_animation_update_key_frame");
undo_redo->add_undo_method(ape, "_animation_update_key_frame");
}
undo_redo->commit_action();
//selection.clear();
@ -1953,9 +1996,9 @@ AnimationBezierTrackEdit::AnimationBezierTrackEdit() {
set_clip_contents(true);
ED_SHORTCUT("animation_bezier_editor/focus", TTR("Focus"), Key::F);
ED_SHORTCUT("animation_bezier_editor/select_all_keys", TTR("Select All Keys"), KeyModifierMask::CMD_OR_CTRL | Key::A);
ED_SHORTCUT("animation_bezier_editor/deselect_all_keys", TTR("Deselect All Keys"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::A);
ED_SHORTCUT("animation_bezier_editor/focus", TTRC("Focus"), Key::F);
ED_SHORTCUT("animation_bezier_editor/select_all_keys", TTRC("Select All Keys"), KeyModifierMask::CMD_OR_CTRL | Key::A);
ED_SHORTCUT("animation_bezier_editor/deselect_all_keys", TTRC("Deselect All Keys"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::A);
menu = memnew(PopupMenu);
add_child(menu);