2
0
mirror of https://github.com/godotengine/godot.git synced 2025-04-13 01:00:35 +08:00

Merge pull request from SatLess/Hide-Function-Names

Support hiding functions calls in Method Tracks
This commit is contained in:
Rémi Verschelde 2025-03-19 12:25:57 +01:00
commit ffe262b12b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 41 additions and 2 deletions

@ -2235,8 +2235,21 @@ void AnimationTrackEdit::_notification(int p_what) {
offset_n = offset_n + editor->get_moving_selection_offset();
}
offset_n = offset_n * scale + limit;
float offset_last = limit_end;
if (i < animation->track_get_key_count(track) - 2) {
offset_last = animation->track_get_key_time(track, i + 2) - timeline->get_value();
if (editor->is_key_selected(track, i + 2) && editor->is_moving_selection()) {
offset_last = offset_last + editor->get_moving_selection_offset();
}
offset_last = offset_last * scale + limit;
}
int limit_string = (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) ? int(offset_last) : int(offset_n);
if (editor->is_key_selected(track, i) && editor->is_moving_selection()) {
limit_string = int(MAX(limit_end, offset_last));
}
draw_key_link(i, scale, int(offset), int(offset_n), limit, limit_end);
draw_key(i, scale, int(offset), editor->is_key_selected(track, i), limit, limit_string);
continue;
}
draw_key(i, scale, int(offset), editor->is_key_selected(track, i), limit, limit_end);
@ -2541,7 +2554,8 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
}
text += ")";
int limit = MAX(0, p_clip_right - p_x - icon_to_draw->get_width());
int limit = ((p_selected && editor->is_moving_selection()) || editor->is_function_name_pressed()) ? 0 : MAX(0, p_clip_right - p_x - icon_to_draw->get_width() * 2);
if (limit > 0) {
draw_string(font, Vector2(p_x + icon_to_draw->get_width(), int(get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)), text, HORIZONTAL_ALIGNMENT_LEFT, limit, font_size, color);
}
@ -5162,6 +5176,7 @@ void AnimationTrackEditor::_notification(int p_what) {
snap_keys->set_button_icon(get_editor_theme_icon(SNAME("SnapKeys")));
fps_compat->set_button_icon(get_editor_theme_icon(SNAME("FPS")));
view_group->set_button_icon(get_editor_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup")));
function_name_toggler->set_button_icon(get_editor_theme_icon(SNAME("MemberMethod")));
selected_filter->set_button_icon(get_editor_theme_icon(SNAME("AnimationFilter")));
imported_anim_warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
dummy_player_warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
@ -5176,6 +5191,8 @@ void AnimationTrackEditor::_notification(int p_what) {
const int track_separation = get_theme_constant(SNAME("track_v_separation"), SNAME("AnimationTrackEditor"));
track_vbox->add_theme_constant_override("separation", track_separation);
function_name_toggler->add_theme_color_override("icon_pressed_color", get_theme_color("icon_disabled_color", EditorStringName(Editor)));
} break;
case NOTIFICATION_READY: {
@ -7345,6 +7362,10 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) {
_update_tracks();
}
void AnimationTrackEditor::_toggle_function_names() {
_redraw_tracks();
}
void AnimationTrackEditor::_view_group_toggle() {
_update_tracks();
view_group->set_button_icon(get_editor_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup")));
@ -7359,6 +7380,10 @@ bool AnimationTrackEditor::is_grouping_tracks() {
return !view_group->is_pressed();
}
bool AnimationTrackEditor::is_function_name_pressed() {
return function_name_toggler->is_pressed();
}
void AnimationTrackEditor::_auto_fit() {
timeline->auto_fit();
}
@ -7652,6 +7677,16 @@ AnimationTrackEditor::AnimationTrackEditor() {
bottom_hf->add_child(bezier_edit_icon);
function_name_toggler = memnew(Button);
function_name_toggler->set_flat(true);
function_name_toggler->connect(SceneStringName(pressed), callable_mp(this, &AnimationTrackEditor::_toggle_function_names));
function_name_toggler->set_shortcut(ED_SHORTCUT("animation_editor/toggle_function_names", TTRC("Toggle method names")));
function_name_toggler->set_toggle_mode(true);
function_name_toggler->set_shortcut_in_tooltip(false);
function_name_toggler->set_tooltip_text(TTRC("Toggle function names in the track editor."));
bottom_hf->add_child(function_name_toggler);
selected_filter = memnew(Button);
selected_filter->set_flat(true);
selected_filter->connect(SceneStringName(pressed), callable_mp(this, &AnimationTrackEditor::_view_group_toggle)); // Same function works the same.

@ -801,6 +801,9 @@ class AnimationTrackEditor : public VBoxContainer {
void _anim_paste_keys(float p_ofs, bool p_ofs_valid, int p_track);
void _toggle_function_names();
Button *function_name_toggler = nullptr;
void _view_group_toggle();
Button *view_group = nullptr;
Button *selected_filter = nullptr;
@ -946,6 +949,7 @@ public:
bool is_marker_selected(const StringName &p_marker) const;
bool is_marker_moving_selection() const;
float get_marker_moving_selection_offset() const;
bool is_function_name_pressed();
/** If `p_from_mouse_event` is `true`, handle Shift key presses for precise snapping. */
void goto_prev_step(bool p_from_mouse_event);