diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 697027f41bb..da0833a69db 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1370,7 +1370,7 @@ int AnimationTimelineEdit::get_name_limit() const { } void AnimationTimelineEdit::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { + if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { add_track->set_icon(get_icon("Add", "EditorIcons")); loop->set_icon(get_icon("Loop", "EditorIcons")); time_icon->set_texture(get_icon("Time", "EditorIcons")); @@ -1841,6 +1841,16 @@ AnimationTimelineEdit::AnimationTimelineEdit() { //////////////////////////////////// void AnimationTrackEdit::_notification(int p_what) { + if (p_what == NOTIFICATION_THEME_CHANGED) { + if (animation.is_null()) { + return; + } + ERR_FAIL_INDEX(track, animation->get_track_count()); + + type_icon = _get_key_type_icon(); + selected_icon = get_icon("KeySelected", "EditorIcons"); + } + if (p_what == NOTIFICATION_DRAW) { if (animation.is_null()) { return; @@ -1858,14 +1868,6 @@ void AnimationTrackEdit::_notification(int p_what) { Ref font = get_font("font", "Label"); Color color = get_color("font_color", "Label"); - Ref type_icons[6] = { - get_icon("KeyValue", "EditorIcons"), - get_icon("KeyXform", "EditorIcons"), - get_icon("KeyCall", "EditorIcons"), - get_icon("KeyBezier", "EditorIcons"), - get_icon("KeyAudio", "EditorIcons"), - get_icon("KeyAnimation", "EditorIcons") - }; int hsep = get_constant("hseparation", "ItemList"); Color linecolor = color; linecolor.a = 0.2; @@ -1881,7 +1883,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref type_icon = type_icons[animation->track_get_type(track)]; + Ref type_icon = _get_key_type_icon(); draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; @@ -2321,19 +2323,10 @@ void AnimationTrackEdit::set_animation_and_track(const Ref &p_animati track = p_track; update(); - Ref type_icons[6] = { - get_icon("KeyValue", "EditorIcons"), - get_icon("KeyXform", "EditorIcons"), - get_icon("KeyCall", "EditorIcons"), - get_icon("KeyBezier", "EditorIcons"), - get_icon("KeyAudio", "EditorIcons"), - get_icon("KeyAnimation", "EditorIcons") - }; - ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); - type_icon = type_icons[animation->track_get_type(track)]; + type_icon = _get_key_type_icon(); selected_icon = get_icon("KeySelected", "EditorIcons"); } @@ -2431,6 +2424,18 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant return (!prop_exists || Variant::can_convert(p_key_value.get_type(), r_valid_type)); } +Ref AnimationTrackEdit::_get_key_type_icon() const { + Ref type_icons[6] = { + get_icon("KeyValue", "EditorIcons"), + get_icon("KeyXform", "EditorIcons"), + get_icon("KeyCall", "EditorIcons"), + get_icon("KeyBezier", "EditorIcons"), + get_icon("KeyAudio", "EditorIcons"), + get_icon("KeyAnimation", "EditorIcons") + }; + return type_icons[animation->track_get_type(track)]; +} + String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (check_rect.has_point(p_pos)) { return TTR("Toggle this track on/off."); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 951225aa74b..ec02fbd3d0f 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -180,6 +180,8 @@ class AnimationTrackEdit : public Control { void _play_position_draw(); bool _is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const; + Ref _get_key_type_icon() const; + mutable int dropping_at; float insert_at_pos; bool moving_selection_attempt; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 3e80b4cb9a5..06118692a53 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -152,6 +152,8 @@ void AnimationPlayerEditor::_notification(int p_what) { ITEM_ICON(TOOL_EDIT_TRANSITIONS, "Blend"); ITEM_ICON(TOOL_EDIT_RESOURCE, "Edit"); ITEM_ICON(TOOL_REMOVE_ANIM, "Remove"); + + _update_animation_list_icons(); } break; } } @@ -860,22 +862,13 @@ void AnimationPlayerEditor::_update_player() { int active_idx = -1; for (List::Element *E = animlist.front(); E; E = E->next()) { - Ref icon; - if (E->get() == player->get_autoplay()) { - if (E->get() == "RESET") { - icon = autoplay_reset_icon; - } else { - icon = autoplay_icon; - } - } else if (E->get() == "RESET") { - icon = reset_icon; - } - animation->add_icon_item(icon, E->get()); + animation->add_item(E->get()); if (player->get_assigned_animation() == E->get()) { active_idx = animation->get_item_count() - 1; } } + _update_animation_list_icons(); updating = false; if (active_idx != -1) { @@ -904,6 +897,30 @@ void AnimationPlayerEditor::_update_player() { _update_animation(); } +void AnimationPlayerEditor::_update_animation_list_icons() { + List animlist; + if (player) { + player->get_animation_list(&animlist); + } + + for (int i = 0; i < animation->get_item_count(); i++) { + String name = animation->get_item_text(i); + + Ref icon; + if (name == player->get_autoplay()) { + if (name == "RESET") { + icon = autoplay_reset_icon; + } else { + icon = autoplay_icon; + } + } else if (name == "RESET") { + icon = reset_icon; + } + + animation->set_item_icon(i, icon); + } +} + void AnimationPlayerEditor::edit(AnimationPlayer *p_player) { if (player && pin->is_pressed()) { return; // Ignore, pinned. diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 11fd8e9f0cc..a291d59d524 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -193,6 +193,7 @@ class AnimationPlayerEditor : public VBoxContainer { void _list_changed(); void _update_animation(); void _update_player(); + void _update_animation_list_icons(); void _blend_edited(); void _animation_player_changed(Object *p_pl);