summaryrefslogtreecommitdiffstats
path: root/editor/plugins/sprite_frames_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-19 10:11:50 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-19 10:11:50 +0200
commit150acefb39baf20f28ef92ee438add6571d1826b (patch)
tree32e9e1da41ed6df59f703ae4061fb9fff9b1cb2c /editor/plugins/sprite_frames_editor_plugin.cpp
parent9dfae0eb0f747cd0b0bf21cef1348737c4bdbe24 (diff)
parent9cf2d0f058c526f1e49129e1b656de36c58c15e7 (diff)
downloadredot-engine-150acefb39baf20f28ef92ee438add6571d1826b.tar.gz
Merge pull request #77221 from hakro/fix-animation-frames-editor
Hide Animation Frames section when there are no animations
Diffstat (limited to 'editor/plugins/sprite_frames_editor_plugin.cpp')
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 12d27fc608..9ff9b521d6 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1198,7 +1198,13 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
List<StringName> anim_names;
frames->get_animation_list(&anim_names);
anim_names.sort_custom<StringName::AlphCompare>();
-
+ if (!anim_names.size()) {
+ missing_anim_label->show();
+ anim_frames_vb->hide();
+ return;
+ }
+ missing_anim_label->hide();
+ anim_frames_vb->show();
bool searching = anim_search_box->get_text().size();
String searched_string = searching ? anim_search_box->get_text().to_lower() : String();
@@ -1705,12 +1711,22 @@ SpriteFramesEditor::SpriteFramesEditor() {
delete_anim->set_shortcut_context(animations);
delete_anim->set_shortcut(ED_SHORTCUT("sprite_frames/delete_animation", TTR("Delete Animation"), Key::KEY_DELETE));
- VBoxContainer *vbc = memnew(VBoxContainer);
- add_child(vbc);
- vbc->set_h_size_flags(SIZE_EXPAND_FILL);
+ missing_anim_label = memnew(Label);
+ missing_anim_label->set_text(TTR("This resource does not have any animations."));
+ missing_anim_label->set_h_size_flags(SIZE_EXPAND_FILL);
+ missing_anim_label->set_v_size_flags(SIZE_EXPAND_FILL);
+ missing_anim_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
+ missing_anim_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
+ missing_anim_label->hide();
+ add_child(missing_anim_label);
+
+ anim_frames_vb = memnew(VBoxContainer);
+ add_child(anim_frames_vb);
+ anim_frames_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ anim_frames_vb->hide();
sub_vb = memnew(VBoxContainer);
- vbc->add_margin_child(TTR("Animation Frames:"), sub_vb, true);
+ anim_frames_vb->add_margin_child(TTR("Animation Frames:"), sub_vb, true);
HFlowContainer *hfc = memnew(HFlowContainer);
sub_vb->add_child(hfc);