Merge pull request #49255 from kleonc/sprite_frames_editor-anim-search-box
This commit is contained in:
commit
59629fdf20
2 changed files with 28 additions and 4 deletions
|
@ -424,6 +424,7 @@ void SpriteFramesEditor::_notification(int p_what) {
|
|||
zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
|
||||
new_anim->set_icon(get_icon("New", "EditorIcons"));
|
||||
remove_anim->set_icon(get_icon("Remove", "EditorIcons"));
|
||||
anim_search_box->set_right_icon(get_icon("Search", "EditorIcons"));
|
||||
split_sheet_zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons"));
|
||||
split_sheet_zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons"));
|
||||
split_sheet_zoom_in->set_icon(get_icon("ZoomMore", "EditorIcons"));
|
||||
|
@ -752,7 +753,7 @@ void SpriteFramesEditor::_animation_name_edited() {
|
|||
undo_redo->add_do_method(this, "_update_library");
|
||||
undo_redo->add_undo_method(this, "_update_library");
|
||||
|
||||
edited_anim = new_name;
|
||||
edited_anim = name;
|
||||
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
@ -818,6 +819,10 @@ void SpriteFramesEditor::_animation_remove_confirmed() {
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void SpriteFramesEditor::_animation_search_text_changed(const String &p_text) {
|
||||
_update_library();
|
||||
}
|
||||
|
||||
void SpriteFramesEditor::_animation_loop_changed() {
|
||||
if (updating) {
|
||||
return;
|
||||
|
@ -902,14 +907,19 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
|
|||
TreeItem *anim_root = animations->create_item();
|
||||
|
||||
List<StringName> anim_names;
|
||||
|
||||
frames->get_animation_list(&anim_names);
|
||||
|
||||
anim_names.sort_custom<StringName::AlphCompare>();
|
||||
|
||||
bool searching = anim_search_box->get_text().size();
|
||||
String searched_string = searching ? anim_search_box->get_text().to_lower() : String();
|
||||
|
||||
for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) {
|
||||
String name = E->get();
|
||||
|
||||
if (searching && name.to_lower().find(searched_string) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TreeItem *it = animations->create_item(anim_root);
|
||||
|
||||
it->set_metadata(0, name);
|
||||
|
@ -972,7 +982,6 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
|
|||
anim_loop->set_pressed(frames->get_animation_loop(edited_anim));
|
||||
|
||||
updating = false;
|
||||
//player->add_resource("default",resource);
|
||||
}
|
||||
|
||||
void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
|
||||
|
@ -1144,6 +1153,7 @@ void SpriteFramesEditor::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_animation_add"), &SpriteFramesEditor::_animation_add);
|
||||
ClassDB::bind_method(D_METHOD("_animation_remove"), &SpriteFramesEditor::_animation_remove);
|
||||
ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &SpriteFramesEditor::_animation_remove_confirmed);
|
||||
ClassDB::bind_method(D_METHOD("_animation_search_text_changed"), &SpriteFramesEditor::_animation_search_text_changed);
|
||||
ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &SpriteFramesEditor::_animation_loop_changed);
|
||||
ClassDB::bind_method(D_METHOD("_animation_fps_changed"), &SpriteFramesEditor::_animation_fps_changed);
|
||||
ClassDB::bind_method(D_METHOD("_tree_input"), &SpriteFramesEditor::_tree_input);
|
||||
|
@ -1188,6 +1198,13 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
|||
hbc_animlist->add_child(remove_anim);
|
||||
remove_anim->connect("pressed", this, "_animation_remove");
|
||||
|
||||
anim_search_box = memnew(LineEdit);
|
||||
hbc_animlist->add_child(anim_search_box);
|
||||
anim_search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
anim_search_box->set_placeholder(TTR("Filter animations"));
|
||||
anim_search_box->set_clear_button_enabled(true);
|
||||
anim_search_box->connect("text_changed", this, "_animation_search_text_changed");
|
||||
|
||||
animations = memnew(Tree);
|
||||
sub_vb->add_child(animations);
|
||||
animations->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
@ -1467,6 +1484,10 @@ SpriteFramesEditor::SpriteFramesEditor() {
|
|||
max_sheet_zoom = 16.0f * MAX(1.0f, EDSCALE);
|
||||
min_sheet_zoom = 0.01f * MAX(1.0f, EDSCALE);
|
||||
_zoom_reset();
|
||||
|
||||
// Ensure the anim search box is wide enough by default.
|
||||
// Not by setting its minimum size so it can still be shrinked if desired.
|
||||
set_split_offset(56 * EDSCALE);
|
||||
}
|
||||
|
||||
void SpriteFramesEditorPlugin::edit(Object *p_object) {
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "scene/2d/animated_sprite.h"
|
||||
#include "scene/gui/dialogs.h"
|
||||
#include "scene/gui/file_dialog.h"
|
||||
#include "scene/gui/line_edit.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/gui/tree.h"
|
||||
|
@ -68,6 +69,7 @@ class SpriteFramesEditor : public HSplitContainer {
|
|||
|
||||
ToolButton *new_anim;
|
||||
ToolButton *remove_anim;
|
||||
LineEdit *anim_search_box;
|
||||
|
||||
Tree *animations;
|
||||
SpinBox *anim_speed;
|
||||
|
@ -132,6 +134,7 @@ class SpriteFramesEditor : public HSplitContainer {
|
|||
void _animation_add();
|
||||
void _animation_remove();
|
||||
void _animation_remove_confirmed();
|
||||
void _animation_search_text_changed(const String &p_text);
|
||||
void _animation_loop_changed();
|
||||
void _animation_fps_changed(double p_value);
|
||||
|
||||
|
|
Loading…
Reference in a new issue