-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed auto-scroll in Animation window on adding new animation #75322
Conversation
@@ -747,6 +747,7 @@ void SpriteFramesEditor::_select_animation(const String &p_name, bool p_update_n | |||
if (!selected) { | |||
return; | |||
}; | |||
animations->scroll_to_item(selected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since _update_library()
may update the list, so it is better to write this after that just to be safe.
_update_library();
selected = animations->get_item_with_text(p_name);
if (!selected) {
return;
};
animations->scroll_to_item(selected);
However, this is too redundant, so the best solution is to do it in _update_library()
. Since _update_library()
has a p_skip_selector
argument to detect if a selection has been made, you can use that to separate cases like below:
TreeItem *selected = nullptr;
for (const StringName &E : anim_names) {
String name = E;
if (searching && name.to_lower().find(searched_string) < 0) {
continue;
}
TreeItem *it = animations->create_item(anim_root);
it->set_metadata(0, name);
it->set_text(0, name);
it->set_editable(0, true);
if (animated_sprite) {
if (name == String(animated_sprite->call("get_autoplay"))) {
it->set_icon(0, autoplay_icon);
}
}
if (E == edited_anim) {
it->select(0);
selected = it;
}
}
if (selected) {
animations->scroll_to_item(selected);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I get you correctly: you want to move scroll_to_item()
call to _update_library()
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please see the above example.
Superseded by #79743. Your contribution has been credited by the other PR, so thanks for your work and congrats with your first Godot PR! |
Fixed auto-scroll in Animation window
Linked issue: #74185
Just added one line in _select_animation, it's possibly the best place to add scroll to selected item