Skip to content

Commit

Permalink
Merge pull request #69127 from KoBeWi/redUNDOnt
Browse files Browse the repository at this point in the history
Cleanup remaining EditorUndoRedoManager usages
  • Loading branch information
akien-mga committed Nov 24, 2022
2 parents e836284 + 8a3d2f4 commit e1b87cc
Show file tree
Hide file tree
Showing 59 changed files with 408 additions and 406 deletions.
12 changes: 8 additions & 4 deletions editor/animation_bezier_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,6 @@ Size2 AnimationBezierTrackEdit::get_minimum_size() const {
return Vector2(1, 1);
}

void AnimationBezierTrackEdit::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) {
undo_redo = p_undo_redo;
}

void AnimationBezierTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) {
timeline = p_timeline;
timeline->connect("zoom_changed", callable_mp(this, &AnimationBezierTrackEdit::_zoom_changed));
Expand Down Expand Up @@ -791,6 +787,7 @@ void AnimationBezierTrackEdit::_clear_selection() {
}

void AnimationBezierTrackEdit::_change_selected_keys_handle_mode(Animation::HandleMode p_mode, bool p_auto) {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Update Selected Key Handles"));
for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
const IntPair track_key_pair = E->get();
Expand Down Expand Up @@ -987,6 +984,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
if (I.value.has_point(mb->get_position())) {
if (I.key == REMOVE_ICON) {
if (!read_only) {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action("Remove Bezier Track");

undo_redo->add_do_method(this, "_update_locked_tracks_after", track);
Expand Down Expand Up @@ -1173,6 +1171,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
time += 0.001;
}

Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Add Bezier Point"));
undo_redo->add_do_method(animation.ptr(), "bezier_track_insert_key", selected_track, time, new_point);
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
Expand Down Expand Up @@ -1270,6 +1269,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
if (moving_selection) {
//combit it

Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Move Bezier Points"));

List<AnimMoveRestore> to_restore;
Expand Down Expand Up @@ -1470,6 +1470,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) {

if ((moving_handle == -1 || moving_handle == 1) && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
if (!read_only) {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Move Bezier Points"));
if (moving_handle == -1) {
real_t ratio = timeline->get_zoom_scale() * v_zoom;
Expand Down Expand Up @@ -1541,6 +1542,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) {
time += 0.001;
}

Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Add Bezier Point"));
undo_redo->add_do_method(animation.ptr(), "track_insert_key", selected_track, time, new_point);
undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", selected_track, time);
Expand Down Expand Up @@ -1588,6 +1590,7 @@ void AnimationBezierTrackEdit::duplicate_selection() {
}
}

Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Anim Duplicate Keys"));

List<Pair<int, real_t>> new_selection_values;
Expand Down Expand Up @@ -1633,6 +1636,7 @@ void AnimationBezierTrackEdit::duplicate_selection() {

void AnimationBezierTrackEdit::delete_selection() {
if (selection.size()) {
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
undo_redo->create_action(TTR("Anim Delete Keys"));

for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) {
Expand Down
3 changes: 0 additions & 3 deletions editor/animation_bezier_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "animation_track_editor.h"
#include "core/templates/hashfuncs.h"

class EditorUndoRedoManager;
class ViewPanner;

class AnimationBezierTrackEdit : public Control {
Expand All @@ -53,7 +52,6 @@ class AnimationBezierTrackEdit : public Control {
};

AnimationTimelineEdit *timeline = nullptr;
Ref<EditorUndoRedoManager> undo_redo;
Node *root = nullptr;
Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster
real_t play_position_pos = 0;
Expand Down Expand Up @@ -197,7 +195,6 @@ class AnimationBezierTrackEdit : public Control {
void set_animation_and_track(const Ref<Animation> &p_animation, int p_track, bool p_read_only);
virtual Size2 get_minimum_size() const override;

void set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo);
void set_timeline(AnimationTimelineEdit *p_timeline);
void set_editor(AnimationTrackEditor *p_editor);
void set_root(Node *p_root);
Expand Down
Loading

0 comments on commit e1b87cc

Please sign in to comment.