Skip to content

Commit

Permalink
Merge pull request #19475 from YeldhamDev/animplayer_cosmetic
Browse files Browse the repository at this point in the history
Minor changes to the AnimationPlayer editor
  • Loading branch information
mhilbrunner authored Jul 5, 2018
2 parents c488a74 + 0218129 commit 9f82368
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
51 changes: 44 additions & 7 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
/*************************************************************************/
/* animation_track_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#include "animation_track_editor.h"
#include "animation_track_editor_plugins.h"
#include "editor/animation_bezier_editor.h"
Expand Down Expand Up @@ -719,6 +749,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
len_hb->set_position(Vector2(get_size().width - get_buttons_width(), 0));
len_hb->set_size(Size2(get_buttons_width(), get_size().height));
}

if (p_what == NOTIFICATION_DRAW) {

int key_range = get_size().width - get_buttons_width() - get_name_limit();
Expand Down Expand Up @@ -1670,27 +1701,27 @@ void AnimationTrackEdit::_path_entered(const String &p_text) {
String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {

if (check_rect.has_point(p_pos)) {
return TTR("Toggle this track on/off");
return TTR("Toggle this track on/off.");
}

if (path_rect.has_point(p_pos)) {
return animation->track_get_path(track);
}

if (update_mode_rect.has_point(p_pos)) {
return TTR("Update Mode (How this property is set).");
return TTR("Update Mode (How this property is set)");
}

if (interp_mode_rect.has_point(p_pos)) {
return TTR("Interpolation Mode");
}

if (loop_mode_rect.has_point(p_pos)) {
return TTR("Loop Wrap Mode (Interpolate end with beginning on loop");
return TTR("Loop Wrap Mode (Interpolate end with beginning on loop)");
}

if (remove_rect.has_point(p_pos)) {
return TTR("Remove this track");
return TTR("Remove this track.");
}

if (p_pos.x >= timeline->get_name_limit() && p_pos.x <= (get_size().width - timeline->get_buttons_width())) {
Expand Down Expand Up @@ -2442,12 +2473,16 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) {
if (animation.is_valid()) {
animation->connect("changed", this, "_animation_changed");

hscroll->show();
edit->set_disabled(false);
step->set_block_signals(true);
step->set_value(animation->get_step());
step->set_block_signals(false);
step->set_read_only(false);
snap->set_disabled(false);
} else {
hscroll->hide();
edit->set_disabled(true);
step->set_block_signals(true);
step->set_value(0);
step->set_block_signals(false);
Expand Down Expand Up @@ -3423,7 +3458,6 @@ MenuButton *AnimationTrackEditor::get_edit_menu() {

void AnimationTrackEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) {

zoom_icon->set_texture(get_icon("Zoom", "EditorIcons"));
snap->set_icon(get_icon("Snap", "EditorIcons"));
view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons"));
Expand All @@ -3436,7 +3470,6 @@ void AnimationTrackEditor::_notification(int p_what) {
}

if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {

update_keying();
EditorNode::get_singleton()->update_keying();
emit_signal("keying_changed");
Expand Down Expand Up @@ -4815,9 +4848,10 @@ AnimationTrackEditor::AnimationTrackEditor() {
timeline_vbox->set_custom_minimum_size(Size2(0, 150) * EDSCALE);

hscroll = memnew(HScrollBar);
timeline_vbox->add_child(hscroll);
hscroll->share(timeline);
hscroll->hide();
hscroll->connect("value_changed", this, "_update_scroll");
timeline_vbox->add_child(hscroll);
timeline->set_hscroll(hscroll);

track_vbox = memnew(VBoxContainer);
Expand Down Expand Up @@ -4860,6 +4894,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
step->set_step(0.01);
step->set_hide_slider(true);
step->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
step->set_tooltip(TTR("Animation step value."));
bottom_hb->add_child(step);
step->connect("value_changed", this, "_update_step");
step->set_read_only(true);
Expand All @@ -4882,6 +4917,8 @@ AnimationTrackEditor::AnimationTrackEditor() {
edit = memnew(MenuButton);
edit->set_text(TTR("Edit"));
edit->set_flat(false);
edit->set_disabled(true);
edit->set_tooltip(TTR("Animation properties."));
edit->get_popup()->add_item(TTR("Copy Tracks"), EDIT_COPY_TRACKS);
edit->get_popup()->add_item(TTR("Paste Tracks"), EDIT_PASTE_TRACKS);
edit->get_popup()->add_separator();
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/animation_player_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,8 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
//tool_anim->get_popup()->add_separator();
//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);

hb->add_child(memnew(VSeparator));

track_editor = memnew(AnimationTrackEditor);

hb->add_child(track_editor->get_edit_menu());
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4481,7 +4481,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_insert_button->set_flat(true);
key_insert_button->set_focus_mode(FOCUS_NONE);
key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY));
key_insert_button->set_tooltip(TTR("Insert Keys"));
key_insert_button->set_tooltip(TTR("Insert keys."));
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT));

animation_hb->add_child(key_insert_button);
Expand Down
1 change: 0 additions & 1 deletion scene/resources/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,6 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {

int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset, float p_end_offset) {

print_line("really insert key? ");
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, -1);
Expand Down

0 comments on commit 9f82368

Please sign in to comment.