mirror of
https://github.com/godotengine/godot
synced 2024-09-05 18:59:47 +00:00
Fixed a few issues with the bezier animation track editor, fixed the Travis CI errors, added TTR to bezier value labels and rounded them to 3 decimal points
This commit is contained in:
parent
7e0c97e73b
commit
a7ef836c69
|
@ -453,6 +453,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
|
||||||
ep.point_rect.size = bezier_icon->get_size();
|
ep.point_rect.size = bezier_icon->get_size();
|
||||||
if (selection.has(i)) {
|
if (selection.has(i)) {
|
||||||
draw_texture(selected_icon, ep.point_rect.position);
|
draw_texture(selected_icon, ep.point_rect.position);
|
||||||
|
draw_string(font, ep.point_rect.position + Vector2(8, -font->get_height() - 4), TTR("Time:") + " " + rtos(Math::stepify(offset, 0.001)), accent);
|
||||||
|
draw_string(font, ep.point_rect.position + Vector2(8, -8), TTR("Value:") + " " + rtos(Math::stepify(value, 0.001)), accent);
|
||||||
} else {
|
} else {
|
||||||
draw_texture(bezier_icon, ep.point_rect.position);
|
draw_texture(bezier_icon, ep.point_rect.position);
|
||||||
}
|
}
|
||||||
|
@ -518,6 +520,12 @@ void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_a
|
||||||
|
|
||||||
animation = p_animation;
|
animation = p_animation;
|
||||||
track = p_track;
|
track = p_track;
|
||||||
|
if (is_connected("select_key", editor, "_key_selected"))
|
||||||
|
disconnect("select_key", editor, "_key_selected");
|
||||||
|
if (is_connected("deselect_key", editor, "_key_deselected"))
|
||||||
|
disconnect("deselect_key", editor, "_key_deselected");
|
||||||
|
connect("select_key", editor, "_key_selected", varray(p_track), CONNECT_DEFERRED);
|
||||||
|
connect("deselect_key", editor, "_key_deselected", varray(p_track), CONNECT_DEFERRED);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,6 +544,7 @@ void AnimationBezierTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) {
|
||||||
}
|
}
|
||||||
void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
|
void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
|
||||||
editor = p_editor;
|
editor = p_editor;
|
||||||
|
connect("clear_selection", editor, "_clear_selection");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationBezierTrackEdit::_play_position_draw() {
|
void AnimationBezierTrackEdit::_play_position_draw() {
|
||||||
|
@ -578,6 +587,7 @@ String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const {
|
||||||
|
|
||||||
void AnimationBezierTrackEdit::_clear_selection() {
|
void AnimationBezierTrackEdit::_clear_selection() {
|
||||||
selection.clear();
|
selection.clear();
|
||||||
|
emit_signal("clear_selection");
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,6 +608,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int
|
||||||
ERR_FAIL_COND(idx < 0);
|
ERR_FAIL_COND(idx < 0);
|
||||||
|
|
||||||
selection.insert(idx);
|
selection.insert(idx);
|
||||||
|
emit_signal("select_key", idx, true);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,20 +664,22 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
|
if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
|
||||||
|
|
||||||
menu_insert_key = mb->get_position();
|
menu_insert_key = mb->get_position();
|
||||||
Vector2 popup_pos = get_global_transform().xform(mb->get_position());
|
if (menu_insert_key.x >= timeline->get_name_limit() && menu_insert_key.x <= get_size().width - timeline->get_buttons_width()) {
|
||||||
|
Vector2 popup_pos = get_global_transform().xform(mb->get_position());
|
||||||
|
|
||||||
menu->clear();
|
menu->clear();
|
||||||
menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT);
|
menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT);
|
||||||
if (selection.size()) {
|
if (selection.size()) {
|
||||||
menu->add_separator();
|
menu->add_separator();
|
||||||
menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE);
|
menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE);
|
||||||
menu->add_separator();
|
menu->add_separator();
|
||||||
menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE);
|
menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->set_as_minsize();
|
||||||
|
menu->set_position(popup_pos);
|
||||||
|
menu->popup();
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->set_as_minsize();
|
|
||||||
menu->set_position(popup_pos);
|
|
||||||
menu->popup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
|
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
|
||||||
|
@ -678,6 +691,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
for (Map<int, Rect2>::Element *E = subtracks.front(); E; E = E->next()) {
|
for (Map<int, Rect2>::Element *E = subtracks.front(); E; E = E->next()) {
|
||||||
if (E->get().has_point(mb->get_position())) {
|
if (E->get().has_point(mb->get_position())) {
|
||||||
set_animation_and_track(animation, E->key());
|
set_animation_and_track(animation, E->key());
|
||||||
|
_clear_selection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,7 +864,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
// 2- remove overlapped keys
|
// 2- remove overlapped keys
|
||||||
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
||||||
|
|
||||||
float newtime = animation->track_get_key_time(track, E->get()) + moving_selection_offset.x;
|
float newtime = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
|
||||||
|
|
||||||
int idx = animation->track_find_key(track, newtime, true);
|
int idx = animation->track_find_key(track, newtime, true);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
|
@ -872,7 +886,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
// 3-move the keys (re insert them)
|
// 3-move the keys (re insert them)
|
||||||
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
||||||
|
|
||||||
float newpos = animation->track_get_key_time(track, E->get()) + moving_selection_offset.x;
|
float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
|
||||||
/*
|
/*
|
||||||
if (newpos<0)
|
if (newpos<0)
|
||||||
continue; //no add at the beginning
|
continue; //no add at the beginning
|
||||||
|
@ -887,7 +901,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
// 4-(undo) remove inserted keys
|
// 4-(undo) remove inserted keys
|
||||||
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
||||||
|
|
||||||
float newpos = animation->track_get_key_time(track, E->get()) + moving_selection_offset.x;
|
float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x);
|
||||||
/*
|
/*
|
||||||
if (newpos<0)
|
if (newpos<0)
|
||||||
continue; //no remove what no inserted
|
continue; //no remove what no inserted
|
||||||
|
@ -924,7 +938,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
for (Set<int>::Element *E = selection.back(); E; E = E->prev()) {
|
||||||
|
|
||||||
float oldpos = animation->track_get_key_time(track, E->get());
|
float oldpos = animation->track_get_key_time(track, E->get());
|
||||||
float newpos = oldpos + moving_selection_offset.x;
|
float newpos = editor->snap_time(oldpos + moving_selection_offset.x);
|
||||||
|
|
||||||
undo_redo->add_do_method(this, "_select_at_anim", animation, track, newpos);
|
undo_redo->add_do_method(this, "_select_at_anim", animation, track, newpos);
|
||||||
undo_redo->add_undo_method(this, "_select_at_anim", animation, track, oldpos);
|
undo_redo->add_undo_method(this, "_select_at_anim", animation, track, oldpos);
|
||||||
|
@ -965,7 +979,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float y = (get_size().height / 2 - mm->get_position().y) * v_zoom + v_scroll;
|
float y = (get_size().height / 2 - mm->get_position().y) * v_zoom + v_scroll;
|
||||||
float x = ((mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale()) + timeline->get_value();
|
float x = editor->snap_time(((mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale()) + timeline->get_value());
|
||||||
|
|
||||||
moving_selection_offset = Vector2(x - animation->track_get_key_time(track, moving_selection_from_key), y - animation->bezier_track_get_key_value(track, moving_selection_from_key));
|
moving_selection_offset = Vector2(x - animation->track_get_key_time(track, moving_selection_from_key), y - animation->bezier_track_get_key_value(track, moving_selection_from_key));
|
||||||
update();
|
update();
|
||||||
|
@ -1154,8 +1168,8 @@ void AnimationBezierTrackEdit::_bind_methods() {
|
||||||
ClassDB::bind_method("_play_position_draw", &AnimationBezierTrackEdit::_play_position_draw);
|
ClassDB::bind_method("_play_position_draw", &AnimationBezierTrackEdit::_play_position_draw);
|
||||||
|
|
||||||
ClassDB::bind_method("_clear_selection", &AnimationBezierTrackEdit::_clear_selection);
|
ClassDB::bind_method("_clear_selection", &AnimationBezierTrackEdit::_clear_selection);
|
||||||
ClassDB::bind_method("_clear_selection_for_anim", &AnimationBezierTrackEdit::_clear_selection);
|
ClassDB::bind_method("_clear_selection_for_anim", &AnimationBezierTrackEdit::_clear_selection_for_anim);
|
||||||
ClassDB::bind_method("_select_at_anim", &AnimationBezierTrackEdit::_clear_selection);
|
ClassDB::bind_method("_select_at_anim", &AnimationBezierTrackEdit::_select_at_anim);
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::REAL, "position"), PropertyInfo(Variant::BOOL, "drag")));
|
ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::REAL, "position"), PropertyInfo(Variant::BOOL, "drag")));
|
||||||
ADD_SIGNAL(MethodInfo("remove_request", PropertyInfo(Variant::INT, "track")));
|
ADD_SIGNAL(MethodInfo("remove_request", PropertyInfo(Variant::INT, "track")));
|
||||||
|
|
|
@ -309,8 +309,8 @@ public:
|
||||||
setting = true;
|
setting = true;
|
||||||
undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS);
|
undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS);
|
||||||
Vector2 prev = animation->bezier_track_get_key_in_handle(track, key);
|
Vector2 prev = animation->bezier_track_get_key_in_handle(track, key);
|
||||||
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_in_handle", track, key, value);
|
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, value);
|
||||||
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_in_handle", track, key, prev);
|
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, prev);
|
||||||
undo_redo->add_do_method(this, "_update_obj", animation);
|
undo_redo->add_do_method(this, "_update_obj", animation);
|
||||||
undo_redo->add_undo_method(this, "_update_obj", animation);
|
undo_redo->add_undo_method(this, "_update_obj", animation);
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
@ -325,8 +325,8 @@ public:
|
||||||
setting = true;
|
setting = true;
|
||||||
undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS);
|
undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS);
|
||||||
Vector2 prev = animation->bezier_track_get_key_out_handle(track, key);
|
Vector2 prev = animation->bezier_track_get_key_out_handle(track, key);
|
||||||
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_out_handle", track, key, value);
|
undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, value);
|
||||||
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_out_handle", track, key, prev);
|
undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, prev);
|
||||||
undo_redo->add_do_method(this, "_update_obj", animation);
|
undo_redo->add_do_method(this, "_update_obj", animation);
|
||||||
undo_redo->add_undo_method(this, "_update_obj", animation);
|
undo_redo->add_undo_method(this, "_update_obj", animation);
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
@ -1274,13 +1274,7 @@ void AnimationTrackEdit::_notification(int p_what) {
|
||||||
} else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
|
} else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) {
|
||||||
text = TTR("Anim Clips:");
|
text = TTR("Anim Clips:");
|
||||||
} else {
|
} else {
|
||||||
Vector<StringName> sn = path.get_subnames();
|
text += path.get_concatenated_subnames();
|
||||||
for (int i = 0; i < sn.size(); i++) {
|
|
||||||
if (i > 0) {
|
|
||||||
text += ".";
|
|
||||||
}
|
|
||||||
text += sn[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
text_color.a *= 0.7;
|
text_color.a *= 0.7;
|
||||||
} else if (node) {
|
} else if (node) {
|
||||||
|
@ -1294,14 +1288,10 @@ void AnimationTrackEdit::_notification(int p_what) {
|
||||||
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
|
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
|
||||||
icon_cache = icon;
|
icon_cache = icon;
|
||||||
|
|
||||||
text = node->get_name();
|
text = String() + node->get_name() + ":" + path.get_concatenated_subnames();
|
||||||
ofs += hsep;
|
ofs += hsep;
|
||||||
ofs += icon->get_width();
|
ofs += icon->get_width();
|
||||||
Vector<StringName> sn = path.get_subnames();
|
|
||||||
for (int i = 0; i < sn.size(); i++) {
|
|
||||||
text += ".";
|
|
||||||
text += sn[i];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
icon_cache = type_icon;
|
icon_cache = type_icon;
|
||||||
|
|
||||||
|
@ -3536,7 +3526,10 @@ void AnimationTrackEditor::_animation_changed() {
|
||||||
if (key_edit && key_edit->setting) {
|
if (key_edit && key_edit->setting) {
|
||||||
//if editing a key, just update the edited track, makes refresh less costly
|
//if editing a key, just update the edited track, makes refresh less costly
|
||||||
if (key_edit->track < track_edits.size()) {
|
if (key_edit->track < track_edits.size()) {
|
||||||
track_edits[key_edit->track]->update();
|
if (animation->track_get_type(key_edit->track) == Animation::TYPE_BEZIER)
|
||||||
|
bezier_edit->update();
|
||||||
|
else
|
||||||
|
track_edits[key_edit->track]->update();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue