Skip to content
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

Closed

Conversation

DarellLdark
Copy link
Contributor

@DarellLdark DarellLdark commented Mar 25, 2023

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

@DarellLdark DarellLdark changed the title Fixed auto-scroll in Animation window Fixed auto-scroll in Animation window on adding new animation Mar 25, 2023
@Calinou Calinou added this to the 4.1 milestone Mar 25, 2023
@@ -747,6 +747,7 @@ void SpriteFramesEditor::_select_animation(const String &p_name, bool p_update_n
if (!selected) {
return;
};
animations->scroll_to_item(selected);
Copy link
Member

@TokageItLab TokageItLab May 26, 2023

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);
}

Copy link
Contributor Author

@DarellLdark DarellLdark Jun 17, 2023

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?

Copy link
Member

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.

@YuriSizov
Copy link
Contributor

Superseded by #79743. Your contribution has been credited by the other PR, so thanks for your work and congrats with your first Godot PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants