mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Merge pull request #98558 from jasonmorgado/add-track-filter
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Add type filters to AnimationPlayer's "Add Track"
This commit is contained in:
commit
0f5f3bc954
@ -5297,6 +5297,28 @@ void AnimationTrackEditor::_add_track(int p_type) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adding_track_type = p_type;
|
adding_track_type = p_type;
|
||||||
|
Vector<StringName> valid_types;
|
||||||
|
switch (adding_track_type) {
|
||||||
|
case Animation::TYPE_BLEND_SHAPE: {
|
||||||
|
// Blend Shape is a property of MeshInstance3D.
|
||||||
|
valid_types.push_back(SNAME("MeshInstance3D"));
|
||||||
|
} break;
|
||||||
|
case Animation::TYPE_POSITION_3D:
|
||||||
|
case Animation::TYPE_ROTATION_3D:
|
||||||
|
case Animation::TYPE_SCALE_3D: {
|
||||||
|
// 3D Properties come from nodes inheriting Node3D.
|
||||||
|
valid_types.push_back(SNAME("Node3D"));
|
||||||
|
} break;
|
||||||
|
case Animation::TYPE_AUDIO: {
|
||||||
|
valid_types.push_back(SNAME("AudioStreamPlayer"));
|
||||||
|
valid_types.push_back(SNAME("AudioStreamPlayer2D"));
|
||||||
|
valid_types.push_back(SNAME("AudioStreamPlayer3D"));
|
||||||
|
} break;
|
||||||
|
case Animation::TYPE_ANIMATION: {
|
||||||
|
valid_types.push_back(SNAME("AnimationPlayer"));
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
pick_track->set_valid_types(valid_types);
|
||||||
pick_track->popup_scenetree_dialog(nullptr, root_node);
|
pick_track->popup_scenetree_dialog(nullptr, root_node);
|
||||||
pick_track->get_filter_line_edit()->clear();
|
pick_track->get_filter_line_edit()->clear();
|
||||||
pick_track->get_filter_line_edit()->grab_focus();
|
pick_track->get_filter_line_edit()->grab_focus();
|
||||||
|
@ -1684,24 +1684,30 @@ void SceneTreeDialog::_show_all_nodes_changed(bool p_button_pressed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
|
void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
|
||||||
if (p_valid.is_empty()) {
|
if (allowed_types_hbox) {
|
||||||
return;
|
allowed_types_hbox->queue_free();
|
||||||
|
allowed_types_hbox = nullptr;
|
||||||
|
valid_type_icons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
tree->set_valid_types(p_valid);
|
tree->set_valid_types(p_valid);
|
||||||
|
|
||||||
HBoxContainer *hbox = memnew(HBoxContainer);
|
if (p_valid.is_empty()) {
|
||||||
content->add_child(hbox);
|
return;
|
||||||
content->move_child(hbox, 0);
|
}
|
||||||
|
|
||||||
|
allowed_types_hbox = memnew(HBoxContainer);
|
||||||
|
content->add_child(allowed_types_hbox);
|
||||||
|
content->move_child(allowed_types_hbox, 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
Label *label = memnew(Label);
|
Label *label = memnew(Label);
|
||||||
hbox->add_child(label);
|
allowed_types_hbox->add_child(label);
|
||||||
label->set_text(TTR("Allowed:"));
|
label->set_text(TTR("Allowed:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
HFlowContainer *hflow = memnew(HFlowContainer);
|
HFlowContainer *hflow = memnew(HFlowContainer);
|
||||||
hbox->add_child(hflow);
|
allowed_types_hbox->add_child(hflow);
|
||||||
hflow->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
hflow->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
for (const StringName &type : p_valid) {
|
for (const StringName &type : p_valid) {
|
||||||
@ -1735,6 +1741,9 @@ void SceneTreeDialog::set_valid_types(const Vector<StringName> &p_valid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show_all_nodes->show();
|
show_all_nodes->show();
|
||||||
|
if (is_inside_tree()) {
|
||||||
|
_update_valid_type_icons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeDialog::_notification(int p_what) {
|
void SceneTreeDialog::_notification(int p_what) {
|
||||||
@ -1753,11 +1762,7 @@ void SceneTreeDialog::_notification(int p_what) {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_THEME_CHANGED: {
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
filter->set_right_icon(get_editor_theme_icon(SNAME("Search")));
|
_update_valid_type_icons();
|
||||||
for (TextureRect *trect : valid_type_icons) {
|
|
||||||
trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)), 0));
|
|
||||||
trect->set_texture(trect->get_meta("icon"));
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
@ -1766,6 +1771,14 @@ void SceneTreeDialog::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneTreeDialog::_update_valid_type_icons() {
|
||||||
|
filter->set_right_icon(get_editor_theme_icon(SNAME("Search")));
|
||||||
|
for (TextureRect *trect : valid_type_icons) {
|
||||||
|
trect->set_custom_minimum_size(Vector2(get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)), 0));
|
||||||
|
trect->set_texture(trect->get_meta("icon"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SceneTreeDialog::_cancel() {
|
void SceneTreeDialog::_cancel() {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,7 @@ class SceneTreeDialog : public ConfirmationDialog {
|
|||||||
LineEdit *filter = nullptr;
|
LineEdit *filter = nullptr;
|
||||||
CheckButton *show_all_nodes = nullptr;
|
CheckButton *show_all_nodes = nullptr;
|
||||||
LocalVector<TextureRect *> valid_type_icons;
|
LocalVector<TextureRect *> valid_type_icons;
|
||||||
|
HBoxContainer *allowed_types_hbox = nullptr;
|
||||||
|
|
||||||
void _select();
|
void _select();
|
||||||
void _cancel();
|
void _cancel();
|
||||||
@ -208,6 +209,7 @@ class SceneTreeDialog : public ConfirmationDialog {
|
|||||||
void _show_all_nodes_changed(bool p_button_pressed);
|
void _show_all_nodes_changed(bool p_button_pressed);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _update_valid_type_icons();
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user