@@ -1456,6 +1456,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
14561456 add_track->set_button_icon (get_editor_theme_icon (SNAME (" Add" )));
14571457 loop->set_button_icon (get_editor_theme_icon (SNAME (" Loop" )));
14581458 time_icon->set_texture (get_editor_theme_icon (SNAME (" Time" )));
1459+ filter_track->set_right_icon (get_editor_theme_icon (SNAME (" Search" )));
14591460
14601461 add_track->get_popup ()->clear ();
14611462 add_track->get_popup ()->add_icon_item (get_editor_theme_icon (SNAME (" KeyValue" )), TTR (" Property Track..." ));
@@ -1483,6 +1484,8 @@ void AnimationTimelineEdit::_notification(int p_what) {
14831484 case NOTIFICATION_RESIZED: {
14841485 len_hb->set_position (Vector2 (get_size ().width - get_buttons_width (), 0 ));
14851486 len_hb->set_size (Size2 (get_buttons_width (), get_size ().height ));
1487+ int hsize_icon_width = get_editor_theme_icon (SNAME (" Hsize" ))->get_width ();
1488+ add_track_hb->set_size (Size2 (name_limit - ((hsize_icon_width + 16 ) * EDSCALE), 0 ));
14861489 } break ;
14871490
14881491 case NOTIFICATION_DRAW: {
@@ -1705,6 +1708,7 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, boo
17051708
17061709 if (animation.is_valid ()) {
17071710 len_hb->show ();
1711+ filter_track->show ();
17081712 if (read_only) {
17091713 add_track->hide ();
17101714 } else {
@@ -1713,14 +1717,15 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation, boo
17131717 play_position->show ();
17141718 } else {
17151719 len_hb->hide ();
1720+ filter_track->hide ();
17161721 add_track->hide ();
17171722 play_position->hide ();
17181723 }
17191724 queue_redraw ();
17201725}
17211726
17221727Size2 AnimationTimelineEdit::get_minimum_size () const {
1723- Size2 ms = add_track ->get_minimum_size ();
1728+ Size2 ms = filter_track ->get_minimum_size ();
17241729 const Ref<Font> font = get_theme_font (SceneStringName (font), SNAME (" Label" ));
17251730 const int font_size = get_theme_font_size (SceneStringName (font_size), SNAME (" Label" ));
17261731 ms.height = MAX (ms.height , font->get_height (font_size));
@@ -1927,6 +1932,8 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) {
19271932 if (dragging_hsize) {
19281933 int ofs = mm->get_position ().x - dragging_hsize_from;
19291934 name_limit = dragging_hsize_at + ofs;
1935+ int hsize_icon_width = get_editor_theme_icon (SNAME (" Hsize" ))->get_width ();
1936+ add_track_hb->set_size (Size2 (name_limit - ((hsize_icon_width + 16 ) * EDSCALE), 0 ));
19301937 // Make sure name_limit is clamped to the range that UI allows.
19311938 name_limit = get_name_limit ();
19321939 queue_redraw ();
@@ -1984,6 +1991,7 @@ void AnimationTimelineEdit::_bind_methods() {
19841991 ADD_SIGNAL (MethodInfo (" timeline_changed" , PropertyInfo (Variant::FLOAT, " position" ), PropertyInfo (Variant::BOOL, " timeline_only" )));
19851992 ADD_SIGNAL (MethodInfo (" track_added" , PropertyInfo (Variant::INT, " track" )));
19861993 ADD_SIGNAL (MethodInfo (" length_changed" , PropertyInfo (Variant::FLOAT, " size" )));
1994+ ADD_SIGNAL (MethodInfo (" filter_changed" ));
19871995
19881996 ClassDB::bind_method (D_METHOD (" update_values" ), &AnimationTimelineEdit::update_values);
19891997}
@@ -1997,10 +2005,21 @@ AnimationTimelineEdit::AnimationTimelineEdit() {
19972005 play_position->set_anchors_and_offsets_preset (PRESET_FULL_RECT);
19982006 play_position->connect (SceneStringName (draw), callable_mp (this , &AnimationTimelineEdit::_play_position_draw));
19992007
2008+ add_track_hb = memnew (HBoxContainer);
2009+ add_child (add_track_hb);
2010+
20002011 add_track = memnew (MenuButton);
2012+ add_track->set_tooltip_text (TTR (" Select a new track by type to add to this animation." ));
20012013 add_track->set_position (Vector2 (0 , 0 ));
2002- add_child (add_track);
2003- add_track->set_text (TTR (" Add Track" ));
2014+ add_track_hb->add_child (add_track);
2015+ filter_track = memnew (LineEdit);
2016+ filter_track->set_h_size_flags (SIZE_EXPAND_FILL);
2017+ filter_track->set_placeholder (TTR (" Filter Tracks" ));
2018+ filter_track->set_tooltip_text (TTR (" Filter tracks by entering part of their node name or property." ));
2019+ filter_track->connect (SceneStringName (text_changed), callable_mp ((AnimationTrackEditor *)this , &AnimationTrackEditor::_on_filter_updated));
2020+ filter_track->set_clear_button_enabled (true );
2021+ filter_track->hide ();
2022+ add_track_hb->add_child (filter_track);
20042023
20052024 len_hb = memnew (HBoxContainer);
20062025
@@ -4817,6 +4836,10 @@ bool AnimationTrackEditor::can_add_reset_key() const {
48174836 return false ;
48184837}
48194838
4839+ void AnimationTrackEditor::_on_filter_updated (const String &p_filter) {
4840+ emit_signal (SNAME (" filter_changed" ));
4841+ }
4842+
48204843void AnimationTrackEditor::_update_tracks () {
48214844 int selected = _get_track_selected ();
48224845
@@ -4878,6 +4901,15 @@ void AnimationTrackEditor::_update_tracks() {
48784901 }
48794902 }
48804903
4904+ String filter_text = timeline->filter_track ->get_text ();
4905+
4906+ if (!filter_text.is_empty ()) {
4907+ String target = animation->track_get_path (i);
4908+ if (!target.containsn (filter_text)) {
4909+ continue ;
4910+ }
4911+ }
4912+
48814913 if (animation->track_get_type (i) == Animation::TYPE_VALUE) {
48824914 NodePath path = animation->track_get_path (i);
48834915
@@ -7561,6 +7593,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
75617593 timeline->connect (" track_added" , callable_mp (this , &AnimationTrackEditor::_add_track));
75627594 timeline->connect (SceneStringName (value_changed), callable_mp (this , &AnimationTrackEditor::_timeline_value_changed));
75637595 timeline->connect (" length_changed" , callable_mp (this , &AnimationTrackEditor::_update_length));
7596+ timeline->connect (" filter_changed" , callable_mp (this , &AnimationTrackEditor::_update_tracks));
75647597
75657598 panner.instantiate ();
75667599 panner->set_scroll_zoom_factor (AnimationTimelineEdit::SCROLL_ZOOM_FACTOR_IN);
0 commit comments